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 device_scalar to take async_resource_ref #1447

Merged
merged 6 commits into from
Feb 2, 2024
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
18 changes: 8 additions & 10 deletions include/rmm/device_scalar.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2021, NVIDIA CORPORATION.
* Copyright (c) 2019-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 All @@ -18,8 +18,8 @@

#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/mr/device/device_memory_resource.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
#include <rmm/resource_ref.hpp>

#include <type_traits>

Expand Down Expand Up @@ -92,9 +92,8 @@ class device_scalar {
* @param stream Stream on which to perform asynchronous allocation.
* @param mr Optional, resource with which to allocate.
*/
explicit device_scalar(
cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
explicit device_scalar(cuda_stream_view stream,
device_async_resource_ref mr = mr::get_current_device_resource())
: _storage{1, stream, mr}
{
}
Expand All @@ -115,10 +114,9 @@ class device_scalar {
* @param stream Optional, stream on which to perform allocation and copy.
* @param mr Optional, resource with which to allocate.
*/
explicit device_scalar(
value_type const& initial_value,
cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
explicit device_scalar(value_type const& initial_value,
cuda_stream_view stream,
device_async_resource_ref mr = mr::get_current_device_resource())
: _storage{1, stream, mr}
{
set_value_async(initial_value, stream);
Expand All @@ -138,7 +136,7 @@ class device_scalar {
*/
device_scalar(device_scalar const& other,
cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
device_async_resource_ref mr = mr::get_current_device_resource())
: _storage{other._storage, stream, mr}
{
}
Expand Down
5 changes: 4 additions & 1 deletion tests/device_scalar_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
#include <rmm/device_scalar.hpp>
#include <rmm/mr/device/device_memory_resource.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
#include <rmm/resource_ref.hpp>

#include <cuda_runtime_api.h>

#include <cuda/memory_resource>

#include <chrono>
#include <cstddef>
#include <random>
Expand All @@ -36,7 +39,7 @@ struct DeviceScalarTest : public ::testing::Test {
std::default_random_engine generator{};
T value{};
rmm::cuda_stream stream{};
rmm::mr::device_memory_resource* mr{rmm::mr::get_current_device_resource()};
rmm::device_async_resource_ref mr{rmm::mr::get_current_device_resource()};

DeviceScalarTest() : value{random_value()} {}

Expand Down
Loading