P4 to Git Change 1562965 by skudchad@skudchad_test2_win_opencl on 2018/06/01 14:48:31

SWDEV-145570 - [HIP] - Implement hipHostRegister/Unregister, hipHostAlloc.

	ReviewBoardURL = http://ocltc.amd.com/reviews/r/15041/diff/

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/hip/hip_internal.hpp#12 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_memory.cpp#30 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_texture.cpp#8 edit


[ROCm/clr commit: 2c4c7ab564]
This commit is contained in:
foreman
2018-06-01 15:01:45 -04:00
parent 0f8c914c5f
commit 24ec56cba1
3 changed files with 41 additions and 12 deletions
+34 -6
View File
@@ -37,7 +37,7 @@ extern void getDrvChannelOrderAndType(const enum hipArray_Format Format,
cl_channel_type* channelType);
inline amd::Memory* getMemoryObject(const void* ptr, size_t& offset) {
amd::Memory *memObj = amd::SvmManager::FindSvmBuffer(ptr);
amd::Memory *memObj = amd::MemObjMap::FindMemObj(ptr);
if (memObj != nullptr) {
offset = reinterpret_cast<size_t>(ptr) - reinterpret_cast<size_t>(memObj->getSvmPtr());
}
@@ -500,20 +500,48 @@ hipError_t hipHostGetFlags(unsigned int* flagsPtr, void* hostPtr) {
hipError_t hipHostRegister(void* hostPtr, size_t sizeBytes, unsigned int flags) {
HIP_INIT_API(hostPtr, sizeBytes, flags);
if(hostPtr != nullptr) {
amd::Context *amdContext = hip::getCurrentContext();
amd::Memory* mem = new (*amdContext) amd::Buffer(*amdContext, CL_MEM_USE_HOST_PTR, sizeBytes);
assert(0 && "Unimplemented");
return hipErrorUnknown;
if (!mem->create(hostPtr)) {
mem->release();
return hipErrorMemoryAllocation;
}
amd::MemObjMap::AddMemObj(hostPtr, mem);
return hipSuccess;
} else {
return ihipMalloc(&hostPtr, sizeBytes, flags);
}
}
hipError_t hipHostUnregister(void* hostPtr) {
HIP_INIT_API(hostPtr);
assert(0 && "Unimplemented");
if (amd::SvmBuffer::malloced(hostPtr)) {
hip::syncStreams();
hip::getNullStream()->finish();
amd::SvmBuffer::free(*hip::getCurrentContext(), hostPtr);
return hipSuccess;
} else {
size_t offset = 0;
amd::Memory* mem = getMemoryObject(hostPtr, offset);
return hipErrorUnknown;
if(mem) {
mem->release();
return hipSuccess;
}
}
return hipErrorInvalidValue;
}
// Deprecated function:
hipError_t hipHostAlloc(void** ptr, size_t sizeBytes, unsigned int flags) {
return ihipMalloc(ptr, sizeBytes, flags);
};
hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src, size_t count,
size_t offset, hipMemcpyKind kind) {
HIP_INIT_API(symbolName, src, count, offset, kind);