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/streams_diff_test.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 / streams_diff_test.c` 56 lines · 2973 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 /* streams_diff_test.c -- CUDApp#115 host differential: built only with CUDAPP_MIGRATION_PENDING_STREAMS_DIFF (mk/om-streams.mk). 3 * Runs omega_gpu_cmdlist_streams_diff_sweep (every chunk configuration through C and seeded Omega, abort on any 4 * difference), every AIEN_OMEGA_GPU_CHANNELS value class, and every extra queue index (both diffed in their callers). */ 5 #include "cudapp_native.h" 6 #include "omega_gpu_platform_linux.h" 7 #include "omega_gpu_session.h" 8 #include 9 #include 10 #include 11 #include 12 #include 13 14 uint64_t omega_gpu_cmdlist_streams_diff_sweep(void); 15 void cudapp_streams_diff_note(int same, const char *line); 16 17 /* Diff hook of src/omega_gpu_cmdlist.c / omega_gpu_session.c: SAME lines go to $CUDAPP_STREAMS_DIFF_LOG; a 18 * difference is printed and aborts. */ 19 void cudapp_streams_diff_note(int same, const char *line) { 20 if (!same) { fprintf(stderr, "%s\n", line); abort(); } 21 static FILE *f; 22 const char *log = getenv("CUDAPP_STREAMS_DIFF_LOG"); 23 if (!f && log) { int fd = open(log, O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, 0600); if (fd >= 0) { f = fdopen(fd, "a"); if (!f) close(fd); } } 24 if (f) fprintf(f, "%s\n", line); 25 } 26 27 int main(void) { 28 const uint64_t chunks = omega_gpu_cmdlist_streams_diff_sweep(); 29 static const char *const env[] = { "", "0", "1", "2", "3", "4", "5", "9", "22", "2x", "/", ":", "a" }; 30 unsigned nenv = 0; 31 unsetenv("AIEN_OMEGA_GPU_CHANNELS"); (void)omega_gpu_platform_linux_channels_env(); nenv++; 32 for (size_t i = 0; i < sizeof env / sizeof env[0]; i++) { 33 setenv("AIEN_OMEGA_GPU_CHANNELS", env[i], 1); 34 (void)omega_gpu_platform_linux_channels_env(); nenv++; 35 } 36 OmegaGpuQueueHandle q; 37 for (uint32_t i = 0; i < 6u; i++) (void)omega_gpu_session_extra_queue(i, &q); /* no device: admission still diffed */ 38 /* The session holds no open queues here, so the extra-queue rule is also checked on every open set directly: 39 * om/streams/xq.om against the rule of xq_admit_c (src/omega_gpu_session.c). */ 40 unsigned nxq = 0; 41 for (uint64_t i = 0; i < 6u; i++) for (uint64_t open = 0; open < 16u; open++) { 42 uint64_t want = 3, r = 99; 43 if (i == 0 || i > 3) want = 0; 44 else if ((open >> i) & 1u) want = 1; 45 else for (uint64_t j = 1; j < i; j++) if (!((open >> j) & 1u)) { want = 2; break; } 46 if (omega_streams_xq(&r, i, open) != 0 || r != want) { 47 fprintf(stderr, "streams diff: extra queue i=%llu open=%llx Omega %llu C %llu\n", (unsigned long long)i, 48 (unsigned long long)open, (unsigned long long)r, (unsigned long long)want); 49 abort(); 50 } 51 nxq++; 52 } 53 printf("streams diff sweep: %llu chunks, %u channel values, 6 extra queue indexes, %u extra queue open sets: C and Omega identical\n", 54 (unsigned long long)chunks, nenv, nxq); 55 return chunks ? 0 : 1; 56 }