Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Change check_device_code HIP tests to use SYCL_EXTERNAL #13990

Merged
merged 6 commits into from
Jun 10, 2024

Conversation

ianayl
Copy link
Contributor

@ianayl ianayl commented May 31, 2024

Changed the HIP sycl/test/check_device_code lit tests to use SYCL_EXTERNAL functions instead of writing entire programs.

@ianayl ianayl requested a review from a team as a code owner May 31, 2024 16:06
Copy link
Contributor

@konradkusiak97 konradkusiak97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@hdelan
Copy link
Contributor

hdelan commented Jun 5, 2024

diff --git a/sycl/test/check_device_code/hip/atomic/amdgpu_unsafe_atomics.cpp b/sycl/test/check_device_code/hip/atomic/amdgpu_unsafe_atomics.cpp
index 0b78738a0151..4856f3bcba1a 100644
--- a/sycl/test/check_device_code/hip/atomic/amdgpu_unsafe_atomics.cpp
+++ b/sycl/test/check_device_code/hip/atomic/amdgpu_unsafe_atomics.cpp
@@ -5,45 +5,37 @@
 
 #include <sycl/sycl.hpp>
 
-class intKernel;
-class fpKernel;
+SYCL_EXTERNAL void intAtomicFunc(int *i) {
+  sycl::atomic_ref<int, sycl::memory_order_relaxed, sycl::memory_scope_device>
+      atomicInt(*i);
+  atomicInt.fetch_xor(1);
+  atomicInt.fetch_and(1);
+  atomicInt.fetch_or(1);
+  // CHECK: void{{.*}}intAtomicFunc
+  // CHECK-SAFE: cmpxchg volatile
+  // CHECK-SAFE-NOT: atomicrmw
+  // CHECK-UNSAFE: atomicrmw volatile xor
+  // CHECK-UNSAFE: atomicrmw volatile and
+  // CHECK-UNSAFE: atomicrmw volatile or
+  // CHECK-UNSAFE-NOT: cmpxchg
+}
 
-int main() {
-  int *i;
-  float *f;
-  double *d;
-  sycl::queue{}.single_task<intKernel>([=] {
-    sycl::atomic_ref<int, sycl::memory_order_relaxed, sycl::memory_scope_device>
-        atomicInt(*i);
-    atomicInt.fetch_xor(1);
-    atomicInt.fetch_and(1);
-    atomicInt.fetch_or(1);
-    // CHECK: amdgpu_kernel void{{.*}}intKernel
-    // CHECK-SAFE: cmpxchg volatile
-    // CHECK-SAFE-NOT: atomicrmw
-    // CHECK-UNSAFE: atomicrmw volatile xor
-    // CHECK-UNSAFE: atomicrmw volatile and
-    // CHECK-UNSAFE: atomicrmw volatile or
-    // CHECK-UNSAFE-NOT: cmpxchg
-  });
-  sycl::queue{}.single_task<fpKernel>([=] {
-    sycl::atomic_ref<float, sycl::memory_order_relaxed,
-                     sycl::memory_scope_device,
-                     sycl::access::address_space::global_space>(*f)
-        .fetch_add(1.0f);
-    // CHECK: amdgpu_kernel void{{.*}}fpKernel
-    // CHECK-SAFE: atomicrmw volatile fadd
-    // CHECK-SAFE-NOT: llvm.amdgcn.global.atomic.fadd.f32
-    // CHECK-UNSAFE-FP: llvm.amdgcn.global.atomic.fadd.f32
-    // CHECK-UNSAFE-FP-NOT: atomicrmw volatile fadd
-    sycl::atomic_ref<double, sycl::memory_order_relaxed,
-                     sycl::memory_scope_device,
-                     sycl::access::address_space::global_space>(*d)
-        .fetch_add(1.0);
-    // CHECK-SAFE: cmpxchg
-    // CHECK-SAFE-NOT: llvm.amdgcn.global.atomic.fadd.f64
-    // CHECK-UNSAFE-FP: llvm.amdgcn.global.atomic.fadd.f64
-    // CHECK-UNSAFE-FP-NOT: cmpxchg
-    // CHECK: __CLANG_OFFLOAD_BUNDLE____END__ sycl-amdgcn-amd-amdhsa-
-  });
+SYCL_EXTERNAL void fpAtomicFunc(float *f, double *d) {
+  sycl::atomic_ref<float, sycl::memory_order_relaxed, sycl::memory_scope_device,
+                   sycl::access::address_space::global_space>(*f)
+      .fetch_add(1.0f);
+  // CHECK: void{{.*}}fpAtomicFunc
+  // CHECK-SAFE: atomicrmw volatile fadd
+  // CHECK-SAFE-NOT: llvm.amdgcn.global.atomic.fadd.f32
+  // CHECK-UNSAFE-FP: llvm.amdgcn.global.atomic.fadd.f32
+  // CHECK-UNSAFE-FP-NOT: atomicrmw volatile fadd
+  sycl::atomic_ref<double, sycl::memory_order_relaxed,
+                   sycl::memory_scope_device,
+                   sycl::access::address_space::global_space>(*d)
+      .fetch_add(1.0);
+  // CHECK-SAFE: cmpxchg
+  // CHECK-SAFE-NOT: llvm.amdgcn.global.atomic.fadd.f64
+  // CHECK-UNSAFE-FP: llvm.amdgcn.global.atomic.fadd.f64
+  // CHECK-UNSAFE-FP-NOT: cmpxchg
+  // CHECK: __CLANG_OFFLOAD_BUNDLE____END__ sycl-amdgcn-amd-amdhsa-
 }

This should work for the new changes in amdgpu_unsafe_atomics.cpp

@ianayl ianayl changed the title [SYCL] change check_device_code HIP tests to use SYCL_EXTERNAL [SYCL] Change check_device_code HIP tests to use SYCL_EXTERNAL Jun 6, 2024
@ianayl
Copy link
Contributor Author

ianayl commented Jun 6, 2024

@intel/llvm-reviewers-cuda The PR is ready, is there anything else I need to do to get it merged?

Thanks!

@konradkusiak97
Copy link
Contributor

Looks good to me. Please merge the sycl tip into this branch again, that will hopefully make the CI green.

@ianayl
Copy link
Contributor Author

ianayl commented Jun 7, 2024

@konradkusiak97 I've merged sycl into the branch again, can you run the CI again? Thanks!

@konradkusiak97
Copy link
Contributor

@intel/llvm-gatekeepers please merge

@sommerlukas
Copy link
Contributor

@ianayl you need to update your Github profile settings to include your mail address in PRs.

Otherwise it will say

This commit will be authored by 54701975+ianayl@users.noreply.github.com

Akin to upstream LLVM policy, we don't allow commits with those mail addresses.

@ianayl
Copy link
Contributor Author

ianayl commented Jun 10, 2024

@sommerlukas My bad! It's public now. I wouldn't need to redo my commits would I?

@sommerlukas sommerlukas merged commit 849299f into intel:sycl Jun 10, 2024
13 checks passed
@sommerlukas
Copy link
Contributor

@sommerlukas My bad! It's public now. I wouldn't need to redo my commits would I?

No, the commit resulting from "Squash and Merge" now has the correct author mail address after you changed the setttings, no worries.

I merged the PR now.

@ianayl
Copy link
Contributor Author

ianayl commented Jun 10, 2024

Thanks!

ianayl added a commit to ianayl/sycl that referenced this pull request Jun 13, 2024
…#13990)

Changed the HIP sycl/test/check_device_code lit tests to use
SYCL_EXTERNAL functions instead of writing entire programs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants