[PATCH] D106069: [HIP] Add test with_fopenmp.hip

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 21 12:32:08 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rTd9107edc1a4e: [HIP] Add test with_fopenmp.hip (authored by yaxunl).

Repository:
  rT test-suite

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106069/new/

https://reviews.llvm.org/D106069

Files:
  External/HIP/CMakeLists.txt
  External/HIP/with-fopenmp.hip
  External/HIP/with-fopenmp.reference_output


Index: External/HIP/with-fopenmp.reference_output
===================================================================
--- /dev/null
+++ External/HIP/with-fopenmp.reference_output
@@ -0,0 +1,2 @@
+PASSED!
+exit 0
Index: External/HIP/with-fopenmp.hip
===================================================================
--- /dev/null
+++ External/HIP/with-fopenmp.hip
@@ -0,0 +1,33 @@
+#include <hip/hip_runtime.h>
+#include <cmath>
+
+// Test use of std::isnan in device and host code.
+
+namespace TestIsNan {
+__device__ bool DevPass = false;
+
+__global__ void kernel() {
+  double X = 1.0;
+  DevPass = !std::isnan(X);
+}
+
+bool test() {
+  double X = 1.0;
+  kernel<<<1, 1>>>();
+  bool Pass;
+  hipMemcpyFromSymbol(&Pass, DevPass, sizeof(DevPass));
+  return Pass & !std::isnan(X);
+}
+}
+
+int main() {
+  bool Pass = TestIsNan::test();
+
+  if (!Pass) {
+    printf("FAILED!\n");
+    return 1;
+  }
+
+  printf("PASSED!\n");
+  return 0;
+}
Index: External/HIP/CMakeLists.txt
===================================================================
--- External/HIP/CMakeLists.txt
+++ External/HIP/CMakeLists.txt
@@ -5,8 +5,12 @@
 # Create targets for HIP tests that are part of the test suite.
 macro(create_local_hip_tests VariantSuffix)
   set(VariantOffload "hip")
+  # Set per-source compilation/link options
+  set_source_files_properties(with_fopenmp.hip PROPERTIES
+    COMPILE_FLAGS -fopenmp)
   # Add HIP tests to be added to hip-tests-simple
   list(APPEND HIP_LOCAL_TESTS empty)
+  list(APPEND HIP_LOCAL_TESTS with_fopenmp)
   list(APPEND HIP_LOCAL_TESTS saxpy)
   foreach(_hip_test IN LISTS HIP_LOCAL_TESTS)
     create_one_local_test(${_hip_test} ${_hip_test}.hip


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106069.360559.patch
Type: text/x-patch
Size: 1681 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210721/162c6214/attachment.bin>


More information about the cfe-commits mailing list