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.

api: added memcpy

+56
+2
kestrel/include/kestrel/interface.h
··· 1 1 #pragma once 2 2 3 + #include "kestrel.h" 3 4 #include "kestrel/kestrel.h" 4 5 5 6 #ifdef __cplusplus ··· 24 25 KesCommandList (*fn_start_recording)(KesQueue); 25 26 void (*fn_submit)(KesQueue, KesCommandList); 26 27 void (*fn_cmd_memset)(KesCommandList, kes_gpuptr_t addr, size_t size, uint32_t value); 28 + void (*fn_cmd_memcpy)(KesCommandList, kes_gpuptr_t dst, kes_gpuptr_t src, size_t size); 27 29 void (*fn_cmd_write_timestamp)(KesCommandList, kes_gpuptr_t addr); 28 30 void (*fn_cmd_signal_after)(KesCommandList, enum KesStage before, kes_gpuptr_t addr, uint64_t value, enum KesSignal); 29 31 void (*fn_cmd_wait_before)(KesCommandList, enum KesStage after, kes_gpuptr_t addr, uint64_t value, enum KesOp, enum KesHazardFlags, uint64_t mask);
+9
kestrel/include/kestrel/kestrel.h
··· 243 243 void kes_cmd_memset(KesCommandList command_list, kes_gpuptr_t addr, size_t size, uint32_t value); 244 244 245 245 /** 246 + * Record a memory copy command in the command list. 247 + * @param command_list The command list to record the command in. 248 + * @param dst The GPU address to copy memory to. 249 + * @param src The GPU address to copy memory from. 250 + * @param size The size of the copy in bytes. 251 + */ 252 + void kes_cmd_memcpy(KesCommandList command_list, kes_gpuptr_t dst, kes_gpuptr_t src, size_t size); 253 + 254 + /** 246 255 * Record a timestamp write command in the command list. Writes a 64-bit unsigned timestamp in ticks to the provided address. 247 256 * @param command_list The command list to record the command in. 248 257 * @param addr The GPU address to write the timestamp to.
+8
kestrel/rt/api.cpp
··· 172 172 173 173 dev->fns.fn_cmd_memset(clhandle->cmdlist, addr, size, value); 174 174 } 175 + 176 + API_EXPORT void kes_cmd_memcpy(KesCommandList pcl, kes_gpuptr_t dst, kes_gpuptr_t src, size_t size) { 177 + auto *clhandle = reinterpret_cast<CommandListHandle *>(pcl); 178 + auto *dev = clhandle->dev; 179 + 180 + dev->fns.fn_cmd_memcpy(clhandle->cmdlist, dst, src, size); 181 + } 182 + 175 183 API_EXPORT void kes_cmd_write_timestamp(KesCommandList pcl, kes_gpuptr_t addr) { 176 184 auto *clhandle = reinterpret_cast<CommandListHandle *>(pcl); 177 185 auto *dev = clhandle->dev;
+37
test/test/05_hello_transfer_copy/transfer_copy.cpp
··· 1 + #include <unistd.h> 2 + #include <kestrel/kestrel.h> 3 + 4 + #include <stdio.h> 5 + 6 + int main(void) { 7 + 8 + auto dev = kes_create(); 9 + 10 + std::size_t size = 10 * 1024 * 1024; 11 + auto x = kes_malloc(dev, size, 4, KesMemoryDefault); 12 + auto y = kes_malloc(dev, size, 4, KesMemoryDefault); 13 + 14 + printf("x: %p (%p) (%llu bytes)\n", x.cpu, x.gpu, x.size); 15 + printf("y: %p (%p) (%llu bytes)\n", y.cpu, y.gpu, y.size); 16 + 17 + auto dma = kes_create_queue(dev, KesQueueTypeTransfer); 18 + 19 + sleep(1); 20 + 21 + auto l1 = kes_start_recording(dma); 22 + kes_cmd_memset(l1, x.gpu, size, 2); 23 + kes_cmd_memcpy(l1, y.gpu, x.gpu, size); 24 + kes_submit(dma, l1); 25 + 26 + // @todo: hacky bussy-wait 27 + printf("x[0]: %u\n", ((uint32_t *)x.cpu)[0]); 28 + printf("y[0]: %u\n", ((uint32_t *)y.cpu)[0]); 29 + sleep(1); 30 + printf("x[0]: %u\n", ((uint32_t *)x.cpu)[0]); 31 + printf("y[0]: %u\n", ((uint32_t *)y.cpu)[0]); 32 + 33 + kes_free(dev, &x); 34 + kes_destroy(dev); 35 + 36 + return 0; 37 + }