Skip to content

Commit cf829e0

Browse files
authored
[syclcompat][CUDA] FIX UB in test / seq_cst requires sm_70 on CUDA (#12575)
Fix UB in test by using a single thread task. A shared USM variable was being simultaneously written to by multiple threads without using atomics. AFAIK this is generally not a well defined program, and was leading to invalid values. seq_cst also requires sm_70 on CUDA, so the compilation invocation is updated to reflect this. The CI device is >= sm_70 so it can use seq_cst. However this test did not compile for >=sm_70. Signed-off-by: JackAKirk <[email protected]>
1 parent d018b31 commit cf829e0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sycl/test-e2e/syclcompat/atomic/atomic_class.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
// UNSUPPORTED: hip || (windows && level_zero)
3434

35-
// RUN: %clangxx -std=c++20 -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out
35+
// RUN: %clangxx -std=c++20 -fsycl -fsycl-targets=%{sycl_triple} %if any-device-is-cuda %{ -Xsycl-target-backend --cuda-gpu-arch=sm_70 %} %s -o %t.out
3636
// RUN: %{run} %t.out
3737

3838
#include <sycl/sycl.hpp>
@@ -41,8 +41,8 @@
4141
#include "../common.hpp"
4242
#include "atomic_fixt.hpp"
4343

44-
constexpr size_t numBlocks = 64;
45-
constexpr size_t numThreads = 256;
44+
constexpr size_t numBlocks = 1;
45+
constexpr size_t numThreads = 1;
4646
constexpr size_t numData = 6;
4747

4848
template <typename T, typename AtomicType>

sycl/test-e2e/syclcompat/atomic/atomic_memory_acq_rel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
// UNSUPPORTED: hip
3434

35-
// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out
35+
// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %if any-device-is-cuda %{ -Xsycl-target-backend --cuda-gpu-arch=sm_70 %} %s -o %t.out
3636
// RUN: %{run} %t.out
3737

3838
#include <iostream>

0 commit comments

Comments
 (0)