@@ -2035,7 +2035,7 @@ hsa_amd_memory_pool_t Device::getHostMemoryPool(MemorySegment mem_seg,
20352035
20362036// ================================================================================================
20372037void * Device::hostAlloc (size_t size, size_t alignment, MemorySegment mem_seg,
2038- const void * agentInfo, bool allowAccess ) const {
2038+ const void * agentInfo, bool allowAllAgentsAccess ) const {
20392039 void * ptr = nullptr ;
20402040 uint32_t memFlags = 0 ;
20412041 if (mem_seg == kKernArg ) {
@@ -2055,17 +2055,13 @@ void* Device::hostAlloc(size_t size, size_t alignment, MemorySegment mem_seg,
20552055 return nullptr ;
20562056 }
20572057
2058- if (allowAccess) {
2058+ // Allow access to all GPU agents if the flag is set
2059+ // otherwise only allow access to the local backend device.
2060+ if (allowAllAgentsAccess) {
20592061 stat = Hsa::agents_allow_access (gpu_agents_.size (), &gpu_agents_[0 ], nullptr , ptr);
2060- } else {
2061- hsa_amd_memory_pool_access_t access;
2062- stat = Hsa::agent_memory_pool_get_info (bkendDevice_, pool,
2063- HSA_AMD_AGENT_MEMORY_POOL_INFO_ACCESS, &access);
2064-
2065- if ((stat == HSA_STATUS_SUCCESS) && (access == HSA_AMD_MEMORY_POOL_ACCESS_DISALLOWED_BY_DEFAULT))
2066- {
2067- stat = Hsa::agents_allow_access (1 , &bkendDevice_, nullptr , ptr);
2068- }
2062+ }
2063+ else {
2064+ stat = Hsa::agents_allow_access (1 , &bkendDevice_, nullptr , ptr);
20692065 }
20702066
20712067 if (stat != HSA_STATUS_SUCCESS) {
@@ -2200,7 +2196,7 @@ void Device::releaseMemory(void* ptr, size_t size) const {
22002196 }
22012197}
22022198
2203- void * Device::deviceLocalAlloc (size_t size, const AllocationFlags& flags, bool allowAccess ) const {
2199+ void * Device::deviceLocalAlloc (size_t size, const AllocationFlags& flags, bool allowAllAgentsAccess ) const {
22042200 const hsa_amd_memory_pool_t & pool =
22052201 (flags.pseudo_fine_grain_ && gpu_ext_fine_grained_segment_.handle )
22062202 ? gpu_ext_fine_grained_segment_
@@ -2235,7 +2231,7 @@ void* Device::deviceLocalAlloc(size_t size, const AllocationFlags& flags, bool a
22352231 return nullptr ;
22362232 }
22372233
2238- if (allowAccess ) {
2234+ if (allowAllAgentsAccess ) {
22392235 if (isP2pEnabled () && deviceAllowAccess (ptr) == false ) {
22402236 LogError (" Allow p2p access for memory allocation" );
22412237 memFree (ptr, size);
0 commit comments