27 #include <level_zero/ze_api.h>
35 std::vector<std::shared_ptr<L0Device>>
devices_;
38 ze_context_handle_t context_;
39 ze_driver_handle_t driver_;
44 explicit L0Driver(ze_driver_handle_t handle);
45 ze_context_handle_t ctx()
const;
46 ze_driver_handle_t driver()
const;
50 const std::vector<std::shared_ptr<L0Device>>&
devices()
const;
61 ze_device_handle_t device_;
73 bool log =
false)
const;
77 ze_device_handle_t device()
const;
78 ze_context_handle_t ctx()
const;
86 ze_module_handle_t handle_;
95 explicit L0Module(ze_module_handle_t handle);
96 ze_module_handle_t handle()
const;
103 void set_kernel_args(ze_kernel_handle_t kernel) {}
105 template <
int Index,
typename Head>
106 void set_kernel_args(ze_kernel_handle_t kernel, Head&& head) {
108 kernel, Index,
sizeof(std::remove_reference_t<Head>), head));
111 template <
int Index,
typename Head,
typename... Tail>
112 void set_kernel_args(ze_kernel_handle_t kernel, Head&& head, Tail&&... tail) {
113 set_kernel_args<Index>(kernel, head);
114 set_kernel_args<Index + 1>(kernel, std::forward<Tail>(tail)...);
121 ze_kernel_handle_t handle_;
122 ze_group_count_t group_size_;
126 L0Kernel(ze_kernel_handle_t handle, uint32_t x, uint32_t y, uint32_t z);
127 ze_group_count_t& group_size();
128 ze_kernel_handle_t handle()
const;
136 ze_command_queue_handle_t handle_;
140 ze_command_queue_handle_t handle()
const;
148 ze_command_list_handle_t handle_;
152 void copy(
void* dst,
const void* src,
const size_t num_bytes);
154 template <
typename... Args>
157 set_kernel_args<0>(kernel.handle(), std::forward<Args>(
args)...);
160 handle_, kernel.handle(), &kernel.group_size(),
nullptr, 0,
nullptr));
162 L0_SAFE_CALL(zeCommandListAppendBarrier(handle_,
nullptr, 0,
nullptr));
169 ze_command_list_handle_t handle()
const;
182 const int8_t* host_ptr,
183 const size_t num_bytes,
184 const int device_num);
186 const int8_t* device_ptr,
187 const size_t num_bytes,
188 const int device_num);
191 const size_t num_bytes,
192 const int dest_device_num,
193 const int src_device_num);
199 void zeroDeviceMem(int8_t* device_ptr,
const size_t num_bytes,
const int device_num);
201 const unsigned char uc,
202 const size_t num_bytes,
203 const int device_num);
207 const std::vector<std::shared_ptr<L0Driver>>&
drivers()
const;
void freeDeviceMem(int8_t *device_ptr)
void zeroDeviceMem(int8_t *device_ptr, const size_t num_bytes, const int device_num)
#define L0_SAFE_CALL(call)
void copyHostToDevice(int8_t *device_ptr, const int8_t *host_ptr, const size_t num_bytes, const int device_num)
void setDeviceMem(int8_t *device_ptr, const unsigned char uc, const size_t num_bytes, const int device_num)
std::unique_ptr< L0CommandList > create_command_list() const
std::shared_ptr< L0Module > create_module(uint8_t *code, size_t len, bool log=false) const
void launch(L0Kernel &kernel, Args &&...args)
void copy(void *dst, const void *src, const size_t num_bytes)
void submit(L0CommandQueue &queue)
std::shared_ptr< L0CommandQueue > command_queue() const
void copyDeviceToDevice(int8_t *dest_ptr, int8_t *src_ptr, const size_t num_bytes, const int dest_device_num, const int src_device_num)
std::vector< std::shared_ptr< L0Device > > devices_
void synchronizeDevices() const
std::shared_ptr< L0CommandQueue > command_queue_
void copyDeviceToHost(int8_t *host_ptr, const int8_t *device_ptr, const size_t num_bytes, const int device_num)
void freePinnedHostMem(int8_t *host_ptr)
const std::vector< std::shared_ptr< L0Driver > > & drivers() const
int8_t * allocatePinnedHostMem(const size_t num_bytes)
std::vector< std::shared_ptr< L0Driver > > drivers_
void * allocate_device_mem(const size_t num_bytes, L0Device &device)
int8_t * allocateDeviceMem(const size_t num_bytes, const int device_num)
const std::vector< std::shared_ptr< L0Device > > & devices() const
std::shared_ptr< L0Kernel > create_kernel(const char *name, uint32_t x, uint32_t y, uint32_t z) const