CCCC
C bytecode compiler + VM interpreter
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
kernel.h File Reference

Work-item builtins and the launch builtin for [[cccc::kernel]] functions. See docs/kernels.md. More...

#include <stddef.h>
Include dependency graph for kernel.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cccc_range
 An NDRange extent of one to three dimensions. Build one with CCCC_RANGE. More...
 

Macros

#define CCCC_LOCAL_FENCE   1
 Memory fence flags for cccc_barrier(). Every flag orders the same in the VM.
 
#define CCCC_GLOBAL_FENCE   2
 
#define CCCC_RANGE_DIMS_(_1, _2, _3, N, ...)   N
 
#define CCCC_RANGE(...)    ((cccc_range){CCCC_RANGE_DIMS_(__VA_ARGS__, 3, 2, 1), {__VA_ARGS__}})
 CCCC_RANGE(x), CCCC_RANGE(x, y) or CCCC_RANGE(x, y, z).
 
#define cccc_launch(k, g, l, ...)    __builtin_kernel_launch(k, g, l, ##__VA_ARGS__)
 Launches a kernel over global work-items in work-groups of local.
 
#define CCCC_LOCAL(bytes)   __builtin_kernel_local(bytes)
 Argument for a [[cccc::local]] pointer parameter: bytes of work-group memory.
 

Functions

size_t cccc_global_id (unsigned dim)
 Index of the calling work-item in the whole range, per dimension.
 
size_t cccc_local_id (unsigned dim)
 Index of the calling work-item within its work-group.
 
size_t cccc_group_id (unsigned dim)
 Index of the calling work-item's work-group.
 
size_t cccc_global_size (unsigned dim)
 Size of the whole range.
 
size_t cccc_local_size (unsigned dim)
 Size of a work-group.
 
size_t cccc_num_groups (unsigned dim)
 Number of work-groups.
 
unsigned cccc_work_dim (void)
 Dimensions of the launch (1 outside a launch).
 
void cccc_barrier (unsigned fences)
 Waits until every work-item of the group has reached the barrier.
 

Detailed Description

Work-item builtins and the launch builtin for [[cccc::kernel]] functions. See docs/kernels.md.

Macro Definition Documentation

◆ CCCC_GLOBAL_FENCE

#define CCCC_GLOBAL_FENCE   2

◆ cccc_launch

#define cccc_launch (   k,
  g,
  l,
  ... 
)     __builtin_kernel_launch(k, g, l, ##__VA_ARGS__)

Launches a kernel over global work-items in work-groups of local.

Parameters
kKernel function (or pointer to one) marked [[cccc::kernel]].
gGlobal range, a cccc_range.
lWork-group range, a cccc_range of the same dimensions.
Note
The remaining arguments are checked against the kernel's parameters like an ordinary call. A [[cccc::local]] pointer parameter takes CCCC_LOCAL(bytes). Returns when every work-item has finished.

◆ CCCC_LOCAL

#define CCCC_LOCAL (   bytes)    __builtin_kernel_local(bytes)

Argument for a [[cccc::local]] pointer parameter: bytes of work-group memory.

◆ CCCC_LOCAL_FENCE

#define CCCC_LOCAL_FENCE   1

Memory fence flags for cccc_barrier(). Every flag orders the same in the VM.

◆ CCCC_RANGE

#define CCCC_RANGE (   ...)     ((cccc_range){CCCC_RANGE_DIMS_(__VA_ARGS__, 3, 2, 1), {__VA_ARGS__}})

◆ CCCC_RANGE_DIMS_

#define CCCC_RANGE_DIMS_ (   _1,
  _2,
  _3,
  N,
  ... 
)    N

Function Documentation

◆ cccc_barrier()

void cccc_barrier ( unsigned  fences)

Waits until every work-item of the group has reached the barrier.

◆ cccc_global_id()

size_t cccc_global_id ( unsigned  dim)

Index of the calling work-item in the whole range, per dimension.

◆ cccc_global_size()

size_t cccc_global_size ( unsigned  dim)

Size of the whole range.

◆ cccc_group_id()

size_t cccc_group_id ( unsigned  dim)

Index of the calling work-item's work-group.

◆ cccc_local_id()

size_t cccc_local_id ( unsigned  dim)

Index of the calling work-item within its work-group.

◆ cccc_local_size()

size_t cccc_local_size ( unsigned  dim)

Size of a work-group.

◆ cccc_num_groups()

size_t cccc_num_groups ( unsigned  dim)

Number of work-groups.

◆ cccc_work_dim()

unsigned cccc_work_dim ( void  )

Dimensions of the launch (1 outside a launch).