Skip to content

Commit c2f239c

Browse files
committed
change flag name to allowAllAgentsAccess, to be more accurate
1 parent 86b9090 commit c2f239c

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

projects/clr/rocclr/device/rocm/rocdevice.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,7 @@ hsa_amd_memory_pool_t Device::getHostMemoryPool(MemorySegment mem_seg,
20352035

20362036
// ================================================================================================
20372037
void* 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);

projects/clr/rocclr/device/rocm/rocdevice.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ class Device : public NullDevice {
429429
virtual bool globalFreeMemory(size_t* freeMemory) const override;
430430
virtual void* hostAlloc(size_t size, size_t alignment,
431431
MemorySegment mem_seg = MemorySegment::kNoAtomics,
432-
const void* agentInfo = nullptr, bool allowAccess = true) const override; // nullptr uses default CPU agent
432+
const void* agentInfo = nullptr, bool allowAllAgentsAccess = true) const override; // nullptr uses default CPU agent
433433
virtual void hostFree(void* ptr, size_t size = 0) const override;
434434

435435
virtual bool amdFileRead(amd::Os::FileDesc handle, void* devicePtr, uint64_t size, int64_t file_offset,
@@ -444,7 +444,7 @@ class Device : public NullDevice {
444444
uint64_t deviceVmemAlloc(size_t size, uint64_t flags) const;
445445

446446
void* deviceLocalAlloc(size_t size,
447-
const AllocationFlags& flags = AllocationFlags{}, bool allowAccess = true) const override;
447+
const AllocationFlags& flags = AllocationFlags{}, bool allowAllAgentsAccess = true) const override;
448448
void* reserveMemory(size_t size, size_t alignment) const;
449449
void releaseMemory(void* ptr, size_t size) const;
450450
void memFree(void* ptr, size_t size) const;

0 commit comments

Comments
 (0)