Skip to content

Commit 486136d

Browse files
authored
Merge pull request intel#1129 from bb-sycl/xmain
Auto pulldown and update tc files for xmain branch on 20220902
2 parents 05c96d8 + 015ed7b commit 486136d

File tree

103 files changed

+3421
-301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+3421
-301
lines changed

MultiSource/Applications/ClamAV/libclamav_readdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ static int cli_loaddbdir_l(const char *dirname, struct cl_engine **engine, unsig
11421142
}
11431143
}
11441144

1145-
qsort(dents, ndents, sizeof(struct dirent), dirent_compare);
1145+
qsort(dents, ndents, sizeof(struct dirent), (int (*)(const void *, const void *))dirent_compare);
11461146

11471147
for (i=0; i<ndents; i++) {
11481148
dent = &dents[i];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
list(APPEND CFLAGS -Wno-implicit-int)
1+
list(APPEND CFLAGS -Wno-implicit-int -Wno-incompatible-function-pointer-types)
22
llvm_multisource(unix-tbl)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
LEVEL = ../../../..
22

3-
CFLAGS += -Wno-implicit-int
3+
CFLAGS += -Wno-implicit-int -Wno-incompatible-function-pointer-types
44
PROG = unix-tbl
55
include $(LEVEL)/MultiSource/Makefile.multisrc
66

SYCL/Assert/assert_in_simultaneously_multiple_tus.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// FIXME flaky output on Level Zero
2-
// UNSUPPORTED: level_zero
31
// RUN: %clangxx -DSYCL_FALLBACK_ASSERT=1 -fsycl -fsycl-targets=%sycl_triple -I %S/Inputs %s %S/Inputs/kernels_in_file2.cpp -o %t.out %threads_lib
42
// RUN: %CPU_RUN_PLACEHOLDER %t.out &> %t.txt || true
53
// RUN: %CPU_RUN_PLACEHOLDER FileCheck %s --input-file %t.txt

SYCL/AtomicRef/assignment_atomic64.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
// RUN: %GPU_RUN_PLACEHOLDER %t.out
55
// RUN: %ACC_RUN_PLACEHOLDER %t.out
66

7-
// XFAIL: hip
8-
// Expected failure because hip does not have atomic64 check implementation
9-
107
#include "assignment.h"
118
#include <iostream>
129
using namespace sycl;

SYCL/Basic/aspects.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
// Hip is missing some of the parameters tested here so it fails with NVIDIA
55
// XFAIL: hip_nvidia
66

7-
// XFAIL: hip
8-
// Expected failure because hip does not have atomic64 check implementation
9-
107
//==--------------- aspects.cpp - SYCL device test ------------------------==//
118
//
129
// Returns the various aspects of a device and platform.

SYCL/Basic/buffer/buffer_allocator.cpp

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// RUN: %clangxx -fsycl -DSYCL2020_CONFORMANT_APIS -fsycl-targets=%sycl_triple %s -o %t.out
2-
// RUN: env SYCL_DEVICE_FILTER=opencl %CPU_RUN_PLACEHOLDER %t.out
3-
// RUN: env SYCL_DEVICE_FILTER=opencl %GPU_RUN_PLACEHOLDER %t.out
4-
// RUN: env SYCL_DEVICE_FILTER=opencl %ACC_RUN_PLACEHOLDER %t.out
51
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
62
// RUN: env SYCL_DEVICE_FILTER=opencl %CPU_RUN_PLACEHOLDER %t.out
73
// RUN: env SYCL_DEVICE_FILTER=opencl %GPU_RUN_PLACEHOLDER %t.out
@@ -15,9 +11,9 @@
1511
//
1612
//===----------------------------------------------------------------------===//
1713

18-
// Tests that the default (and explicit with SYCL 2020) buffer_allocator used by
19-
// buffers are as defined by the spec and will allocate the right amount of
20-
// memory on the device.
14+
// Tests that the default and explicit buffer_allocator used by buffers are as
15+
// defined by the spec and will allocate the right amount of memory on the
16+
// device.
2117

2218
#include <iostream>
2319
#include <sycl/sycl.hpp>
@@ -45,40 +41,27 @@ bool checkResult(sycl::buffer<T, 1, AllocT> &Buf, size_t N, std::string &TName,
4541
template <typename T> bool runTest(sycl::queue &Q, std::string TName) {
4642
sycl::buffer<T, 1> DefaultBuf{NumElems};
4743

48-
#ifdef SYCL2020_CONFORMANT_APIS
4944
static_assert(std::is_same_v<decltype(DefaultBuf),
5045
sycl::buffer<T, 1, sycl::buffer_allocator<T>>>);
5146

5247
sycl::buffer<T, 1, sycl::buffer_allocator<char>> CharAllocBuf{NumElems};
5348
sycl::buffer<T, 1, sycl::buffer_allocator<long>> LongAllocBuf{NumElems};
54-
#else
55-
static_assert(std::is_same_v<decltype(DefaultBuf),
56-
sycl::buffer<T, 1, sycl::buffer_allocator>>);
57-
#endif
5849

5950
Q.submit([&](sycl::handler &CGH) {
6051
auto DefaultAcc = DefaultBuf.get_access(CGH);
61-
#ifdef SYCL2020_CONFORMANT_APIS
6252
auto CharAllocAcc = CharAllocBuf.get_access(CGH);
6353
auto LongAllocAcc = LongAllocBuf.get_access(CGH);
64-
#endif
6554
CGH.parallel_for<TestKernel<T>>(NumElems, [=](sycl::item<1> It) {
6655
DefaultAcc[It] = static_cast<T>(It[0]);
67-
#ifdef SYCL2020_CONFORMANT_APIS
6856
CharAllocAcc[It] = static_cast<T>(It[0]);
6957
LongAllocAcc[It] = static_cast<T>(It[0]);
70-
#endif
7158
});
7259
}).wait();
7360

74-
#ifdef SYCL2020_CONFORMANT_APIS
7561
return checkResult(DefaultBuf, NumElems, TName,
7662
"buffer_allocator<" + TName + ">") &&
7763
checkResult(CharAllocBuf, NumElems, TName, "buffer_allocator<char>") &&
7864
checkResult(LongAllocBuf, NumElems, TName, "buffer_allocator<long>");
79-
#else
80-
return checkResult(DefaultBuf, NumElems, TName, "buffer_allocator");
81-
#endif
8265
}
8366

8467
#define RUN_TEST(TYPE, Q) runTest<TYPE>(Q, #TYPE)

SYCL/Basic/code_location_e2e.cpp

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
// UNSUPPORTED: hip || cuda
2+
3+
// RUN: %clangxx -fsycl -DNDEBUG %s -o %t.out
4+
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER
5+
// RUN: %GPU_RUN_PLACEHOLDER %t.out %GPU_CHECK_PLACEHOLDER
6+
// RUN: %ACC_RUN_PLACEHOLDER %t.out %ACC_CHECK_PLACEHOLDER
7+
8+
// RUN: %clangxx -fsycl %s -o %t.out
9+
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER
10+
// RUN: %GPU_RUN_PLACEHOLDER %t.out %GPU_CHECK_PLACEHOLDER
11+
// RUN: %ACC_RUN_PLACEHOLDER %t.out %ACC_CHECK_PLACEHOLDER
12+
13+
/*
14+
clang++ -fsycl -DNDEBUG -o smyl.bin code_location_e2e.cpp // <<--- NDEBUG
15+
will suppress fileLocation
16+
17+
-DNDEBUG <-- not debugging, meaning fileName should not be retrievable (for
18+
data privacy reasons)
19+
20+
Between having to test against NDEBUG and test from kernel code,
21+
using assert/abort type of logic is not available. This test just
22+
outputs strings that it checks with FileCheck.
23+
24+
This test uses hardcoded file code location positions. If modified, those
25+
may change. pass in any value to signal "report only" and not run tests.
26+
27+
*/
28+
29+
#include <sycl/sycl.hpp>
30+
using namespace sycl;
31+
32+
// llvm/sycl/doc/design/DeviceLibExtensions.rst
33+
// Our devicelib support for <cstring> only includes three memory
34+
// operations, none of the string ones. So we need to provide
35+
// our own string comparison for kernel calls.
36+
bool stringsAreSameP(const char *a, const char *b) {
37+
// If both are nullptr, then they are the same,
38+
if ((a == nullptr) && (b == nullptr))
39+
return true;
40+
// but if only one, they are not.
41+
if ((a == nullptr) || (b == nullptr))
42+
return false;
43+
44+
int index = 0;
45+
while (true) {
46+
if (a[index] != b[index]) {
47+
return false;
48+
}
49+
if (a[index] == '\0') {
50+
return true;
51+
} // If we are on this line we know a[i]==b[i].
52+
index++;
53+
}
54+
// We will never arrive here.
55+
return true;
56+
}
57+
58+
template <typename OS> void report(OS &out, detail::code_location code_loc) {
59+
out << "function {line:col} => " << code_loc.functionName() << " {"
60+
<< code_loc.lineNumber() << ":" << code_loc.columnNumber() << "}"
61+
<< "\n";
62+
63+
auto fileName = code_loc.fileName();
64+
if (fileName == nullptr)
65+
out << "nullptr for fileName"
66+
<< "\n";
67+
else
68+
out << "fileName: " << code_loc.fileName() << "\n";
69+
}
70+
71+
template <typename OS>
72+
void test(OS &out, detail::code_location &code_loc, const char *fileName,
73+
const char *funcName, int line, int col) {
74+
75+
// functionName
76+
auto funcNameStr = code_loc.functionName();
77+
auto fNameResult =
78+
((funcNameStr != nullptr) && stringsAreSameP(funcNameStr, funcName))
79+
? "OK"
80+
: "WRONG";
81+
out << "code_location.functionName: " << fNameResult << "\n";
82+
83+
// lineNumber
84+
auto lineNumberResult = (code_loc.lineNumber() == line) ? "OK" : "WRONG";
85+
out << "code_location.lineNumber: " << lineNumberResult << "\n";
86+
87+
// columnNumber
88+
auto colNumberResult = (code_loc.columnNumber() == col) ? "OK" : "WRONG";
89+
out << "code_location.columnNumber: " << colNumberResult << "\n";
90+
91+
// fileName
92+
auto fileNameStr = code_loc.fileName();
93+
#ifdef NDEBUG
94+
// NDEBUG == not debugging == no fileName (for security).
95+
auto fileNameResult =
96+
(fileNameStr == nullptr)
97+
? "OK"
98+
: "WRONG - fileName should not be present when NDEBUG defined";
99+
#else
100+
auto fileNameResult = stringsAreSameP(fileName, fileNameStr) ? "OK" : "WRONG";
101+
#endif
102+
out << "code_location.fileName: " << fileNameResult << "\n";
103+
}
104+
105+
int main(int argc, char **argv) {
106+
bool testing =
107+
(argc <= 1); // Passing in ANY argument means report only, do not test.
108+
auto code_loc = sycl::detail::code_location::current(); // <--
109+
int EXPECTED_LINE = __LINE__ - 1;
110+
#ifdef NDEBUG
111+
std::cout << "NDEBUG, therefore no fileName" << std::endl;
112+
#else
113+
std::cout << "NDEBUG NOT DEFINED, make sure file name isn't a full path "
114+
<< std::endl;
115+
std::cout << "file name: " << code_loc.fileName() << std::endl;
116+
#endif
117+
std::cout << "------- host test -------" << std::endl;
118+
report(std::cout, code_loc);
119+
120+
if (testing)
121+
test(std::cout, code_loc, "code_location_e2e.cpp", "main", EXPECTED_LINE,
122+
19);
123+
124+
std::cout << "------- kernel test -------" << std::endl;
125+
126+
queue q;
127+
q.submit([testing](handler &cgh) {
128+
sycl::stream out(2024, 400, cgh);
129+
cgh.single_task<class KHALID>([=]() {
130+
auto kernel_loc = sycl::detail::code_location::current(); // <--
131+
int EXPECTED_LINE = __LINE__ - 1;
132+
report(out, kernel_loc);
133+
134+
if (testing)
135+
test(out, kernel_loc, "code_location_e2e.cpp", "operator()",
136+
EXPECTED_LINE, 25);
137+
138+
out << "-------" << sycl::endl;
139+
});
140+
});
141+
q.wait();
142+
143+
return 0;
144+
}
145+
146+
// CHECK: ------- host test -------
147+
// CHECK: code_location.functionName: OK
148+
// CHECK-NEXT: code_location.lineNumber: OK
149+
// CHECK-NEXT: code_location.columnNumber: OK
150+
// XHECK-NEXT: code_location.fileName: OK
151+
152+
// CHECK: ------- kernel test -------
153+
// CHECK: code_location.functionName: OK
154+
// CHECK-NEXT: code_location.lineNumber: OK
155+
// CHECK-NEXT: code_location.columnNumber: OK
156+
// XHECK-NEXT: code_location.fileName: OK

SYCL/Basic/context-with-multiple-devices.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// UNSUPPORTED: windows || linux
2-
// temporarily disabled
3-
41
// REQUIRES: accelerator, opencl-aot
52

63
// RUN: %clangxx -fsycl -fintelfpga -fsycl-unnamed-lambda %s -o %t2.out

SYCL/Basic/device-selectors.cpp

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2+
// RUN: %t.out
3+
4+
#include <sycl/sycl.hpp>
5+
using namespace sycl;
6+
7+
auto exception_handler_lambda = [](exception_list elist) {
8+
// nop
9+
};
10+
11+
void handle_exceptions_f(exception_list elist) {
12+
// nop
13+
}
14+
15+
auto refuse_any_device_lambda = [](const device &d) { return -1; };
16+
17+
int refuse_any_device_f(const device &d) { return -1; }
18+
19+
int main() {
20+
// Ensure these compile correctly. That exception handler does not
21+
// end up specialized against device selector.
22+
queue exception_queue_01(exception_handler_lambda);
23+
queue exception_queue_02(handle_exceptions_f);
24+
25+
// Set up callable device selector.
26+
std::vector<device> deviceList = device::get_devices();
27+
device &lastDevice = deviceList.back();
28+
auto select_last_device = [&lastDevice](const device &d) {
29+
return d == lastDevice;
30+
};
31+
32+
// Instantiate platform via callable Device Selector.
33+
platform lastPlatform(select_last_device);
34+
35+
// Test each of the four queue constructors that take callable Device
36+
// Selectors: q(device selector) q(dev selector , async handler)
37+
// q(context , dev selector) q(context, dev selector , async handler)
38+
queue lastQueue(select_last_device);
39+
assert(lastQueue.get_device().get_platform() == lastPlatform &&
40+
"Queue and platform created by selecting same device, should result "
41+
"in matching platforms.");
42+
43+
queue lastQueueWithHandler(select_last_device, exception_handler_lambda);
44+
assert(lastQueueWithHandler.get_device() == lastDevice &&
45+
"Queue created by selecting a device should have that same device.");
46+
47+
// Create a context.
48+
platform plt;
49+
std::vector<device> platformDevices = plt.get_devices();
50+
context ctx(platformDevices);
51+
// Set up a callable device selector to select the last device from the
52+
// context.
53+
device &lastPlatformDevice = platformDevices.back();
54+
auto select_last_platform_device = [&lastPlatformDevice](const device &d) {
55+
return d == lastPlatformDevice;
56+
};
57+
// Test queue constructors that use devices from a context.
58+
queue lastQueueViaContext(ctx, select_last_platform_device);
59+
assert(lastQueueViaContext.get_device() == lastPlatformDevice &&
60+
"Queue created by selecting a device should have that same device.");
61+
62+
queue lastQueueViaContextWithHandler(ctx, select_last_platform_device,
63+
handle_exceptions_f);
64+
assert(lastQueueViaContextWithHandler.get_device() == lastPlatformDevice &&
65+
"Queue created by selecting a device should have that same device.");
66+
67+
// Device constructor.
68+
device matchingDevice(select_last_device);
69+
assert(matchingDevice == lastDevice && "Incorrect selected device.");
70+
71+
// Check exceptions and failures.
72+
try {
73+
platform refusedPlatform(refuse_any_device_lambda);
74+
assert(false &&
75+
"Declined device selection should have resulted in an exception.");
76+
} catch (sycl::exception &e) {
77+
assert(e.code() == sycl::errc::runtime && "Incorrect error code.");
78+
}
79+
80+
try {
81+
queue refusedQueue(refuse_any_device_f);
82+
assert(false &&
83+
"Declined device selection should have resulted in an exception.");
84+
} catch (sycl::exception &e) {
85+
assert(e.code() == sycl::errc::runtime && "Incorrect error code.");
86+
}
87+
88+
try {
89+
device refusedDevice(refuse_any_device_f);
90+
assert(false &&
91+
"Declined device selection should have resulted in an exception.");
92+
} catch (sycl::exception &e) {
93+
assert(e.code() == sycl::errc::runtime && "Incorrect error code.");
94+
}
95+
96+
// Standalone device selectors.
97+
queue default_queue(default_selector_v); // Compilation and no error
98+
99+
// Not sure what devices are available when this test is run, so no action is
100+
// necessary on error.
101+
try {
102+
queue gpu_queue(gpu_selector_v);
103+
assert(gpu_queue.get_device().is_gpu() &&
104+
"Incorrect device. Expected GPU.");
105+
} catch (exception &e) {
106+
}
107+
try {
108+
queue cpu_queue(cpu_selector_v);
109+
assert(cpu_queue.get_device().is_cpu() &&
110+
"Incorrect device. Expected CPU.");
111+
} catch (exception &e) {
112+
}
113+
try {
114+
queue acc_queue(accelerator_selector_v);
115+
assert(acc_queue.get_device().is_accelerator() &&
116+
"Incorrect device. Expected Accelerator.");
117+
} catch (exception &e) {
118+
}
119+
120+
return 0;
121+
}

0 commit comments

Comments
 (0)