SWDEV-540609 - capture of MIOpen OCL kernels needs remainder globalWorkSize (#431)
Co-authored-by: Rakesh Roy <rakesh.roy@amd.com>
This commit is contained in:
committed by
GitHub
parent
296a4021f9
commit
ded5b86e83
@@ -83,30 +83,48 @@ hipError_t ihipGraphAddKernelNode(hip::GraphNode** pGraphNode, hip::Graph* graph
|
||||
hip::GraphNode* const* pDependencies, size_t numDependencies,
|
||||
const hipKernelNodeParams* pNodeParams,
|
||||
const ihipExtKernelEvents* pNodeEvents = nullptr,
|
||||
bool capture = true, int coopKernel = 0, int devId = 0) {
|
||||
bool capture = true, int coopKernel = 0, int devId = 0,
|
||||
int globalWorkSizeX_remainder = 0,
|
||||
int globalWorkSizeY_remainder = 0,
|
||||
int globalWorkSizeZ_remainder = 0) {
|
||||
if (!hip::Graph::isGraphValid(graph)) {
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
|
||||
hipFunction_t func = hip::GraphKernelNode::getFunc(*pNodeParams, ihipGetDevice());
|
||||
if (!func) {
|
||||
return hipErrorInvalidDeviceFunction;
|
||||
}
|
||||
hipError_t status =
|
||||
hip::GraphKernelNode::validateKernelParams(pNodeParams, func, ihipGetDevice());
|
||||
|
||||
amd::HIPLaunchParams launch_params(pNodeParams->gridDim.x, pNodeParams->gridDim.y,
|
||||
pNodeParams->gridDim.z, pNodeParams->blockDim.x,
|
||||
pNodeParams->blockDim.y, pNodeParams->blockDim.z,
|
||||
pNodeParams->sharedMemBytes, globalWorkSizeX_remainder,
|
||||
globalWorkSizeY_remainder, globalWorkSizeZ_remainder);
|
||||
if (!launch_params.IsValidConfig()) {
|
||||
return hipErrorInvalidConfiguration;
|
||||
}
|
||||
hipError_t status = ihipLaunchKernel_validate(func, launch_params, pNodeParams->kernelParams,
|
||||
pNodeParams->extra, ihipGetDevice(), 0);
|
||||
if (hipSuccess != status) {
|
||||
return status;
|
||||
}
|
||||
|
||||
size_t globalWorkSizeX = static_cast<size_t>(pNodeParams->gridDim.x) * pNodeParams->blockDim.x;
|
||||
size_t globalWorkSizeY = static_cast<size_t>(pNodeParams->gridDim.y) * pNodeParams->blockDim.y;
|
||||
size_t globalWorkSizeZ = static_cast<size_t>(pNodeParams->gridDim.z) * pNodeParams->blockDim.z;
|
||||
size_t globalWorkSizeX = static_cast<size_t>(pNodeParams->gridDim.x) * pNodeParams->blockDim.x +
|
||||
globalWorkSizeX_remainder;
|
||||
size_t globalWorkSizeY = static_cast<size_t>(pNodeParams->gridDim.y) * pNodeParams->blockDim.y +
|
||||
globalWorkSizeY_remainder;
|
||||
size_t globalWorkSizeZ = static_cast<size_t>(pNodeParams->gridDim.z) * pNodeParams->blockDim.z +
|
||||
globalWorkSizeZ_remainder;
|
||||
if (globalWorkSizeX > std::numeric_limits<uint32_t>::max() ||
|
||||
globalWorkSizeY > std::numeric_limits<uint32_t>::max() ||
|
||||
globalWorkSizeZ > std::numeric_limits<uint32_t>::max()) {
|
||||
return hipErrorInvalidConfiguration;
|
||||
}
|
||||
|
||||
*pGraphNode = new hip::GraphKernelNode(pNodeParams, pNodeEvents, coopKernel);
|
||||
*pGraphNode =
|
||||
new hip::GraphKernelNode(pNodeParams, pNodeEvents, coopKernel, globalWorkSizeX_remainder,
|
||||
globalWorkSizeY_remainder, globalWorkSizeZ_remainder);
|
||||
if (devId != 0) {
|
||||
(*pGraphNode)->SetDeviceId(devId);
|
||||
}
|
||||
@@ -238,10 +256,13 @@ hipError_t capturehipLaunchKernel(hipStream_t& stream, const void*& hostFunction
|
||||
|
||||
hipError_t ihipExtLaunchKernel(hipStream_t stream, hipFunction_t f, uint32_t globalWorkSizeX,
|
||||
uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ,
|
||||
uint32_t localWorkSizeX, uint32_t localWorkSizeY,
|
||||
uint32_t localWorkSizeZ, size_t sharedMemBytes, void** kernelParams,
|
||||
void** extra, hipEvent_t startEvent, hipEvent_t stopEvent,
|
||||
uint32_t flags, bool capture = true) {
|
||||
uint32_t globalWorkSizeX_remainder,
|
||||
uint32_t globalWorkSizeY_remainder,
|
||||
uint32_t globalWorkSizeZ_remainder, uint32_t localWorkSizeX,
|
||||
uint32_t localWorkSizeY, uint32_t localWorkSizeZ,
|
||||
size_t sharedMemBytes, void** kernelParams, void** extra,
|
||||
hipEvent_t startEvent, hipEvent_t stopEvent, uint32_t flags,
|
||||
bool capture = true) {
|
||||
if (!hip::isValid(stream)) {
|
||||
return hipErrorContextIsDestroyed;
|
||||
}
|
||||
@@ -275,9 +296,10 @@ hipError_t ihipExtLaunchKernel(hipStream_t stream, hipFunction_t f, uint32_t glo
|
||||
nodeParams.kernelParams = kernelParams;
|
||||
nodeParams.sharedMemBytes = sharedMemBytes;
|
||||
|
||||
status =
|
||||
ihipGraphAddKernelNode(&pGraphNode, s->GetCaptureGraph(), s->GetLastCapturedNodes().data(),
|
||||
s->GetLastCapturedNodes().size(), &nodeParams, &nodeEvents);
|
||||
status = ihipGraphAddKernelNode(
|
||||
&pGraphNode, s->GetCaptureGraph(), s->GetLastCapturedNodes().data(),
|
||||
s->GetLastCapturedNodes().size(), &nodeParams, &nodeEvents, true, 0, s->DeviceId(),
|
||||
globalWorkSizeX_remainder, globalWorkSizeY_remainder, globalWorkSizeZ_remainder);
|
||||
|
||||
if (status != hipSuccess) {
|
||||
return status;
|
||||
@@ -298,8 +320,10 @@ hipError_t capturehipExtModuleLaunchKernel(hipStream_t& stream, hipFunction_t& f
|
||||
"[hipGraph] Current capture node ExtModuleLaunchKernel on stream : %p", stream);
|
||||
return ihipExtLaunchKernel(stream, f, globalWorkSizeX / localWorkSizeX,
|
||||
globalWorkSizeY / localWorkSizeY, globalWorkSizeZ / localWorkSizeZ,
|
||||
localWorkSizeX, localWorkSizeY, localWorkSizeZ, sharedMemBytes,
|
||||
kernelParams, extra, startEvent, stopEvent, flags);
|
||||
globalWorkSizeX % localWorkSizeX, globalWorkSizeY % localWorkSizeY,
|
||||
globalWorkSizeZ % localWorkSizeZ, localWorkSizeX, localWorkSizeY,
|
||||
localWorkSizeZ, sharedMemBytes, kernelParams, extra, startEvent,
|
||||
stopEvent, flags);
|
||||
}
|
||||
|
||||
hipError_t capturehipExtLaunchKernel(hipStream_t& stream, const void*& hostFunction, dim3& gridDim,
|
||||
@@ -307,10 +331,10 @@ hipError_t capturehipExtLaunchKernel(hipStream_t& stream, const void*& hostFunct
|
||||
hipEvent_t& startEvent, hipEvent_t& stopEvent, int& flags) {
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_API,
|
||||
"[hipGraph] Current capture node ExtLaunchKernel on stream : %p", stream);
|
||||
return ihipExtLaunchKernel(stream,
|
||||
reinterpret_cast<hipFunction_t>(const_cast<void*>(hostFunction)),
|
||||
gridDim.x, gridDim.y, gridDim.z, blockDim.x, blockDim.y, blockDim.z,
|
||||
sharedMemBytes, args, nullptr, startEvent, stopEvent, flags);
|
||||
return ihipExtLaunchKernel(
|
||||
stream, reinterpret_cast<hipFunction_t>(const_cast<void*>(hostFunction)), gridDim.x,
|
||||
gridDim.y, gridDim.z, 0, 0, 0, blockDim.x, blockDim.y, blockDim.z, sharedMemBytes, args,
|
||||
nullptr, startEvent, stopEvent, flags);
|
||||
}
|
||||
|
||||
hipError_t capturehipModuleLaunchKernel(hipStream_t& stream, hipFunction_t& f, uint32_t& gridDimX,
|
||||
|
||||
Reference in New Issue
Block a user