@@ -2924,6 +2924,8 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
2924
2924
OMPX_ApuMaps (" OMPX_APU_MAPS" , false ),
2925
2925
OMPX_EnableGFX90ACoarseGrainUsmMaps (
2926
2926
" OMPX_ENABLE_GFX90A_COARSE_GRAIN_USM_MAPS" , false ),
2927
+ OMPX_EnableGFX90ACoarseGrainSharedAlloc (
2928
+ " OMPX_ENABLE_GFX90A_COARSE_GRAIN_SHARED_ALLOC" , false ),
2927
2929
OMPX_StrictSanityChecks (" OMPX_STRICT_SANITY_CHECKS" , false ),
2928
2930
OMPX_SyncCopyBack (" LIBOMPTARGET_SYNC_COPY_BACK" , true ),
2929
2931
OMPX_APUPrefaultMemcopy (" LIBOMPTARGET_APU_PREFAULT_MEMCOPY" , " true" ),
@@ -4339,6 +4341,8 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
4339
4341
// / - Coarse graining upon USM map on MI200 needs to be enabled.
4340
4342
void specialBehaviorHandling () {
4341
4343
EnableGFX90ACoarseGrainUsmMaps = OMPX_EnableGFX90ACoarseGrainUsmMaps;
4344
+ EnableGFX90ACoarseGrainSharedAlloc =
4345
+ OMPX_EnableGFX90ACoarseGrainSharedAlloc;
4342
4346
}
4343
4347
4344
4348
bool IsGfx90aCoarseGrainUsmMapEnabledImpl () override final {
@@ -4460,6 +4464,12 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
4460
4464
// / OMPX_DISABLE_USM_MAPS
4461
4465
BoolEnvar OMPX_EnableGFX90ACoarseGrainUsmMaps;
4462
4466
4467
+ // / Value of OMPX_ENABLE_GFX90A_COARSE_GRAIN_SHARED_ALLOC.
4468
+ // / Use on MI200 systems to enable coarse grain
4469
+ // / allocation of TARGET_ALLOC_SHARED memory.
4470
+ // / Default is fine grain allocation.
4471
+ BoolEnvar OMPX_EnableGFX90ACoarseGrainSharedAlloc;
4472
+
4463
4473
// / Makes warnings turn into fatal errors
4464
4474
BoolEnvar OMPX_StrictSanityChecks;
4465
4475
@@ -4549,6 +4559,10 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
4549
4559
// residing on the page goes through implicit/explicit OpenMP map.
4550
4560
bool EnableGFX90ACoarseGrainUsmMaps = false ;
4551
4561
4562
+ // Set by OMPX_ENABLE_GFX90A_COARSE_GRAIN_SHARED_ALLOC environment variable.
4563
+ // If set, TARGET_ALLOC_SHARED is allocated on coarse grain memory on MI200
4564
+ bool EnableGFX90ACoarseGrainSharedAlloc = false ;
4565
+
4552
4566
// / True if in multi-device mode.
4553
4567
bool IsMultiDeviceEnabled = false ;
4554
4568
@@ -5246,6 +5260,11 @@ void *AMDGPUDeviceTy::allocate(size_t Size, void *, TargetAllocTy Kind) {
5246
5260
break ;
5247
5261
}
5248
5262
5263
+ if (Kind == TARGET_ALLOC_SHARED && IsEquippedWithGFX90A &&
5264
+ EnableGFX90ACoarseGrainSharedAlloc) {
5265
+ MemoryPool = CoarseGrainedMemoryPools[0 ];
5266
+ }
5267
+
5249
5268
if (!MemoryPool) {
5250
5269
REPORT (" No memory pool for the specified allocation kind\n " );
5251
5270
return nullptr ;
0 commit comments