Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 7bf4f96

Browse files
authored
[ESIMD] Add tests for ESIMD memory functions accepting 64 bit offsets (#1385)
1 parent 0db4626 commit 7bf4f96

34 files changed

+467
-15
lines changed

SYCL/ESIMD/Stencil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ int main(int argc, char *argv[]) {
176176

177177
simd<unsigned, WIDTH> elm16_off =
178178
elm16 * sizeof(float) + out_off;
179-
scatter<float, WIDTH>(outputMatrix, sum, elm16_off, p);
179+
scatter<float, WIDTH>(outputMatrix, elm16_off, sum, p);
180180
out_off += DIM_SIZE * sizeof(float);
181181

182182
if (v_pos * HEIGHT + 10 + i >= DIM_SIZE - 1)

SYCL/ESIMD/api/esimd_rgba_smoke.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919

2020
#include <iostream>
2121

22+
#ifdef USE_64_BIT_OFFSET
23+
typedef uint64_t Toffset;
24+
#else
25+
typedef uint32_t Toffset;
26+
#endif
27+
2228
using namespace sycl;
2329
using namespace sycl::ext::intel::esimd;
2430

@@ -71,7 +77,8 @@ bool test_impl(queue q) {
7177

7278
std::cout << "Testing mask=";
7379
print_mask(ChMask);
74-
std::cout << ", T=" << typeid(T).name() << ", NPixels=" << NPixels << "\n";
80+
std::cout << ", T=" << esimd_test::type_name<T>() << ", NPixels=" << NPixels
81+
<< "\n";
7582

7683
T *A = malloc_shared<T>(Size, q);
7784
T *B = malloc_shared<T>(Size, q);
@@ -92,7 +99,7 @@ bool test_impl(queue q) {
9299
cgh.single_task<TestID<T, NPixels, static_cast<int>(ChMask)>>(
93100
[=]() SYCL_ESIMD_KERNEL {
94101
constexpr unsigned NElems = NPixels * NOnChs;
95-
simd<unsigned int, NPixels> offsets(0, sizeof(T) * NAllChs);
102+
simd<Toffset, NPixels> offsets(0, sizeof(T) * NAllChs);
96103
simd<T, NElems> p = gather_rgba<ChMask>(A, offsets);
97104
// simply scatter back to B - should give same results as A in
98105
// enabled channels, the rest should remain zero:
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//==---------------- esimd_rgba_smoke_64.cpp - DPC++ ESIMD on-device test -==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// REQUIRES: gpu
9+
// UNSUPPORTED: cuda || hip
10+
// RUN: %clangxx -fsycl %s -o %t.out
11+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
12+
13+
// Smoke test for scatter/gather also illustrating correct use of these APIs
14+
// 64 bit offset variant of the test - uses 64 bit offsets.
15+
16+
#define USE_64_BIT_OFFSET
17+
18+
#include "esimd_rgba_smoke.cpp"

SYCL/ESIMD/api/svm_gather_scatter.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ using namespace sycl::ext::intel::esimd;
2828
using bfloat16 = sycl::ext::oneapi::bfloat16;
2929
using tfloat32 = sycl::ext::intel::experimental::esimd::tfloat32;
3030

31+
#ifdef USE_64_BIT_OFFSET
32+
typedef uint64_t Toffset;
33+
#else
34+
typedef uint32_t Toffset;
35+
#endif
36+
3137
template <typename T, int N> bool test(queue &Q) {
3238
std::cout << " Running " << esimd_test::type_name<T>() << " test, N=" << N
3339
<< "...\n";
@@ -55,7 +61,7 @@ template <typename T, int N> bool test(queue &Q) {
5561
try {
5662
Q.submit([&](handler &CGH) {
5763
CGH.parallel_for(sycl::range<1>{1}, [=](id<1>) SYCL_ESIMD_KERNEL {
58-
simd<uint32_t, N> Offsets(0u, sizeof(T));
64+
simd<Toffset, N> Offsets(0u, sizeof(T));
5965
scatter<T, N>(Dst, Offsets, gather<T, N>(Src, Offsets));
6066
});
6167
}).wait();
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//==---------- svm_gather_scatter_64.cpp - DPC++ ESIMD on-device test -==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// REQUIRES: gpu && !gpu-intel-pvc
9+
// UNSUPPORTED: cuda || hip
10+
// RUN: %clangxx -fsycl %s -o %t.out
11+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
12+
13+
// Regression test for gather/scatter API.
14+
// 64 bit offset variant of the test - uses 64 bit offsets.
15+
16+
#define USE_64_BIT_OFFSET
17+
18+
#include "svm_gather_scatter.cpp"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//==---------- svm_gather_scatter_pvc_64.cpp - DPC++ ESIMD on-device test -==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// REQUIRES: gpu-intel-pvc
9+
// RUN: %clangxx -fsycl %s -o %t.out
10+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
11+
12+
// Regression test for SVM gather/scatter API.
13+
// PVC variant of the test - adds tfloat32 and uses 64 bit offsets.
14+
15+
#define USE_TF32
16+
#define USE_64_BIT_OFFSET
17+
18+
#include "svm_gather_scatter.cpp"

SYCL/ESIMD/histogram.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ using namespace sycl;
2828
#define BLOCK_WIDTH 32
2929
#define BLOCK_HEIGHT 64
3030

31+
#ifdef USE_64_BIT_OFFSET
32+
typedef uint64_t Toffset;
33+
#else
34+
typedef uint32_t Toffset;
35+
#endif
36+
3137
void histogram_CPU(unsigned int width, unsigned int height, unsigned char *srcY,
3238
unsigned int *cpuHistogram) {
3339
int i;
@@ -191,7 +197,7 @@ int main(int argc, char *argv[]) {
191197
}
192198

193199
// Declare a vector to store the offset for atomic write operation
194-
simd<unsigned int, 8> offset(0, 1); // init to 0, 1, 2, ..., 7
200+
simd<Toffset, 8> offset(0, 1); // init to 0, 1, 2, ..., 7
195201
offset *= sizeof(unsigned int);
196202

197203
// Update global sum by atomically adding each local histogram

SYCL/ESIMD/histogram_2d.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ using namespace sycl;
2828
#define BLOCK_WIDTH 32
2929
#define BLOCK_HEIGHT 64
3030

31+
#ifdef USE_64_BIT_OFFSET
32+
typedef uint64_t Toffset;
33+
#else
34+
typedef uint32_t Toffset;
35+
#endif
36+
3137
void histogram_CPU(unsigned int width, unsigned int height, unsigned char *srcY,
3238
unsigned int *cpuHistogram) {
3339
int i;
@@ -193,7 +199,7 @@ int main(int argc, char *argv[]) {
193199
}
194200

195201
// Declare a vector to store the offset for atomic write operation
196-
simd<unsigned int, 8> offset(0, 1); // init to 0, 1, 2, ..., 7
202+
simd<Toffset, 8> offset(0, 1); // init to 0, 1, 2, ..., 7
197203
offset *= sizeof(unsigned int);
198204

199205
// Update global sum by atomically adding each local histogram

SYCL/ESIMD/histogram_2d_64.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//==---------------- histogram_2d_64.cpp - DPC++ ESIMD on-device test -----==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// REQUIRES: gpu
9+
// UNSUPPORTED: cuda || hip
10+
// RUN: %clangxx -fsycl %s -o %t.out
11+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
12+
//
13+
// 64 bit offset variant of the test - uses 64 bit offsets.
14+
15+
#define USE_64_BIT_OFFSET
16+
17+
#include "histogram_2d.cpp"

SYCL/ESIMD/histogram_64.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//==---------------- histogram_64.cpp - DPC++ ESIMD on-device test ------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// REQUIRES: gpu
9+
// UNSUPPORTED: cuda || hip
10+
// RUN: %clangxx -fsycl %s -o %t.out
11+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
12+
//
13+
// 64 bit offset variant of the test - uses 64 bit offsets.
14+
15+
#define USE_64_BIT_OFFSET
16+
17+
#include "histogram.cpp"

SYCL/ESIMD/lsc/Inputs/lsc_usm_load.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ using namespace sycl;
1717
using namespace sycl::ext::intel::esimd;
1818
using namespace sycl::ext::intel::experimental::esimd;
1919

20+
#ifdef USE_64_BIT_OFFSET
21+
typedef uint64_t Toffset;
22+
#else
23+
typedef uint32_t Toffset;
24+
#endif
25+
2026
template <int case_num, typename T, uint32_t Groups, uint32_t Threads,
2127
uint16_t VL, uint16_t VS, bool transpose,
2228
lsc_data_size DS = lsc_data_size::default_size,
@@ -89,7 +95,7 @@ bool test(uint32_t pmask = 0xffffffff) {
8995
lsc_block_store<T, VS, lsc_data_size::default_size>(
9096
out + elem_off, vals);
9197
} else {
92-
simd<uint32_t, VL> offset(byte_off, VS * sizeof(T));
98+
simd<Toffset, VL> offset(byte_off, VS * sizeof(T));
9399
simd_mask<VL> pred;
94100
for (int i = 0; i < VL; i++)
95101
pred.template select<1, 1>(i) = (pmask >> i) & 1;

SYCL/ESIMD/lsc/Inputs/lsc_usm_store.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ using namespace sycl;
1717
using namespace sycl::ext::intel::esimd;
1818
using namespace sycl::ext::intel::experimental::esimd;
1919

20+
#ifdef USE_64_BIT_OFFSET
21+
typedef uint64_t Toffset;
22+
#else
23+
typedef uint32_t Toffset;
24+
#endif
25+
2026
template <int case_num, typename T, uint32_t Groups, uint32_t Threads,
2127
uint16_t VL, uint16_t VS, bool transpose,
2228
lsc_data_size DS = lsc_data_size::default_size,
@@ -78,7 +84,7 @@ bool test(uint32_t pmask = 0xffffffff) {
7884
simd<T, VS> vals(new_val + elem_off, 1);
7985
lsc_block_store<T, VS, DS, L1H, L3H>(out + elem_off, vals);
8086
} else {
81-
simd<uint32_t, VL> offset(byte_off, VS * sizeof(T));
87+
simd<Toffset, VL> offset(byte_off, VS * sizeof(T));
8288
simd_mask<VL> pred;
8389
for (int i = 0; i < VL; i++)
8490
pred.template select<1, 1>(i) = (pmask >> i) & 1;

SYCL/ESIMD/lsc/atomic_smoke.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ using namespace sycl;
2323
using namespace sycl::ext::intel::esimd;
2424
using namespace sycl::ext::intel::experimental::esimd;
2525

26+
#ifdef USE_64_BIT_OFFSET
27+
typedef uint64_t Toffset;
28+
#else
29+
typedef uint32_t Toffset;
30+
#endif
31+
2632
struct Config {
2733
int threads_per_group;
2834
int n_groups;
@@ -210,8 +216,8 @@ bool test(queue q, const Config &cfg) {
210216
cgh.parallel_for<TestID<T, N, ImplF>>(
211217
rng, [=](id<1> ii) SYCL_ESIMD_KERNEL {
212218
int i = ii;
213-
simd<unsigned, N> offsets(cfg.start_ind * sizeof(T),
214-
cfg.stride * sizeof(T));
219+
simd<Toffset, N> offsets(cfg.start_ind * sizeof(T),
220+
cfg.stride * sizeof(T));
215221
simd_mask<N> m = 1;
216222
m[cfg.masked_lane] = 0;
217223
// barrier to achieve better contention:

SYCL/ESIMD/lsc/atomic_smoke_64.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//==---------------- atomic_smoke_64.cpp - DPC++ ESIMD on-device test -----==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// This test checks LSC atomic operations.
9+
//===----------------------------------------------------------------------===//
10+
// REQUIRES: gpu-intel-pvc
11+
// TODO: esimd_emulator fails due to random timeouts (_XFAIL_: esimd_emulator)
12+
// UNSUPPORTED: esimd_emulator
13+
// RUN: %clangxx -fsycl %s -o %t.out
14+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
15+
//
16+
// 64 bit offset variant of the test - uses 64 bit offsets.
17+
18+
#define USE_64_BIT_OFFSET
19+
20+
#include "atomic_smoke.cpp"

SYCL/ESIMD/lsc/lsc_usm.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
#include <sycl/ext/intel/esimd.hpp>
2020
#include <sycl/sycl.hpp>
2121

22+
#ifdef USE_64_BIT_OFFSET
23+
typedef uint64_t Toffset;
24+
#else
25+
typedef uint32_t Toffset;
26+
#endif
27+
2228
int main() {
2329
using namespace sycl;
2430
using namespace sycl::ext::intel::esimd;
@@ -48,8 +54,8 @@ int main() {
4854
h.parallel_for<class SimplestKernel>(
4955
range<1>{size / SIMDSize}, [=](id<1> id) SYCL_ESIMD_KERNEL {
5056
auto offset = id[0] * SIMDSize;
51-
auto offsets = simd<uint32_t, SIMDSize>(id * SIMDSize * sizeof(int),
52-
sizeof(int));
57+
auto offsets = simd<Toffset, SIMDSize>(id * SIMDSize * sizeof(int),
58+
sizeof(int));
5359
auto pred = simd_mask<SIMDSize>(1);
5460
auto add = simd<int, SIMDSize>(5);
5561
auto compare = simd<int, SIMDSize>(id * SIMDSize, 1);

SYCL/ESIMD/lsc/lsc_usm_64.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//==------------ lsc_usm_64.cpp - DPC++ ESIMD on-device test --------------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// REQUIRES: gpu-intel-pvc || esimd_emulator
9+
// UNSUPPORTED: cuda || hip
10+
// TODO : esimd_emulator does not support lsc-atomic yet
11+
// RUN: %clangxx -fsycl %s -o %t.out
12+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
13+
14+
#define USE_64_BIT_OFFSET
15+
16+
#include "lsc_usm.cpp"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//==--- lsc_usm_atomic_cachehint_64.cpp - DPC++ ESIMD on-device test -------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// REQUIRES: gpu-intel-pvc || esimd_emulator
9+
// UNSUPPORTED: cuda || hip
10+
// TODO : Test uses 'kernel_bundle' that is not supported in ESIMD_EMULATOR
11+
// XFAIL: esimd_emulator
12+
// RUN: %clangxx -fsycl %s -o %t.out
13+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
14+
// 64 bit offset variant of the test - uses 64 bit offsets.
15+
16+
#define USE_64_BIT_OFFSET
17+
18+
#include "lsc_usm_atomic_cachehint.cpp"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//==------- lsc_usm_load_u16u32_64.cpp - DPC++ ESIMD on-device test --------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// REQUIRES: gpu-intel-pvc || esimd_emulator
9+
// UNSUPPORTED: cuda || hip
10+
// RUN: %clangxx -fsycl %s -o %t.out
11+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
12+
13+
// 64 bit offset variant of the test - uses 64 bit offsets.
14+
15+
#define USE_64_BIT_OFFSET
16+
17+
#include "lsc_usm_load_u16u32.cpp"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//==------- lsc_usm_load_u32_64.cpp - DPC++ ESIMD on-device test -----------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// REQUIRES: gpu-intel-pvc || esimd_emulator
9+
// UNSUPPORTED: cuda || hip
10+
// RUN: %clangxx -fsycl %s -o %t.out
11+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
12+
13+
// 64 bit offset variant of the test - uses 64 bit offsets.
14+
15+
#define USE_64_BIT_OFFSET
16+
17+
#include "lsc_usm_load_u32.cpp"

0 commit comments

Comments
 (0)