From 5623619ce6964fd2b9ac22733cbaaaf76e027f6e Mon Sep 17 00:00:00 2001 From: Nathan Ellingwood Date: Fri, 17 Dec 2021 13:37:38 -0700 Subject: [PATCH 1/5] BuildSystem: update PTHREAD to THREADS Compatibility change in accordance with kokkos/kokkos#4619 Resolves nightly build failures (due to undefined references at link stage) when both Pthreads (not Threads) and Serial backends simultaneously enabled --- cmake/kokkos_backends.cmake | 2 +- cmake/kokkoskernels_eti_devices.cmake | 18 +++++++++--------- unit_test/CMakeLists.txt | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmake/kokkos_backends.cmake b/cmake/kokkos_backends.cmake index 11c51eed53..a90ad69bf0 100644 --- a/cmake/kokkos_backends.cmake +++ b/cmake/kokkos_backends.cmake @@ -10,7 +10,7 @@ MACRO(CHECK_KOKKOS_BACKEND BE) ENDMACRO(CHECK_KOKKOS_BACKEND) CHECK_KOKKOS_BACKEND(SERIAL) -CHECK_KOKKOS_BACKEND(PTHREAD) +CHECK_KOKKOS_BACKEND(THREADS) CHECK_KOKKOS_BACKEND(OPENMP) CHECK_KOKKOS_BACKEND(OPENMPTARGET) CHECK_KOKKOS_BACKEND(CUDA) diff --git a/cmake/kokkoskernels_eti_devices.cmake b/cmake/kokkoskernels_eti_devices.cmake index 81ab89508e..47dce1f9d1 100644 --- a/cmake/kokkoskernels_eti_devices.cmake +++ b/cmake/kokkoskernels_eti_devices.cmake @@ -8,7 +8,7 @@ SET(EXEC_SPACES EXECSPACE_SYCL EXECSPACE_OPENMPTARGET EXECSPACE_OPENMP - EXECSPACE_PTHREAD + EXECSPACE_THREADS EXECSPACE_SERIAL ) SET(EXECSPACE_CUDA_CPP_TYPE Kokkos::Cuda) @@ -16,7 +16,7 @@ SET(EXECSPACE_HIP_CPP_TYPE Kokkos::Experimental::HIP) SET(EXECSPACE_SYCL_CPP_TYPE Kokkos::Experimental::SYCL) SET(EXECSPACE_OPENMPTARGET_CPP_TYPE Kokkos::Experimental::OpenMPTarget) SET(EXECSPACE_OPENMP_CPP_TYPE Kokkos::OpenMP) -SET(EXECSPACE_PTHREAD_CPP_TYPE Kokkos::Threads) +SET(EXECSPACE_THREADS_CPP_TYPE Kokkos::Threads) SET(EXECSPACE_SERIAL_CPP_TYPE Kokkos::Serial) SET(MEM_SPACES @@ -174,17 +174,17 @@ ENDIF() KOKKOSKERNELS_ADD_OPTION( INST_EXECSPACE_THREADS - ${KOKKOSKERNELS_INST_EXECSPACE_PTHREAD_DEFAULT} + ${KOKKOSKERNELS_INST_EXECSPACE_THREADS_DEFAULT} BOOL - "Whether to build kernels for the execution space Kokkos::Threads. If explicit template instantiation (ETI) is enabled in Trilinos, disabling this when Kokkos_ENABLE_PTHREAD is enabled may increase build times. Default: ON if Kokkos is Threads-enabled, OFF otherwise." + "Whether to build kernels for the execution space Kokkos::Threads. If explicit template instantiation (ETI) is enabled in Trilinos, disabling this when Kokkos_ENABLE_THREADS is enabled may increase build times. Default: ON if Kokkos is Threads-enabled, OFF otherwise." ) #There continues to be name ambiguity with threads vs pthreads -SET(KOKKOSKERNELS_INST_EXECSPACE_PTHREAD ${KOKKOSKERNELS_INST_EXECSPACE_THREADS}) +SET(KOKKOSKERNELS_INST_EXECSPACE_THREADS ${KOKKOSKERNELS_INST_EXECSPACE_THREADS}) -IF(KOKKOSKERNELS_INST_EXECSPACE_PTHREAD AND KOKKOSKERNELS_INST_MEMSPACE_HOSTSPACE) +IF(KOKKOSKERNELS_INST_EXECSPACE_THREADS AND KOKKOSKERNELS_INST_MEMSPACE_HOSTSPACE) LIST(APPEND DEVICE_LIST "") - IF(NOT KOKKOS_ENABLE_PTHREAD) - MESSAGE(FATAL_ERROR "Set ETI on for PTHREAD, but Kokkos was not configured with the PTHREAD backend") + IF(NOT KOKKOS_ENABLE_THREADS) + MESSAGE(FATAL_ERROR "Set ETI on for THREADS, but Kokkos was not configured with the THREADS backend") ENDIF() ENDIF() @@ -201,7 +201,7 @@ SET(EXECSPACE_SYCL_VALID_MEM_SPACES SYCLSPACE SYCLSHAREDSPACE) SET(EXECSPACE_OPENMPTARGET_VALID_MEM_SPACES OPENMPTARGETSPACE) SET(EXECSPACE_SERIAL_VALID_MEM_SPACES HBWSPACE HOSTSPACE) SET(EXECSPACE_OPENMP_VALID_MEM_SPACES HBWSPACE HOSTSPACE) -SET(EXECSPACE_PTHREAD_VALID_MEM_SPACES HBWSPACE HOSTSPACE) +SET(EXECSPACE_THREADS_VALID_MEM_SPACES HBWSPACE HOSTSPACE) SET(DEVICES) FOREACH(EXEC ${EXEC_SPACES}) IF (KOKKOSKERNELS_INST_${EXEC}) diff --git a/unit_test/CMakeLists.txt b/unit_test/CMakeLists.txt index f226063166..59498efcf8 100644 --- a/unit_test/CMakeLists.txt +++ b/unit_test/CMakeLists.txt @@ -367,7 +367,7 @@ IF (KOKKOS_ENABLE_SERIAL) ) ENDIF () -IF (KOKKOS_ENABLE_PTHREAD) +IF (KOKKOS_ENABLE_THREADS) KOKKOSKERNELS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/threads) KOKKOSKERNELS_INCLUDE_DIRECTORIES(REQUIRED_DURING_INSTALLATION_TESTING ${CMAKE_CURRENT_SOURCE_DIR}/threads) From 3dafa527f5edbfb9cb073f1625e33bf6a4c8141a Mon Sep 17 00:00:00 2001 From: Luc Berger Date: Wed, 5 Jan 2022 12:22:29 -0700 Subject: [PATCH 2/5] Update cmake/kokkos_backends.cmake Good for backward compatibility Co-authored-by: Damien L-G --- cmake/kokkos_backends.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmake/kokkos_backends.cmake b/cmake/kokkos_backends.cmake index a90ad69bf0..14ba8b5f73 100644 --- a/cmake/kokkos_backends.cmake +++ b/cmake/kokkos_backends.cmake @@ -10,7 +10,12 @@ MACRO(CHECK_KOKKOS_BACKEND BE) ENDMACRO(CHECK_KOKKOS_BACKEND) CHECK_KOKKOS_BACKEND(SERIAL) -CHECK_KOKKOS_BACKEND(THREADS) +# for backward compatibility. can be dropped when requiring Kokkos 3.6 +#CHECK_KOKKOS_BACKEND(THREADS) +IF (Kokkos_ENABLE_THREADS OR Kokkos_ENABLE_PTHREAD) + SET(KOKKOS_ENABLE_THREADS ON) + SET(KOKKOSKERNELS_INST_EXECSPACE_THREADS_DEFAULT ON) +ENDIF() CHECK_KOKKOS_BACKEND(OPENMP) CHECK_KOKKOS_BACKEND(OPENMPTARGET) CHECK_KOKKOS_BACKEND(CUDA) From eda2cc45ccc829528e3c9d84ce489f7a787025de Mon Sep 17 00:00:00 2001 From: Luc Berger-Vergiat Date: Thu, 6 Jan 2022 10:40:20 -0700 Subject: [PATCH 3/5] Kokkos synch up: update build system and remove macro usage Adding a fix in kokkos_backends.cmake and remove all usage of KOKKOS_IMPL_DO_NOT_USE_PRINTF since it was removed from Kokkos. These changes should allow us to build against Kokkos develop version again. --- cmake/kokkos_backends.cmake | 13 +- .../dense/impl/KokkosBatched_Axpy_Impl.hpp | 12 +- .../sparse/KokkosBatched_JacobiPrec.hpp | 4 +- .../impl/KokkosBatched_Spmv_Serial_Impl.hpp | 12 +- .../KokkosBatched_Spmv_TeamVector_Impl.hpp | 12 +- .../impl/KokkosBatched_Spmv_Team_Impl.hpp | 12 +- unit_test/common/Test_Common_ArithTraits.hpp | 134 +++++++++--------- 7 files changed, 100 insertions(+), 99 deletions(-) diff --git a/cmake/kokkos_backends.cmake b/cmake/kokkos_backends.cmake index 14ba8b5f73..9346475f91 100644 --- a/cmake/kokkos_backends.cmake +++ b/cmake/kokkos_backends.cmake @@ -10,14 +10,15 @@ MACRO(CHECK_KOKKOS_BACKEND BE) ENDMACRO(CHECK_KOKKOS_BACKEND) CHECK_KOKKOS_BACKEND(SERIAL) -# for backward compatibility. can be dropped when requiring Kokkos 3.6 -#CHECK_KOKKOS_BACKEND(THREADS) -IF (Kokkos_ENABLE_THREADS OR Kokkos_ENABLE_PTHREAD) - SET(KOKKOS_ENABLE_THREADS ON) - SET(KOKKOSKERNELS_INST_EXECSPACE_THREADS_DEFAULT ON) -ENDIF() +CHECK_KOKKOS_BACKEND(THREADS) CHECK_KOKKOS_BACKEND(OPENMP) CHECK_KOKKOS_BACKEND(OPENMPTARGET) CHECK_KOKKOS_BACKEND(CUDA) CHECK_KOKKOS_BACKEND(HIP) CHECK_KOKKOS_BACKEND(SYCL) + +# for backward compatibility. can be dropped when requiring Kokkos 3.6 +IF (Kokkos_ENABLE_PTHREAD) + SET(KOKKOS_ENABLE_THREADS ON) + SET(KOKKOSKERNELS_INST_EXECSPACE_THREADS_DEFAULT ON) +ENDIF() diff --git a/src/batched/dense/impl/KokkosBatched_Axpy_Impl.hpp b/src/batched/dense/impl/KokkosBatched_Axpy_Impl.hpp index 1d45931bc4..1a9fd81f2c 100644 --- a/src/batched/dense/impl/KokkosBatched_Axpy_Impl.hpp +++ b/src/batched/dense/impl/KokkosBatched_Axpy_Impl.hpp @@ -223,14 +223,14 @@ KOKKOS_INLINE_FUNCTION int SerialAxpy::invoke(const alphaViewType& alpha, // Check compatibility of dimensions at run time. if (X.extent(0) != Y.extent(0) || X.extent(1) != Y.extent(1)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::axpy: Dimensions of X and Y do not match: X: %d x %d, " "Y: %d x %d\n", (int)X.extent(0), (int)X.extent(1), (int)Y.extent(0), (int)Y.extent(1)); return 1; } if (X.extent(0) != alpha.extent(0)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::axpy: First dimension of X and alpha do not match: X: " "%d x %d, alpha: %d\n", (int)X.extent(0), (int)X.extent(1), (int)alpha.extent(0)); @@ -270,14 +270,14 @@ KOKKOS_INLINE_FUNCTION int TeamAxpy::invoke( // Check compatibility of dimensions at run time. if (X.extent(0) != Y.extent(0) || X.extent(1) != Y.extent(1)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::axpy: Dimensions of X and Y do not match: X: %d x %d, " "Y: %d x %d\n", (int)X.extent(0), (int)X.extent(1), (int)Y.extent(0), (int)Y.extent(1)); return 1; } if (X.extent(0) != alpha.extent(0)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::axpy: First dimension of X and alpha do not match: X: " "%d x %d, alpha: %d\n", (int)X.extent(0), (int)X.extent(1), (int)alpha.extent(0)); @@ -318,14 +318,14 @@ KOKKOS_INLINE_FUNCTION int TeamVectorAxpy::invoke( // Check compatibility of dimensions at run time. if (X.extent(0) != Y.extent(0) || X.extent(1) != Y.extent(1)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::axpy: Dimensions of X and Y do not match: X: %d x %d, " "Y: %d x %d\n", (int)X.extent(0), (int)X.extent(1), (int)Y.extent(0), (int)Y.extent(1)); return 1; } if (X.extent(0) != alpha.extent(0)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::axpy: First dimension of X and alpha do not match: X: " "%d x %d, alpha: %d\n", (int)X.extent(0), (int)X.extent(1), (int)alpha.extent(0)); diff --git a/src/batched/sparse/KokkosBatched_JacobiPrec.hpp b/src/batched/sparse/KokkosBatched_JacobiPrec.hpp index b41e53519f..d75c250e39 100644 --- a/src/batched/sparse/KokkosBatched_JacobiPrec.hpp +++ b/src/batched/sparse/KokkosBatched_JacobiPrec.hpp @@ -132,7 +132,7 @@ class JacobiPrec { } if (tooSmall > 0) - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::JacobiPrec: %d entrie(s) has/have a too small " "magnitude and have been replaced by one, \n", (int)tooSmall); @@ -153,4 +153,4 @@ class JacobiPrec { } // namespace KokkosBatched -#endif \ No newline at end of file +#endif diff --git a/src/batched/sparse/impl/KokkosBatched_Spmv_Serial_Impl.hpp b/src/batched/sparse/impl/KokkosBatched_Spmv_Serial_Impl.hpp index ccf26c5500..31ea8d16d9 100644 --- a/src/batched/sparse/impl/KokkosBatched_Spmv_Serial_Impl.hpp +++ b/src/batched/sparse/impl/KokkosBatched_Spmv_Serial_Impl.hpp @@ -179,7 +179,7 @@ struct SerialSpmv { // Check compatibility of dimensions at run time. if (X.extent(0) != Y.extent(0) || X.extent(1) != Y.extent(1)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: Dimensions of X and Y do not match: X: %d x " "%d, Y: %d x %d\n", (int)X.extent(0), (int)X.extent(1), (int)Y.extent(0), @@ -187,21 +187,21 @@ struct SerialSpmv { return 1; } if (X.extent(0) != alpha.extent(0)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: First dimension of X and alpha do not match: " "X: %d x %d, alpha: %d\n", (int)X.extent(0), (int)X.extent(1), (int)alpha.extent(0)); return 1; } if (X.extent(0) != beta.extent(0)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: First dimension of X and beta do not match: X: " "%d x %d, beta: %d\n", (int)X.extent(0), (int)X.extent(1), (int)beta.extent(0)); return 1; } if (X.extent(0) != values.extent(0)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: First dimension of X and the first dimension " "of values do not match: X: %d x %d, values: %d x %d\n", (int)X.extent(0), (int)X.extent(1), (int)values.extent(0), @@ -209,7 +209,7 @@ struct SerialSpmv { return 1; } if (colIndices.extent(0) != values.extent(1)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: Dimension of colIndices and the second " "dimension of values do not match: colIndices: %d , values: %d x " "%d\n", @@ -218,7 +218,7 @@ struct SerialSpmv { return 1; } if (row_ptr.extent(0) - 1 != X.extent(1)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: Dimension of row_ptr and the second dimension " "of X do not match: colIndices (-1): %d , values: %d x %d\n", (int)row_ptr.extent(0) - 1, (int)X.extent(0), (int)X.extent(1)); diff --git a/src/batched/sparse/impl/KokkosBatched_Spmv_TeamVector_Impl.hpp b/src/batched/sparse/impl/KokkosBatched_Spmv_TeamVector_Impl.hpp index dfd0ae510b..d4851bcf44 100644 --- a/src/batched/sparse/impl/KokkosBatched_Spmv_TeamVector_Impl.hpp +++ b/src/batched/sparse/impl/KokkosBatched_Spmv_TeamVector_Impl.hpp @@ -221,7 +221,7 @@ struct TeamVectorSpmv { // Check compatibility of dimensions at run time. if (X.extent(0) != Y.extent(0) || X.extent(1) != Y.extent(1)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: Dimensions of X and Y do not match: X: %d x " "%d, Y: %d x %d\n", (int)X.extent(0), (int)X.extent(1), (int)Y.extent(0), @@ -229,21 +229,21 @@ struct TeamVectorSpmv { return 1; } if (X.extent(0) != alpha.extent(0)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: First dimension of X and alpha do not match: " "X: %d x %d, alpha: %d\n", (int)X.extent(0), (int)X.extent(1), (int)alpha.extent(0)); return 1; } if (X.extent(0) != beta.extent(0)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: First dimension of X and beta do not match: X: " "%d x %d, beta: %d\n", (int)X.extent(0), (int)X.extent(1), (int)beta.extent(0)); return 1; } if (X.extent(0) != values.extent(0)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: First dimension of X and the first dimension " "of values do not match: X: %d x %d, values: %d x %d\n", (int)X.extent(0), (int)X.extent(1), (int)values.extent(0), @@ -251,7 +251,7 @@ struct TeamVectorSpmv { return 1; } if (colIndices.extent(0) != values.extent(1)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: Dimension of colIndices and the second " "dimension of values do not match: colIndices: %d , values: %d x " "%d\n", @@ -260,7 +260,7 @@ struct TeamVectorSpmv { return 1; } if (row_ptr.extent(0) - 1 != X.extent(1)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: Dimension of row_ptr and the second dimension " "of X do not match: colIndices (-1): %d , values: %d x %d\n", (int)row_ptr.extent(0) - 1, (int)X.extent(0), (int)X.extent(1)); diff --git a/src/batched/sparse/impl/KokkosBatched_Spmv_Team_Impl.hpp b/src/batched/sparse/impl/KokkosBatched_Spmv_Team_Impl.hpp index 2972cfb180..319c17ef99 100644 --- a/src/batched/sparse/impl/KokkosBatched_Spmv_Team_Impl.hpp +++ b/src/batched/sparse/impl/KokkosBatched_Spmv_Team_Impl.hpp @@ -217,7 +217,7 @@ struct TeamSpmv { // Check compatibility of dimensions at run time. if (X.extent(0) != Y.extent(0) || X.extent(1) != Y.extent(1)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: Dimensions of X and Y do not match: X: %d x " "%d, Y: %d x %d\n", (int)X.extent(0), (int)X.extent(1), (int)Y.extent(0), @@ -225,21 +225,21 @@ struct TeamSpmv { return 1; } if (X.extent(0) != alpha.extent(0)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: First dimension of X and alpha do not match: " "X: %d x %d, alpha: %d\n", (int)X.extent(0), (int)X.extent(1), (int)alpha.extent(0)); return 1; } if (X.extent(0) != beta.extent(0)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: First dimension of X and beta do not match: X: " "%d x %d, beta: %d\n", (int)X.extent(0), (int)X.extent(1), (int)beta.extent(0)); return 1; } if (X.extent(0) != values.extent(0)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: First dimension of X and the first dimension " "of values do not match: X: %d x %d, values: %d x %d\n", (int)X.extent(0), (int)X.extent(1), (int)values.extent(0), @@ -247,7 +247,7 @@ struct TeamSpmv { return 1; } if (colIndices.extent(0) != values.extent(1)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: Dimension of colIndices and the second " "dimension of values do not match: colIndices: %d , values: %d x " "%d\n", @@ -256,7 +256,7 @@ struct TeamSpmv { return 1; } if (row_ptr.extent(0) - 1 != X.extent(1)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "KokkosBatched::spmv: Dimension of row_ptr and the second dimension " "of X do not match: colIndices (-1): %d , values: %d x %d\n", (int)row_ptr.extent(0) - 1, (int)X.extent(0), (int)X.extent(1)); diff --git a/unit_test/common/Test_Common_ArithTraits.hpp b/unit_test/common/Test_Common_ArithTraits.hpp index 38a6ba7d78..4d1d8bc888 100644 --- a/unit_test/common/Test_Common_ArithTraits.hpp +++ b/unit_test/common/Test_Common_ArithTraits.hpp @@ -65,14 +65,14 @@ #define FAILURE() \ { \ - KOKKOS_IMPL_DO_NOT_USE_PRINTF("%s:%s:%d: Failure\n", __FILE__, __func__, \ + printf("%s:%s:%d: Failure\n", __FILE__, __func__, \ __LINE__); \ success = 0; \ } #if 0 #define TRACE() \ - KOKKOS_IMPL_DO_NOT_USE_PRINTF("%s:%s:%d: Trace\n", __FILE__, __func__, \ + printf("%s:%s:%d: Trace\n", __FILE__, __func__, \ __LINE__); #else #define TRACE() @@ -209,7 +209,7 @@ class ArithTraitsTesterBase { // T, but we check for this int constant for compatibility with // std::numeric_limits. if (!AT::is_specialized) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("! AT::is_specialized\n"); + printf("! AT::is_specialized\n"); FAILURE(); } @@ -217,12 +217,12 @@ class ArithTraitsTesterBase { // function, just not to its class methods (which are not marked // as device functions). if (AT::is_integer != std::numeric_limits::is_integer) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "AT::is_integer not same as numeric_limits\n"); FAILURE(); } if (AT::is_exact != std::numeric_limits::is_exact) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "AT::is_exact not same as numeric_limits\n"); FAILURE(); } @@ -232,34 +232,34 @@ class ArithTraitsTesterBase { // Test properties of the arithmetic and multiplicative identities. if (zero + zero != zero) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("0 + 0 != 0\n"); + printf("0 + 0 != 0\n"); FAILURE(); } if (zero + one != one) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("0 + 1 != 1\n"); + printf("0 + 1 != 1\n"); FAILURE(); } if (one - one != zero) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("1 - 1 != 0\n"); + printf("1 - 1 != 0\n"); FAILURE(); } // This is technically 1 even of Z_2, since in that field, one // is its own inverse (so -one == one). if ((one + one) - one != one) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("(1 + 1) - 1 != 1\n"); + printf("(1 + 1) - 1 != 1\n"); FAILURE(); } if (AT::abs(zero) != zero) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::abs(0) != 0\n"); + printf("AT::abs(0) != 0\n"); FAILURE(); } if (AT::abs(one) != one) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::abs(1) != 1\n"); + printf("AT::abs(1) != 1\n"); FAILURE(); } if (AT::is_signed && AT::abs(-one) != one) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::is_signed and AT::abs(-1) != 1\n"); + printf("AT::is_signed and AT::abs(-1) != 1\n"); FAILURE(); } // Need enable_if to test whether T can be compared using <=. @@ -268,7 +268,7 @@ class ArithTraitsTesterBase { // These are very mild ordering properties. // They should work even for a set only containing zero. if (AT::abs(zero) > AT::abs(AT::max())) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::abs(0) > AT::abs (AT::max ())\n"); + printf("AT::abs(0) > AT::abs (AT::max ())\n"); FAILURE(); } @@ -585,20 +585,20 @@ class ArithTraitsTesterTranscendentalBase if (!AT::is_complex) { result = AT::pow(two, three); if (!equal(result, eight)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::pow(2,3) != 8\n"); + printf("AT::pow(2,3) != 8\n"); FAILURE(); } } if (!equal(AT::pow(three, zero), one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::pow(3,0) != 1\n"); + printf("AT::pow(3,0) != 1\n"); FAILURE(); } if (!equal(AT::pow(three, one), three)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::pow(3,1) != 3\n"); + printf("AT::pow(3,1) != 3\n"); FAILURE(); } if (!equal(AT::pow(three, two), nine)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::pow(3,2) != 9\n"); + printf("AT::pow(3,2) != 9\n"); FAILURE(); } @@ -606,7 +606,7 @@ class ArithTraitsTesterTranscendentalBase if (!AT::is_complex) { result = AT::pow(three, three); if (!equal(result, twentySeven)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::pow(3,3) != 27\n"); + printf("AT::pow(3,3) != 27\n"); FAILURE(); } } @@ -615,93 +615,93 @@ class ArithTraitsTesterTranscendentalBase if (AT::is_signed && !AT::is_complex) { result = AT::pow(-three, one); if (!equal(result, -three)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::pow(-3,1) != -3\n"); + printf("AT::pow(-3,1) != -3\n"); FAILURE(); } result = AT::pow(-three, two); if (!equal(result, nine)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::pow(-3,2) != 9\n"); + printf("AT::pow(-3,2) != 9\n"); FAILURE(); } result = AT::pow(-three, three); if (!equal(result, -twentySeven)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::pow(-3,3) != 27\n"); + printf("AT::pow(-3,3) != 27\n"); FAILURE(); } } if (!equal(AT::sqrt(zero), zero)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::sqrt(0) != 0\n"); + printf("AT::sqrt(0) != 0\n"); FAILURE(); } if (!equal(AT::sqrt(one), one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::sqrt(1) != 1\n"); + printf("AT::sqrt(1) != 1\n"); FAILURE(); } if (!equal(AT::sqrt(thirtySix), six)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::sqrt(36) != 6\n"); + printf("AT::sqrt(36) != 6\n"); FAILURE(); } if (!equal(AT::sqrt(sixtyFour), eight)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::sqrt(64) != 8\n"); + printf("AT::sqrt(64) != 8\n"); FAILURE(); } if (AT::is_integer) { if (!equal(AT::sqrt(fortyTwo), six)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT:sqrt(42) != 6\n"); + printf("AT:sqrt(42) != 6\n"); FAILURE(); } if (!equal(AT::sqrt(oneTwentySeven), eleven)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::sqrt(127) != 11\n"); + printf("AT::sqrt(127) != 11\n"); FAILURE(); } } if (!equal(AT::cbrt(zero), zero)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::cbrt(0) != 0\n"); + printf("AT::cbrt(0) != 0\n"); FAILURE(); } if (!equal(AT::cbrt(one), one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::cbrt(1) != 1\n"); + printf("AT::cbrt(1) != 1\n"); FAILURE(); } if (!equal(AT::cbrt(twentySeven), three)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::cbrt(27) != 3\n"); + printf("AT::cbrt(27) != 3\n"); FAILURE(); } if (!equal(AT::cbrt(sixtyFour), four)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::cbrt(64) != 4\n"); + printf("AT::cbrt(64) != 4\n"); FAILURE(); } if (AT::is_integer) { if (!equal(AT::cbrt(fortyTwo), three)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT:cbrt(42) != 3\n"); + printf("AT:cbrt(42) != 3\n"); FAILURE(); } if (!equal(AT::cbrt(oneTwentySeven), five)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::cbrt(127) != 5\n"); + printf("AT::cbrt(127) != 5\n"); FAILURE(); } } if (!equal(AT::exp(zero), one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::cbrt(0) != 1\n"); + printf("AT::cbrt(0) != 1\n"); FAILURE(); } if (AT::is_complex) { const ScalarType val = two; //(two.real(), two.real()); if (!equal(AT::conj(AT::exp(val)), AT::exp(AT::conj(val)))) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "AT::conj(exp(complex(2,2))) != AT::exp(conj(complex(2,2)))\n"); FAILURE(); } } if (!equal(AT::log(one), zero)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::log(1) != 0\n"); + printf("AT::log(1) != 0\n"); FAILURE(); } if (!equal(AT::log10(one), zero)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::log10(1) != 0\n"); + printf("AT::log10(1) != 0\n"); FAILURE(); } @@ -710,12 +710,12 @@ class ArithTraitsTesterTranscendentalBase const auto val_sin = AT::sin(val); const auto val_cos = AT::cos(val); if (!equal(val_sin * val_sin + val_cos * val_cos, one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "AT(complex):: sin(val)*sin(val) + cos(val)*cos(val) != 1\n"); FAILURE(); } if (!equal(val_sin / val_cos, AT::tan(val))) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "AT(complex):: sin(val)/cos(val) != AT(real)::tan(val)\n"); FAILURE(); } @@ -724,27 +724,27 @@ class ArithTraitsTesterTranscendentalBase const auto val_sin = AT::sin(val); const auto val_cos = AT::cos(val); if (!equal(val_sin * val_sin + val_cos * val_cos, one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "AT(real):: sin(val)*sin(val) + cos(a)*cos(a) != 1\n"); FAILURE(); } if (!equal(val_sin / val_cos, AT::tan(val))) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "AT(real):: sin(val)/cos(val) != AT(real)::tan(val)\n"); FAILURE(); } } if (!equal(AT::asin(AT::sin(one)), one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::asin(sin(1)) != 1\n"); + printf("AT::asin(sin(1)) != 1\n"); FAILURE(); } if (!equal(AT::acos(AT::cos(one)), one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::acos(cos(1)) != 1\n"); + printf("AT::acos(cos(1)) != 1\n"); FAILURE(); } if (!equal(AT::atan(AT::tan(one)), one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::atan(tan(1)) != 1\n"); + printf("AT::atan(tan(1)) != 1\n"); FAILURE(); } @@ -871,40 +871,40 @@ class ArithTraitsTesterTranscendentalBase } if (!equal(AT::cbrt(zero), zero)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::cbrt(0) != 0\n"); + printf("AT::cbrt(0) != 0\n"); FAILURE(); } if (!equal(AT::cbrt(one), one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::cbrt(1) != 1\n"); + printf("AT::cbrt(1) != 1\n"); FAILURE(); } if (!equal(AT::cbrt(twentySeven), three)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::cbrt(27) != 3\n"); + printf("AT::cbrt(27) != 3\n"); FAILURE(); } if (!equal(AT::cbrt(sixtyFour), four)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::cbrt(64) != 4\n"); + printf("AT::cbrt(64) != 4\n"); FAILURE(); } if (AT::is_integer) { if (!equal(AT::cbrt(fortyTwo), three)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT:cbrt(42) != 3\n"); + printf("AT:cbrt(42) != 3\n"); FAILURE(); } if (!equal(AT::cbrt(oneTwentySeven), five)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::cbrt(127) != 5\n"); + printf("AT::cbrt(127) != 5\n"); FAILURE(); } } if (!equal(AT::exp(zero), one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::cbrt(0) != 1\n"); + printf("AT::cbrt(0) != 1\n"); FAILURE(); } if (AT::is_complex) { const ScalarType val = two; //(two.real(), two.real()); if (!equal(AT::conj(AT::exp(val)), AT::exp(AT::conj(val)))) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "AT::conj(exp(complex(2,0))) != AT::exp(conj(complex(2,0)))\n"); FAILURE(); } @@ -923,12 +923,12 @@ class ArithTraitsTesterTranscendentalBase const auto val_sin = AT::sin(val); const auto val_cos = AT::cos(val); if (!equal(val_sin * val_sin + val_cos * val_cos, one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "AT(complex):: sin(val)*sin(val) + cos(val)*cos(val) != 1\n"); FAILURE(); } if (!equal(val_sin / val_cos, AT::tan(val))) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "AT(complex):: sin(val)/cos(val) != AT(real)::tan(val)\n"); FAILURE(); } @@ -937,27 +937,27 @@ class ArithTraitsTesterTranscendentalBase const auto val_sin = AT::sin(val); const auto val_cos = AT::cos(val); if (!equal(val_sin * val_sin + val_cos * val_cos, one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "AT(real):: sin(val)*sin(val) + cos(a)*cos(a) != 1\n"); FAILURE(); } if (!equal(val_sin / val_cos, AT::tan(val))) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "AT(real):: sin(val)/cos(val) != AT(real)::tan(val)\n"); FAILURE(); } } if (!equal(AT::asin(AT::sin(three)), three)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::asin(sin(3)) != 3\n"); + printf("AT::asin(sin(3)) != 3\n"); FAILURE(); } if (!equal(AT::acos(AT::cos(three)), three)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::acos(cos(3)) != 3\n"); + printf("AT::acos(cos(3)) != 3\n"); FAILURE(); } if (!equal(AT::atan(AT::tan(three)), three)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::atan(tan(3)) != 3\n"); + printf("AT::atan(tan(3)) != 3\n"); FAILURE(); } @@ -1050,7 +1050,7 @@ class ArithTraitsTesterComplexBase #else { if (AT::is_signed != std::numeric_limits::is_signed) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF( + printf( "AT::is_signed = 0x%x, std::numeric_limits::is_signed " "= 0x%x\n", AT::is_signed, std::numeric_limits::is_signed); @@ -1271,12 +1271,12 @@ class ArithTraitsTesterFloatingPointBase int success = 1; if (AT::is_exact) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("AT::is_exact is 1\n"); + printf("AT::is_exact is 1\n"); FAILURE(); } if (!AT::isNan(AT::nan())) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("NaN is not NaN\n"); + printf("NaN is not NaN\n"); FAILURE(); } @@ -1284,19 +1284,19 @@ class ArithTraitsTesterFloatingPointBase const ScalarType one = AT::one(); if (AT::isInf(zero)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("0 is Inf\n"); + printf("0 is Inf\n"); FAILURE(); } if (AT::isInf(one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("1 is Inf\n"); + printf("1 is Inf\n"); FAILURE(); } if (AT::isNan(zero)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("0 is NaN\n"); + printf("0 is NaN\n"); FAILURE(); } if (AT::isNan(one)) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("1 is NaN\n"); + printf("1 is NaN\n"); FAILURE(); } @@ -1392,7 +1392,7 @@ class ArithTraitsTesterFloatingPointBase int success = 1; if (!AT::is_exact) { - KOKKOS_IMPL_DO_NOT_USE_PRINTF("! AT:is_exact\n"); + printf("! AT:is_exact\n"); FAILURE(); } From c5e66abf80970be2aa7f058572163e78f2c15b85 Mon Sep 17 00:00:00 2001 From: Luc Berger-Vergiat Date: Thu, 6 Jan 2022 10:49:49 -0700 Subject: [PATCH 4/5] Applying clang-format to modified source files --- unit_test/common/Test_Common_ArithTraits.hpp | 55 +++++++------------- 1 file changed, 20 insertions(+), 35 deletions(-) diff --git a/unit_test/common/Test_Common_ArithTraits.hpp b/unit_test/common/Test_Common_ArithTraits.hpp index 4d1d8bc888..913c98454f 100644 --- a/unit_test/common/Test_Common_ArithTraits.hpp +++ b/unit_test/common/Test_Common_ArithTraits.hpp @@ -63,17 +63,14 @@ #include // typeid (T) #include -#define FAILURE() \ - { \ - printf("%s:%s:%d: Failure\n", __FILE__, __func__, \ - __LINE__); \ - success = 0; \ +#define FAILURE() \ + { \ + printf("%s:%s:%d: Failure\n", __FILE__, __func__, __LINE__); \ + success = 0; \ } #if 0 -#define TRACE() \ - printf("%s:%s:%d: Trace\n", __FILE__, __func__, \ - __LINE__); +#define TRACE() printf("%s:%s:%d: Trace\n", __FILE__, __func__, __LINE__); #else #define TRACE() #endif @@ -217,13 +214,11 @@ class ArithTraitsTesterBase { // function, just not to its class methods (which are not marked // as device functions). if (AT::is_integer != std::numeric_limits::is_integer) { - printf( - "AT::is_integer not same as numeric_limits\n"); + printf("AT::is_integer not same as numeric_limits\n"); FAILURE(); } if (AT::is_exact != std::numeric_limits::is_exact) { - printf( - "AT::is_exact not same as numeric_limits\n"); + printf("AT::is_exact not same as numeric_limits\n"); FAILURE(); } @@ -691,8 +686,7 @@ class ArithTraitsTesterTranscendentalBase if (AT::is_complex) { const ScalarType val = two; //(two.real(), two.real()); if (!equal(AT::conj(AT::exp(val)), AT::exp(AT::conj(val)))) { - printf( - "AT::conj(exp(complex(2,2))) != AT::exp(conj(complex(2,2)))\n"); + printf("AT::conj(exp(complex(2,2))) != AT::exp(conj(complex(2,2)))\n"); FAILURE(); } } @@ -710,13 +704,11 @@ class ArithTraitsTesterTranscendentalBase const auto val_sin = AT::sin(val); const auto val_cos = AT::cos(val); if (!equal(val_sin * val_sin + val_cos * val_cos, one)) { - printf( - "AT(complex):: sin(val)*sin(val) + cos(val)*cos(val) != 1\n"); + printf("AT(complex):: sin(val)*sin(val) + cos(val)*cos(val) != 1\n"); FAILURE(); } if (!equal(val_sin / val_cos, AT::tan(val))) { - printf( - "AT(complex):: sin(val)/cos(val) != AT(real)::tan(val)\n"); + printf("AT(complex):: sin(val)/cos(val) != AT(real)::tan(val)\n"); FAILURE(); } } else { @@ -724,13 +716,11 @@ class ArithTraitsTesterTranscendentalBase const auto val_sin = AT::sin(val); const auto val_cos = AT::cos(val); if (!equal(val_sin * val_sin + val_cos * val_cos, one)) { - printf( - "AT(real):: sin(val)*sin(val) + cos(a)*cos(a) != 1\n"); + printf("AT(real):: sin(val)*sin(val) + cos(a)*cos(a) != 1\n"); FAILURE(); } if (!equal(val_sin / val_cos, AT::tan(val))) { - printf( - "AT(real):: sin(val)/cos(val) != AT(real)::tan(val)\n"); + printf("AT(real):: sin(val)/cos(val) != AT(real)::tan(val)\n"); FAILURE(); } } @@ -904,8 +894,7 @@ class ArithTraitsTesterTranscendentalBase if (AT::is_complex) { const ScalarType val = two; //(two.real(), two.real()); if (!equal(AT::conj(AT::exp(val)), AT::exp(AT::conj(val)))) { - printf( - "AT::conj(exp(complex(2,0))) != AT::exp(conj(complex(2,0)))\n"); + printf("AT::conj(exp(complex(2,0))) != AT::exp(conj(complex(2,0)))\n"); FAILURE(); } } @@ -923,13 +912,11 @@ class ArithTraitsTesterTranscendentalBase const auto val_sin = AT::sin(val); const auto val_cos = AT::cos(val); if (!equal(val_sin * val_sin + val_cos * val_cos, one)) { - printf( - "AT(complex):: sin(val)*sin(val) + cos(val)*cos(val) != 1\n"); + printf("AT(complex):: sin(val)*sin(val) + cos(val)*cos(val) != 1\n"); FAILURE(); } if (!equal(val_sin / val_cos, AT::tan(val))) { - printf( - "AT(complex):: sin(val)/cos(val) != AT(real)::tan(val)\n"); + printf("AT(complex):: sin(val)/cos(val) != AT(real)::tan(val)\n"); FAILURE(); } } else { @@ -937,13 +924,11 @@ class ArithTraitsTesterTranscendentalBase const auto val_sin = AT::sin(val); const auto val_cos = AT::cos(val); if (!equal(val_sin * val_sin + val_cos * val_cos, one)) { - printf( - "AT(real):: sin(val)*sin(val) + cos(a)*cos(a) != 1\n"); + printf("AT(real):: sin(val)*sin(val) + cos(a)*cos(a) != 1\n"); FAILURE(); } if (!equal(val_sin / val_cos, AT::tan(val))) { - printf( - "AT(real):: sin(val)/cos(val) != AT(real)::tan(val)\n"); + printf("AT(real):: sin(val)/cos(val) != AT(real)::tan(val)\n"); FAILURE(); } } @@ -1059,9 +1044,9 @@ class ArithTraitsTesterComplexBase } #endif // KOKKOS_HALF_T_IS_FLOAT - if (AT::is_complex) { - FAILURE(); - } + if (AT::is_complex) { + FAILURE(); + } // Call the base class' implementation. Every subclass' // implementation of operator() must do this, in order to include From 5b03d8cb7a8deeeefddc91cfd7c628e965a986f1 Mon Sep 17 00:00:00 2001 From: Luc Berger-Vergiat Date: Thu, 6 Jan 2022 10:53:11 -0700 Subject: [PATCH 5/5] Run clang-format 10 instead of clang-format 13... --- unit_test/common/Test_Common_ArithTraits.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unit_test/common/Test_Common_ArithTraits.hpp b/unit_test/common/Test_Common_ArithTraits.hpp index 913c98454f..2e0b7358eb 100644 --- a/unit_test/common/Test_Common_ArithTraits.hpp +++ b/unit_test/common/Test_Common_ArithTraits.hpp @@ -1044,9 +1044,9 @@ class ArithTraitsTesterComplexBase } #endif // KOKKOS_HALF_T_IS_FLOAT - if (AT::is_complex) { - FAILURE(); - } + if (AT::is_complex) { + FAILURE(); + } // Call the base class' implementation. Every subclass' // implementation of operator() must do this, in order to include