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 / no_posix_native.c

55 lines · 2434 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2/* Verification-only transport. No device or driver dependency. */
3#include <stdint.h>
4#include "omega_native.h"
5static uint64_t ins[8192], phys[288], meta[104], image[16777216], result[16];
6static uint8_t code[16384], name[64], text[16777216];
7static int exercise(void) {
8 uint64_t bytes = 0;
9 if (omega2_bw_enc_sm121(&bytes, ins, 8192, phys, 288, 0, 1, code, 16384) || bytes != 512) return 1;
10 if (code[0] != 0x18 || code[1] != 0x79 || code[12] != 0 || code[13] != 0xc0 || code[14] != 0x0f) return 2;
11 result[0] = bytes;
12 if (omega2_bw_enc_sm121(&bytes, ins, 8192, phys, 288, 0, 0, code, 16384) || bytes) return 3;
13 ins[0] = UINT64_MAX;
14 if (omega2_bw_enc_sm121(&bytes, ins, 8192, phys, 288, 1, 0, code, 16384) || bytes) return 4;
15 bytes = 99;
16 if (omega2_bw_enc_sm121(&bytes, ins, 8191, phys, 288, 0, 0, code, 16384) != OMEGA_BAD_ARG || bytes != 99) return 5;
17 meta[6] = 999;
18 image[0] = 17;
19 if (omega2_cubin_elf(&bytes, meta, 104, name, 64, text, 16777216, image, 16777216) || bytes != 1 || image[0] != 17) return 6;
20 result[1] = bytes;
21 /* Exact RNE/NaN vectors derived in evidence NO-POSIX README with Wolfram. */
22 const uint64_t inputs[] = {0,2147483648,1065353216,1065385984,1065451520,2139095041,4294967295,2139095040};
23 const uint64_t wanted[] = {0,32768,16256,16256,16258,32704,65535,32640};
24 for (unsigned i = 0; i < sizeof(inputs)/sizeof(inputs[0]); ++i) {
25 if (omega2_no_bf16(&result[2+i], inputs[i]) || result[2+i] != wanted[i]) return 7;
26 }
27#ifdef NO_POSIX_RED
28 return 90;
29#else
30 return 0;
31#endif
32}
33#ifdef NO_POSIX_BARE
34#include <asm/unistd.h>
35#define S1(x) #x
36#define S(x) S1(x)
37int no_posix_main(void) {
38 int rc = exercise();
39 if (rc) return rc;
40 register long x0 __asm__("x0") = 1;
41 register long x1 __asm__("x1") = (long)result;
42 register long x2 __asm__("x2") = sizeof(result);
43 register long x8 __asm__("x8") = __NR_write;
44 __asm__ volatile("svc #0" : "+r"(x0) : "r"(x1), "r"(x2), "r"(x8) : "memory", "cc");
45 return x0 == sizeof(result) ? 0 : 91;
46}
47__asm__(".text\n.global _start\n.type _start,%function\n_start:\nbl no_posix_main\nmov x8,#" S(__NR_exit) "\nsvc #0\nbrk #0\n");
48#else
49#include <stdio.h>
50int main(void) {
51 int rc = exercise();
52 if (rc) return rc;
53 return fwrite(result, 1, sizeof(result), stdout) == sizeof(result) ? 0 : 91;
54}
55#endif