summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2018-11-27 21:06:09 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2018-11-27 21:06:09 +0000
commitd4de439cf45ac3c0093ef2ec3bfe83cca8f0eaaa (patch)
tree5a57a4eb8ec1472004eabbcdebbdeaa958631005
parent00eae5ea315dce8f34ece5e1e96d43d09fb1400e (diff)
downloadbcm5719-llvm-d4de439cf45ac3c0093ef2ec3bfe83cca8f0eaaa.tar.gz
bcm5719-llvm-d4de439cf45ac3c0093ef2ec3bfe83cca8f0eaaa.zip
[OPENMP][NVPTX]Basic support for reductions across the teams.
Summary: Added functions __kmpc_nvptx_teams_reduce_nowait_simple and __kmpc_nvptx_teams_end_reduce_nowait_simple to implement basic support for reductions across the teams. Reviewers: gtbercea, kkwli0 Subscribers: guansong, jfb, caomhin, openmp-commits Differential Revision: https://reviews.llvm.org/D54967 llvm-svn: 347710
-rw-r--r--openmp/libomptarget/deviceRTLs/nvptx/src/interface.h6
-rw-r--r--openmp/libomptarget/deviceRTLs/nvptx/src/reduction.cu18
2 files changed, 24 insertions, 0 deletions
diff --git a/openmp/libomptarget/deviceRTLs/nvptx/src/interface.h b/openmp/libomptarget/deviceRTLs/nvptx/src/interface.h
index 4414ea43b99..40321a624cd 100644
--- a/openmp/libomptarget/deviceRTLs/nvptx/src/interface.h
+++ b/openmp/libomptarget/deviceRTLs/nvptx/src/interface.h
@@ -419,6 +419,12 @@ EXTERN int32_t __kmpc_nvptx_teams_reduce_nowait_simple_generic(
int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data,
kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct,
kmp_CopyToScratchpadFctPtr sratchFct, kmp_LoadReduceFctPtr ldFct);
+EXTERN int32_t __kmpc_nvptx_teams_reduce_nowait_simple(kmp_Ident *loc,
+ int32_t global_tid,
+ kmp_CriticalName *crit);
+EXTERN void __kmpc_nvptx_teams_end_reduce_nowait_simple(kmp_Ident *loc,
+ int32_t global_tid,
+ kmp_CriticalName *crit);
EXTERN int32_t __kmpc_shuffle_int32(int32_t val, int16_t delta, int16_t size);
EXTERN int64_t __kmpc_shuffle_int64(int64_t val, int16_t delta, int16_t size);
diff --git a/openmp/libomptarget/deviceRTLs/nvptx/src/reduction.cu b/openmp/libomptarget/deviceRTLs/nvptx/src/reduction.cu
index 2a2edcef03d..aaa95c77cb5 100644
--- a/openmp/libomptarget/deviceRTLs/nvptx/src/reduction.cu
+++ b/openmp/libomptarget/deviceRTLs/nvptx/src/reduction.cu
@@ -430,3 +430,21 @@ int32_t __kmpc_nvptx_teams_reduce_nowait_simple_generic(
/*isSPMDExecutionMode=*/false,
/*isRuntimeUninitialized=*/true);
}
+
+EXTERN int32_t __kmpc_nvptx_teams_reduce_nowait_simple(kmp_Ident *loc,
+ int32_t global_tid,
+ kmp_CriticalName *crit) {
+ if (checkSPMDMode(loc) && GetThreadIdInBlock() != 0)
+ return 0;
+ // The master thread of the team actually does the reduction.
+ while (atomicCAS((uint32_t *)crit, 0, 1))
+ ;
+ return 1;
+}
+
+EXTERN void
+__kmpc_nvptx_teams_end_reduce_nowait_simple(kmp_Ident *loc, int32_t global_tid,
+ kmp_CriticalName *crit) {
+ (void)atomicExch((uint32_t *)crit, 0);
+}
+
OpenPOWER on IntegriCloud