[Openmp-commits] [PATCH] D76713: [libomptarget][nfc] Explicitly static function scope shared variables
Jon Chesterfield via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Tue Mar 24 10:12:06 PDT 2020
JonChesterfield created this revision.
JonChesterfield added reviewers: jdoerfert, ABataev, grokos.
Herald added a project: OpenMP.
Herald added a subscriber: openmp-commits.
[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 <https://reviews.llvm.org/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).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76713
Files:
openmp/libomptarget/deviceRTLs/common/src/reduction.cu
Index: openmp/libomptarget/deviceRTLs/common/src/reduction.cu
===================================================================
--- openmp/libomptarget/deviceRTLs/common/src/reduction.cu
+++ openmp/libomptarget/deviceRTLs/common/src/reduction.cu
@@ -230,7 +230,7 @@
: /*Master thread only*/ 1;
uint32_t TeamId = GetBlockIdInKernel();
uint32_t NumTeams = GetNumberOfBlocksInKernel();
- SHARED volatile bool IsLastTeam;
+ static SHARED volatile bool IsLastTeam;
// Team masters of all teams write to the scratchpad.
if (ThreadId == 0) {
@@ -423,8 +423,8 @@
: /*Master thread only*/ 1;
uint32_t TeamId = GetBlockIdInKernel();
uint32_t NumTeams = GetNumberOfBlocksInKernel();
- SHARED unsigned Bound;
- SHARED unsigned ChunkTeamCount;
+ static SHARED unsigned Bound;
+ static SHARED unsigned ChunkTeamCount;
// Block progress for teams greater than the current upper
// limit. We always only allow a number of teams less or equal
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76713.252359.patch
Type: text/x-patch
Size: 1015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200324/db346874/attachment.bin>
More information about the Openmp-commits
mailing list