SWDEV-353281 - Change pool type for graphs
Under ROCr physical allocations don't have initial VA and require extra flag in ROCclr. Add an option to have a mempool of physical allocations. Change-Id: I4d062fe0dd8113d4eaf6e8b51749ed56d8701d1e
Dieser Commit ist enthalten in:
committet von
Julia Jiang
Ursprung
51926b6b6b
Commit
f296159f62
@@ -57,7 +57,7 @@ bool Device::Create() {
|
||||
}
|
||||
|
||||
// Create graph memory pool
|
||||
graph_mem_pool_ = new MemoryPool(this);
|
||||
graph_mem_pool_ = new MemoryPool(this, nullptr, true);
|
||||
if (graph_mem_pool_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1071,7 +1071,7 @@ class GraphKernelNode : public GraphNode {
|
||||
|
||||
hipError_t SetAttrParams(hipKernelNodeAttrID attr, const hipKernelNodeAttrValue* params) {
|
||||
hipDeviceProp_t prop = {0};
|
||||
hipError_t status = ihipGetDeviceProperties(&prop, ihipGetDevice());
|
||||
hipError_t status = ihipGetDeviceProperties(&prop, ihipGetDevice());
|
||||
if (hipSuccess != status){
|
||||
return status;
|
||||
}
|
||||
@@ -2106,9 +2106,10 @@ class GraphMemAllocNode final : public GraphNode {
|
||||
size_ = aligned_size;
|
||||
// Execute the original mapping command
|
||||
VirtualMapCommand::submit(device);
|
||||
queue()->device().SetMemAccess(va_->getSvmPtr(), aligned_size, amd::Device::VmmAccess::kReadWrite);
|
||||
va_->retain();
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_MEM_POOL, "Graph MemAlloc execute: %p, %p",
|
||||
va_->getSvmPtr(), memory());
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_MEM_POOL, "Graph MemAlloc execute [%p-%p], %p",
|
||||
va_->getSvmPtr(), reinterpret_cast<char*>(va_->getSvmPtr()) + aligned_size, memory());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -180,6 +180,7 @@ void* MemoryPool::AllocateMemory(size_t size, Stream* stream, void* dptr) {
|
||||
return nullptr;
|
||||
}
|
||||
cl_svm_mem_flags flags = (state_.interprocess_) ? ROCCLR_MEM_INTERPROCESS : 0;
|
||||
flags |= (state_.phys_mem_) ? ROCCLR_MEM_PHYMEM : 0;
|
||||
dev_ptr = amd::SvmBuffer::malloc(*context, flags, size, dev_info.memBaseAddrAlign_, nullptr);
|
||||
if (dev_ptr == nullptr) {
|
||||
size_t free = 0, total =0;
|
||||
@@ -291,7 +292,7 @@ bool MemoryPool::FreeMemory(amd::Memory* memory, Stream* stream, Event* event) {
|
||||
|
||||
// Decrement the reference counter on the pool.
|
||||
// Note: It may delete memory pool for the last allocation. Thus, the scope lock can't include
|
||||
// this call.
|
||||
// this call.
|
||||
release();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -196,7 +196,7 @@ class MemoryPool : public amd::ReferenceCountedObject {
|
||||
SharedAccess access_[kMaxMgpuAccess]; //!< The list of devices for access
|
||||
};
|
||||
|
||||
MemoryPool(hip::Device* device, const hipMemPoolProps* props = nullptr)
|
||||
MemoryPool(hip::Device* device, const hipMemPoolProps* props = nullptr, bool phys_mem = false)
|
||||
: busy_heap_(device),
|
||||
free_heap_(device),
|
||||
lock_pool_ops_("Pool operations", true),
|
||||
@@ -208,6 +208,7 @@ class MemoryPool : public amd::ReferenceCountedObject {
|
||||
state_.event_dependencies_ = 1;
|
||||
state_.opportunistic_ = 1;
|
||||
state_.internal_dependencies_ = 1;
|
||||
state_.phys_mem_ = HIP_MEM_POOL_USE_VM && phys_mem;
|
||||
if (props != nullptr) {
|
||||
properties_ = *props;
|
||||
} else {
|
||||
@@ -317,6 +318,7 @@ class MemoryPool : public amd::ReferenceCountedObject {
|
||||
//!< dependencies
|
||||
uint32_t interprocess_ : 1; //!< Memory pool can be used in interprocess communications
|
||||
uint32_t graph_in_use_ : 1; //!< Memory pool was used in a graph execution
|
||||
uint32_t phys_mem_ : 1; //!< Mempool is used for graphs and will have physical allocations
|
||||
};
|
||||
uint32_t value_;
|
||||
} state_;
|
||||
|
||||
@@ -2615,6 +2615,9 @@ void VirtualGPU::submitVirtualMap(amd::VirtualMapCommand& vcmd) {
|
||||
LogError("HSA Command: hsa_amd_vmem_map failed!");
|
||||
}
|
||||
} else {
|
||||
dispatchBarrierPacket(kBarrierPacketHeader, false);
|
||||
Barriers().WaitCurrent();
|
||||
|
||||
// Unmap the object, since the physical addr is set.
|
||||
if ((hsa_status = hsa_amd_vmem_unmap(vaddr_mem_obj->getSvmPtr(), vcmd.size()))
|
||||
== HSA_STATUS_SUCCESS) {
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren