Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/platform_linux_wait.c # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / platform_linux_wait.c` 50 lines · 2188 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 /* Marker poll through mapget. No device is opened. A memfd is the fixture. 3 * WolframLanguageEvaluator: {2^31, 2^32-1, `1000000`/50000, 2000*(`1000000`/50000)} 4 * -> {`2147483648`, `4294967295`, 20, 40000}. */ 5 #include "../om/platform-linux/gen/plat_wait.h" 6 #include 7 #include 8 #include 9 #include 10 #include 11 12 int main(void) { 13 int fd = memfd_create("plat-wait", 0); 14 assert(fd >= 0); 15 assert(ftruncate(fd, 4096) == 0); 16 uint32_t *p = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); 17 assert(p != MAP_FAILED); 18 uint64_t h = 0, r = 0; 19 /* WolframLanguageEvaluator: 256*1024*1024 -> `268435456`. Alias, not the C mmap address. */ 20 assert(omega2_plat_wait_hold(&h, 268435456ull, 4096) == 0 && (int64_t)h > 0); 21 assert(omega2_plat_wait_bind(&r, h, (uint64_t)fd) == 0 && (int64_t)r == 0); 22 23 p[1] = 5; 24 assert(omega2_plat_wait_ge(&r, h, 4, 5, 1) == 0 && (int64_t)r == 0); 25 p[1] = 4; 26 assert(omega2_plat_wait_ge(&r, h, 4, 5, 2) == 0 && (int64_t)r == -1); 27 /* 32-bit wrap: 1 is two past 0xfffffffe. An unmasked compare would miss it. */ 28 p[1] = 1; 29 assert(omega2_plat_wait_ge(&r, h, 4, 0xfffffffe, 1) == 0 && (int64_t)r == 0); 30 p[1] = 0xfffffffd; 31 assert(omega2_plat_wait_ge(&r, h, 4, 0xfffffffe, 1) == 0 && (int64_t)r == -1); 32 /* zero polls still reads once */ 33 p[1] = 9; 34 assert(omega2_plat_wait_ge(&r, h, 4, 9, 0) == 0 && (int64_t)r == 0); 35 36 assert(omega2_plat_wait_budget(&r, 0) == 0 && r == 0); 37 assert(omega2_plat_wait_budget(&r, 1) == 0 && r == 20); 38 assert(omega2_plat_wait_budget(&r, 2000) == 0 && r == 40000); 39 assert(omega2_plat_wait_budget(&r, 2001) == 0 && r == 40000); 40 41 omega_native_context *foreign = NULL; 42 assert(omega_native_context_create(4, &foreign) == 0); 43 uint32_t st = omega2_ctx_plat_wait_ge(foreign, &r, h, 4, 1, 1); 44 assert(st != 0); 45 assert(omega_native_context_destroy(foreign) == 0); 46 assert(omega2_plat_wait_drop(&r, h) == 0 && (int64_t)r == 0); 47 assert(munmap(p, 4096) == 0 && close(fd) == 0); 48 printf("PASS platform linux wait\n"); 49 return 0; 50 }