This repository was archived by the owner on Mar 28, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ // ==------------------- free_during_kernel_execution.cpp -------------------==//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ // ===----------------------------------------------------------------------===//
8
+ //
9
+ // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t1.out
10
+ // RUN: %HOST_RUN_PLACEHOLDER %t1.out
11
+ // RUN: %CPU_RUN_PLACEHOLDER %t1.out
12
+ // RUN: %GPU_RUN_PLACEHOLDER %t1.out
13
+ // RUN: %ACC_RUN_PLACEHOLDER %t1.out
14
+
15
+ #include < CL/sycl.hpp>
16
+
17
+ class KernelA ;
18
+
19
+ int main () {
20
+ const int N = 512 ;
21
+ sycl::queue Queue;
22
+ sycl::buffer<int , 1 > Buffer (N);
23
+ sycl::range<1 > NumOfWorkItems{Buffer.size ()};
24
+
25
+ auto *USM = sycl::malloc_host<int >(1 , Queue.get_context ());
26
+
27
+ Queue.submit ([&](sycl::handler &cgh) {
28
+ auto Accessor = Buffer.get_access <sycl::access::mode::write>(cgh);
29
+ cgh.single_task <KernelA>([=]() {
30
+ for (int I = 0 ; I < N; ++I) {
31
+ Accessor[I] = I;
32
+ }
33
+ });
34
+ });
35
+
36
+ // Check that freeing USM before the kernel was finished works.
37
+ free (USM, Queue.get_context ());
38
+
39
+ return 0 ;
40
+ }
You can’t perform that action at this time.
0 commit comments