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.

test: added unit tests (broken)

+60
+60
test/unit/test.cpp
··· 1 + #include "test_utils.h" 2 + #include <catch2/catch_test_macros.hpp> 3 + #include <catch2/generators/catch_generators.hpp> 4 + #include <cstdlib> 5 + 6 + TEST_CASE("Device creation and alloc") { 7 + DeviceGuard device; 8 + 9 + auto x = kes_malloc(device.dev, 256, 4, KesMemoryDefault); 10 + 11 + REQUIRE(x.cpu != 0); 12 + REQUIRE(x.gpu != 0); 13 + } 14 + 15 + /* 16 + TEST_CASE("Cross-queue synchronization", "[sync][queue]") { 17 + DeviceGuard device; 18 + 19 + // Test parameters 20 + auto size = GENERATE(1024, 1024*1024, 10*1024*1024); 21 + 22 + SECTION("Transfer -> Compute sync with signal") { 23 + auto buffer = device.alloc(size); 24 + auto signal_mem = device.alloc(4); 25 + TimestampReader timestamps(device.dev, 4); 26 + 27 + auto dma = kes_create_queue(device.dev, KesQueueTypeTransfer); 28 + auto compute = kes_create_queue(device.dev, KesQueueTypeCompute); 29 + 30 + // DMA: memset + signal 31 + auto l1 = kes_start_recording(dma); 32 + kes_cmd_write_timestamp(l1, timestamps.gpu_ptr(0)); 33 + kes_cmd_memset(l1, buffer.gpu, size, 0x42); 34 + kes_cmd_write_timestamp(l1, timestamps.gpu_ptr(1)); 35 + kes_cmd_signal_after(l1, KesStageTransfer, signal_mem.gpu, 36 + 0x13, KesSignalAtomicSet); 37 + 38 + // Compute: wait + timestamp 39 + auto l2 = kes_start_recording(compute); 40 + kes_cmd_write_timestamp(l2, timestamps.gpu_ptr(2)); 41 + kes_cmd_wait_before(l2, KesStageTransfer, signal_mem.gpu, 42 + 0x13, KesOpEqual, KesHazardFlagsNone, ~0); 43 + kes_cmd_write_timestamp(l2, timestamps.gpu_ptr(3)); 44 + 45 + kes_submit(dma, l1); 46 + kes_submit(compute, l2); 47 + 48 + // Wait for completion 49 + busy_wait_for_value(signal_mem.cpu, 0x13); 50 + 51 + // Verify memory was set 52 + // REQUIRE(((uint32_t *)buffer.cpu)[0] == 0x42); 53 + // REQUIRE(((uint32_t *)buffer.cpu)[size-1] == 0x42); 54 + 55 + // Verify timestamp ordering: t0 <= t1 <= t3, t2 <= t3 56 + timestamps.check_ordering({0, 1, 3}); 57 + timestamps.check_ordering({2, 3}); 58 + } 59 + } 60 + */