GPU CUDA API Guide

CUDA requires that all functions be declared according to where they are going to be called and executed.

Given that the custom API scripts are called and run on the GPU, they must be declared as __device__ functions as follows:

__device__
void calculateForce(NCudaApiTypesV1_0_0::CApiElement& element1,
NCudaApiTypesV1_0_0::CApiElement& element2,
…

Other function declarations such as __Global__ and __Host__ are available. However, they are not required.

CUDA Programming Style

The CUDA API is closer to the C++ programming style and the basic operations usually take a much simpler form. Some examples of functions are as follows:
Function Type CUDA Function
Vector arithmetic a-b
a+b
a*b
a/b
Vector operations a.dot(b)
a.cross(b)
a.normalize()
Note: For more information about the available functions, see the API Help documentation at the following location: <EDEM install directory>\202X.X\EDEM\src\Api\Help.
CAUTION: API users should be cautious when implementing contact models for the CUDA solver to not rely on the contact normal being in the same direction as the vector from the API element 'position' member to the contact point. While this does work for Multi-Sphere shapes, it will not work for Sphero-Cylinder or Polyhedral shapes. You must instead use the contactNormal member which is passed in the overlapData API structure. Apart from this, all contact properties for Sphero-Cylinders have a similar definition to those for Multi-Sphere particles.