Skip to content

Commit 3fea807

Browse files
[SYCL][E2E] Fix abs ambiguities ahead of changes to builtins (#10208)
Upcoming changes to SYCL builtins will cause code using namespace sycl implicitly to be ambiguous when using certain builtins that are available in the global scope already. This commit changes uses of `abs` to be namespace qualified to avoid them breaking with future builtin changes. --------- Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 276b9cf commit 3fea807

File tree

10 files changed

+14
-13
lines changed

10 files changed

+14
-13
lines changed

sycl/test-e2e/ESIMD/Stencil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bool CheckResults(float *out, float *in, unsigned n) {
5858
in[(i + 5) * n + (j + 0)] * 0.02f;
5959

6060
// check result
61-
if (abs(res - out[i * n + j]) >= 0.0015f) {
61+
if (std::abs(res - out[i * n + j]) >= 0.0015f) {
6262
std::cout << "out[" << i << "][" << j << "] = " << out[i * n + j]
6363
<< " expect result " << res << std::endl;
6464
return false;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ template <class T1, class T2, class OpClass> struct verify_n {
212212
using Tint = esimd_test::int_type_t<sizeof(T)>;
213213
Tint res_bits = *(Tint *)&res;
214214
Tint gold_bits = *(Tint *)&gold;
215-
return (abs(gold_bits - res_bits) > n) ? false : true;
215+
return (std::abs(gold_bits - res_bits) > n) ? false : true;
216216
}
217217
};
218218

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ bool test(Ops ops, queue &q) {
125125
? 1
126126
: 0;
127127

128-
if ((Gold != Res) && (abs(ResBits - GoldBits) > delta)) {
128+
if ((Gold != Res) && (std::abs(ResBits - GoldBits) > delta)) {
129129
if (++err_cnt < 10) {
130130
std::cout << " failed at index " << (res_off + j) << ", op "
131131
<< esimd_test::Op2Str(op) << ": " << cast(Res)

sycl/test-e2e/ESIMD/esimd_test_utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ bool cmp_binary_files(const char *testOutFile, const char *referenceFile,
149149
double maxRelativeDiff = 0;
150150
bool status = true;
151151
for (size_t i = 0; i < size; i++) {
152-
const auto diff = abs(testVec[i] - referenceVec[i]);
152+
const auto diff = std::abs(testVec[i] - referenceVec[i]);
153153
if (diff > tolerance) {
154154
if (!mismatchRateTolerance || (totalMismatches < mismatchReportLimit)) {
155155

sycl/test-e2e/ESIMD/ext_math.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ bool test(queue &Q, const std::string &Name,
377377
}
378378

379379
bool BothFinite = std::isfinite(Test) && std::isfinite(Gold);
380-
if (BothFinite && abs(Test - Gold) > delta) {
380+
if (BothFinite && std::abs(Test - Gold) > delta) {
381381
if (++ErrCnt < 10) {
382382
std::cout << " failed at index " << I << ", " << Test
383383
<< " != " << Gold << " (gold)\n";

sycl/test-e2e/ESIMD/kmeans/kmeans.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ bool verify_result(Centroid4 *centroids4, // gpu centroids result
8080
float errY = std::fabs(centroids4[j].y[k] - centroids[i].y) /
8181
max(std::fabs(centroids4[j].y[k]), std::fabs(centroids[i].y));
8282
float errSize =
83-
abs(centroids4[j].num_points[k] - centroids[i].num_points) /
84-
max(abs(centroids4[j].num_points[k]), abs(centroids[i].num_points));
83+
std::abs(centroids4[j].num_points[k] - centroids[i].num_points) /
84+
max(std::abs(centroids4[j].num_points[k]),
85+
std::abs(centroids[i].num_points));
8586
// std::cout << i << ": Wanted (" << centroids[i].x << ", " <<
8687
// centroids[i].y
8788
// << ", " << centroids[i].num_points << ")" << std::endl;

sycl/test-e2e/ESIMD/linear/bitmap_helpers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ __SYCL_INLINE_VER_NAMESPACE(_V1) {
255255
return false;
256256
}
257257

258-
width = abs(*(short *)&header_out[18]);
259-
height = abs(*(short *)&header_out[22]);
258+
width = std::abs(*(short *)&header_out[18]);
259+
height = std::abs(*(short *)&header_out[22]);
260260

261261
img_out = (unsigned char *)std::malloc(width * height * 3);
262262
img_gold = (unsigned char *)std::malloc(width * height * 3);
@@ -276,7 +276,7 @@ __SYCL_INLINE_VER_NAMESPACE(_V1) {
276276
fclose(f_gold);
277277

278278
for (i = 0; i < width * height * 3; i++) {
279-
if (abs(img_out[i] - img_gold[i]) > tolerance) {
279+
if (std::abs(img_out[i] - img_gold[i]) > tolerance) {
280280
return false;
281281
}
282282
}

sycl/test-e2e/ESIMD/stencil2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bool CheckResults(float *out, float *in, unsigned n) {
5959
in[(i + 5) * n + (j + 0)] * 0.02f;
6060

6161
// check result
62-
if (abs(res - out[i * n + j]) >= 0.0015f) {
62+
if (std::abs(res - out[i * n + j]) >= 0.0015f) {
6363
std::cout << "out[" << i << "][" << j << "] = " << out[i * n + j]
6464
<< " expect result " << res << std::endl;
6565
return false;

sycl/test-e2e/ESIMD/vadd_half.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ int main(int argc, char **argv) {
9898
Tint ResBits = *(Tint *)&Res;
9999
Tint GoldBits = *(Tint *)&Gold;
100100

101-
if (abs(ResBits - GoldBits) > 1) {
101+
if (std::abs(ResBits - GoldBits) > 1) {
102102
if (++err_cnt < 100) {
103103
std::cout << "failed at index " << i << ": " << cast(Res) << "(0x"
104104
<< std::hex << ResBits << ")"

sycl/test-e2e/GroupAlgorithm/SYCL2020/reduce_over_group_size.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ int main() {
9191
}
9292
for (int j = 0; j < NV; j++) {
9393
auto d = s[j] - r[k * NV + j];
94-
if (abs(d) > 1e-10) {
94+
if (std::abs(d) > 1e-10) {
9595
printf("partial fail ");
9696
printf("%i\t%i\t%g\t%g\n", k, j, s[j], r[k * NV + j]);
9797
fails++;

0 commit comments

Comments
 (0)