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 / gpu_resident_fixture.h

32 lines · 1165 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2#ifndef GPU_RESIDENT_FIXTURE_H
3#define GPU_RESIDENT_FIXTURE_H
4#include <stdint.h>
5/* Independent plain C sequential evaluator. f32 left-to-right; build with -ffp-contract=off. */
6static void resident_reference(const uint32_t *d, unsigned n, float *x) {
7 for(unsigned l=0;l<n;l++,d+=8) for(unsigned r=0;r<d[4];r++) {
8 float v=0;
9 if(d[0]==1) for(unsigned k=0;k<d[5];k++) v=v+x[d[1]+r*d[5]+k]*x[d[2]+k];
10 if(d[0]==2) v=x[d[1]+r]+x[d[2]+r];
11 if(d[0]==3) v=x[d[1]+r]*x[d[2]+r];
12 if(d[0]==4) for(unsigned k=0;k<d[5];k++) v=v+x[d[1]+k];
13 if(d[0]==5) v=x[d[1]+r];
14 x[d[3]+r]=v;
15 }
16}
17static const uint32_t resident_model[]={
18 1,0,16,32,4,4,0,0,
19 2,32,20,36,4,1,0,0,
20 3,36,24,40,4,1,0,0,
21 4,40,0,44,1,4,0,0,
22 5,44,0,45,1,1,0,0
23};
24static void resident_input(float *x, unsigned witness) {
25 for(unsigned i=0;i<64;i++) x[i]=0;
26 for(unsigned i=0;i<28;i++) x[i]=(float)(i%4+1);
27 if(witness) {
28 x[0]=-1; x[1]=1.00000011920928955078125f; x[2]=0;x[3]=0;
29 x[16]=1;x[17]=0.99999988079071044921875f;x[18]=0;x[19]=0;
30 }
31}
32#endif