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 / src / omega_gpu_graph_om.h

28 lines · 1305 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2#ifndef OMEGA_GPU_GRAPH_OM_H
3#define OMEGA_GPU_GRAPH_OM_H
4#include "cudapp_native.h"
5#include <stdint.h>
6#include <string.h>
7/* Projection only: floats arrive as raw bits, and Omega emits the full node.
8 * Tensor/session objects never cross the seeded numeric ABI. */
9static inline uint64_t omega_graph_fbits(float f) { uint32_t u; memcpy(&u,&f,4); return u; }
10static inline int omega_graph_next(const uint64_t cfg[16], const uint64_t va[64], uint64_t node[64], uint64_t phase) {
11 uint64_t result=0;
12 return omega_mg_node(&result,cfg,16,va,64,node,64,phase)==OMEGA_OK && result==1;
13}
14static inline void omega_graph_args(const uint64_t node[64], uint32_t words[32]) {
15 for (unsigned i=0;i<node[5];i++) words[i]=(uint32_t)node[32+i];
16}
17static inline uint64_t omega_graph_addr(uint64_t op,uint64_t base,uint64_t dev,uint64_t split,uint64_t off,uint64_t index,uint64_t stride) {
18#ifdef CUDAPP_MIGRATION_PENDING_C_GRAPHS
19 if(op==0)return(base+255u)&~UINT64_C(255);
20 if(op==1)return off<split?base+off:dev+(off-split);
21 return base+index*stride;
22#else
23 const uint64_t q[8]={op,base,dev,split,off,index,stride,0};uint64_t result=0;
24 if(omega_mg_addr(&result,q,8)!=OMEGA_OK)__builtin_trap();
25 return result;
26#endif
27}
28#endif