@@ -2680,6 +2680,8 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
2680
2680
OMPX_ApuMaps (" OMPX_APU_MAPS" , false ),
2681
2681
OMPX_EnableGFX90ACoarseGrainUsmMaps (
2682
2682
" OMPX_ENABLE_GFX90A_COARSE_GRAIN_USM_MAPS" , false ),
2683
+ OMPX_EnableGFX90ACoarseGrainSharedAlloc (
2684
+ " OMPX_ENABLE_GFX90A_COARSE_GRAIN_SHARED_ALLOC" , false ),
2683
2685
OMPX_StrictSanityChecks (" OMPX_STRICT_SANITY_CHECKS" , false ),
2684
2686
OMPX_SyncCopyBack (" LIBOMPTARGET_SYNC_COPY_BACK" , true ),
2685
2687
OMPX_APUPrefaultMemcopy (" LIBOMPTARGET_APU_PREFAULT_MEMCOPY" , " true" ),
@@ -4093,6 +4095,8 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
4093
4095
// / - Coarse graining upon USM map on MI200 needs to be enabled.
4094
4096
void specialBehaviorHandling () {
4095
4097
EnableGFX90ACoarseGrainUsmMaps = OMPX_EnableGFX90ACoarseGrainUsmMaps;
4098
+ EnableGFX90ACoarseGrainSharedAlloc =
4099
+ OMPX_EnableGFX90ACoarseGrainSharedAlloc;
4096
4100
}
4097
4101
4098
4102
bool IsGfx90aCoarseGrainUsmMapEnabledImpl () override final {
@@ -4210,6 +4214,12 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
4210
4214
// / OMPX_DISABLE_USM_MAPS
4211
4215
BoolEnvar OMPX_EnableGFX90ACoarseGrainUsmMaps;
4212
4216
4217
+ // / Value of OMPX_ENABLE_GFX90A_COARSE_GRAIN_SHARED_ALLOC.
4218
+ // / Use on MI200 systems to enable coarse grain
4219
+ // / allocation of TARGET_ALLOC_SHARED memory.
4220
+ // / Default is fine grain allocation.
4221
+ BoolEnvar OMPX_EnableGFX90ACoarseGrainSharedAlloc;
4222
+
4213
4223
// / Makes warnings turn into fatal errors
4214
4224
BoolEnvar OMPX_StrictSanityChecks;
4215
4225
@@ -4295,6 +4305,10 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
4295
4305
// residing on the page goes through implicit/explicit OpenMP map.
4296
4306
bool EnableGFX90ACoarseGrainUsmMaps = false ;
4297
4307
4308
+ // Set by OMPX_ENABLE_GFX90A_COARSE_GRAIN_SHARED_ALLOC environment variable.
4309
+ // If set, TARGET_ALLOC_SHARED is allocated on coarse grain memory on MI200
4310
+ bool EnableGFX90ACoarseGrainSharedAlloc = false ;
4311
+
4298
4312
// / True if in multi-device mode.
4299
4313
bool IsMultiDeviceEnabled = false ;
4300
4314
@@ -4954,6 +4968,11 @@ void *AMDGPUDeviceTy::allocate(size_t Size, void *, TargetAllocTy Kind) {
4954
4968
break ;
4955
4969
}
4956
4970
4971
+ if (Kind == TARGET_ALLOC_SHARED && IsEquippedWithGFX90A &&
4972
+ EnableGFX90ACoarseGrainSharedAlloc) {
4973
+ MemoryPool = CoarseGrainedMemoryPools[0 ];
4974
+ }
4975
+
4957
4976
if (!MemoryPool) {
4958
4977
REPORT (" No memory pool for the specified allocation kind\n " );
4959
4978
return nullptr ;
0 commit comments