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

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 15 08:10:45 PDT 2021


yaxunl created this revision.
yaxunl added reviewers: tra, ashi1.
Herald added subscribers: guansong, mgorny.
yaxunl requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

Add a test to test-suite for testing std::isnan in host and device functions
when compiled with -fopenmp.


Repository:
  rT test-suite

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.358970.patch
Type: text/x-patch
Size: 1681 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210715/333d952b/attachment-0001.bin>


More information about the cfe-commits mailing list