diff options
author | Brad King <brad.king@kitware.com> | 2021-10-06 14:17:24 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-10-06 14:17:46 (GMT) |
commit | ca2bc33626897bdea801ba86d0beccbf75e3f27c (patch) | |
tree | cca43233f45289f25ef985805b11eeaacf4ed5ad /Tests | |
parent | 0c606d0c3d2068cbaef4a5e29c1bffdaa2e56139 (diff) | |
parent | 64038fd5bc901f90cf0ab5a76b562db455d66c22 (diff) | |
download | CMake-ca2bc33626897bdea801ba86d0beccbf75e3f27c.zip CMake-ca2bc33626897bdea801ba86d0beccbf75e3f27c.tar.gz CMake-ca2bc33626897bdea801ba86d0beccbf75e3f27c.tar.bz2 |
Merge topic 'find-blas-lapack-sizeof-integer'
64038fd5bc Help: Add release notes for Find{BLAS,LAPACK} BLA_SIZEOF_INTEGER option
972489ae4e Find{BLAS,LAPACK}: Provide testing of BLA_SIZEOF_INTEGER
95219365ff Find{BLAS,LAPACK}: Make possible testing of ILP64 model
2cd94f3e57 Find{BLAS,LAPACK}: Specify integer type in tests
9b69307b56 Find{BLAS,LAPACK}: De-duplicate and generalize test creation logic
91fd645d46 FindLAPACK: Stop processing if LAPACK library does not have 64-bit integer API
b8a3cea51f FindBLAS: Stop processing if BLAS library does not have 64-bit integer API
d2f5c7856f FindLAPACK: Search 32/64-bit integer API via BLA_SIZEOF_INTEGER if possible
...
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6407
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/FindBLAS/CMakeLists.txt | 51 | ||||
-rw-r--r-- | Tests/FindBLAS/Test/CMakeLists.txt | 11 | ||||
-rw-r--r-- | Tests/FindBLAS/Test/main.c | 17 | ||||
-rw-r--r-- | Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake | 53 | ||||
-rw-r--r-- | Tests/FindLAPACK/CMakeLists.txt | 51 | ||||
-rw-r--r-- | Tests/FindLAPACK/Test/CMakeLists.txt | 11 | ||||
-rw-r--r-- | Tests/FindLAPACK/Test/main.c | 20 |
7 files changed, 107 insertions, 107 deletions
diff --git a/Tests/FindBLAS/CMakeLists.txt b/Tests/FindBLAS/CMakeLists.txt index 482cee8..00b254d 100644 --- a/Tests/FindBLAS/CMakeLists.txt +++ b/Tests/FindBLAS/CMakeLists.txt @@ -1,49 +1,2 @@ -foreach(variant IN LISTS CMake_TEST_FindBLAS) - if(variant MATCHES "^([^.]+)\\.(.*)$") - set(vendor "${CMAKE_MATCH_1}") - set(alt_compiler "-DCMAKE_C_COMPILER=${CMAKE_MATCH_2}") - else() - set(vendor "${variant}") - set(alt_compiler "") - endif() - if(vendor STREQUAL "All" AND CMake_TEST_FindBLAS_All) - set(EXPECT_All "-DEXPECT_All=${CMake_TEST_FindBLAS_All}") - else() - set(EXPECT_All "") - endif() - add_test(NAME FindBLAS.Test_${variant} COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindBLAS/Test" - "${CMake_BINARY_DIR}/Tests/FindBLAS/Test_${variant}" - ${build_generator_args} - --build-project TestFindBLAS - --build-options ${build_options} ${alt_compiler} ${EXPECT_All} -DBLA_VENDOR=${vendor} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) -endforeach() - -foreach(variant IN LISTS CMake_TEST_FindBLAS_STATIC) - if(variant MATCHES "^([^.]+)\\.(.*)$") - set(vendor "${CMAKE_MATCH_1}") - set(alt_compiler "-DCMAKE_C_COMPILER=${CMAKE_MATCH_2}") - else() - set(vendor "${variant}") - set(alt_compiler "") - endif() - if(vendor STREQUAL "All" AND CMake_TEST_FindBLAS_STATIC_All) - set(EXPECT_All "-DEXPECT_All=${CMake_TEST_FindBLAS_STATIC_All}") - else() - set(EXPECT_All "") - endif() - add_test(NAME FindBLAS.Test_${variant}_Static COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindBLAS/Test" - "${CMake_BINARY_DIR}/Tests/FindBLAS/Test_${variant}_Static" - ${build_generator_args} - --build-project TestFindBLAS - --build-options ${build_options} ${alt_compiler} ${EXPECT_All} -DBLA_VENDOR=${vendor} -DBLA_STATIC=ON - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) -endforeach() +include("${CMake_SOURCE_DIR}/Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake") +add_BLAS_LAPACK_tests(CMake_TEST_FindBLAS) diff --git a/Tests/FindBLAS/Test/CMakeLists.txt b/Tests/FindBLAS/Test/CMakeLists.txt index 7379749..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 @@ -17,4 +23,9 @@ if((BLA_VENDOR STREQUAL "Intel10_64lp") OR if(NOT BLAS_LIBRARIES MATCHES "^(-Wl,--start-group;)?[^;]*mkl_intel_lp64") message(FATAL_ERROR "BLAS_LIBRARIES does not start in mkl_intel_lp64:\n ${BLAS_LIBRARIES}") endif() +elseif((BLA_VENDOR STREQUAL "Intel10_64ilp") OR + (BLA_VENDOR STREQUAL "All" AND EXPECT_All STREQUAL "Intel10_64ilp")) + if(NOT BLAS_LIBRARIES MATCHES "^(-Wl,--start-group;)?[^;]*mkl_intel_ilp64") + message(FATAL_ERROR "BLAS_LIBRARIES does not start in mkl_intel_ilp64:\n ${BLAS_LIBRARIES}") + endif() endif() diff --git a/Tests/FindBLAS/Test/main.c b/Tests/FindBLAS/Test/main.c index e61b02c..4fc9fe4 100644 --- a/Tests/FindBLAS/Test/main.c +++ b/Tests/FindBLAS/Test/main.c @@ -1,16 +1,25 @@ #include <assert.h> +#include <stdint.h> #include <string.h> +#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_(int* N, double* X, int* incX, double* Y, int* incY); +void dswap_(blas_int* N, double* X, blas_int* incX, double* Y, blas_int* incY); int main() { double x[4] = { 1, 2, 3, 4 }; double y[4] = { 8, 7, 7, 6 }; - int N = 4; - int incX = 1; - int incY = 1; + blas_int N = 4; + blas_int incX = 1; + blas_int incY = 1; dswap_(&N, x, &incX, y, &incY); return 0; } diff --git a/Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake b/Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake new file mode 100644 index 0000000..42fe386 --- /dev/null +++ b/Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake @@ -0,0 +1,53 @@ +function(add_BLAS_LAPACK_tests var) + if(var MATCHES "^CMake_TEST_Find(BLAS|LAPACK)$") + set(package "${CMAKE_MATCH_1}") + else() + message(FATAL_ERROR "Test list variable '${var}' not supported.") + endif() + + 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|model|static)=(.*)$") + set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}") + continue() + elseif(variant MATCHES "^([^=]+)=(.*)$") + message(FATAL_ERROR "Unknown variable '${variant}'") + endif() + set(variant_name "${variant}") + set(variant_options "-DBLA_VENDOR=${variant}") + 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}") + endif() + if(static) + string(APPEND variant_name "_Static") + list(APPEND variant_options "-DBLA_STATIC=ON") + endif() + add_test(NAME Find${package}.Test_${variant_name} COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Find${package}/Test" + "${CMake_BINARY_DIR}/Tests/Find${package}/Test_${variant_name}" + ${build_generator_args} + --build-project TestFind${package} + --build-options ${build_options} ${variant_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + endforeach() +endfunction() diff --git a/Tests/FindLAPACK/CMakeLists.txt b/Tests/FindLAPACK/CMakeLists.txt index 535c7b6..a2470ef 100644 --- a/Tests/FindLAPACK/CMakeLists.txt +++ b/Tests/FindLAPACK/CMakeLists.txt @@ -1,49 +1,2 @@ -foreach(variant IN LISTS CMake_TEST_FindLAPACK) - if(variant MATCHES "^([^.]+)\\.(.*)$") - set(vendor "${CMAKE_MATCH_1}") - set(alt_compiler "-DCMAKE_C_COMPILER=${CMAKE_MATCH_2}") - else() - set(vendor "${variant}") - set(alt_compiler "") - endif() - if(vendor STREQUAL "All" AND CMake_TEST_FindLAPACK_All) - set(EXPECT_All "-DEXPECT_All=${CMake_TEST_FindLAPACK_All}") - else() - set(EXPECT_All "") - endif() - add_test(NAME FindLAPACK.Test_${variant} COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindLAPACK/Test" - "${CMake_BINARY_DIR}/Tests/FindLAPACK/Test_${variant}" - ${build_generator_args} - --build-project TestFindLAPACK - --build-options ${build_options} ${alt_compiler} ${EXPECT_All} -DBLA_VENDOR=${vendor} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) -endforeach() - -foreach(variant IN LISTS CMake_TEST_FindLAPACK_STATIC) - if(variant MATCHES "^([^.]+)\\.(.*)$") - set(vendor "${CMAKE_MATCH_1}") - set(alt_compiler "-DCMAKE_C_COMPILER=${CMAKE_MATCH_2}") - else() - set(vendor "${variant}") - set(alt_compiler "") - endif() - if(vendor STREQUAL "All" AND CMake_TEST_FindLAPACK_STATIC_All) - set(EXPECT_All "-DEXPECT_All=${CMake_TEST_FindLAPACK_STATIC_All}") - else() - set(EXPECT_All "") - endif() - add_test(NAME FindLAPACK.Test_${variant}_Static COMMAND - ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindLAPACK/Test" - "${CMake_BINARY_DIR}/Tests/FindLAPACK/Test_${variant}_Static" - ${build_generator_args} - --build-project TestFindLAPACK - --build-options ${build_options} ${alt_compiler} ${EXPECT_All} -DBLA_VENDOR=${vendor} -DBLA_STATIC=ON - --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> - ) -endforeach() +include("${CMake_SOURCE_DIR}/Tests/FindBLAS/add_BLAS_LAPACK_tests.cmake") +add_BLAS_LAPACK_tests(CMake_TEST_FindLAPACK) diff --git a/Tests/FindLAPACK/Test/CMakeLists.txt b/Tests/FindLAPACK/Test/CMakeLists.txt index 23a43ac..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 @@ -17,4 +23,9 @@ if((BLA_VENDOR STREQUAL "Intel10_64lp") OR if(NOT LAPACK_LIBRARIES MATCHES "^(-Wl,--start-group;)?[^;]*mkl_intel_lp64") message(FATAL_ERROR "LAPACK_LIBRARIES does not start in mkl_intel_lp64:\n ${LAPACK_LIBRARIES}") endif() +elseif((BLA_VENDOR STREQUAL "Intel10_64ilp") OR + (BLA_VENDOR STREQUAL "All" AND EXPECT_All STREQUAL "Intel10_64ilp")) + if(NOT LAPACK_LIBRARIES MATCHES "^(-Wl,--start-group;)?[^;]*mkl_intel_ilp64") + message(FATAL_ERROR "LAPACK_LIBRARIES does not start in mkl_intel_ilp64:\n ${LAPACK_LIBRARIES}") + endif() endif() diff --git a/Tests/FindLAPACK/Test/main.c b/Tests/FindLAPACK/Test/main.c index 5873e7b..dd33fb3 100644 --- a/Tests/FindLAPACK/Test/main.c +++ b/Tests/FindLAPACK/Test/main.c @@ -1,8 +1,18 @@ #include <assert.h> +#include <stdint.h> #include <string.h> +#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_(int*, int*, double*, int*, int*, double*, int*, int*); +void dgesv_(blas_int*, blas_int*, double*, blas_int*, blas_int*, double*, + blas_int*, blas_int*); int main() { @@ -10,11 +20,11 @@ int main() 0, 1, 2, 3, 4, 5, 6, 7, }; double B[2] = { 0, 5 }; - int ipiv[2] = { 0, 0 }; - int info = 0; + blas_int ipiv[2] = { 0, 0 }; + blas_int info = 0; - int dim = 2; - int numCols = 1; + blas_int dim = 2; + blas_int numCols = 1; dgesv_(&dim, &numCols, A, &dim, ipiv, B, &dim, &info); return 0; } |