Creating Kernel Code

Making kernel code is pretty simple! Here’s what you need to know:

  1. Include the Essential Header
    Always start by including the mu/mu.hpp header. It’s a must-have!
    #include "mu/mu.hpp"
    
  2. Pick Your Host-Callable Functions
    Choose which functions you want to call from the host.
    Just remember to use MU_KERNEL_ADD macro to show it’s host-callable.

    For example:

    void kernel_callable(int size)
    {
       ...
    }
    
    void host_callable(int* data, int size)
    {
        // Your awesome code here
    }   
    MU_KERNEL_ADD(host_callable)  
    
  3. Keep Parameters in Check
    You can use up to 9 parameters for your kernel function. No more!

  4. Memory Constraints
    • Heap Size: The kernel’s heap size is limited to 3MB.
    • Stack Size: The kernel’s stack size is limited to 64KB.

Stick to these guidelines, and you’ll be creating great kernel code in no time!