diff --git a/examples/raja-launch.cpp b/examples/raja-launch.cpp index 1262b97bfb..dd0dbcfc22 100644 --- a/examples/raja-launch.cpp +++ b/examples/raja-launch.cpp @@ -143,7 +143,7 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[])) if (select_cpu_or_gpu == RAJA::ExecPlace::HOST){ std::cout << "\n Running upper triangular pattern example on the host...\n"; - }else { + } else { std::cout << "\n Running upper triangular pattern example on the device...\n"; } diff --git a/examples/resource-dynamic-forall.cpp b/examples/resource-dynamic-forall.cpp index d769e67010..1f9f4bcd88 100644 --- a/examples/resource-dynamic-forall.cpp +++ b/examples/resource-dynamic-forall.cpp @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) RAJA::ExecPlace select_cpu_or_gpu; if(pol < 2) { select_cpu_or_gpu = RAJA::ExecPlace::HOST; - }else { + } else { select_cpu_or_gpu = RAJA::ExecPlace::DEVICE; } diff --git a/include/RAJA/pattern/launch/launch_core.hpp b/include/RAJA/pattern/launch/launch_core.hpp index 67c3c50e21..6e23986ad3 100644 --- a/include/RAJA/pattern/launch/launch_core.hpp +++ b/include/RAJA/pattern/launch/launch_core.hpp @@ -3,7 +3,7 @@ * * \file * - * \brief RAJA header file containing the core components of RAJA::Teams + * \brief RAJA header file containing the core components of RAJA::launch * ****************************************************************************** */ @@ -311,7 +311,7 @@ launch(RAJA::resources::Resource res, LaunchParams const ¶ms, const char *ke ExecPlace place; if(res.get_platform() == RAJA::Platform::host) { place = RAJA::ExecPlace::HOST; - }else{ + } else { place = RAJA::ExecPlace::DEVICE; } @@ -445,7 +445,7 @@ template struct TileExecute; template -struct TileICountExecute; +struct TileTCountExecute; template -RAJA_HOST_DEVICE RAJA_INLINE void tile_icount(CONTEXT const &ctx, +RAJA_HOST_DEVICE RAJA_INLINE void tile_tcount(CONTEXT const &ctx, TILE_T tile_size, SEGMENT const &segment, BODY const &body) { - TileICountExecute, SEGMENT>::exec(ctx, + TileTCountExecute, SEGMENT>::exec(ctx, tile_size, segment, body); @@ -509,7 +509,7 @@ template -RAJA_HOST_DEVICE RAJA_INLINE void tile_icount(CONTEXT const &ctx, +RAJA_HOST_DEVICE RAJA_INLINE void tile_tcount(CONTEXT const &ctx, TILE_T tile_size0, TILE_T tile_size1, SEGMENT const &segment0, @@ -517,7 +517,7 @@ RAJA_HOST_DEVICE RAJA_INLINE void tile_icount(CONTEXT const &ctx, BODY const &body) { - TileICountExecute, SEGMENT>::exec(ctx, + TileTCountExecute, SEGMENT>::exec(ctx, tile_size0, tile_size1, segment0, diff --git a/include/RAJA/policy/cuda/launch.hpp b/include/RAJA/policy/cuda/launch.hpp index 463d6582a0..b1241fcaf8 100644 --- a/include/RAJA/policy/cuda/launch.hpp +++ b/include/RAJA/policy/cuda/launch.hpp @@ -957,7 +957,7 @@ struct TileExecute, SEGMENT> { //Tile execute + return index template -struct TileICountExecute, SEGMENT> { +struct TileTCountExecute, SEGMENT> { template static RAJA_INLINE RAJA_DEVICE void exec( @@ -980,7 +980,7 @@ struct TileICountExecute, SEGMENT> { template -struct TileICountExecute, SEGMENT> { +struct TileTCountExecute, SEGMENT> { template static RAJA_INLINE RAJA_DEVICE void exec( @@ -1002,7 +1002,7 @@ struct TileICountExecute, SEGMENT> { template -struct TileICountExecute, SEGMENT> { +struct TileTCountExecute, SEGMENT> { template static RAJA_INLINE RAJA_DEVICE void exec( @@ -1027,7 +1027,7 @@ struct TileICountExecute, SEGMENT> { template -struct TileICountExecute, SEGMENT> { +struct TileTCountExecute, SEGMENT> { template static RAJA_INLINE RAJA_DEVICE void exec( diff --git a/include/RAJA/policy/hip/launch.hpp b/include/RAJA/policy/hip/launch.hpp index 497e6d7011..ca525b2acb 100644 --- a/include/RAJA/policy/hip/launch.hpp +++ b/include/RAJA/policy/hip/launch.hpp @@ -944,7 +944,7 @@ struct TileExecute, SEGMENT> { //Tile execute + return index template -struct TileICountExecute, SEGMENT> { +struct TileTCountExecute, SEGMENT> { template static RAJA_INLINE RAJA_DEVICE void exec( @@ -967,7 +967,7 @@ struct TileICountExecute, SEGMENT> { template -struct TileICountExecute, SEGMENT> { +struct TileTCountExecute, SEGMENT> { template static RAJA_INLINE RAJA_DEVICE void exec( @@ -989,7 +989,7 @@ struct TileICountExecute, SEGMENT> { template -struct TileICountExecute, SEGMENT> { +struct TileTCountExecute, SEGMENT> { template static RAJA_INLINE RAJA_DEVICE void exec( @@ -1014,7 +1014,7 @@ struct TileICountExecute, SEGMENT> { template -struct TileICountExecute, SEGMENT> { +struct TileTCountExecute, SEGMENT> { template static RAJA_INLINE RAJA_DEVICE void exec( diff --git a/include/RAJA/policy/openmp/launch.hpp b/include/RAJA/policy/openmp/launch.hpp index 8e1048acbd..64dfc0d85e 100644 --- a/include/RAJA/policy/openmp/launch.hpp +++ b/include/RAJA/policy/openmp/launch.hpp @@ -424,7 +424,7 @@ struct TileExecute { }; template -struct TileICountExecute { +struct TileTCountExecute { template static RAJA_INLINE RAJA_HOST_DEVICE void exec( @@ -470,7 +470,7 @@ struct TileExecute { }; template -struct TileICountExecute { +struct TileTCountExecute { template static RAJA_INLINE RAJA_HOST_DEVICE void exec( @@ -486,7 +486,7 @@ struct TileICountExecute { #pragma omp for for (int i = 0; i < numTiles; i++) { const int i_tile_size = i * tile_size; - body.get_priv()(segment.slice(i_tile_size, tile_size), i); + body(segment.slice(i_tile_size, tile_size), i); } } }; diff --git a/include/RAJA/policy/sequential/launch.hpp b/include/RAJA/policy/sequential/launch.hpp index d20e15289d..a8a2a649ab 100644 --- a/include/RAJA/policy/sequential/launch.hpp +++ b/include/RAJA/policy/sequential/launch.hpp @@ -224,7 +224,7 @@ struct TileExecute { }; template -struct TileICountExecute { +struct TileTCountExecute { template static RAJA_HOST_DEVICE RAJA_INLINE void exec( diff --git a/include/RAJA/policy/sycl/launch.hpp b/include/RAJA/policy/sycl/launch.hpp index b21873e2f9..4a97264120 100644 --- a/include/RAJA/policy/sycl/launch.hpp +++ b/include/RAJA/policy/sycl/launch.hpp @@ -952,7 +952,7 @@ struct TileExecute, SEGMENT> { //Tile execute + return index template -struct TileICountExecute, SEGMENT> { +struct TileTCountExecute, SEGMENT> { template static RAJA_INLINE RAJA_DEVICE void exec( @@ -975,7 +975,7 @@ struct TileICountExecute, SEGMENT> { template -struct TileICountExecute, SEGMENT> { +struct TileTCountExecute, SEGMENT> { template static RAJA_INLINE RAJA_DEVICE void exec( @@ -997,7 +997,7 @@ struct TileICountExecute, SEGMENT> { template -struct TileICountExecute, SEGMENT> { +struct TileTCountExecute, SEGMENT> { template static RAJA_INLINE RAJA_DEVICE void exec( @@ -1020,7 +1020,7 @@ struct TileICountExecute, SEGMENT> { template -struct TileICountExecute, SEGMENT> { +struct TileTCountExecute, SEGMENT> { template static RAJA_INLINE RAJA_DEVICE void exec( diff --git a/test/functional/launch/CMakeLists.txt b/test/functional/launch/CMakeLists.txt index 81da678bf8..8975e38f78 100644 --- a/test/functional/launch/CMakeLists.txt +++ b/test/functional/launch/CMakeLists.txt @@ -19,10 +19,29 @@ if(RAJA_ENABLE_HIP) list(APPEND LAUNCH_BACKENDS Hip) endif() +if(RAJA_ENABLE_SYCL) + list(APPEND LAUNCH_BACKENDS Sycl) +endif() + add_subdirectory(run-time-switch) +#Adapted from forall test +add_subdirectory(reduce-basic) + add_subdirectory(segment) add_subdirectory(shared_mem) +add_subdirectory(nested_loop) + +add_subdirectory(nested_direct) + +add_subdirectory(tile_icount_direct) + +add_subdirectory(tile_icount_loop) + +add_subdirectory(nested_tile_direct) + +add_subdirectory(nested_tile_loop) + unset( LAUNCH_BACKENDS ) diff --git a/test/functional/launch/nested_direct/CMakeLists.txt b/test/functional/launch/nested_direct/CMakeLists.txt new file mode 100644 index 0000000000..c795b833a8 --- /dev/null +++ b/test/functional/launch/nested_direct/CMakeLists.txt @@ -0,0 +1,30 @@ +############################################################################### +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +# and RAJA project contributors. See the RAJA/LICENSE file for details. +# +# SPDX-License-Identifier: (BSD-3-Clause) +############################################################################### + +# +# List of segment types for generating test files. +# +set(NESTEDTYPES Direct) + +# +# Generate tests for each enabled RAJA back-end. +# +# + +foreach( BACKEND ${LAUNCH_BACKENDS} ) + foreach( NESTEDTYPES ${NESTEDTYPES} ) + configure_file( test-launch-nested.cpp.in + test-launch-nested-${NESTEDTYPES}-${BACKEND}.cpp ) + raja_add_test( NAME test-launch-nested-${NESTEDTYPES}-${BACKEND} + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/test-launch-nested-${NESTEDTYPES}-${BACKEND}.cpp ) + + target_include_directories(test-launch-nested-${NESTEDTYPES}-${BACKEND}.exe + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests) + endforeach() +endforeach() + +unset( NESTEDTYPES ) diff --git a/test/functional/launch/nested_direct/test-launch-nested.cpp.in b/test/functional/launch/nested_direct/test-launch-nested.cpp.in new file mode 100644 index 0000000000..d177655d99 --- /dev/null +++ b/test/functional/launch/nested_direct/test-launch-nested.cpp.in @@ -0,0 +1,39 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +// +// test/include headers +// +#include "RAJA_test-base.hpp" +#include "RAJA_test-camp.hpp" +#include "RAJA_test-index-types.hpp" + +#include "RAJA_test-forall-data.hpp" +#include "RAJA_test-launch-direct-teams-threads-3D-execpol.hpp" + +// +// Header for tests in ./tests directory +// +// Note: CMake adds ./tests as an include dir for these tests. +// +#include "test-launch-nested-@NESTEDTYPES@.hpp" + + +// +// Cartesian product of types used in parameterized tests +// +using @BACKEND@LaunchNestedTypes = + Test< camp::cartesian_product>::Types; + +// +// Instantiate parameterized test +// +INSTANTIATE_TYPED_TEST_SUITE_P(@BACKEND@, + LaunchNested@NESTEDTYPES@Test, + @BACKEND@LaunchNestedTypes); diff --git a/test/functional/launch/nested_direct/tests/test-launch-nested-Direct.hpp b/test/functional/launch/nested_direct/tests/test-launch-nested-Direct.hpp new file mode 100644 index 0000000000..5caf46a2d1 --- /dev/null +++ b/test/functional/launch/nested_direct/tests/test-launch-nested-Direct.hpp @@ -0,0 +1,188 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +#ifndef __TEST_LAUNCH_NESTED_DIRECT_HPP__ +#define __TEST_LAUNCH_NESTED_DIRECT_HPP__ + +#include + +template +void LaunchNestedDirectTestImpl(INDEX_TYPE M) +{ + + RAJA::TypedRangeSegment r1(0, 2*M); + RAJA::TypedRangeSegment r2(0, 3*M); + RAJA::TypedRangeSegment r3(0, 4*M); + + RAJA::TypedRangeSegment r4(0, 4*M); + RAJA::TypedRangeSegment r5(0, 5*M); + RAJA::TypedRangeSegment r6(0, 6*M); + + INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); + INDEX_TYPE N2 = static_cast(r2.end() - r2.begin()); + INDEX_TYPE N3 = static_cast(r3.end() - r3.begin()); + + INDEX_TYPE N4 = static_cast(r4.end() - r4.begin()); + INDEX_TYPE N5 = static_cast(r5.end() - r5.begin()); + INDEX_TYPE N6 = static_cast(r6.end() - r6.begin()); + + INDEX_TYPE N = static_cast(N1 * N2 * + N3 * N4 * + N5 * N6); + + camp::resources::Resource working_res{WORKING_RES::get_default()}; + INDEX_TYPE* working_array; + INDEX_TYPE* check_array; + INDEX_TYPE* test_array; + + size_t data_len = RAJA::stripIndexType(N); + if ( data_len == 0 ) { + data_len = 1; + } + + allocateForallTestData(data_len, + working_res, + &working_array, + &check_array, + &test_array); + //6 threads total + constexpr int threads_x = 2; + constexpr int threads_y = 3; + constexpr int threads_z = 4; + + constexpr int blocks_x = 4; + constexpr int blocks_y = 5; + constexpr int blocks_z = 6; + + if ( RAJA::stripIndexType(N) > 0 ) { + + std::iota(test_array, test_array + RAJA::stripIndexType(N), 0); + + constexpr int DIM = 6; + using layout_t = RAJA::Layout; + RAJA::View Aview(working_array, N6, N5, N4, N3, N2, N1); + + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks_x, blocks_y, blocks_z), RAJA::Threads(threads_x, threads_y,threads_z)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::loop(ctx, r6, [&](INDEX_TYPE bz) { + RAJA::loop(ctx, r5, [&](INDEX_TYPE by) { + RAJA::loop(ctx, r4, [&](INDEX_TYPE bx) { + + RAJA::loop(ctx, r3, [&](INDEX_TYPE tz) { + RAJA::loop(ctx, r2, [&](INDEX_TYPE ty) { + RAJA::loop(ctx, r1, [&](INDEX_TYPE tx) { + + auto idx = tx + N1 * (ty + N2 * (tz + N3 * (bx + N4 * (by + N5 * bz)))); + + + Aview(bz, by, bx, tz, ty, tx) = static_cast(idx); + }); + }); + }); + + }); + }); + }); + }); + } else { // zero-length segment + + memset(static_cast(test_array), 0, sizeof(INDEX_TYPE) * data_len); + + working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * data_len); + + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks_x, blocks_y, blocks_z), RAJA::Threads(blocks_x, blocks_y ,blocks_z)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::loop(ctx, r3, [&](INDEX_TYPE RAJA_UNUSED_ARG(bz)) { + RAJA::loop(ctx, r2, [&](INDEX_TYPE RAJA_UNUSED_ARG(by)) { + RAJA::loop(ctx, r1, [&](INDEX_TYPE RAJA_UNUSED_ARG(bx)) { + + RAJA::loop(ctx, r3, [&](INDEX_TYPE RAJA_UNUSED_ARG(tz)) { + RAJA::loop(ctx, r2, [&](INDEX_TYPE RAJA_UNUSED_ARG(ty)) { + RAJA::loop(ctx, r1, [&](INDEX_TYPE RAJA_UNUSED_ARG(tx)) { + + working_array[0]++; + + }); + }); + }); + + }); + }); + }); + }); + } + + working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); + + if (RAJA::stripIndexType(N) > 0) { + + for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + } + + } else { + + ASSERT_EQ(test_array[0], check_array[0]); + + } + + deallocateForallTestData(working_res, + working_array, + check_array, + test_array); +} + + +TYPED_TEST_SUITE_P(LaunchNestedDirectTest); +template +class LaunchNestedDirectTest : public ::testing::Test +{ +}; + + +TYPED_TEST_P(LaunchNestedDirectTest, RangeSegmentTeams) +{ + + using INDEX_TYPE = typename camp::at>::type; + using WORKING_RES = typename camp::at>::type; + using LAUNCH_POLICY = typename camp::at>::type, camp::num<0>>::type; + + using TEAM_Z_POLICY = typename camp::at>::type, camp::num<1>>::type; + using TEAM_Y_POLICY = typename camp::at>::type, camp::num<2>>::type; + using TEAM_X_POLICY = typename camp::at>::type, camp::num<3>>::type; + + using THREAD_Z_POLICY = typename camp::at>::type, camp::num<4>>::type; + using THREAD_Y_POLICY = typename camp::at>::type, camp::num<5>>::type; + using THREAD_X_POLICY = typename camp::at>::type, camp::num<6>>::type; + + + + // test zero-length range segment + LaunchNestedDirectTestImpl + (INDEX_TYPE(0)); + + //Keep at one since we are doing a direct thread test + LaunchNestedDirectTestImpl + (INDEX_TYPE(1)); + + +} + +REGISTER_TYPED_TEST_SUITE_P(LaunchNestedDirectTest, + RangeSegmentTeams); + +#endif // __TEST_LAUNCH_NESTED_DIRECT_HPP__ diff --git a/test/functional/launch/nested_loop/CMakeLists.txt b/test/functional/launch/nested_loop/CMakeLists.txt new file mode 100644 index 0000000000..ab7d0245f0 --- /dev/null +++ b/test/functional/launch/nested_loop/CMakeLists.txt @@ -0,0 +1,30 @@ +############################################################################### +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +# and RAJA project contributors. See the RAJA/LICENSE file for details. +# +# SPDX-License-Identifier: (BSD-3-Clause) +############################################################################### + +# +# List of segment types for generating test files. +# +set(NESTEDTYPES Loop) + +# +# Generate tests for each enabled RAJA back-end. +# +# + +foreach( BACKEND ${LAUNCH_BACKENDS} ) + foreach( NESTEDTYPES ${NESTEDTYPES} ) + configure_file( test-launch-nested.cpp.in + test-launch-nested-${NESTEDTYPES}-${BACKEND}.cpp ) + raja_add_test( NAME test-launch-nested-${NESTEDTYPES}-${BACKEND} + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/test-launch-nested-${NESTEDTYPES}-${BACKEND}.cpp ) + + target_include_directories(test-launch-nested-${NESTEDTYPES}-${BACKEND}.exe + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests) + endforeach() +endforeach() + +unset( NESTEDTYPES ) diff --git a/test/functional/launch/nested_loop/test-launch-nested.cpp.in b/test/functional/launch/nested_loop/test-launch-nested.cpp.in new file mode 100644 index 0000000000..00eaff7034 --- /dev/null +++ b/test/functional/launch/nested_loop/test-launch-nested.cpp.in @@ -0,0 +1,39 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +// +// test/include headers +// +#include "RAJA_test-base.hpp" +#include "RAJA_test-camp.hpp" +#include "RAJA_test-index-types.hpp" + +#include "RAJA_test-forall-data.hpp" +#include "RAJA_test-launch-loop-teams-threads-3D-execpol.hpp" + +// +// Header for tests in ./tests directory +// +// Note: CMake adds ./tests as an include dir for these tests. +// +#include "test-launch-nested-@NESTEDTYPES@.hpp" + + +// +// Cartesian product of types used in parameterized tests +// +using @BACKEND@LaunchNestedTypes = + Test< camp::cartesian_product>::Types; + +// +// Instantiate parameterized test +// +INSTANTIATE_TYPED_TEST_SUITE_P(@BACKEND@, + LaunchNested@NESTEDTYPES@Test, + @BACKEND@LaunchNestedTypes); diff --git a/test/functional/launch/nested_loop/tests/test-launch-nested-Loop.hpp b/test/functional/launch/nested_loop/tests/test-launch-nested-Loop.hpp new file mode 100644 index 0000000000..4ade3f0e4e --- /dev/null +++ b/test/functional/launch/nested_loop/tests/test-launch-nested-Loop.hpp @@ -0,0 +1,192 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +#ifndef __TEST_LAUNCH_NESTED_LOOP_HPP__ +#define __TEST_LAUNCH_NESTED_LOOP_HPP__ + +#include + +template +void LaunchNestedLoopTestImpl(INDEX_TYPE M) +{ + + RAJA::TypedRangeSegment r1(0, 2*M); + RAJA::TypedRangeSegment r2(0, 3*M); + RAJA::TypedRangeSegment r3(0, 4*M); + + RAJA::TypedRangeSegment r4(0, 8*M); + RAJA::TypedRangeSegment r5(0, 2*M); + RAJA::TypedRangeSegment r6(0, 3*M); + + INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); + INDEX_TYPE N2 = static_cast(r2.end() - r2.begin()); + INDEX_TYPE N3 = static_cast(r3.end() - r3.begin()); + + INDEX_TYPE N4 = static_cast(r4.end() - r4.begin()); + INDEX_TYPE N5 = static_cast(r5.end() - r5.begin()); + INDEX_TYPE N6 = static_cast(r6.end() - r6.begin()); + + + INDEX_TYPE N = static_cast(N1 * + N2 * + N3 * + N4 * + N5 * + N6); + + camp::resources::Resource working_res{WORKING_RES::get_default()}; + INDEX_TYPE* working_array; + INDEX_TYPE* check_array; + INDEX_TYPE* test_array; + + size_t data_len = RAJA::stripIndexType(N); + if ( data_len == 0 ) { + data_len = 1; + } + + allocateForallTestData(data_len, + working_res, + &working_array, + &check_array, + &test_array); + + //6 threads total + constexpr int threads_x = 1; + constexpr int threads_y = 2; + constexpr int threads_z = 3; + + constexpr int blocks_x = 3; + constexpr int blocks_y = 2; + constexpr int blocks_z = 1; + + if ( RAJA::stripIndexType(N) > 0 ) { + + std::iota(test_array, test_array + RAJA::stripIndexType(N), 0); + + constexpr int DIM = 6; + using layout_t = RAJA::Layout; + RAJA::View Aview(working_array, N6, N5, N4, N3, N2, N1); + + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks_x, blocks_y, blocks_z), RAJA::Threads(threads_x, threads_y,threads_z)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::loop(ctx, r6, [&](INDEX_TYPE bz) { + RAJA::loop(ctx, r5, [&](INDEX_TYPE by) { + RAJA::loop(ctx, r4, [&](INDEX_TYPE bx) { + + RAJA::loop(ctx, r3, [&](INDEX_TYPE tz) { + RAJA::loop(ctx, r2, [&](INDEX_TYPE ty) { + RAJA::loop(ctx, r1, [&](INDEX_TYPE tx) { + + auto idx = tx + N1 * (ty + N2 * (tz + N3 * (bx + N4 * (by + N5 * bz)))); + + + Aview(bz, by, bx, tz, ty, tx) = static_cast(idx); + + }); + }); + }); + + }); + }); + }); + }); + } else { // zero-length segment + + memset(static_cast(test_array), 0, sizeof(INDEX_TYPE) * data_len); + + working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * data_len); + + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks_x, blocks_y, blocks_z), RAJA::Threads(blocks_x, blocks_y ,blocks_z)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::loop(ctx, r3, [&](INDEX_TYPE RAJA_UNUSED_ARG(bz)) { + RAJA::loop(ctx, r2, [&](INDEX_TYPE RAJA_UNUSED_ARG(by)) { + RAJA::loop(ctx, r1, [&](INDEX_TYPE RAJA_UNUSED_ARG(bx)) { + + RAJA::loop(ctx, r3, [&](INDEX_TYPE RAJA_UNUSED_ARG(tz)) { + RAJA::loop(ctx, r2, [&](INDEX_TYPE RAJA_UNUSED_ARG(ty)) { + RAJA::loop(ctx, r1, [&](INDEX_TYPE RAJA_UNUSED_ARG(tx) ) { + + working_array[0]++; + + }); + }); + }); + + }); + }); + }); + }); + } + + working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); + + if (RAJA::stripIndexType(N) > 0) { + + for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + } + + } else { + + ASSERT_EQ(test_array[0], check_array[0]); + + } + + deallocateForallTestData(working_res, + working_array, + check_array, + test_array); +} + + +TYPED_TEST_SUITE_P(LaunchNestedLoopTest); +template +class LaunchNestedLoopTest : public ::testing::Test +{ +}; + + +TYPED_TEST_P(LaunchNestedLoopTest, RangeSegmentTeams) +{ + + using INDEX_TYPE = typename camp::at>::type; + using WORKING_RES = typename camp::at>::type; + using LAUNCH_POLICY = typename camp::at>::type, camp::num<0>>::type; + + using TEAM_Z_POLICY = typename camp::at>::type, camp::num<1>>::type; + using TEAM_Y_POLICY = typename camp::at>::type, camp::num<2>>::type; + using TEAM_X_POLICY = typename camp::at>::type, camp::num<3>>::type; + + using THREAD_Z_POLICY = typename camp::at>::type, camp::num<4>>::type; + using THREAD_Y_POLICY = typename camp::at>::type, camp::num<5>>::type; + using THREAD_X_POLICY = typename camp::at>::type, camp::num<6>>::type; + + + // test zero-length range segment + LaunchNestedLoopTestImpl + (INDEX_TYPE(0)); + + LaunchNestedLoopTestImpl + (INDEX_TYPE(3)); + + +} + +REGISTER_TYPED_TEST_SUITE_P(LaunchNestedLoopTest, + RangeSegmentTeams); + +#endif // __TEST_LAUNCH_NESTED_LOOP_HPP__ diff --git a/test/functional/launch/nested_tile_direct/CMakeLists.txt b/test/functional/launch/nested_tile_direct/CMakeLists.txt new file mode 100644 index 0000000000..f7ace622f7 --- /dev/null +++ b/test/functional/launch/nested_tile_direct/CMakeLists.txt @@ -0,0 +1,22 @@ +############################################################################### +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +# and RAJA project contributors. See the RAJA/LICENSE file for details. +# +# SPDX-License-Identifier: (BSD-3-Clause) +############################################################################### + +# +# Generate tests for each enabled RAJA back-end. +# +# + +foreach( BACKEND ${LAUNCH_BACKENDS} ) + configure_file( test-launch-nested-tile-direct.cpp.in + test-launch-nested-Tile-Direct-${BACKEND}.cpp ) + raja_add_test( NAME test-launch-nested-Tile-Direct-${BACKEND} + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/test-launch-nested-Tile-Direct-${BACKEND}.cpp ) + + target_include_directories(test-launch-nested-Tile-Direct-${BACKEND}.exe + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests) +endforeach() + diff --git a/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in b/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in new file mode 100644 index 0000000000..3152799f7b --- /dev/null +++ b/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in @@ -0,0 +1,39 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +// +// test/include headers +// +#include "RAJA_test-base.hpp" +#include "RAJA_test-camp.hpp" +#include "RAJA_test-index-types.hpp" + +#include "RAJA_test-forall-data.hpp" +#include "RAJA_test-launch-direct-teams-threads-3D-execpol.hpp" + +// +// Header for tests in ./tests directory +// +// Note: CMake adds ./tests as an include dir for these tests. +// +#include "test-launch-nested-Tile-Direct.hpp" + + +// +// Cartesian product of types used in parameterized tests +// +using @BACKEND@LaunchNestedTypes = + Test< camp::cartesian_product>::Types; + +// +// Instantiate parameterized test +// +INSTANTIATE_TYPED_TEST_SUITE_P(@BACKEND@, + LaunchNestedTileDirectTest, + @BACKEND@LaunchNestedTypes); diff --git a/test/functional/launch/nested_tile_direct/tests/test-launch-nested-Tile-Direct.hpp b/test/functional/launch/nested_tile_direct/tests/test-launch-nested-Tile-Direct.hpp new file mode 100644 index 0000000000..6f7e473668 --- /dev/null +++ b/test/functional/launch/nested_tile_direct/tests/test-launch-nested-Tile-Direct.hpp @@ -0,0 +1,183 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +#ifndef __TEST_LAUNCH_NESTED_TILE_DIRECT_HPP__ +#define __TEST_LAUNCH_NESTED_TILE_DIRECT_HPP__ + +#include + +template +void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) +{ + + constexpr int tile_size_x = 2; + constexpr int tile_size_y = 3; + constexpr int tile_size_z = 4; + + constexpr int threads_x = 2*tile_size_x; + constexpr int threads_y = 3*tile_size_y; + constexpr int threads_z = 4*tile_size_z; + + constexpr int blocks_x = 4; + constexpr int blocks_y = 5; + constexpr int blocks_z = 6; + + RAJA::TypedRangeSegment r1(0, tile_size_x*M); + RAJA::TypedRangeSegment r2(0, tile_size_y*M); + RAJA::TypedRangeSegment r3(0, tile_size_z*M); + + INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); + INDEX_TYPE N2 = static_cast(r2.end() - r2.begin()); + INDEX_TYPE N3 = static_cast(r3.end() - r3.begin()); + + INDEX_TYPE N = static_cast(N1 * + N2 * + N3); + + camp::resources::Resource working_res{WORKING_RES::get_default()}; + INDEX_TYPE* working_array; + INDEX_TYPE* check_array; + INDEX_TYPE* test_array; + + size_t data_len = RAJA::stripIndexType(N); + if ( data_len == 0 ) { + data_len = 1; + } + + allocateForallTestData(data_len, + working_res, + &working_array, + &check_array, + &test_array); + + if ( RAJA::stripIndexType(N) > 0 ) { + + std::iota(test_array, test_array + RAJA::stripIndexType(N), 0); + + constexpr int DIM = 3; + using layout_t = RAJA::Layout; + RAJA::View Aview(working_array, N3, N2, N1); + + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks_x, blocks_y, blocks_z), RAJA::Threads(threads_x, threads_y,threads_z)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::tile(ctx, tile_size_z, r3, [&](RAJA::TypedRangeSegment const &z_tile) { + RAJA::tile(ctx, tile_size_y, r2, [&](RAJA::TypedRangeSegment const &y_tile) { + RAJA::tile(ctx, tile_size_x, r1, [&](RAJA::TypedRangeSegment const &x_tile) { + + RAJA::loop(ctx, z_tile, [&](INDEX_TYPE tz) { + RAJA::loop(ctx, y_tile, [&](INDEX_TYPE ty) { + RAJA::loop(ctx, x_tile, [&](INDEX_TYPE tx) { + + auto idx = tx + N1 * (ty + N2 * tz); + + Aview(tz, ty, tx) = static_cast(idx); + + }); + }); + }); + + }); + }); + }); + }); + } else { // zero-length segment + + memset(static_cast(test_array), 0, sizeof(INDEX_TYPE) * data_len); + + working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * data_len); + + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks_x, blocks_y, blocks_z), RAJA::Threads(blocks_x, blocks_y ,blocks_z)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::tile(ctx, threads_z, r3, [&](RAJA::TypedRangeSegment const &z_tile) { + RAJA::tile(ctx, threads_y, r2, [&](RAJA::TypedRangeSegment const &y_tile) { + RAJA::tile(ctx, threads_x, r1, [&](RAJA::TypedRangeSegment const &x_tile) { + + RAJA::loop(ctx, z_tile, [&](INDEX_TYPE RAJA_UNUSED_ARG(tz)) { + RAJA::loop(ctx, y_tile, [&](INDEX_TYPE RAJA_UNUSED_ARG(ty)) { + RAJA::loop(ctx, x_tile, [&](INDEX_TYPE RAJA_UNUSED_ARG(tx)) { + + working_array[0]++; + + }); + }); + }); + + }); + }); + }); + }); + } + + working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); + + if (RAJA::stripIndexType(N) > 0) { + + for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + } + + } else { + + ASSERT_EQ(test_array[0], check_array[0]); + + } + + deallocateForallTestData(working_res, + working_array, + check_array, + test_array); +} + + +TYPED_TEST_SUITE_P(LaunchNestedTileDirectTest); +template +class LaunchNestedTileDirectTest : public ::testing::Test +{ +}; + + +TYPED_TEST_P(LaunchNestedTileDirectTest, RangeSegmentTeams) +{ + + using INDEX_TYPE = typename camp::at>::type; + using WORKING_RES = typename camp::at>::type; + using LAUNCH_POLICY = typename camp::at>::type, camp::num<0>>::type; + + using THREAD_X_POLICY = typename camp::at>::type, camp::num<1>>::type; + using THREAD_Y_POLICY = typename camp::at>::type, camp::num<2>>::type; + using THREAD_Z_POLICY = typename camp::at>::type, camp::num<3>>::type; + + using TEAM_X_POLICY = typename camp::at>::type, camp::num<4>>::type; + using TEAM_Y_POLICY = typename camp::at>::type, camp::num<5>>::type; + using TEAM_Z_POLICY = typename camp::at>::type, camp::num<6>>::type; + + + // test zero-length range segment + LaunchNestedTileDirectTestImpl + (INDEX_TYPE(0)); + + //Keep at one since we are doing a direct thread test + LaunchNestedTileDirectTestImpl + (INDEX_TYPE(1)); + + +} + +REGISTER_TYPED_TEST_SUITE_P(LaunchNestedTileDirectTest, + RangeSegmentTeams); + +#endif // __TEST_LAUNCH_NESTED_TILE_DIRECT_HPP__ diff --git a/test/functional/launch/nested_tile_loop/CMakeLists.txt b/test/functional/launch/nested_tile_loop/CMakeLists.txt new file mode 100644 index 0000000000..c3e8334503 --- /dev/null +++ b/test/functional/launch/nested_tile_loop/CMakeLists.txt @@ -0,0 +1,23 @@ +############################################################################### +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +# and RAJA project contributors. See the RAJA/LICENSE file for details. +# +# SPDX-License-Identifier: (BSD-3-Clause) +############################################################################### + +# +# Generate tests for each enabled RAJA back-end. +# +# + +foreach( BACKEND ${LAUNCH_BACKENDS} ) + configure_file( test-launch-nested-tile-loop.cpp.in + test-launch-nested-Tile-Loop-${BACKEND}.cpp ) + raja_add_test( NAME test-launch-nested-Tile-Loop-${BACKEND} + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/test-launch-nested-Tile-Loop-${BACKEND}.cpp ) + + target_include_directories(test-launch-nested-Tile-Loop-${BACKEND}.exe + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests) +endforeach() + +unset( NESTEDTYPES ) diff --git a/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in b/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in new file mode 100644 index 0000000000..493be2181a --- /dev/null +++ b/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in @@ -0,0 +1,39 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +// +// test/include headers +// +#include "RAJA_test-base.hpp" +#include "RAJA_test-camp.hpp" +#include "RAJA_test-index-types.hpp" + +#include "RAJA_test-forall-data.hpp" +#include "RAJA_test-launch-loop-teams-threads-3D-execpol.hpp" + +// +// Header for tests in ./tests directory +// +// Note: CMake adds ./tests as an include dir for these tests. +// +#include "test-launch-nested-Tile-Loop.hpp" + + +// +// Cartesian product of types used in parameterized tests +// +using @BACKEND@LaunchNestedTypes = + Test< camp::cartesian_product>::Types; + +// +// Instantiate parameterized test +// +INSTANTIATE_TYPED_TEST_SUITE_P(@BACKEND@, + LaunchNestedTileLoopTest, + @BACKEND@LaunchNestedTypes); diff --git a/test/functional/launch/nested_tile_loop/tests/test-launch-nested-Tile-Loop.hpp b/test/functional/launch/nested_tile_loop/tests/test-launch-nested-Tile-Loop.hpp new file mode 100644 index 0000000000..a7d56987a2 --- /dev/null +++ b/test/functional/launch/nested_tile_loop/tests/test-launch-nested-Tile-Loop.hpp @@ -0,0 +1,182 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +#ifndef __TEST_LAUNCH_NESTED_TILE_LOOP_HPP__ +#define __TEST_LAUNCH_NESTED_TILE_LOOP_HPP__ + +#include + +template +void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) +{ + + constexpr int threads_x = 2; + constexpr int threads_y = 3; + constexpr int threads_z = 4; + + constexpr int blocks_x = 4; + constexpr int blocks_y = 5; + constexpr int blocks_z = 6; + + //Add one to we check the bounds checking capability + RAJA::TypedRangeSegment r1(0, threads_x*M + 1); + RAJA::TypedRangeSegment r2(0, threads_y*M + 1); + RAJA::TypedRangeSegment r3(0, threads_z*M + 1); + + INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); + INDEX_TYPE N2 = static_cast(r2.end() - r2.begin()); + INDEX_TYPE N3 = static_cast(r3.end() - r3.begin()); + + INDEX_TYPE N = static_cast(N1 * + N2 * + N3); + + camp::resources::Resource working_res{WORKING_RES::get_default()}; + INDEX_TYPE* working_array; + INDEX_TYPE* check_array; + INDEX_TYPE* test_array; + + size_t data_len = RAJA::stripIndexType(N); + if ( data_len == 0 ) { + data_len = 1; + } + + allocateForallTestData(data_len, + working_res, + &working_array, + &check_array, + &test_array); + + if ( RAJA::stripIndexType(N) > 0 ) { + + std::iota(test_array, test_array + RAJA::stripIndexType(N), 0); + + constexpr int DIM = 3; + using layout_t = RAJA::Layout; + RAJA::View Aview(working_array, N3, N2, N1); + + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks_x, blocks_y, blocks_z), RAJA::Threads(threads_x, threads_y,threads_z)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::tile(ctx, threads_z, r3, [&](RAJA::TypedRangeSegment const &z_tile) { + RAJA::tile(ctx, threads_y, r2, [&](RAJA::TypedRangeSegment const &y_tile) { + RAJA::tile(ctx, threads_x, r1, [&](RAJA::TypedRangeSegment const &x_tile) { + + RAJA::loop(ctx, z_tile, [&](INDEX_TYPE tz) { + RAJA::loop(ctx, y_tile, [&](INDEX_TYPE ty) { + RAJA::loop(ctx, x_tile, [&](INDEX_TYPE tx) { + + auto idx = tx + N1 * (ty + N2 * tz); + + Aview(tz, ty, tx) = static_cast(idx); + }); + }); + }); + + }); + }); + }); + }); + } else { // zero-length segment + + memset(static_cast(test_array), 0, sizeof(INDEX_TYPE) * data_len); + + working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * data_len); + + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks_x, blocks_y, blocks_z), RAJA::Threads(blocks_x, blocks_y ,blocks_z)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::tile(ctx, threads_z, r3, [&](RAJA::TypedRangeSegment const &z_tile) { + RAJA::tile(ctx, threads_y, r2, [&](RAJA::TypedRangeSegment const &y_tile) { + RAJA::tile(ctx, threads_x, r1, [&](RAJA::TypedRangeSegment const &x_tile) { + + RAJA::loop(ctx, z_tile, [&](INDEX_TYPE tz) { + RAJA::loop(ctx, y_tile, [&](INDEX_TYPE ty) { + RAJA::loop(ctx, x_tile, [&](INDEX_TYPE tx) { + + (void) tx; + (void) ty; + (void) tz; + + working_array[0]++; + }); + }); + }); + + }); + }); + }); + }); + } + + working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); + + if (RAJA::stripIndexType(N) > 0) { + + for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + } + + } else { + + ASSERT_EQ(test_array[0], check_array[0]); + + } + + deallocateForallTestData(working_res, + working_array, + check_array, + test_array); +} + + +TYPED_TEST_SUITE_P(LaunchNestedTileLoopTest); +template +class LaunchNestedTileLoopTest : public ::testing::Test +{ +}; + + +TYPED_TEST_P(LaunchNestedTileLoopTest, RangeSegmentTeams) +{ + + using INDEX_TYPE = typename camp::at>::type; + using WORKING_RES = typename camp::at>::type; + using LAUNCH_POLICY = typename camp::at>::type, camp::num<0>>::type; + + using THREAD_X_POLICY = typename camp::at>::type, camp::num<1>>::type; + using THREAD_Y_POLICY = typename camp::at>::type, camp::num<2>>::type; + using THREAD_Z_POLICY = typename camp::at>::type, camp::num<3>>::type; + + using TEAM_X_POLICY = typename camp::at>::type, camp::num<4>>::type; + using TEAM_Y_POLICY = typename camp::at>::type, camp::num<5>>::type; + using TEAM_Z_POLICY = typename camp::at>::type, camp::num<6>>::type; + + + // test zero-length range segment + LaunchNestedTileLoopTestImpl + (INDEX_TYPE(0)); + + //Keep at one since we are doing a direct thread test + LaunchNestedTileLoopTestImpl + (INDEX_TYPE(1)); + + +} + +REGISTER_TYPED_TEST_SUITE_P(LaunchNestedTileLoopTest, + RangeSegmentTeams); + +#endif // __TEST_LAUNCH_NESTED_TILE_LOOP_HPP__ diff --git a/test/functional/launch/reduce-basic/CMakeLists.txt b/test/functional/launch/reduce-basic/CMakeLists.txt new file mode 100644 index 0000000000..aff230d30e --- /dev/null +++ b/test/functional/launch/reduce-basic/CMakeLists.txt @@ -0,0 +1,75 @@ +############################################################################### +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +# and RAJA project contributors. See the RAJA/LICENSE file for details. +# +# SPDX-License-Identifier: (BSD-3-Clause) +############################################################################### + +# +# List of experimental reduction types for generating test files. +# +set(REDUCETYPES ReduceSum ReduceMin ReduceMax ReduceMaxLoc ReduceMinLoc) + +set(DATATYPES CoreReductionDataTypeList) + +# +# List of core reduction types for generating test files. +# Only does a couple as they are covered in the forall tests +set(REDUCETYPES ReduceSum ReduceMin) + +set(DATATYPES CoreReductionDataTypeList) + + +# +# Generate core reduction tests for each enabled RAJA back-end +# +# Note: LAUNCH_BACKENDS is defined in ../CMakeLists.txt +# +foreach( BACKEND ${LAUNCH_BACKENDS} ) + if( NOT (BACKEND STREQUAL "Sycl")) + foreach( REDUCETYPE ${REDUCETYPES} ) + configure_file( test-launch-basic-reduce.cpp.in + test-launch-basic-${REDUCETYPE}-${BACKEND}.cpp) + raja_add_test( NAME test-launch-basic-${REDUCETYPE}-${BACKEND} + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/test-launch-basic-${REDUCETYPE}-${BACKEND}.cpp ) + + target_include_directories(test-launch-basic-${REDUCETYPE}-${BACKEND}.exe + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests) + endforeach() + endif() +endforeach() + +unset( DATATYPES ) +unset( REDUCETYPES ) + + + +# +# List of bitwise reduction types for generating test files. +# ReduceBitAnd ReduceBitOr -- only does one as they are covered +# in the forall tests +set(REDUCETYPES ReduceBitAnd) + +set(DATATYPES BitwiseReductionDataTypeList) + +# +# Generate bitwise reduction tests for each enabled RAJA back-end +# +# Note: LAUNCH_BACKENDS is defined in ../CMakeLists.txt +# +foreach( BACKEND ${LAUNCH_BACKENDS} ) + if( NOT (BACKEND STREQUAL "Sycl")) + foreach( REDUCETYPE ${REDUCETYPES} ) + configure_file( test-launch-basic-reduce.cpp.in + test-launch-basic-${REDUCETYPE}-${BACKEND}.cpp ) + raja_add_test( NAME test-launch-basic-${REDUCETYPE}-${BACKEND} + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/test-launch-basic-${REDUCETYPE}-${BACKEND}.cpp ) + + target_include_directories(test-launch-basic-${REDUCETYPE}-${BACKEND}.exe + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests) + endforeach() + endif() +endforeach() + +unset( DATATYPES ) +unset( REDUCETYPES ) diff --git a/test/functional/launch/reduce-basic/test-launch-basic-reduce.cpp.in b/test/functional/launch/reduce-basic/test-launch-basic-reduce.cpp.in new file mode 100644 index 0000000000..532b12c177 --- /dev/null +++ b/test/functional/launch/reduce-basic/test-launch-basic-reduce.cpp.in @@ -0,0 +1,63 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +// +// test/include headers +// +#include "RAJA_test-base.hpp" +#include "RAJA_test-camp.hpp" +#include "RAJA_test-index-types.hpp" + +#include "RAJA_test-forall-data.hpp" +#include "RAJA_test-forall-execpol.hpp" +#include "RAJA_test-reducepol.hpp" +#include "RAJA_test-launch-execpol.hpp" + + +// +// Header for tests in ./tests directory +// +// Note: CMake adds ./tests as an include dir for these tests. +// +#include "test-launch-basic-@REDUCETYPE@.hpp" + +// +// Data types for core reduction basic tests +// +using CoreReductionDataTypeList = camp::list< int, + float, + double >; + +// +// Data types for bitwise reduction basic tests +// +using BitwiseReductionDataTypeList = camp::list< int, + unsigned int >; + + +// +// These tests exercise only one index type. We parameterize here to +// make it easier to expand types in the future if needed. +// +using TestIdxTypeList = camp::list< RAJA::Index_type >; + +// +// Cartesian product of types used in parameterized tests +// +using @BACKEND@LaunchReduceBasicTypes = + Test< camp::cartesian_product>::Types; + +// +// Instantiate parameterized test +// +INSTANTIATE_TYPED_TEST_SUITE_P(@BACKEND@, + Launch@REDUCETYPE@BasicTest, + @BACKEND@LaunchReduceBasicTypes); diff --git a/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceBitAnd.hpp b/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceBitAnd.hpp new file mode 100644 index 0000000000..e6dcc56288 --- /dev/null +++ b/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceBitAnd.hpp @@ -0,0 +1,198 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +#ifndef __TEST_LAUNCH_BASIC_REDUCEBITAND_HPP__ +#define __TEST_LAUNCH_BASIC_REDUCEBITAND_HPP__ + +#include +#include +#include +#include + +template +void LaunchReduceBitAndBasicTestImpl(const SEG_TYPE& seg, + const std::vector& seg_idx, + camp::resources::Resource working_res) +{ + IDX_TYPE data_len = seg_idx[seg_idx.size() - 1] + 1; + IDX_TYPE idx_len = static_cast( seg_idx.size() ); + + DATA_TYPE* working_array; + DATA_TYPE* check_array; + DATA_TYPE* test_array; + + constexpr int threads = 256; + int blocks = (seg.size() - 1)/threads + 1; + + allocateForallTestData(data_len, + working_res, + &working_array, + &check_array, + &test_array); + + // + // First a simple non-trivial test that is mildly interesting + // + for (IDX_TYPE i = 0; i < data_len; ++i) { + test_array[i] = 13; + } + working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); + + RAJA::ReduceBitAnd simpand(21); + + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + RAJA::loop(ctx, seg, [&](IDX_TYPE idx) { + + simpand &= working_array[idx]; + }); + }); + + ASSERT_EQ(static_cast(simpand.get()), 5); + + + // + // And now a randomized test that pushes zeros around + // + + const int modval = 100; + + for (IDX_TYPE i = 0; i < data_len; ++i) { + test_array[i] = static_cast( rand() % modval ); + } + working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); + + DATA_TYPE ref_and = 0; + for (IDX_TYPE i = 0; i < idx_len; ++i) { + ref_and &= test_array[ seg_idx[i] ]; + } + + RAJA::ReduceBitAnd redand(0); + RAJA::ReduceBitAnd redand2(2); + + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + RAJA::loop(ctx, seg, [&](IDX_TYPE idx) { + redand &= working_array[idx]; + redand2 &= working_array[idx]; + }); + }); + + ASSERT_EQ(static_cast(redand.get()), ref_and); + ASSERT_EQ(static_cast(redand2.get()), ref_and); + + redand.reset(0); + + const int nloops = 3; + for (int j = 0; j < nloops; ++j) { + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + RAJA::loop(ctx, seg, [&](IDX_TYPE idx) { + redand &= working_array[idx]; + }); + }); + } + + ASSERT_EQ(static_cast(redand.get()), ref_and); + + + deallocateForallTestData(working_res, + working_array, + check_array, + test_array); +} + + +TYPED_TEST_SUITE_P(LaunchReduceBitAndBasicTest); +template +class LaunchReduceBitAndBasicTest : public ::testing::Test +{ +}; + +TYPED_TEST_P(LaunchReduceBitAndBasicTest, ReduceBitAndBasicForall) +{ + using IDX_TYPE = typename camp::at>::type; + using DATA_TYPE = typename camp::at>::type; + using WORKING_RES = typename camp::at>::type; + using LAUNCH_POLICY = typename camp::at>::type, camp::num<0>>::type; + using GLOBAL_THREAD_POLICY = typename camp::at>::type, camp::num<1>>::type; + using REDUCE_POLICY = typename camp::at>::type; + + camp::resources::Resource working_res{WORKING_RES::get_default()}; + + std::vector seg_idx; + +// Range segment tests + RAJA::TypedRangeSegment r1( 0, 28 ); + RAJA::getIndices(seg_idx, r1); + LaunchReduceBitAndBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r1, seg_idx, working_res); + + seg_idx.clear(); + RAJA::TypedRangeSegment r2( 3, 642 ); + RAJA::getIndices(seg_idx, r2); + LaunchReduceBitAndBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r2, seg_idx, working_res); + + seg_idx.clear(); + RAJA::TypedRangeSegment r3( 0, 2057 ); + RAJA::getIndices(seg_idx, r3); + LaunchReduceBitAndBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r3, seg_idx, working_res); + +// Range-stride segment tests + seg_idx.clear(); + RAJA::TypedRangeStrideSegment r4( 0, 188, 2 ); + RAJA::getIndices(seg_idx, r4); + LaunchReduceBitAndBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r4, seg_idx, working_res); + + seg_idx.clear(); + RAJA::TypedRangeStrideSegment r5( 3, 1029, 3 ); + RAJA::getIndices(seg_idx, r5); + LaunchReduceBitAndBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r5, seg_idx, working_res); + + // List segment tests + seg_idx.clear(); + IDX_TYPE last = 10567; + srand( time(NULL) ); + for (IDX_TYPE i = 0; i < last; ++i) { + IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); + if ( i < randval ) { + seg_idx.push_back(i); + } + } + RAJA::TypedListSegment l1( &seg_idx[0], seg_idx.size(), + working_res ); + LaunchReduceBitAndBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + l1, seg_idx, working_res); +} + +REGISTER_TYPED_TEST_SUITE_P(LaunchReduceBitAndBasicTest, + ReduceBitAndBasicForall); + +#endif // __TEST_LAUNCH_BASIC_REDUCEBITOR_HPP__ diff --git a/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceMin.hpp b/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceMin.hpp new file mode 100644 index 0000000000..b7734cf49c --- /dev/null +++ b/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceMin.hpp @@ -0,0 +1,189 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +#ifndef __TEST_LAUNCH_BASIC_REDUCEMIN_HPP__ +#define __TEST_LAUNCH_BASIC_REDUCEMIN_HPP__ + +#include +#include +#include +#include + +template +void LaunchReduceMinBasicTestImpl(const SEG_TYPE& seg, + const std::vector& seg_idx, + camp::resources::Resource working_res) +{ + IDX_TYPE data_len = seg_idx[seg_idx.size() - 1] + 1; + IDX_TYPE idx_len = static_cast( seg_idx.size() ); + + DATA_TYPE* working_array; + DATA_TYPE* check_array; + DATA_TYPE* test_array; + + constexpr int threads = 256; + int blocks = (seg.size() - 1)/threads + 1; + + allocateForallTestData(data_len, + working_res, + &working_array, + &check_array, + &test_array); + + const int modval = 100; + const DATA_TYPE min_init = modval+1; + const DATA_TYPE small_min = -modval; + + for (IDX_TYPE i = 0; i < data_len; ++i) { + test_array[i] = static_cast( rand() % modval ); + } + + DATA_TYPE ref_min = min_init; + for (IDX_TYPE i = 0; i < idx_len; ++i) { + ref_min = RAJA_MIN(test_array[ seg_idx[i] ], ref_min); + } + + working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); + + + RAJA::ReduceMin mininit(small_min); + RAJA::ReduceMin min(min_init); + + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + RAJA::loop(ctx, seg, [&](IDX_TYPE idx) { + + mininit.min( working_array[idx] ); + min.min( working_array[idx] ); + }); + }); + + ASSERT_EQ(static_cast(mininit.get()), small_min); + ASSERT_EQ(static_cast(min.get()), ref_min); + + min.reset(min_init); + ASSERT_EQ(static_cast(min.get()), min_init); + + DATA_TYPE factor = 3; + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + RAJA::loop(ctx, seg, [&](IDX_TYPE idx) { + + min.min( working_array[idx] * factor); + }); + }); + + ASSERT_EQ(static_cast(min.get()), ref_min * factor); + + factor = 2; + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + RAJA::loop(ctx, seg, [&](IDX_TYPE idx) { + + min.min( working_array[idx] * factor); + }); + }); + + ASSERT_EQ(static_cast(min.get()), ref_min * factor); + + + deallocateForallTestData(working_res, + working_array, + check_array, + test_array); +} + + +TYPED_TEST_SUITE_P(LaunchReduceMinBasicTest); +template +class LaunchReduceMinBasicTest : public ::testing::Test +{ +}; + +TYPED_TEST_P(LaunchReduceMinBasicTest, ReduceMinBasicForall) +{ + using IDX_TYPE = typename camp::at>::type; + using DATA_TYPE = typename camp::at>::type; + using WORKING_RES = typename camp::at>::type; + using LAUNCH_POLICY = typename camp::at>::type, camp::num<0>>::type; + using GLOBAL_THREAD_POLICY = typename camp::at>::type, camp::num<1>>::type; + using REDUCE_POLICY = typename camp::at>::type; + + camp::resources::Resource working_res{WORKING_RES::get_default()}; + + std::vector seg_idx; + +// Range segment tests + RAJA::TypedRangeSegment r1( 0, 28 ); + RAJA::getIndices(seg_idx, r1); + LaunchReduceMinBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r1, seg_idx, working_res); + + seg_idx.clear(); + RAJA::TypedRangeSegment r2( 3, 642 ); + RAJA::getIndices(seg_idx, r2); + LaunchReduceMinBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r2, seg_idx, working_res); + + seg_idx.clear(); + RAJA::TypedRangeSegment r3( 0, 2057 ); + RAJA::getIndices(seg_idx, r3); + LaunchReduceMinBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r3, seg_idx, working_res); + +// Range-stride segment tests + seg_idx.clear(); + RAJA::TypedRangeStrideSegment r4( 0, 188, 2 ); + RAJA::getIndices(seg_idx, r4); + LaunchReduceMinBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r4, seg_idx, working_res); + + seg_idx.clear(); + RAJA::TypedRangeStrideSegment r5( 3, 1029, 3 ); + RAJA::getIndices(seg_idx, r5); + LaunchReduceMinBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r5, seg_idx, working_res); + +// List segment tests + seg_idx.clear(); + IDX_TYPE last = 10567; + srand( time(NULL) ); + for (IDX_TYPE i = 0; i < last; ++i) { + IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); + if ( i < randval ) { + seg_idx.push_back(i); + } + } + RAJA::TypedListSegment l1( &seg_idx[0], seg_idx.size(), + working_res ); + LaunchReduceMinBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + l1, seg_idx, working_res); +} + +REGISTER_TYPED_TEST_SUITE_P(LaunchReduceMinBasicTest, + ReduceMinBasicForall); + +#endif // __TEST_LAUNCH_BASIC_REDUCEMIN_HPP__ diff --git a/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceSum.hpp b/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceSum.hpp new file mode 100644 index 0000000000..7c17f359b9 --- /dev/null +++ b/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceSum.hpp @@ -0,0 +1,176 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +#ifndef __TEST_LAUNCH_BASIC_REDUCESUM_HPP__ +#define __TEST_LAUNCH_BASIC_REDUCESUM_HPP__ + +#include +#include +#include +#include + +template +void LaunchReduceSumBasicTestImpl(const SEG_TYPE& seg, + const std::vector& seg_idx, + camp::resources::Resource working_res) +{ + + IDX_TYPE data_len = seg_idx[seg_idx.size() - 1] + 1; + IDX_TYPE idx_len = static_cast( seg_idx.size() ); + + DATA_TYPE* working_array; + DATA_TYPE* check_array; + DATA_TYPE* test_array; + + constexpr int threads = 256; + int blocks = (seg.size() - 1)/threads + 1; + + allocateForallTestData(data_len, + working_res, + &working_array, + &check_array, + &test_array); + + const int modval = 100; + + for (IDX_TYPE i = 0; i < data_len; ++i) { + test_array[i] = static_cast( rand() % modval ); + } + + DATA_TYPE ref_sum = 0; + for (IDX_TYPE i = 0; i < idx_len; ++i) { + ref_sum += test_array[ seg_idx[i] ]; + } + + working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); + + + RAJA::ReduceSum sum(0); + RAJA::ReduceSum sum2(2); + + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + RAJA::loop(ctx, seg, [&](IDX_TYPE idx) { + sum += working_array[idx]; + sum2 += working_array[idx]; + }); + }); + + ASSERT_EQ(static_cast(sum.get()), ref_sum); + ASSERT_EQ(static_cast(sum2.get()), ref_sum + 2); + + sum.reset(0); + + const int nloops = 2; + + for (int j = 0; j < nloops; ++j) { + RAJA::launch + (RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), + [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::loop(ctx, seg, [&](IDX_TYPE idx) { + sum += working_array[idx]; + }); + }); + } + + ASSERT_EQ(static_cast(sum.get()), nloops * ref_sum); + + + deallocateForallTestData(working_res, + working_array, + check_array, + test_array); +} + + +TYPED_TEST_SUITE_P(LaunchReduceSumBasicTest); +template +class LaunchReduceSumBasicTest : public ::testing::Test +{ +}; + +TYPED_TEST_P(LaunchReduceSumBasicTest, ReduceSumBasicForall) +{ + using IDX_TYPE = typename camp::at>::type; + using DATA_TYPE = typename camp::at>::type; + using WORKING_RES = typename camp::at>::type; + using LAUNCH_POLICY = typename camp::at>::type, camp::num<0>>::type; + using GLOBAL_THREAD_POLICY = typename camp::at>::type, camp::num<1>>::type; + using REDUCE_POLICY = typename camp::at>::type; + + camp::resources::Resource working_res{WORKING_RES::get_default()}; + + std::vector seg_idx; + +// Range segment tests + RAJA::TypedRangeSegment r1( 0, 28 ); + RAJA::getIndices(seg_idx, r1); + LaunchReduceSumBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r1, seg_idx, working_res); + seg_idx.clear(); + RAJA::TypedRangeSegment r2( 3, 642 ); + RAJA::getIndices(seg_idx, r2); + LaunchReduceSumBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r2, seg_idx, working_res); + + seg_idx.clear(); + RAJA::TypedRangeSegment r3( 0, 2057 ); + RAJA::getIndices(seg_idx, r3); + LaunchReduceSumBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r3, seg_idx, working_res); + +// Range-stride segment tests + seg_idx.clear(); + RAJA::TypedRangeStrideSegment r4( 0, 188, 2 ); + RAJA::getIndices(seg_idx, r4); + LaunchReduceSumBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r4, seg_idx, working_res); + + seg_idx.clear(); + RAJA::TypedRangeStrideSegment r5( 3, 1029, 3 ); + RAJA::getIndices(seg_idx, r5); + LaunchReduceSumBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + r5, seg_idx, working_res); + +// List segment tests + seg_idx.clear(); + IDX_TYPE last = 10567; + srand( time(NULL) ); + for (IDX_TYPE i = 0; i < last; ++i) { + IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); + if ( i < randval ) { + seg_idx.push_back(i); + } + } + RAJA::TypedListSegment l1( &seg_idx[0], seg_idx.size(), + working_res ); + LaunchReduceSumBasicTestImpl, + LAUNCH_POLICY, GLOBAL_THREAD_POLICY, REDUCE_POLICY>( + l1, seg_idx, working_res); +} + +REGISTER_TYPED_TEST_SUITE_P(LaunchReduceSumBasicTest, + ReduceSumBasicForall); + +#endif // __TEST_LAUNCH_BASIC_REDUCESUM_HPP__ diff --git a/test/functional/launch/run-time-switch/tests/test-launch-BasicShared.hpp b/test/functional/launch/run-time-switch/tests/test-launch-BasicShared.hpp index 485803541c..3dc1de2e4f 100644 --- a/test/functional/launch/run-time-switch/tests/test-launch-BasicShared.hpp +++ b/test/functional/launch/run-time-switch/tests/test-launch-BasicShared.hpp @@ -26,29 +26,31 @@ void LaunchBasicSharedTestImpl() &working_array, &check_array, &test_array); - + //Select platform RAJA::ExecPlace select_cpu_or_gpu; if (working_res.get_platform() == camp::resources::Platform::host){ select_cpu_or_gpu = RAJA::ExecPlace::HOST; - }else{ + }else{ select_cpu_or_gpu = RAJA::ExecPlace::DEVICE; } + size_t shared_mem_size = 1 * sizeof(int); - RAJA::launch(select_cpu_or_gpu, - RAJA::LaunchParams(RAJA::Teams(N), RAJA::Threads(N)), + RAJA::launch + (select_cpu_or_gpu, + RAJA::LaunchParams(RAJA::Teams(N), RAJA::Threads(N), shared_mem_size), [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { RAJA::loop(ctx, RAJA::RangeSegment(0, N), [&](int r) { // Array shared within threads of the same team - RAJA_TEAM_SHARED int s_A[1]; + int * s_A = ctx.getSharedMemory(1); RAJA::loop(ctx, RAJA::RangeSegment(0, 1), [&](int c) { - s_A[c] = r; + s_A[c] = r; }); ctx.teamSync(); @@ -59,6 +61,7 @@ void LaunchBasicSharedTestImpl() working_array[idx] = s_A[0]; }); // loop j + ctx.releaseSharedMemory(); }); // loop r }); // outer lambda diff --git a/test/functional/launch/segment/CMakeLists.txt b/test/functional/launch/segment/CMakeLists.txt index 61004abba1..4d6d91e469 100644 --- a/test/functional/launch/segment/CMakeLists.txt +++ b/test/functional/launch/segment/CMakeLists.txt @@ -8,8 +8,6 @@ # # List of segment types for generating test files. # -# TODO: Support list segments with RAJA Launch -# set(SEGTYPES ListSegment RangeSegment RangeStrideSegment) diff --git a/test/functional/launch/segment/tests/test-launch-ListSegment.hpp b/test/functional/launch/segment/tests/test-launch-ListSegment.hpp index 386904033a..a7929aebf7 100644 --- a/test/functional/launch/segment/tests/test-launch-ListSegment.hpp +++ b/test/functional/launch/segment/tests/test-launch-ListSegment.hpp @@ -98,10 +98,15 @@ void LaunchListSegmentTestImpl(INDEX_TYPE N) working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { - ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + if (RAJA::stripIndexType(N) > 0) { + for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + } + } else { + ASSERT_EQ(test_array[0], check_array[0]); } + deallocateForallTestData(working_res, working_array, check_array, diff --git a/test/functional/launch/segment/tests/test-launch-RangeSegment.hpp b/test/functional/launch/segment/tests/test-launch-RangeSegment.hpp index f92adacc77..9a5856777c 100644 --- a/test/functional/launch/segment/tests/test-launch-RangeSegment.hpp +++ b/test/functional/launch/segment/tests/test-launch-RangeSegment.hpp @@ -42,37 +42,49 @@ void LaunchRangeSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last) std::iota(test_array, test_array + RAJA::stripIndexType(N), rbegin); - RAJA::launch - (RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), + RAJA::launch( + RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { - - RAJA::loop(ctx, r1, [&](INDEX_TYPE idx) { + + RAJA::loop( + ctx, r1, [&](INDEX_TYPE idx) { working_array[RAJA::stripIndexType(idx - rbegin)] = idx; - }); - }); + } + ); + } + ); - } else { // zero-length segment + } else { // zero-length segment memset(static_cast(test_array), 0, sizeof(INDEX_TYPE) * data_len); working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * data_len); - RAJA::launch - (RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), - [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { - - RAJA::loop(ctx, r1, [&](INDEX_TYPE idx) { - (void) idx; + RAJA::launch( + RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::loop( + ctx, r1, [&](INDEX_TYPE RAJA_UNUSED_ARG(idx)) { working_array[0]++; - }); - }); + } + ); + } + ); } working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { - ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + if (RAJA::stripIndexType(N) > 0) { + + for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + } + + } else { + + ASSERT_EQ(test_array[0], check_array[0]); + } deallocateForallTestData(working_res, @@ -105,7 +117,7 @@ void runNegativeTests() LaunchRangeSegmentTestImpl(INDEX_TYPE(-5), INDEX_TYPE(5)); } -TYPED_TEST_P(LaunchRangeSegmentTest, RangeSegmentTeams) +TYPED_TEST_P(LaunchRangeSegmentTest, RangeSegmentTeams) { using INDEX_TYPE = typename camp::at>::type; diff --git a/test/functional/launch/segment/tests/test-launch-RangeStrideSegment.hpp b/test/functional/launch/segment/tests/test-launch-RangeStrideSegment.hpp index 861a8847d2..690b61a29c 100644 --- a/test/functional/launch/segment/tests/test-launch-RangeStrideSegment.hpp +++ b/test/functional/launch/segment/tests/test-launch-RangeStrideSegment.hpp @@ -10,9 +10,9 @@ #include -template -void LaunchRangeStrideSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last, +void LaunchRangeStrideSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last, DIFF_TYPE stride) { RAJA::TypedRangeStrideSegment r1(RAJA::stripIndexType(first), RAJA::stripIndexType(last), stride); @@ -37,7 +37,7 @@ void LaunchRangeStrideSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last, memset(static_cast(test_array), 0, sizeof(INDEX_TYPE) * data_len); - working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * data_len); + working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * data_len); constexpr int threads = 256; int blocks = (data_len - 1)/threads + 1; @@ -47,38 +47,48 @@ void LaunchRangeStrideSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last, INDEX_TYPE idx = first; for (INDEX_TYPE i = INDEX_TYPE(0); i < N; ++i) { test_array[ RAJA::stripIndexType((idx-first)/stride) ] = idx; - idx += stride; + idx += stride; } - - RAJA::launch - (RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), - [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { - - RAJA::loop(ctx, r1, [&](INDEX_TYPE idx) { + + RAJA::launch( + RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::loop( + ctx, r1, [&](INDEX_TYPE idx) { working_array[ RAJA::stripIndexType((idx-first)/stride) ] = idx; - }); + } + ); - }); + } + ); } else { // zero-length segment - RAJA::launch - (RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), - [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { - - RAJA::loop(ctx, r1, [&](INDEX_TYPE idx) { - working_array[ RAJA::stripIndexType((idx-first)/stride) ] = idx; - (void) idx; + RAJA::launch( + RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::loop( + ctx, r1, [&](INDEX_TYPE RAJA_UNUSED_ARG(idx)) { working_array[0]++; - }); + } + ); - }); + } + ); } working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { - ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + if (RAJA::stripIndexType(N) > 0) { + + for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + } + + } else { + + ASSERT_EQ(test_array[0], check_array[0]); + } deallocateForallTestData(working_res, diff --git a/test/functional/launch/shared_mem/CMakeLists.txt b/test/functional/launch/shared_mem/CMakeLists.txt index 563ea0803c..ec013b85ac 100644 --- a/test/functional/launch/shared_mem/CMakeLists.txt +++ b/test/functional/launch/shared_mem/CMakeLists.txt @@ -18,6 +18,7 @@ set(SHARED_MEM_TYPES DynamicMem StaticMem) foreach( BACKEND ${LAUNCH_BACKENDS} ) foreach( SHARED_MEM_TYPES ${SHARED_MEM_TYPES} ) + if( NOT ((BACKEND STREQUAL "Sycl") AND (SHARED_MEM_TYPES STREQUAL "StaticMem"))) configure_file( test-launch-shared-mem.cpp.in test-launch-shared-mem-${SHARED_MEM_TYPES}-${BACKEND}.cpp ) raja_add_test( NAME test-launch-shared-mem-${SHARED_MEM_TYPES}-${BACKEND} @@ -25,6 +26,7 @@ foreach( BACKEND ${LAUNCH_BACKENDS} ) target_include_directories(test-launch-shared-mem-${SHARED_MEM_TYPES}-${BACKEND}.exe PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests) + endif() endforeach() endforeach() diff --git a/test/functional/launch/shared_mem/test-launch-shared-mem.cpp.in b/test/functional/launch/shared_mem/test-launch-shared-mem.cpp.in index 0bc7376ca6..f3a1781438 100644 --- a/test/functional/launch/shared_mem/test-launch-shared-mem.cpp.in +++ b/test/functional/launch/shared_mem/test-launch-shared-mem.cpp.in @@ -13,7 +13,7 @@ #include "RAJA_test-index-types.hpp" #include "RAJA_test-forall-data.hpp" -#include "RAJA_test-launch-teams_threads_1D_execpol.hpp" +#include "RAJA_test-launch-direct-teams-threads-1D-execpol.hpp" // // Header for tests in ./tests directory diff --git a/test/functional/launch/tile_icount_direct/CMakeLists.txt b/test/functional/launch/tile_icount_direct/CMakeLists.txt new file mode 100644 index 0000000000..0e05771192 --- /dev/null +++ b/test/functional/launch/tile_icount_direct/CMakeLists.txt @@ -0,0 +1,22 @@ +############################################################################### +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +# and RAJA project contributors. See the RAJA/LICENSE file for details. +# +# SPDX-License-Identifier: (BSD-3-Clause) +############################################################################### + +# +# Generate tests for each enabled RAJA back-end. +# +# + +foreach( BACKEND ${LAUNCH_BACKENDS} ) + configure_file( test-launch-nested-tile-icount-direct.cpp.in + test-launch-nested-Tile-iCount-Direct-${BACKEND}.cpp ) + raja_add_test( NAME test-launch-nested-Tile-iCount-Direct-${BACKEND} + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/test-launch-nested-Tile-iCount-Direct-${BACKEND}.cpp ) + + target_include_directories(test-launch-nested-Tile-iCount-Direct-${BACKEND}.exe + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests) +endforeach() + diff --git a/test/functional/launch/tile_icount_direct/test-launch-nested-tile-icount-direct.cpp.in b/test/functional/launch/tile_icount_direct/test-launch-nested-tile-icount-direct.cpp.in new file mode 100644 index 0000000000..c5fe291da0 --- /dev/null +++ b/test/functional/launch/tile_icount_direct/test-launch-nested-tile-icount-direct.cpp.in @@ -0,0 +1,39 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +// +// test/include headers +// +#include "RAJA_test-base.hpp" +#include "RAJA_test-camp.hpp" +#include "RAJA_test-index-types.hpp" + +#include "RAJA_test-forall-data.hpp" +#include "RAJA_test-launch-direct-teams-threads-1D-execpol.hpp" + +// +// Header for tests in ./tests directory +// +// Note: CMake adds ./tests as an include dir for these tests. +// +#include "test-launch-nested-Tile-iCount-Direct.hpp" + + +// +// Cartesian product of types used in parameterized tests +// +using @BACKEND@LaunchNestedTypes = + Test< camp::cartesian_product>::Types; + +// +// Instantiate parameterized test +// +INSTANTIATE_TYPED_TEST_SUITE_P(@BACKEND@, + LaunchNestedTileDirectTest, + @BACKEND@LaunchNestedTypes); diff --git a/test/functional/launch/tile_icount_direct/tests/test-launch-nested-Tile-iCount-Direct.hpp b/test/functional/launch/tile_icount_direct/tests/test-launch-nested-Tile-iCount-Direct.hpp new file mode 100644 index 0000000000..cdd4a31287 --- /dev/null +++ b/test/functional/launch/tile_icount_direct/tests/test-launch-nested-Tile-iCount-Direct.hpp @@ -0,0 +1,178 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +#ifndef __TEST_LAUNCH_NESTED_TILE_ICOUNT_DIRECT_HPP__ +#define __TEST_LAUNCH_NESTED_TILE_ICOUNT_DIRECT_HPP__ + +#include + +template +void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) +{ + + constexpr int threads_x = 4; + constexpr int blocks_x = 4; + + RAJA::TypedRangeSegment r1(0, M*threads_x+1); + + INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); + + INDEX_TYPE no_tiles = (N1-1)/threads_x + 1; + + INDEX_TYPE N = static_cast(RAJA::stripIndexType(N1)); + + camp::resources::Resource working_res{WORKING_RES::get_default()}; + INDEX_TYPE* working_ttile_array; + INDEX_TYPE* check_ttile_array; + INDEX_TYPE* test_ttile_array; + + INDEX_TYPE* working_iloop_array; + INDEX_TYPE* check_iloop_array; + INDEX_TYPE* test_iloop_array; + + size_t data_len = RAJA::stripIndexType(N); + if ( data_len == 0 ) { + data_len = 1; + } + + allocateForallTestData(data_len, + working_res, + &working_ttile_array, + &check_ttile_array, + &test_ttile_array); + + allocateForallTestData(data_len, + working_res, + &working_iloop_array, + &check_iloop_array, + &test_iloop_array); + + if ( RAJA::stripIndexType(N) > 0 ) { + + std::iota(test_ttile_array, test_ttile_array + RAJA::stripIndexType(N), 0); + std::iota(test_iloop_array, test_iloop_array + RAJA::stripIndexType(N), 0); + + RAJA::launch( + RAJA::LaunchParams(RAJA::Teams(blocks_x), RAJA::Threads(threads_x)), [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::tile_tcount( + ctx, threads_x, r1, [&](RAJA::TypedRangeSegment const &x_tile, INDEX_TYPE bx) { + RAJA::loop_icount( + ctx, x_tile, [&](INDEX_TYPE tx, INDEX_TYPE ix) { + + working_ttile_array[tx] = bx; + working_iloop_array[tx] = ix; + + } + ); + } + ); + } + ); + + } else { // zero-length segment + + memset(static_cast(test_ttile_array), 0, sizeof(INDEX_TYPE) * data_len); + + working_res.memcpy(working_ttile_array, test_ttile_array, sizeof(INDEX_TYPE) * data_len); + + RAJA::launch( + RAJA::LaunchParams(RAJA::Teams(blocks_x), RAJA::Threads(blocks_x)), [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::tile_tcount( + ctx, threads_x, r1, [&](RAJA::TypedRangeSegment const &x_tile, INDEX_TYPE RAJA_UNUSED_ARG(bx)) { + RAJA::loop_icount( + ctx, x_tile, [&](INDEX_TYPE RAJA_UNUSED_ARG(tx), INDEX_TYPE RAJA_UNUSED_ARG (ix)) { + + working_ttile_array[0]++; + working_iloop_array[0]++; + + } + ); + } + ); + } + ); + } + + working_res.memcpy(check_ttile_array, working_ttile_array, sizeof(INDEX_TYPE) * data_len); + working_res.memcpy(check_iloop_array, working_iloop_array, sizeof(INDEX_TYPE) * data_len); + + if (RAJA::stripIndexType(N) > 0) { + + INDEX_TYPE idx = 0; + for (INDEX_TYPE bx = INDEX_TYPE(0); bx < no_tiles; ++bx) { + for (INDEX_TYPE tx = INDEX_TYPE(0); tx < threads_x; ++tx) { + + if(idx >= N1) break; + + ASSERT_EQ(check_ttile_array[RAJA::stripIndexType(idx)], bx); + ASSERT_EQ(check_iloop_array[RAJA::stripIndexType(idx)], tx); + + idx++; + } + } + + } else { + + ASSERT_EQ(check_ttile_array[0], check_ttile_array[0]); + ASSERT_EQ(check_iloop_array[0], check_iloop_array[0]); + + } + + deallocateForallTestData(working_res, + working_ttile_array, + check_ttile_array, + test_ttile_array); + + deallocateForallTestData(working_res, + working_iloop_array, + check_iloop_array, + test_iloop_array); +} + + +TYPED_TEST_SUITE_P(LaunchNestedTileDirectTest); +template +class LaunchNestedTileDirectTest : public ::testing::Test +{ +}; + + +TYPED_TEST_P(LaunchNestedTileDirectTest, RangeSegmentTeams) +{ + + using INDEX_TYPE = typename camp::at>::type; + using WORKING_RES = typename camp::at>::type; + using LAUNCH_POLICY = typename camp::at>::type, camp::num<0>>::type; + + using TEAM_X_POLICY = typename camp::at>::type, camp::num<1>>::type; + using THREAD_X_POLICY = typename camp::at>::type, camp::num<2>>::type; + + + // test zero-length range segment + LaunchNestedTileDirectTestImpl + (INDEX_TYPE(0)); + + //Keep at one since we are doing a direct thread test + LaunchNestedTileDirectTestImpl + (INDEX_TYPE(1)); + + LaunchNestedTileDirectTestImpl + (INDEX_TYPE(2)); + + +} + +REGISTER_TYPED_TEST_SUITE_P(LaunchNestedTileDirectTest, + RangeSegmentTeams); + +#endif // __TEST_LAUNCH_NESTED_TILE_DIRECT_HPP__ diff --git a/test/functional/launch/tile_icount_loop/CMakeLists.txt b/test/functional/launch/tile_icount_loop/CMakeLists.txt new file mode 100644 index 0000000000..d632479280 --- /dev/null +++ b/test/functional/launch/tile_icount_loop/CMakeLists.txt @@ -0,0 +1,22 @@ +############################################################################### +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +# and RAJA project contributors. See the RAJA/LICENSE file for details. +# +# SPDX-License-Identifier: (BSD-3-Clause) +############################################################################### + +# +# Generate tests for each enabled RAJA back-end. +# +# + +foreach( BACKEND ${LAUNCH_BACKENDS} ) + configure_file( test-launch-nested-tile-icount-loop.cpp.in + test-launch-nested-Tile-iCount-Loop-${BACKEND}.cpp ) + raja_add_test( NAME test-launch-nested-Tile-iCount-Loop-${BACKEND} + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/test-launch-nested-Tile-iCount-Loop-${BACKEND}.cpp ) + + target_include_directories(test-launch-nested-Tile-iCount-Loop-${BACKEND}.exe + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests) +endforeach() + diff --git a/test/functional/launch/tile_icount_loop/test-launch-nested-tile-icount-loop.cpp.in b/test/functional/launch/tile_icount_loop/test-launch-nested-tile-icount-loop.cpp.in new file mode 100644 index 0000000000..47131b3a55 --- /dev/null +++ b/test/functional/launch/tile_icount_loop/test-launch-nested-tile-icount-loop.cpp.in @@ -0,0 +1,39 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +// +// test/include headers +// +#include "RAJA_test-base.hpp" +#include "RAJA_test-camp.hpp" +#include "RAJA_test-index-types.hpp" + +#include "RAJA_test-forall-data.hpp" +#include "RAJA_test-launch-loop-teams-threads-1D-execpol.hpp" + +// +// Header for tests in ./tests loopory +// +// Note: CMake adds ./tests as an include dir for these tests. +// +#include "test-launch-nested-Tile-iCount-Loop.hpp" + + +// +// Cartesian product of types used in parameterized tests +// +using @BACKEND@LaunchNestedTypes = + Test< camp::cartesian_product>::Types; + +// +// Instantiate parameterized test +// +INSTANTIATE_TYPED_TEST_SUITE_P(@BACKEND@, + LaunchNestedTileLoopTest, + @BACKEND@LaunchNestedTypes); diff --git a/test/functional/launch/tile_icount_loop/tests/test-launch-nested-Tile-iCount-Loop.hpp b/test/functional/launch/tile_icount_loop/tests/test-launch-nested-Tile-iCount-Loop.hpp new file mode 100644 index 0000000000..76133f67eb --- /dev/null +++ b/test/functional/launch/tile_icount_loop/tests/test-launch-nested-Tile-iCount-Loop.hpp @@ -0,0 +1,182 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +#ifndef __TEST_LAUNCH_NESTED_TILE_ICOUNT_LOOP_hpp__ +#define __TEST_LAUNCH_NESTED_TILE_ICOUNT_LOOP_hpp__ + +#include + +template +void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) +{ + + constexpr int tile_size = 4; + + //following grid will require loop policies + constexpr int threads_x = 3; + constexpr int blocks_x = 1; + + RAJA::TypedRangeSegment r1(0, M*tile_size+1); + + INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); + + INDEX_TYPE no_tiles = (N1-1)/tile_size + 1; + + INDEX_TYPE N = static_cast(RAJA::stripIndexType(N1)); + + camp::resources::Resource working_res{WORKING_RES::get_default()}; + INDEX_TYPE* working_ttile_array; + INDEX_TYPE* check_ttile_array; + INDEX_TYPE* test_ttile_array; + + INDEX_TYPE* working_iloop_array; + INDEX_TYPE* check_iloop_array; + INDEX_TYPE* test_iloop_array; + + size_t data_len = RAJA::stripIndexType(N); + if ( data_len == 0 ) { + data_len = 1; + } + + allocateForallTestData(data_len, + working_res, + &working_ttile_array, + &check_ttile_array, + &test_ttile_array); + + allocateForallTestData(data_len, + working_res, + &working_iloop_array, + &check_iloop_array, + &test_iloop_array); + + if ( RAJA::stripIndexType(N) > 0 ) { + + std::iota(test_ttile_array, test_ttile_array + RAJA::stripIndexType(N), 0); + std::iota(test_iloop_array, test_iloop_array + RAJA::stripIndexType(N), 0); + + RAJA::launch( + RAJA::LaunchParams(RAJA::Teams(blocks_x), RAJA::Threads(threads_x)), [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::tile_tcount( + ctx, tile_size, r1, [&](RAJA::TypedRangeSegment const &x_tile, INDEX_TYPE bx) { + RAJA::loop_icount( + ctx, x_tile, [&](INDEX_TYPE tx, INDEX_TYPE ix) { + + working_ttile_array[tx] = bx; + working_iloop_array[tx] = ix; + + } + ); + } + ); + } + ); + } else { // zero-length segment + + memset(static_cast(test_ttile_array), 0, sizeof(INDEX_TYPE) * data_len); + + working_res.memcpy(working_ttile_array, test_ttile_array, sizeof(INDEX_TYPE) * data_len); + + RAJA::launch( + RAJA::LaunchParams(RAJA::Teams(blocks_x), RAJA::Threads(blocks_x)), [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { + + RAJA::tile_tcount + (ctx, tile_size, r1, [&](RAJA::TypedRangeSegment const &x_tile, INDEX_TYPE RAJA_UNUSED_ARG(bx)) { + + RAJA::loop_icount + (ctx, x_tile, [&](INDEX_TYPE RAJA_UNUSED_ARG(tx), INDEX_TYPE RAJA_UNUSED_ARG(ix)) { + + working_ttile_array[0]++; + working_iloop_array[0]++; + + } + ); + } + ); + } + ); + } + + working_res.memcpy(check_ttile_array, working_ttile_array, sizeof(INDEX_TYPE) * data_len); + working_res.memcpy(check_iloop_array, working_iloop_array, sizeof(INDEX_TYPE) * data_len); + + if (RAJA::stripIndexType(N) > 0) { + + INDEX_TYPE idx = 0; + for (INDEX_TYPE bx = INDEX_TYPE(0); bx < no_tiles; ++bx) { + for (INDEX_TYPE tx = INDEX_TYPE(0); tx < tile_size; ++tx) { + + if(idx >= N1) break; + + ASSERT_EQ(check_ttile_array[RAJA::stripIndexType(idx)], bx); + ASSERT_EQ(check_iloop_array[RAJA::stripIndexType(idx)], tx); + + idx++; + } + } + + } else { + + ASSERT_EQ(check_ttile_array[0], check_ttile_array[0]); + ASSERT_EQ(check_iloop_array[0], check_iloop_array[0]); + + } + + deallocateForallTestData(working_res, + working_ttile_array, + check_ttile_array, + test_ttile_array); + + deallocateForallTestData(working_res, + working_iloop_array, + check_iloop_array, + test_iloop_array); +} + + +TYPED_TEST_SUITE_P(LaunchNestedTileLoopTest); +template +class LaunchNestedTileLoopTest : public ::testing::Test +{ +}; + + +TYPED_TEST_P(LaunchNestedTileLoopTest, RangeSegmentTeams) +{ + + using INDEX_TYPE = typename camp::at>::type; + using WORKING_RES = typename camp::at>::type; + using LAUNCH_POLICY = typename camp::at>::type, camp::num<0>>::type; + + using TEAM_X_POLICY = typename camp::at>::type, camp::num<1>>::type; + using THREAD_X_POLICY = typename camp::at>::type, camp::num<2>>::type; + + + + // test zero-length range segment + LaunchNestedTileLoopTestImpl + (INDEX_TYPE(0)); + + //Keep at one since we are doing a direct thread test + LaunchNestedTileLoopTestImpl + (INDEX_TYPE(1)); + + LaunchNestedTileLoopTestImpl + (INDEX_TYPE(2)); + + +} + +REGISTER_TYPED_TEST_SUITE_P(LaunchNestedTileLoopTest, + RangeSegmentTeams); + +#endif // __TEST_LAUNCH_NESTED_TILE_DIRECT_HPP__ diff --git a/test/include/RAJA_test-launch-direct-teams-threads-1D-execpol.hpp b/test/include/RAJA_test-launch-direct-teams-threads-1D-execpol.hpp new file mode 100644 index 0000000000..5b5dfdbebf --- /dev/null +++ b/test/include/RAJA_test-launch-direct-teams-threads-1D-execpol.hpp @@ -0,0 +1,93 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +// +// Execution policy lists used throughout launch tests +// + +#ifndef __RAJA_TEST_LAUNCH_DIRECT_TEAMS_THREADS_1D_EXECPOL_HPP__ +#define __RAJA_TEST_LAUNCH_DIRECT_TEAMS_THREADS_1D_EXECPOL_HPP__ + +#include "RAJA/RAJA.hpp" +#include "camp/list.hpp" + +//Launch policies +using seq_policies = + camp::list< + RAJA::LaunchPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Sequential_launch_policies = + camp::list< + seq_policies + >; + +#if defined(RAJA_ENABLE_OPENMP) +using omp_policies = + camp::list< + RAJA::LaunchPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using OpenMP_launch_policies = camp::list; + +#endif // RAJA_ENABLE_OPENMP + +#if defined(RAJA_ENABLE_CUDA) + +using cuda_direct_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using cuda_direct_explicit_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Cuda_launch_policies = + camp::list< + cuda_direct_policies, + cuda_direct_explicit_policies + >; +#endif // RAJA_ENABLE_CUDA + +#if defined(RAJA_ENABLE_HIP) + +using hip_direct_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Hip_launch_policies = camp::list; + +#endif // RAJA_ENABLE_HIP + +#if defined(RAJA_ENABLE_SYCL) + +using sycl_direct_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Sycl_launch_policies = camp::list; + +#endif + + +#endif // __RAJA_TEST_LAUNCH_DIRECT_TEAMS_THREADS_1D_EXECPOL_HPP__ diff --git a/test/include/RAJA_test-launch-direct-teams-threads-3D-execpol.hpp b/test/include/RAJA_test-launch-direct-teams-threads-3D-execpol.hpp new file mode 100644 index 0000000000..42fca2ccfe --- /dev/null +++ b/test/include/RAJA_test-launch-direct-teams-threads-3D-execpol.hpp @@ -0,0 +1,116 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +// +// Execution policy lists used throughout launch tests +// + +#ifndef __RAJA_TEST_LAUNCH_DIRECT_TEAM_THREADS_3D_EXECPOL_HPP__ +#define __RAJA_TEST_LAUNCH_DIRECT_TEAM_THREADS_3D_EXECPOL_HPP__ + +#include "RAJA/RAJA.hpp" +#include "camp/list.hpp" + +//Launch policies +using seq_policies = + camp::list< + RAJA::LaunchPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Sequential_launch_policies = camp::list; + +#if defined(RAJA_ENABLE_OPENMP) + +using omp_policies = + camp::list< + RAJA::LaunchPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using OpenMP_launch_policies = camp::list; + +#endif // RAJA_ENABLE_OPENMP + +#if defined(RAJA_ENABLE_CUDA) + +using cuda_direct_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using cuda_direct_explicit_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Cuda_launch_policies = + camp::list< + cuda_direct_policies, + cuda_direct_explicit_policies + >; + +#endif // RAJA_ENABLE_CUDA + +#if defined(RAJA_ENABLE_HIP) + +using hip_direct_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Hip_launch_policies = camp::list; + +#endif // RAJA_ENABLE_HIP + +#if defined(RAJA_ENABLE_SYCL) + +using sycl_direct_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Sycl_launch_policies = camp::list; + +#endif + + +#endif //__RAJA_TEST_LAUNCH_DIRECT_TEAM_THREADS_3D_EXECPOL_HPP__ diff --git a/test/include/RAJA_test-launch-execpol.hpp b/test/include/RAJA_test-launch-execpol.hpp index 93e014f0e7..772b04edb0 100644 --- a/test/include/RAJA_test-launch-execpol.hpp +++ b/test/include/RAJA_test-launch-execpol.hpp @@ -9,8 +9,8 @@ // Execution policy lists used throughout launch tests // -#ifndef __RAJA_test_launch_execpol_HPP__ -#define __RAJA_test_launch_execpol_HPP__ +#ifndef __RAJA_TEST_LAUNCH_EXECPOL_HPP__ +#define __RAJA_TEST_LAUNCH_EXECPOL_HPP__ #include "RAJA/RAJA.hpp" #include "camp/list.hpp" @@ -64,5 +64,16 @@ using Hip_launch_policies = camp::list< >; #endif // RAJA_ENABLE_HIP +#if defined(RAJA_ENABLE_SYCL) -#endif // __RAJA_test_launch_execpol_HPP__ +using sycl_policies = camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy>; + +using Sycl_launch_policies = camp::list< + sycl_policies + >; +#endif // RAJA_ENABLE_SYCL + + +#endif // __RAJA_TEST_LAUNCH_EXECPOL_HPP__ diff --git a/test/include/RAJA_test-launch-teams_threads_1D_execpol.hpp b/test/include/RAJA_test-launch-loop-teams-threads-1D-execpol.hpp similarity index 54% rename from test/include/RAJA_test-launch-teams_threads_1D_execpol.hpp rename to test/include/RAJA_test-launch-loop-teams-threads-1D-execpol.hpp index a23aca3f13..43a2c3ccd6 100644 --- a/test/include/RAJA_test-launch-teams_threads_1D_execpol.hpp +++ b/test/include/RAJA_test-launch-loop-teams-threads-1D-execpol.hpp @@ -9,8 +9,8 @@ // Execution policy lists used throughout launch tests // -#ifndef __RAJA_test_launch_teams_threads_1D_execpol_HPP__ -#define __RAJA_test_launch_teams_threads_1D_execpol_HPP__ +#ifndef __RAJA_TEST_LAUNCH_TEAMS_THREADS_LOOP_3D_EXECPOL_HPP__ +#define __RAJA_TEST_LAUNCH_TEAMS_THREADS_LOOP_3D_EXECPOL_HPP__ #include "RAJA/RAJA.hpp" #include "camp/list.hpp" @@ -18,8 +18,8 @@ //Launch policies using seq_policies = camp::list< RAJA::LaunchPolicy, - RAJA::LoopPolicy, - RAJA::LoopPolicy + RAJA::LoopPolicy, + RAJA::LoopPolicy >; using Sequential_launch_policies = camp::list< @@ -30,7 +30,7 @@ using Sequential_launch_policies = camp::list< using omp_policies = camp::list< RAJA::LaunchPolicy, RAJA::LoopPolicy, - RAJA::LoopPolicy + RAJA::LoopPolicy >; using OpenMP_launch_policies = camp::list< @@ -41,37 +41,48 @@ using OpenMP_launch_policies = camp::list< #if defined(RAJA_ENABLE_CUDA) -using cuda_policies = camp::list< +using cuda_loop_policies = camp::list< RAJA::LaunchPolicy>, - RAJA::LoopPolicy, - RAJA::LoopPolicy + RAJA::LoopPolicy, + RAJA::LoopPolicy >; - -using cuda_explicit_policies = camp::list< +using cuda_loop_explicit_policies = camp::list< RAJA::LaunchPolicy>, - RAJA::LoopPolicy, - RAJA::LoopPolicy + RAJA::LoopPolicy, + RAJA::LoopPolicy >; using Cuda_launch_policies = camp::list< - cuda_policies, - cuda_explicit_policies + cuda_loop_policies, + cuda_loop_explicit_policies >; #endif // RAJA_ENABLE_CUDA #if defined(RAJA_ENABLE_HIP) -using hip_policies = camp::list< +using hip_loop_policies = camp::list< RAJA::LaunchPolicy>, - RAJA::LoopPolicy, - RAJA::LoopPolicy + RAJA::LoopPolicy, + RAJA::LoopPolicy >; using Hip_launch_policies = camp::list< - hip_policies + hip_loop_policies >; #endif // RAJA_ENABLE_HIP +#if defined(RAJA_ENABLE_SYCL) +using sycl_loop_policies = camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Sycl_launch_policies = camp::list< + sycl_loop_policies + >; +#endif + -#endif // __RAJA_test_launch_teams_threads_1D_execpol_HPP__ +#endif // __RAJA_test_launch_teams_threads_loop_3D_execpol_HPP__ diff --git a/test/include/RAJA_test-launch-loop-teams-threads-3D-execpol.hpp b/test/include/RAJA_test-launch-loop-teams-threads-3D-execpol.hpp new file mode 100644 index 0000000000..604d52065e --- /dev/null +++ b/test/include/RAJA_test-launch-loop-teams-threads-3D-execpol.hpp @@ -0,0 +1,112 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC +// and RAJA project contributors. See the RAJA/LICENSE file for details. +// +// SPDX-License-Identifier: (BSD-3-Clause) +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + +// +// Execution policy lists used throughout launch tests +// + +#ifndef __RAJA_test_launch_teams_threads_loop_3D_execpol_HPP__ +#define __RAJA_test_launch_teams_threads_loop_3D_execpol_HPP__ + +#include "RAJA/RAJA.hpp" +#include "camp/list.hpp" + +//Launch policies +using seq_policies = camp::list< + RAJA::LaunchPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Sequential_launch_policies = camp::list< + seq_policies + >; + +#if defined(RAJA_ENABLE_OPENMP) +using omp_policies = camp::list< + RAJA::LaunchPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using OpenMP_launch_policies = camp::list< + omp_policies + >; + +#endif // RAJA_ENABLE_OPENMP + +#if defined(RAJA_ENABLE_CUDA) + +using cuda_loop_policies = camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using cuda_loop_explicit_policies = camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Cuda_launch_policies = camp::list< + cuda_loop_policies, + cuda_loop_explicit_policies + >; +#endif // RAJA_ENABLE_CUDA + +#if defined(RAJA_ENABLE_HIP) + +using hip_loop_policies = camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Hip_launch_policies = camp::list< + hip_loop_policies + >; +#endif // RAJA_ENABLE_HIP + +#if defined(RAJA_ENABLE_SYCL) +using sycl_loop_policies = camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Sycl_launch_policies = camp::list< + sycl_loop_policies + >; +#endif + + +#endif // __RAJA_test_launch_teams_threads_loop_3D_execpol_HPP__ diff --git a/test/include/RAJA_test-launch-runtime-execpol.hpp b/test/include/RAJA_test-launch-runtime-execpol.hpp index 5ff11aa7bc..93a59874c8 100644 --- a/test/include/RAJA_test-launch-runtime-execpol.hpp +++ b/test/include/RAJA_test-launch-runtime-execpol.hpp @@ -9,44 +9,64 @@ // Execution policy lists used throughout teams tests // -#ifndef __RAJA_TEST_TEAMS_RUNTIME_EXECPOL_HPP__ -#define __RAJA_TEST_TEAMS_RUNTIME_EXECPOL_HPP__ +#ifndef __RAJA_TEST_LAUNCH_RUNTIME_EXECPOL_HPP__ +#define __RAJA_TEST_LAUNCH_RUNTIME_EXECPOL_HPP__ #include "RAJA/RAJA.hpp" #include "camp/list.hpp" //Launch policies #if defined(RAJA_ENABLE_CUDA) -using seq_cuda_policies = camp::list< - RAJA::LaunchPolicy>, - RAJA::LoopPolicy, - RAJA::LoopPolicy>; +using seq_cuda_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using seq_cuda_explicit_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Sequential_launch_policies = + camp::list< + seq_cuda_policies, + seq_cuda_explicit_policies + >; -using seq_cuda_explicit_policies = camp::list< - RAJA::LaunchPolicy>, - RAJA::LoopPolicy, - RAJA::LoopPolicy>; +#elif defined(RAJA_ENABLE_HIP) +using seq_hip_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; -using Sequential_launch_policies = camp::list< - seq_cuda_policies, - seq_cuda_explicit_policies - >; +using Sequential_launch_policies = camp::list; -#elif defined(RAJA_ENABLE_HIP) -using seq_hip_policies = camp::list< - RAJA::LaunchPolicy>, - RAJA::LoopPolicy, - RAJA::LoopPolicy>; +#elif defined(RAJA_ENABLE_SYCL) + +using seq_sycl_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using Sequential_launch_policies = camp::list; -using Sequential_launch_policies = camp::list< - seq_hip_policies - >; #else -using Sequential_launch_policies = camp::list< - camp::list< - RAJA::LaunchPolicy, - RAJA::LoopPolicy, - RAJA::LoopPolicy>>; +using Sequential_launch_policies = + camp::list< + camp::list< + RAJA::LaunchPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + > + >; #endif // Sequential @@ -54,63 +74,99 @@ using Sequential_launch_policies = camp::list< #if defined(RAJA_ENABLE_CUDA) -using omp_cuda_policies = camp::list< - RAJA::LaunchPolicy>, - RAJA::LoopPolicy, - RAJA::LoopPolicy - >; +using omp_cuda_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using omp_cuda_explicit_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; + +using OpenMP_launch_policies = + camp::list< + omp_cuda_policies, + omp_cuda_explicit_policies + >; + +#elif defined(RAJA_ENABLE_HIP) -using omp_cuda_explicit_policies = camp::list< - RAJA::LaunchPolicy>, - RAJA::LoopPolicy, - RAJA::LoopPolicy - >; +using omp_hip_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; -using OpenMP_launch_policies = camp::list< - omp_cuda_policies, - omp_cuda_explicit_policies - >; +using OpenMP_launch_policies = camp::list; -#elif defined(RAJA_ENABLE_HIP) +#elif defined(RAJA_ENABLE_SYCL) + +using omp_sycl_policies = + camp::list< + RAJA::LaunchPolicy>, + RAJA::LoopPolicy, + RAJA::LoopPolicy + >; -using omp_hip_policies = camp::list< - RAJA::LaunchPolicy>, - RAJA::LoopPolicy, - RAJA::LoopPolicy - >; +using OpenMP_launch_policies = camp::list; -using OpenMP_launch_policies = camp::list< - omp_hip_policies - >; #else -using OpenMP_launch_policies = camp::list< - camp::list< - RAJA::LaunchPolicy, - RAJA::LoopPolicy, - RAJA::LoopPolicy>>; + +using OpenMP_launch_policies = + camp::list< + camp::list< + RAJA::LaunchPolicy, + RAJA::LoopPolicy, + RAJA::LoopPolicy + > + >; #endif #endif // RAJA_ENABLE_OPENMP #if defined(RAJA_ENABLE_CUDA) -using Cuda_launch_policies = camp::list< - seq_cuda_policies - , seq_cuda_explicit_policies + +using Cuda_launch_policies = + camp::list< + seq_cuda_policies + ,seq_cuda_explicit_policies + #if defined(RAJA_ENABLE_OPENMP) - , omp_cuda_policies - , omp_cuda_explicit_policies + ,omp_cuda_policies + ,omp_cuda_explicit_policies #endif - >; + + >; #endif // RAJA_ENABLE_CUDA #if defined(RAJA_ENABLE_HIP) + using Hip_launch_policies = camp::list< seq_hip_policies + #if defined(RAJA_ENABLE_OPENMP) , omp_hip_policies #endif >; + #endif // RAJA_ENABLE_HIP +#if defined(RAJA_ENABLE_SYCL) + +using Sycl_launch_policies = camp::list< + seq_sycl_policies + +#if defined(RAJA_ENABLE_OPENMP) + , omp_sycl_policies +#endif + >; + +#endif // RAJA_ENABLE_SYCL -#endif // __RAJA_test_teams_runtime_execpol_HPP__ +#endif // __RAJA_TEST_LAUNCH_RUNTIME_EXECPOL_HPP__