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_grid.h

26 lines · 1173 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2#ifndef GPU_RESIDENT_GRID_H
3#define GPU_RESIDENT_GRID_H
4#include "bw_warp_sim_k.h"
5/* Additive one-warp/block grid scheduler. Unlike ws_run, a polling CTA yields.
6 * Memory is coherent/SC in this simulator; fence/cache hardware remains NOT_RUN.
7 * Both CTA orders and several instruction quanta exercise actual generated spin loops. */
8static int resident_grid(WsSim *s, unsigned ctas, unsigned reverse) {
9 (void)ws_run;
10 WsWarp *w=calloc(ctas,sizeof *w);
11 if(!w || !s->quantum || s->threads!=32) { free(w);return WS_E_OP; }
12 for(unsigned c=0;c<ctas;c++) { w[c].nfrag=1;w[c].frag[0].mask=0xffffffffu; }
13 for(unsigned epoch=0;epoch<100000;epoch++) {
14 unsigned live=0;
15 for(unsigned v=0;v<ctas;v++) {
16 unsigned c=reverse ? ctas-1-v:v;
17 if(!w[c].nfrag) continue;
18 live++;
19 int rc=ws_run_warp(s,&w[c],0,c,0,0);
20 if(rc<0||rc==1) { free(w);return s->err ? s->err:WS_E_STUCK; }
21 }
22 if(!live) { free(w);return s->err; }
23 }
24 free(w);ws_fail(s,WS_E_STEPS,-1,"resident grid scheduling budget");return s->err;
25}
26#endif