This repository was archived by the owner on Mar 28, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +54
-12
lines changed Expand file tree Collapse file tree 4 files changed +54
-12
lines changed Original file line number Diff line number Diff line change @@ -15,20 +15,17 @@ int main() {
15
15
buffer<::cl_int, 1 > Buffer (Size);
16
16
Queue.submit ([&](handler &cgh) {
17
17
accessor Accessor{Buffer, cgh, read_write};
18
- if (NumOfDevices > 1 )
19
- // Currently the Level Zero plugin uses host allocations for multi-device
20
- // contexts because such allocations are accessible by all devices.
21
- std::cerr << " Multi GPU should use zeMemAllocHost\n " ;
22
- else if (D.get_info <info::device::host_unified_memory>())
18
+ if (D.get_info <info::device::host_unified_memory>())
23
19
std::cerr << " Integrated GPU should use zeMemAllocHost\n " ;
24
20
else
25
21
std::cerr << " Discrete GPU should use zeMemAllocDevice\n " ;
26
- cgh.parallel_for <class CreateBuffer >(range<1 >(Size), [=](id<1 > ID) {});
22
+ cgh.parallel_for <class CreateBuffer >(range<1 >(Size),
23
+ [=](id<1 > ID) { Accessor[ID] = 0 ; });
27
24
});
28
25
Queue.wait ();
29
26
30
27
return 0 ;
31
28
}
32
29
33
- // CHECK: {{Integrated|Multi| Discrete}} GPU should use [[API:zeMemAllocHost| zeMemAllocHost|zeMemAllocDevice]]
30
+ // CHECK: {{Integrated|Discrete}} GPU should use [[API:zeMemAllocHost|zeMemAllocDevice]]
34
31
// CHECK: ZE ---> [[API]](
Original file line number Diff line number Diff line change
1
+ // REQUIRES: gpu
2
+ // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
3
+ // RUN: %GPU_RUN_PLACEHOLDER %t.out
4
+ // RUN: env NEOReadDebugKeys=1 CreateMultipleRootDevices=2 %GPU_RUN_PLACEHOLDER %t.out
5
+ // RUN: env NEOReadDebugKeys=1 CreateMultipleRootDevices=3 %GPU_RUN_PLACEHOLDER %t.out
6
+ //
7
+ // Test for buffer use in a context with multiple devices (all found
8
+ // root-devices)
9
+ //
10
+
11
+ #include < CL/sycl.hpp>
12
+ using namespace cl ::sycl;
13
+
14
+ int main () {
15
+
16
+ int Data = 0 ;
17
+ int Result = 0 ;
18
+ buffer<int , 1 > Buffer (&Data, range<1 >(1 ));
19
+
20
+ const auto &Devices =
21
+ platform (gpu_selector{}).get_devices (info::device_type::gpu);
22
+ std::cout << Devices.size () << " devices found" << std::endl;
23
+ context C (Devices);
24
+
25
+ int Index = 0 ;
26
+ for (auto D : Devices) {
27
+ std::cout << " Using on device " << Index << " : "
28
+ << D.get_info <info::device::name>() << std::endl;
29
+ Result |= (1 << Index);
30
+
31
+ queue Q (C, D);
32
+ Q.submit ([&](handler &cgh) {
33
+ accessor Accessor{Buffer, cgh, read_write};
34
+ cgh.parallel_for <class MigrateBuffer >(
35
+ range<1 >(1 ), [=](id<1 > ID) { Accessor[ID] |= (1 << Index); });
36
+ });
37
+ Q.wait ();
38
+ ++Index;
39
+ }
40
+
41
+ auto HostAcc = Buffer.get_host_access ();
42
+ auto Passed = (HostAcc[0 ] == Result);
43
+ std::cout << " Checking result on host: " << (Passed ? " passed" : " FAILED" )
44
+ << std::endl;
45
+ std::cout << HostAcc[0 ] << " ?= " << Result << std::endl;
46
+ return !Passed;
47
+ }
Original file line number Diff line number Diff line change 9
9
// 2. User-provided memory allocation is freed by DPCPP RT if
10
10
// "transfer" ownership is specified.
11
11
12
+ // NOTE: SYCL RT will see unbalanced count of alloc/free,
13
+ // so this test will fail with ZE_DEBUG=4.
14
+
12
15
// Keep ownership
13
16
// CHECK: zeMemFree
14
17
Original file line number Diff line number Diff line change @@ -90,11 +90,6 @@ int main() {
90
90
Queue.wait ();
91
91
92
92
{
93
- char *Ptr = (char *)HostBuffer1;
94
- for (int i = 0 ; i < 10 ; i++) {
95
- assert (Ptr[i] == ' a' );
96
- }
97
-
98
93
auto HostAcc1 = HostBufferInterop1.get_host_access ();
99
94
for (int i = 0 ; i < 10 ; i++) {
100
95
assert (HostAcc1[i] == ' a' );
You can’t perform that action at this time.
0 commit comments