diff --git a/.gitmodules b/.gitmodules index 91c28b9..570a788 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "ext_lib/eigen"] path = ext_lib/eigen url = https://gitlab.com/libeigen/eigen.git +[submodule "ext_lib/mdspan"] + path = ext_lib/mdspan + url = https://github.com/kokkos/mdspan diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a524a4..da23fca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ project(executors_tutorial LANGUAGES CXX) # Add cmake helpers list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake") +set(BACKEND AUTO CACHE STRING "CHOICE OF PARALLEL BACKEND") + # Keep BUILD_TESTING set(PRIVATE_BUILD_TESTING ${BUILD_TESTING}) @@ -22,7 +24,11 @@ endif() # Libraries add_subdirectory(lib) add_subdirectory(ext_lib/json) -add_subdirectory(ext_lib/eigen) +add_subdirectory(ext_lib/mdspan) + +if(BACKEND STREQUAL "OPENMP") + add_subdirectory(ext_lib/eigen) +endif() # Test set(BUILD_TESTING ${PRIVATE_BUILD_TESTING}) diff --git a/ext_lib/eigen b/ext_lib/eigen index 59b3ef5..a798d07 160000 --- a/ext_lib/eigen +++ b/ext_lib/eigen @@ -1 +1 @@ -Subproject commit 59b3ef5409452095e27e8d39a2ca81139bb8c971 +Subproject commit a798d076596343b89b18e44c8033d77d22e19892 diff --git a/ext_lib/googletest b/ext_lib/googletest index e907816..455fcb7 160000 --- a/ext_lib/googletest +++ b/ext_lib/googletest @@ -1 +1 @@ -Subproject commit e9078161e6d35e31535b3d76086ffd5714050a1b +Subproject commit 455fcb7773dedc70ab489109fb12d8abc7fd59b6 diff --git a/ext_lib/json b/ext_lib/json index c71ecde..5d27543 160000 --- a/ext_lib/json +++ b/ext_lib/json @@ -1 +1 @@ -Subproject commit c71ecde505ebf236048a731c81ae8ecaf2b260a8 +Subproject commit 5d2754306d67d1e654a1a34e1d2e74439a9d53b3 diff --git a/ext_lib/mdspan b/ext_lib/mdspan new file mode 160000 index 0000000..9d0a451 --- /dev/null +++ b/ext_lib/mdspan @@ -0,0 +1 @@ +Subproject commit 9d0a451e11177cbdeaef035c7914b0aa73ddd1e2 diff --git a/ext_lib/stdexec b/ext_lib/stdexec index 124be24..0693876 160000 --- a/ext_lib/stdexec +++ b/ext_lib/stdexec @@ -1 +1 @@ -Subproject commit 124be2415c4c56f94acf16f1062f339537e62982 +Subproject commit 0693876c6144479ab5d9bec671751bd32d14e23a diff --git a/lib/executors/CMakeLists.txt b/lib/executors/CMakeLists.txt index 9d357bd..06b30cf 100644 --- a/lib/executors/CMakeLists.txt +++ b/lib/executors/CMakeLists.txt @@ -29,4 +29,5 @@ if(PROGRAMMING_MODEL STREQUAL "THRUST") endif() # Compiler versions +target_link_libraries(math_lib INTERFACE std::mdspan) target_compile_features(math_lib INTERFACE cxx_std_20) diff --git a/lib/executors/Transpose.hpp b/lib/executors/Transpose.hpp index a9aed5d..1101bd8 100644 --- a/lib/executors/Transpose.hpp +++ b/lib/executors/Transpose.hpp @@ -50,7 +50,7 @@ namespace Impl { out(i1, i0, i2) = in(i0, i1, i2); }); } else if(axes == axes_type({1, 2, 0})) { - using mdspan2d_type = stdex::mdspan, layout_type>; + using mdspan2d_type = stdex::mdspan, layout_type>; using extent2d_type = std::array; extent2d_type in_shape({in.extent(0), in.extent(1) * in.extent(2)}); extent2d_type out_shape({in.extent(1) * in.extent(2), in.extent(0)}); @@ -59,7 +59,7 @@ namespace Impl { mdspan2d_type sub_out(out.data_handle(), out_shape); transpose(blas_handle, sub_in, sub_out); } else if(axes == axes_type({2, 0, 1})) { - using mdspan2d_type = stdex::mdspan, layout_type>; + using mdspan2d_type = stdex::mdspan, layout_type>; using extent2d_type = std::array; extent2d_type in_shape({in.extent(0) * in.extent(1), in.extent(2)}); extent2d_type out_shape({in.extent(2), in.extent(0) * in.extent(1)}); diff --git a/lib/executors/numpy_like.hpp b/lib/executors/numpy_like.hpp index dea8998..87062eb 100644 --- a/lib/executors/numpy_like.hpp +++ b/lib/executors/numpy_like.hpp @@ -31,13 +31,13 @@ namespace Impl { for(int ir=0; ir < reduce_size; ir++) { if(reduce_dim == 0) { - auto sub_in = submdspan(in, ir, std::experimental::full_extent, std::experimental::full_extent); + auto sub_in = stdex::submdspan(in, ir, std::full_extent, std::full_extent); sum += sub_in(i0, i1); } else if(reduce_dim == 1) { - auto sub_in = submdspan(in, std::experimental::full_extent, ir, std::experimental::full_extent); + auto sub_in = stdex::submdspan(in, std::full_extent, ir, std::full_extent); sum += sub_in(i0, i1); } else { - auto sub_in = submdspan(in, std::experimental::full_extent, std::experimental::full_extent, ir); + auto sub_in = stdex::submdspan(in, std::full_extent, std::full_extent, ir); sum += sub_in(i0, i1); } } @@ -54,13 +54,13 @@ namespace Impl { assert(out.extent(reduce_dim) == 1); if(reduce_dim == 0) { - auto sub_out = submdspan(out, 0, std::experimental::full_extent, std::experimental::full_extent); + auto sub_out = stdex::submdspan(out, 0, std::full_extent, std::full_extent); mean_(in, sub_out, axis); } else if(reduce_dim == 1) { - auto sub_out = submdspan(out, std::experimental::full_extent, 0, std::experimental::full_extent); + auto sub_out = stdex::submdspan(out, std::full_extent, 0, std::full_extent); mean_(in, sub_out, axis); } else { - auto sub_out = submdspan(out, std::experimental::full_extent, std::experimental::full_extent, 0); + auto sub_out = stdex::submdspan(out, std::full_extent, std::full_extent, 0); mean_(in, sub_out, axis); } } @@ -82,10 +82,10 @@ namespace Impl { for(int ir=0; ir < reduce_size; ir++) { if(reduce_dim == 0) { - auto sub_in = submdspan(in, ir, std::experimental::full_extent); + auto sub_in = stdex::submdspan(in, ir, std::full_extent); sum += sub_in(idx); } else { - auto sub_in = submdspan(in, std::experimental::full_extent, ir); + auto sub_in = stdex::submdspan(in, std::full_extent, ir); sum += sub_in(idx); } } @@ -102,10 +102,10 @@ namespace Impl { assert(out.extent(reduce_dim) == 1); if(reduce_dim == 0) { - auto sub_out = submdspan(out, 0, std::experimental::full_extent); + auto sub_out = stdex::submdspan(out, 0, std::full_extent); mean_(in, sub_out, axis); } else { - auto sub_out = submdspan(out, std::experimental::full_extent, 0); + auto sub_out = stdex::submdspan(out, std::full_extent, 0); mean_(in, sub_out, axis); } } @@ -323,10 +323,10 @@ namespace Impl { x(i0, i1) = alpha * x(i0, i1) + beta * y(i0, i1); }); } else if( ny0 == 1 && ny0 < nx0 && ny1 == nx1 ) { - auto sub_y = submdspan(y, 0, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, 0, std::full_extent); axpy_(x, sub_y, beta, alpha, 1); } else if( ny0 == nx0 && ny1 == 1 && ny1 < nx1 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, 0); + auto sub_y = stdex::submdspan(y, std::full_extent, 0); axpy_(x, sub_y, beta, alpha, 0); } else if( ny0 == 1 && ny0 < nx0 && ny1 == 1 && ny1 < nx1 ) { IteratePolicy policy2d({0, 0}, {nx0, nx1}); @@ -359,10 +359,10 @@ namespace Impl { z(i0, i1) = alpha * x(i0, i1) + beta * y(i0, i1); }); } else if( ny0 == 1 && ny0 < nx0 && ny1 == nx1 ) { - auto sub_y = submdspan(y, 0, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, 0, std::full_extent); axpy_(x, sub_y, z, beta, alpha, 1); } else if( ny0 == nx0 && ny1 == 1 && ny1 < nx1 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, 0); + auto sub_y = stdex::submdspan(y, std::full_extent, 0); axpy_(x, sub_y, z, beta, alpha, 0); } else if( ny0 == 1 && ny0 < nx0 && ny1 == 1 && ny1 < nx1 ) { IteratePolicy policy2d({0, 0}, {nx0, nx1}); @@ -527,22 +527,22 @@ namespace Impl { x(i0, i1, i2) = alpha * x(i0, i1, i2) + beta * y(i0, i1, i2); }); } else if( ny0 == 1 && ny0 < nx0 && ny1 == nx1 && ny2 == nx2 ) { - auto sub_y = submdspan(y, 0, std::experimental::full_extent, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, 0, std::full_extent, std::full_extent); axpy_(x, sub_y, beta, alpha, 0); } else if( ny0 == 1 && ny0 < nx0 && ny1 == 1 && ny1 < nx1 && ny2 == nx2 ) { - auto sub_y = submdspan(y, 0, 0, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, 0, 0, std::full_extent); axpy_(x, sub_y, beta, alpha, 2); } else if( ny0 == 1 && ny0 < nx0 && ny1 == nx1 && ny2 == 1 && ny2 < nx2 ) { - auto sub_y = submdspan(y, 0, std::experimental::full_extent, 0); + auto sub_y = stdex::submdspan(y, 0, std::full_extent, 0); axpy_(x, sub_y, beta, alpha, 1); } else if( ny0 == nx0 && ny1 == 1 && ny1 < nx1 && ny2 == nx2 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, 0, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, std::full_extent, 0, std::full_extent); axpy_(x, sub_y, beta, alpha, 1); } else if( ny0 == nx0 && ny1 == 1 && ny1 < nx1 && ny2 == 1 && ny2 < nx2 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, 0, 0); + auto sub_y = stdex::submdspan(y, std::full_extent, 0, 0); axpy_(x, sub_y, beta, alpha, 0); } else if( ny0 == nx0 && ny1 == nx1 && ny2 == 1 && ny2 < nx2 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, std::experimental::full_extent, 0); + auto sub_y = stdex::submdspan(y, std::full_extent, std::full_extent, 0); axpy_(x, sub_y, beta, alpha, 2); } else if( ny0 == 1 && ny0 < nx0 && ny1 == 1 && ny1 < nx1 && ny2 == 1 && ny2 < nx2 ) { IteratePolicy policy3d({0, 0, 0}, {nx0, nx1, nx2}); @@ -574,22 +574,22 @@ namespace Impl { z(i0, i1, i2) = alpha * x(i0, i1, i2) + beta * y(i0, i1, i2); }); } else if( ny0 == 1 && ny0 < nx0 && ny1 == nx1 && ny2 == nx2 ) { - auto sub_y = submdspan(y, 0, std::experimental::full_extent, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, 0, std::full_extent, std::full_extent); axpy_(x, sub_y, z, beta, alpha, 0); } else if( ny0 == 1 && ny0 < nx0 && ny1 == 1 && ny1 < nx1 && ny2 == nx2 ) { - auto sub_y = submdspan(y, 0, 0, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, 0, 0, std::full_extent); axpy_(x, sub_y, z, beta, alpha, 2); } else if( ny0 == 1 && ny0 < nx0 && ny1 == nx1 && ny2 == 1 && ny2 < nx2 ) { - auto sub_y = submdspan(y, 0, std::experimental::full_extent, 0); + auto sub_y = stdex::submdspan(y, 0, std::full_extent, 0); axpy_(x, sub_y, z, beta, alpha, 1); } else if( ny0 == nx0 && ny1 == 1 && ny1 < nx1 && ny2 == nx2 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, 0, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, std::full_extent, 0, std::full_extent); axpy_(x, sub_y, z, beta, alpha, 1); } else if( ny0 == nx0 && ny1 == 1 && ny1 < nx1 && ny2 == 1 && ny2 < nx2 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, 0, 0); + auto sub_y = stdex::submdspan(y, std::full_extent, 0, 0); axpy_(x, sub_y, z, beta, alpha, 0); } else if( ny0 == nx0 && ny1 == nx1 && ny2 == 1 && ny2 < nx2 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, std::experimental::full_extent, 0); + auto sub_y = stdex::submdspan(y, std::full_extent, std::full_extent, 0); axpy_(x, sub_y, z, beta, alpha, 2); } else if( ny0 == 1 && ny0 < nx0 && ny1 == 1 && ny1 < nx1 && ny2 == 1 && ny2 < nx2 ) { IteratePolicy policy3d({0, 0, 0}, {nx0, nx1, nx2}); @@ -767,7 +767,7 @@ namespace Impl { const std::size_t rank = ViewType::rank(); - using mdspan_type = stdex::mdspan, layout_type>; + using mdspan_type = stdex::mdspan, layout_type>; using extent_type = std::array; std::vector v; @@ -790,7 +790,7 @@ namespace Impl { const std::size_t size = std::accumulate(shape.begin(), shape.end(), 1, std::multiplies<>()); assert( size == x.size() ); - using mdspan_type = stdex::mdspan, layout_type>; + using mdspan_type = stdex::mdspan, layout_type>; return mdspan_type( x.data_handle(), shape ); } diff --git a/lib/openmp_linalg.hpp b/lib/openmp_linalg.hpp index 6b5077c..8378485 100644 --- a/lib/openmp_linalg.hpp +++ b/lib/openmp_linalg.hpp @@ -64,9 +64,9 @@ namespace Impl { #pragma omp parallel for for(int ib=0; ib matA(sub_A.data_handle(), sub_A.extent(0), sub_A.extent(1)); Eigen::Map matB(sub_B.data_handle(), sub_B.extent(0), sub_B.extent(1)); @@ -133,9 +133,9 @@ namespace Impl { #pragma omp parallel for for(int ib=0; ib matA(sub_A.data_handle(), sub_A.extent(0), sub_A.extent(1)); Eigen::Map vecB(sub_B.data_handle(), sub_B.extent(0)); @@ -186,8 +186,8 @@ namespace Impl { const int batchSize = v.extent(1); #pragma omp parallel for for(int ib=0; ib mat(sub_a.data_handle(), sub_a.extent(0), sub_a.extent(1)); Eigen::Map vec(sub_v.data_handle(), sub_v.extent(0)); diff --git a/lib/stdpar/CMakeLists.txt b/lib/stdpar/CMakeLists.txt index 551f4c5..7e33d57 100644 --- a/lib/stdpar/CMakeLists.txt +++ b/lib/stdpar/CMakeLists.txt @@ -18,4 +18,5 @@ else() endif() # Compiler versions +target_link_libraries(math_lib INTERFACE std::mdspan) target_compile_features(math_lib INTERFACE cxx_std_20) diff --git a/lib/stdpar/Transpose.hpp b/lib/stdpar/Transpose.hpp index 26f97ea..ba06db0 100644 --- a/lib/stdpar/Transpose.hpp +++ b/lib/stdpar/Transpose.hpp @@ -57,7 +57,7 @@ namespace Impl { out(i1, i0, i2) = in(i0, i1, i2); }); } else if(axes == axes_type({1, 2, 0})) { - using mdspan2d_type = stdex::mdspan, layout_type>; + using mdspan2d_type = stdex::mdspan, layout_type>; using extent2d_type = std::array; extent2d_type in_shape({in.extent(0), in.extent(1) * in.extent(2)}); extent2d_type out_shape({in.extent(1) * in.extent(2), in.extent(0)}); @@ -66,7 +66,7 @@ namespace Impl { mdspan2d_type sub_out(out.data_handle(), out_shape); transpose(blas_handle, sub_in, sub_out); } else if(axes == axes_type({2, 0, 1})) { - using mdspan2d_type = stdex::mdspan, layout_type>; + using mdspan2d_type = stdex::mdspan, layout_type>; using extent2d_type = std::array; extent2d_type in_shape({in.extent(0) * in.extent(1), in.extent(2)}); extent2d_type out_shape({in.extent(2), in.extent(0) * in.extent(1)}); diff --git a/lib/stdpar/numpy_like.hpp b/lib/stdpar/numpy_like.hpp index 4e8de37..2bb4c0b 100644 --- a/lib/stdpar/numpy_like.hpp +++ b/lib/stdpar/numpy_like.hpp @@ -76,13 +76,13 @@ namespace Impl { for(int ir=0; ir < reduce_size; ir++) { if(reduce_dim == 0) { - auto sub_in = submdspan(in, ir, std::experimental::full_extent, std::experimental::full_extent); + auto sub_in = stdex::submdspan(in, ir, std::full_extent, std::full_extent); sum += sub_in(i0, i1); } else if(reduce_dim == 1) { - auto sub_in = submdspan(in, std::experimental::full_extent, ir, std::experimental::full_extent); + auto sub_in = stdex::submdspan(in, std::full_extent, ir, std::full_extent); sum += sub_in(i0, i1); } else { - auto sub_in = submdspan(in, std::experimental::full_extent, std::experimental::full_extent, ir); + auto sub_in = stdex::submdspan(in, std::full_extent, std::full_extent, ir); sum += sub_in(i0, i1); } } @@ -99,13 +99,13 @@ namespace Impl { assert(out.extent(reduce_dim) == 1); if(reduce_dim == 0) { - auto sub_out = submdspan(out, 0, std::experimental::full_extent, std::experimental::full_extent); + auto sub_out = stdex::submdspan(out, 0, std::full_extent, std::full_extent); mean_(in, sub_out, axis); } else if(reduce_dim == 1) { - auto sub_out = submdspan(out, std::experimental::full_extent, 0, std::experimental::full_extent); + auto sub_out = stdex::submdspan(out, std::full_extent, 0, std::full_extent); mean_(in, sub_out, axis); } else { - auto sub_out = submdspan(out, std::experimental::full_extent, std::experimental::full_extent, 0); + auto sub_out = stdex::submdspan(out, std::full_extent, std::full_extent, 0); mean_(in, sub_out, axis); } } @@ -127,10 +127,10 @@ namespace Impl { for(int ir=0; ir < reduce_size; ir++) { if(reduce_dim == 0) { - auto sub_in = submdspan(in, ir, std::experimental::full_extent); + auto sub_in = stdex::submdspan(in, ir, std::full_extent); sum += sub_in(idx); } else { - auto sub_in = submdspan(in, std::experimental::full_extent, ir); + auto sub_in = stdex::submdspan(in, std::full_extent, ir); sum += sub_in(idx); } } @@ -147,10 +147,10 @@ namespace Impl { assert(out.extent(reduce_dim) == 1); if(reduce_dim == 0) { - auto sub_out = submdspan(out, 0, std::experimental::full_extent); + auto sub_out = stdex::submdspan(out, 0, std::full_extent); mean_(in, sub_out, axis); } else { - auto sub_out = submdspan(out, std::experimental::full_extent, 0); + auto sub_out = stdex::submdspan(out, std::full_extent, 0); mean_(in, sub_out, axis); } } @@ -368,10 +368,10 @@ namespace Impl { x(i0, i1) = alpha * x(i0, i1) + beta * y(i0, i1); }); } else if( ny0 == 1 && ny0 < nx0 && ny1 == nx1 ) { - auto sub_y = submdspan(y, 0, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, 0, std::full_extent); axpy_(x, sub_y, beta, alpha, 1); } else if( ny0 == nx0 && ny1 == 1 && ny1 < nx1 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, 0); + auto sub_y = stdex::submdspan(y, std::full_extent, 0); axpy_(x, sub_y, beta, alpha, 0); } else if( ny0 == 1 && ny0 < nx0 && ny1 == 1 && ny1 < nx1 ) { IteratePolicy policy2d({0, 0}, {nx0, nx1}); @@ -404,10 +404,10 @@ namespace Impl { z(i0, i1) = alpha * x(i0, i1) + beta * y(i0, i1); }); } else if( ny0 == 1 && ny0 < nx0 && ny1 == nx1 ) { - auto sub_y = submdspan(y, 0, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, 0, std::full_extent); axpy_(x, sub_y, z, beta, alpha, 1); } else if( ny0 == nx0 && ny1 == 1 && ny1 < nx1 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, 0); + auto sub_y = stdex::submdspan(y, std::full_extent, 0); axpy_(x, sub_y, z, beta, alpha, 0); } else if( ny0 == 1 && ny0 < nx0 && ny1 == 1 && ny1 < nx1 ) { IteratePolicy policy2d({0, 0}, {nx0, nx1}); @@ -573,22 +573,22 @@ namespace Impl { }); } else if( ny0 == 1 && ny0 < nx0 && ny1 == nx1 && ny2 == nx2 ) { - auto sub_y = submdspan(y, 0, std::experimental::full_extent, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, 0, std::full_extent, std::full_extent); axpy_(x, sub_y, beta, alpha, 0); } else if( ny0 == 1 && ny0 < nx0 && ny1 == 1 && ny1 < nx1 && ny2 == nx2 ) { - auto sub_y = submdspan(y, 0, 0, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, 0, 0, std::full_extent); axpy_(x, sub_y, beta, alpha, 2); } else if( ny0 == 1 && ny0 < nx0 && ny1 == nx1 && ny2 == 1 && ny2 < nx2 ) { - auto sub_y = submdspan(y, 0, std::experimental::full_extent, 0); + auto sub_y = stdex::submdspan(y, 0, std::full_extent, 0); axpy_(x, sub_y, beta, alpha, 1); } else if( ny0 == nx0 && ny1 == 1 && ny1 < nx1 && ny2 == nx2 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, 0, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, std::full_extent, 0, std::full_extent); axpy_(x, sub_y, beta, alpha, 1); } else if( ny0 == nx0 && ny1 == 1 && ny1 < nx1 && ny2 == 1 && ny2 < nx2 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, 0, 0); + auto sub_y = stdex::submdspan(y, std::full_extent, 0, 0); axpy_(x, sub_y, beta, alpha, 0); } else if( ny0 == nx0 && ny1 == nx1 && ny2 == 1 && ny2 < nx2 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, std::experimental::full_extent, 0); + auto sub_y = stdex::submdspan(y, std::full_extent, std::full_extent, 0); axpy_(x, sub_y, beta, alpha, 2); } else if( ny0 == 1 && ny0 < nx0 && ny1 == 1 && ny1 < nx1 && ny2 == 1 && ny2 < nx2 ) { IteratePolicy policy3d({0, 0, 0}, {nx0, nx1, nx2}); @@ -620,22 +620,22 @@ namespace Impl { z(i0, i1, i2) = alpha * x(i0, i1, i2) + beta * y(i0, i1, i2); }); } else if( ny0 == 1 && ny0 < nx0 && ny1 == nx1 && ny2 == nx2 ) { - auto sub_y = submdspan(y, 0, std::experimental::full_extent, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, 0, std::full_extent, std::full_extent); axpy_(x, sub_y, z, beta, alpha, 0); } else if( ny0 == 1 && ny0 < nx0 && ny1 == 1 && ny1 < nx1 && ny2 == nx2 ) { - auto sub_y = submdspan(y, 0, 0, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, 0, 0, std::full_extent); axpy_(x, sub_y, z, beta, alpha, 2); } else if( ny0 == 1 && ny0 < nx0 && ny1 == nx1 && ny2 == 1 && ny2 < nx2 ) { - auto sub_y = submdspan(y, 0, std::experimental::full_extent, 0); + auto sub_y = stdex::submdspan(y, 0, std::full_extent, 0); axpy_(x, sub_y, z, beta, alpha, 1); } else if( ny0 == nx0 && ny1 == 1 && ny1 < nx1 && ny2 == nx2 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, 0, std::experimental::full_extent); + auto sub_y = stdex::submdspan(y, std::full_extent, 0, std::full_extent); axpy_(x, sub_y, z, beta, alpha, 1); } else if( ny0 == nx0 && ny1 == 1 && ny1 < nx1 && ny2 == 1 && ny2 < nx2 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, 0, 0); + auto sub_y = stdex::submdspan(y, std::full_extent, 0, 0); axpy_(x, sub_y, z, beta, alpha, 0); } else if( ny0 == nx0 && ny1 == nx1 && ny2 == 1 && ny2 < nx2 ) { - auto sub_y = submdspan(y, std::experimental::full_extent, std::experimental::full_extent, 0); + auto sub_y = stdex::submdspan(y, std::full_extent, std::full_extent, 0); axpy_(x, sub_y, z, beta, alpha, 2); } else if( ny0 == 1 && ny0 < nx0 && ny1 == 1 && ny1 < nx1 && ny2 == 1 && ny2 < nx2 ) { IteratePolicy policy3d({0, 0, 0}, {nx0, nx1, nx2}); @@ -813,7 +813,7 @@ namespace Impl { const std::size_t rank = ViewType::rank(); - using mdspan_type = stdex::mdspan, layout_type>; + using mdspan_type = stdex::mdspan, layout_type>; using extent_type = std::array; std::vector v; @@ -836,7 +836,7 @@ namespace Impl { const std::size_t size = std::accumulate(shape.begin(), shape.end(), 1, std::multiplies<>()); assert( size == x.size() ); - using mdspan_type = stdex::mdspan, layout_type>; + using mdspan_type = stdex::mdspan, layout_type>; return mdspan_type( x.data_handle(), shape ); } diff --git a/mini-apps/heat3d-mpi/executors/mpi_comm.hpp b/mini-apps/heat3d-mpi/executors/mpi_comm.hpp index e888be4..39f0cb9 100644 --- a/mini-apps/heat3d-mpi/executors/mpi_comm.hpp +++ b/mini-apps/heat3d-mpi/executors/mpi_comm.hpp @@ -235,8 +235,8 @@ class Comm { // Exchange in x direction { int i = 0; - auto ux_send_left = submdspan(u, 1, inner_y, inner_z); - auto ux_send_right = submdspan(u, u.extent(0) - 2, inner_y, inner_z); + auto ux_send_left = stdex::submdspan(u, 1, inner_y, inner_z); + auto ux_send_right = stdex::submdspan(u, u.extent(0) - 2, inner_y, inner_z); pack_(schdeuler, send_buffer(i), ux_send_left, ux_send_right); } @@ -244,8 +244,8 @@ class Comm { // Exchange in y direction { int i = 1; - auto uy_send_left = submdspan(u, inner_x, 1, inner_z); - auto uy_send_right = submdspan(u, inner_x, u.extent(1) - 2, inner_z); + auto uy_send_left = stdex::submdspan(u, inner_x, 1, inner_z); + auto uy_send_right = stdex::submdspan(u, inner_x, u.extent(1) - 2, inner_z); pack_(schdeuler, send_buffer(i), uy_send_left, uy_send_right); } @@ -253,8 +253,8 @@ class Comm { // Exchange in z direction { int i = 2; - auto uz_send_left = submdspan(u, inner_x, inner_y, 1); - auto uz_send_right = submdspan(u, inner_x, inner_y, u.extent(2) - 2); + auto uz_send_left = stdex::submdspan(u, inner_x, inner_y, 1); + auto uz_send_right = stdex::submdspan(u, inner_x, inner_y, u.extent(2) - 2); pack_(schdeuler, send_buffer(i), uz_send_left, uz_send_right); } @@ -270,8 +270,8 @@ class Comm { // Exchange in x direction { int i = 0; - auto ux_recv_left = submdspan(u, 0, inner_y, inner_z); - auto ux_recv_right = submdspan(u, u.extent(0) - 1, inner_y, inner_z); + auto ux_recv_left = stdex::submdspan(u, 0, inner_y, inner_z); + auto ux_recv_right = stdex::submdspan(u, u.extent(0) - 1, inner_y, inner_z); unpack_(schdeuler, ux_recv_left, ux_recv_right, recv_buffer(i)); } @@ -279,8 +279,8 @@ class Comm { // Exchange in y direction { int i = 1; - auto uy_recv_left = submdspan(u, inner_x, 0, inner_z); - auto uy_recv_right = submdspan(u, inner_x, u.extent(1) - 1, inner_z); + auto uy_recv_left = stdex::submdspan(u, inner_x, 0, inner_z); + auto uy_recv_right = stdex::submdspan(u, inner_x, u.extent(1) - 1, inner_z); unpack_(schdeuler, uy_recv_left, uy_recv_right, recv_buffer(i)); } @@ -288,8 +288,8 @@ class Comm { // Exchange in z direction { int i = 2; - auto uz_recv_left = submdspan(u, inner_x, inner_y, 0); - auto uz_recv_right = submdspan(u, inner_x, inner_y, u.extent(2) - 1); + auto uz_recv_left = stdex::submdspan(u, inner_x, inner_y, 0); + auto uz_recv_right = stdex::submdspan(u, inner_x, inner_y, u.extent(2) - 1); unpack_(schdeuler, uz_recv_left, uz_recv_right, recv_buffer(i)); } @@ -305,8 +305,8 @@ class Comm { // Exchange in x direction { int i = 0; - auto ux_recv_left = submdspan(u, 1, inner_y, inner_z); - auto ux_recv_right = submdspan(u, u.extent(0) - 2, inner_y, inner_z); + auto ux_recv_left = stdex::submdspan(u, 1, inner_y, inner_z); + auto ux_recv_right = stdex::submdspan(u, u.extent(0) - 2, inner_y, inner_z); boundaryUpdate_(conf, schdeuler, ux_recv_left, ux_recv_right, recv_buffer(i)); } @@ -314,8 +314,8 @@ class Comm { // Exchange in y direction { int i = 1; - auto uy_recv_left = submdspan(u, inner_x, 1, inner_z); - auto uy_recv_right = submdspan(u, inner_x, u.extent(1) - 2, inner_z); + auto uy_recv_left = stdex::submdspan(u, inner_x, 1, inner_z); + auto uy_recv_right = stdex::submdspan(u, inner_x, u.extent(1) - 2, inner_z); boundaryUpdate_(conf, schdeuler, uy_recv_left, uy_recv_right, recv_buffer(i)); } @@ -323,8 +323,8 @@ class Comm { // Exchange in z direction { int i = 2; - auto uz_recv_left = submdspan(u, inner_x, inner_y, 1); - auto uz_recv_right = submdspan(u, inner_x, inner_y, u.extent(2) - 2); + auto uz_recv_left = stdex::submdspan(u, inner_x, inner_y, 1); + auto uz_recv_right = stdex::submdspan(u, inner_x, inner_y, u.extent(2) - 2); boundaryUpdate_(conf, schdeuler, uz_recv_left, uz_recv_right, recv_buffer(i)); } @@ -346,10 +346,10 @@ class Comm { // Exchange in x direction { int i = 0; - auto ux_send_left = submdspan(u, 1, inner_y, inner_z); - auto ux_send_right = submdspan(u, u.extent(0) - 2, inner_y, inner_z); - auto ux_recv_left = submdspan(u, 0, inner_y, inner_z); - auto ux_recv_right = submdspan(u, u.extent(0) - 1, inner_y, inner_z); + auto ux_send_left = stdex::submdspan(u, 1, inner_y, inner_z); + auto ux_send_right = stdex::submdspan(u, u.extent(0) - 2, inner_y, inner_z); + auto ux_recv_left = stdex::submdspan(u, 0, inner_y, inner_z); + auto ux_recv_right = stdex::submdspan(u, u.extent(0) - 1, inner_y, inner_z); pack_(schdeuler, send_buffer(i), ux_send_left, ux_send_right); commP2P_(recv_buffer(i), send_buffer(i)); @@ -359,10 +359,10 @@ class Comm { // Exchange in y direction { int i = 1; - auto uy_send_left = submdspan(u, inner_x, 1, inner_z); - auto uy_send_right = submdspan(u, inner_x, u.extent(1) - 2, inner_z); - auto uy_recv_left = submdspan(u, inner_x, 0, inner_z); - auto uy_recv_right = submdspan(u, inner_x, u.extent(1) - 1, inner_z); + auto uy_send_left = stdex::submdspan(u, inner_x, 1, inner_z); + auto uy_send_right = stdex::submdspan(u, inner_x, u.extent(1) - 2, inner_z); + auto uy_recv_left = stdex::submdspan(u, inner_x, 0, inner_z); + auto uy_recv_right = stdex::submdspan(u, inner_x, u.extent(1) - 1, inner_z); pack_(schdeuler, send_buffer(i), uy_send_left, uy_send_right); commP2P_(recv_buffer(i), send_buffer(i)); @@ -372,10 +372,10 @@ class Comm { // Exchange in z direction { int i = 2; - auto uz_send_left = submdspan(u, inner_x, inner_y, 1); - auto uz_send_right = submdspan(u, inner_x, inner_y, u.extent(2) - 2); - auto uz_recv_left = submdspan(u, inner_x, inner_y, 0); - auto uz_recv_right = submdspan(u, inner_x, inner_y, u.extent(2) - 1); + auto uz_send_left = stdex::submdspan(u, inner_x, inner_y, 1); + auto uz_send_right = stdex::submdspan(u, inner_x, inner_y, u.extent(2) - 2); + auto uz_recv_left = stdex::submdspan(u, inner_x, inner_y, 0); + auto uz_recv_right = stdex::submdspan(u, inner_x, inner_y, u.extent(2) - 1); pack_(schdeuler, send_buffer(i), uz_send_left, uz_send_right); commP2P_(recv_buffer(i), send_buffer(i)); diff --git a/mini-apps/heat3d-mpi/stdpar/mpi_comm.hpp b/mini-apps/heat3d-mpi/stdpar/mpi_comm.hpp index ee1bd03..a36107b 100644 --- a/mini-apps/heat3d-mpi/stdpar/mpi_comm.hpp +++ b/mini-apps/heat3d-mpi/stdpar/mpi_comm.hpp @@ -234,10 +234,10 @@ class Comm { // Exchange in x direction { int i = 0; - auto ux_send_left = submdspan(u, 1, inner_y, inner_z); - auto ux_send_right = submdspan(u, u.extent(0) - 2, inner_y, inner_z); - auto ux_recv_left = submdspan(u, 0, inner_y, inner_z); - auto ux_recv_right = submdspan(u, u.extent(0) - 1, inner_y, inner_z); + auto ux_send_left = stdex::submdspan(u, 1, inner_y, inner_z); + auto ux_send_right = stdex::submdspan(u, u.extent(0) - 2, inner_y, inner_z); + auto ux_recv_left = stdex::submdspan(u, 0, inner_y, inner_z); + auto ux_recv_right = stdex::submdspan(u, u.extent(0) - 1, inner_y, inner_z); if(use_timer) timers[HaloPack]->begin(); pack_(send_buffer(i), ux_send_left, ux_send_right); @@ -255,10 +255,10 @@ class Comm { // Exchange in y direction { int i = 1; - auto uy_send_left = submdspan(u, inner_x, 1, inner_z); - auto uy_send_right = submdspan(u, inner_x, u.extent(1) - 2, inner_z); - auto uy_recv_left = submdspan(u, inner_x, 0, inner_z); - auto uy_recv_right = submdspan(u, inner_x, u.extent(1) - 1, inner_z); + auto uy_send_left = stdex::submdspan(u, inner_x, 1, inner_z); + auto uy_send_right = stdex::submdspan(u, inner_x, u.extent(1) - 2, inner_z); + auto uy_recv_left = stdex::submdspan(u, inner_x, 0, inner_z); + auto uy_recv_right = stdex::submdspan(u, inner_x, u.extent(1) - 1, inner_z); if(use_timer) timers[HaloPack]->begin(); pack_(send_buffer(i), uy_send_left, uy_send_right); @@ -276,10 +276,10 @@ class Comm { // Exchange in z direction { int i = 2; - auto uz_send_left = submdspan(u, inner_x, inner_y, 1); - auto uz_send_right = submdspan(u, inner_x, inner_y, u.extent(2) - 2); - auto uz_recv_left = submdspan(u, inner_x, inner_y, 0); - auto uz_recv_right = submdspan(u, inner_x, inner_y, u.extent(2) - 1); + auto uz_send_left = stdex::submdspan(u, inner_x, inner_y, 1); + auto uz_send_right = stdex::submdspan(u, inner_x, inner_y, u.extent(2) - 2); + auto uz_recv_left = stdex::submdspan(u, inner_x, inner_y, 0); + auto uz_recv_right = stdex::submdspan(u, inner_x, inner_y, u.extent(2) - 1); if(use_timer) timers[HaloPack]->begin(); pack_(send_buffer(i), uz_send_left, uz_send_right); diff --git a/mini-apps/heat3d-mpi/thrust/mpi_comm.hpp b/mini-apps/heat3d-mpi/thrust/mpi_comm.hpp index bd8418d..9f30484 100644 --- a/mini-apps/heat3d-mpi/thrust/mpi_comm.hpp +++ b/mini-apps/heat3d-mpi/thrust/mpi_comm.hpp @@ -236,8 +236,8 @@ class Comm { // Exchange in x direction { int i = 0; - auto ux_send_left = submdspan(u, 1, inner_y, inner_z); - auto ux_send_right = submdspan(u, u.extent(0) - 2, inner_y, inner_z); + auto ux_send_left = stdex::submdspan(u, 1, inner_y, inner_z); + auto ux_send_right = stdex::submdspan(u, u.extent(0) - 2, inner_y, inner_z); pack_(send_buffer(i), ux_send_left, ux_send_right); } @@ -245,8 +245,8 @@ class Comm { // Exchange in y direction { int i = 1; - auto uy_send_left = submdspan(u, inner_x, 1, inner_z); - auto uy_send_right = submdspan(u, inner_x, u.extent(1) - 2, inner_z); + auto uy_send_left = stdex::submdspan(u, inner_x, 1, inner_z); + auto uy_send_right = stdex::submdspan(u, inner_x, u.extent(1) - 2, inner_z); pack_(send_buffer(i), uy_send_left, uy_send_right); } @@ -254,8 +254,8 @@ class Comm { // Exchange in z direction { int i = 2; - auto uz_send_left = submdspan(u, inner_x, inner_y, 1); - auto uz_send_right = submdspan(u, inner_x, inner_y, u.extent(2) - 2); + auto uz_send_left = stdex::submdspan(u, inner_x, inner_y, 1); + auto uz_send_right = stdex::submdspan(u, inner_x, inner_y, u.extent(2) - 2); pack_(send_buffer(i), uz_send_left, uz_send_right); } @@ -271,8 +271,8 @@ class Comm { // Exchange in x direction { int i = 0; - auto ux_recv_left = submdspan(u, 0, inner_y, inner_z); - auto ux_recv_right = submdspan(u, u.extent(0) - 1, inner_y, inner_z); + auto ux_recv_left = stdex::submdspan(u, 0, inner_y, inner_z); + auto ux_recv_right = stdex::submdspan(u, u.extent(0) - 1, inner_y, inner_z); unpack_(ux_recv_left, ux_recv_right, recv_buffer(i)); } @@ -280,8 +280,8 @@ class Comm { // Exchange in y direction { int i = 1; - auto uy_recv_left = submdspan(u, inner_x, 0, inner_z); - auto uy_recv_right = submdspan(u, inner_x, u.extent(1) - 1, inner_z); + auto uy_recv_left = stdex::submdspan(u, inner_x, 0, inner_z); + auto uy_recv_right = stdex::submdspan(u, inner_x, u.extent(1) - 1, inner_z); unpack_(uy_recv_left, uy_recv_right, recv_buffer(i)); } @@ -289,8 +289,8 @@ class Comm { // Exchange in z direction { int i = 2; - auto uz_recv_left = submdspan(u, inner_x, inner_y, 0); - auto uz_recv_right = submdspan(u, inner_x, inner_y, u.extent(2) - 1); + auto uz_recv_left = stdex::submdspan(u, inner_x, inner_y, 0); + auto uz_recv_right = stdex::submdspan(u, inner_x, inner_y, u.extent(2) - 1); unpack_(uz_recv_left, uz_recv_right, recv_buffer(i)); } @@ -306,8 +306,8 @@ class Comm { // Exchange in x direction { int i = 0; - auto ux_recv_left = submdspan(u, 1, inner_y, inner_z); - auto ux_recv_right = submdspan(u, u.extent(0) - 2, inner_y, inner_z); + auto ux_recv_left = stdex::submdspan(u, 1, inner_y, inner_z); + auto ux_recv_right = stdex::submdspan(u, u.extent(0) - 2, inner_y, inner_z); boundaryUpdate_(conf, schdeuler, ux_recv_left, ux_recv_right, recv_buffer(i)); } @@ -315,8 +315,8 @@ class Comm { // Exchange in y direction { int i = 1; - auto uy_recv_left = submdspan(u, inner_x, 1, inner_z); - auto uy_recv_right = submdspan(u, inner_x, u.extent(1) - 2, inner_z); + auto uy_recv_left = stdex::submdspan(u, inner_x, 1, inner_z); + auto uy_recv_right = stdex::submdspan(u, inner_x, u.extent(1) - 2, inner_z); boundaryUpdate_(conf, schdeuler, uy_recv_left, uy_recv_right, recv_buffer(i)); } @@ -324,8 +324,8 @@ class Comm { // Exchange in z direction { int i = 2; - auto uz_recv_left = submdspan(u, inner_x, inner_y, 1); - auto uz_recv_right = submdspan(u, inner_x, inner_y, u.extent(2) - 2); + auto uz_recv_left = stdex::submdspan(u, inner_x, inner_y, 1); + auto uz_recv_right = stdex::submdspan(u, inner_x, inner_y, u.extent(2) - 2); boundaryUpdate_(conf, schdeuler, uz_recv_left, uz_recv_right, recv_buffer(i)); } @@ -347,10 +347,10 @@ class Comm { // Exchange in x direction { int i = 0; - auto ux_send_left = submdspan(u, 1, inner_y, inner_z); - auto ux_send_right = submdspan(u, u.extent(0) - 2, inner_y, inner_z); - auto ux_recv_left = submdspan(u, 0, inner_y, inner_z); - auto ux_recv_right = submdspan(u, u.extent(0) - 1, inner_y, inner_z); + auto ux_send_left = stdex::submdspan(u, 1, inner_y, inner_z); + auto ux_send_right = stdex::submdspan(u, u.extent(0) - 2, inner_y, inner_z); + auto ux_recv_left = stdex::submdspan(u, 0, inner_y, inner_z); + auto ux_recv_right = stdex::submdspan(u, u.extent(0) - 1, inner_y, inner_z); pack_(send_buffer(i), ux_send_left, ux_send_right); commP2P_(recv_buffer(i), send_buffer(i)); @@ -360,10 +360,10 @@ class Comm { // Exchange in y direction { int i = 1; - auto uy_send_left = submdspan(u, inner_x, 1, inner_z); - auto uy_send_right = submdspan(u, inner_x, u.extent(1) - 2, inner_z); - auto uy_recv_left = submdspan(u, inner_x, 0, inner_z); - auto uy_recv_right = submdspan(u, inner_x, u.extent(1) - 1, inner_z); + auto uy_send_left = stdex::submdspan(u, inner_x, 1, inner_z); + auto uy_send_right = stdex::submdspan(u, inner_x, u.extent(1) - 2, inner_z); + auto uy_recv_left = stdex::submdspan(u, inner_x, 0, inner_z); + auto uy_recv_right = stdex::submdspan(u, inner_x, u.extent(1) - 1, inner_z); pack_(send_buffer(i), uy_send_left, uy_send_right); commP2P_(recv_buffer(i), send_buffer(i)); @@ -373,10 +373,10 @@ class Comm { // Exchange in z direction { int i = 2; - auto uz_send_left = submdspan(u, inner_x, inner_y, 1); - auto uz_send_right = submdspan(u, inner_x, inner_y, u.extent(2) - 2); - auto uz_recv_left = submdspan(u, inner_x, inner_y, 0); - auto uz_recv_right = submdspan(u, inner_x, inner_y, u.extent(2) - 1); + auto uz_send_left = stdex::submdspan(u, inner_x, inner_y, 1); + auto uz_send_right = stdex::submdspan(u, inner_x, inner_y, u.extent(2) - 2); + auto uz_recv_left = stdex::submdspan(u, inner_x, inner_y, 0); + auto uz_recv_right = stdex::submdspan(u, inner_x, inner_y, u.extent(2) - 1); pack_(send_buffer(i), uz_send_left, uz_send_right); commP2P_(recv_buffer(i), send_buffer(i)); diff --git a/mini-apps/heat3d-mpi/types.hpp b/mini-apps/heat3d-mpi/types.hpp index 6a10e83..0d2973b 100644 --- a/mini-apps/heat3d-mpi/types.hpp +++ b/mini-apps/heat3d-mpi/types.hpp @@ -18,12 +18,12 @@ namespace stdex = std::experimental; #endif template -using View1D = stdex::mdspan, default_layout>; +using View1D = stdex::mdspan, default_layout>; template -using View2D = stdex::mdspan, default_layout>; +using View2D = stdex::mdspan, default_layout>; template -using View3D = stdex::mdspan, default_layout>; +using View3D = stdex::mdspan, default_layout>; #endif diff --git a/mini-apps/heat3d/executors/CMakeLists.txt b/mini-apps/heat3d/executors/CMakeLists.txt index 1c7e32b..b0c0130 100644 --- a/mini-apps/heat3d/executors/CMakeLists.txt +++ b/mini-apps/heat3d/executors/CMakeLists.txt @@ -1,5 +1,5 @@ add_executable(heat3d-executors heat3D.cpp) -target_link_libraries(heat3d-executors PUBLIC Threads::Threads STDEXEC::stdexec STDEXEC::nvexec) +target_link_libraries(heat3d-executors PUBLIC Threads::Threads STDEXEC::stdexec STDEXEC::nvexec std::mdspan) target_compile_features(heat3d-executors PUBLIC cxx_std_20) set(BACKEND AUTO CACHE STRING "CHOICE OF PARALLEL BACKEND") @@ -7,4 +7,7 @@ if(BACKEND STREQUAL "OPENMP") find_package(OpenMP REQUIRED) target_link_libraries(heat3d-executors PUBLIC OpenMP::OpenMP_CXX) target_compile_definitions(heat3d-executors PUBLIC ENABLE_OPENMP THRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_OMP) + if(${CMAKE_CXX_COMPILER_ID} STREQUAL NVHPC) + target_compile_options(heat3d-executors PUBLIC -fast) + endif() endif() diff --git a/mini-apps/heat3d/stdpar/CMakeLists.txt b/mini-apps/heat3d/stdpar/CMakeLists.txt index 33f7d31..e41c9ce 100644 --- a/mini-apps/heat3d/stdpar/CMakeLists.txt +++ b/mini-apps/heat3d/stdpar/CMakeLists.txt @@ -5,9 +5,10 @@ if(BACKEND STREQUAL "CUDA") target_compile_options(heat3d-stdpar PUBLIC -stdpar=gpu) target_link_options(heat3d-stdpar PUBLIC -stdpar=gpu) elseif(BACKEND STREQUAL "OPENMP") - target_compile_options(heat3d-stdpar PUBLIC -stdpar=multicore) + target_compile_options(heat3d-stdpar PUBLIC -stdpar=multicore -fast) else() message(FATAL_ERROR "No parallel backend specified. One of CUDA, and OPENMP must be On.") endif() +target_link_libraries(heat3d-stdpar PUBLIC std::mdspan) target_compile_features(heat3d-stdpar PUBLIC cxx_std_20) diff --git a/mini-apps/heat3d/thrust/CMakeLists.txt b/mini-apps/heat3d/thrust/CMakeLists.txt index 30b91ae..b756cad 100644 --- a/mini-apps/heat3d/thrust/CMakeLists.txt +++ b/mini-apps/heat3d/thrust/CMakeLists.txt @@ -9,12 +9,16 @@ elseif(BACKEND STREQUAL "OPENMP") target_link_libraries(heat3d-thrust PUBLIC Threads::Threads STDEXEC::stdexec STDEXEC::nvexec OpenMP::OpenMP_CXX) target_compile_features(heat3d-thrust PUBLIC cxx_std_20) target_compile_definitions(heat3d-thrust PUBLIC ENABLE_OPENMP THRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_OMP) + if(${CMAKE_CXX_COMPILER_ID} STREQUAL NVHPC) + target_compile_options(heat3d-thrust PUBLIC -fast) + endif() elseif(BACKEND STREQUAL "HIP") enable_language(HIP) target_compile_features(heat3d-thrust PUBLIC cxx_std_17) target_compile_options(heat3d-thrust PUBLIC -std=c++1z) set_source_files_properties(heat3D.cpp PROPERTIES LANGUAGE HIP) - target_link_libraries(heat3d-thrust PUBLIC std::mdspan) else() message(FATAL_ERROR "No parallel backend specified. One of CUDA, HIP and OPENMP must be On.") endif() + +target_link_libraries(heat3d-thrust PUBLIC std::mdspan) diff --git a/mini-apps/heat3d/types.hpp b/mini-apps/heat3d/types.hpp index 6a10e83..0d2973b 100644 --- a/mini-apps/heat3d/types.hpp +++ b/mini-apps/heat3d/types.hpp @@ -18,12 +18,12 @@ namespace stdex = std::experimental; #endif template -using View1D = stdex::mdspan, default_layout>; +using View1D = stdex::mdspan, default_layout>; template -using View2D = stdex::mdspan, default_layout>; +using View2D = stdex::mdspan, default_layout>; template -using View3D = stdex::mdspan, default_layout>; +using View3D = stdex::mdspan, default_layout>; #endif diff --git a/mini-apps/lbm2d-letkf/executors/force.hpp b/mini-apps/lbm2d-letkf/executors/force.hpp index 2eb29d2..549808e 100644 --- a/mini-apps/lbm2d-letkf/executors/force.hpp +++ b/mini-apps/lbm2d-letkf/executors/force.hpp @@ -55,7 +55,7 @@ struct Force { const auto x = x_.mdspan(); const auto y = y_.mdspan(); const auto rand_pool = rand_pool_.mdspan(); - const auto sub_rand_pool = submdspan(rand_pool, stdex::full_extent, stdex::full_extent, shift); + const auto sub_rand_pool = stdex::submdspan(rand_pool, std::full_extent, std::full_extent, shift); auto fx = fx_.mdspan(); auto fy = fy_.mdspan(); diff --git a/mini-apps/lbm2d-letkf/executors/letkf_solver.hpp b/mini-apps/lbm2d-letkf/executors/letkf_solver.hpp index fce1eaa..a66d842 100644 --- a/mini-apps/lbm2d-letkf/executors/letkf_solver.hpp +++ b/mini-apps/lbm2d-letkf/executors/letkf_solver.hpp @@ -32,13 +32,13 @@ stdexec::sender auto mean_sender(Sender&& sender, Scheduler&& scheduler, const I const int i1 = idx/n0; for(int ir=0; ir < reduce_size; ir++) { if(reduce_dim == 0) { - auto sub_in = submdspan(in, ir, std::experimental::full_extent, std::experimental::full_extent); + auto sub_in = stdex::submdspan(in, ir, std::full_extent, std::full_extent); sum += sub_in(i0, i1); } else if(reduce_dim == 1) { - auto sub_in = submdspan(in, std::experimental::full_extent, ir, std::experimental::full_extent); + auto sub_in = stdex::submdspan(in, std::full_extent, ir, std::full_extent); sum += sub_in(i0, i1); } else { - auto sub_in = submdspan(in, std::experimental::full_extent, std::experimental::full_extent, ir); + auto sub_in = stdex::submdspan(in, std::full_extent, std::full_extent, ir); sum += sub_in(i0, i1); } } diff --git a/mini-apps/lbm2d-letkf/executors/types.hpp b/mini-apps/lbm2d-letkf/executors/types.hpp index 06a8413..8cbb7d6 100644 --- a/mini-apps/lbm2d-letkf/executors/types.hpp +++ b/mini-apps/lbm2d-letkf/executors/types.hpp @@ -45,13 +45,13 @@ template using shape_type = std::array; template < typename ElementType > -using View1D = View, default_layout>; +using View1D = View, default_layout>; template < typename ElementType > -using View2D = View, default_layout>; +using View2D = View, default_layout>; template < typename ElementType > -using View3D = View, default_layout>; +using View3D = View, default_layout>; using RealView1D = View1D; using RealView2D = View2D; diff --git a/mini-apps/lbm2d-letkf/stdpar/force.hpp b/mini-apps/lbm2d-letkf/stdpar/force.hpp index c5eab96..bdaedd1 100644 --- a/mini-apps/lbm2d-letkf/stdpar/force.hpp +++ b/mini-apps/lbm2d-letkf/stdpar/force.hpp @@ -53,7 +53,7 @@ struct Force { const auto x = x_.mdspan(); const auto y = y_.mdspan(); const auto rand_pool = rand_pool_.mdspan(); - //const auto sub_rand_pool = submdspan(rand_pool, stdex::full_extent_t, stdex::full_extent_t, shift); + //const auto sub_rand_pool = stdex::submdspan(rand_pool, std::full_extent_t, std::full_extent_t, shift); auto fx = fx_.mdspan(); auto fy = fy_.mdspan(); diff --git a/mini-apps/lbm2d-letkf/stdpar/types.hpp b/mini-apps/lbm2d-letkf/stdpar/types.hpp index 2aab124..d729316 100644 --- a/mini-apps/lbm2d-letkf/stdpar/types.hpp +++ b/mini-apps/lbm2d-letkf/stdpar/types.hpp @@ -45,13 +45,13 @@ template using shape_type = std::array; template < typename ElementType > -using View1D = View, default_layout>; +using View1D = View, default_layout>; template < typename ElementType > -using View2D = View, default_layout>; +using View2D = View, default_layout>; template < typename ElementType > -using View3D = View, default_layout>; +using View3D = View, default_layout>; using RealView1D = View1D; using RealView2D = View2D; diff --git a/mini-apps/lbm2d-letkf/thrust/force.hpp b/mini-apps/lbm2d-letkf/thrust/force.hpp index e4fc740..add40bc 100644 --- a/mini-apps/lbm2d-letkf/thrust/force.hpp +++ b/mini-apps/lbm2d-letkf/thrust/force.hpp @@ -53,7 +53,7 @@ struct Force { const auto x = x_.mdspan(); const auto y = y_.mdspan(); const auto rand_pool = rand_pool_.mdspan(); - //const auto sub_rand_pool = submdspan(rand_pool, stdex::full_extent_t, stdex::full_extent_t, shift); + //const auto sub_rand_pool = stdex::submdspan(rand_pool, std::full_extent_t, std::full_extent_t, shift); auto fx = fx_.mdspan(); auto fy = fy_.mdspan(); diff --git a/mini-apps/lbm2d-letkf/thrust/types.hpp b/mini-apps/lbm2d-letkf/thrust/types.hpp index 2aab124..d729316 100644 --- a/mini-apps/lbm2d-letkf/thrust/types.hpp +++ b/mini-apps/lbm2d-letkf/thrust/types.hpp @@ -45,13 +45,13 @@ template using shape_type = std::array; template < typename ElementType > -using View1D = View, default_layout>; +using View1D = View, default_layout>; template < typename ElementType > -using View2D = View, default_layout>; +using View2D = View, default_layout>; template < typename ElementType > -using View3D = View, default_layout>; +using View3D = View, default_layout>; using RealView1D = View1D; using RealView2D = View2D; diff --git a/mini-apps/vlp4d/executors/types.hpp b/mini-apps/vlp4d/executors/types.hpp index 666e6d6..3e3d7f3 100644 --- a/mini-apps/vlp4d/executors/types.hpp +++ b/mini-apps/vlp4d/executors/types.hpp @@ -41,16 +41,16 @@ template using shape_type = std::array; template < typename ElementType > -using View1D = View, default_layout>; +using View1D = View, default_layout>; template < typename ElementType > -using View2D = View, default_layout>; +using View2D = View, default_layout>; template < typename ElementType > -using View3D = View, default_layout>; +using View3D = View, default_layout>; template < typename ElementType > -using View4D = View, default_layout>; +using View4D = View, default_layout>; using RealView1D = View1D; using RealView2D = View2D; diff --git a/mini-apps/vlp4d/stdpar/types.hpp b/mini-apps/vlp4d/stdpar/types.hpp index 92508a4..fbb417c 100644 --- a/mini-apps/vlp4d/stdpar/types.hpp +++ b/mini-apps/vlp4d/stdpar/types.hpp @@ -41,16 +41,16 @@ template using shape_type = std::array; template < typename ElementType > -using View1D = View, default_layout>; +using View1D = View, default_layout>; template < typename ElementType > -using View2D = View, default_layout>; +using View2D = View, default_layout>; template < typename ElementType > -using View3D = View, default_layout>; +using View3D = View, default_layout>; template < typename ElementType > -using View4D = View, default_layout>; +using View4D = View, default_layout>; using RealView1D = View1D; using RealView2D = View2D; diff --git a/mini-apps/vlp4d/thrust/types.hpp b/mini-apps/vlp4d/thrust/types.hpp index 92508a4..fbb417c 100644 --- a/mini-apps/vlp4d/thrust/types.hpp +++ b/mini-apps/vlp4d/thrust/types.hpp @@ -41,16 +41,16 @@ template using shape_type = std::array; template < typename ElementType > -using View1D = View, default_layout>; +using View1D = View, default_layout>; template < typename ElementType > -using View2D = View, default_layout>; +using View2D = View, default_layout>; template < typename ElementType > -using View3D = View, default_layout>; +using View3D = View, default_layout>; template < typename ElementType > -using View4D = View, default_layout>; +using View4D = View, default_layout>; using RealView1D = View1D; using RealView2D = View2D; diff --git a/tests/executors/Types.hpp b/tests/executors/Types.hpp index a72d484..c642605 100644 --- a/tests/executors/Types.hpp +++ b/tests/executors/Types.hpp @@ -51,13 +51,13 @@ template using shape_type = std::array; template < typename ElementType > -using View1D = View, default_layout >; +using View1D = View, default_layout >; template < typename ElementType > -using View2D = View, default_layout >; +using View2D = View, default_layout >; template < typename ElementType > -using View3D = View, default_layout >; +using View3D = View, default_layout >; template < typename ElementType > -using View4D = View, default_layout >; +using View4D = View, default_layout >; using RealView1D = View1D; using RealView2D = View2D; diff --git a/tests/stdpar/Types.hpp b/tests/stdpar/Types.hpp index a38e9b9..46370b2 100644 --- a/tests/stdpar/Types.hpp +++ b/tests/stdpar/Types.hpp @@ -49,22 +49,22 @@ template using shape_type = std::array; template -using Mdspan1D = stdex::mdspan, default_layout>; +using Mdspan1D = stdex::mdspan, default_layout>; template -using Mdspan2D = stdex::mdspan, default_layout>; +using Mdspan2D = stdex::mdspan, default_layout>; template -using Mdspan3D = stdex::mdspan, default_layout>; +using Mdspan3D = stdex::mdspan, default_layout>; template -using Mdspan4D = stdex::mdspan, default_layout>; +using Mdspan4D = stdex::mdspan, default_layout>; template < typename ElementType > -using View1D = View, default_layout >; +using View1D = View, default_layout >; template < typename ElementType > -using View2D = View, default_layout >; +using View2D = View, default_layout >; +template < typename ElementType > +using View3D = View, default_layout >; template < typename ElementType > -using View3D = View, default_layout >; -template < typename ElementType > -using View4D = View, default_layout >; +using View4D = View, default_layout >; using RealView1D = View1D; using RealView2D = View2D; diff --git a/tutorial/03_mdspan_nvexec/CMakeLists.txt b/tutorial/03_mdspan_nvexec/CMakeLists.txt index 24abd87..8cd39ff 100644 --- a/tutorial/03_mdspan_nvexec/CMakeLists.txt +++ b/tutorial/03_mdspan_nvexec/CMakeLists.txt @@ -1,3 +1,3 @@ add_executable(03_mdspan_test main.cpp) -target_link_libraries(03_mdspan_test PUBLIC Threads::Threads STDEXEC::stdexec STDEXEC::nvexec) +target_link_libraries(03_mdspan_test PUBLIC Threads::Threads STDEXEC::stdexec STDEXEC::nvexec std::mdspan) target_compile_features(03_mdspan_test PUBLIC cxx_std_20) diff --git a/tutorial/05_heat2d/CMakeLists.txt b/tutorial/05_heat2d/CMakeLists.txt index 8b7a38c..9f47acf 100644 --- a/tutorial/05_heat2d/CMakeLists.txt +++ b/tutorial/05_heat2d/CMakeLists.txt @@ -1,5 +1,5 @@ add_executable(05_heat_test heat2D.cpp) -target_link_libraries(05_heat_test PUBLIC Threads::Threads STDEXEC::stdexec STDEXEC::nvexec) +target_link_libraries(05_heat_test PUBLIC Threads::Threads STDEXEC::stdexec STDEXEC::nvexec std::mdspan) target_compile_features(05_heat_test PUBLIC cxx_std_20) set(BACKEND AUTO CACHE STRING "CHOICE OF PARALLEL BACKEND") diff --git a/tutorial/05_heat2d/types.hpp b/tutorial/05_heat2d/types.hpp index 2642360..14070cc 100644 --- a/tutorial/05_heat2d/types.hpp +++ b/tutorial/05_heat2d/types.hpp @@ -13,8 +13,8 @@ namespace stdex = std::experimental; using default_layout = stdex::layout_left; #endif -using RealView1D = stdex::mdspan, default_layout>; -using RealView2D = stdex::mdspan, default_layout>; -using RealView3D = stdex::mdspan, default_layout>; +using RealView1D = stdex::mdspan, default_layout>; +using RealView2D = stdex::mdspan, default_layout>; +using RealView3D = stdex::mdspan, default_layout>; #endif diff --git a/tutorial/06_sender_from_function/CMakeLists.txt b/tutorial/06_sender_from_function/CMakeLists.txt index 9fbbeab..08f729d 100644 --- a/tutorial/06_sender_from_function/CMakeLists.txt +++ b/tutorial/06_sender_from_function/CMakeLists.txt @@ -1,3 +1,3 @@ add_executable(06_sender_from_function heat2D.cpp) -target_link_libraries(06_sender_from_function PUBLIC Threads::Threads STDEXEC::stdexec STDEXEC::nvexec) +target_link_libraries(06_sender_from_function PUBLIC Threads::Threads STDEXEC::stdexec STDEXEC::nvexec std::mdspan) target_compile_features(06_sender_from_function PUBLIC cxx_std_20) diff --git a/tutorial/06_sender_from_function/types.hpp b/tutorial/06_sender_from_function/types.hpp index c14b996..104e1ea 100644 --- a/tutorial/06_sender_from_function/types.hpp +++ b/tutorial/06_sender_from_function/types.hpp @@ -14,8 +14,8 @@ namespace stdex = std::experimental; using default_layout = stdex::layout_right; #endif -using RealView1D = stdex::mdspan, default_layout>; -using RealView2D = stdex::mdspan, default_layout>; -using RealView3D = stdex::mdspan, default_layout>; +using RealView1D = stdex::mdspan, default_layout>; +using RealView2D = stdex::mdspan, default_layout>; +using RealView3D = stdex::mdspan, default_layout>; #endif diff --git a/tutorial/07_heat2d_repeat_n/CMakeLists.txt b/tutorial/07_heat2d_repeat_n/CMakeLists.txt index b2c7c5c..dab0461 100644 --- a/tutorial/07_heat2d_repeat_n/CMakeLists.txt +++ b/tutorial/07_heat2d_repeat_n/CMakeLists.txt @@ -1,3 +1,3 @@ add_executable(07_heat2d_repeat_n heat2D.cpp) -target_link_libraries(07_heat2d_repeat_n PUBLIC Threads::Threads STDEXEC::stdexec STDEXEC::nvexec) +target_link_libraries(07_heat2d_repeat_n PUBLIC Threads::Threads STDEXEC::stdexec STDEXEC::nvexec std::mdspan) target_compile_features(07_heat2d_repeat_n PUBLIC cxx_std_20) diff --git a/tutorial/07_heat2d_repeat_n/types.hpp b/tutorial/07_heat2d_repeat_n/types.hpp index c14b996..104e1ea 100644 --- a/tutorial/07_heat2d_repeat_n/types.hpp +++ b/tutorial/07_heat2d_repeat_n/types.hpp @@ -14,8 +14,8 @@ namespace stdex = std::experimental; using default_layout = stdex::layout_right; #endif -using RealView1D = stdex::mdspan, default_layout>; -using RealView2D = stdex::mdspan, default_layout>; -using RealView3D = stdex::mdspan, default_layout>; +using RealView1D = stdex::mdspan, default_layout>; +using RealView2D = stdex::mdspan, default_layout>; +using RealView3D = stdex::mdspan, default_layout>; #endif diff --git a/tutorial/08_test_overlapping/types.hpp b/tutorial/08_test_overlapping/types.hpp index c14b996..104e1ea 100644 --- a/tutorial/08_test_overlapping/types.hpp +++ b/tutorial/08_test_overlapping/types.hpp @@ -14,8 +14,8 @@ namespace stdex = std::experimental; using default_layout = stdex::layout_right; #endif -using RealView1D = stdex::mdspan, default_layout>; -using RealView2D = stdex::mdspan, default_layout>; -using RealView3D = stdex::mdspan, default_layout>; +using RealView1D = stdex::mdspan, default_layout>; +using RealView2D = stdex::mdspan, default_layout>; +using RealView3D = stdex::mdspan, default_layout>; #endif