xref: /libCEED/rust/libceed-sys/c-src/backends/cuda/ceed-cuda-compile.h (revision 3d8e882215d238700cdceb37404f76ca7fa24eaa)
1*3d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2*3d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
36d69246aSJeremy L Thompson //
4*3d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
56d69246aSJeremy L Thompson //
6*3d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
76d69246aSJeremy L Thompson 
86d69246aSJeremy L Thompson #ifndef _ceed_cuda_compile_h
96d69246aSJeremy L Thompson #define _ceed_cuda_compile_h
106d69246aSJeremy L Thompson 
116d69246aSJeremy L Thompson #include <ceed/ceed.h>
126d69246aSJeremy L Thompson #include <cuda.h>
136d69246aSJeremy L Thompson #include <nvrtc.h>
146d69246aSJeremy L Thompson 
150d0321e0SJeremy L Thompson static inline CeedInt CeedDivUpInt(CeedInt numerator, CeedInt denominator) {
160d0321e0SJeremy L Thompson   return (numerator + denominator - 1) / denominator;
170d0321e0SJeremy L Thompson }
180d0321e0SJeremy L Thompson 
196d69246aSJeremy L Thompson CEED_INTERN int CeedCompileCuda(Ceed ceed, const char *source, CUmodule *module,
200d0321e0SJeremy L Thompson                                 const CeedInt num_opts, ...);
216d69246aSJeremy L Thompson 
226d69246aSJeremy L Thompson CEED_INTERN int CeedGetKernelCuda(Ceed ceed, CUmodule module, const char *name,
236d69246aSJeremy L Thompson                                   CUfunction *kernel);
246d69246aSJeremy L Thompson 
256d69246aSJeremy L Thompson CEED_INTERN int CeedRunKernelCuda(Ceed ceed, CUfunction kernel,
260d0321e0SJeremy L Thompson                                   const int grid_size,
270d0321e0SJeremy L Thompson                                   const int block_size, void **args);
286d69246aSJeremy L Thompson 
296d69246aSJeremy L Thompson CEED_INTERN int CeedRunKernelAutoblockCuda(Ceed ceed, CUfunction kernel,
306d69246aSJeremy L Thompson     size_t size, void **args);
316d69246aSJeremy L Thompson 
326d69246aSJeremy L Thompson CEED_INTERN int CeedRunKernelDimCuda(Ceed ceed, CUfunction kernel,
330d0321e0SJeremy L Thompson                                      const int grid_size,
340d0321e0SJeremy L Thompson                                      const int block_size_x, const int block_size_y,
350d0321e0SJeremy L Thompson                                      const int block_size_z, void **args);
366d69246aSJeremy L Thompson 
376d69246aSJeremy L Thompson CEED_INTERN int CeedRunKernelDimSharedCuda(Ceed ceed, CUfunction kernel,
380d0321e0SJeremy L Thompson     const int grid_size, const int block_size_x, const int block_size_y,
390d0321e0SJeremy L Thompson     const int block_size_z, const int shared_mem_size, void **args);
406d69246aSJeremy L Thompson 
416d69246aSJeremy L Thompson #endif // _ceed_cuda_compile_h
42