Skip to content
Merged
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
4 changes: 2 additions & 2 deletions cpp/src/utilities/prefetch.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -51,7 +51,7 @@ cudaError_t prefetch_noexcept(void const* ptr,
#if defined(CUDART_VERSION) && CUDART_VERSION >= 13000
cudaMemLocation location{
(device_id.value() == cudaCpuDeviceId) ? cudaMemLocationTypeHost : cudaMemLocationTypeDevice,
device_id.value()};
{device_id.value()}};
Comment on lines 52 to +54

@bdice bdice Jul 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative fix that should work with CUDA 13.0-13.2 or CUDA 13.3+ is this (untested):

Suggested change
cudaMemLocation location{
(device_id.value() == cudaCpuDeviceId) ? cudaMemLocationTypeHost : cudaMemLocationTypeDevice,
device_id.value()};
{device_id.value()}};
cudaMemLocation location{};
location.type = (device_id.value() == cudaCpuDeviceId)
? cudaMemLocationTypeHost
: cudaMemLocationTypeDevice;
location.id = device_id.value();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This suggestion appears to be a "declare and delay initialization" anti-pattern which prevents location from being a constant variable.

constexpr int flags = 0;
auto result = cudaMemPrefetchAsync(ptr, size, location, flags, stream.value());
#else
Expand Down
Loading