Index: libomptarget/deviceRTLs/nvptx/src/sync.cu =================================================================== --- libomptarget/deviceRTLs/nvptx/src/sync.cu +++ libomptarget/deviceRTLs/nvptx/src/sync.cu @@ -130,7 +130,7 @@ EXTERN void __kmpc_flush(kmp_Ident *loc) { PRINT0(LD_IO, "call kmpc_flush\n"); - __threadfence_system(); + __threadfence(); } //////////////////////////////////////////////////////////////////////////////// Index: libomptarget/deviceRTLs/nvptx/test/parallel/flush.c =================================================================== --- /dev/null +++ libomptarget/deviceRTLs/nvptx/test/parallel/flush.c @@ -0,0 +1,33 @@ +// RUN: %compile-run-and-check + +#include +#include + +int main(int argc, char *argv[]) { + int data, flag = 0; +#pragma omp target parallel num_threads(64) map(to : data, flag) + { + if (omp_get_thread_num() == 0) { + /* Write to the data buffer that will be read by thread */ + data = 42; +/* Flush data to thread 1 and strictly order the write to data + relative to the write to the flag */ +#pragma omp flush(flag, data) + /* Set flag to release thread 1 */ + flag = 1; +/* Flush flag to ensure that thread 1 sees S-21 the change */ +#pragma omp flush(flag) + } else if (omp_get_thread_num() == 32) { +/* Loop until we see the update to the flag */ +#pragma omp flush(flag, data) + while (flag < 1) { +#pragma omp flush(flag, data) + } +#pragma omp flush(flag, data) + // CHECK: data=42. + /* Values data will be 42, value of flag still undefined */ + printf("data=%d.\n", data); + } + } + return 0; +}