• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2023 Alyssa Rosenzweig
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #ifndef LIBAGX_H
7 #define LIBAGX_H
8 
9 /* Define stdint types compatible between the CPU and GPU for shared headers */
10 #ifndef __OPENCL_VERSION__
11 #include <stdint.h>
12 #include "util/macros.h"
13 #define GLOBAL(type_)            uint64_t
14 #define AGX_STATIC_ASSERT(_COND) static_assert(_COND, "OpenCL assertion")
15 #else
16 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
17 #define PACKED        __attribute__((packed, aligned(4)))
18 #define GLOBAL(type_) global type_ *
19 
20 typedef ulong uint64_t;
21 typedef uint uint32_t;
22 typedef ushort uint16_t;
23 typedef uint uint8_t;
24 
25 typedef long int64_t;
26 typedef int int32_t;
27 typedef short int16_t;
28 typedef int int8_t;
29 
30 /* Define NIR intrinsics for CL */
31 uint32_t nir_interleave_agx(uint16_t x, uint16_t y);
32 void nir_doorbell_agx(uint8_t value);
33 void nir_stack_map_agx(uint16_t index, uint32_t address);
34 uint32_t nir_stack_unmap_agx(uint16_t index);
35 uint32_t nir_load_core_id_agx(void);
36 uint32_t nir_load_helper_op_id_agx(void);
37 uint32_t nir_load_helper_arg_lo_agx(void);
38 uint32_t nir_load_helper_arg_hi_agx(void);
39 uint32_t nir_fence_helper_exit_agx(void);
40 
41 #define AGX_STATIC_ASSERT(_COND)                                               \
42    typedef char static_assertion_##__line__[(_COND) ? 1 : -1]
43 
44 #endif
45 
46 #endif
47