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

Add rmm::exec_policy_nosync #1009

Merged
merged 2 commits into from
Apr 26, 2022
Merged
Changes from 1 commit
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
29 changes: 29 additions & 0 deletions include/rmm/exec_policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <rmm/mr/device/thrust_allocator_adaptor.hpp>

#include <thrust/system/cuda/execution_policy.h>
#include <thrust/version.h>

namespace rmm {

Expand All @@ -46,4 +47,32 @@ class exec_policy : public thrust_exec_policy_t {
}
};

#if THRUST_VERSION >= 101600

using thrust_exec_policy_nosync_t =
thrust::detail::execute_with_allocator<rmm::mr::thrust_allocator<char>,
thrust::cuda_cub::execute_on_stream_nosync_base>;
/**
* @brief Helper class usable as a Thrust CUDA execution policy
* that uses RMM for temporary memory allocation on the specified stream
* and which allows the Thrust backend to skip stream synchronizations that
* are not required for correctness.
*/
class exec_policy_nosync : public thrust_exec_policy_nosync_t {
public:
explicit exec_policy_nosync(cuda_stream_view stream = cuda_stream_default,
rmm::mr::device_memory_resource* mr = mr::get_current_device_resource())
: thrust_exec_policy_nosync_t(
thrust::cuda::par_nosync(rmm::mr::thrust_allocator<char>(stream, mr)).on(stream.value()))
{
}
};

#else

using thrust_exec_policy_nosync_t = thrust_exec_policy_t;
using exec_policy_nosync = exec_policy;

#endif

} // namespace rmm