From 36db23145c0901cee3d61852be34f77f75400d14 Mon Sep 17 00:00:00 2001 From: Stuart Slattery <slatterysr@ornl.gov> Date: Wed, 21 Mar 2018 12:11:11 -0400 Subject: [PATCH] adding additional test memory space --- core/src/Cabana_Parallel.hpp | 6 +++--- core/unit_test/Cuda/TestCudaUVM_Category.hpp | 5 ++++- core/unit_test/OpenMP/TestOpenMP_Category.hpp | 3 +++ core/unit_test/Serial/TestSerial_Category.hpp | 3 +++ core/unit_test/tstAoSoA.hpp | 4 ++-- core/unit_test/tstMemberSlice.hpp | 2 +- core/unit_test/tstParallel.hpp | 2 +- core/unit_test/unit_test_main.cpp | 7 ++++++- 8 files changed, 23 insertions(+), 9 deletions(-) diff --git a/core/src/Cabana_Parallel.hpp b/core/src/Cabana_Parallel.hpp index cd9bf94..236cb80 100644 --- a/core/src/Cabana_Parallel.hpp +++ b/core/src/Cabana_Parallel.hpp @@ -50,7 +50,7 @@ inline void parallel_for( const ExecutionPolicy& exec_policy, // each thread loops over the inner arrays. std::size_t array_size = begin.a(); auto functor_wrapper = - KOKKOS_LAMBDA( std::size_t s ) + KOKKOS_LAMBDA( const std::size_t s ) { std::size_t i_begin = (s == s_begin) ? begin.i() : 0; std::size_t i_end = ((s == s_end - 1) && (end.i() != 0)) @@ -99,7 +99,7 @@ inline void parallel_for( const ExecutionPolicy& exec_policy, // Create a wrapper for the functor. Each struct is given a thread and // each thread loops over the inner arrays. auto functor_wrapper = - KOKKOS_LAMBDA( std::size_t i ) + KOKKOS_LAMBDA( const std::size_t i ) { Index idx( array_size, s, i ); functor( idx ); @@ -140,7 +140,7 @@ inline void parallel_for( const ExecutionPolicy& exec_policy, // Create a wrapper for the functor. auto functor_wrapper = - KOKKOS_LAMBDA( std::size_t s, std::size_t i ) + KOKKOS_LAMBDA( const std::size_t s, const std::size_t i ) { Index idx( array_size, s, i ); if ( idx >= begin && idx < end ) functor( idx ); diff --git a/core/unit_test/Cuda/TestCudaUVM_Category.hpp b/core/unit_test/Cuda/TestCudaUVM_Category.hpp index adcc38e..325d415 100644 --- a/core/unit_test/Cuda/TestCudaUVM_Category.hpp +++ b/core/unit_test/Cuda/TestCudaUVM_Category.hpp @@ -1,6 +1,9 @@ #ifndef CABANA_TEST_CUDAUVM_CATEGORY_HPP #define CABANA_TEST_CUDAUVM_CATEGORY_HPP -#define TEST_EXECSPACE Kokkos::CudaUVMSpace +#include <Kokkos_Cuda.hpp> + +#define TEST_EXECSPACE Kokkos::Cuda +#define TEST_MEMSPACE Kokkos::CudaUVMSpace #endif // end CABANA_TEST_CUDAUVM_CATEGORY_HPP diff --git a/core/unit_test/OpenMP/TestOpenMP_Category.hpp b/core/unit_test/OpenMP/TestOpenMP_Category.hpp index 0975dcb..8693453 100644 --- a/core/unit_test/OpenMP/TestOpenMP_Category.hpp +++ b/core/unit_test/OpenMP/TestOpenMP_Category.hpp @@ -1,6 +1,9 @@ #ifndef CABANA_TEST_OPENMP_CATEGORY_HPP #define CABANA_TEST_OPENMP_CATEGORY_HPP +#include <Kokkos_OpenMP.hpp> + #define TEST_EXECSPACE Kokkos::OpenMP +#define TEST_MEMSPACE Kokkos::OpenMP::memory_space #endif // end CABANA_TEST_OPENMP_CATEGORY_HPP diff --git a/core/unit_test/Serial/TestSerial_Category.hpp b/core/unit_test/Serial/TestSerial_Category.hpp index b96a3b3..f0eafe3 100644 --- a/core/unit_test/Serial/TestSerial_Category.hpp +++ b/core/unit_test/Serial/TestSerial_Category.hpp @@ -1,6 +1,9 @@ #ifndef CABANA_TEST_SERIAL_CATEGORY_HPP #define CABANA_TEST_SERIAL_CATEGORY_HPP +#include <Kokkos_Serial.hpp> + #define TEST_EXECSPACE Kokkos::Serial +#define TEST_MEMSPACE Kokkos::Serial::memory_space #endif // end CABANA_TEST_SERIAL_CATEGORY_HPP diff --git a/core/unit_test/tstAoSoA.hpp b/core/unit_test/tstAoSoA.hpp index b9a5b4d..67bf3fd 100644 --- a/core/unit_test/tstAoSoA.hpp +++ b/core/unit_test/tstAoSoA.hpp @@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE( aosoa_serial_api_test ) >; // Declare the AoSoA type. - using AoSoA_t = Cabana::AoSoA<DataTypes,inner_array_size,TEST_EXECSPACE>; + using AoSoA_t = Cabana::AoSoA<DataTypes,inner_array_size,TEST_MEMSPACE>; // Make sure that it is actually an AoSoA. BOOST_CHECK( Cabana::is_aosoa<AoSoA_t>::value ); @@ -250,7 +250,7 @@ BOOST_AUTO_TEST_CASE( aosoa_raw_data_test ) >; // Declare the AoSoA type. - using AoSoA_t = Cabana::AoSoA<DataTypes,inner_array_size,TEST_EXECSPACE>; + using AoSoA_t = Cabana::AoSoA<DataTypes,inner_array_size,TEST_MEMSPACE>; // Create an AoSoA using the default constructor. std::size_t num_data = 350; diff --git a/core/unit_test/tstMemberSlice.hpp b/core/unit_test/tstMemberSlice.hpp index 92f8a2e..c2b3781 100644 --- a/core/unit_test/tstMemberSlice.hpp +++ b/core/unit_test/tstMemberSlice.hpp @@ -67,7 +67,7 @@ BOOST_AUTO_TEST_CASE( slice_serial_api_test ) >; // Declare the AoSoA type. - using AoSoA_t = Cabana::AoSoA<DataTypes,inner_array_size,TEST_EXECSPACE>; + using AoSoA_t = Cabana::AoSoA<DataTypes,inner_array_size,TEST_MEMSPACE>; // Make sure that it is actually an AoSoA. BOOST_CHECK( Cabana::is_aosoa<AoSoA_t>::value ); diff --git a/core/unit_test/tstParallel.hpp b/core/unit_test/tstParallel.hpp index 2895fe7..3ffbbfb 100644 --- a/core/unit_test/tstParallel.hpp +++ b/core/unit_test/tstParallel.hpp @@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE( parallel_for_test ) >; // Declare the AoSoA type. - using AoSoA_t = Cabana::AoSoA<DataTypes,inner_array_size,TEST_EXECSPACE>; + using AoSoA_t = Cabana::AoSoA<DataTypes,inner_array_size,TEST_MEMSPACE>; // Create an AoSoA. std::size_t num_data = 155; diff --git a/core/unit_test/unit_test_main.cpp b/core/unit_test/unit_test_main.cpp index 2ea85d8..87675d3 100644 --- a/core/unit_test/unit_test_main.cpp +++ b/core/unit_test/unit_test_main.cpp @@ -3,9 +3,14 @@ #define BOOST_TEST_DYN_LINK #include <boost/test/unit_test.hpp> +#include <Kokkos_Core.hpp> + bool init_function() { return true; } int main( int argc, char* argv[] ) { - return ::boost::unit_test::unit_test_main( &init_function, argc, argv ); + Kokkos::initialize( argc, argv ); + auto return_val = ::boost::unit_test::unit_test_main( &init_function, argc, argv ); + Kokkos::finalize(); + return return_val; } -- GitLab