Find{BLAS,LAPACK}: Provide testing of BLA_SIZEOF_INTEGER

This commit is contained in:
Igor S. Gerasimov 2021-09-04 11:35:22 +09:00
parent 95219365ff
commit 972489ae4e
6 changed files with 44 additions and 4 deletions

View File

@ -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 "")

View File

@ -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

View File

@ -1,7 +1,14 @@
#include <assert.h>
#include <stdint.h>
#include <string.h>
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);

View File

@ -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}")

View File

@ -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

View File

@ -1,7 +1,14 @@
#include <assert.h>
#include <stdint.h>
#include <string.h>
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*,