Skip to content

Commit 314272f

Browse files
committed
Replace STF SCOPE(exit) with cudax scope_exit in data_place_impl
Use cuda::experimental::scope_exit instead of the STF-specific SCOPE(exit) macro. This removes __places' dependency on scope_guard.cuh (and transitively on unittest.cuh, traits.cuh, core.cuh), reducing the __stf -> __places coupling. Made-with: Cursor
1 parent a12219d commit 314272f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

cudax/include/cuda/experimental/__places/data_place_impl.cuh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include <cuda/experimental/__places/data_place_interface.cuh>
3232
#include <cuda/experimental/__stf/utility/cuda_safe_call.cuh>
33-
#include <cuda/experimental/__stf/utility/scope_guard.cuh>
33+
#include <cuda/experimental/__utility/scope_exit.cuh>
3434

3535
namespace cuda::experimental::stf
3636
{
@@ -258,13 +258,12 @@ public:
258258
cuda_safe_call(cudaSetDevice(device_id_));
259259
}
260260

261-
SCOPE(exit)
262-
{
261+
::cuda::experimental::scope_exit restore_dev([&]() noexcept {
263262
if (prev_dev != device_id_)
264263
{
265264
cuda_safe_call(cudaSetDevice(prev_dev));
266265
}
267-
};
266+
});
268267

269268
cuda_safe_call(cudaMallocAsync(&result, size, stream));
270269
return result;
@@ -279,13 +278,12 @@ public:
279278
cuda_safe_call(cudaSetDevice(device_id_));
280279
}
281280

282-
SCOPE(exit)
283-
{
281+
::cuda::experimental::scope_exit restore_dev([&]() noexcept {
284282
if (prev_dev != device_id_)
285283
{
286284
cuda_safe_call(cudaSetDevice(prev_dev));
287285
}
288-
};
286+
});
289287

290288
cuda_safe_call(cudaFreeAsync(ptr, stream));
291289
}

0 commit comments

Comments
 (0)