diff --git a/SYCL/Basic/buffer/buffer_release.cpp b/SYCL/Basic/buffer/buffer_release.cpp new file mode 100644 index 0000000000..b11954959b --- /dev/null +++ b/SYCL/Basic/buffer/buffer_release.cpp @@ -0,0 +1,33 @@ +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %CPU_RUN_PLACEHOLDER %t.out + +#include + +using namespace sycl; +using namespace sycl::access; + +static constexpr size_t BUFFER_SIZE = 256; + +void test() { + queue Q; + std::unique_ptr> HostAcc; + { + buffer Buffer{BUFFER_SIZE}; + HostAcc.reset(new host_accessor(Buffer)); + // Host accessor should block kernel execution + Q.submit([&](handler &CGH) { + auto Acc = Buffer.template get_access(CGH); + CGH.parallel_for(BUFFER_SIZE, + [=](item<1> Id) { Acc[Id] = 0; }); + }); + // Buffer destructor should not wait till all operations completion here + } + // Unblock kernel execution + HostAcc.reset(nullptr); + Q.wait(); +} + +int main() { + test(); + return 0; +}