diff --git a/SYCL/Basic/buffer/buffer_create.cpp b/SYCL/Basic/buffer/buffer_create.cpp index 8088a2ee14..cf13aad52e 100644 --- a/SYCL/Basic/buffer/buffer_create.cpp +++ b/SYCL/Basic/buffer/buffer_create.cpp @@ -15,20 +15,17 @@ int main() { buffer<::cl_int, 1> Buffer(Size); Queue.submit([&](handler &cgh) { accessor Accessor{Buffer, cgh, read_write}; - if (NumOfDevices > 1) - // Currently the Level Zero plugin uses host allocations for multi-device - // contexts because such allocations are accessible by all devices. - std::cerr << "Multi GPU should use zeMemAllocHost\n"; - else if (D.get_info()) + if (D.get_info()) std::cerr << "Integrated GPU should use zeMemAllocHost\n"; else std::cerr << "Discrete GPU should use zeMemAllocDevice\n"; - cgh.parallel_for(range<1>(Size), [=](id<1> ID) {}); + cgh.parallel_for(range<1>(Size), + [=](id<1> ID) { Accessor[ID] = 0; }); }); Queue.wait(); return 0; } -// CHECK: {{Integrated|Multi|Discrete}} GPU should use [[API:zeMemAllocHost|zeMemAllocHost|zeMemAllocDevice]] +// CHECK: {{Integrated|Discrete}} GPU should use [[API:zeMemAllocHost|zeMemAllocDevice]] // CHECK: ZE ---> [[API]]( diff --git a/SYCL/Basic/buffer/buffer_migrate.cpp b/SYCL/Basic/buffer/buffer_migrate.cpp new file mode 100644 index 0000000000..621f90523b --- /dev/null +++ b/SYCL/Basic/buffer/buffer_migrate.cpp @@ -0,0 +1,47 @@ +// REQUIRES: gpu +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// RUN: env NEOReadDebugKeys=1 CreateMultipleRootDevices=2 %GPU_RUN_PLACEHOLDER %t.out +// RUN: env NEOReadDebugKeys=1 CreateMultipleRootDevices=3 %GPU_RUN_PLACEHOLDER %t.out +// +// Test for buffer use in a context with multiple devices (all found +// root-devices) +// + +#include +using namespace cl::sycl; + +int main() { + + int Data = 0; + int Result = 0; + buffer Buffer(&Data, range<1>(1)); + + const auto &Devices = + platform(gpu_selector{}).get_devices(info::device_type::gpu); + std::cout << Devices.size() << " devices found" << std::endl; + context C(Devices); + + int Index = 0; + for (auto D : Devices) { + std::cout << "Using on device " << Index << ": " + << D.get_info() << std::endl; + Result |= (1 << Index); + + queue Q(C, D); + Q.submit([&](handler &cgh) { + accessor Accessor{Buffer, cgh, read_write}; + cgh.parallel_for( + range<1>(1), [=](id<1> ID) { Accessor[ID] |= (1 << Index); }); + }); + Q.wait(); + ++Index; + } + + auto HostAcc = Buffer.get_host_access(); + auto Passed = (HostAcc[0] == Result); + std::cout << "Checking result on host: " << (Passed ? "passed" : "FAILED") + << std::endl; + std::cout << HostAcc[0] << " ?= " << Result << std::endl; + return !Passed; +} diff --git a/SYCL/Plugin/interop-level-zero-buffer-ownership.cpp b/SYCL/Plugin/interop-level-zero-buffer-ownership.cpp old mode 100644 new mode 100755 index 96921ae78f..92da27c50d --- a/SYCL/Plugin/interop-level-zero-buffer-ownership.cpp +++ b/SYCL/Plugin/interop-level-zero-buffer-ownership.cpp @@ -9,6 +9,9 @@ // 2. User-provided memory allocation is freed by DPCPP RT if // "transfer" ownership is specified. +// NOTE: SYCL RT will see unbalanced count of alloc/free, +// so this test will fail with ZE_DEBUG=4. + // Keep ownership // CHECK: zeMemFree diff --git a/SYCL/Plugin/interop-level-zero-buffer.cpp b/SYCL/Plugin/interop-level-zero-buffer.cpp old mode 100644 new mode 100755 index b45f27c391..cd364e7496 --- a/SYCL/Plugin/interop-level-zero-buffer.cpp +++ b/SYCL/Plugin/interop-level-zero-buffer.cpp @@ -90,11 +90,6 @@ int main() { Queue.wait(); { - char *Ptr = (char *)HostBuffer1; - for (int i = 0; i < 10; i++) { - assert(Ptr[i] == 'a'); - } - auto HostAcc1 = HostBufferInterop1.get_host_access(); for (int i = 0; i < 10; i++) { assert(HostAcc1[i] == 'a');