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

Change rmm::exec_policy to take async_resource_ref #1449

Merged
merged 4 commits into from
Feb 2, 2024
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
17 changes: 11 additions & 6 deletions include/rmm/exec_policy.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,6 +28,8 @@
#include <thrust/system/cuda/execution_policy.h>
#include <thrust/version.h>

#include <cuda/memory_resource>

namespace rmm {
/**
* @addtogroup thrust_integrations
Expand All @@ -47,15 +49,17 @@ using thrust_exec_policy_t =
* that uses RMM for temporary memory allocation on the specified stream.
*/
class exec_policy : public thrust_exec_policy_t {
using async_resource_ref = cuda::mr::async_resource_ref<cuda::mr::device_accessible>;

public:
/**
* @brief Construct a new execution policy object
*
* @param stream The stream on which to allocate temporary memory
* @param mr The resource to use for allocating temporary memory
*/
explicit exec_policy(cuda_stream_view stream = cuda_stream_default,
rmm::mr::device_memory_resource* mr = mr::get_current_device_resource())
explicit exec_policy(cuda_stream_view stream = cuda_stream_default,
async_resource_ref mr = rmm::mr::get_current_device_resource())
: thrust_exec_policy_t(
thrust::cuda::par(rmm::mr::thrust_allocator<char>(stream, mr)).on(stream.value()))
{
Expand All @@ -77,10 +81,11 @@ using thrust_exec_policy_nosync_t =
* are not required for correctness.
*/
class exec_policy_nosync : public thrust_exec_policy_nosync_t {
using async_resource_ref = cuda::mr::async_resource_ref<cuda::mr::device_accessible>;

public:
explicit exec_policy_nosync(
cuda_stream_view stream = cuda_stream_default,
rmm::mr::device_memory_resource* mr = mr::get_current_device_resource())
explicit exec_policy_nosync(cuda_stream_view stream = cuda_stream_default,
async_resource_ref mr = rmm::mr::get_current_device_resource())
: thrust_exec_policy_nosync_t(
thrust::cuda::par_nosync(rmm::mr::thrust_allocator<char>(stream, mr)).on(stream.value()))
{
Expand Down
Loading