A Modern GPGPU API & wip linux RDNA2+ Driver
rdna driver linux gpu
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

documentation work

+246 -53
+8 -25
docs/_static/custom.css
··· 1 - /* docs/_static/custom.css */ 2 - 3 - /* Target the container that doxygenfile creates */ 4 - .breathe-sectiondef { 5 - margin-left: 0px !important; 6 - padding-left: 15px; 7 - border-left: 2px solid #e1e4e5; /* Subtle vertical line for grouping */ 8 - margin-bottom: 40px; 1 + dl.function, 2 + dl.struct, 3 + dl.enum, 4 + dl.type { 5 + margin-top: 2em; 6 + background-color: #ecf0f3; 9 7 } 10 - 11 - /* Style the 'Typedefs', 'Functions', 'Enums' headers */ 12 - .breathe-sectiondef-title { 13 - font-family: "Roboto Slab", "ff-tisa-web-pro", "Georgia", serif; 14 - font-size: 1.2em; 15 - font-weight: bold; 16 - color: #333; 17 - border-bottom: 1px solid #eee; 18 - margin-bottom: 15px; 19 - padding-bottom: 5px; 20 - text-transform: uppercase; 21 - letter-spacing: 0.05em; 22 - } 23 - 24 - /* The actual function/member blocks */ 25 - .breathe-definition { 26 - margin-bottom: 25px !important; 8 + dt.sig-object { 9 + display: block !important; 27 10 }
+1 -1
docs/api/index.rst
··· 6 6 7 7 .. note:: 8 8 The API docs are generated from :file:`kestrel/include/kestrel/kestrel.h`. 9 - To update this documentation, please edit the header file. 9 + To update this documentation, please also edit the header file. 10 10 11 11 .. toctree:: 12 12 :hidden:
+6
docs/api/init.rst
··· 1 1 Initialization 2 2 ============== 3 + 4 + 5 + .. doxygentypedef:: KesDevice 6 + 7 + .. doxygenfunction:: kes_create 8 + .. doxygenfunction:: kes_destroy
+3 -3
docs/conf.py.in
··· 17 17 return "Unknown" 18 18 return "Unknown" 19 19 20 - project = '@PROJECT_NAME@' 20 + project = 'kestrel' 21 21 copyright = '@PROJECT_COPYRIGHT@, @PROJECT_AUTHORS@' 22 22 author = '@PROJECT_AUTHORS@' 23 23 ··· 59 59 "conf_py_path": "/docs/" 60 60 } 61 61 62 - breathe_projects = { "@PROJECT_NAME@": "@CMAKE_CURRENT_BINARY_DIR@/xml" } 63 - breathe_default_project = "@PROJECT_NAME@" 62 + breathe_projects = { "kestrel": "@CMAKE_CURRENT_BINARY_DIR@/xml" } 63 + breathe_default_project = "kestrel" 64 64 65 65 nitpick_ignore = [ 66 66 ('cpp:identifier', 'uint64_t'),
+1 -1
docs/drivers/architecture.rst
··· 4 4 Each driver library (`libkestrel_<platform>.so`) exports only 5 5 a single symbol. 6 6 7 - .. doxygenfile:: kestrel/interface.h 7 + 8 8 9 9 When a new Device is created, the Kestrel runtime iterates 10 10 the available DRM devices on the system, and tries to resolve
+22 -12
kestrel/include/kestrel/interface.h
··· 6 6 extern "C" { 7 7 #endif 8 8 9 + /** 10 + * Holds the set of functions exported by the driver, as well as the version. 11 + * @sa kes_drv_interface 12 + */ 9 13 struct KesDriverFuncs { 14 + /** 15 + * Version 16 + */ 10 17 uint32_t version; 11 - KesDevice (*fn_create)(int drm_fd); 12 - typeof(kes_destroy) *fn_destroy; 13 - typeof(kes_malloc) *fn_malloc; 14 - typeof(kes_free) *fn_free; 15 - typeof(kes_create_queue) *fn_create_queue; 16 - typeof(kes_destroy_queue) *fn_destroy_queue; 17 - typeof(kes_start_recording) *fn_start_recording; 18 - typeof(kes_submit) *fn_submit; 19 - typeof(kes_cmd_memset) *fn_cmd_memset; 20 - typeof(kes_cmd_write_timestamp) *fn_cmd_write_timestamp; 21 - typeof(kes_cmd_signal_after) *fn_cmd_signal_after; 22 - typeof(kes_cmd_wait_before) *fn_cmd_wait_before; 18 + KesDevice (*fn_create)(int drm_fd); 19 + void (*fn_destroy)(KesDevice); 20 + struct KesAllocation (*fn_malloc)(KesDevice, size_t size, size_t align, enum KesMemory); 21 + void (*fn_free)(KesDevice, struct KesAllocation *); 22 + KesQueue (*fn_create_queue)(KesDevice, enum KesQueueType); 23 + void (*fn_destroy_queue)(KesQueue); 24 + KesCommandList (*fn_start_recording)(KesQueue); 25 + void (*fn_submit)(KesQueue, KesCommandList); 26 + void (*fn_cmd_memset)(KesCommandList, kes_gpuptr_t addr, size_t size, uint32_t value); 27 + void (*fn_cmd_write_timestamp)(KesCommandList, kes_gpuptr_t addr); 28 + void (*fn_cmd_signal_after)(KesCommandList, enum KesStage before, kes_gpuptr_t addr, uint64_t value, enum KesSignal); 29 + void (*fn_cmd_wait_before)(KesCommandList, enum KesStage after, kes_gpuptr_t addr, uint64_t value, enum KesOp, enum KesHazardFlags, uint64_t mask); 23 30 }; 24 31 32 + /** 33 + * 34 + */ 25 35 void kes_drv_interface(struct KesDriverFuncs *fns); 26 36 27 37 #ifdef __cplusplus
+205 -11
kestrel/include/kestrel/kestrel.h
··· 1 1 #pragma once 2 2 3 + /** 4 + * @file kestrel.h 5 + * @brief Core Kestrel API 6 + */ 7 + 3 8 #include <cstdint> 4 9 #include <stddef.h> 5 10 #include <stdint.h> ··· 8 13 extern "C" { 9 14 #endif 10 15 16 + /** 17 + * GPU pointer type. 18 + */ 11 19 typedef uint64_t kes_gpuptr_t; 20 + /** 21 + * Opaque handle to a Device. 22 + */ 12 23 typedef void *KesDevice; 24 + /** 25 + * Opaque handle to a Command Queue. 26 + */ 13 27 typedef void *KesQueue; 28 + /** 29 + * Opaque handle to a Command List. 30 + */ 14 31 typedef void *KesCommandList; 15 32 33 + /** 34 + * Structure describing a memory allocation. 35 + * @sa kes_malloc 36 + */ 16 37 struct KesAllocation { 38 + /** 39 + * Pointer to the CPU-accessible memory. 40 + */ 17 41 void *cpu; 42 + /** 43 + * GPU pointer to the allocated memory. 44 + */ 18 45 kes_gpuptr_t gpu; 46 + /** 47 + * Size of the allocation in bytes. 48 + */ 19 49 size_t size; 50 + /** 51 + * Internal driver-specific data. Should not be modified directly. 52 + */ 20 53 void *_internal; 21 54 }; 22 55 56 + /** 57 + * Memory types for allocation. 58 + * @sa kes_malloc 59 + */ 23 60 enum KesMemory { 61 + /** 62 + * Memory type suitable for most data (uniforms, etc). Always visible to both the CPU and GPU. 63 + */ 24 64 KesMemoryDefault, 65 + /** 66 + * Memory type optimized for GPU access, not visible to the CPU. Use for large buffers or textures 67 + * that the CPU does not need to read or write. 68 + */ 25 69 KesMemoryGpu, 70 + /** 71 + * Memory type optimized for CPU readback. Visible to both CPU and GPU, but optimized for CPU reads. 72 + */ 26 73 KesMemoryReadback 27 74 }; 28 75 76 + /** 77 + * Special flags for wait operations. 78 + * @sa kes_cmd_wait_before 79 + */ 29 80 enum KesHazardFlags { 81 + /** 82 + * No special hazard flags. 83 + */ 30 84 KesHazardFlagsNone = 0, 85 + /** 86 + * Indicates that the wait is for draw arguments. 87 + */ 31 88 KesHazardFlagsDrawArguments = 1 << 0, 89 + /** 90 + * Indicates that the wait is for descriptor updates. 91 + */ 32 92 KesHazardFlagsDescriptors = 1 << 1, 33 93 }; 34 94 95 + /** 96 + * Comparison operations for wait operations. 97 + * @sa kes_cmd_wait_before 98 + */ 35 99 enum KesOp { 100 + /** 101 + * Never pass the wait. 102 + */ 36 103 KesOpNever, 104 + /** 105 + * Pass the wait if the value is less than the specified value. 106 + */ 37 107 KesOpLess, 108 + /** 109 + * Pass the wait if the value is equal to the specified value. 110 + */ 38 111 KesOpEqual 39 112 }; 40 113 114 + /** 115 + * Signal operations for signal operations. 116 + * @sa kes_cmd_signal_after 117 + */ 41 118 enum KesSignal { 119 + /** 120 + * Set the value atomically. 121 + */ 42 122 KesSignalAtomicSet, 123 + /** 124 + * Set the value to the maximum of the current and specified value atomically. 125 + */ 43 126 KesSignalAtomicMax, 127 + /** 128 + * Perform a bitwise OR with the specified value atomically. 129 + */ 44 130 KesSignalAtomicOr, 45 131 }; 46 132 133 + /** 134 + * Pipeline stages for synchronization. 135 + * @sa kes_cmd_signal_after, kes_cmd_wait_before 136 + */ 47 137 enum KesStage { 138 + /** 139 + * Transfer stage. Should only be used on transfer queues. 140 + */ 48 141 KesStageTransfer, 142 + /** 143 + * Compute stage. 144 + */ 49 145 KesStageCompute, 146 + /** 147 + * Raster color output stage (e.g., render target writes). 148 + */ 50 149 KesStageRasterColorOut, 150 + /** 151 + * Pixel shader stage. 152 + */ 51 153 KesStagePixelShader, 154 + /** 155 + * Vertex shader stage. 156 + */ 52 157 KesStageVertexShader 53 158 }; 54 159 160 + /** 161 + * Types of command queues. 162 + * @sa kes_create_queue 163 + */ 55 164 enum KesQueueType { 165 + /** 166 + * Graphics queue, capable of rasterization and compute. 167 + */ 56 168 KesQueueTypeGraphics, 169 + /** 170 + * Compute-only queue. 171 + */ 57 172 KesQueueTypeCompute, 173 + /** 174 + * Transfer-only queue, optimized for memory copy and fill operations. 175 + */ 58 176 KesQueueTypeTransfer 59 177 }; 60 178 179 + /** 180 + * Create a new Device. 181 + * @return A handle to the created device. 182 + */ 61 183 KesDevice kes_create(); 62 - void kes_destroy(KesDevice); 63 184 64 - struct KesAllocation kes_malloc(KesDevice, size_t size, size_t align, KesMemory); 65 - void kes_free(KesDevice, struct KesAllocation *); 185 + /** 186 + * Destroy a Device. 187 + * @param device The device to destroy. 188 + */ 189 + void kes_destroy(KesDevice device); 66 190 67 - KesQueue kes_create_queue(KesDevice, KesQueueType); 68 - void kes_destroy_queue(KesQueue); 191 + /** 192 + * Allocate memory on the device. 193 + * @param device The device to allocate memory on. 194 + * @param size The size of the allocation in bytes. 195 + * @param align The alignment of the allocation in bytes. 196 + * @param memory The type of memory to allocate. 197 + * @return A KesAllocation structure describing the allocated memory. 198 + */ 199 + struct KesAllocation kes_malloc(KesDevice device, size_t size, size_t align, enum KesMemory memory); 69 200 70 - KesCommandList kes_start_recording(KesQueue); 201 + /** 202 + * Free a previously allocated memory allocation. 203 + * @param device The device the memory was allocated on. 204 + * @param allocation The allocation to free. 205 + */ 206 + void kes_free(KesDevice device, struct KesAllocation *allocation); 71 207 72 - void kes_submit(KesQueue, KesCommandList); 208 + /** 209 + * Create a command queue on the device. 210 + * @param device The device to create the queue on. 211 + * @param type The type of queue to create. 212 + * @return A handle to the created queue. 213 + */ 214 + KesQueue kes_create_queue(KesDevice device, enum KesQueueType type); 73 215 74 - void kes_cmd_memset(KesCommandList, kes_gpuptr_t addr, size_t size, uint32_t value); 75 - void kes_cmd_write_timestamp(KesCommandList, kes_gpuptr_t addr); 216 + /** 217 + * Destroy a command queue. 218 + * @param queue The queue to destroy. 219 + */ 220 + void kes_destroy_queue(KesQueue queue); 76 221 77 - void kes_cmd_signal_after(KesCommandList, KesStage before, kes_gpuptr_t addr, uint64_t value, KesSignal); 78 - void kes_cmd_wait_before(KesCommandList, KesStage after, kes_gpuptr_t addr, uint64_t value, KesOp, KesHazardFlags, uint64_t mask); 222 + /** 223 + * Start recording commands on a command queue. 224 + * @param queue The queue to record commands on. 225 + * @return A handle to the command list for recording commands. 226 + */ 227 + KesCommandList kes_start_recording(KesQueue queue); 228 + 229 + /** 230 + * Submit a recorded command list to a command queue for execution. 231 + * @param queue The queue to submit the command list to. Must be the queue that the command list was created for. 232 + * @param command_list The command list to submit. 233 + */ 234 + void kes_submit(KesQueue queue, KesCommandList command_list); 235 + 236 + /** 237 + * Record a memory set command in the command list. 238 + * @param command_list The command list to record the command in. 239 + * @param addr The GPU address to set memory at. 240 + * @param size The size of the memory to set in bytes. 241 + * @param value The value to set each byte to. 242 + */ 243 + void kes_cmd_memset(KesCommandList command_list, kes_gpuptr_t addr, size_t size, uint32_t value); 244 + 245 + /** 246 + * Record a timestamp write command in the command list. Writes a 64-bit unsigned timestamp in ticks to the provided address. 247 + * @param command_list The command list to record the command in. 248 + * @param addr The GPU address to write the timestamp to. 249 + */ 250 + void kes_cmd_write_timestamp(KesCommandList command_list, kes_gpuptr_t addr); 251 + 252 + /** 253 + * Record a signal command in the command list. 254 + * @param command_list The command list to record the command in. 255 + * @param before The pipeline stage before which the signal should occur. 256 + * @param addr The GPU address to signal to. 257 + * @param value The value to signal. 258 + * @param signal The type of signal operation to perform. 259 + */ 260 + void kes_cmd_signal_after(KesCommandList command_list, enum KesStage before, kes_gpuptr_t addr, uint64_t value, enum KesSignal signal); 261 + 262 + /** 263 + * Record a wait command in the command list. 264 + * @param command_list The command list to record the command in. 265 + * @param after The pipeline stage after which the wait should occur. 266 + * @param addr The GPU address to wait on. 267 + * @param value The value to compare against. 268 + * @param op The comparison operation to use. 269 + * @param hazard_flags Special hazard flags for the wait operation. 270 + * @param mask A bitmask to apply to the value before comparison. 271 + */ 272 + void kes_cmd_wait_before(KesCommandList command_list, enum KesStage after, kes_gpuptr_t addr, uint64_t value, enum KesOp op, enum KesHazardFlags hazard_flags, uint64_t mask); 79 273 80 274 #ifdef __cplusplus 81 275 }