Skip to content

Commit aa94dfc

Browse files
committed
Add spmd constraint and address comments
1 parent feb4053 commit aa94dfc

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

offload/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,11 @@ struct AMDGPUKernelTy : public GenericKernelTy {
884884
/// Indicates whether or not we need to set up our own private segment size.
885885
bool usesDynamicStack() const { return DynamicStack; }
886886

887+
/// Get the execution mode of this kernel.
888+
OMPTgtExecModeFlags getExecutionMode() const {
889+
return getExecutionModeFlags();
890+
}
891+
887892
/// Envar to disable host-exec thread creation.
888893
BoolEnvar OMPX_DisableHostExec;
889894

@@ -2186,7 +2191,8 @@ struct AMDGPUStreamTy {
21862191

21872192
// If runtime autotuning is enabled, setup the callback functions to process
21882193
// the data after kernel completed.
2189-
if (Device.enableRuntimeAutotuning()) {
2194+
if (Device.enableRuntimeAutotuning() &&
2195+
Kernel.getExecutionMode() == OMP_TGT_EXEC_MODE_SPMD) {
21902196
std::string KernelName(Kernel.getName());
21912197
KernelRunRecord *KernelRecords = Device.getKernelRunRecords();
21922198

offload/plugins-nextgen/common/include/PluginInterface.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ struct KernelRunRecord {
13051305
uint32_t IdxThread = 0;
13061306
uint32_t IdxCUMultiplier = 0;
13071307
// Run counters.
1308-
uint32_t RunCounters;
1308+
uint32_t RunCounters = 0;
13091309
// Entry with minimum running time.
13101310
KernelRunEntry MinEntries;
13111311
};
@@ -1363,10 +1363,19 @@ struct KernelRunRecord {
13631363
}
13641364

13651365
bool reachedRunLimitForKernel(std::string KernelName) {
1366+
if (TuningData.count(KernelName) == 0) {
1367+
// If no record for this kernel.
1368+
return false;
1369+
}
1370+
13661371
return TuningData[KernelName].RunCounters > RunLimiter;
13671372
}
13681373

13691374
uint32_t getRunCounterForKernel(std::string KernelName) {
1375+
if (TuningData.count(KernelName) == 0) {
1376+
return 0;
1377+
}
1378+
13701379
return TuningData[KernelName].RunCounters;
13711380
}
13721381

offload/plugins-nextgen/common/src/PluginInterface.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,8 @@ Error GenericKernelTy::launch(GenericDeviceTy &GenericDevice, void **ArgPtrs,
734734
KernelRunCounter = KernelRecord->getRunCounterForKernel(KernelName);
735735
}
736736
// If Autotuning is enabled and the kernel is not launched for the first time.
737-
if (GenericDevice.enableRuntimeAutotuning() && KernelRunCounter > 0) {
737+
if (GenericDevice.enableRuntimeAutotuning() && isSPMDMode() &&
738+
KernelRunCounter > 0) {
738739
assert(KernelRecord &&
739740
"Autotuning is enabled, but KernelRunRecord is not initialized!");
740741

0 commit comments

Comments
 (0)