forked from plaidml/plaidml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
executor.h
54 lines (38 loc) · 1.6 KB
/
executor.h
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
// Copyright 2017-2018 Intel Corporation.
#pragma once
#include <memory>
#include <vector>
#include "tile/base/hal.h"
#include "tile/hal/opencl/device_state.h"
namespace vertexai {
namespace tile {
namespace hal {
namespace opencl {
class Executor : public hal::Executor {
public:
explicit Executor(const std::shared_ptr<DeviceState>& device_state);
const hal::proto::HardwareInfo& info() final { return info_; }
Memory* device_memory() final { return device_memory_.get(); }
Memory* shared_memory() final { return shared_memory_.get(); }
bool is_synchronous() const final {
return !(device_state_->cl_normal_queue().props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE);
}
std::shared_ptr<hal::Event> Copy(const context::Context& ctx, const std::shared_ptr<hal::Buffer>& from,
std::size_t from_offset, const std::shared_ptr<hal::Buffer>& to,
std::size_t to_offset, std::size_t length,
const std::vector<std::shared_ptr<hal::Event>>& dependencies) final;
boost::future<std::unique_ptr<hal::Executable>> Prepare(Library* library) final;
boost::future<std::vector<std::shared_ptr<hal::Result>>> WaitFor(
const std::vector<std::shared_ptr<hal::Event>>& events) final;
void Flush() final;
private:
void InitSharedMemory();
const std::shared_ptr<DeviceState> device_state_;
const hal::proto::HardwareInfo info_;
std::unique_ptr<Memory> device_memory_;
std::unique_ptr<Memory> shared_memory_;
};
} // namespace opencl
} // namespace hal
} // namespace tile
} // namespace vertexai