[Openmp-commits] [openmp] 20ec416 - [Libomptarget] Add branch prediction intrinsic to state check

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Fri May 20 12:39:39 PDT 2022


Author: Joseph Huber
Date: 2022-05-20T15:38:54-04:00
New Revision: 20ec4161d7c9e146c844fadf5af2a44afb9e7a60

URL: https://github.com/llvm/llvm-project/commit/20ec4161d7c9e146c844fadf5af2a44afb9e7a60
DIFF: https://github.com/llvm/llvm-project/commit/20ec4161d7c9e146c844fadf5af2a44afb9e7a60.diff

LOG: [Libomptarget] Add branch prediction intrinsic to state check

Summary:
We usually used the `OMP_LIKELY` and `OMP_UNLIKELY` macros to add branch
prediction intrinsics to help the optimizer ignore unlikely loops. This
wasn't applied to this one loop so add that in.

Added: 
    

Modified: 
    openmp/libomptarget/DeviceRTL/src/State.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/src/State.cpp b/openmp/libomptarget/DeviceRTL/src/State.cpp
index f299aa0a4a27f..c8910635278ff 100644
--- a/openmp/libomptarget/DeviceRTL/src/State.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/State.cpp
@@ -289,7 +289,7 @@ uint32_t &lookupForModify32Impl(uint32_t ICVStateTy::*Var, IdentTy *Ident) {
                  TeamState.ICVState.LevelVar == 0))
     return TeamState.ICVState.*Var;
   uint32_t TId = mapping::getThreadIdInBlock();
-  if (!ThreadStates[TId]) {
+  if (OMP_UNLIKELY(!ThreadStates[TId])) {
     ThreadStates[TId] = reinterpret_cast<ThreadStateTy *>(memory::allocGlobal(
         sizeof(ThreadStateTy), "ICV modification outside data environment"));
     ASSERT(ThreadStates[TId] != nullptr && "Nullptr returned by malloc!");


        


More information about the Openmp-commits mailing list