Summary: The RPC server is responsible for providing host services from the GPU. Generally, the client running on the GPU will spin in place until the host checks the server. Inside the runtime, we elected to have the user thread do this checking while it would be otherwise waiting for the kernel to finish. However, for Nvidia this caused problems when offloading to a target region that requires a copy back. This is caused by the implementation of `dataRetrieve` on Nvidia. We initialize an asynchronous copy-back on the same stream that the kernel is running on. This creates an implicit sync on the kernel to finish before we issue the D2H copy, which we then wait on. This implicit sync happens inside of the CUDA runtime. This is problematic when running the RPC server because we need someone to check the RPC server. If no one checks the RPC server then the kernel will never finish, meaning that the memcpy will never be issued and the program hangs. This patch adds an explicit check for unfinished work on the stream and waits for it to complete.
23 lines
559 B
C
23 lines
559 B
C
// RUN: %libomptarget-compile-run-and-check-generic
|
|
|
|
// REQUIRES: libc
|
|
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
|
|
#pragma omp declare target to(stdout)
|
|
|
|
int main() {
|
|
int r = 0;
|
|
// CHECK: PASS
|
|
#pragma omp target map(from : r)
|
|
{ r = fwrite("PASS\n", 1, sizeof("PASS\n") - 1, stdout); }
|
|
assert(r == sizeof("PASS\n") - 1 && "Incorrect number of bytes written");
|
|
|
|
// CHECK: PASS
|
|
#pragma omp target map(from : r) nowait
|
|
{ r = fwrite("PASS\n", 1, 5, stdout); }
|
|
#pragma omp taskwait
|
|
assert(r == sizeof("PASS\n") - 1 && "Incorrect number of bytes written");
|
|
}
|