Skip to content

Commit 436e687

Browse files
authored
[ESIMD][NFC][E2E] Fix 570 compilation warnings in ESIMD E2E tests (#12748)
Warnings fixed: - deprecated scatter_rgba - deprecated get_cl_code - deprecated lsc_fence - deprecated uchar type usage - deprecated get_access on HOST - deprecated get_pointer - usage of isfinite with -ffast-math - deprecated dpas_argument_type::s1 - deprecated gpu_selector() Also, the memory alloc/free in historgram*.cpp tests were updated to simplify the potential memory leak avoidance. Signed-off-by: Klochkov, Vyacheslav N <[email protected]>
1 parent 5fae0aa commit 436e687

30 files changed

+219
-273
lines changed

sycl/test-e2e/ESIMD/accessor_global.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: %{build} -fsycl-esimd-force-stateless-mem -o %t.out
33
// RUN: %{run} %t.out
44

5-
// This test verifies usage of accessor methods operator[] and get_pointer().
5+
// This test verifies usage of accessor methods operator[] and get_multi_ptr().
66

77
#include "esimd_test_utils.hpp"
88

@@ -39,7 +39,8 @@ bool test(queue Q, uint32_t LocalRange, uint32_t GlobalRange) {
3939
for (int I = 0; I < VL; I++)
4040
TmpAcc[GID * VL + I] = GID * 100 + I;
4141
} else {
42-
T *Ptr = TmpAcc.get_pointer();
42+
T *Ptr =
43+
TmpAcc.template get_multi_ptr<access::decorated::yes>().get();
4344
simd<int, VL> IntValues(GID * 100, 1);
4445
simd<T, VL> Values = IntValues;
4546
block_store(Ptr + GID * VL, Values);
@@ -53,12 +54,13 @@ bool test(queue Q, uint32_t LocalRange, uint32_t GlobalRange) {
5354
for (int I = 0; I < VL; I++)
5455
Out[(GID + LID) * VL + I] = TmpAcc[(GID + LID) * VL + I];
5556
} else {
56-
T *Ptr = TmpAcc.get_pointer();
57+
T *Ptr = TmpAcc.template get_multi_ptr<access::decorated::yes>()
58+
.get();
5759
simd<T, VL> Values = block_load<T, VL>(Ptr + (GID + LID) * VL);
5860
Values.template copy_to(Out + (GID + LID) * VL);
5961
}
6062
} // end for (int LID = 0; LID < LocalRange; LID++)
61-
} // end if (LID == 0)
63+
} // end if (LID == 0)
6264
});
6365
}).wait();
6466
} catch (sycl::exception const &e) {

sycl/test-e2e/ESIMD/accessor_local.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ bool test(queue Q, uint32_t LocalRange, uint32_t GlobalRange) {
4343
CGH.parallel_for(NDRange, [=](nd_item<1> Item) SYCL_ESIMD_KERNEL {
4444
uint32_t GID = Item.get_global_id(0);
4545
uint32_t LID = Item.get_local_id(0);
46-
uint32_t LocalAccOffset = static_cast<uint32_t>(
47-
reinterpret_cast<std::uintptr_t>(LocalAcc.get_pointer().get()));
46+
uint32_t LocalAccOffset =
47+
static_cast<uint32_t>(reinterpret_cast<std::uintptr_t>(
48+
LocalAcc.template get_multi_ptr<access::decorated::yes>()
49+
.get()));
4850
if constexpr (TestSubscript) {
4951
for (int I = 0; I < VL; I++)
5052
LocalAcc[LID * VL + I] = GID * 100 + I;
@@ -67,7 +69,7 @@ bool test(queue Q, uint32_t LocalRange, uint32_t GlobalRange) {
6769
ValuesFromSLM.copy_to(Out + (GID + LID) * VL);
6870
}
6971
} // end for (int LID = 0; LID < LocalRange; LID++)
70-
} // end if (LID == 0)
72+
} // end if (LID == 0)
7173
});
7274
}).wait();
7375
} catch (sycl::exception const &e) {

sycl/test-e2e/ESIMD/api/simd_view_copy_move_assign.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using namespace sycl::ext::intel::esimd;
2424
template <unsigned VL, class T, class F>
2525
bool test(queue q, std::string str, F funcUnderTest) {
2626
std::cout << "Testing " << str << ", VL = " << VL << " ...\n";
27-
size_t Size = 4 * VL;
27+
constexpr size_t Size = 4 * VL;
2828
T A[Size];
2929
T B[Size];
3030
constexpr unsigned HalfVL = VL > 1 ? (VL / 2) : 1;

sycl/test-e2e/ESIMD/dpas/dpas_common.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ std::string toString(dpas_argument_type T) {
5151
return "bf16";
5252
case dpas_argument_type::tf32:
5353
return "tf32";
54-
case dpas_argument_type::s1:
55-
case dpas_argument_type::u1:
56-
case dpas_argument_type::Invalid:
54+
default:
5755
return "UNSUPPORTED";
5856
}
5957
return "UNRECOGNIZED";
@@ -127,9 +125,7 @@ template <dpas_argument_type T> constexpr int getBitSize() {
127125
case dpas_argument_type::tf32:
128126
return 32;
129127

130-
case dpas_argument_type::Invalid:
131-
case dpas_argument_type::s1:
132-
case dpas_argument_type::u1:
128+
default:
133129
break;
134130
}
135131
return 0;
@@ -405,7 +401,7 @@ bool test(queue &Q, bool Print) {
405401
<< ") != expected (" << GoldRes << ")" << std::endl;
406402
}
407403
} // end for JJ
408-
} // end for II
404+
} // end for II
409405

410406
free(Res, Q);
411407
free(APacked, Q);

sycl/test-e2e/ESIMD/esimd_test_utils.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ using namespace sycl;
2727

2828
namespace esimd_test {
2929

30+
template <typename T>
31+
using shared_allocator = sycl::usm_allocator<T, sycl::usm::alloc::shared>;
32+
template <typename T> using shared_vector = std::vector<T, shared_allocator<T>>;
33+
3034
// This is the function provided to SYCL runtime by the application to decide
3135
// on which device to run, or whether to run at all.
3236
// When selecting a device, SYCL runtime first takes (1) a selector provided by

sycl/test-e2e/ESIMD/ext_math.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,10 @@ bool test(queue &Q, const std::string &Name, InitF Init = InitNarrow<T>{},
388388
if constexpr (sizeof(T) <= 2)
389389
delta = delta + delta;
390390

391-
bool BothFinite = std::isfinite(Test) && std::isfinite(Gold);
391+
bool BothFinite = true;
392+
#ifndef TEST_FAST_MATH
393+
BothFinite = std::isfinite(Test) && std::isfinite(Gold);
394+
#endif
392395
if (BothFinite && std::abs(Test - Gold) > delta) {
393396
if (++ErrCnt < 10) {
394397
std::cout << " failed at index " << I << ", " << Test

sycl/test-e2e/ESIMD/grf.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,10 @@ int main(void) {
7171
A[i] = i;
7272
}
7373

74+
queue q(esimd_test::ESIMDSelector, esimd_test::createExceptionHandler());
75+
esimd_test::printTestLabel(q);
7476
try {
7577
buffer<float, 1> bufa(A.data(), range<1>(Size));
76-
queue q(gpu_selector{}, esimd_test::createExceptionHandler());
77-
78-
auto dev = q.get_device();
79-
std::cout << "Running on " << dev.get_info<info::device::name>() << "\n";
80-
8178
auto e = q.submit([&](handler &cgh) {
8279
auto PA = bufa.get_access<access::mode::read_write>(cgh);
8380
cgh.parallel_for<class SyclKernel>(Size,
@@ -98,11 +95,6 @@ int main(void) {
9895

9996
try {
10097
buffer<float, 1> bufa(A.data(), range<1>(Size));
101-
queue q(esimd_test::ESIMDSelector, esimd_test::createExceptionHandler());
102-
103-
auto dev = q.get_device();
104-
std::cout << "Running on " << dev.get_info<info::device::name>() << "\n";
105-
10698
auto e = q.submit([&](handler &cgh) {
10799
auto PA = bufa.get_access<access::mode::read_write>(cgh);
108100
cgh.parallel_for<class EsimdKernel>(Size, [=](id<1> i) SYCL_ESIMD_KERNEL {
@@ -128,7 +120,6 @@ int main(void) {
128120

129121
try {
130122
buffer<float, 1> bufa(A.data(), range<1>(Size));
131-
queue q(esimd_test::ESIMDSelector, esimd_test::createExceptionHandler());
132123
#ifdef USE_AUTO
133124
sycl::ext::oneapi::experimental::properties prop{grf_size_automatic};
134125
#elif defined(USE_NEW_API)
@@ -137,9 +128,6 @@ int main(void) {
137128
sycl::ext::oneapi::experimental::properties prop{
138129
register_alloc_mode<register_alloc_mode_enum::large>};
139130
#endif
140-
auto dev = q.get_device();
141-
std::cout << "Running on " << dev.get_info<info::device::name>() << "\n";
142-
143131
auto e = q.submit([&](handler &cgh) {
144132
auto PA = bufa.get_access<access::mode::read_write>(cgh);
145133
cgh.parallel_for<class EsimdKernelSpecifiedGRF>(

sycl/test-e2e/ESIMD/histogram.cpp

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ int main(int argc, char *argv[]) {
8585

8686
// Allocate Input Buffer
8787
queue q = esimd_test::createQueue();
88+
esimd_test::printTestLabel(q);
8889

89-
auto dev = q.get_device();
90-
unsigned char *srcY = malloc_shared<unsigned char>(width * height, q);
91-
if (srcY == NULL) {
92-
std::cerr << "Out of memory\n";
93-
exit(1);
94-
}
95-
unsigned int *bins = malloc_shared<unsigned int>(NUM_BINS, q);
96-
std::cout << "Running on " << dev.get_info<info::device::name>() << "\n";
90+
esimd_test::shared_vector<uint8_t> srcY_vec(
91+
width * height, esimd_test::shared_allocator<uint8_t>{q});
92+
esimd_test::shared_vector<unsigned int> bins_vec(
93+
NUM_BINS, esimd_test::shared_allocator<unsigned int>{q});
94+
uint8_t *srcY = srcY_vec.data();
95+
;
96+
unsigned int *bins = bins_vec.data();
9797

9898
uint range_width = width / BLOCK_WIDTH;
9999
uint range_height = height / BLOCK_HEIGHT;
@@ -106,16 +106,12 @@ int main(int argc, char *argv[]) {
106106
FILE *f = fopen(input_file, "rb");
107107
if (f == NULL) {
108108
std::cerr << "Error opening file " << input_file;
109-
free(srcY, q);
110-
free(bins, q);
111109
std::exit(1);
112110
}
113111

114112
unsigned int cnt = fread(srcY, sizeof(unsigned char), input_size, f);
115113
if (cnt != input_size) {
116114
std::cerr << "Error reading input from " << input_file;
117-
free(srcY, q);
118-
free(bins, q);
119115
std::exit(1);
120116
}
121117
} else {
@@ -171,18 +167,17 @@ int main(int argc, char *argv[]) {
171167
uint h_pos = (tid % range_width) * BLOCK_WIDTH;
172168
uint v_pos = (tid / range_width) * BLOCK_HEIGHT;
173169

174-
// Declare a 8x32 uchar matrix to store the input block pixel
170+
// Declare a 8x32 uint8_t matrix to store the input block pixel
175171
// value
176-
simd<unsigned char, 8 * 32> in;
172+
simd<uint8_t, 8 * 32> in;
177173

178174
// Declare a vector to store the local histogram
179175
simd<unsigned int, NUM_BINS> histogram(0);
180176

181177
// Each thread handles BLOCK_HEIGHTxBLOCK_WIDTH pixel block
182178
for (int y = 0; y < BLOCK_HEIGHT / 8; y++) {
183179
// Perform 2D media block read to load 8x32 pixel block
184-
in = media_block_load<unsigned char, 8, 32>(readAcc, h_pos,
185-
v_pos);
180+
in = media_block_load<uint8_t, 8, 32>(readAcc, h_pos, v_pos);
186181

187182
// Accumulate local histogram for each pixel value
188183
#pragma unroll
@@ -236,8 +231,6 @@ int main(int argc, char *argv[]) {
236231
// make sure data is given back to the host at the end of this scope
237232
} catch (sycl::exception const &e) {
238233
std::cerr << "SYCL exception caught: " << e.what() << '\n';
239-
free(srcY, q);
240-
free(bins, q);
241234
return 1;
242235
}
243236

@@ -251,8 +244,6 @@ int main(int argc, char *argv[]) {
251244
writeHist(cpuHistogram);
252245
// Checking Histogram
253246
bool Success = checkHistogram(cpuHistogram, bins);
254-
free(srcY, q);
255-
free(bins, q);
256247

257248
if (!Success) {
258249
std::cerr << "FAILED\n";

sycl/test-e2e/ESIMD/histogram_256_slm.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ ESIMD_INLINE void histogram_atomic(const uint32_t *input_ptr, uint32_t *output,
4545
auto start_addr = ((unsigned int *)input_ptr) + start_off;
4646
simd<uint, 32> data;
4747
data.copy_from(start_addr);
48-
auto in = data.bit_cast_view<uchar>();
48+
auto in = data.bit_cast_view<uint8_t>();
4949

5050
#pragma unroll
5151
for (int j = 0; j < BLOCK_WIDTH * sizeof(int); j += 16) {
@@ -75,7 +75,7 @@ void HistogramCPU(unsigned int size, unsigned int *src,
7575
unsigned int *cpu_histogram) {
7676
for (int i = 0; i < size; i++) {
7777
unsigned int x = src[i];
78-
cpu_histogram[(x)&0xFFU] += 1;
78+
cpu_histogram[(x) & 0xFFU] += 1;
7979
cpu_histogram[(x >> 8) & 0xFFU] += 1;
8080
cpu_histogram[(x >> 16) & 0xFFU] += 1;
8181
cpu_histogram[(x >> 24) & 0xFFU] += 1;
@@ -104,14 +104,18 @@ int CheckHistogram(unsigned int *cpu_histogram, unsigned int *gpu_histogram) {
104104

105105
int main() {
106106
queue q = esimd_test::createQueue();
107+
esimd_test::printTestLabel(q);
107108

108109
const char *input_file = nullptr;
109110
unsigned int width = 1024;
110111
unsigned int height = 1024;
111112

112113
// Initializes input.
113114
unsigned int input_size = width * height;
114-
unsigned int *input_ptr = malloc_shared<unsigned int>(input_size, q);
115+
116+
esimd_test::shared_vector<unsigned int> input_vec(
117+
input_size, esimd_test::shared_allocator<unsigned int>{q});
118+
unsigned int *input_ptr = input_vec.data();
115119
printf("Processing %dx%d inputs\n", width, height);
116120

117121
srand(2009);
@@ -124,13 +128,8 @@ int main() {
124128

125129
// Allocates system memory for output buffer.
126130
int buffer_size = sizeof(unsigned int) * NUM_BINS;
127-
unsigned int *hist = new unsigned int[buffer_size];
128-
if (hist == nullptr) {
129-
free(input_ptr, q);
130-
std::cerr << "Out of memory\n";
131-
exit(1);
132-
}
133-
memset(hist, 0, buffer_size);
131+
std::vector<unsigned int> hist_vec(buffer_size, 0);
132+
unsigned int *hist = hist_vec.data();
134133

135134
// Uses the CPU to calculate the histogram output data.
136135
unsigned int cpu_histogram[NUM_BINS];
@@ -141,7 +140,9 @@ int main() {
141140
std::cout << "finish cpu_histogram\n";
142141

143142
// Uses the GPU to calculate the histogram output data.
144-
unsigned int *output_surface = malloc_shared<unsigned int>(NUM_BINS, q);
143+
esimd_test::shared_vector<unsigned int> output_vec(
144+
NUM_BINS, esimd_test::shared_allocator<unsigned int>{q});
145+
unsigned int *output_surface = output_vec.data();
145146

146147
unsigned int num_threads;
147148
num_threads = width * height / (NUM_BLOCKS * BLOCK_WIDTH);
@@ -194,9 +195,6 @@ int main() {
194195

195196
memcpy(hist, output_surface, 4 * NUM_BINS);
196197

197-
free(output_surface, q);
198-
free(input_ptr, q);
199-
200198
// Compares the CPU histogram output data with the
201199
// GPU histogram output data.
202200
// If there is no difference, the result is correct.
@@ -207,7 +205,5 @@ int main() {
207205
else
208206
std::cout << "FAILED\n";
209207

210-
delete[] hist;
211-
212208
return res ? 0 : -1;
213209
}

0 commit comments

Comments
 (0)