@@ -323,9 +323,7 @@ hipError_t hipDeviceGetStreamPriorityRange(int* leastPriority, int* greatestPrio
323323// ================================================================================================
324324hipError_t hipStreamGetFlags_common (hipStream_t stream, unsigned int * flags) {
325325 if ((flags != nullptr ) && (stream != nullptr )) {
326- if (!hip::isValid (stream)) {
327- return hipErrorContextIsDestroyed;
328- }
326+ getStreamPerThread (stream);
329327 *flags = reinterpret_cast <hip::Stream*>(stream)->Flags ();
330328 } else {
331329 return hipErrorInvalidValue;
@@ -349,9 +347,7 @@ hipError_t hipStreamGetFlags_spt(hipStream_t stream, unsigned int* flags) {
349347
350348// ================================================================================================
351349hipError_t hipStreamSynchronize_common (hipStream_t stream) {
352- if (!hip::isValid (stream)) {
353- HIP_RETURN (hipErrorContextIsDestroyed);
354- }
350+ getStreamPerThread (stream);
355351 if (stream != nullptr && stream != hipStreamLegacy) {
356352 // If still capturing return error
357353 if (hip::Stream::StreamCaptureOngoing (stream) == true ) {
@@ -398,9 +394,6 @@ hipError_t hipStreamDestroy(hipStream_t stream) {
398394 if (stream == hipStreamPerThread || stream == hipStreamLegacy) {
399395 HIP_RETURN (hipErrorInvalidResourceHandle);
400396 }
401- if (!hip::isValid (stream)) {
402- HIP_RETURN (hipErrorContextIsDestroyed);
403- }
404397 hip::Stream* s = reinterpret_cast <hip::Stream*>(stream);
405398 if (s->GetCaptureStatus () != hipStreamCaptureStatusNone) {
406399 if (s->GetParentStream () != nullptr ) {
@@ -448,9 +441,10 @@ void WaitThenDecrementSignal(hipStream_t stream, hipError_t status, void* user_d
448441// ================================================================================================
449442hipError_t hipStreamWaitEvent_common (hipStream_t stream, hipEvent_t event, unsigned int flags) {
450443 hipError_t status = hipSuccess;
451- if (event == nullptr || ! hip::isValid (stream) ) {
444+ if (event == nullptr ) {
452445 return hipErrorInvalidHandle;
453446 }
447+ getStreamPerThread (stream);
454448 hip::Stream* waitStream = hip::getStream (stream);
455449 hip::Event* e = reinterpret_cast <hip::Event*>(event);
456450 auto eventStreamHandle = reinterpret_cast <hipStream_t>(e->GetCaptureStream ());
@@ -511,9 +505,7 @@ hipError_t hipStreamWaitEvent_spt(hipStream_t stream, hipEvent_t event, unsigned
511505
512506// ================================================================================================
513507hipError_t hipStreamQuery_common (hipStream_t stream) {
514- if (!hip::isValid (stream)) {
515- return hipErrorContextIsDestroyed;
516- }
508+ getStreamPerThread (stream);
517509 if (stream != nullptr ) {
518510 // If still capturing return error
519511 if (hip::Stream::StreamCaptureOngoing (stream) == true ) {
@@ -566,10 +558,7 @@ hipError_t hipStreamQuery_spt(hipStream_t stream) {
566558}
567559
568560hipError_t streamCallback_common (hipStream_t stream, StreamCallback* cbo, void * userData) {
569- if (!hip::isValid (stream)) {
570- return hipErrorContextIsDestroyed;
571- }
572-
561+ getStreamPerThread (stream);
573562 hip::Stream* hip_stream = hip::getStream (stream);
574563 amd::Command* last_command = hip_stream->getLastQueuedCommand (true );
575564 amd::Command::EventWaitList eventWaitList;
@@ -688,9 +677,7 @@ hipError_t hipStreamGetPriority_common(hipStream_t stream, int* priority) {
688677 }
689678
690679 if ((priority != nullptr ) && (stream != nullptr )) {
691- if (!hip::isValid (stream)) {
692- return hipErrorContextIsDestroyed;
693- }
680+ getStreamPerThread (stream);
694681 *priority = static_cast <int >(reinterpret_cast <hip::Stream*>(stream)->GetPriority ());
695682 } else {
696683 return hipErrorInvalidValue;
0 commit comments