NERSC / hpcpp

MIT License
7 stars 3 forks source link

fix for repeat_n when stdpar=multicore #8

Closed mhaseeb123 closed 7 months ago

mhaseeb123 commented 7 months ago

This PR fixes - at least for now - issue 7 (https://github.com/NERSC/hpcpp/issues/7) using compiler directive on USE_GPU. Elegant fix will be to write a repeat_nΩ sender for multicore scheduler.

weilewei commented 7 months ago

Although I really do not like the idea of diverging CPU & GPU code, it seems this is the only workaround now. Unless there is repeat_n cpu implementation. Let me create a ticket on stdexec.

Here is the compilation error I tried for PrefixSum. Can you fix it?

[ 92%] Building CXX object apps/prefixSum/CMakeFiles/prefixSum-stdexec.dir/prefixSum-stdexec.cpp.o
"/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp", line 58: error: namespace "exec" has no member "on"
      | exec::on(sch,
              ^

"/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp", line 57: error: the deduced placeholder type "<error-type>" failed the type constraint
      ex::sender auto uSweep = ex::just()
      ^
"/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/execution.hpp", line 1489: note: atomic constraint failed substitution
      enable_sender<__decay_t<_Sender>> &&                  //
      ^

"/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp", line 81: error: no instance of overloaded function "stdexec::__sync_wait::sync_wait_t::operator()" matches the argument list
            argument types are: (<error-type>)
            object type is: const stdexec::__sync_wait::sync_wait_t
      ex::sync_wait(uSweep);
      ^

"/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp", line 92: error: namespace "exec" has no member "on"
      | exec::on(sch,
              ^

"/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp", line 91: error: the deduced placeholder type "<error-type>" failed the type constraint
      ex::sender auto dSweep = ex::just()
      ^
"/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/execution.hpp", line 1489: note: atomic constraint failed substitution
      enable_sender<__decay_t<_Sender>> &&                  //
      ^

"/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp", line 121: error: no instance of overloaded function "stdexec::__sync_wait::sync_wait_t::operator()" matches the argument list
            argument types are: (<error-type>)
            object type is: const stdexec::__sync_wait::sync_wait_t
      ex::sync_wait(dSweep);
      ^

"/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/execution.hpp", line 682: warning: statement is unreachable [code_is_unreachable]
        STDEXEC_UNREACHABLE();
        ^
          detected during:
            instantiation of "auto stdexec::__bulk::bulk_t::operator()(_Sender &&, _Shape, _Fun) const [with _Sender=exec::static_thread_pool::scheduler::sender, _Shape=int, _Fun=lambda [](int)->void]" at line 51 of "/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp"
            instantiation of "T *prefixSum(stdexec::scheduler auto &&, const T *, int) [with T=data_t, <auto-1>=exec::static_thread_pool::scheduler]" at line 184 of "/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp"

Remark: individual warnings can be suppressed with "--diag_suppress <warning-name>"

"/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/exec/static_thread_pool.hpp", line 239: warning: statement is unreachable [code_is_unreachable]
          STDEXEC_UNREACHABLE();
          ^
          detected during:
            instantiation of "decltype(auto) stdexec::__domain::__transform_sender_1::operator()(_Domain, _Sender &&, const _Env &...) const [with _Domain=exec::static_thread_pool::domain, _Sender=stdexec::__sexpr<lambda [](_Cvref, _Fun &&) mutable->decltype((<expression>))>, _Env=<>]" at line 328 of "/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/__detail/__meta.hpp"
            instantiation of class "stdexec::__mdefer<_Fn, _Args...> [with _Fn=stdexec::__q<stdexec::__call_result_>, _Args=<stdexec::__domain::__transform_sender_1, exec::static_thread_pool::domain, stdexec::__sexpr<lambda [](_Cvref, _Fun &&) mutable->decltype((<expression>))>>]" at line 60 of "/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/__detail/__meta.hpp"
            instantiation of type "stdexec::__t<stdexec::__mdefer<stdexec::__q<stdexec::__call_result_>, stdexec::__domain::__transform_sender_1, exec::static_thread_pool::domain, stdexec::__sexpr<lambda [](_Cvref, _Fun &&) mutable->decltype((<expression>))>>>" at line 719 of "/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/__detail/__meta.hpp"
            instantiation of type "stdexec::__call_result_t<stdexec::__domain::__transform_sender_1, exec::static_thread_pool::domain, stdexec::__sexpr<lambda [](_Cvref, _Fun &&) mutable->decltype((<expression>))>>" at line 1303 of "/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/execution.hpp"
            instantiation of "decltype(auto) stdexec::__domain::__transform_sender::operator()(_Domain, _Sender &&, const _Env &...) const [with _Self=stdexec::__domain::__transform_sender, _Domain=exec::static_thread_pool::domain, _Sender=stdexec::__sexpr<lambda [](_Cvref, _Fun &&) mutable->decltype((<expression>))>, _Env=<>]" at line 3843 of "/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/execution.hpp"
            instantiation of "auto stdexec::__bulk::bulk_t::operator()(_Sender &&, _Shape, _Fun) const [with _Sender=exec::static_thread_pool::scheduler::sender, _Shape=int, _Fun=lambda [](int)->void]" at line 51 of "/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp"
            instantiation of "T *prefixSum(stdexec::scheduler auto &&, const T *, int) [with T=data_t, <auto-1>=exec::static_thread_pool::scheduler]" at line 184 of "/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp"

"/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/execution.hpp", line 136: warning: statement is unreachable [code_is_unreachable]
        STDEXEC_UNREACHABLE();
        ^
          detected during:
            instantiation of "decltype(auto) stdexec::__domain::__transform_sender_1::operator()(_Domain, _Sender &&, const _Env &...) const [with _Domain=exec::static_thread_pool::domain, _Sender=exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>, _Env=<>]" at line 328 of "/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/__detail/__meta.hpp"
            instantiation of class "stdexec::__mdefer<_Fn, _Args...> [with _Fn=stdexec::__q<stdexec::__call_result_>, _Args=<stdexec::__domain::__transform_sender_1, exec::static_thread_pool::domain, exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>>]" at line 60 of "/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/__detail/__meta.hpp"
            instantiation of type "stdexec::__t<stdexec::__mdefer<stdexec::__q<stdexec::__call_result_>, stdexec::__domain::__transform_sender_1, exec::static_thread_pool::domain, exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>>>" at line 719 of "/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/__detail/__meta.hpp"
            instantiation of type "stdexec::__call_result_t<stdexec::__domain::__transform_sender_1, exec::static_thread_pool::domain, exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>>" at line 1303
            instantiation of "decltype(auto) stdexec::__domain::__transform_sender::operator()(_Domain, _Sender &&, const _Env &...) const [with _Self=stdexec::__domain::__transform_sender, _Domain=exec::static_thread_pool::domain, _Sender=exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>, _Env=<>]" at line 1311
            instantiation of "decltype(auto) stdexec::__domain::__transform_sender::operator()(_Domain, _Sender &&, const _Env &...) const [with _Self=stdexec::__domain::__transform_sender, _Domain=exec::static_thread_pool::domain, _Sender=stdexec::__sexpr<lambda [](_Cvref, _Fun &&) mutable->decltype((<expression>))>, _Env=<>]" at line 3843
            instantiation of "auto stdexec::__bulk::bulk_t::operator()(_Sender &&, _Shape, _Fun) const [with _Sender=exec::static_thread_pool::scheduler::sender, _Shape=int, _Fun=lambda [](int)->void]" at line 51 of "/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp"
            instantiation of "T *prefixSum(stdexec::scheduler auto &&, const T *, int) [with T=data_t, <auto-1>=exec::static_thread_pool::scheduler]" at line 184 of "/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp"

"/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/execution.hpp", line 7269: warning: statement is unreachable [code_is_unreachable]
        STDEXEC_UNREACHABLE();
        ^
          detected during instantiation of "T *prefixSum(stdexec::scheduler auto &&, const T *, int) [with T=data_t, <auto-1>=exec::static_thread_pool::scheduler]" at line 184 of "/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp"

"/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/execution.hpp", line 706: warning: statement is unreachable [code_is_unreachable]
        STDEXEC_UNREACHABLE();
        ^
          detected during:
            instantiation of class "stdexec::__mdefer<_Fn, _Args...> [with _Fn=stdexec::__q<stdexec::__call_result_>, _Args=<stdexec::__get_late_domain_t, exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>, stdexec::__sync_wait::__env>]" at line 1433
            instantiation of "auto stdexec::__get_completion_signatures::get_completion_signatures_t::__impl<_Sender,_Env>() [with _Sender=exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>, _Env=stdexec::__sync_wait::__env]" at line 7249
            instantiation of "auto stdexec::__sync_wait::__diagnose_error<_Sender>() [with _Sender=exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>]" at line 51 of "/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp"
            instantiation of "T *prefixSum(stdexec::scheduler auto &&, const T *, int) [with T=data_t, <auto-1>=exec::static_thread_pool::scheduler]" at line 184 of "/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp"

"/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/execution.hpp", line 148: warning: statement is unreachable [code_is_unreachable]
        STDEXEC_UNREACHABLE();
        ^
          detected during:
            instantiation of "decltype(auto) stdexec::__domain::__transform_sender_1::operator()(_Domain, _Sender &&, const _Env &...) const [with _Domain=exec::static_thread_pool::domain, _Sender=exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>, _Env=<stdexec::__sync_wait::__env>]" at line 328 of "/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/__detail/__meta.hpp"
            instantiation of class "stdexec::__mdefer<_Fn, _Args...> [with _Fn=stdexec::__q<stdexec::__call_result_>, _Args=<stdexec::__domain::__transform_sender_1, exec::static_thread_pool::domain, exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>, const stdexec::__sync_wait::__env &>]" at line 60 of "/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/__detail/__meta.hpp"
            instantiation of type "stdexec::__t<stdexec::__mdefer<stdexec::__q<stdexec::__call_result_>, stdexec::__domain::__transform_sender_1, exec::static_thread_pool::domain, exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>, const stdexec::__sync_wait::__env &>>" at line 719 of "/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/__detail/__meta.hpp"
            instantiation of type "stdexec::__call_result_t<stdexec::__domain::__transform_sender_1, exec::static_thread_pool::domain, exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>, const stdexec::__sync_wait::__env &>" at line 1303
            instantiation of "decltype(auto) stdexec::__domain::__transform_sender::operator()(_Domain, _Sender &&, const _Env &...) const [with _Self=stdexec::__domain::__transform_sender, _Domain=exec::static_thread_pool::domain, _Sender=exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>, _Env=<stdexec::__sync_wait::__env>]" at line 328 of "/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/__detail/__meta.hpp"
            instantiation of class "stdexec::__mdefer<_Fn, _Args...> [with _Fn=stdexec::__q<stdexec::__call_result_>, _Args=<stdexec::transform_sender_t, exec::static_thread_pool::domain, exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>, stdexec::__sync_wait::__env>]" at line 1433
            instantiation of "auto stdexec::__get_completion_signatures::get_completion_signatures_t::__impl<_Sender,_Env>() [with _Sender=exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>, _Env=stdexec::__sync_wait::__env]" at line 7249
            instantiation of "auto stdexec::__sync_wait::__diagnose_error<_Sender>() [with _Sender=exec::static_thread_pool::bulk_sender<stdexec::_Xp<exec::static_thread_pool::scheduler::sender>::_Up, int, stdexec::_Xp<lambda [](int)->void>::_Up>]" at line 51 of "/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp"
            instantiation of "T *prefixSum(stdexec::scheduler auto &&, const T *, int) [with T=data_t, <auto-1>=exec::static_thread_pool::scheduler]" at line 184 of "/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp"

"/global/homes/w/wwei/src/hpcpp/build_repeat_n/_deps/stdexec-src/include/stdexec/execution.hpp", line 163: warning: statement is unreachable [code_is_unreachable]
        STDEXEC_UNREACHABLE();
        ^
          detected during instantiation of "T *prefixSum(stdexec::scheduler auto &&, const T *, int) [with T=data_t, <auto-1>=exec::static_thread_pool::scheduler]" at line 184 of "/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp"

"/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp", line 59: error: identifier "repeat_n" is undefined
         repeat_n(niters, ex::bulk(N/2, [=](int k){
         ^
          detected during instantiation of "T *prefixSum(stdexec::scheduler auto &&, const T *, int) [with T=data_t, <auto-1>=exec::static_thread_pool::scheduler]" at line 184

7 errors detected in the compilation of "/global/homes/w/wwei/src/hpcpp/apps/prefixSum/prefixSum-stdexec.cpp".
make[2]: *** [apps/prefixSum/CMakeFiles/prefixSum-stdexec.dir/build.make:76: apps/prefixSum/CMakeFiles/prefixSum-stdexec.dir/prefixSum-stdexec.cpp.o] Error 2
make[1]: *** [CMakeFiles/Makefile2:835: apps/prefixSum/CMakeFiles/prefixSum-stdexec.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
weilewei commented 7 months ago

LGTM!