Skip to content
Raphael Baier edited this page Nov 12, 2020 · 2 revisions

OpenCL

Relevance

To support high-load workloads, an engine requires a modern and preferrably easy to use compute platform, this modules aims to provide just that. It loads a modern (OpenCL2.0 or above) context and abstracts all of the uneccessary details away to have a simple as possible frontend interface. Alternatively the user can assume control of as many steps as he wants to achieve even better performance (such as creating the Buffers manually), which provides a flexible, easy to monitor and easy to upgrade system for all computing needs. Moreover the OpenCL2.0 language is compiled in a way, that provides additional useful features such as linking the names of parameters to buffers.

General Information

Root Path legion/engine/core/compute/

  • It loads an OpenCL context of Version >2.0 context.hpp

  • It can create Buffers on the Computing device buffer.hpp

  • It can create Compute-Programs program.hpp

  • It can create Kernels and CommandQueues on the Computing device kernel.hpp

  • It abstracts the creation of Programs, Buffers, CommandQueues and Kernels on a high level high_level/function.hpp

Basic Usage Example:

  //  assets/kernels/vadd_kernel.cl
  __kernel void vector_add(__global const int* A, __global const int* B,__global int* C) {
    int i = get_global_id(0);
  
    C[i] = A[i] + B[i];
  }
  
  std::vector<int> A = ...;
  std::vector<int> B = ...;
  std::vector<int> Results(1024);
  
  using compute::out;
  
  auto vector_add = fs::view("assets://kernels/vadd_kernel.cl")
                      .load_as<compute::function>("vector_add");
                      
  vector_add(1024,A,B,out(Results));
  

Prototypes contained in Legion

Clone this wiki locally