P4 to Git Change 1736033 by kjayapra@9_HIPWS_IPCCHKIN on 2019/01/25 17:44:48

SWDEV-145570 - IPC Mem Handle Changes for HIP.

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/hip/hip_internal.hpp#20 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_memory.cpp#43 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#330 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#112 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#33 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.cpp#42 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.hpp#13 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.hpp#108 edit
이 커밋은 다음에 포함됨:
foreman
2019-01-25 19:18:53 -05:00
부모 eb76a4fb09
커밋 a17f3e34dc
6개의 변경된 파일102개의 추가작업 그리고 0개의 파일을 삭제
+13
파일 보기
@@ -728,6 +728,10 @@ class Memory : public amd::HeapObject {
virtual uint64_t virtualAddress() const { return 0; }
virtual void IpcCreate(size_t offset, size_t* mem_size, void* handle) const {
ShouldNotReachHere();
}
protected:
enum Flags {
HostMemoryDirectAccess = 0x00000001, //!< GPU has direct access to the host memory
@@ -1318,6 +1322,15 @@ class Device : public RuntimeObject {
//! Checks if OCL runtime can use code object manager for compilation
bool ValidateComgr();
virtual amd::Memory *IpcAttach(const void* handle, size_t mem_size, unsigned int flags, void** dev_ptr) const {
ShouldNotReachHere();
return nullptr;
}
virtual void IpcDetach(amd::Memory& memory) const {
ShouldNotReachHere();
}
protected:
//! Enable the specified extension
char* getExtensionString();
+53
파일 보기
@@ -1570,6 +1570,59 @@ void Device::updateFreeMemory(size_t size, bool free) {
}
}
amd::Memory *Device::IpcAttach(const void* handle, size_t mem_size, unsigned int flags, void** dev_ptr) const {
amd::Memory* amd_mem_obj = nullptr;
hsa_status_t hsa_status = HSA_STATUS_SUCCESS;
/* Retrieve the devPtr from the handle */
hsa_agent_t hsa_agent = getBackendDevice();
hsa_status
= hsa_amd_ipc_memory_attach(reinterpret_cast<const hsa_amd_ipc_memory_t*>(handle),
mem_size, 1, &hsa_agent, dev_ptr);
if (hsa_status != HSA_STATUS_SUCCESS) {
LogError("[OCL] HSA failed to attach IPC memory");
return nullptr;
}
/* Create an amd Memory object for the pointer */
amd_mem_obj = new (context()) amd::Buffer(context(), flags, mem_size, *dev_ptr);
if (amd_mem_obj == nullptr) {
LogError("[OCL] failed to create a mem object!");
return nullptr;
}
if (!amd_mem_obj->create(nullptr)) {
LogError("[OCL] failed to create a svm hidden buffer!");
amd_mem_obj->release();
return nullptr;
}
return amd_mem_obj;
}
void Device::IpcDetach (amd::Memory& memory) const {
void* dev_ptr = nullptr;
hsa_status_t hsa_status = HSA_STATUS_SUCCESS;
if(memory.getSvmPtr() != nullptr) {
dev_ptr = memory.getSvmPtr();
} else if (memory.getHostMem() != nullptr) {
dev_ptr = memory.getHostMem();
} else {
ShouldNotReachHere();
}
/*Detach the memory from HSA */
hsa_status = hsa_amd_ipc_memory_detach(dev_ptr);
if (hsa_status != HSA_STATUS_SUCCESS) {
LogError("[OCL] HSA failed to detach memory !");
return;
}
memory.release();
}
void* Device::svmAlloc(amd::Context& context, size_t size, size_t alignment, cl_svm_mem_flags flags,
void* svmPtr) const {
amd::Memory* mem = nullptr;
+3
파일 보기
@@ -381,6 +381,9 @@ class Device : public NullDevice {
// Update the global free memory size
void updateFreeMemory(size_t size, bool free);
virtual amd::Memory* IpcAttach(const void* handle, size_t mem_size, unsigned int flags, void** dev_ptr) const;
virtual void IpcDetach (amd::Memory& memory) const;
private:
static hsa_ven_amd_loader_1_00_pfn_t amd_loader_ext_table;
+27
파일 보기
@@ -171,6 +171,33 @@ void* Memory::cpuMap(device::VirtualDevice& vDev, uint flags, uint startLayer, u
return mapTarget;
}
void Memory::IpcCreate(size_t offset, size_t* mem_size, void* handle) const {
void* dev_ptr = nullptr;
hsa_status_t hsa_status = HSA_STATUS_SUCCESS;
/* Get the memory size from starting pointer */
*mem_size = owner()->getSize() - offset;
/* Get the starting pointer from the amd::Memory object */
if (owner()->getSvmPtr() != nullptr) {
dev_ptr = reinterpret_cast<address>(owner()->getSvmPtr()) + offset;
} else if (owner()->getHostMem() != nullptr) {
dev_ptr = reinterpret_cast<address>(owner()->getHostMem()) + offset;
} else {
ShouldNotReachHere();
}
/* Pass the pointer and memory size to retrieve the handle */
hsa_status = hsa_amd_ipc_memory_create(dev_ptr, *mem_size,
reinterpret_cast<hsa_amd_ipc_memory_t*>(handle));
if (hsa_status != HSA_STATUS_SUCCESS) {
LogError("[OCL] Failed to create memory for IPC");
return;
}
}
void Memory::cpuUnmap(device::VirtualDevice& vDev) {
if (!isHostMemDirectAccess() && !IsPersistentDirectMap()) {
if (!vDev.blitMgr().writeBuffer(mapMemory_->getHostMem(), *this, amd::Coord3D(0),
+2
파일 보기
@@ -91,6 +91,8 @@ class Memory : public device::Memory {
void* PersistentHostPtr() const { return persistent_host_ptr_; }
virtual void IpcCreate (size_t offset, size_t* mem_size, void* handle) const;
protected:
bool allocateMapMemory(size_t allocationSize);
+4
파일 보기
@@ -253,6 +253,10 @@ class Memory : public amd::RuntimeObject {
bool forceCopy = false //!< Force system memory allocation
);
virtual void IpcCreate (size_t offset, size_t* mem_size, void* handle) const {
ShouldNotReachHere();
}
// Accessors
Memory* parent() const { return parent_; }
bool isParent() const { return isParent_; }