diff --git a/RandLAPACK/CMakeLists.txt b/RandLAPACK/CMakeLists.txt index 2554df5cc..69df8b870 100644 --- a/RandLAPACK/CMakeLists.txt +++ b/RandLAPACK/CMakeLists.txt @@ -1,32 +1,4 @@ -set(RandLAPACK_cxx_sources - rl_abrik.hh - rl_lapackpp.hh - rl_cqrrt.hh - rl_cqrrpt.hh - rl_bqrrp.hh - rl_rsvd.hh - rl_revd2.hh - rl_qb.hh - rl_orth.hh - rl_util.hh - rl_determiter.hh - rl_rs.hh - rl_rf.hh - rl_syps.hh - rl_syrf.hh - rl_rpchol.hh - rl_blaspp.hh - rl_pdkernels.hh - rl_exceptions.hh - - rl_cusolver.hh - rl_cuda_kernels.cuh - rl_cuda_macros.hh - rl_cqrrpt_gpu.hh - rl_bqrrp_gpu.hh -) - add_library(RandLAPACK INTERFACE) target_compile_features(RandLAPACK INTERFACE cxx_std_20) diff --git a/RandLAPACK/gpu_functions/rl_cusolver.hh b/RandLAPACK/gpu_functions/rl_cusolver.hh deleted file mode 100644 index 8a80fef0a..000000000 --- a/RandLAPACK/gpu_functions/rl_cusolver.hh +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -#if defined(ENABLE_CUDA) -#include -#include -#include -#include "cublas_traits.h" -#else -// -// We don't have access to cuBLAS / cuSOLVER. -// -// We need to create dummy aliases for CUDA types. -// -using cublasHandle_t = void *; -using cusolverDnHandle_t = void *; -using cublasFillMode_t = char; -// -// We have code that calls certain CUDA-defined functions -// regardless of whether USE_CUBLAS was defined. -// -// We need to define dummy versions of these functions. -// -// Naturally, these dummy versions should raise an error -// if called. Here is some context that informs how we handle this -// -// It so happens that the CUDA functions in question all return -// values from a CUDA-defined enum to indicate if the operation -// succeeded or failed. -// -// Our code that calls these CUDA functions is supposed to raise -// an error if the CUDA function returned anything other than zero. -// -// Therefore our dummy versions of these functions only need to -// return a value other than zero in order to raise errors where -// they're invoked. -// -// We have them return 1, since this corresponds to the value of -// CUSOLVER_STATUS_NOT_INITIALIZED in the cusolverStatus_t enum. -// -int cusolverDnCreate(cusolverDnHandle_t *x) { - return 1; -} -int cusolverDnDestroy(cusolverDnHandle_t x) { - return 1; -} -int cublasCreate(cublasHandle_t *x) { - return 1; -} -int cublasDestroy(cublasHandle_t x) { - return 1; -} -// -// For good measure, we define macros that map to the success condition -// for the CUDA functions we might call. -// -#define CUSOLVER_STATUS_SUCCESS 0 -#define CUBLAS_STATUS_SUCCESS 0 -#endif diff --git a/RandLAPACK/rl_config.hh.in b/RandLAPACK/rl_config.hh.in index 5a15a252e..19a04d42f 100644 --- a/RandLAPACK/rl_config.hh.in +++ b/RandLAPACK/rl_config.hh.in @@ -1,9 +1,11 @@ #pragma once -#include "../RandBLAS/RandBLAS/config.h.in" + +// CMake's configure_file turns this template into rl_config.hh at configure time, and +// the generated copy is installed with the headers so downstream projects can query the +// version. RandBLAS's own config.h arrives through RandBLAS.hh, so it is not repeated +// here. test/misc/test_config.cc exists to keep this header compiled. #define RandLAPACK_VERSION "@RandLAPACK_VERSION@" #define RandLAPACK_VERSION_MAJOR @RandLAPACK_VERSION_MAJOR@ #define RandLAPACK_VERSION_MINOR @RandLAPACK_VERSION_MINOR@ #define RandLAPACK_VERSION_PATCH @RandLAPACK_VERSION_PATCH@ - -#endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9f99fdc92..fff7e6fc5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -22,6 +22,7 @@ if (GTest_FOUND) drivers/test_hqrrp.cc drivers/test_abrik.cc drivers/test_orth_linop.cc + misc/test_config.cc misc/test_util.cc misc/test_pdkernels.cc linops/test_linops.cc diff --git a/test/misc/test_config.cc b/test/misc/test_config.cc new file mode 100644 index 000000000..3980f2da1 --- /dev/null +++ b/test/misc/test_config.cc @@ -0,0 +1,35 @@ +// rl_config.hh is generated by CMake and installed, but nothing in the library +// includes it, so for a long time nothing compiled it and it silently stopped being +// valid C++. These tests are cheap; their real job is to keep that from recurring. + +#include "RandLAPACK/rl_config.hh" + +#include +#include + +class TestConfig : public ::testing::Test {}; + +TEST_F(TestConfig, version_macros_are_defined) { + // Compilation is the substantive check. These assertions document what the header + // is expected to provide. + std::string version = RandLAPACK_VERSION; + EXPECT_FALSE(version.empty()); + + EXPECT_GE(RandLAPACK_VERSION_MAJOR, 0); + EXPECT_GE(RandLAPACK_VERSION_MINOR, 0); + EXPECT_GE(RandLAPACK_VERSION_PATCH, 0); +} + +TEST_F(TestConfig, version_string_starts_with_the_numeric_components) { + // rl_version.cmake derives the components from `git describe`, so the string always + // begins with MAJOR.MINOR.PATCH and may carry a commit suffix after that. + std::string expected_prefix = + std::to_string(RandLAPACK_VERSION_MAJOR) + "." + + std::to_string(RandLAPACK_VERSION_MINOR) + "." + + std::to_string(RandLAPACK_VERSION_PATCH); + std::string version = RandLAPACK_VERSION; + + EXPECT_EQ(version.rfind(expected_prefix, 0), 0u) + << "version string \"" << version << "\" does not start with \"" + << expected_prefix << "\""; +}