hipStreamQuery uses av::is_empty. Add HIP_FORCE_NULL_STREAM.

This commit is contained in:
Ben Sander
2017-08-31 02:50:30 +00:00
والد ed8c3ba7e7
کامیت fff74eee21
3فایلهای تغییر یافته به همراه27 افزوده شده و 16 حذف شده
+4
مشاهده پرونده
@@ -90,6 +90,8 @@ int HIP_SYNC_HOST_ALLOC = 1;
int HIP_SYNC_STREAM_WAIT = 0; int HIP_SYNC_STREAM_WAIT = 0;
int HIP_FORCE_NULL_STREAM=0;
#if (__hcc_workweek__ >= 17300) #if (__hcc_workweek__ >= 17300)
// Make sure we have required bug fix in HCC // Make sure we have required bug fix in HCC
@@ -1251,6 +1253,8 @@ void HipReadEnv()
READ_ENV_I(release, HIP_SYNC_HOST_ALLOC, 0, "Sync before and after all host memory allocations. May help stability"); READ_ENV_I(release, HIP_SYNC_HOST_ALLOC, 0, "Sync before and after all host memory allocations. May help stability");
READ_ENV_I(release, HIP_SYNC_NULL_STREAM, 0, "Synchronize on host for null stream submissions"); READ_ENV_I(release, HIP_SYNC_NULL_STREAM, 0, "Synchronize on host for null stream submissions");
READ_ENV_I(release, HIP_FORCE_NULL_STREAM, 0, "Force all stream allocations to secretly return the null stream");
READ_ENV_I(release, HIP_SYNC_STREAM_WAIT, 0, "hipStreamWaitEvent will synchronize to host"); READ_ENV_I(release, HIP_SYNC_STREAM_WAIT, 0, "hipStreamWaitEvent will synchronize to host");
@@ -68,6 +68,7 @@ extern int HIP_SYNC_HOST_ALLOC;
extern int HIP_SYNC_STREAM_WAIT; extern int HIP_SYNC_STREAM_WAIT;
extern int HIP_SYNC_NULL_STREAM; extern int HIP_SYNC_NULL_STREAM;
extern int HIP_FORCE_NULL_STREAM;
// TODO - remove when this is standard behavior. // TODO - remove when this is standard behavior.
extern int HCC_OPT_FLUSH; extern int HCC_OPT_FLUSH;
+22 -16
مشاهده پرونده
@@ -38,21 +38,26 @@ hipError_t ihipStreamCreate(hipStream_t *stream, unsigned int flags)
hipError_t e = hipSuccess; hipError_t e = hipSuccess;
if (ctx) { if (ctx) {
hc::accelerator acc = ctx->getWriteableDevice()->_acc;
// TODO - se try-catch loop to detect memory exception? if (HIP_FORCE_NULL_STREAM) {
// *stream = 0;
//Note this is an execute_in_order queue, so all kernels submitted will atuomatically wait for prev to complete: } else {
//This matches CUDA stream behavior: hc::accelerator acc = ctx->getWriteableDevice()->_acc;
{ // TODO - se try-catch loop to detect memory exception?
// Obtain mutex access to the device critical data, release by destructor //
LockedAccessor_CtxCrit_t ctxCrit(ctx->criticalData()); //Note this is an execute_in_order queue, so all kernels submitted will atuomatically wait for prev to complete:
//This matches CUDA stream behavior:
auto istream = new ihipStream_t(ctx, acc.create_view(), flags); {
// Obtain mutex access to the device critical data, release by destructor
LockedAccessor_CtxCrit_t ctxCrit(ctx->criticalData());
ctxCrit->addStream(istream); auto istream = new ihipStream_t(ctx, acc.create_view(), flags);
*stream = istream;
ctxCrit->addStream(istream);
*stream = istream;
}
} }
tprintf(DB_SYNC, "hipStreamCreate, %s\n", ToString(*stream).c_str()); tprintf(DB_SYNC, "hipStreamCreate, %s\n", ToString(*stream).c_str());
@@ -119,15 +124,14 @@ hipError_t hipStreamQuery(hipStream_t stream)
stream = device->_defaultStream; stream = device->_defaultStream;
} }
int pendingOps = 0; bool isEmpty = 0;
{ {
LockedAccessor_StreamCrit_t crit(stream->_criticalData); LockedAccessor_StreamCrit_t crit(stream->_criticalData);
pendingOps = crit->_av.get_pending_async_ops(); isEmpty = crit->_av.get_is_empty();
} }
hipError_t e = isEmpty ? hipSuccess : hipErrorNotReady ;
hipError_t e = (pendingOps > 0) ? hipErrorNotReady : hipSuccess;
return ihipLogStatus(e); return ihipLogStatus(e);
} }
@@ -167,7 +171,9 @@ hipError_t hipStreamDestroy(hipStream_t stream)
//--- Drain the stream: //--- Drain the stream:
if (stream == NULL) { if (stream == NULL) {
e = hipErrorInvalidResourceHandle; // TODO - review - what happens if try to destroy null stream if (!HIP_FORCE_NULL_STREAM) {
e = hipErrorInvalidResourceHandle;
}
} else { } else {
stream->locked_wait(); stream->locked_wait();