MimIR
0.3-dev
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim_cuda_rt.c
Go to the documentation of this file.
1
// Runtime wrappers for the MimIR `ll_nvptx` backend.
2
//
3
// Like `ll`'s `mim_rt.c`, this file is compiled to textual LLVM IR by `clang` at build time (see
4
// `add_mim_runtime` in `cmake/Mim.cmake`) and embedded into or linked with the host module emitted
5
// by the `ll_nvptx` backend (`-X ll_nvptx:rt=embed|extern`); see issue #486.
6
//
7
// It intentionally does not include <cuda.h>: the wrappers only touch the CUresult return codes
8
// that the backend already has in hand, so they stay self-contained and build without the CUDA
9
// toolkit. Wrappers that need the driver API itself can be added here later.
10
11
#include <stdio.h>
12
#include <stdlib.h>
13
14
/// Aborts the program if a CUDA Driver API call returned a non-zero `CUresult`.
15
/// The backend emits a call to this after every driver call instead of open-coding error handling.
16
void
mim_cu_check
(
int
result) {
17
if
(result != 0) {
18
fprintf(stderr,
"MimIR: CUDA driver error: CUresult %d\n"
, result);
19
abort();
20
}
21
}
mim_cu_check
void mim_cu_check(int result)
Aborts the program if a CUDA Driver API call returned a non-zero CUresult.
Definition
mim_cuda_rt.c:16
src
mim
plug
ll_nvptx
rt
mim_cuda_rt.c
Generated by
1.16.1