1 /* 2 * Copyright 2023 Asahi Lina 3 * SPDX-License-Identifier: MIT 4 */ 5 6 #ifndef LIBAGX_HELPER_H 7 #define LIBAGX_HELPER_H 8 9 #include "agx_pack.h" 10 #include "libagx.h" 11 12 // Enable this to debug core mappings. 13 // #define SCRATCH_DEBUG_CORES 512 14 15 #define AGX_SPILL_SIZE_BUCKETS 16 16 17 #define AGX_MAX_CORES_PER_CLUSTER 16 18 #define AGX_MAX_CLUSTERS 8 19 20 #ifdef SCRATCH_DEBUG_CORES 21 #define AGX_MAX_CORE_ID SCRATCH_DEBUG_CORES 22 #else 23 #define AGX_MAX_CORE_ID (AGX_MAX_CLUSTERS * AGX_MAX_CORES_PER_CLUSTER) 24 #endif 25 26 struct agx_helper_block { 27 uint32_t blocks[4]; 28 } PACKED; 29 AGX_STATIC_ASSERT(sizeof(struct agx_helper_block) == 16); 30 31 struct agx_helper_core { 32 GLOBAL(struct agx_helper_block) blocklist; 33 uint32_t alloc_cur; 34 uint32_t alloc_max; 35 uint32_t alloc_failed; 36 uint32_t _pad; 37 uint32_t alloc_count[AGX_SPILL_SIZE_BUCKETS]; 38 } PACKED; 39 AGX_STATIC_ASSERT(sizeof(struct agx_helper_core) == 40 (8 + 3 * 4 + AGX_SPILL_SIZE_BUCKETS * 4 + 4)); 41 42 struct agx_helper_header { 43 uint32_t subgroups; 44 uint32_t _pad; 45 struct agx_helper_core cores[AGX_MAX_CORE_ID]; 46 } PACKED; 47 AGX_STATIC_ASSERT(sizeof(struct agx_helper_header) == 48 (4 + 4 + AGX_MAX_CORE_ID * sizeof(struct agx_helper_core))); 49 50 #endif 51