From 972489ae4e22179028b5e3ed8f908100665a368d Mon Sep 17 00:00:00 2001 From: "Igor S. Gerasimov" Date: Sat, 4 Sep 2021 11:35:22 +0900 Subject: Find{BLAS,LAPACK}: Provide testing of BLA_SIZEOF_INTEGER --- .gitlab/ci/configure_intelcompiler_common.cmake | 6 +++++- Tests/FindBLAS/Test/CMakeLists.txt | 6 ++++++ Tests/FindBLAS/Test/main.c | 9 ++++++++- Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake | 12 +++++++++++- Tests/FindLAPACK/Test/CMakeLists.txt | 6 ++++++ Tests/FindLAPACK/Test/main.c | 9 ++++++++- 6 files changed, 44 insertions(+), 4 deletions(-) diff --git a/.gitlab/ci/configure_intelcompiler_common.cmake b/.gitlab/ci/configure_intelcompiler_common.cmake index 2698f88..bd34740 100644 --- a/.gitlab/ci/configure_intelcompiler_common.cmake +++ b/.gitlab/ci/configure_intelcompiler_common.cmake @@ -1,7 +1,11 @@ set(blas_lapack_cases - all=Intel10_64lp + model=lp64 all=Intel10_64lp static=0 All Intel10_64lp compiler=gcc Intel10_64lp compiler= static=1 All Intel10_64lp compiler=gcc Intel10_64lp compiler= + + model=ilp64 all=Intel10_64ilp + static=0 All Intel10_64ilp compiler=gcc Intel10_64ilp compiler= + static=1 All Intel10_64ilp compiler=gcc Intel10_64ilp compiler= ) set(CMake_TEST_FindBLAS "${blas_lapack_cases}" CACHE STRING "") set(CMake_TEST_FindLAPACK "${blas_lapack_cases}" CACHE STRING "") diff --git a/Tests/FindBLAS/Test/CMakeLists.txt b/Tests/FindBLAS/Test/CMakeLists.txt index bbe2ddc..14bf19f 100644 --- a/Tests/FindBLAS/Test/CMakeLists.txt +++ b/Tests/FindBLAS/Test/CMakeLists.txt @@ -4,12 +4,18 @@ include(CTest) find_package(BLAS REQUIRED) +if(NOT BLA_SIZEOF_INTEGER) + set(BLA_SIZEOF_INTEGER 4) +endif() + add_executable(test_tgt main.c) target_link_libraries(test_tgt BLAS::BLAS) +target_compile_definitions(test_tgt PUBLIC BLA_SIZEOF_INTEGER=${BLA_SIZEOF_INTEGER}) add_test(NAME test_tgt COMMAND test_tgt) add_executable(test_var main.c) target_link_libraries(test_var PRIVATE ${BLAS_LIBRARIES}) +target_compile_definitions(test_var PUBLIC BLA_SIZEOF_INTEGER=${BLA_SIZEOF_INTEGER}) add_test(NAME test_var COMMAND test_var) if((BLA_VENDOR STREQUAL "Intel10_64lp") OR diff --git a/Tests/FindBLAS/Test/main.c b/Tests/FindBLAS/Test/main.c index 8e58559..4fc9fe4 100644 --- a/Tests/FindBLAS/Test/main.c +++ b/Tests/FindBLAS/Test/main.c @@ -1,7 +1,14 @@ #include +#include #include -typedef int blas_int; +#if BLA_SIZEOF_INTEGER == 4 +typedef int32_t blas_int; +#elif BLA_SIZEOF_INTEGER == 8 +typedef int64_t blas_int; +#else +# error BLA_SIZEOF_INTEGER is not declared! +#endif // declare what parts of the blas C-API we need void dswap_(blas_int* N, double* X, blas_int* incX, double* Y, blas_int* incY); diff --git a/Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake b/Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake index db33404..42fe386 100644 --- a/Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake +++ b/Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake @@ -7,10 +7,14 @@ function(add_BLAS_LAPACK_tests var) set(all "") set(compiler "") + set(model "") set(static "") + set(sizeof_int_lp64 4) + set(sizeof_int_ilp64 8) + foreach(variant IN LISTS ${var}) - if(variant MATCHES "^(all|compiler|static)=(.*)$") + if(variant MATCHES "^(all|compiler|model|static)=(.*)$") set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}") continue() elseif(variant MATCHES "^([^=]+)=(.*)$") @@ -21,6 +25,12 @@ function(add_BLAS_LAPACK_tests var) if(variant STREQUAL "All" AND all) list(APPEND variant_options "-DEXPECT_All=${all}") endif() + if(model) + if(NOT variant_name MATCHES "Intel10_64") + string(APPEND variant_name "_${model}") + endif() + list(APPEND variant_options "-DBLA_SIZEOF_INTEGER=${sizeof_int_${model}}") + endif() if(compiler) string(APPEND variant_name "_${compiler}") list(APPEND variant_options "-DCMAKE_C_COMPILER=${compiler}") diff --git a/Tests/FindLAPACK/Test/CMakeLists.txt b/Tests/FindLAPACK/Test/CMakeLists.txt index 21b1303..f5d5a73 100644 --- a/Tests/FindLAPACK/Test/CMakeLists.txt +++ b/Tests/FindLAPACK/Test/CMakeLists.txt @@ -4,12 +4,18 @@ include(CTest) find_package(LAPACK REQUIRED) +if(NOT BLA_SIZEOF_INTEGER) + set(BLA_SIZEOF_INTEGER 4) +endif() + add_executable(test_tgt main.c) target_link_libraries(test_tgt LAPACK::LAPACK) +target_compile_definitions(test_tgt PUBLIC BLA_SIZEOF_INTEGER=${BLA_SIZEOF_INTEGER}) add_test(NAME test_tgt COMMAND test_tgt) add_executable(test_var main.c) target_link_libraries(test_var PRIVATE ${LAPACK_LIBRARIES}) +target_compile_definitions(test_var PUBLIC BLA_SIZEOF_INTEGER=${BLA_SIZEOF_INTEGER}) add_test(NAME test_var COMMAND test_var) if((BLA_VENDOR STREQUAL "Intel10_64lp") OR diff --git a/Tests/FindLAPACK/Test/main.c b/Tests/FindLAPACK/Test/main.c index 04eedea..dd33fb3 100644 --- a/Tests/FindLAPACK/Test/main.c +++ b/Tests/FindLAPACK/Test/main.c @@ -1,7 +1,14 @@ #include +#include #include -typedef int blas_int; +#if BLA_SIZEOF_INTEGER == 4 +typedef int32_t blas_int; +#elif BLA_SIZEOF_INTEGER == 8 +typedef int64_t blas_int; +#else +# error BLA_SIZEOF_INTEGER is not declared! +#endif // declare what parts of the lapack C-API we need void dgesv_(blas_int*, blas_int*, double*, blas_int*, blas_int*, double*, -- cgit v0.12