diff --git a/catch/unit/stream/hipStreamCreateWithPriority.cc b/catch/unit/stream/hipStreamCreateWithPriority.cc index 03b34e4da1..9bc8bb32bf 100644 --- a/catch/unit/stream/hipStreamCreateWithPriority.cc +++ b/catch/unit/stream/hipStreamCreateWithPriority.cc @@ -256,6 +256,8 @@ bool runFuncTestsForAllPriorityLevelsMultThread(unsigned int flags) { int priority; int priority_low; int priority_high; + std::vector stream_set{}; + hipStream_t stream{}; // Test is to get the Stream Priority Range HIP_CHECK(hipDeviceGetStreamPriorityRange(&priority_low, &priority_high)); @@ -265,23 +267,19 @@ bool runFuncTestsForAllPriorityLevelsMultThread(unsigned int flags) { return true; } - int numOfPriorities = priority_low - priority_high; + int numOfPriorities = priority_low - priority_high + 1; INFO("numOfPriorities : " << numOfPriorities); - // 0 idx is for default stream - std::vector stream(numOfPriorities + 1); - stream[0] = 0; - // Create a stream for each of the priority levels - int count = 1; - for (priority = priority_high; priority < priority_low; priority++) { - HIP_CHECK(hipStreamCreateWithPriority(&stream[count++], flags, + for (priority = priority_high; priority <= priority_low; priority++) { + HIP_CHECK(hipStreamCreateWithPriority(&stream, flags, priority)); + stream_set.push_back(stream); } for (int i = 0; i < TOTALTHREADS; i++) { T[i] = std::thread(queueTasksInStreams, - &stream, numOfPriorities + 1); + &stream_set, numOfPriorities); } for (int i=0; i < TOTALTHREADS; i++) { @@ -294,9 +292,9 @@ bool runFuncTestsForAllPriorityLevelsMultThread(unsigned int flags) { } // Destroy the stream for each of the priority levels - count = 1; - for (priority = priority_high; priority < priority_low; priority++) { - HIP_CHECK(hipStreamDestroy(stream[count++])); + size_t set_size = stream_set.size(); + for (int i = 0; i < set_size; i++) { + HIP_CHECK(hipStreamDestroy(stream_set[i])); } return TestPassed; }