SYCL Base Module - Native Kernel Edition
Higher-level SYCL utilities for tensor operations. This version uses pre-compiled native SYCL kernels, ensuring compatibility with all SYCL devices (CPU, GPU, accelerators).
Global State:
- syclQueues: seqSyclQueue - One queue per device
- syclDeviceType: SyclDeviceType - Device type (CPU/GPU/etc)
Usage: initSycl() # Initialize SYCL with default device initSycl(sdtGPU) # Initialize SYCL with GPU var buf = allocatefloat64 write(queue, data, buf) # ... run kernels via the each macro ... read(queue, result, buf) finalizeSycl()
Vars
syclDeviceType: SyclDeviceType = sdtDefault
syclQueues: seq[SyclQueue]
Procs
proc buffer[T](queue: SyclQueue; count: int): SyclBuffer
- Allocate a typed buffer on the device.
proc bufferLike[T](queue: SyclQueue; data: openArray[T]): SyclBuffer
- Allocate a buffer sized to match the given array.
proc finalizeSycl() {....raises: [], tags: [], forbids: [].}
- Finalize SYCL and release all resources.
proc initSycl(dtype: SyclDeviceType = sdtDefault) {....raises: [ESycl], tags: [], forbids: [].}
- Initialize SYCL with the specified device type. Creates one queue per available device.
proc read(queue: SyclQueue; dest: pointer; buf: SyclBuffer; size: int) {. ...raises: [], tags: [], forbids: [].}
- Read raw data from device buffer.
proc read[T](queue: SyclQueue; data: var openArray[T]; buf: SyclBuffer)
- Read device buffer into array.
proc release(buf: SyclBuffer) {....raises: [], tags: [], forbids: [].}
- Release a buffer using the first global queue. OpenCL compatibility - in OpenCL, buffers are associated with context not queue.
proc release(buf: SyclBuffer; queue: SyclQueue) {....raises: [], tags: [], forbids: [].}
- Release a buffer with explicit queue.
proc write(queue: SyclQueue; src: pointer; buf: SyclBuffer; size: int) {. ...raises: [], tags: [], forbids: [].}
- Write raw data to device buffer.
proc write[T](queue: SyclQueue; data: openArray[T]; buf: SyclBuffer)
- Write array data to device buffer.
Exports
-
SyclQueue, SyclBuffer, SyclDevice, SyclContext, SyclEvent, SyclDeviceType, SyclResult, ESycl, getDeviceCount, createQueue, destroyQueue, wait, getDeviceName, allocate, deallocate, isCpu, isGpu, getBufferPtr, kernelCopy, kernelCopy, kernelAdd, kernelAdd, kernelSub, kernelSub, kernelMul, kernelMul, kernelScalarMul, kernelScalarMul, kernelScalarAdd, kernelScalarAdd, kernelComplexAdd, kernelComplexScalarMul, kernelMatMul, kernelMatMul, kernelComplexMatMul, kernelMatVec, kernelMatVec, kernelComplexMatVec, kernelMatAdd, kernelComplexMatAdd, kernelVecAdd, kernelComplexVecAdd, kernelTensorScalarMul, kernelComplexTensorScalarMul, kernelTensorScalarAdd, kernelSetElement, kernelSetElements, kernelStencilCopy, kernelStencilCopy, kernelStencilScalarMul, kernelStencilScalarMul, kernelStencilAdd, kernelStencilAdd