interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / tests / dagsim / jstr_diff.c

25 lines · 1020 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2#define main dagsim_unused_main
3#include "../../tools/dagsim/dagsim_cli.c"
4#undef main
5#include "../../src/cudapp_native.h"
6int main(int argc, char **argv) {
7 if (argc > 1 && !strcmp(argv[1], "--stream")) {
8 char s[2] = {0, 0};
9 jstr(s);
10 for (unsigned c = 1; c < 256; ++c) { s[0] = (char)c; jstr(s); }
11 return 0;
12 }
13 for (unsigned c = 0; c < 256; ++c) {
14 unsigned char b[6] = {0}; uint64_t n = 0; char want[8]; int len;
15 if (c == '"' || c == '\\') len = snprintf(want, sizeof want, "\\%c", c);
16 else if (c < 32) len = snprintf(want, sizeof want, "\\u%04x", c);
17 else { want[0] = (char)c; len = 1; }
18 if (omega_dag_jstr(&n, c, b, sizeof b)) return 2;
19 if (argc > 1) b[0] ^= 1;
20 if (n != (uint64_t)len || memcmp(b, want, n)) {
21 fprintf(stderr, "byte %u differs\n", c); return 1;
22 }
23 }
24 puts("JSON BYTE DIFFERENTIAL PASS all 256 bytes"); return 0;
25}