-
Notifications
You must be signed in to change notification settings - Fork 769
/
Copy pathhost_task.hpp
66 lines (54 loc) · 1.69 KB
/
host_task.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//==---- host_task.hpp -----------------------------------------------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// Implementation of various classes/methods related to host task support so
// that it could be excluded from <sycl/detail/core.hpp> as such support pulls
// in interop->image->vec/marray dependencies.
#pragma once
#include <detail/cg.hpp>
#include <detail/global_handler.hpp>
#include <sycl/detail/cg_types.hpp>
#include <sycl/handler.hpp>
#include <sycl/interop_handle.hpp>
namespace sycl {
inline namespace _V1 {
class interop_handle;
namespace detail {
class HostTask {
std::function<void()> MHostTask;
std::function<void(interop_handle)> MInteropTask;
public:
HostTask() : MHostTask([]() {}) {}
HostTask(std::function<void()> &&Func) : MHostTask(Func) {}
HostTask(std::function<void(interop_handle)> &&Func) : MInteropTask(Func) {}
bool isInteropTask() const { return !!MInteropTask; }
void call(HostProfilingInfo *HPI) {
if (!GlobalHandler::instance().isOkToDefer()) {
return;
}
if (HPI)
HPI->start();
MHostTask();
if (HPI)
HPI->end();
}
void call(HostProfilingInfo *HPI, interop_handle handle) {
if (!GlobalHandler::instance().isOkToDefer()) {
return;
}
if (HPI)
HPI->start();
MInteropTask(handle);
if (HPI)
HPI->end();
}
friend class DispatchHostTask;
friend class ExecCGCommand;
};
} // namespace detail
} // namespace _V1
} // namespace sycl