ocl – OpenCL-Wrapper

Zusammenfassung

C-Wrapper um OpenCL: Plattform-/Device-Auswahl, Programm-Kompilierung, Buffer-Erzeugung, Kernel-Enqueue und fachliche Kernels (Bildverarbeitung, Matrix-Vektor, SD-Attention, IWT-Simulation). Der Aufrufer arbeitet mit cl_mem-Buffern und benannten Kernel-Enums statt roher OpenCL-Handhabung.

Umfang

  • Setup: ocl_initialize, ocl_compile, ocl_deinitialize.
  • Buffer: ocl_create_input_buffer_from_memory, ocl_create_output_buffer, ocl_create_buffer (Read/Write/Read-Write).
  • Kernel: ocl_load_kernels, ocl_get_kernel, ocl_enqueue_kernel (global/local work size), ocl_finish_frame.
  • Parameter-Setter je Kernel (ocl_set_parameter_*): subtract_images, histogram, brightest_spot, matvec_bf16, …
  • Kernel-Satz (ocl_kernel_t): u. a. OCL_KERNEL_IWT_FLUX, OCL_KERNEL_IWT_Q, OCL_KERNEL_IWT_UPDATE_INFO, OCL_KERNEL_IWT_MASS_CHARGE, OCL_KERNEL_IWT_REDSHIFT_DAMPING, OCL_KERNEL_IWT_WAVE_EMIT.

Nutzung

#include <ocl/ocl.h>
 
struct ocl_core core = {0};
if (ocl_initialize(&core) == false) return 1;
ocl_compile(&core);
/* ... Parameter-Setter + ocl_enqueue_kernel ... */
ocl_deinitialize(&core);

Abhängigkeiten

  • api, logging, threading
  • System: OpenCL-Header/Library (CL_TARGET_OPENCL_VERSION = 300)

Quellen

  • Repo: https://github.com/deppenkaiser/ocl (public, Apache-2.0)
  • libraries/ocl/ocl/ocl.h, libraries/ocl/{ocl,kernels,iwt_kernels}.c
  • Build: cmake -S . -B build && cmake --build build; Einbindung <ocl/ocl.h>

Verwandte Artikel