OClCollMeshEngn:*KernelComplete: use WRITE_INVLDT during finalize()

Doing it this way enables us to get the mapBuffer() call working
during finalize. But we couldn't get the unmap call working. That
has to do with a bug in the Rusticl event waiting code.
This commit is contained in:
2025-11-14 18:04:12 -04:00
parent 2e75dd40aa
commit 51a2858214
2 changed files with 21 additions and 8 deletions
@@ -711,16 +711,21 @@ bool OpenClCollatingAndMeshingEngine::stop()
return wasAcceptingRequests;
}
void OpenClCollatingAndMeshingEngine::compactKernelComplete()
void OpenClCollatingAndMeshingEngine::compactKernelComplete(bool isFinalizing)
{
cl_map_flags mapFlags;
/** EXPLANATION:
* Technically we should only need to do this if we plan to read the
* compacted slots for debugging purposes. Otherwise this is unnecessary.
*/
mapAssemblyBuffer(CL_MAP_READ);
if (isFinalizing) { mapFlags = CL_MAP_WRITE_INVALIDATE_REGION; }
else { mapFlags = CL_MAP_READ; }
mapAssemblyBuffer(mapFlags);
unmapAssemblyBuffer();
clFlush(commandQueue);
clFinish(commandQueue);
// Stop only compact kernel
if (compactIsRunning && currentCompactKernelEvent)
@@ -729,20 +734,26 @@ void OpenClCollatingAndMeshingEngine::compactKernelComplete()
clReleaseEvent(currentCompactKernelEvent);
currentCompactKernelEvent = nullptr;
}
clFinish(commandQueue);
compactKernelCb = [](cl_int){};
compactIsRunning = false;
}
void OpenClCollatingAndMeshingEngine::collateKernelComplete()
void OpenClCollatingAndMeshingEngine::collateKernelComplete(bool isFinalizing)
{
cl_map_flags mapFlags;
/** EXPLANATION:
* Technically we should only need to do this if we plan to read the
* collated dgrams for debugging purposes. Otherwise this is unnecessary.
*/
mapCollationBuffer(CL_MAP_READ);
if (isFinalizing) { mapFlags = CL_MAP_WRITE_INVALIDATE_REGION; }
else { mapFlags = CL_MAP_READ; }
mapCollationBuffer(mapFlags);
unmapCollationBuffer();
clFlush(commandQueue);
clFinish(commandQueue);
// Stop only collate kernel
if (collateIsRunning && currentCollateKernelEvent)
{
@@ -750,6 +761,8 @@ void OpenClCollatingAndMeshingEngine::collateKernelComplete()
clReleaseEvent(currentCollateKernelEvent);
currentCollateKernelEvent = nullptr;
}
clFinish(commandQueue);
collateKernelCb = [](cl_int){};
collateIsRunning = false;
}