Skip to content
3 changes: 2 additions & 1 deletion llvm/include/llvm/Frontend/OpenMP/OMPDeviceConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ enum OMPTgtExecModeFlags : unsigned char {
OMP_TGT_EXEC_MODE_GENERIC = 1 << 0,
OMP_TGT_EXEC_MODE_SPMD = 1 << 1,
OMP_TGT_EXEC_MODE_GENERIC_SPMD =
OMP_TGT_EXEC_MODE_GENERIC | OMP_TGT_EXEC_MODE_SPMD
OMP_TGT_EXEC_MODE_GENERIC | OMP_TGT_EXEC_MODE_SPMD,
OMP_TGT_EXEC_MODE_SPMD_NO_LOOP = 1 << 2 | OMP_TGT_EXEC_MODE_SPMD
};

} // end namespace omp
Expand Down
3 changes: 2 additions & 1 deletion offload/DeviceRTL/src/Kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ enum OMPTgtExecModeFlags : unsigned char {
OMP_TGT_EXEC_MODE_GENERIC = 1 << 0,
OMP_TGT_EXEC_MODE_SPMD = 1 << 1,
OMP_TGT_EXEC_MODE_GENERIC_SPMD =
OMP_TGT_EXEC_MODE_GENERIC | OMP_TGT_EXEC_MODE_SPMD
OMP_TGT_EXEC_MODE_GENERIC | OMP_TGT_EXEC_MODE_SPMD,
OMP_TGT_EXEC_MODE_SPMD_NO_LOOP = 1 << 2 | OMP_TGT_EXEC_MODE_SPMD
};

static void
Expand Down
9 changes: 8 additions & 1 deletion offload/plugins-nextgen/common/include/PluginInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ struct GenericKernelTy {
return "Generic";
case OMP_TGT_EXEC_MODE_GENERIC_SPMD:
return "Generic-SPMD";
case OMP_TGT_EXEC_MODE_SPMD_NO_LOOP:
return "SPMD-No-Loop";
}
llvm_unreachable("Unknown execution mode!");
}
Expand Down Expand Up @@ -471,7 +473,8 @@ struct GenericKernelTy {
uint32_t BlockLimitClause[3], uint64_t LoopTripCount,
uint32_t &NumThreads, bool IsNumThreadsFromUser) const;

/// Indicate if the kernel works in Generic SPMD, Generic or SPMD mode.
/// Indicate if the kernel works in Generic SPMD, Generic, No-Loop
/// or SPMD mode.
bool isGenericSPMDMode() const {
return KernelEnvironment.Configuration.ExecMode ==
OMP_TGT_EXEC_MODE_GENERIC_SPMD;
Expand All @@ -486,6 +489,10 @@ struct GenericKernelTy {
bool isBareMode() const {
return KernelEnvironment.Configuration.ExecMode == OMP_TGT_EXEC_MODE_BARE;
}
bool isNoLoopMode() const {
return KernelEnvironment.Configuration.ExecMode ==
OMP_TGT_EXEC_MODE_SPMD_NO_LOOP;
}

/// The kernel name.
std::string Name;
Expand Down
4 changes: 4 additions & 0 deletions offload/plugins-nextgen/common/src/PluginInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,10 @@ uint32_t GenericKernelTy::getNumBlocks(GenericDeviceTy &GenericDevice,
return std::min(NumTeamsClause[0], GenericDevice.getBlockLimit());
}

// Return the number of teams required to cover the loop iterations.
if (isNoLoopMode())
return LoopTripCount > 0 ? (((LoopTripCount - 1) / NumThreads) + 1) : 1;

uint64_t DefaultNumBlocks = GenericDevice.getDefaultNumBlocks();
uint64_t TripCountNumBlocks = std::numeric_limits<uint64_t>::max();
if (LoopTripCount > 0) {
Expand Down