Skip to content

Commit e323313

Browse files
authored
[OpenMP][Offload][AMDGPU] Add support for GPU-specific envar indexing (llvm#1621)
2 parents c2d4f43 + 73d868f commit e323313

File tree

1 file changed

+40
-1
lines changed
  • offload/plugins-nextgen/amdgpu/src

1 file changed

+40
-1
lines changed

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

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3022,7 +3022,14 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
30223022
OMPX_EnableDevice2DeviceMemAccess(
30233023
"OMPX_ENABLE_DEVICE_TO_DEVICE_MEM_ACCESS", false),
30243024
AMDGPUStreamManager(*this, Agent), AMDGPUEventManager(*this),
3025-
AMDGPUSignalManager(*this), Agent(Agent), HostDevice(HostDevice) {}
3025+
AMDGPUSignalManager(*this), Agent(Agent), HostDevice(HostDevice) {
3026+
// Get config for envars.
3027+
const DeviceEnvarConfigTy &EnvarConfig = getEnvarConfig();
3028+
// Check each envar if it was set by user.
3029+
if (!OMPX_UseMultipleSdmaEngines.isPresent()) {
3030+
OMPX_UseMultipleSdmaEngines = EnvarConfig.OMPX_UseMultipleSdmaEngines;
3031+
}
3032+
}
30263033

30273034
~AMDGPUDeviceTy() {}
30283035

@@ -4713,6 +4720,38 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
47134720
/// True if in multi-device mode.
47144721
bool IsMultiDeviceEnabled = false;
47154722

4723+
/// Representing all the runtime envar configs for a device.
4724+
struct DeviceEnvarConfigTy {
4725+
bool
4726+
OMPX_UseMultipleSdmaEngines; // LIBOMPTARGET_AMDGPU_USE_MULTIPLE_SDMA_ENGINES
4727+
};
4728+
4729+
static inline const std::unordered_map<std::string, DeviceEnvarConfigTy>
4730+
EnvarConfigs = {{"MI210", {.OMPX_UseMultipleSdmaEngines = true}},
4731+
{"MI300A", {.OMPX_UseMultipleSdmaEngines = false}},
4732+
{"MI300X", {.OMPX_UseMultipleSdmaEngines = true}},
4733+
// Default config for unknown devices.
4734+
{"DEFAULT", {.OMPX_UseMultipleSdmaEngines = true}}};
4735+
4736+
const DeviceEnvarConfigTy &getEnvarConfig() const {
4737+
std::string DeviceMarketingName = getNormMarketingName();
4738+
auto It = EnvarConfigs.find(DeviceMarketingName);
4739+
4740+
if (DeviceMarketingName == "UNKNOWN" || It == EnvarConfigs.end()) {
4741+
// Return default config
4742+
DP("Default envar config is used.\n");
4743+
auto DefaultIt = EnvarConfigs.find("DEFAULT");
4744+
4745+
assert(DefaultIt != EnvarConfigs.end() &&
4746+
"Default envar config not found!\n");
4747+
return DefaultIt->second;
4748+
}
4749+
4750+
DP("Envar config for %s is used.\n", DeviceMarketingName.c_str());
4751+
4752+
return It->second;
4753+
}
4754+
47164755
public:
47174756
/// Return if it is an MI300 series device.
47184757
bool checkIfMI300Device() {

0 commit comments

Comments
 (0)