Building and Running KernelsΒΆ

Now that we have data in the device, we want to start computing our vector addition. We must first build a kernel that uses device data.

Kernels are built at runtime so we require 2 things

  • The file with the kernel source code
  • The name of the kernel in the source code we wish to use
occa::kernel addVectors = device.buildKernel("addVectors.okl", "addVectors");
occaKernel addVectors = deviceBuildKernel(device, "addVectors.okl", "addVectors");
add_vectors = device.build_kernel("addVectors.okl", "addVectors")
type(occaKernel) :: addVectors
addVectors = occaDeviceBuildKernel(device, "addVectors.okl", "addVectors")

We can now call addVectors with our device arrays.

addVectors(entries, o_a, o_b, o_ab);
occaKernelRun(addVectors, occaInt32(entries), o_a, o_b, o_ab);
add_vectors(entries, o_a, o_b, o_ab)
call occaKernelRun(addVectors, occaInt32(entries), o_a, o_b, o_ab)