diff --git a/openmp/libomptarget/DeviceRTL/src/Misc.cpp b/openmp/libomptarget/DeviceRTL/src/Misc.cpp --- a/openmp/libomptarget/DeviceRTL/src/Misc.cpp +++ b/openmp/libomptarget/DeviceRTL/src/Misc.cpp @@ -52,7 +52,7 @@ double getWTime() { unsigned long long nsecs; - asm("mov.u64 %0, %%globaltimer;" : "=l"(nsecs)); + asm volatile("mov.u64 %0, %%globaltimer;" : "=l"(nsecs)); return (double)nsecs * getWTick(); } diff --git a/openmp/libomptarget/test/lit.cfg b/openmp/libomptarget/test/lit.cfg --- a/openmp/libomptarget/test/lit.cfg +++ b/openmp/libomptarget/test/lit.cfg @@ -127,18 +127,30 @@ # Is this target in the current system? If so create a compile, run and test # command. Otherwise create command that return false. if libomptarget_target == config.libomptarget_current_target: - config.substitutions.append(("%libomptarget-compilexx-run-and-check-generic", + config.substitutions.append(("%libomptarget-compilexx-run-and-check-generic", "%libomptarget-compilexx-run-and-check-" + libomptarget_target)) config.substitutions.append(("%libomptarget-compile-run-and-check-generic", "%libomptarget-compile-run-and-check-" + libomptarget_target)) + config.substitutions.append(("%libomptarget-compileoptxx-run-and-check-generic", + "%libomptarget-compileoptxx-run-and-check-" + libomptarget_target)) + config.substitutions.append(("%libomptarget-compileopt-run-and-check-generic", + "%libomptarget-compileopt-run-and-check-" + libomptarget_target)) config.substitutions.append(("%libomptarget-compilexx-and-run-generic", "%libomptarget-compilexx-and-run-" + libomptarget_target)) config.substitutions.append(("%libomptarget-compile-and-run-generic", "%libomptarget-compile-and-run-" + libomptarget_target)) + config.substitutions.append(("%libomptarget-compileoptxx-and-run-generic", + "%libomptarget-compilexx-and-run-" + libomptarget_target)) + config.substitutions.append(("%libomptarget-compileopt-and-run-generic", + "%libomptarget-compile-and-run-" + libomptarget_target)) config.substitutions.append(("%libomptarget-compilexx-generic", "%libomptarget-compilexx-" + libomptarget_target)) config.substitutions.append(("%libomptarget-compile-generic", "%libomptarget-compile-" + libomptarget_target)) + config.substitutions.append(("%libomptarget-compileoptxx-generic", + "%libomptarget-compilexx-" + libomptarget_target)) + config.substitutions.append(("%libomptarget-compileopt-generic", + "%libomptarget-compile-" + libomptarget_target)) config.substitutions.append(("%libomptarget-run-generic", "%libomptarget-run-" + libomptarget_target)) config.substitutions.append(("%libomptarget-run-fail-generic", @@ -159,6 +171,14 @@ libomptarget_target, \ "%libomptarget-compile-and-run-" + libomptarget_target + \ " | " + config.libomptarget_filecheck + " %s")) + config.substitutions.append(("%libomptarget-compileoptxx-run-and-check-" + \ + libomptarget_target, \ + "%libomptarget-compileoptxx-and-run-" + libomptarget_target + \ + " | " + config.libomptarget_filecheck + " %s")) + config.substitutions.append(("%libomptarget-compileopt-run-and-check-" + \ + libomptarget_target, \ + "%libomptarget-compileopt-and-run-" + libomptarget_target + \ + " | " + config.libomptarget_filecheck + " %s")) config.substitutions.append(("%libomptarget-compilexx-and-run-" + \ libomptarget_target, \ "%libomptarget-compilexx-" + libomptarget_target + " && " + \ @@ -167,12 +187,26 @@ libomptarget_target, \ "%libomptarget-compile-" + libomptarget_target + " && " + \ "%libomptarget-run-" + libomptarget_target)) + config.substitutions.append(("%libomptarget-compileoptxx-and-run-" + \ + libomptarget_target, \ + "%libomptarget-compileoptxx-" + libomptarget_target + " && " + \ + "%libomptarget-run-" + libomptarget_target)) + config.substitutions.append(("%libomptarget-compileopt-and-run-" + \ + libomptarget_target, \ + "%libomptarget-compileopt-" + libomptarget_target + " && " + \ + "%libomptarget-run-" + libomptarget_target)) config.substitutions.append(("%libomptarget-compilexx-" + \ libomptarget_target, \ "%clangxx-" + libomptarget_target + " %s -o %t")) config.substitutions.append(("%libomptarget-compile-" + \ libomptarget_target, \ "%clang-" + libomptarget_target + " %s -o %t")) + config.substitutions.append(("%libomptarget-compileoptxx-" + \ + libomptarget_target, \ + "%clangxx-" + libomptarget_target + " -O3 %s -o %t")) + config.substitutions.append(("%libomptarget-compileopt-" + \ + libomptarget_target, \ + "%clang-" + libomptarget_target + " -O3 %s -o %t")) config.substitutions.append(("%libomptarget-run-" + \ libomptarget_target, \ "%t")) @@ -194,18 +228,36 @@ config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \ libomptarget_target, \ "echo ignored-command")) + config.substitutions.append(("%libomptarget-compileopt-run-and-check-" + \ + libomptarget_target, \ + "echo ignored-command")) + config.substitutions.append(("%libomptarget-compileoptxx-run-and-check-" + \ + libomptarget_target, \ + "echo ignored-command")) config.substitutions.append(("%libomptarget-compile-and-run-" + \ libomptarget_target, \ "echo ignored-command")) config.substitutions.append(("%libomptarget-compilexx-and-run-" + \ libomptarget_target, \ "echo ignored-command")) + config.substitutions.append(("%libomptarget-compileopt-and-run-" + \ + libomptarget_target, \ + "echo ignored-command")) + config.substitutions.append(("%libomptarget-compileoptxx-and-run-" + \ + libomptarget_target, \ + "echo ignored-command")) config.substitutions.append(("%libomptarget-compilexx-" + \ libomptarget_target, \ "echo ignored-command")) config.substitutions.append(("%libomptarget-compile-" + \ libomptarget_target, \ "echo ignored-command")) + config.substitutions.append(("%libomptarget-compileoptxx-" + \ + libomptarget_target, \ + "echo ignored-command")) + config.substitutions.append(("%libomptarget-compileopt-" + \ + libomptarget_target, \ + "echo ignored-command")) config.substitutions.append(("%libomptarget-run-" + \ libomptarget_target, \ "echo ignored-command")) diff --git a/openmp/libomptarget/test/offloading/wtime.c b/openmp/libomptarget/test/offloading/wtime.c new file mode 100644 --- /dev/null +++ b/openmp/libomptarget/test/offloading/wtime.c @@ -0,0 +1,24 @@ +// RUN: %libomptarget-compileopt-run-and-check-generic + +// UNSUPPORTED: amdgcn-amd-amdhsa +// UNSUPPORTED: amdgcn-amd-amdhsa-oldDriver +// UNSUPPORTED: amdgcn-amd-amdhsa-LTO + +#include +#include + +int main(int argc, char *argv[]) { + int data[1024]; +#pragma omp target + { + double start = omp_get_wtime(); + for (int i = 0; i < 1024; ++i) + data[i] = i; + double end = omp_get_wtime(); + double duration = end - start; + printf("duration: %lfs\n", duration); + } + return 0; +} + +// CHECK: duration: [1-9]+