13
13
#include " target_impl.h"
14
14
#include < stdio.h>
15
15
16
- // Warp ID in the CUDA block
17
- INLINE static unsigned getWarpId () { return threadIdx .x / WARPSIZE; }
18
- // Lane ID in the CUDA warp.
19
- INLINE static unsigned getLaneId () { return threadIdx .x % WARPSIZE; }
20
-
21
16
// Return true if this is the first active thread in the warp.
22
17
INLINE static bool IsWarpMasterActiveThread () {
23
18
unsigned long long Mask = __kmpc_impl_activemask ();
@@ -67,7 +62,7 @@ __kmpc_initialize_data_sharing_environment(__kmpc_data_sharing_slot *rootS,
67
62
DSPRINT0 (DSFLAG_INIT,
68
63
" Entering __kmpc_initialize_data_sharing_environment\n " );
69
64
70
- unsigned WID = getWarpId ();
65
+ unsigned WID = GetWarpId ();
71
66
DSPRINT (DSFLAG_INIT, " Warp ID: %u\n " , WID);
72
67
73
68
omptarget_nvptx_TeamDescr *teamDescr =
@@ -111,7 +106,7 @@ EXTERN void *__kmpc_data_sharing_environment_begin(
111
106
DSPRINT (DSFLAG, " Default Data Size %016llx\n " ,
112
107
(unsigned long long )SharingDefaultDataSize);
113
108
114
- unsigned WID = getWarpId ();
109
+ unsigned WID = GetWarpId ();
115
110
__kmpc_impl_lanemask_t CurActiveThreads = __kmpc_impl_activemask ();
116
111
117
112
__kmpc_data_sharing_slot *&SlotP = DataSharingState.SlotPtr [WID];
@@ -231,7 +226,7 @@ EXTERN void __kmpc_data_sharing_environment_end(
231
226
232
227
DSPRINT0 (DSFLAG, " Entering __kmpc_data_sharing_environment_end\n " );
233
228
234
- unsigned WID = getWarpId ();
229
+ unsigned WID = GetWarpId ();
235
230
236
231
if (IsEntryPoint) {
237
232
if (IsWarpMasterActiveThread ()) {
@@ -359,7 +354,7 @@ EXTERN void __kmpc_data_sharing_init_stack_spmd() {
359
354
// This function initializes the stack pointer with the pointer to the
360
355
// statically allocated shared memory slots. The size of a shared memory
361
356
// slot is pre-determined to be 256 bytes.
362
- if (threadIdx . x == 0 )
357
+ if (GetThreadIdInBlock () == 0 )
363
358
data_sharing_init_stack_common ();
364
359
365
360
__threadfence_block ();
@@ -377,7 +372,7 @@ INLINE static void* data_sharing_push_stack_common(size_t PushSize) {
377
372
PushSize = (PushSize + (Alignment - 1 )) / Alignment * Alignment;
378
373
379
374
// Frame pointer must be visible to all workers in the same warp.
380
- const unsigned WID = getWarpId ();
375
+ const unsigned WID = GetWarpId ();
381
376
void *FrameP = 0 ;
382
377
__kmpc_impl_lanemask_t CurActive = __kmpc_impl_activemask ();
383
378
@@ -467,7 +462,7 @@ EXTERN void *__kmpc_data_sharing_push_stack(size_t DataSize,
467
462
// Compute the start address of the frame of each thread in the warp.
468
463
uintptr_t FrameStartAddress =
469
464
(uintptr_t ) data_sharing_push_stack_common (PushSize);
470
- FrameStartAddress += (uintptr_t ) (getLaneId () * DataSize);
465
+ FrameStartAddress += (uintptr_t ) (GetLaneId () * DataSize);
471
466
return (void *)FrameStartAddress;
472
467
}
473
468
@@ -482,7 +477,7 @@ EXTERN void __kmpc_data_sharing_pop_stack(void *FrameStart) {
482
477
__threadfence_block ();
483
478
484
479
if (GetThreadIdInBlock () % WARPSIZE == 0 ) {
485
- unsigned WID = getWarpId ();
480
+ unsigned WID = GetWarpId ();
486
481
487
482
// Current slot
488
483
__kmpc_data_sharing_slot *&SlotP = DataSharingState.SlotPtr [WID];
0 commit comments