Skip to content

Commit 050919f

Browse files
committed
Migrate to refs where possible
1 parent 1c11cd3 commit 050919f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

cpp/include/rmm/mr/binning_memory_resource.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class binning_memory_resource final : public device_memory_resource {
154154
} else if (resource_bins_.count(allocation_size) == 0) { // do nothing if bin already exists
155155
owned_bin_resources_.push_back(
156156
std::make_unique<fixed_size_memory_resource<Upstream>>(upstream_mr_, allocation_size));
157-
resource_bins_.insert({allocation_size, owned_bin_resources_.back().get()});
157+
resource_bins_.insert({allocation_size, *owned_bin_resources_.back()});
158158
}
159159
}
160160

cpp/include/rmm/mr/per_device_resource.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ namespace detail {
105105
*
106106
* @return Pointer to the static cuda_memory_resource used as the initial, default resource
107107
*/
108-
RMM_EXPORT inline device_memory_resource* initial_resource()
108+
RMM_EXPORT inline cuda_memory_resource* initial_resource()
109109
{
110110
static cuda_memory_resource mr{};
111111
return &mr;
@@ -198,7 +198,7 @@ inline device_async_resource_ref set_per_device_resource_ref_unsafe(
198198
// Note: because resource_ref is not default-constructible, we can't use std::map::operator[]
199199
if (old_itr == map.end()) {
200200
map.insert({device_id.value(), new_resource_ref});
201-
return device_async_resource_ref{detail::initial_resource()};
201+
return device_async_resource_ref{*detail::initial_resource()};
202202
}
203203

204204
auto old_resource_ref = old_itr->second;
@@ -244,7 +244,7 @@ inline device_memory_resource* set_per_device_resource(cuda_device_id device_id,
244244
// state consistent with the resource pointer state. This is necessary because the
245245
// Python API still uses the raw pointer API. Once the Python API is updated to use
246246
// resource_ref, this call can be removed.
247-
detail::set_per_device_resource_ref_unsafe(device_id, new_mr);
247+
if (new_mr != nullptr) { detail::set_per_device_resource_ref_unsafe(device_id, *new_mr); }
248248

249249
auto& map = detail::get_map();
250250
auto const old_itr = map.find(device_id.value());
@@ -338,7 +338,7 @@ inline device_async_resource_ref get_per_device_resource_ref(cuda_device_id devi
338338
// If a resource was never set for `id`, set to the initial resource
339339
auto const found = map.find(device_id.value());
340340
if (found == map.end()) {
341-
auto item = map.insert({device_id.value(), detail::initial_resource()});
341+
auto item = map.insert({device_id.value(), *detail::initial_resource()});
342342
return item.first->second;
343343
}
344344
return found->second;
@@ -447,7 +447,7 @@ inline device_async_resource_ref set_current_device_resource_ref(
447447
*/
448448
inline device_async_resource_ref reset_per_device_resource_ref(cuda_device_id device_id)
449449
{
450-
return set_per_device_resource_ref(device_id, detail::initial_resource());
450+
return set_per_device_resource_ref(device_id, *detail::initial_resource());
451451
}
452452

453453
/**

0 commit comments

Comments
 (0)