Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Use reference mdspan Release0.6 #32

Merged
merged 3 commits into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand All @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion ext_lib/eigen
Submodule eigen updated from 59b3ef to a798d0
2 changes: 1 addition & 1 deletion ext_lib/googletest
2 changes: 1 addition & 1 deletion ext_lib/json
Submodule json updated 1 files
+1 −0 README.md
1 change: 1 addition & 0 deletions ext_lib/mdspan
Submodule mdspan added at 9d0a45
2 changes: 1 addition & 1 deletion ext_lib/stdexec
Submodule stdexec updated 77 files
+1 −0 .clang-format
+1 −0 .github/workflows/ci.gpu.yml
+2 −0 CMakeLists.txt
+3 −3 README.md
+1 −0 examples/nvexec/CMakeLists.txt
+8 −7 examples/nvexec/maxwell/snr.cuh
+33 −0 examples/nvexec/nvtx.cpp
+3 −6 include/exec/__detail/__sender_facade.hpp
+9 −2 include/exec/any_sender_of.hpp
+6 −1 include/exec/async_scope.hpp
+1 −0 include/exec/at_coroutine_exit.hpp
+3 −3 include/exec/env.hpp
+6 −1 include/exec/finally.hpp
+46 −35 include/exec/linux/io_uring_context.hpp
+4 −0 include/exec/materialize.hpp
+9 −7 include/exec/on.hpp
+360 −0 include/exec/sequence/any_sequence_of.hpp
+2 −2 include/exec/sequence/empty_sequence.hpp
+300 −0 include/exec/sequence/ignore_all_values.hpp
+191 −0 include/exec/sequence/iterate.hpp
+26 −6 include/exec/sequence_senders.hpp
+386 −345 include/exec/static_thread_pool.hpp
+1 −0 include/exec/task.hpp
+23 −4 include/exec/variant_sender.hpp
+2 −1 include/exec/when_any.hpp
+259 −3 include/nvexec/detail/memory.cuh
+1 −0 include/nvexec/detail/queue.cuh
+3 −1 include/nvexec/detail/variant.cuh
+2 −1 include/nvexec/multi_gpu_context.cuh
+168 −0 include/nvexec/nvtx.cuh
+3 −3 include/nvexec/stream/bulk.cuh
+225 −89 include/nvexec/stream/common.cuh
+24 −35 include/nvexec/stream/ensure_started.cuh
+3 −3 include/nvexec/stream/let_xxx.cuh
+9 −2 include/nvexec/stream/reduce.cuh
+70 −8 include/nvexec/stream/schedule_from.cuh
+23 −34 include/nvexec/stream/split.cuh
+35 −12 include/nvexec/stream/sync_wait.cuh
+2 −1 include/nvexec/stream/then.cuh
+2 −3 include/nvexec/stream/transfer.cuh
+4 −3 include/nvexec/stream/upon_error.cuh
+2 −1 include/nvexec/stream/upon_stopped.cuh
+18 −13 include/nvexec/stream/when_all.cuh
+6 −83 include/nvexec/stream_context.cuh
+76 −2 include/stdexec/__detail/__config.hpp
+2 −0 include/stdexec/__detail/__execution_fwd.hpp
+152 −43 include/stdexec/__detail/__meta.hpp
+161 −0 include/stdexec/__detail/__sender_utils.hpp
+12 −5 include/stdexec/concepts.hpp
+925 −697 include/stdexec/execution.hpp
+48 −7 include/stdexec/functional.hpp
+4 −1 test/CMakeLists.txt
+134 −0 test/exec/sequence/test_any_sequence_of.cpp
+4 −2 test/exec/sequence/test_empty_sequence.cpp
+74 −0 test/exec/sequence/test_ignore_all_values.cpp
+106 −0 test/exec/sequence/test_iterate.cpp
+4 −1 test/exec/test_any_sender.cpp
+16 −6 test/exec/test_io_uring_context.cpp
+2 −0 test/exec/test_sequence_senders.cpp
+50 −0 test/exec/test_task.cpp
+11 −5 test/exec/test_variant_sender.cpp
+27 −0 test/exec/test_when_any.cpp
+2 −0 test/nvexec/CMakeLists.txt
+9 −10 test/nvexec/bulk.cpp
+5 −2 test/nvexec/common.cuh
+86 −0 test/nvexec/monotonic_buffer.cpp
+87 −0 test/nvexec/synchronized_pool.cpp
+97 −7 test/nvexec/then.cpp
+48 −0 test/nvexec/tracer_resource.h
+1 −22 test/nvexec/upon_error.cpp
+26 −4 test/stdexec/algos/adaptors/test_then.cpp
+99 −0 test/stdexec/algos/adaptors/test_upon_error.cpp
+2 −1 test/stdexec/algos/adaptors/test_when_all.cpp
+14 −6 test/stdexec/concepts/test_awaitables.cpp
+2 −0 test/stdexec/cpos/test_cpo_connect.cpp
+22 −1 test/test_common/receivers.hpp
+30 −10 test/test_common/schedulers.hpp
1 change: 1 addition & 0 deletions lib/executors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions lib/executors/Transpose.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<value_type, stdex::dextents<size_type, 2>, layout_type>;
using mdspan2d_type = stdex::mdspan<value_type, std::dextents<size_type, 2>, layout_type>;
using extent2d_type = std::array<std::size_t, 2>;
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)});
Expand All @@ -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<value_type, stdex::dextents<size_type, 2>, layout_type>;
using mdspan2d_type = stdex::mdspan<value_type, std::dextents<size_type, 2>, layout_type>;
using extent2d_type = std::array<std::size_t, 2>;
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)});
Expand Down
56 changes: 28 additions & 28 deletions lib/executors/numpy_like.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}
Expand All @@ -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);
}
}
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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<typename InoutView::layout_type, 2> policy2d({0, 0}, {nx0, nx1});
Expand Down Expand Up @@ -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<typename InoutView::layout_type, 2> policy2d({0, 0}, {nx0, nx1});
Expand Down Expand Up @@ -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<typename InoutView::layout_type, 3> policy3d({0, 0, 0}, {nx0, nx1, nx2});
Expand Down Expand Up @@ -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<typename InoutView::layout_type, 3> policy3d({0, 0, 0}, {nx0, nx1, nx2});
Expand Down Expand Up @@ -767,7 +767,7 @@ namespace Impl {

const std::size_t rank = ViewType::rank();

using mdspan_type = stdex::mdspan<value_type, stdex::dextents<size_type, rank-1>, layout_type>;
using mdspan_type = stdex::mdspan<value_type, std::dextents<size_type, rank-1>, layout_type>;
using extent_type = std::array<std::size_t, rank-1>;

std::vector<std::size_t> v;
Expand All @@ -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<value_type, stdex::dextents<size_type, N>, layout_type>;
using mdspan_type = stdex::mdspan<value_type, std::dextents<size_type, N>, layout_type>;

return mdspan_type( x.data_handle(), shape );
}
Expand Down
16 changes: 8 additions & 8 deletions lib/openmp_linalg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ namespace Impl {

#pragma omp parallel for
for(int ib=0; ib<batchSize; ib++) {
auto sub_A = submdspan(A, std::experimental::full_extent, std::experimental::full_extent, ib);
auto sub_B = submdspan(B, std::experimental::full_extent, std::experimental::full_extent, ib);
auto sub_C = submdspan(C, std::experimental::full_extent, std::experimental::full_extent, ib);
auto sub_A = stdex::submdspan(A, std::full_extent, std::full_extent, ib);
auto sub_B = stdex::submdspan(B, std::full_extent, std::full_extent, ib);
auto sub_C = stdex::submdspan(C, std::full_extent, std::full_extent, ib);

Eigen::Map<const matrix_type> matA(sub_A.data_handle(), sub_A.extent(0), sub_A.extent(1));
Eigen::Map<const matrix_type> matB(sub_B.data_handle(), sub_B.extent(0), sub_B.extent(1));
Expand Down Expand Up @@ -133,9 +133,9 @@ namespace Impl {

#pragma omp parallel for
for(int ib=0; ib<batchSize; ib++) {
auto sub_A = submdspan(A, std::experimental::full_extent, std::experimental::full_extent, ib);
auto sub_B = submdspan(B, std::experimental::full_extent, ib);
auto sub_C = submdspan(C, std::experimental::full_extent, ib);
auto sub_A = stdex::submdspan(A, std::full_extent, std::full_extent, ib);
auto sub_B = stdex::submdspan(B, std::full_extent, ib);
auto sub_C = stdex::submdspan(C, std::full_extent, ib);

Eigen::Map<const matrix_type> matA(sub_A.data_handle(), sub_A.extent(0), sub_A.extent(1));
Eigen::Map<const vector_type> vecB(sub_B.data_handle(), sub_B.extent(0));
Expand Down Expand Up @@ -186,8 +186,8 @@ namespace Impl {
const int batchSize = v.extent(1);
#pragma omp parallel for
for(int ib=0; ib<batchSize; ib++) {
auto sub_a = submdspan(a, std::experimental::full_extent, std::experimental::full_extent, ib);
auto sub_v = submdspan(v, std::experimental::full_extent, ib);
auto sub_a = stdex::submdspan(a, std::full_extent, std::full_extent, ib);
auto sub_v = stdex::submdspan(v, std::full_extent, ib);

Eigen::Map<matrix_type> mat(sub_a.data_handle(), sub_a.extent(0), sub_a.extent(1));
Eigen::Map<vector_type> vec(sub_v.data_handle(), sub_v.extent(0));
Expand Down
1 change: 1 addition & 0 deletions lib/stdpar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions lib/stdpar/Transpose.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<value_type, stdex::dextents<size_type, 2>, layout_type>;
using mdspan2d_type = stdex::mdspan<value_type, std::dextents<size_type, 2>, layout_type>;
using extent2d_type = std::array<std::size_t, 2>;
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)});
Expand All @@ -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<value_type, stdex::dextents<size_type, 2>, layout_type>;
using mdspan2d_type = stdex::mdspan<value_type, std::dextents<size_type, 2>, layout_type>;
using extent2d_type = std::array<std::size_t, 2>;
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)});
Expand Down
Loading