xref: /libCEED/backends/cuda/ceed-cuda-compile.h (revision cdf95791513f7c35170bef3ba2e19f272fe04533)
1 // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
2 // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
3 // All Rights reserved. See files LICENSE and NOTICE for details.
4 //
5 // This file is part of CEED, a collection of benchmarks, miniapps, software
6 // libraries and APIs for efficient high-order finite element and spectral
7 // element discretizations for exascale applications. For more information and
8 // source code availability see http://github.com/ceed.
9 //
10 // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11 // a collaborative effort of two U.S. Department of Energy organizations (Office
12 // of Science and the National Nuclear Security Administration) responsible for
13 // the planning and preparation of a capable exascale ecosystem, including
14 // software, applications, hardware, advanced system engineering and early
15 // testbed platforms, in support of the nation's exascale computing imperative.
16 
17 #ifndef _ceed_cuda_compile_h
18 #define _ceed_cuda_compile_h
19 
20 #include <ceed/ceed.h>
21 #include <cuda.h>
22 #include <nvrtc.h>
23 
24 static inline CeedInt CeedDivUpInt(CeedInt numerator, CeedInt denominator) {
25   return (numerator + denominator - 1) / denominator;
26 }
27 
28 CEED_INTERN int CeedCompileCuda(Ceed ceed, const char *source, CUmodule *module,
29                                 const CeedInt num_opts, ...);
30 
31 CEED_INTERN int CeedGetKernelCuda(Ceed ceed, CUmodule module, const char *name,
32                                   CUfunction *kernel);
33 
34 CEED_INTERN int CeedRunKernelCuda(Ceed ceed, CUfunction kernel,
35                                   const int grid_size,
36                                   const int block_size, void **args);
37 
38 CEED_INTERN int CeedRunKernelAutoblockCuda(Ceed ceed, CUfunction kernel,
39     size_t size, void **args);
40 
41 CEED_INTERN int CeedRunKernelDimCuda(Ceed ceed, CUfunction kernel,
42                                      const int grid_size,
43                                      const int block_size_x, const int block_size_y,
44                                      const int block_size_z, void **args);
45 
46 CEED_INTERN int CeedRunKernelDimSharedCuda(Ceed ceed, CUfunction kernel,
47     const int grid_size, const int block_size_x, const int block_size_y,
48     const int block_size_z, const int shared_mem_size, void **args);
49 
50 #endif // _ceed_cuda_compile_h
51