1 | //===-- lib/cuda/registration.cpp -------------------------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "flang/Runtime/CUDA/registration.h" |
10 | #include "flang-rt/runtime/terminator.h" |
11 | #include "flang/Runtime/CUDA/common.h" |
12 | |
13 | #include "cuda_runtime.h" |
14 | |
15 | namespace Fortran::runtime::cuda { |
16 | |
17 | extern "C" { |
18 | |
19 | extern void **__cudaRegisterFatBinary(void *); |
20 | extern void __cudaRegisterFatBinaryEnd(void *); |
21 | extern void __cudaRegisterFunction(void **fatCubinHandle, const char *hostFun, |
22 | char *deviceFun, const char *deviceName, int thread_limit, uint3 *tid, |
23 | uint3 *bid, dim3 *bDim, dim3 *gDim, int *wSize); |
24 | extern void __cudaRegisterVar(void **fatCubinHandle, char *hostVar, |
25 | const char *deviceAddress, const char *deviceName, int ext, size_t size, |
26 | int constant, int global); |
27 | |
28 | void *RTDECL(CUFRegisterModule)(void *data) { |
29 | void **fatHandle{__cudaRegisterFatBinary(data)}; |
30 | __cudaRegisterFatBinaryEnd(fatHandle); |
31 | return fatHandle; |
32 | } |
33 | |
34 | void RTDEF(CUFRegisterFunction)( |
35 | void **module, const char *fctSym, char *fctName) { |
36 | __cudaRegisterFunction(module, fctSym, fctName, fctName, -1, (uint3 *)0, |
37 | (uint3 *)0, (dim3 *)0, (dim3 *)0, (int *)0); |
38 | } |
39 | |
40 | void RTDEF(CUFRegisterVariable)( |
41 | void **module, char *varSym, const char *varName, int64_t size) { |
42 | __cudaRegisterVar(module, varSym, varName, varName, 0, size, 0, 0); |
43 | } |
44 | |
45 | } // extern "C" |
46 | |
47 | } // namespace Fortran::runtime::cuda |
48 | |