Skip to content

Commit c70f7e9

Browse files
committed
Replace EXPECT with _CCCL_ASSERT for idx bounds checks
Where idx is only checked (idx == 0) but not used afterwards, use _CCCL_ASSERT instead of EXPECT. These are precondition checks that can be disabled in release builds. Keeps EXPECT for grid impl where idx is validated against size and then used to index the array. Made-with: Cursor
1 parent 1ba3459 commit c70f7e9

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

cudax/include/cuda/experimental/__stf/places/exec/green_context.cuh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,13 @@ public:
279279

280280
::std::shared_ptr<exec_place::impl> get_place(size_t idx) override
281281
{
282-
EXPECT(idx == 0, "Index out of bounds for green_ctx exec_place");
282+
_CCCL_ASSERT(idx == 0, "Index out of bounds for green_ctx exec_place");
283283
return shared_from_this();
284284
}
285285

286286
exec_place activate(size_t idx) const override
287287
{
288-
EXPECT(idx == 0, "Index out of bounds for green_ctx exec_place");
288+
_CCCL_ASSERT(idx == 0, "Index out of bounds for green_ctx exec_place");
289289

290290
// Save the current context and transform it into a fake green context place
291291
CUcontext current_ctx;
@@ -301,7 +301,7 @@ public:
301301

302302
void deactivate(const exec_place& prev, size_t idx = 0) const override
303303
{
304-
EXPECT(idx == 0, "Index out of bounds for green_ctx exec_place");
304+
_CCCL_ASSERT(idx == 0, "Index out of bounds for green_ctx exec_place");
305305

306306
auto prev_impl = ::std::static_pointer_cast<exec_place_green_ctx_impl>(prev.get_impl());
307307
CUcontext saved_ctx = prev_impl->driver_context_;

cudax/include/cuda/experimental/__stf/places/places.cuh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -943,21 +943,21 @@ public:
943943
// Grid interface - host is a 1-element grid
944944
::std::shared_ptr<exec_place::impl> get_place(size_t idx) override
945945
{
946-
EXPECT(idx == 0, "Index out of bounds for host exec_place");
946+
_CCCL_ASSERT(idx == 0, "Index out of bounds for host exec_place");
947947
// Static instance - use no-op deleter instead of shared_from_this()
948948
return ::std::shared_ptr<impl>(this, [](impl*) {});
949949
}
950950

951951
// Activation - no-op for host
952952
exec_place activate(size_t idx) const override
953953
{
954-
EXPECT(idx == 0, "Index out of bounds for host exec_place");
954+
_CCCL_ASSERT(idx == 0, "Index out of bounds for host exec_place");
955955
return exec_place();
956956
}
957957

958958
void deactivate(const exec_place& prev, size_t idx = 0) const override
959959
{
960-
EXPECT(idx == 0, "Index out of bounds for host exec_place");
960+
_CCCL_ASSERT(idx == 0, "Index out of bounds for host exec_place");
961961
_CCCL_ASSERT(!prev.get_impl(), "Host deactivate expects empty prev");
962962
}
963963

@@ -1012,7 +1012,7 @@ public:
10121012

10131013
::std::shared_ptr<exec_place::impl> get_place(size_t idx) override
10141014
{
1015-
EXPECT(idx == 0, "Index out of bounds for device_auto exec_place");
1015+
_CCCL_ASSERT(idx == 0, "Index out of bounds for device_auto exec_place");
10161016
// Static instance - use no-op deleter instead of shared_from_this()
10171017
return ::std::shared_ptr<impl>(this, [](impl*) {});
10181018
}
@@ -1061,7 +1061,7 @@ public:
10611061

10621062
exec_place activate(size_t idx) const override
10631063
{
1064-
EXPECT(idx == 0, "Index out of bounds for device exec_place");
1064+
_CCCL_ASSERT(idx == 0, "Index out of bounds for device exec_place");
10651065
auto old_dev_id = cuda_try<cudaGetDevice>();
10661066
if (old_dev_id != devid_)
10671067
{
@@ -1072,7 +1072,7 @@ public:
10721072

10731073
void deactivate(const exec_place& prev, size_t idx = 0) const override
10741074
{
1075-
EXPECT(idx == 0, "Index out of bounds for device exec_place");
1075+
_CCCL_ASSERT(idx == 0, "Index out of bounds for device exec_place");
10761076
auto current_dev_id = cuda_try<cudaGetDevice>();
10771077
auto restored_dev_id = device_ordinal(prev.affine_data_place());
10781078
if (current_dev_id != restored_dev_id)
@@ -1328,13 +1328,13 @@ inline exec_place data_place::affine_exec_place() const
13281328

13291329
inline ::std::shared_ptr<exec_place::impl> exec_place::impl::get_place(size_t idx)
13301330
{
1331-
EXPECT(idx == 0, "Index out of bounds for scalar exec_place");
1331+
_CCCL_ASSERT(idx == 0, "Index out of bounds for scalar exec_place");
13321332
return shared_from_this();
13331333
}
13341334

13351335
inline ::std::shared_ptr<exec_place::impl> exec_place_device::impl::get_place(size_t idx)
13361336
{
1337-
EXPECT(idx == 0, "Index out of bounds for device exec_place");
1337+
_CCCL_ASSERT(idx == 0, "Index out of bounds for device exec_place");
13381338
// Static instance - use no-op deleter instead of shared_from_this()
13391339
return ::std::shared_ptr<impl>(this, [](impl*) {});
13401340
}

0 commit comments

Comments
 (0)