P4 to Git Change 1981324 by kjayapra@3_HIPWS_TXT_ROCM on 2019/08/11 18:44:40

SWDEV-188177 - Texture API implementation and support for extern variables.

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/hip/hip_hcc.def.in#18 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_hcc.map.in#20 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_internal.hpp#35 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_module.cpp#32 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_platform.cpp#37 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_texture.cpp#14 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#340 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.cpp#57 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.hpp#31 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#608 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.hpp#172 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#250 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.hpp#79 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#152 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.hpp#41 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.cpp#96 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.hpp#39 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#133 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#39 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#105 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.hpp#48 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/program.cpp#102 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/program.hpp#46 edit
This commit is contained in:
foreman
2019-08-11 18:53:11 -04:00
rodzic 3494344c4d
commit e51298aee1
6 zmienionych plików z 83 dodań i 8 usunięć
+1
Wyświetl plik
@@ -110,6 +110,7 @@ hipMemsetD8
hipMemset3D
hipModuleGetFunction
hipModuleGetGlobal
hipModuleGetTexRef
hipModuleLaunchKernel
hipModuleLaunchKernelExt
hipLaunchCooperativeKernel
+1
Wyświetl plik
@@ -111,6 +111,7 @@ global:
hipMemset3D;
hipModuleGetFunction;
hipModuleGetGlobal;
hipModuleGetTexRef;
hipModuleLaunchKernel;
hipModuleLaunchKernelExt;
hipLaunchCooperativeKernel;
+3
Wyświetl plik
@@ -135,7 +135,9 @@ public:
std::vector<hipFunction_t> functions;
};
struct DeviceVar {
void* shadowVptr;
std::string hostVar;
size_t size;
std::vector< std::pair< hipModule_t, bool > >* modules;
std::vector<RegisteredVar> rvars;
};
@@ -161,6 +163,7 @@ public:
bool getFuncAttr(const void* hostFunction, hipFuncAttributes* func_attr);
bool getGlobalVar(const void* hostVar, int deviceId, hipDeviceptr_t* dev_ptr,
size_t* size_ptr);
bool getShadowVarInfo(std::string var_name, void** var_addr, size_t* var_size);
void setupArgument(const void *arg, size_t size, size_t offset);
void configureCall(dim3 gridDim, dim3 blockDim, size_t sharedMem, hipStream_t stream);
+24 -2
Wyświetl plik
@@ -114,7 +114,7 @@ bool ihipModuleRegisterGlobal(amd::Program* program, hipModule_t* module) {
device::Program* dev_program
= program->getDeviceProgram(*hip::getCurrentContext()->devices()[0]);
if (!dev_program->getGlobalSymbolsFromCodeObj(&var_names)) {
if (!dev_program->getGlobalVarFromCodeObj(&var_names)) {
return false;
}
@@ -124,7 +124,7 @@ bool ihipModuleRegisterGlobal(amd::Program* program, hipModule_t* module) {
modules->at(dev) = std::make_pair(*module, false);
}
PlatformState::DeviceVar dvar{it->c_str(), modules,
PlatformState::DeviceVar dvar{nullptr, it->c_str(), 0, modules,
std::vector<PlatformState::RegisteredVar>{ g_devices.size()}};
PlatformState::instance().registerVar(it->c_str(), dvar);
}
@@ -417,3 +417,25 @@ hipError_t hipExtLaunchMultiKernelMultiDevice(hipLaunchParams* launchParamsList,
int numDevices, unsigned int flags) {
return ihipLaunchCooperativeKernelMultiDevice(launchParamsList, numDevices, flags, 0);
}
hipError_t hipModuleGetTexRef(textureReference** texRef, hipModule_t hmod, const char* name) {
HIP_INIT_API(texRef, hmod, name);
hipDeviceptr_t dptr = nullptr;
size_t bytes = 0;
/* input args check */
if ((texRef == nullptr) || (name == nullptr)) {
HIP_RETURN(hipErrorInvalidValue);
}
/* Get address and size for the global symbol */
if (!PlatformState::instance().getGlobalVar(name, ihipGetDevice(), &dptr,
&bytes)) {
HIP_RETURN(hipErrorUnknown);
}
*texRef = reinterpret_cast<textureReference*>(dptr);
HIP_RETURN(hipSuccess);
}
+20 -1
Wyświetl plik
@@ -209,6 +209,23 @@ bool ihipGetFuncAttributes(const char* func_name, amd::Program* program, hipFunc
return true;
}
bool PlatformState::getShadowVarInfo(std::string var_name, void** var_addr, size_t* var_size) {
const auto it = vars_.find(var_name);
if (it != vars_.cend()) {
DeviceVar& dvar = it->second;
*var_addr = dvar.shadowVptr;
*var_size = dvar.size;
return true;
} else {
return false;
}
}
bool CL_CALLBACK getSvarInfo(cl_program program, std::string var_name, void** var_addr,
size_t* var_size) {
return PlatformState::instance().getShadowVarInfo(var_name, var_addr, var_size);
}
hipFunction_t PlatformState::getFunc(const void* hostFunction, int deviceId) {
amd::ScopedLock lock(lock_);
const auto it = functions_.find(hostFunction);
@@ -218,6 +235,7 @@ hipFunction_t PlatformState::getFunc(const void* hostFunction, int deviceId) {
hipModule_t module = (*devFunc.modules)[deviceId].first;
if (!(*devFunc.modules)[deviceId].second) {
amd::Program* program = as_amd(reinterpret_cast<cl_program>(module));
program->setVarInfoCallBack(&getSvarInfo);
if (CL_SUCCESS != program->build(g_devices[deviceId]->devices(), nullptr, nullptr, nullptr)) {
return nullptr;
}
@@ -280,6 +298,7 @@ bool PlatformState::getGlobalVar(const void* hostVar, int deviceId,
if (!(*dvar.modules)[deviceId].second) {
amd::Program* program = as_amd(reinterpret_cast<cl_program>((*dvar.modules)[deviceId].first));
program->setVarInfoCallBack(&getSvarInfo);
if (CL_SUCCESS != program->build(g_devices[deviceId]->devices(), nullptr, nullptr, nullptr)) {
return false;
}
@@ -358,7 +377,7 @@ extern "C" void __hipRegisterVar(
{
HIP_INIT();
PlatformState::DeviceVar dvar{ std::string{ hostVar }, modules,
PlatformState::DeviceVar dvar{var, std::string{ hostVar }, static_cast<size_t>(size), modules,
std::vector<PlatformState::RegisteredVar>{ g_devices.size() } };
PlatformState::instance().registerVar(hostVar, dvar);
+34 -5
Wyświetl plik
@@ -442,13 +442,38 @@ hipError_t hipBindTextureToArray(textureReference* tex, hipArray_const_t array,
HIP_RETURN(hipErrorUnknown);
}
hipError_t ihipBindTextureImpl(int dim, enum hipTextureReadMode readMode, size_t* offset,
const void* devPtr, const struct hipChannelFormatDesc* desc,
size_t size, textureReference* tex) {
HIP_INIT_API(dim, readMode, offset, devPtr, size, tex);
assert(1 == dim);
HIP_RETURN(ihipBindTexture(CL_MEM_OBJECT_IMAGE1D, offset, tex, devPtr, desc, 1, 1, size));
}
hipError_t ihipBindTextureToArrayImpl(TlsData* tls, int dim, enum hipTextureReadMode readMode,
hipArray_const_t array,
const struct hipChannelFormatDesc& desc,
textureReference* tex) {
assert(0 && "Unimplemented");
HIP_INIT_API(dim, readMode, &desc, array, tex);
return hipErrorUnknown;
cl_mem_object_type clType;
size_t offset = 0;
switch (dim) {
case 1:
clType = CL_MEM_OBJECT_IMAGE1D_ARRAY;
break;
case 2:
clType = CL_MEM_OBJECT_IMAGE2D_ARRAY;
break;
default:
HIP_RETURN(hipErrorInvalidValue);
}
HIP_RETURN(ihipBindTexture(clType, &offset, tex, array->data, &desc, array->width,
array->height, array->depth));
}
hipError_t hipBindTextureToMipmappedArray(textureReference* tex,
@@ -464,7 +489,7 @@ hipError_t hipBindTextureToMipmappedArray(textureReference* tex,
hipError_t hipUnbindTexture(const textureReference* tex) {
HIP_INIT_API(tex);
as_amd(reinterpret_cast<cl_mem>(tex->textureObject))->release();
ihipDestroyTextureObject(reinterpret_cast<hip::TextureObject*>(tex->textureObject));
HIP_RETURN(hipSuccess);
}
@@ -482,9 +507,13 @@ hipError_t hipGetChannelDesc(hipChannelFormatDesc* desc, hipArray_const_t array)
hipError_t hipGetTextureAlignmentOffset(size_t* offset, const textureReference* tex) {
HIP_INIT_API(offset, tex);
assert(0 && "Unimplemented");
if ((offset == nullptr) || (tex == nullptr)) {
HIP_RETURN(hipErrorInvalidValue);
}
HIP_RETURN(hipErrorUnknown);
*offset = 0;
HIP_RETURN(hipSuccess);
}
hipError_t hipGetTextureReference(const textureReference** tex, const void* symbol) {