@@ -155,9 +155,10 @@ CUB_RUNTIME_FUNCTION inline int DeviceCountUncached()
155
155
156
156
/* *
157
157
* \brief Cache for an arbitrary value produced by a nullary function.
158
+ * deprecated [Since 2.6.0]
158
159
*/
159
160
template <typename T, T (*Function)()>
160
- struct ValueCache
161
+ struct CUB_DEPRECATED ValueCache
161
162
{
162
163
T const value;
163
164
@@ -170,13 +171,11 @@ struct ValueCache
170
171
{}
171
172
};
172
173
173
- // Host code, only safely usable in C++11 or newer, where thread-safe
174
- // initialization of static locals is guaranteed. This is a separate function
175
- // to avoid defining a local static in a host/device function.
174
+ // Host code. This is a separate function to avoid defining a local static in a host/device function.
176
175
_CCCL_HOST inline int DeviceCountCachedValue ()
177
176
{
178
- static ValueCache< int , DeviceCountUncached> cache ;
179
- return cache. value ;
177
+ static int count = DeviceCountUncached () ;
178
+ return count ;
180
179
}
181
180
182
181
/* *
@@ -211,7 +210,7 @@ struct PerDeviceAttributeCache
211
210
// Each entry starts in the `DeviceEntryEmpty` state, then proceeds to the
212
211
// `DeviceEntryInitializing` state, and then proceeds to the
213
212
// `DeviceEntryReady` state. These are the only state transitions allowed;
214
- // e.g . a linear sequence of transitions.
213
+ // i.e . a linear sequence of transitions.
215
214
enum DeviceEntryStatus
216
215
{
217
216
DeviceEntryEmpty = 0 ,
@@ -372,7 +371,6 @@ _CCCL_HOST inline cudaError_t PtxVersionUncached(int& ptx_version, int device)
372
371
template <typename Tag>
373
372
_CCCL_HOST inline PerDeviceAttributeCache& GetPerDeviceAttributeCache ()
374
373
{
375
- // C++11 guarantees that initialization of static locals is thread safe.
376
374
static PerDeviceAttributeCache cache;
377
375
return cache;
378
376
}
@@ -392,8 +390,7 @@ struct SmVersionCacheTag
392
390
_CCCL_HOST inline cudaError_t PtxVersion (int & ptx_version, int device)
393
391
{
394
392
auto const payload = GetPerDeviceAttributeCache<PtxVersionCacheTag>()(
395
- // If this call fails, then we get the error code back in the payload,
396
- // which we check with `CubDebug` below.
393
+ // If this call fails, then we get the error code back in the payload, which we check with `CubDebug` below.
397
394
[=](int & pv) {
398
395
return PtxVersionUncached (pv, device);
399
396
},
@@ -417,23 +414,10 @@ _CCCL_HOST inline cudaError_t PtxVersion(int& ptx_version, int device)
417
414
CUB_RUNTIME_FUNCTION inline cudaError_t PtxVersion (int & ptx_version)
418
415
{
419
416
cudaError_t result = cudaErrorUnknown;
420
- NV_IF_TARGET (
421
- NV_IS_HOST,
422
- (auto const device = CurrentDevice ();
423
- auto const payload = GetPerDeviceAttributeCache<PtxVersionCacheTag>()(
424
- // If this call fails, then we get the error code back in the payload,
425
- // which we check with `CubDebug` below.
426
- [=](int & pv) {
427
- return PtxVersionUncached (pv, device);
428
- },
429
- device);
430
-
431
- if (!CubDebug (payload.error )) { ptx_version = payload.attribute ; }
432
-
433
- result = payload.error ;),
434
- ( // NV_IS_DEVICE:
435
- result = PtxVersionUncached (ptx_version);));
436
-
417
+ NV_IF_TARGET (NV_IS_HOST,
418
+ (result = PtxVersion (ptx_version, CurrentDevice ());),
419
+ ( // NV_IS_DEVICE:
420
+ result = PtxVersionUncached (ptx_version);));
437
421
return result;
438
422
}
439
423
@@ -477,8 +461,7 @@ CUB_RUNTIME_FUNCTION inline cudaError_t SmVersion(int& sm_version, int device =
477
461
NV_IF_TARGET (
478
462
NV_IS_HOST,
479
463
(auto const payload = GetPerDeviceAttributeCache<SmVersionCacheTag>()(
480
- // If this call fails, then we get the error code back in
481
- // the payload, which we check with `CubDebug` below.
464
+ // If this call fails, then we get the error code back in the payload, which we check with `CubDebug` below.
482
465
[=](int & pv) {
483
466
return SmVersionUncached (pv, device);
484
467
},
@@ -565,9 +548,8 @@ CUB_RUNTIME_FUNCTION inline cudaError_t DebugSyncStream(cudaStream_t stream)
565
548
CUB_RUNTIME_FUNCTION inline cudaError_t HasUVA (bool & has_uva)
566
549
{
567
550
has_uva = false ;
568
- cudaError_t error = cudaSuccess;
569
551
int device = -1 ;
570
- error = CubDebug (cudaGetDevice (&device));
552
+ cudaError_t error = CubDebug (cudaGetDevice (&device));
571
553
if (cudaSuccess != error)
572
554
{
573
555
return error;
0 commit comments