From 306d06adbf0fe75c9138cfd56950ad937b3bd416 Mon Sep 17 00:00:00 2001 From: "Yu-Hsiang M. Tsai" Date: Wed, 27 Nov 2024 18:52:50 +0100 Subject: [PATCH] make test target_name aligned with binary name, split isai due to nvhpc limitation --- CMakeLists.txt | 5 ++-- cmake/create_test.cmake | 23 +++++++++++-------- reference/test/preconditioner/CMakeLists.txt | 6 +++++ .../test/preconditioner/isai_kernels.cpp | 20 ++++++++++++++++ 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8aeb00c0c30..c48d12989aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,9 +34,8 @@ option(GINKGO_TEST_NONDEFAULT_STREAM "Uses non-default streams in CUDA and HIP t option(GINKGO_MIXED_PRECISION "Instantiate true mixed-precision kernels (otherwise they will be conversion-based using implicit temporary storage)" OFF) option(GINKGO_ENABLE_HALF "Enable the use of half precision" ON) # We do not support MSVC. SYCL will come later -# NVHPC 23.3 faces "termminated by signal 11" in reference/test/isal_kernel and core/config/preconditioner, so we don't support this version for half unfortunately. -if(MSVC OR GINKGO_BUILD_SYCL OR (CMAKE_CXX_COMPILER_ID MATCHES "PGI|NVHPC" AND CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 23.3.0)) - message(STATUS "HALF is not supported in MSVC, NVHPC 23.3, and later support in SYCL") +if(MSVC OR GINKGO_BUILD_SYCL) + message(STATUS "HALF is not supported in MSVC, and later support in SYCL") set(GINKGO_ENABLE_HALF OFF CACHE BOOL "Enable the use of half precision" FORCE) endif() option(GINKGO_SKIP_DEPENDENCY_UPDATE diff --git a/cmake/create_test.cmake b/cmake/create_test.cmake index c540d6e2cf7..239613ef804 100644 --- a/cmake/create_test.cmake +++ b/cmake/create_test.cmake @@ -5,9 +5,14 @@ set(gko_test_option_args "NO_RESOURCES;NO_GTEST_MAIN") ## Replaces / by _ to create valid target names from relative paths function(ginkgo_build_test_name test_name target_name) + cmake_parse_arguments(PARSE_ARGV 2 build_test_name "" "${gko_test_single_args}" "") file(RELATIVE_PATH REL_BINARY_DIR ${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - string(REPLACE "/" "_" TEST_TARGET_NAME "${REL_BINARY_DIR}/${test_name}") + set(test_binary_name ${test_name}) + if (build_test_name_EXECUTABLE_NAME) + set(test_binary_name ${build_test_name_EXECUTABLE_NAME}) + endif() + string(REPLACE "/" "_" TEST_TARGET_NAME "${REL_BINARY_DIR}/${test_binary_name}") set(${target_name} ${TEST_TARGET_NAME} PARENT_SCOPE) endfunction() @@ -127,7 +132,7 @@ endfunction() ## Normal test function(ginkgo_create_test test_name) - ginkgo_build_test_name(${test_name} test_target_name) + ginkgo_build_test_name(${test_name} test_target_name ${ARGN}) add_executable(${test_target_name} ${test_name}.cpp) target_link_libraries(${test_target_name}) ginkgo_set_test_target_properties(${test_target_name} "_cpu" ${ARGN}) @@ -136,7 +141,7 @@ endfunction(ginkgo_create_test) ## Test compiled with dpcpp function(ginkgo_create_dpcpp_test test_name) - ginkgo_build_test_name(${test_name} test_target_name) + ginkgo_build_test_name(${test_name} test_target_name ${ARGN}) add_executable(${test_target_name} ${test_name}.dp.cpp) target_compile_options(${test_target_name} PRIVATE ${GINKGO_DPCPP_FLAGS}) gko_add_sycl_to_target(TARGET ${test_target_name} SOURCES ${test_name}.dp.cpp) @@ -151,7 +156,7 @@ endfunction(ginkgo_create_dpcpp_test) ## Test compiled with CUDA function(ginkgo_create_cuda_test test_name) - ginkgo_build_test_name(${test_name} test_target_name) + ginkgo_build_test_name(${test_name} test_target_name ${ARGN}) ginkgo_create_cuda_test_internal(${test_name} ${test_name}.cu ${test_target_name} ${ARGN}) endfunction(ginkgo_create_cuda_test) @@ -177,7 +182,7 @@ endfunction(ginkgo_create_cuda_test_internal) ## Test compiled with HIP function(ginkgo_create_hip_test test_name) - ginkgo_build_test_name(${test_name} test_target_name) + ginkgo_build_test_name(${test_name} test_target_name ${ARGN}) ginkgo_create_hip_test_internal(${test_name} ${test_name}.hip.cpp ${test_target_name} ${ARGN}) endfunction(ginkgo_create_hip_test) @@ -196,12 +201,12 @@ endfunction(ginkgo_create_hip_test_internal) ## Test compiled with OpenMP function(ginkgo_create_omp_test test_name) - ginkgo_build_test_name(${test_name} test_target_name) + ginkgo_build_test_name(${test_name} test_target_name ${ARGN}) ginkgo_create_omp_test_internal(${test_name} ${test_name}.cpp ${test_target_name} "" ${ARGN}) endfunction() function(ginkgo_create_omp_test_internal test_name filename test_target_name) - ginkgo_build_test_name(${test_name} test_target_name) + ginkgo_build_test_name(${test_name} test_target_name ${ARGN}) add_executable(${test_target_name} ${test_name}.cpp) target_compile_definitions(${test_target_name} PRIVATE GKO_COMPILING_OMP GKO_DEVICE_NAMESPACE=omp) target_link_libraries(${test_target_name} PRIVATE OpenMP::OpenMP_CXX) @@ -241,7 +246,7 @@ function(ginkgo_create_common_test_internal test_name exec_type exec) else () set(test_resource_type sycl) endif () - ginkgo_build_test_name(${test_name} test_target_name) + ginkgo_build_test_name(${test_name} test_target_name ${ARGN}) string(TOUPPER ${exec} exec_upper) # set up actual test @@ -267,7 +272,7 @@ endfunction(ginkgo_create_common_test_internal) ## Common test compiled with the device compiler, one target for each enabled backend function(ginkgo_create_common_device_test test_name) cmake_parse_arguments(PARSE_ARGV 1 common_device_test "" "${gko_test_single_args}" "${gko_test_multi_args}") - ginkgo_build_test_name(${test_name} test_target_name) + ginkgo_build_test_name(${test_name} test_target_name ${ARGN}) if(GINKGO_BUILD_SYCL) ginkgo_create_common_test_internal(${test_name} DpcppExecutor dpcpp ${ARGN}) target_compile_options(${test_target_name}_dpcpp PRIVATE ${GINKGO_DPCPP_FLAGS}) diff --git a/reference/test/preconditioner/CMakeLists.txt b/reference/test/preconditioner/CMakeLists.txt index f558aa87495..603b5033cf9 100644 --- a/reference/test/preconditioner/CMakeLists.txt +++ b/reference/test/preconditioner/CMakeLists.txt @@ -3,6 +3,12 @@ ginkgo_create_test(gauss_seidel) ginkgo_create_test(ilu) ginkgo_create_test(ic) ginkgo_create_test(isai_kernels) +# need to split the isai_kernels due to NVHPC compilation limitation +if(CMAKE_CXX_COMPILER_ID MATCHES "PGI|NVHPC" AND GINKGO_ENABLE_HALF) + ginkgo_create_test(isai_kernels EXECUTABLE_NAME isai_kernels_half) + ginkgo_build_test_name(isai_kernels isai_half_target EXECUTABLE_NAME isai_kernels_half) + target_compile_definitions(${isai_half_target} PRIVATE "NVHPC_HALF") +endif() ginkgo_create_test(jacobi) ginkgo_create_test(jacobi_kernels) ginkgo_create_test(sor_kernels) diff --git a/reference/test/preconditioner/isai_kernels.cpp b/reference/test/preconditioner/isai_kernels.cpp index f55d7e12b87..0164f5d8e58 100644 --- a/reference/test/preconditioner/isai_kernels.cpp +++ b/reference/test/preconditioner/isai_kernels.cpp @@ -322,10 +322,30 @@ class Isai : public ::testing::Test { std::shared_ptr spd_sparse_inv; }; +#ifdef __NVCOMPILER + + +// Due to NVHPC compilation limitation, we need to split it to two files. +#ifdef NVHPC_HALF +using HalfIndexTypes = gko::test::cartesian_type_product_t< + ::testing::Types>, + gko::test::IndexTypes>; +TYPED_TEST_SUITE(Isai, HalfIndexTypes, PairTypenameNameGenerator); +#else +TYPED_TEST_SUITE(Isai, gko::test::ValueIndexTypes, PairTypenameNameGenerator); +#endif + + +#else + + TYPED_TEST_SUITE(Isai, gko::test::ValueIndexTypesWithHalf, PairTypenameNameGenerator); +#endif + + TYPED_TEST(Isai, KernelGenerateA) { using Csr = typename TestFixture::Csr;