Fix signal resource issue.

Remove memory leak with new hc::completion_future.
Implement HIP_LAUNCH_BLOCKING with queue-level wait.

Change-Id: I45975f81c4d239fdeed7776970988d28449865dc


[ROCm/hip commit: 225e37fdc9]
Tá an tiomantas seo le fáil i:
Ben Sander
2016-09-26 16:32:35 -05:00
tuismitheoir 00f8a4f5a7
tiomantas 0dadf681db
D'athraigh 3 comhad le 12 breiseanna agus 10 scriosta
+1 -1
Féach ar an gComhad
@@ -373,7 +373,7 @@ typedef uint64_t SeqNum_t ;
//--- //---
// Member functions that begin with locked_ are thread-safe accessors - these acquire / release the critical mutex. // Member functions that begin with locked_ are thread-safe accessors - these acquire / release the critical mutex.
LockedAccessor_StreamCrit_t lockopen_preKernelCommand(); LockedAccessor_StreamCrit_t lockopen_preKernelCommand();
void lockclose_postKernelCommand(hc::completion_future &kernel_future); void lockclose_postKernelCommand(hc::accelerator_view *av);
void locked_wait(bool assertQueueEmpty=false); void locked_wait(bool assertQueueEmpty=false);
+8 -7
Féach ar an gComhad
@@ -253,11 +253,12 @@ LockedAccessor_StreamCrit_t ihipStream_t::lockopen_preKernelCommand()
//--- //---
// Must be called after kernel finishes, this releases the lock on the stream so other commands can submit. // Must be called after kernel finishes, this releases the lock on the stream so other commands can submit.
void ihipStream_t::lockclose_postKernelCommand(hc::completion_future &kernelFuture) void ihipStream_t::lockclose_postKernelCommand(hc::accelerator_view *av)
{ {
if (HIP_LAUNCH_BLOCKING) { if (HIP_LAUNCH_BLOCKING) {
kernelFuture.wait(); // TODO - fix this so it goes through proper stream::wait() call.
av->wait(); // direct wait OK since we know the stream is locked.
tprintf(DB_SYNC, " %s LAUNCH_BLOCKING for kernel completion\n", ToString(this).c_str()); tprintf(DB_SYNC, " %s LAUNCH_BLOCKING for kernel completion\n", ToString(this).c_str());
} }
@@ -1163,7 +1164,7 @@ hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, dim3 block, grid_
auto crit = stream->lockopen_preKernelCommand(); auto crit = stream->lockopen_preKernelCommand();
lp->av = &(crit->_av); lp->av = &(crit->_av);
lp->cf = new hc::completion_future; lp->cf = nullptr;
ihipPrintKernelLaunch(kernelNameStr, lp, stream); ihipPrintKernelLaunch(kernelNameStr, lp, stream);
return (stream); return (stream);
@@ -1185,7 +1186,7 @@ hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, dim3 block, gri
auto crit = stream->lockopen_preKernelCommand(); auto crit = stream->lockopen_preKernelCommand();
lp->av = &(crit->_av); lp->av = &(crit->_av);
lp->cf = new hc::completion_future; lp->cf = nullptr;
ihipPrintKernelLaunch(kernelNameStr, lp, stream); ihipPrintKernelLaunch(kernelNameStr, lp, stream);
return (stream); return (stream);
} }
@@ -1206,7 +1207,7 @@ hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, size_t block, gri
auto crit = stream->lockopen_preKernelCommand(); auto crit = stream->lockopen_preKernelCommand();
lp->av = &(crit->_av); lp->av = &(crit->_av);
lp->cf = new hc::completion_future; lp->cf = nullptr;
ihipPrintKernelLaunch(kernelNameStr, lp, stream); ihipPrintKernelLaunch(kernelNameStr, lp, stream);
return (stream); return (stream);
} }
@@ -1227,7 +1228,7 @@ hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, size_t block, g
auto crit = stream->lockopen_preKernelCommand(); auto crit = stream->lockopen_preKernelCommand();
lp->av = &(crit->_av); lp->av = &(crit->_av);
lp->cf = new hc::completion_future; // TODO, is this necessary? lp->cf = nullptr;
ihipPrintKernelLaunch(kernelNameStr, lp, stream); ihipPrintKernelLaunch(kernelNameStr, lp, stream);
@@ -1240,7 +1241,7 @@ hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, size_t block, g
//This releases the lock on the stream. //This releases the lock on the stream.
void ihipPostLaunchKernel(hipStream_t stream, grid_launch_parm &lp) void ihipPostLaunchKernel(hipStream_t stream, grid_launch_parm &lp)
{ {
stream->lockclose_postKernelCommand(*(lp.cf)); stream->lockclose_postKernelCommand(lp.av);
} }
+3 -2
Féach ar an gComhad
@@ -772,7 +772,7 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t s
} }
} }
stream->lockclose_postKernelCommand(cf); stream->lockclose_postKernelCommand(&crit->_av);
if (HIP_LAUNCH_BLOCKING) { if (HIP_LAUNCH_BLOCKING) {
@@ -822,9 +822,10 @@ hipError_t hipMemset(void* dst, int value, size_t sizeBytes )
e = hipErrorInvalidValue; e = hipErrorInvalidValue;
} }
} }
// TODO - is hipMemset supposed to be async?
cf.wait(); cf.wait();
stream->lockclose_postKernelCommand(cf); stream->lockclose_postKernelCommand(&crit->_av);
if (HIP_LAUNCH_BLOCKING) { if (HIP_LAUNCH_BLOCKING) {