- All Implemented Interfaces:
ExecutionContext
The application can access thread-id for 1D, 2D and 3D dimensions. Additionally, the application can access local memory (OpenCL terminology), or shared memory (CUDA terminology) as well as synchronization primitives such as barriers.
KernelContextis an object exposed by the TornadoVM API in order to leverage low-level programming features provided by heterogeneous frameworks (e.g. OpenCL, CUDA) to the developers, such as thread-id, access to local/shared memory and barriers.KernelContextprovides a Java API that is transparently translated to both OpenCL and PTX by the TornadoVM JIT compiler. The main difference with theTaskGraphAPI is that the tasks within aTaskGraphthat useKernelContextmust beGridScheduler.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal IntegerIt returns the global group size of a particular dimension (e.g.final Integerfinal Integerfinal IntegerIt returns the thread identifier for the first dimension.final IntegerIt returns the thread identifier for the second dimension.final IntegerIt returns the thread identifier for the third dimension.final Integerfinal Integerfinal Integerfinal IntegerIt returns the global group size of a particular dimension (e.g.final Integerfinal Integerfinal Integerfinal Integerfinal Integer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]allocateByteLocalArray(int size) It allocates a single dimensional array in local memory (known as shared memory in PTX).double[]allocateDoubleLocalArray(int size) It allocates a single dimensional array in local memory (known as shared memory in PTX).float[]allocateFloatLocalArray(int size) It allocates a single dimensional array in local memory (known as shared memory in PTX).allocateHalfFloatLocalArray(int size) It allocates a single dimensional array in local memory (known as shared memory in PTX).int[]allocateIntLocalArray(int size) It allocates a single dimensional array in local memory (known as shared memory in PTX).long[]allocateLongLocalArray(int size) It allocates a single dimensional array in local memory (known as shared memory in PTX).voidatomicAdd(int[] array, int index, int val) Method used to read a memory address by using the array and the index, then add the value of val to it, and write the result back to the same address.voidatomicAdd(DoubleArray array, int index, double val) Method used to read a memory address by using the array and the index, then add the value of val to it, and write the result back to the same address.voidatomicAdd(FloatArray array, int index, float val) Method used to read a memory address by using the array and the index, then add the value of val to it, and write the result back to the same address.voidMethod used to read a memory address by using the array and the index, then add the value of val to it, and write the result back to the same address.voidMethod used to read a memory address by using the array and the index, then add the value of val to it, and write the result back to the same address.voidMethod used as a barrier to synchronize the order of memory operations to the global memory.voidMethod used as a barrier to synchronize the order of memory operations to the local memory (known as shared memory in PTX).
-
Field Details
-
globalIdx
It returns the thread identifier for the first dimension.OpenCL equivalent: get_global_id(0);
PTX equivalent: blockIdx.x * blockDim.x + threadIdx.x
-
globalIdy
It returns the thread identifier for the second dimension.OpenCL equivalent: get_global_id(1);
PTX equivalent: blockIdx.y * blockDim.y + threadIdx.y
-
globalIdz
It returns the thread identifier for the third dimension.OpenCL equivalent: get_global_id(2);
PTX equivalent: blockIdx.z * blockDim.z + threadIdx.z
-
groupIdx
-
groupIdy
-
groupIdz
-
localIdx
-
localIdy
-
localIdz
-
globalGroupSizeX
It returns the global group size of a particular dimension (e.g. X, Y, Z).OpenCL equivalent: get_global_size();
PTX equivalent: gridDim * blockDim
-
globalGroupSizeY
-
globalGroupSizeZ
-
localGroupSizeX
It returns the global group size of a particular dimension (e.g. X, Y, Z).OpenCL equivalent: get_local_size();
PTX equivalent: blockDim
-
localGroupSizeY
-
localGroupSizeZ
-
-
Constructor Details
-
KernelContext
public KernelContext()Class constructor specifying a particularWorkerGridobject.
-
-
Method Details
-
localBarrier
public void localBarrier()Method used as a barrier to synchronize the order of memory operations to the local memory (known as shared memory in PTX).OpenCL equivalent: barrier(CLK_LOCAL_MEM_FENCE);
PTX equivalent: barrier.sync;
- Specified by:
localBarrierin interfaceExecutionContext
-
globalBarrier
public void globalBarrier()Method used as a barrier to synchronize the order of memory operations to the global memory.OpenCL equivalent: barrier(CLK_GLOBAL_MEM_FENCE);
PTX equivalent: barrier.sync;
- Specified by:
globalBarrierin interfaceExecutionContext
-
allocateIntLocalArray
public int[] allocateIntLocalArray(int size) It allocates a single dimensional array in local memory (known as shared memory in PTX).- Specified by:
allocateIntLocalArrayin interfaceExecutionContext- Parameters:
size- the size of the array- Returns:
- int[]: reference to the int array
-
allocateByteLocalArray
public byte[] allocateByteLocalArray(int size) It allocates a single dimensional array in local memory (known as shared memory in PTX).- Specified by:
allocateByteLocalArrayin interfaceExecutionContext- Parameters:
size- the size of the array- Returns:
- byte[]: reference to the byte array
-
allocateHalfFloatLocalArray
It allocates a single dimensional array in local memory (known as shared memory in PTX).- Specified by:
allocateHalfFloatLocalArrayin interfaceExecutionContext- Parameters:
size- the size of the array- Returns:
- HalfFloatArray: reference to the byte array
-
allocateLongLocalArray
public long[] allocateLongLocalArray(int size) It allocates a single dimensional array in local memory (known as shared memory in PTX).- Specified by:
allocateLongLocalArrayin interfaceExecutionContext- Parameters:
size- the size of the array- Returns:
- long[]: reference to the int array
-
allocateFloatLocalArray
public float[] allocateFloatLocalArray(int size) It allocates a single dimensional array in local memory (known as shared memory in PTX).- Specified by:
allocateFloatLocalArrayin interfaceExecutionContext- Parameters:
size- the size of the array- Returns:
- float[]: reference to the int array
-
allocateDoubleLocalArray
public double[] allocateDoubleLocalArray(int size) It allocates a single dimensional array in local memory (known as shared memory in PTX).- Specified by:
allocateDoubleLocalArrayin interfaceExecutionContext- Parameters:
size- the size of the array- Returns:
- double[]: reference to the int array
-
atomicAdd
Method used to read a memory address by using the array and the index, then add the value of val to it, and write the result back to the same address.PTX equivalent: atomicAdd(int* address, int val);
- Specified by:
atomicAddin interfaceExecutionContext
-
atomicAdd
public void atomicAdd(int[] array, int index, int val) Method used to read a memory address by using the array and the index, then add the value of val to it, and write the result back to the same address.PTX equivalent: atomicAdd(int* address, int val);
- Specified by:
atomicAddin interfaceExecutionContext
-
atomicAdd
Method used to read a memory address by using the array and the index, then add the value of val to it, and write the result back to the same address.PTX equivalent: atomicAdd(long* address, long val);
- Specified by:
atomicAddin interfaceExecutionContext
-
atomicAdd
Method used to read a memory address by using the array and the index, then add the value of val to it, and write the result back to the same address.PTX equivalent: atomicAdd(float* address, float val);
- Specified by:
atomicAddin interfaceExecutionContext
-
atomicAdd
Method used to read a memory address by using the array and the index, then add the value of val to it, and write the result back to the same address.PTX equivalent: atomicAdd(double* address, double val);
- Specified by:
atomicAddin interfaceExecutionContext
-