Commit 6cd463e6 authored by Mathieu Faverge's avatar Mathieu Faverge

Merge branch 'issue9/detect_blas_fortran_mangling' into 'master'

Issue9/detect blas fortran mangling

Closes #9

See merge request !43
parents efffaa5a 89c1eb21
...@@ -59,6 +59,12 @@ else() ...@@ -59,6 +59,12 @@ else()
endif() endif()
include(MorseInit) include(MorseInit)
include(GenPkgConfig) 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") ...@@ -959,12 +965,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup") set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
endif() 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) if(CHAMELEON_SCHED_STARPU)
link_directories(${STARPU_LIBRARY_DIRS_DEP}) link_directories(${STARPU_LIBRARY_DIRS_DEP})
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# @copyright (c) 2009-2014 The University of Tennessee and The University # @copyright (c) 2009-2014 The University of Tennessee and The University
# of Tennessee Research Foundation. # of Tennessee Research Foundation.
# All rights reserved. # 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. # @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
# #
### ###
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
# @author Cedric Castagnede # @author Cedric Castagnede
# @author Emmanuel Agullo # @author Emmanuel Agullo
# @author Mathieu Faverge # @author Mathieu Faverge
# @author Florent Pruvost
# @date 13-07-2012 # @date 13-07-2012
# #
### ###
...@@ -52,6 +53,7 @@ set(CHAMELEON_HDRS ...@@ -52,6 +53,7 @@ set(CHAMELEON_HDRS
descriptor.h descriptor.h
gkkleader.h gkkleader.h
global.h global.h
morse_f77.h
morsewinthread.h morsewinthread.h
tile.h tile.h
workspace.h workspace.h
......
...@@ -31,11 +31,6 @@ ...@@ -31,11 +31,6 @@
#ifndef _MORSE_COMMON_H_ #ifndef _MORSE_COMMON_H_
#define _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 ) #if defined( _WIN32 ) || defined( _WIN64 )
#include <io.h> #include <io.h>
...@@ -94,30 +89,6 @@ ...@@ -94,30 +89,6 @@
#include "control/tile.h" #include "control/tile.h"
#include "control/async.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 * Global shortcuts
**/ **/
......
...@@ -28,9 +28,6 @@ ...@@ -28,9 +28,6 @@
/* inherit from public chameleon's definitions */ /* inherit from public chameleon's definitions */
#include "include/chameleon_config.h" #include "include/chameleon_config.h"
/* For BLAS Fortran mangling */
#cmakedefine ADD_
/* StarPU functions */ /* StarPU functions */
#cmakedefine HAVE_STARPU_FXT_PROFILING #cmakedefine HAVE_STARPU_FXT_PROFILING
#cmakedefine HAVE_STARPU_IDLE_PREFETCH #cmakedefine HAVE_STARPU_IDLE_PREFETCH
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @copyright (c) 2009-2014 The University of Tennessee and The University * @copyright (c) 2009-2014 The University of Tennessee and The University
* of Tennessee Research Foundation. * of Tennessee Research Foundation.
* All rights reserved. * 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. * @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
* *
**/ **/
...@@ -16,98 +16,96 @@ ...@@ -16,98 +16,96 @@
* MORSE is a software package provided by Univ. of Tennessee, * MORSE is a software package provided by Univ. of Tennessee,
* Univ. of California Berkeley and Univ. of Colorado Denver * Univ. of California Berkeley and Univ. of Colorado Denver
* *
* @version 0.9.0 * @version 1.0.0
* @author Bilel Hadri * @author Bilel Hadri
* @author Cedric Castagnede * @author Cedric Castagnede
* @author Florent Pruvost
* @date 2010-11-15 * @date 2010-11-15
* *
**/ **/
#include <stdlib.h> #include <stdlib.h>
#include "control/common.h" #include "control/common.h"
#include "morse.h" #include "morse.h"
#include "morse_f77.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
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/******************************************************************************* /*******************************************************************************
* FORTRAN API - auxiliary function prototypes * FORTRAN API - auxiliary function prototypes
**/ **/
void MORSE_INIT(int *CORES, int *NGPUS, int *INFO) void MORSE_INIT(int *CORES, int *NGPUS, int *INFO)
{ *INFO = MORSE_Init(*CORES, *NGPUS); } { *INFO = MORSE_Init(*CORES, *NGPUS); }
void MORSE_FINALIZE(int *INFO) void MORSE_FINALIZE(int *INFO)
{ *INFO = MORSE_Finalize(); } { *INFO = MORSE_Finalize(); }
void MORSE_ENABLE(MORSE_enum *lever, int *INFO) void MORSE_ENABLE(MORSE_enum *lever, int *INFO)
{ *INFO = MORSE_Enable(*lever); } { *INFO = MORSE_Enable(*lever); }
void MORSE_DISABLE(MORSE_enum *lever, int *INFO) void MORSE_DISABLE(MORSE_enum *lever, int *INFO)
{ *INFO = MORSE_Disable(*lever); } { *INFO = MORSE_Disable(*lever); }
void MORSE_SET(MORSE_enum *param, int *value, int *INFO) void MORSE_SET(MORSE_enum *param, int *value, int *INFO)
{ *INFO = MORSE_Set(*param, *value); } { *INFO = MORSE_Set(*param, *value); }
void MORSE_GET(MORSE_enum *param, int *value, int *INFO) void MORSE_GET(MORSE_enum *param, int *value, int *INFO)
{ *INFO = MORSE_Get(*param, value); } { *INFO = MORSE_Get(*param, value); }
void MORSE_DEALLOC_HANDLE(size_t *sp, int *INFO) void MORSE_DEALLOC_HANDLE(size_t *sp, int *INFO)
{ free((void *)(*sp)); { free((void *)(*sp));
*INFO = MORSE_SUCCESS; } *INFO = MORSE_SUCCESS; }
void MORSE_VERSION(int *VER_MAJOR, int *VER_MINOR, int *VER_MICRO, int *INFO) void MORSE_VERSION(int *VER_MAJOR, int *VER_MINOR, int *VER_MICRO, int *INFO)
{ {
*VER_MAJOR = CHAMELEON_VERSION_MAJOR; *VER_MAJOR = CHAMELEON_VERSION_MAJOR;
*VER_MINOR = CHAMELEON_VERSION_MINOR; *VER_MINOR = CHAMELEON_VERSION_MINOR;
*VER_MICRO = CHAMELEON_VERSION_MICRO; *VER_MICRO = CHAMELEON_VERSION_MICRO;
*INFO = MORSE_SUCCESS; *INFO = MORSE_SUCCESS;
} }
/***************************************************************************//** /***************************************************************************
* FORTRAN API - descriptor allocation and deallocation * 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) void MORSE_DESC_CREATE(MORSE_desc_t **desc, void *mat, MORSE_enum *dtyp,
{ *INFO = MORSE_Desc_Create(desc, mat, *dtyp, *mb, *nb, *bsiz, *lm, *ln, *i, *j, *m, *n, *p, *q); } int *mb, int *nb, int *bsiz, int *lm, int *ln,
int *i, int *j, int *m, int *n, int *p, int *q,
void MORSE_DESC_DESTROY(MORSE_desc_t **desc, int *INFO) int *INFO)
{ *INFO = MORSE_Desc_Destroy(desc); } { *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,
* FORTRAN API - conversion from LAPACK F77 matrix layout to tile layout int *i, int *j, int *m, int *n, int *p, int *q,
**/ int *INFO)
void MORSE_LAPACK_TO_TILE(intptr_t *Af77, int *LDA, intptr_t *A, int *INFO) { *INFO = MORSE_Desc_Create_OOC(desc, *dtyp, *mb, *nb, *bsiz, *lm, *ln, *i, *j, *m, *n, *p, *q); }
{ *INFO = MORSE_Lapack_to_Tile( (void *)Af77, *LDA, (MORSE_desc_t *)(*A)); } void MORSE_DESC_CREATE_USER(MORSE_desc_t **descptr, void *mat, MORSE_enum *dtyp,
int *mb, int *nb, int *bsiz, int *lm, int *ln,
void MORSE_TILE_TO_LAPACK(intptr_t *A, intptr_t *Af77, int *LDA, int *INFO) int *i, int *j, int *m, int *n, int *p, int *q,
{ *INFO = MORSE_Tile_to_Lapack((MORSE_desc_t *)(*A), (void *)Af77, *LDA); } 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 #ifdef __cplusplus
} }
......
/**
*
* @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
...@@ -182,6 +182,43 @@ module morse ...@@ -182,6 +182,43 @@ module morse
end function MORSE_Desc_Create_c end function MORSE_Desc_Create_c
end interface 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 interface
function MORSE_Desc_Destroy_c(desc) & function MORSE_Desc_Destroy_c(desc) &
& bind(c, name='MORSE_Desc_Destroy') & bind(c, name='MORSE_Desc_Destroy')
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @copyright (c) 2009-2014 The University of Tennessee and The University * @copyright (c) 2009-2014 The University of Tennessee and The University
* of Tennessee Research Foundation. * of Tennessee Research Foundation.
* All rights reserved. * 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. * @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
* *
**/ **/
...@@ -24,12 +24,14 @@ ...@@ -24,12 +24,14 @@
* @author Mathieu Faverge * @author Mathieu Faverge
* @author Emmanuel Agullo * @author Emmanuel Agullo
* @author Cedric Castagnede * @author Cedric Castagnede
* @author Florent Pruvost
* @date 2010-11-15 * @date 2010-11-15
* @precisions normal z -> c d s * @precisions normal z -> c d s
* *
**/ **/
#include <stdlib.h> #include <stdlib.h>
#include "control/common.h" #include "control/common.h"
#include "control/morse_f77.h"
#undef REAL #undef REAL
#define COMPLEX #define COMPLEX
......
...@@ -17,10 +17,11 @@ elseif (MORSE_CHAMELEON_USE_STARPU) ...@@ -17,10 +17,11 @@ elseif (MORSE_CHAMELEON_USE_STARPU)
endif() endif()
if (MORSE_DISTRIB_DIR) if (MORSE_DISTRIB_DIR)
set( MORSE_CMAKE_MODULE_DIR "${MORSE_DISTRIB_DIR}/cmake_modules/morse" CACHE PATH set( MORSE_CMAKE_MODULE_DIR "${MORSE_DISTRIB_DIR}/morse_cmake/modules" CACHE PATH
"Directory where to find MORSE CMake modules (cmake_modules/morse)") "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}")
list(APPEND CMAKE_MODULE_PATH "${MORSE_CMAKE_MODULE_DIR}/find") 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) include(MorseInit)
# Detect CHAMELEON # Detect CHAMELEON
...@@ -39,8 +40,10 @@ if (MORSE_DISTRIB_DIR) ...@@ -39,8 +40,10 @@ if (MORSE_DISTRIB_DIR)
endif() endif()
# link_chameleon exe # link_chameleon exe
add_executable(link_chameleon link_chameleon.c) add_executable(link_chameleon_c link_chameleon.c)
target_link_libraries(link_chameleon ${CHAMELEON_LIBRARIES_DEP}) 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() else()
message(STATUS "MORSE_DISTRIB_DIR is not set") message(STATUS "MORSE_DISTRIB_DIR is not set")
message(STATUS "Please indicate where is located your MORSE distribution directory." message(STATUS "Please indicate where is located your MORSE distribution directory."
......
#+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
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
...@@ -58,6 +58,7 @@ set(CHAMELEON_HDRS ...@@ -58,6 +58,7 @@ set(CHAMELEON_HDRS
morse_struct.h morse_struct.h
morse_types.h morse_types.h
morse.h morse.h
morse_mangling.h
runtime.h runtime.h
${CHAMELEON_HDRS_GENERATED} ${CHAMELEON_HDRS_GENERATED}
) )
...@@ -80,11 +81,12 @@ set(HDR_INSTALL ...@@ -80,11 +81,12 @@ set(HDR_INSTALL
morse_struct.h morse_struct.h
morse_types.h morse_types.h
runtime.h runtime.h
${CMAKE_CURRENT_BINARY_DIR}/morse.h
${CMAKE_CURRENT_BINARY_DIR}/chameleon_config.h
) )
foreach( hdr_file ${CHAMELEON_HDRS_GENERATED} ) foreach( hdr_file ${CHAMELEON_HDRS_GENERATED} )
list(APPEND HDR_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/${hdr_file}) list(APPEND HDR_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/${hdr_file})
endforeach() endforeach()
list(APPEND HDR_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/morse.h ${CMAKE_CURRENT_BINARY_DIR}/chameleon_config.h)
# installation # installation
# ------------ # ------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment