Added testing for hipStreamSynchronize and hipStreamQuery (#2572)

[ROCm/hip commit: b7f5db36d2]
This commit is contained in:
Fábio authored and GitHub committed 2022-08-08 09:29:20 +05:30
1 parent 132de2d9a3
commit f3ed780a7b
5 files changed
+290 -62

No files matched your search

@@ -66,44 +66,8 @@ bool checkStreamFlags_(hipStream_t stream, bool checkFlags = false, unsigned fla
inline namespace stream {
__device__ int defaultSemaphore = 0;
__global__ void signaling_kernel(int* semaphore) {
size_t tid{blockIdx.x * blockDim.x + threadIdx.x};
if (tid == 0) {
if (semaphore == nullptr) {
atomicAdd(&defaultSemaphore, 1);
} else {
atomicAdd(semaphore, 1);
}
}
}
__global__ void waiting_kernel(int* semaphore) {
size_t tid{blockIdx.x * blockDim.x + threadIdx.x};
if (tid == 0) {
if (semaphore == nullptr) {
while (atomicCAS(&defaultSemaphore, 1, 2) == 0) {
}
} else {
while (atomicCAS(semaphore, 1, 2) == 0) {
}
}
}
}
std::thread startSignalingThread(int* semaphore) {
std::thread signalingThread([semaphore]() {
hipStream_t signalingStream;
HIP_CHECK_THREAD(hipStreamCreateWithFlags(&signalingStream, hipStreamNonBlocking));
signaling_kernel<<<1, 1, 0, signalingStream>>>(semaphore);
HIP_CHECK_THREAD(hipStreamSynchronize(signalingStream));
HIP_CHECK_THREAD(hipStreamDestroy(signalingStream));
});
return signalingThread;
}
/* Empty kernel to ensure work finishes on the stream quickly */
__global__ void empty_kernel() {}
bool checkStream(hipStream_t stream) {
{ // Check default flags