diff --git a/.gitlab/build.sh b/.gitlab/build.sh index bd7b9259e6b1c7ff8388906d6c550b130da28699..de06d28ccbb1424496d8169a107b7c404ae247bb 100755 --- a/.gitlab/build.sh +++ b/.gitlab/build.sh @@ -1,11 +1,5 @@ #!/usr/bin/env bash - -fatal() { - echo "$0: error occurred, exit" - exit 1 -} - -set -x +set -ex SCAN="" @@ -29,14 +23,14 @@ if [[ "$SYSTEM" != "windows" ]]; then # to avoid the Accelerate framework and get Openblas we use BLA_PREFER_PKGCONFIG cmake -B build-${VERSION} -S . \ -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$PWD/install-${VERSION} \ - -DMORSE_ENABLE_COVERAGE=OFF -DBLA_PREFER_PKGCONFIG=ON || fatal + -DMORSE_ENABLE_COVERAGE=OFF -DBLA_PREFER_PKGCONFIG=ON else - source .gitlab-ci-env.sh $CHAM_CI_ENV_ARG || fatal + source .gitlab-ci-env.sh $CHAM_CI_ENV_ARG if [[ $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH ]] then SCAN="scan-build -plist --intercept-first --exclude CMakeFiles --analyze-headers -o analyzer_reports " fi - eval '${SCAN}cmake -B build-${VERSION} -S . -C cmake_modules/gitlab-ci-initial-cache.cmake $BUILD_OPTIONS' || fatal + eval '${SCAN}cmake -B build-${VERSION} -S . -C cmake_modules/gitlab-ci-initial-cache.cmake $BUILD_OPTIONS' fi else # on windows the mpi_f08 interface is missing, see https://www.scivision.dev/windows-mpi-msys2/ @@ -44,9 +38,41 @@ else # directory can reach more than 10Go cmake -GNinja -B build-${VERSION} -S . \ -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$PWD/install-${VERSION} \ - -DCHAMELEON_USE_MPI=OFF \ - || fatal + -DCHAMELEON_USE_MPI=OFF +fi +eval '${SCAN}cmake --build build-${VERSION} -j 4' +cmake --install build-${VERSION} + +# +# Check link to chameleon +# +cd .gitlab/check_link/ + +# Set the compiler +if [[ "$SYSTEM" == "macosx" ]]; then + export CC=clang + if brew ls --versions chameleon > /dev/null; then brew remove --force --ignore-dependencies chameleon; fi +else + export CC=gcc +fi +export FC=gfortran + +# Set the path variables +if [[ "$SYSTEM" == "linux" ]]; then + export LIBRARY_PATH=$PWD/../../install-${VERSION}/lib:$LIBRARY_PATH + export LD_LIBRARY_PATH=$PWD/../../install-${VERSION}/lib:$LD_LIBRARY_PATH +elif [[ "$SYSTEM" == "macosx" ]]; then + export LIBRARY_PATH=$PWD/../../install-${VERSION}/lib:$LIBRARY_PATH + export DYLD_LIBRARY_PATH=$PWD/../../install-${VERSION}/lib:$DYLD_LIBRARY_PATH +elif [[ "$SYSTEM" == "windows" ]]; then + export PATH="/c/Windows/WinSxS/x86_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_10.0.19041.1_none_21374cb0681a6320":$PATH + export PATH=$PWD/../../install-${VERSION}/bin:$PATH fi -eval '${SCAN}cmake --build build-${VERSION} -j 4' || fatal -cmake --install build-${VERSION} || fatal -rm -r install-${VERSION} || fatal + +# 1) using cmake: +./link_cmake.sh $PWD/../../install-${VERSION} +# 2) using pkg-config: +./link_pkgconfig.sh $PWD/../../install-${VERSION} + +cd ../.. +rm -r install-${VERSION} diff --git a/.gitlab/check_link/CMakeLists.txt b/.gitlab/check_link/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..33bf1f657a49c231b2600dc3aaaba3efb22be665 --- /dev/null +++ b/.gitlab/check_link/CMakeLists.txt @@ -0,0 +1,37 @@ +### +# +# @copyright 2013-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, +# Univ. Bordeaux. All rights reserved. +# +# @version 1.3.0 +# @author Mathieu Faverge +# @author Florent Pruvost +# @date 2024-06-13 +# +### +cmake_minimum_required(VERSION 3.5) + +project(LINK_CHAMELEON C CXX Fortran) + +# look for CHAMELEON on the system +# Hint: use CMAKE_PREFIX_PATH (env. var. or cmake var.) to the installation +# directory of CHAMELEON if not installed in a standard path +find_package(CHAMELEON REQUIRED) + +if (TARGET CHAMELEON::chameleon) + message(STATUS "CHAMELEON_BIN_DIR ${CHAMELEON_BIN_DIR}") + message(STATUS "CHAMELEON_INC_DIR ${CHAMELEON_INC_DIR}") + message(STATUS "CHAMELEON_LIB_DIR ${CHAMELEON_LIB_DIR}") +else() + message(FATAL_ERROR "Target CHAMELEON::chameleon is not found, check your CHAMELEONConfig.cmake.") +endif() + +set(CMAKE_BUILD_RPATH ${CHAMELEON_LIB_DIR}) + +add_executable(link_chameleon_c ${CMAKE_CURRENT_SOURCE_DIR}/../../example/link_chameleon/link_chameleon.c) +target_link_libraries(link_chameleon_c PRIVATE CHAMELEON::chameleon) + +# Launch executables with ctest +enable_testing() +include(CTest) +add_test(link_chameleon_c link_chameleon_c) diff --git a/.gitlab/check_link/link_cmake.sh b/.gitlab/check_link/link_cmake.sh new file mode 100755 index 0000000000000000000000000000000000000000..613218956c689e3187ae72e99207f2d51a2b2305 --- /dev/null +++ b/.gitlab/check_link/link_cmake.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +### +# +# @file link_cmake.sh +# @copyright 2023-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, +# Univ. Bordeaux. All rights reserved. +# +# @version 1.3.0 +# @author Florent Pruvost +# @author Mathieu Faverge +# @date 2023-12-07 +# +# Check that linking with the project is ok when using cmake. +# +### +set -ex + +if [ $# -lt 1 ] +then + echo "usage: ./link_cmake.sh path_to_install" + exit 1 +fi +cmake -B build -DCMAKE_PREFIX_PATH=$1 +cmake --build build --verbose +if [[ "$VERSION" != "starpu_simgrid" ]]; then + ctest --test-dir build --verbose +fi diff --git a/.gitlab/check_link/link_pkgconfig.sh b/.gitlab/check_link/link_pkgconfig.sh new file mode 100755 index 0000000000000000000000000000000000000000..f7fc478c6e3145d2cb61586ba86eb2fbd6bdfd95 --- /dev/null +++ b/.gitlab/check_link/link_pkgconfig.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +### +# +# @file link_pkgconfig.sh +# @copyright 2023-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, +# Univ. Bordeaux. All rights reserved. +# +# @version 1.3.0 +# @author Florent Pruvost +# @author Mathieu Faverge +# @date 2023-12-07 +# +# Check that linking with the project is ok when using pkg-config. +# +### +set -ex + +static="" +chameleon_path="" + +while [ $# -gt 0 ] +do + case $1 in + --static | -static | -s ) + static="--static" + ;; + * ) + chameleon_path=$1 + ;; + esac + shift +done + +if [ -z $chameleon_path ] +then + echo """ +usage: ./link_pkgconfig.sh path_to_chameleon_install [--static|-static|-s] + use the --static parameter if chameleon is static (.a) + env. var. CC and FC must be defined to C and Fortran90 compilers +""" + exit 1 +fi + +export PKG_CONFIG_PATH=$chameleon_path/lib/pkgconfig:$PKG_CONFIG_PATH + +mkdir -p build +cd build + +FLAGS=`pkg-config $static --cflags chameleon` +if [[ "$SYSTEM" == "macosx" ]]; then + FLAGS="-Wl,-rpath,$chameleon_path/lib $FLAGS" +fi +LIBS=`pkg-config $static --libs chameleon` +$CC $FLAGS ../../../example/link_chameleon/link_chameleon.c $LIBS -o link_chameleon_c + +if [[ "$VERSION" != "starpu_simgrid" ]]; then + ./link_chameleon_c +fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 44b3fff3f6699f82de1df192d6980aa0f137c7b0..3892d9b94325f20b38d2f8a1b13099786e466d8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -262,8 +262,10 @@ endif() # Option to activate or not simulation mode (use Simgrid through StarPU) # ---------------------------------------------------------------------- +cmake_dependent_option(CHAMELEON_SIMULATION +"Enable simulation mode using Simgrid through StarPU" OFF +"CHAMELEON_SCHED_STARPU" OFF) if(CHAMELEON_SCHED_STARPU) - option(CHAMELEON_SIMULATION "Enable simulation mode using Simgrid through StarPU" OFF) if (NOT CHAMELEON_SIMULATION) message("-- ${BoldGreen}CHAMELEON_SIMULATION is set to OFF, turn it ON to use" " SIMULATION mode (only with StarPU compiled with SimGrid)${ColourReset}") @@ -529,6 +531,12 @@ if(NOT CHAMELEON_SIMULATION) morse_export_imported_target(HIP HIP hip chameleon) morse_export_imported_target(HIP HIPBLAS hipblas chameleon) + if (CHAMELEON_USE_HIP_ROC) + morse_export_imported_target(roc hipblas rochipblas chameleon) + morse_export_imported_target(hip host hiphost chameleon) + morse_export_imported_target(hip device hipdevice chameleon) + morse_export_imported_target(hip amdhip64 hipamdhip64 chameleon) + endif() else(HIP_FOUND) message(FATAL_ERROR "CHAMELEON_USE_HIP requires HIP to be found") endif (HIP_FOUND) diff --git a/cmake_modules/CHAMELEONConfig.cmake.in b/cmake_modules/CHAMELEONConfig.cmake.in index b1f50a43812a77f5e92319868cb5bb5ed9bf1db6..2346b326cbf320c2eb6ca3d556ff330b32448e8d 100644 --- a/cmake_modules/CHAMELEONConfig.cmake.in +++ b/cmake_modules/CHAMELEONConfig.cmake.in @@ -37,6 +37,16 @@ if (@CHAMELEON_USE_CUDA@ AND NOT @CHAMELEON_SIMULATION@) include("${CMAKE_CURRENT_LIST_DIR}/cudaTargets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/cublasTargets.cmake") endif() +if (@CHAMELEON_USE_HIP@ AND NOT @CHAMELEON_SIMULATION@) + include("${CMAKE_CURRENT_LIST_DIR}/hipTargets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/hipblasTargets.cmake") + if (@CHAMELEON_USE_HIP_ROC@) + include("${CMAKE_CURRENT_LIST_DIR}/rochipblasTargets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/hiphostTargets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/hipdeviceTargets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/hipamdhip64Targets.cmake") + endif() +endif() # add the targets file if (@CHAMELEON_USE_HMATOSS@) diff --git a/cmake_modules/GenPkgConfig.cmake b/cmake_modules/GenPkgConfig.cmake index 4cdb04163484a6610d57bf769196b2e7bd4b2a8d..37bbfb8c1e4fccb932d5e4303bb268f3529c1359 100644 --- a/cmake_modules/GenPkgConfig.cmake +++ b/cmake_modules/GenPkgConfig.cmake @@ -128,10 +128,20 @@ MACRO(GENERATE_PKGCONFIG_FILE) list(APPEND CHAMELEON_PKGCONFIG_LIBS_PRIVATE "${QUARK_LIBRARIES_DEP}") elseif(CHAMELEON_SCHED_STARPU) list(APPEND CHAMELEON_PKGCONFIG_LIBS -lchameleon_starpu) - if ( CHAMELEON_USE_MPI ) - list(APPEND CHAMELEON_PKGCONFIG_REQUIRED_PRIVATE starpumpi-${CHAMELEON_STARPU_VERSION}) + if ( CHAMELEON_SIMULATION ) + # need PUBLIC here because simulation mode with starpu requires to replace the + # main function by a starpu main one + if ( CHAMELEON_USE_MPI ) + list(APPEND CHAMELEON_PKGCONFIG_REQUIRED starpumpi-${CHAMELEON_STARPU_VERSION}) + else() + list(APPEND CHAMELEON_PKGCONFIG_REQUIRED starpu-${CHAMELEON_STARPU_VERSION}) + endif() else() - list(APPEND CHAMELEON_PKGCONFIG_REQUIRED_PRIVATE starpu-${CHAMELEON_STARPU_VERSION}) + if ( CHAMELEON_USE_MPI ) + list(APPEND CHAMELEON_PKGCONFIG_REQUIRED_PRIVATE starpumpi-${CHAMELEON_STARPU_VERSION}) + else() + list(APPEND CHAMELEON_PKGCONFIG_REQUIRED_PRIVATE starpu-${CHAMELEON_STARPU_VERSION}) + endif() endif() endif() diff --git a/cmake_modules/morse_cmake b/cmake_modules/morse_cmake index 92987016f5342650fa8b88553708c6dad44052bd..34e01580a425eb5fc13f5495a9a602fb26a3a589 160000 --- a/cmake_modules/morse_cmake +++ b/cmake_modules/morse_cmake @@ -1 +1 @@ -Subproject commit 92987016f5342650fa8b88553708c6dad44052bd +Subproject commit 34e01580a425eb5fc13f5495a9a602fb26a3a589 diff --git a/example/link_chameleon/link_chameleon.c b/example/link_chameleon/link_chameleon.c index 97027293790aeb99fd208a52b1a368b57e557807..bde80da784c96f084a7d493b543d0e4a88b114ae 100644 --- a/example/link_chameleon/link_chameleon.c +++ b/example/link_chameleon/link_chameleon.c @@ -2,295 +2,59 @@ * * @file link_chameleon.c * - * @copyright 2009-2014 The University of Tennessee and The University of - * Tennessee Research Foundation. All rights reserved. - * @copyright 2012-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * @copyright 2024-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, * Univ. Bordeaux. All rights reserved. * *** * * @brief Chameleon link_chameleon example * - * @version 1.2.0 + * @version 1.3.0 * @author Florent Pruvost * @author Mathieu Faverge - * @date 2022-02-22 + * @date 2024-06-14 * */ -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <assert.h> - -#if defined( _WIN32 ) || defined( _WIN64 ) -#include <windows.h> -#else /* Non-Windows */ -#include <unistd.h> -#include <sys/resource.h> -#endif - - -/* Common functions for all steps of the tutorial */ - -static void get_thread_count(int *thrdnbr) { -#if defined WIN32 || defined WIN64 - sscanf( getenv( "NUMBER_OF_PROCESSORS" ), "%d", thrdnbr ); -#else - *thrdnbr = sysconf(_SC_NPROCESSORS_ONLN); -#endif -} - -static int startswith(const char *s, const char *prefix) { - size_t n = strlen( prefix ); - if (strncmp( s, prefix, n )) - return 0; - return 1; -} - - -/* define complexity of algorithms - see Lawn 41 page 120 */ -#define FMULS_POTRF(__n) ((double)(__n) * (((1. / 6.) * (double)(__n) + 0.5) * (double)(__n) + (1. / 3.))) -#define FADDS_POTRF(__n) ((double)(__n) * (((1. / 6.) * (double)(__n) ) * (double)(__n) - (1. / 6.))) -#define FMULS_TRSM(__m, __n) (0.5 * (double)(__n) * (double)(__m) * ((double)(__m)+1.)) -#define FADDS_TRSM(__m, __n) (0.5 * (double)(__n) * (double)(__m) * ((double)(__m)-1.)) - -#include <coreblas/lapacke.h> #include <chameleon.h> - -/* Integer parameters for step1 */ -enum iparam_step1 { - IPARAM_THRDNBR, /* Number of cores */ - IPARAM_N, /* Number of columns of the matrix */ - IPARAM_NRHS, /* Number of RHS */ - /* End */ - IPARAM_SIZEOF -}; - -/* Specific routines used in step1.c main program */ - -/** - * Initialize integer parameters - */ -static void init_iparam(int iparam[IPARAM_SIZEOF]){ - iparam[IPARAM_THRDNBR ] = -1; - iparam[IPARAM_N ] = 500; - iparam[IPARAM_NRHS ] = 1; - } - -/** - * Print how to use the program - */ -static void show_help(char *prog_name) { - printf( "Usage:\n%s [options]\n\n", prog_name ); - printf( "Options are:\n" - " --help Show this help\n" - "\n" - " --n=X dimension (N). (default: 500)\n" - " --nrhs=X number of RHS. (default: 1)\n" - "\n" - " --threads=X Number of CPU workers (default: _SC_NPROCESSORS_ONLN)\n" - "\n"); -} - -/** - * Read arguments following step1 program call - */ -static void read_args(int argc, char *argv[], int *iparam){ - int i; - for (i = 1; i < argc && argv[i]; ++i) { - if ( startswith( argv[i], "--help") || startswith( argv[i], "-help") || - startswith( argv[i], "--h") || startswith( argv[i], "-h") ) { - show_help( argv[0] ); - exit(0); - } else if (startswith( argv[i], "--n=" )) { - sscanf( strchr( argv[i], '=' ) + 1, "%d", &(iparam[IPARAM_N]) ); - } else if (startswith( argv[i], "--nrhs=" )) { - sscanf( strchr( argv[i], '=' ) + 1, "%d", &(iparam[IPARAM_NRHS]) ); - } else if (startswith( argv[i], "--threads=" )) { - sscanf( strchr( argv[i], '=' ) + 1, "%d", &(iparam[IPARAM_THRDNBR]) ); - } else { - fprintf( stderr, "Unknown option: %s\n", argv[i] ); - } - } -} - +#include <stdlib.h> /** - * Print a header message to summarize main parameters - */ -static void print_header(char *prog_name, int * iparam) { -#if defined(CHAMELEON_SIMULATION) - double eps = 0.; -#else - double eps = LAPACKE_dlamch_work( 'e' ); -#endif - - printf( "#\n" - "# CHAMELEON %d.%d.%d, %s\n" - "# Nb threads: %d\n" - "# Nb gpus: %d\n" - "# N: %d\n" - "# NB: %d\n" - "# IB: %d\n" - "# eps: %e\n" - "#\n", - CHAMELEON_VERSION_MAJOR, - CHAMELEON_VERSION_MINOR, - CHAMELEON_VERSION_MICRO, - prog_name, - iparam[IPARAM_THRDNBR], - 0, - iparam[IPARAM_N], - 128, - 32, - eps ); - - printf( "# M N K/NRHS seconds Gflop/s\n"); - printf( "#%7d %7d %7d ", iparam[IPARAM_N], iparam[IPARAM_N], iparam[IPARAM_NRHS]); - fflush( stdout ); - return; -} - -/* - * test external application link with chameleon + * @brief Matrix multiplication example to check library linking with Chameleon */ -int main(int argc, char *argv[]) { - - size_t i, j; - size_t N; // matrix order - size_t NRHS; // number of RHS vectors - int NCPU; // number of cores to use - int NGPU; // number of gpus (cuda devices) to use - int UPLO = ChamUpper; // where is stored L - - /* declarations to time the program and evaluate performances */ - double fmuls, fadds, flops, gflops, cpu_time; - - /* variable to check the numerical results */ - double anorm, bnorm, xnorm, eps, res; - int hres; - - int major, minor, patch; - CHAMELEON_Version(&major, &minor, &patch); - - /* initialize some parameters with default values */ - int iparam[IPARAM_SIZEOF]; - memset(iparam, 0, IPARAM_SIZEOF*sizeof(int)); - init_iparam(iparam); - - /* read arguments */ - read_args(argc, argv, iparam); - N = iparam[IPARAM_N]; - NRHS = iparam[IPARAM_NRHS]; - - /* compute the algorithm complexity to evaluate performances */ - fadds = (double)( FADDS_POTRF(N) + 2 * FADDS_TRSM(N,NRHS) ); - fmuls = (double)( FMULS_POTRF(N) + 2 * FMULS_TRSM(N,NRHS) ); - flops = 1e-9 * (fmuls + fadds); - gflops = 0.0; - cpu_time = 0.0; - - /* initialize the number of thread if not given by the user in argv - * It makes sense only if this program is linked with pthread and - * multithreaded BLAS and LAPACK */ - if ( iparam[IPARAM_THRDNBR] == -1 ) { - get_thread_count( &(iparam[IPARAM_THRDNBR]) ); - } - NCPU = iparam[IPARAM_THRDNBR]; - NGPU = 0; - - /* print informations to user */ - print_header( argv[0], iparam); - - /* Initialize CHAMELEON with main parameters */ - CHAMELEON_Init( NCPU, NGPU ); - - /* - * allocate memory for our data using a C macro (see step1.h) - * - matrix A : size N x N - * - set of RHS vectors B : size N x NRHS - * - set of solutions vectors X : size N x NRHS - */ - double *A = malloc( N * N * sizeof(double) ); - double *Acpy = malloc( N * N * sizeof(double) ); - double *B = malloc( N * NRHS * sizeof(double) ); - double *X = malloc( N * NRHS * sizeof(double) ); - - /* generate A matrix with random values such that it is spd */ - CHAMELEON_dplgsy( (double)N, ChamUpperLower, N, A, N, 51 ); - - /* generate RHS */ - CHAMELEON_dplrnt( N, NRHS, B, N, 5673 ); - - /* copy A before facto. in order to check the result */ - memcpy(Acpy, A, N*N*sizeof(double)); - - /* copy B in X before solving */ - memcpy(X, B, N*NRHS*sizeof(double)); - - /************************************************************/ - /* solve the system AX = B using the Cholesky factorization */ - /************************************************************/ - - cpu_time = -CHAMELEON_timer(); - - /* Cholesky facorization: - * A is replaced by its factorization L or L^T depending on uplo */ - CHAMELEON_dpotrf( UPLO, N, A, N ); - - /* Solve: - * B is stored in X on entry, X contains the result on exit. - * Forward and back substitutions - */ - CHAMELEON_dpotrs(UPLO, N, NRHS, A, N, X, N); - - cpu_time += CHAMELEON_timer(); - - /* print informations to user */ - gflops = flops / cpu_time; - printf( "%9.3f %9.2f\n", cpu_time, gflops); - fflush( stdout ); - - /************************************************************/ - /* check if solve is correct i.e. AX-B = 0 */ - /************************************************************/ - - /* compute norms to check the result */ - anorm = CHAMELEON_dlange( ChamInfNorm, N, N, Acpy, N); - bnorm = CHAMELEON_dlange( ChamInfNorm, N, NRHS, B, N); - xnorm = CHAMELEON_dlange( ChamInfNorm, N, NRHS, X, N); - - /* compute A*X-B, store the result in B */ - CHAMELEON_dgemm(ChamNoTrans, ChamNoTrans, - N, NRHS, N, 1.0, Acpy, N, X, N, -1.0, B, N); - res = CHAMELEON_dlange( ChamInfNorm, N, NRHS, B, N); - - /* check residual and print a message */ - eps = LAPACKE_dlamch_work( 'e' ); - - /* - * if hres = 0 then the test succeed - * else the test failed - */ - hres = 0; - hres = ( res / N / eps / (anorm * xnorm + bnorm ) > 100.0 ); - printf( " ||Ax-b|| ||A|| ||x|| ||b|| ||Ax-b||/N/eps/(||A||||x||+||b||) RETURN\n"); - if (hres) - printf( "%8.5e %8.5e %8.5e %8.5e %8.5e FAILURE \n", - res, anorm, xnorm, bnorm, - res / N / eps / (anorm * xnorm + bnorm )); - else - printf( "%8.5e %8.5e %8.5e %8.5e %8.5e SUCCESS \n", - res, anorm, xnorm, bnorm, - res / N / eps / (anorm * xnorm + bnorm )); - - /* deallocate data */ - free(A); - free(Acpy); - free(B); - free(X); +int main() { + /* number of threads */ + int NT = 2; + /* number of gpus */ + int NG = 0; + /* size of the matrices */ + int N = 16; + /* size of the tiles */ + int NB = 2; + /* seeds for A and B initialization */ + int seedA = 33; + int seedB = 47; + + CHAMELEON_Init( NT, NG ); + CHAMELEON_Set( CHAMELEON_TILE_SIZE, NB ); + int NMPI = CHAMELEON_Comm_size(); + int GRID_P = NMPI; + int GRID_Q = 1; + + CHAM_desc_t *descA = NULL, *descB = NULL, *descC = NULL; + CHAMELEON_Desc_Create(&descA, NULL, ChamRealFloat, + NB, NB, NB*NB, N, N, 0, 0, N, N, GRID_P, GRID_Q); + CHAMELEON_Desc_Create(&descB, NULL, ChamRealFloat, + NB, NB, NB*NB, N, N, 0, 0, N, N, GRID_P, GRID_Q); + CHAMELEON_Desc_Create(&descC, NULL, ChamRealFloat, + NB, NB, NB*NB, N, N, 0, 0, N, N, GRID_P, GRID_Q); + + CHAMELEON_splrnt_Tile( descA, 33 ); + CHAMELEON_splrnt_Tile( descB, 47 ); + CHAMELEON_sgemm_Tile(ChamNoTrans, ChamNoTrans, 1.0, descA, descB, 0.0, descC); + + CHAMELEON_Desc_Destroy( &descA ); + CHAMELEON_Desc_Destroy( &descB ); + CHAMELEON_Desc_Destroy( &descC ); - /* Finalize CHAMELEON */ CHAMELEON_Finalize(); return EXIT_SUCCESS; diff --git a/gpuhipblas/compute/CMakeLists.txt b/gpuhipblas/compute/CMakeLists.txt index abaa7b40a6df131c6349f0d75c96a5c9304009ce..3c6349e809d97fbdc117798ac58e91826047fa72 100644 --- a/gpuhipblas/compute/CMakeLists.txt +++ b/gpuhipblas/compute/CMakeLists.txt @@ -70,7 +70,8 @@ target_include_directories(gpuhipblas PUBLIC $<INSTALL_INTERFACE:include>) set_property(TARGET gpuhipblas PROPERTY INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") -target_link_libraries(gpuhipblas PRIVATE coreblas HIP::HIPBLAS) +target_link_libraries(gpuhipblas PRIVATE coreblas) +target_link_libraries(gpuhipblas PUBLIC HIP::HIPBLAS) target_link_libraries(gpuhipblas PUBLIC MORSE::M) # export target coreblas