diff --git a/CMakeLists.txt b/CMakeLists.txt index 6105696a81e83d57a93184bbf344f782ec3045c8..c055b07acb248fa5d1a000583dd0b5472e246327 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,12 @@ else() endif() include(MorseInit) include(GenPkgConfig) +include(FortranCInterface) +# Ensure that the fortran compiler and c compiler specified are compatible +# ------------------------------------------------------------------------ +FortranCInterface_VERIFY() +FortranCInterface_HEADER(${CMAKE_CURRENT_BINARY_DIR}/include/morse_mangling.h + MACRO_NAMESPACE "MORSE_") ############################################# # # @@ -959,12 +965,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup") endif() -# Add define for Fortran Mangling (should be defined somewhere else) -# ------------------------------------------------------------------ -message("-- ${Blue}Add definition ADD_" - " - For Fortran mangling${ColourReset}") -set(ADD_ 1) - #------------------------------------------------------------------------------ if(CHAMELEON_SCHED_STARPU) link_directories(${STARPU_LIBRARY_DIRS_DEP}) diff --git a/control/CMakeLists.txt b/control/CMakeLists.txt index dddb507e17a8ea96ad72fa605eedf497b6983c8f..e1861ba32614c3f29d30a5ead45bc5fecb0ae53e 100644 --- a/control/CMakeLists.txt +++ b/control/CMakeLists.txt @@ -3,7 +3,7 @@ # @copyright (c) 2009-2014 The University of Tennessee and The University # of Tennessee Research Foundation. # All rights reserved. -# @copyright (c) 2012-2014 Inria. All rights reserved. +# @copyright (c) 2012-2017 Inria. All rights reserved. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. # ### @@ -22,6 +22,7 @@ # @author Cedric Castagnede # @author Emmanuel Agullo # @author Mathieu Faverge +# @author Florent Pruvost # @date 13-07-2012 # ### @@ -52,6 +53,7 @@ set(CHAMELEON_HDRS descriptor.h gkkleader.h global.h + morse_f77.h morsewinthread.h tile.h workspace.h diff --git a/control/common.h b/control/common.h index 194359d3b1658da48915651773335cea23f67e79..a6890efa05c744634e2c4993988757cdeb725d9d 100644 --- a/control/common.h +++ b/control/common.h @@ -31,11 +31,6 @@ #ifndef _MORSE_COMMON_H_ #define _MORSE_COMMON_H_ -#include <stdlib.h> -#include <stdio.h> -#include <math.h> -#include <string.h> -#include <ctype.h> #if defined( _WIN32 ) || defined( _WIN64 ) #include <io.h> @@ -94,30 +89,6 @@ #include "control/tile.h" #include "control/async.h" -/** **************************************************************************** - * Determine FORTRAN names - **/ -#if defined(ADD_) -#define MORSE_FNAME(lcname, UCNAME) morse_##lcname##_ -#define MORSE_TILE_FNAME(lcname, UCNAME) morse_##lcname##_tile_ -#define MORSE_ASYNC_FNAME(lcname, UCNAME) morse_##lcname##_tile_async_ -#define MORSE_WS_FNAME(lcname, UCNAME) morse_alloc_workspace_##lcname##_ -#define MORSE_WST_FNAME(lcname, UCNAME) morse_alloc_workspace_##lcname##_tile_ -#elif defined(NOCHANGE) -#define MORSE_FNAME(lcname, UCNAME) morse_##lcname -#define MORSE_TILE_FNAME(lcname, UCNAME) morse_##lcname##_tile -#define MORSE_ASYNC_FNAME(lcname, UCNAME) morse_##lcname##_tile_async -#define MORSE_WS_FNAME(lcname, UCNAME) morse_alloc_workspace_##lcname -#define MORSE_WST_FNAME(lcname, UCNAME) morse_alloc_workspace_##lcname##_tile -#elif defined(UPCASE) -#define MORSE_FNAME(lcname, UCNAME) MORSE_##UCNAME -#define MORSE_TILE_FNAME(lcname, UCNAME) MORSE_##UCNAME##_TILE -#define MORSE_ASYNC_FNAME(lcname, UCNAME) MORSE_##UCNAME##_TILE_ASYNC -#define MORSE_WS_FNAME(lcname, UCNAME) MORSE_ALLOC_WORKSPACE_##UCNAME -#define MORSE_WST_FNAME(lcname, UCNAME) MORSE_ALLOC_WORKSPACE_##UCNAME##_TILE -#endif - - /******************************************************************************* * Global shortcuts **/ diff --git a/control/config.h.in b/control/config.h.in index 48c3ce5aa77dae52d2e5f4b7b39ea116def31699..1194dc083e6de219d4f5db6eefd1aba10ed1f8dc 100644 --- a/control/config.h.in +++ b/control/config.h.in @@ -28,9 +28,6 @@ /* inherit from public chameleon's definitions */ #include "include/chameleon_config.h" -/* For BLAS Fortran mangling */ -#cmakedefine ADD_ - /* StarPU functions */ #cmakedefine HAVE_STARPU_FXT_PROFILING #cmakedefine HAVE_STARPU_IDLE_PREFETCH diff --git a/control/morse_f77.c b/control/morse_f77.c index fc60d10d8e094c74436728735f403dffb47e1515..a988f12883e18cc84a3beaad038585d2b4fd1700 100644 --- a/control/morse_f77.c +++ b/control/morse_f77.c @@ -3,7 +3,7 @@ * @copyright (c) 2009-2014 The University of Tennessee and The University * of Tennessee Research Foundation. * All rights reserved. - * @copyright (c) 2012-2014 Inria. All rights reserved. + * @copyright (c) 2012-2017 Inria. All rights reserved. * @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. * **/ @@ -16,98 +16,96 @@ * MORSE is a software package provided by Univ. of Tennessee, * Univ. of California Berkeley and Univ. of Colorado Denver * - * @version 0.9.0 + * @version 1.0.0 * @author Bilel Hadri * @author Cedric Castagnede + * @author Florent Pruvost * @date 2010-11-15 * **/ #include <stdlib.h> #include "control/common.h" #include "morse.h" - -#ifdef ADD_ - #define MORSE_INIT morse_init_ - #define MORSE_FINALIZE morse_finalize_ - #define MORSE_ENABLE morse_enable_ - #define MORSE_DISABLE morse_disable_ - #define MORSE_SET morse_set_ - #define MORSE_GET morse_get_ - #define MORSE_DEALLOC_HANDLE morse_dealloc_handle_ - #define MORSE_VERSION morse_version_ - #define MORSE_DESC_CREATE morse_desc_create_ - #define MORSE_DESC_DESTROY morse_desc_destroy_ - #define MORSE_LAPACK_TO_TILE morse_lapack_to_tile_ - #define MORSE_TILE_TO_LAPACK morse_tile_to_lapack_ -#elif defined (NOCHANGE) - #define MORSE_INIT morse_init - #define MORSE_FINALIZE morse_finalize - #define MORSE_ENABLE morse_enable - #define MORSE_DISABLE morse_disable - #define MORSE_SET morse_set - #define MORSE_GET morse_get - #define MORSE_DEALLOC_HANDLE morse_dealloc_handle - #define MORSE_VERSION morse_version - #define MORSE_DESC_CREATE morse_desc_create - #define MORSE_DESC_DESTROY morse_desc_destroy - #define MORSE_LAPACK_TO_TILE morse_lapack_to_tile - #define MORSE_TILE_TO_LAPACK morse_tile_to_lapack -#endif +#include "morse_f77.h" #ifdef __cplusplus extern "C" { #endif -/******************************************************************************* - * FORTRAN API - auxiliary function prototypes - **/ -void MORSE_INIT(int *CORES, int *NGPUS, int *INFO) -{ *INFO = MORSE_Init(*CORES, *NGPUS); } - -void MORSE_FINALIZE(int *INFO) -{ *INFO = MORSE_Finalize(); } - -void MORSE_ENABLE(MORSE_enum *lever, int *INFO) -{ *INFO = MORSE_Enable(*lever); } - -void MORSE_DISABLE(MORSE_enum *lever, int *INFO) -{ *INFO = MORSE_Disable(*lever); } - -void MORSE_SET(MORSE_enum *param, int *value, int *INFO) -{ *INFO = MORSE_Set(*param, *value); } - -void MORSE_GET(MORSE_enum *param, int *value, int *INFO) -{ *INFO = MORSE_Get(*param, value); } - -void MORSE_DEALLOC_HANDLE(size_t *sp, int *INFO) -{ free((void *)(*sp)); - *INFO = MORSE_SUCCESS; } - -void MORSE_VERSION(int *VER_MAJOR, int *VER_MINOR, int *VER_MICRO, int *INFO) -{ - *VER_MAJOR = CHAMELEON_VERSION_MAJOR; - *VER_MINOR = CHAMELEON_VERSION_MINOR; - *VER_MICRO = CHAMELEON_VERSION_MICRO; - *INFO = MORSE_SUCCESS; -} - -/***************************************************************************//** - * FORTRAN API - descriptor allocation and deallocation - **/ - void MORSE_DESC_CREATE(MORSE_desc_t **desc, void *mat, MORSE_enum *dtyp, int *mb, int *nb, int *bsiz, int *lm, int *ln, int *i, int *j, int *m, int *n, int *p, int *q, int *INFO) -{ *INFO = MORSE_Desc_Create(desc, mat, *dtyp, *mb, *nb, *bsiz, *lm, *ln, *i, *j, *m, *n, *p, *q); } - -void MORSE_DESC_DESTROY(MORSE_desc_t **desc, int *INFO) -{ *INFO = MORSE_Desc_Destroy(desc); } - -/***************************************************************************//** - * FORTRAN API - conversion from LAPACK F77 matrix layout to tile layout - **/ -void MORSE_LAPACK_TO_TILE(intptr_t *Af77, int *LDA, intptr_t *A, int *INFO) -{ *INFO = MORSE_Lapack_to_Tile( (void *)Af77, *LDA, (MORSE_desc_t *)(*A)); } - -void MORSE_TILE_TO_LAPACK(intptr_t *A, intptr_t *Af77, int *LDA, int *INFO) -{ *INFO = MORSE_Tile_to_Lapack((MORSE_desc_t *)(*A), (void *)Af77, *LDA); } + /******************************************************************************* + * FORTRAN API - auxiliary function prototypes + **/ + void MORSE_INIT(int *CORES, int *NGPUS, int *INFO) + { *INFO = MORSE_Init(*CORES, *NGPUS); } + + void MORSE_FINALIZE(int *INFO) + { *INFO = MORSE_Finalize(); } + + void MORSE_ENABLE(MORSE_enum *lever, int *INFO) + { *INFO = MORSE_Enable(*lever); } + + void MORSE_DISABLE(MORSE_enum *lever, int *INFO) + { *INFO = MORSE_Disable(*lever); } + + void MORSE_SET(MORSE_enum *param, int *value, int *INFO) + { *INFO = MORSE_Set(*param, *value); } + + void MORSE_GET(MORSE_enum *param, int *value, int *INFO) + { *INFO = MORSE_Get(*param, value); } + + void MORSE_DEALLOC_HANDLE(size_t *sp, int *INFO) + { free((void *)(*sp)); + *INFO = MORSE_SUCCESS; } + + void MORSE_VERSION(int *VER_MAJOR, int *VER_MINOR, int *VER_MICRO, int *INFO) + { + *VER_MAJOR = CHAMELEON_VERSION_MAJOR; + *VER_MINOR = CHAMELEON_VERSION_MINOR; + *VER_MICRO = CHAMELEON_VERSION_MICRO; + *INFO = MORSE_SUCCESS; + } + + /*************************************************************************** + * FORTRAN API - descriptor allocation and deallocation + **/ + void MORSE_DESC_CREATE(MORSE_desc_t **desc, void *mat, MORSE_enum *dtyp, + int *mb, int *nb, int *bsiz, int *lm, int *ln, + int *i, int *j, int *m, int *n, int *p, int *q, + int *INFO) + { *INFO = MORSE_Desc_Create(desc, mat, *dtyp, *mb, *nb, *bsiz, *lm, *ln, *i, *j, *m, *n, *p, *q); } + void MORSE_DESC_CREATE_OOC(MORSE_desc_t **desc, MORSE_enum *dtyp, + int *mb, int *nb, int *bsiz, int *lm, int *ln, + int *i, int *j, int *m, int *n, int *p, int *q, + int *INFO) + { *INFO = MORSE_Desc_Create_OOC(desc, *dtyp, *mb, *nb, *bsiz, *lm, *ln, *i, *j, *m, *n, *p, *q); } + void MORSE_DESC_CREATE_USER(MORSE_desc_t **descptr, void *mat, MORSE_enum *dtyp, + int *mb, int *nb, int *bsiz, int *lm, int *ln, + int *i, int *j, int *m, int *n, int *p, int *q, + void* (*get_blkaddr)( const MORSE_desc_t*, int, int ), + int (*get_blkldd) ( const MORSE_desc_t*, int ), + int (*get_rankof) ( const MORSE_desc_t*, int, int ), + int *INFO) + { *INFO = MORSE_Desc_Create_User(descptr, mat, *dtyp, *mb, *nb, *bsiz, *lm, *ln, *i, *j, *m, *n, *p, *q, + get_blkaddr, get_blkldd, get_rankof); } + void MORSE_DESC_CREATE_OOC_USER(MORSE_desc_t **descptr, MORSE_enum *dtyp, + int *mb, int *nb, int *bsiz, int *lm, int *ln, + int *i, int *j, int *m, int *n, int *p, int *q, + int (*get_rankof) ( const MORSE_desc_t*, int, int ), + int *INFO) + { *INFO = MORSE_Desc_Create_OOC_User(descptr, *dtyp, *mb, *nb, *bsiz, *lm, *ln, *i, *j, *m, *n, *p, *q, + get_rankof); } + + void MORSE_DESC_DESTROY(MORSE_desc_t **desc, int *INFO) + { *INFO = MORSE_Desc_Destroy(desc); } + + /*************************************************************************** + * FORTRAN API - conversion from LAPACK F77 matrix layout to tile layout + **/ + void MORSE_LAPACK_TO_TILE(intptr_t *Af77, int *LDA, intptr_t *A, int *INFO) + { *INFO = MORSE_Lapack_to_Tile( (void *)Af77, *LDA, (MORSE_desc_t *)(*A)); } + + void MORSE_TILE_TO_LAPACK(intptr_t *A, intptr_t *Af77, int *LDA, int *INFO) + { *INFO = MORSE_Tile_to_Lapack((MORSE_desc_t *)(*A), (void *)Af77, *LDA); } #ifdef __cplusplus } diff --git a/control/morse_f77.h b/control/morse_f77.h new file mode 100644 index 0000000000000000000000000000000000000000..ed898be11aa9ba076492395540438b476703423d --- /dev/null +++ b/control/morse_f77.h @@ -0,0 +1,54 @@ +/** + * + * @copyright (c) 2009-2014 The University of Tennessee and The University + * of Tennessee Research Foundation. + * All rights reserved. + * @copyright (c) 2012-2017 Inria. All rights reserved. + * @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. + * + **/ + +/** + * + * @file morse_f77.h + * + * MORSE Fortran names + * MORSE is a software package provided by Univ. of Tennessee, + * Univ. of California Berkeley and Univ. of Colorado Denver + * + * @version 1.0.0 + * @author Florent Pruvost + * @date 2017-05-03 + * + **/ +#ifndef _MORSE_F77_H_ +#define _MORSE_F77_H_ + +#include "include/morse_mangling.h" + +/** **************************************************************************** + * Determine FORTRAN names + **/ +#define MORSE_FNAME(lcname, UCNAME) MORSE_GLOBAL(morse_##lcname, MORSE_##UCNAME) +#define MORSE_TILE_FNAME(lcname, UCNAME) MORSE_GLOBAL(morse_##lcname##_tile, MORSE_##UCNAME##_TILE) +#define MORSE_ASYNC_FNAME(lcname, UCNAME) MORSE_GLOBAL(morse_##lcname##_tile_async, MORSE_##UCNAME##_TILE_ASYNC) +#define MORSE_WS_FNAME(lcname, UCNAME) MORSE_GLOBAL(morse_alloc_workspace_##lcname, MORSE_ALLOC_WORKSPACE_##UCNAME) +#define MORSE_WST_FNAME(lcname, UCNAME) MORSE_GLOBAL(morse_alloc_workspace_##lcname##_tile, MORSE_ALLOC_WORKSPACE_##UCNAME##_TILE) + +#define MORSE_INIT MORSE_GLOBAL(morse_init, MORSE_INIT) +#define MORSE_FINALIZE MORSE_GLOBAL(morse_finalize, MORSE_FINALIZE) +#define MORSE_ENABLE MORSE_GLOBAL(morse_enable, MORSE_ENABLE) +#define MORSE_DISABLE MORSE_GLOBAL(morse_disable, MORSE_DISABLE) +#define MORSE_SET MORSE_GLOBAL(morse_set, MORSE_SET) +#define MORSE_GET MORSE_GLOBAL(morse_get, MORSE_GET) +#define MORSE_DEALLOC_HANDLE MORSE_GLOBAL(morse_dealloc_handle, MORSE_DEALLOC_HANDLE) +#define MORSE_VERSION MORSE_GLOBAL(morse_version, MORSE_VERSION) +#define MORSE_DESC_CREATE MORSE_GLOBAL(morse_desc_create, MORSE_DESC_CREATE) +#define MORSE_DESC_CREATE_OOC MORSE_GLOBAL(morse_desc_create_ooc, MORSE_DESC_CREATE_OOC) +#define MORSE_DESC_CREATE_USER MORSE_GLOBAL(morse_desc_create_user, MORSE_DESC_CREATE_USER) +#define MORSE_DESC_CREATE_OOC_USER MORSE_GLOBAL(morse_desc_create_ooc_user, MORSE_DESC_CREATE_OOC_USER) +#define MORSE_DESC_DESTROY MORSE_GLOBAL(morse_desc_destroy, MORSE_DESC_DESTROY) +#define MORSE_LAPACK_TO_TILE MORSE_GLOBAL(morse_lapack_to_tile, MORSE_LAPACK_TO_TILE) +#define MORSE_TILE_TO_LAPACK MORSE_GLOBAL(morse_tile_to_lapack, MORSE_TILE_TO_LAPACK) + +#endif diff --git a/control/morse_f90.f90 b/control/morse_f90.f90 index 198e0c8bbd1733c73bfa6b899cefb43251bee1fc..fc24f6a6318fb241e6cb687ccdcec71f1fb8ece6 100644 --- a/control/morse_f90.f90 +++ b/control/morse_f90.f90 @@ -182,6 +182,43 @@ module morse end function MORSE_Desc_Create_c end interface + interface + function MORSE_Desc_Create_OOC_c(desc, dtyp, mb, nb, bsiz, lm, ln, i, j, m, n, p, q) & + & bind(c, name='MORSE_Desc_Create_OOC') + use iso_c_binding + integer(kind=c_int) :: MORSE_Desc_Create_OOC_c + type(c_ptr) :: desc + integer(kind=c_int), value :: dtyp + integer(kind=c_int), value :: mb, nb, bsiz, lm, ln, i, j, m, n,p, q + end function MORSE_Desc_Create_OOC_c + end interface + + interface + function MORSE_Desc_Create_User_c(desc, mat, dtyp, mb, nb, bsiz, lm, ln, i, j, m, n, p, q, get_blkaddr, get_blkldd, get_rankof) & + & bind(c, name='MORSE_Desc_Create_User') + use iso_c_binding + integer(kind=c_int) :: MORSE_Desc_Create_User_c + type(c_ptr) :: desc + type(c_ptr), value :: mat + integer(kind=c_int), value :: dtyp + integer(kind=c_int), value :: mb, nb, bsiz, lm, ln, i, j, m, n, p, q + type(c_ptr) :: get_blkaddr + type(c_ptr), value :: get_blkldd, get_rankof + end function MORSE_Desc_Create_User_c + end interface + + interface + function MORSE_Desc_Create_OOC_User_c(desc, dtyp, mb, nb, bsiz, lm, ln, i, j, m, n, p, q, get_rankof) & + & bind(c, name='MORSE_Desc_Create_OOC_User') + use iso_c_binding + integer(kind=c_int) :: MORSE_Desc_Create_OOC_User_c + type(c_ptr) :: desc + integer(kind=c_int), value :: dtyp + integer(kind=c_int), value :: mb, nb, bsiz, lm, ln, i, j, m, n, p, q + type(c_ptr), value :: get_rankof + end function MORSE_Desc_Create_OOC_User_c + end interface + interface function MORSE_Desc_Destroy_c(desc) & & bind(c, name='MORSE_Desc_Destroy') diff --git a/control/morse_zf77.c b/control/morse_zf77.c index b98cd09f96f1682bd9898bbcc6f6a15d4b4c6273..8ea877f355cf352aebc047f2d8d5a65b79a47501 100644 --- a/control/morse_zf77.c +++ b/control/morse_zf77.c @@ -3,7 +3,7 @@ * @copyright (c) 2009-2014 The University of Tennessee and The University * of Tennessee Research Foundation. * All rights reserved. - * @copyright (c) 2012-2014 Inria. All rights reserved. + * @copyright (c) 2012-2017 Inria. All rights reserved. * @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. * **/ @@ -24,12 +24,14 @@ * @author Mathieu Faverge * @author Emmanuel Agullo * @author Cedric Castagnede + * @author Florent Pruvost * @date 2010-11-15 * @precisions normal z -> c d s * **/ #include <stdlib.h> #include "control/common.h" +#include "control/morse_f77.h" #undef REAL #define COMPLEX diff --git a/example/link_chameleon/CMakeLists.txt b/example/link_chameleon/CMakeLists.txt index e13eab1a9e4a85ad5aa099fd8eb13809fc8943cb..957ce2206d02448d71e2231c2492f356cef8ae6b 100644 --- a/example/link_chameleon/CMakeLists.txt +++ b/example/link_chameleon/CMakeLists.txt @@ -17,10 +17,11 @@ elseif (MORSE_CHAMELEON_USE_STARPU) endif() if (MORSE_DISTRIB_DIR) - set( MORSE_CMAKE_MODULE_DIR "${MORSE_DISTRIB_DIR}/cmake_modules/morse" CACHE PATH - "Directory where to find MORSE CMake modules (cmake_modules/morse)") + set( MORSE_CMAKE_MODULE_DIR "${MORSE_DISTRIB_DIR}/morse_cmake/modules" CACHE PATH + "Directory where to find MORSE CMake modules (morse_cmake/modules)") list(APPEND CMAKE_MODULE_PATH "${MORSE_CMAKE_MODULE_DIR}") list(APPEND CMAKE_MODULE_PATH "${MORSE_CMAKE_MODULE_DIR}/find") + message(STATUS "MORSE_CMAKE_MODULE_DIR : ${MORSE_CMAKE_MODULE_DIR}/morse_cmake/modules") include(MorseInit) # Detect CHAMELEON @@ -39,8 +40,10 @@ if (MORSE_DISTRIB_DIR) endif() # link_chameleon exe - add_executable(link_chameleon link_chameleon.c) - target_link_libraries(link_chameleon ${CHAMELEON_LIBRARIES_DEP}) + add_executable(link_chameleon_c link_chameleon.c) + target_link_libraries(link_chameleon_c ${CHAMELEON_LIBRARIES_DEP}) + add_executable(link_chameleon_f link_chameleon.f90) + target_link_libraries(link_chameleon_f ${CHAMELEON_LIBRARIES_DEP}) else() message(STATUS "MORSE_DISTRIB_DIR is not set") message(STATUS "Please indicate where is located your MORSE distribution directory." diff --git a/example/link_chameleon/README.org b/example/link_chameleon/README.org new file mode 100644 index 0000000000000000000000000000000000000000..90e09e0174788d929565f2282cef91883190ef09 --- /dev/null +++ b/example/link_chameleon/README.org @@ -0,0 +1,35 @@ +#+TITLE: How to link with Chameleon +#+LANGUAGE: en +#+OPTIONS: H:3 num:t \n:nil @:t ::t |:t _:nil ^:nil -:t f:t *:t <:t +#+OPTIONS: TeX:t LaTeX:t skip:nil d:nil pri:nil tags:not-in-toc html-style:nil + +Install Chameleon and its dependencies +#+begin_src +# load an environment with dependencies available +# for example +spack install chameleon@master +spack load openblas +spack load hwloc +spack load starpu +spack load chameleon +# alternativaly use pkg-config and/or update your CPATH and LD_LIBRARY_PATH +# for example +export PKG_CONFIG_PATH=/where/is/installed/chameleon/lib/pkgconfig:$PKG_CONFIG_PATH +#+end_src + +Example to link with chameleon in CMake project, see the +~CMakeLists.txt~ file +#+begin_src +mkdir build +cd build +cmake .. -DMORSE_DISTRIB_DIR=$PWD/../../../cmake_modules -DMORSE_CHAMELEON_USE_STARPU=ON +make VERBOSE=1 +./link_chameleon_c +./link_chameleon_f +#+end_src + +Example using directly the pkg-config file +#+begin_src +gcc `pkg-config --cflags chameleon` -o link_chameleon_c link_chameleon.c `pkg-config --libs --static chameleon` +gfortran `pkg-config --cflags chameleon` -o link_chameleon_f link_chameleon.f90 `pkg-config --libs --static chameleon` +#+end_src diff --git a/example/link_chameleon/link_chameleon.f90 b/example/link_chameleon/link_chameleon.f90 new file mode 100644 index 0000000000000000000000000000000000000000..4c689d6a8ee5c322bc6fe8acd5b3dd81b44823b8 --- /dev/null +++ b/example/link_chameleon/link_chameleon.f90 @@ -0,0 +1,53 @@ + +program fortran_example + implicit none + include 'morse_fortran.h' + integer, parameter:: dp=kind(0.d0) ! double precision + integer, parameter :: NCPU=2, NGPU=0 + integer, parameter :: N=500, NRHS=1 + double precision, dimension(N*N) :: A, Acpy + double precision, dimension(N*NRHS) :: B, X + double precision :: anorm, bnorm, xnorm, res, eps=1.11022d-16 + integer :: info + integer :: UPLO=MorseUpper + logical :: hres + + + ! Initialize MORSE with main parameters + call MORSE_Init(NCPU, NGPU, info) + + ! generate A matrix with random values such that it is spd + call MORSE_dplgsy( dfloat(N), MorseUpperLower, N, A, N, 51, info ) + Acpy = A + + ! generate RHS + call MORSE_dplrnt( N, NRHS, B, N, 5673, info ) + X = B + + call MORSE_dpotrf( UPLO, N, A, N, INFO ) + call MORSE_dpotrs( UPLO, N, NRHS, A, N, X, N, info) + + ! compute norms to check the result + call MORSE_dlange( MorseInfNorm, N, N, Acpy, N, anorm) + call MORSE_dlange( MorseInfNorm, N, NRHS, B, N, bnorm) + call MORSE_dlange( MorseInfNorm, N, NRHS, X, N, xnorm) + + ! compute A*X-B, store the result in B + call MORSE_dgemm( MorseNoTrans, MorseNoTrans, N, NRHS, N, 1.d0, Acpy, N, X, N, -1.d0, B, N, info) + call MORSE_dlange( MorseInfNorm, N, NRHS, B, N, res) + + ! if hres = 0 then the test succeed + ! else the test failed + hres = .TRUE. + hres = ( res / N / eps / (anorm * xnorm + bnorm ) > 100.0 ) + print *, " ||Ax-b|| ||A|| ||x|| ||b|| ||Ax-b||/N/eps/(||A||||x||+||b||)" + if (hres) then + print *, res, anorm, xnorm, bnorm, res / N / eps / (anorm * xnorm + bnorm ), "FAILURE" + else + print *, res, anorm, xnorm, bnorm, res / N / eps / (anorm * xnorm + bnorm), "SUCCESS" + endif + + ! Finalize MORSE + call MORSE_Finalize(info) + +end program fortran_example diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 965963b85b96890513bf14053f1af5700c29509e..ccc94012f9d46c8d78dd7d8a224ede3570892ba5 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -58,6 +58,7 @@ set(CHAMELEON_HDRS morse_struct.h morse_types.h morse.h + morse_mangling.h runtime.h ${CHAMELEON_HDRS_GENERATED} ) @@ -80,11 +81,12 @@ set(HDR_INSTALL morse_struct.h morse_types.h runtime.h + ${CMAKE_CURRENT_BINARY_DIR}/morse.h + ${CMAKE_CURRENT_BINARY_DIR}/chameleon_config.h ) foreach( hdr_file ${CHAMELEON_HDRS_GENERATED} ) list(APPEND HDR_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/${hdr_file}) endforeach() -list(APPEND HDR_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/morse.h ${CMAKE_CURRENT_BINARY_DIR}/chameleon_config.h) # installation # ------------