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

Commit 66e0d60

Browse files
committed
[SYCL][ESIMD] Split test into sint and uint
Because we have possibility of trap values and compiler optimizations in general C++17.
1 parent c43b67a commit 66e0d60

File tree

3 files changed

+109
-38
lines changed

3 files changed

+109
-38
lines changed

SYCL/ESIMD/api/functional/operators/operator_bitwise_not.cpp renamed to SYCL/ESIMD/api/functional/operators/operator_bitwise_not.hpp

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,43 @@
1-
//==------- operator_bitwise_not.cpp - DPC++ ESIMD on-device test ---------==//
1+
//===-- operator_bitwise_not.hpp - Functions for tests on simd assignment
2+
// operators. --------------------------------------------------------===//
23
//
34
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45
// See https://llvm.org/LICENSE.txt for license information.
56
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
67
//
78
//===----------------------------------------------------------------------===//
8-
// REQUIRES: gpu, level_zero
9-
// XREQUIRES: gpu
10-
// TODO gpu and level_zero in REQUIRES due to only this platforms supported yet.
11-
// The current "REQUIRES" should be replaced with "gpu" only as mentioned in
12-
// "XREQUIRES".
13-
// UNSUPPORTED: cuda, hip
14-
// RUN: %clangxx -fsycl %s -fsycl-device-code-split=per_kernel -o %t.out
15-
// RUN: %GPU_RUN_PLACEHOLDER %t.out
16-
//
17-
// Test for simd bitwise not operator.
18-
// The test creates source simd instance with reference data and invokes bitwise
19-
// not operator.
20-
// The test verifies that data from simd is not corrupted after calling bitwise
21-
// not operator, that bitwise not operator return type is as expected and
22-
// bitwise not operator result values is correct.
9+
///
10+
/// \file
11+
/// This file provides functions for tests on simd assignment operators.
12+
///
13+
//===----------------------------------------------------------------------===//
14+
15+
#pragma once
2316

2417
#include "../mutator.hpp"
2518
#include "../shared_element.hpp"
2619
#include "common.hpp"
2720
// For std::abs
2821
#include <cmath>
2922

30-
using namespace sycl::ext::intel::experimental::esimd;
31-
using namespace esimd_test::api::functional;
23+
namespace esimd = sycl::ext::intel::esimd;
24+
25+
namespace esimd_test::api::functional::operators {
3226

33-
// Descriptor class for the case of calling bitwise not operator.
27+
// Descriptor class for the case of calling bitwise not operator.
3428
struct bitwise_not_operator {
3529
static std::string get_description() { return "bitwise not"; }
3630

3731
template <typename DataT, int NumElems>
3832
static bool call_operator(const DataT *const ref_data,
3933
DataT *const source_simd_result,
4034
DataT *const operator_result) {
41-
auto simd_obj = simd<DataT, NumElems>();
35+
auto simd_obj = esimd::simd<DataT, NumElems>();
4236
simd_obj.copy_from(ref_data);
4337
auto bitwise_not_result = ~simd_obj;
4438
simd_obj.copy_to(source_simd_result);
4539
bitwise_not_result.copy_to(operator_result);
46-
return std::is_same_v<decltype(~simd_obj), simd<DataT, NumElems>>;
40+
return std::is_same_v<decltype(~simd_obj), esimd::simd<DataT, NumElems>>;
4741
}
4842
};
4943

@@ -169,21 +163,5 @@ template <typename TestCaseT, typename DataT, typename DimT> class run_test {
169163
}
170164
};
171165

172-
int main(int, char **) {
173-
sycl::queue queue(esimd_test::ESIMDSelector{},
174-
esimd_test::createExceptionHandler());
175-
176-
bool passed = true;
177-
178-
const auto uint_types = get_tested_types<tested_types::uint>();
179-
const auto sint_types = get_tested_types<tested_types::sint>();
180-
const auto all_dims = get_all_dimensions();
181-
182-
passed &= for_all_combinations<run_test, bitwise_not_operator>(
183-
uint_types, all_dims, queue);
184-
passed &= for_all_combinations<run_test, bitwise_not_operator>(
185-
sint_types, all_dims, queue);
186166

187-
std::cout << (passed ? "=== Test passed\n" : "=== Test FAILED\n");
188-
return passed ? 0 : 1;
189-
}
167+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//==------- operator_bitwise_not_sint.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, level_zero
9+
// XREQUIRES: gpu
10+
// TODO gpu and level_zero in REQUIRES due to only this platforms supported yet.
11+
// The current "REQUIRES" should be replaced with "gpu" only as mentioned in
12+
// "XREQUIRES".
13+
// UNSUPPORTED: cuda, hip
14+
// RUN: %clangxx -fsycl %s -fsycl-device-code-split=per_kernel -o %t.out
15+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
16+
//
17+
// Test for simd bitwise not operator.
18+
// The test creates source simd instance with reference data and invokes bitwise
19+
// not operator.
20+
// The test verifies that data from simd is not corrupted after calling bitwise
21+
// not operator, that bitwise not operator return type is as expected and
22+
// bitwise not operator result values is correct.
23+
//
24+
// IMPORTANT: there is possibility of trap values and compiler optimizations in
25+
// general C++17, the llvm itself states that signed integer types are
26+
// guaranteed to be two's complement:
27+
// - https://llvm.org/docs/LangRef.html
28+
// - https://bugs.llvm.org/show_bug.cgi?id=950
29+
30+
#include "operator_bitwise_not.hpp"
31+
32+
using namespace esimd_test::api::functional;
33+
34+
int main(int, char **) {
35+
sycl::queue queue(esimd_test::ESIMDSelector{},
36+
esimd_test::createExceptionHandler());
37+
38+
bool passed = true;
39+
40+
const auto sint_types = get_tested_types<tested_types::sint>();
41+
const auto all_dims = get_all_dimensions();
42+
43+
// Running test for all sint types
44+
passed &= for_all_combinations<run_test, bitwise_not_operator>(
45+
sint_types, all_dims, queue);
46+
47+
std::cout << (passed ? "=== Test passed\n" : "=== Test FAILED\n");
48+
return passed ? 0 : 1;
49+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//==------- operator_bitwise_not_uint.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, level_zero
9+
// XREQUIRES: gpu
10+
// TODO gpu and level_zero in REQUIRES due to only this platforms supported yet.
11+
// The current "REQUIRES" should be replaced with "gpu" only as mentioned in
12+
// "XREQUIRES".
13+
// UNSUPPORTED: cuda, hip
14+
// RUN: %clangxx -fsycl %s -fsycl-device-code-split=per_kernel -o %t.out
15+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
16+
//
17+
// Test for simd bitwise not operator.
18+
// The test creates source simd instance with reference data and invokes bitwise
19+
// not operator.
20+
// The test verifies that data from simd is not corrupted after calling bitwise
21+
// not operator, that bitwise not operator return type is as expected and
22+
// bitwise not operator result values is correct.
23+
24+
#include "operator_bitwise_not.hpp"
25+
26+
using namespace esimd_test::api::functional;
27+
28+
int main(int, char **) {
29+
sycl::queue queue(esimd_test::ESIMDSelector{},
30+
esimd_test::createExceptionHandler());
31+
32+
bool passed = true;
33+
34+
const auto uint_types = get_tested_types<tested_types::uint>();
35+
const auto all_dims = get_all_dimensions();
36+
37+
// Running test for all uint types
38+
passed &= for_all_combinations<operators::run_test,
39+
operators::bitwise_not_operator>(
40+
uint_types, all_dims, queue);
41+
42+
std::cout << (passed ? "=== Test passed\n" : "=== Test FAILED\n");
43+
return passed ? 0 : 1;
44+
}

0 commit comments

Comments
 (0)