diff --git a/SYCL/Basic/alloc_on_subdevice.cpp b/SYCL/Basic/alloc_on_subdevice.cpp new file mode 100644 index 0000000000..c1a4f2fd17 --- /dev/null +++ b/SYCL/Basic/alloc_on_subdevice.cpp @@ -0,0 +1,33 @@ +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: env CreateMultipleSubDevices=2 NEOReadDebugKeys=1 SYCL_DEVICE_FILTER="gpu" %t.out +// UNSUPPORTED: gpu-intel-dg1 + +// REQUIRES: gpu, level_zero + +#include + +#include +using namespace sycl; + +class KernelNameA; +int main() { + device dev = device::get_devices(info::device_type::gpu)[0]; + int val = 0; + std::vector subdevices; + + subdevices = dev.create_sub_devices< + info::partition_property::partition_by_affinity_domain>( + info::partition_affinity_domain::numa); + std::cout << "Testing on " << subdevices.size() << " subdevices" << std::endl; + + context commonContext{subdevices}; + for (int j = 0; j < subdevices.size(); ++j) { + buffer buf(&val, range<1>(1)); + queue q{commonContext, subdevices[j]}; + q.submit([&](handler &cgh) { + auto acc = buf.get_access(cgh); + cgh.single_task([=]() { acc[0] = acc[0] + 1; }); + }); + } + assert(val == subdevices.size()); +}