CCCC
C bytecode compiler + VM interpreter
Loading...
Searching...
No Matches
kernel.h
Go to the documentation of this file.
1/*
2 CCCC: Comprehensiev C Compensation Compiler - Kernel Execution Model
3
4 Copyright (C) 2025 George Watson
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>.
18*/
19
26#ifndef CCCC_KERNEL_H
27#define CCCC_KERNEL_H
28
29#include <stddef.h>
30
33#define CCCC_LOCAL_FENCE 1
34#define CCCC_GLOBAL_FENCE 2
35
38typedef struct {
39 unsigned dims;
40 size_t size[3];
42
43#define CCCC_RANGE_DIMS_(_1, _2, _3, N, ...) N
44
46#define CCCC_RANGE(...) \
47 ((cccc_range){CCCC_RANGE_DIMS_(__VA_ARGS__, 3, 2, 1), {__VA_ARGS__}})
48
57#define cccc_launch(k, g, l, ...) \
58 __builtin_kernel_launch(k, g, l, ##__VA_ARGS__)
59
62#define CCCC_LOCAL(bytes) __builtin_kernel_local(bytes)
63
65size_t cccc_global_id(unsigned dim);
67size_t cccc_local_id(unsigned dim);
69size_t cccc_group_id(unsigned dim);
71size_t cccc_global_size(unsigned dim);
73size_t cccc_local_size(unsigned dim);
75size_t cccc_num_groups(unsigned dim);
77unsigned cccc_work_dim(void);
78
80void cccc_barrier(unsigned fences);
81
82#endif
size_t cccc_global_id(unsigned dim)
Index of the calling work-item in the whole range, per dimension.
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_group_id(unsigned dim)
Index of the calling work-item's work-group.
void cccc_barrier(unsigned fences)
Waits until every work-item of the group has reached the barrier.
size_t cccc_num_groups(unsigned dim)
Number of work-groups.
unsigned cccc_work_dim(void)
Dimensions of the launch (1 outside a launch).
size_t cccc_local_id(unsigned dim)
Index of the calling work-item within its work-group.
An NDRange extent of one to three dimensions. Build one with CCCC_RANGE.
Definition kernel.h:38
unsigned dims
Definition kernel.h:39