Skip to content

Commit 0813f41

Browse files
[libomptarget][nfc] Explicitly static function scope shared variables
Summary: [libomptarget][nfc] Explicitly static function scope shared variables `__shared__` in CUDA implies static in function scope. See e.g. D.2.1.1 in CUDA_C_Programming_Guide.pdf, http://developer.download.nvidia.com/compute/DevZone/docs/html/C/doc/ This is surprising for non-cuda developers, see e.g. D73239 where I thought local variables would be thread local. Tested by IR diff of libomptarget.bc (no change), running in tree tests, and binary diff of the nvcc static archives (no significant change). Reviewers: jdoerfert, ABataev, grokos Reviewed By: jdoerfert Subscribers: openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D76713
1 parent 83346a4 commit 0813f41

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

openmp/libomptarget/deviceRTLs/common/src/reduction.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static int32_t nvptx_teams_reduce_nowait(int32_t global_tid, int32_t num_vars,
230230
: /*Master thread only*/ 1;
231231
uint32_t TeamId = GetBlockIdInKernel();
232232
uint32_t NumTeams = GetNumberOfBlocksInKernel();
233-
SHARED volatile bool IsLastTeam;
233+
static SHARED volatile bool IsLastTeam;
234234

235235
// Team masters of all teams write to the scratchpad.
236236
if (ThreadId == 0) {
@@ -423,8 +423,8 @@ EXTERN int32_t __kmpc_nvptx_teams_reduce_nowait_v2(
423423
: /*Master thread only*/ 1;
424424
uint32_t TeamId = GetBlockIdInKernel();
425425
uint32_t NumTeams = GetNumberOfBlocksInKernel();
426-
SHARED unsigned Bound;
427-
SHARED unsigned ChunkTeamCount;
426+
static SHARED unsigned Bound;
427+
static SHARED unsigned ChunkTeamCount;
428428

429429
// Block progress for teams greater than the current upper
430430
// limit. We always only allow a number of teams less or equal

0 commit comments

Comments
 (0)