[Openmp-commits] [openmp] 459e3c5 - [OpenMP] Fix the test case issue that printf cannot be used in target region for AMDGPU

Shilei Tian via Openmp-commits openmp-commits at lists.llvm.org
Thu Aug 4 11:48:54 PDT 2022


Author: Shilei Tian
Date: 2022-08-04T14:48:48-04:00
New Revision: 459e3c51840a7f09536a7839deb7184b53bd7e92

URL: https://github.com/llvm/llvm-project/commit/459e3c51840a7f09536a7839deb7184b53bd7e92
DIFF: https://github.com/llvm/llvm-project/commit/459e3c51840a7f09536a7839deb7184b53bd7e92.diff

LOG: [OpenMP] Fix the test case issue that printf cannot be used in target region for AMDGPU

Added: 
    

Modified: 
    openmp/libomptarget/test/offloading/test_libc.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/test/offloading/test_libc.cpp b/openmp/libomptarget/test/offloading/test_libc.cpp
index cfccf47d7cf2..66d73d7b3e2b 100644
--- a/openmp/libomptarget/test/offloading/test_libc.cpp
+++ b/openmp/libomptarget/test/offloading/test_libc.cpp
@@ -6,16 +6,17 @@ extern "C" int printf(const char *, ...);
 
 // std::equal is lowered to libc function memcmp.
 void test_memcpy() {
-#pragma omp target
+  int r = 0;
+#pragma omp target map(from: r)
   {
     int x[2] = {0, 0};
     int y[2] = {0, 0};
     int z[2] = {0, 1};
     bool eq1 = std::equal(x, x + 2, y);
     bool eq2 = std::equal(x, x + 2, z);
-    bool r = eq1 && !eq2;
-    printf("memcmp: %s\n", r ? "PASS" : "FAIL");
+    r = eq1 && !eq2;
   }
+  printf("memcmp: %s\n", r ? "PASS" : "FAIL");
 }
 
 int main(int argc, char *argv[]) {


        


More information about the Openmp-commits mailing list