Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
CompilerInterfaceDeviceInternal.hpp
Go to the documentation of this file.
2
4
5// Return "auto" should resolve to cudaError_t or hipError_t.
6inline auto __jit_launch_kernel_internal(void *Kernel, dim3 GridDim,
7 dim3 BlockDim, void **KernelArgs,
8 uint64_t ShmemSize, void *Stream) {
9
10 using namespace llvm;
11 using namespace proteus;
12
13 static const bool IsProteusDisabledEnvVar =
14 getEnvOrDefaultBool("PROTEUS_DISABLE", false);
15
16 if (IsProteusDisabledEnvVar) {
18 Kernel, GridDim, BlockDim, KernelArgs, ShmemSize,
19 static_cast<typename JitDeviceImplT::DeviceStream_t>(Stream));
20 }
21
22 auto &Jit = JitDeviceImplT::instance();
23 if (Jit.isProteusDisabled()) {
25 Kernel, GridDim, BlockDim, KernelArgs, ShmemSize,
26 static_cast<typename JitDeviceImplT::DeviceStream_t>(Stream));
27 }
28
29 auto OptionalKernelInfo = Jit.getJITKernelInfo(Kernel);
30 if (!OptionalKernelInfo) {
32 Kernel, GridDim, BlockDim, KernelArgs, ShmemSize,
33 static_cast<typename JitDeviceImplT::DeviceStream_t>(Stream));
34 }
35
36 auto &KernelInfo = OptionalKernelInfo.value().get();
37
38#if PROTEUS_ENABLE_DEBUG
39 Logger::logs("proteus") << "JIT Launch Kernel\n";
40 Logger::logs("proteus") << "=== Kernel Info\n";
41 Logger::logs("proteus") << "KernelName " << KernelInfo.getName() << "\n";
42 Logger::logs("proteus") << "Grid " << GridDim.x << ", " << GridDim.y << ", "
43 << GridDim.z << "\n";
44 Logger::logs("proteus") << "Block " << BlockDim.x << ", " << BlockDim.y
45 << ", " << BlockDim.z << "\n";
46 Logger::logs("proteus") << "KernelArgs " << KernelArgs << "\n";
47 Logger::logs("proteus") << "ShmemSize " << ShmemSize << "\n";
48 Logger::logs("proteus") << "Stream " << Stream << "\n";
49 Logger::logs("proteus") << "=== End Kernel Info\n";
50#endif
51
52 return Jit.compileAndRun(
53 KernelInfo, GridDim, BlockDim, KernelArgs, ShmemSize,
54 static_cast<typename JitDeviceImplT::DeviceStream_t>(Stream));
55}
auto __jit_launch_kernel_internal(void *Kernel, dim3 GridDim, dim3 BlockDim, void **KernelArgs, uint64_t ShmemSize, void *Stream)
Definition CompilerInterfaceDeviceInternal.hpp:6
void * Kernel
Definition CompilerInterfaceDevice.cpp:50
JitEngineHost & Jit
Definition CompilerInterfaceHost.cpp:23
Definition JitEngine.cpp:20
cudaError_t launchKernelDirect(void *KernelFunc, dim3 GridDim, dim3 BlockDim, void **KernelArgs, uint64_t ShmemSize, CUstream Stream)
Definition CoreDeviceCUDA.hpp:20