From 0813f41005fddac8cc41b42fa5e918d9b049c60c Mon Sep 17 00:00:00 2001 From: JonChesterfield Date: Tue, 24 Mar 2020 18:51:36 +0000 Subject: [PATCH] [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 --- openmp/libomptarget/deviceRTLs/common/src/reduction.cu | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openmp/libomptarget/deviceRTLs/common/src/reduction.cu b/openmp/libomptarget/deviceRTLs/common/src/reduction.cu index 7f6ee2e39c7d..427c90a7e091 100644 --- a/openmp/libomptarget/deviceRTLs/common/src/reduction.cu +++ b/openmp/libomptarget/deviceRTLs/common/src/reduction.cu @@ -230,7 +230,7 @@ static int32_t nvptx_teams_reduce_nowait(int32_t global_tid, int32_t num_vars, : /*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 @@ EXTERN int32_t __kmpc_nvptx_teams_reduce_nowait_v2( : /*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