@@ -3022,7 +3022,14 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
3022
3022
OMPX_EnableDevice2DeviceMemAccess (
3023
3023
" OMPX_ENABLE_DEVICE_TO_DEVICE_MEM_ACCESS" , false ),
3024
3024
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
+ }
3026
3033
3027
3034
~AMDGPUDeviceTy () {}
3028
3035
@@ -4713,6 +4720,38 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
4713
4720
// / True if in multi-device mode.
4714
4721
bool IsMultiDeviceEnabled = false ;
4715
4722
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
+
4716
4755
public:
4717
4756
// / Return if it is an MI300 series device.
4718
4757
bool checkIfMI300Device () {
0 commit comments