Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete implementations of GPU basic reducer constructor test #1474

Merged
merged 5 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/unit/reducer/test-reducer-constructors-cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@
#include "tests/test-reducer-constructors.hpp"

#if defined(RAJA_ENABLE_CUDA)
using CudaBasicReducerConstructorTypes =
Test< camp::cartesian_product< CudaReducerPolicyList,
DataTypeList,
CudaResourceList > >::Types;

using CudaInitReducerConstructorTypes =
Test< camp::cartesian_product< CudaReducerPolicyList,
DataTypeList,
CudaResourceList,
CudaForoneList > >::Types;

INSTANTIATE_TYPED_TEST_SUITE_P(CudaBasicTest,
ReducerBasicConstructorUnitTest,
CudaBasicReducerConstructorTypes);

INSTANTIATE_TYPED_TEST_SUITE_P(CudaInitTest,
ReducerInitConstructorUnitTest,
CudaInitReducerConstructorTypes);
Expand Down
9 changes: 9 additions & 0 deletions test/unit/reducer/test-reducer-constructors-hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@
#include "tests/test-reducer-constructors.hpp"

#if defined(RAJA_ENABLE_HIP)
using HipBasicReducerConstructorTypes =
Test< camp::cartesian_product< HipReducerPolicyList,
DataTypeList,
HipResourceList > >::Types;

using HipInitReducerConstructorTypes =
Test< camp::cartesian_product< HipReducerPolicyList,
DataTypeList,
HipResourceList,
HipForoneList > >::Types;

INSTANTIATE_TYPED_TEST_SUITE_P(HipBasicTest,
ReducerBasicConstructorUnitTest,
HipBasicReducerConstructorTypes);

INSTANTIATE_TYPED_TEST_SUITE_P(HipInitTest,
ReducerInitConstructorUnitTest,
HipInitReducerConstructorTypes);
Expand Down
31 changes: 30 additions & 1 deletion test/unit/reducer/tests/test-reducer-constructors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,38 @@ class ReducerInitConstructorUnitTest : public ::testing::Test
TYPED_TEST_SUITE_P(ReducerBasicConstructorUnitTest);
TYPED_TEST_SUITE_P(ReducerInitConstructorUnitTest);

#if defined(RAJA_ENABLE_CUDA) || defined(RAJA_ENABLE_HIP)
template <typename ReducePolicy,
typename NumericType>
void testReducerConstructor()
typename std::enable_if<
#if defined(RAJA_ENABLE_CUDA) // CUDA policy does nothing.
std::is_same<ReducePolicy, RAJA::cuda_reduce>::value
#elif defined(RAJA_ENABLE_HIP) // HIP policy does nothing.
std::is_same<ReducePolicy, RAJA::hip_reduce>::value
#else
#error Please enable a supported GPU platform, e.g. CUDA or HIP.
#endif
>::type
testReducerConstructor()
{
// do nothing
}
#endif

// Basic constructor tests are only expected to be verified on the host.
// Should not run this on a GPU.
template <typename ReducePolicy,
typename NumericType>
typename std::enable_if< // CPU policy.
#if defined(RAJA_ENABLE_CUDA)
!std::is_same<ReducePolicy, RAJA::cuda_reduce>::value
#elif defined(RAJA_ENABLE_HIP)
!std::is_same<ReducePolicy, RAJA::hip_reduce>::value
#else
true // Always run for non-GPU policies.
#endif
>::type
testReducerConstructor()
{
RAJA::ReduceSum<ReducePolicy, NumericType> reduce_sum;
RAJA::ReduceMin<ReducePolicy, NumericType> reduce_min;
Expand Down