Kernels and FunctionsΒΆ

Kernels are functions that specifically run on a device. However, not all functions that run on the device are kernels. We distinguish the two due to kernels requiring at least one outer loop while functions do not have outer or inner loops.

For example

int add(int a, int b) {
  return a + b;

@kernel void addVectors(int N, int *a, int *b, int *ab) {
  for (int group = 0; group < N; group += 64; outer) {
    for (int i = group; i < (group + 64); ++i; inner) {
      ab[i] = add(a[i], b[i]);

The function add is not meant for parallel execution, while addVectors contains both outer and inner loops