xref: /libCEED/interface/ceed-cuda.c (revision 2247a93f19c75a71369fb56e8f7b7446bda8ddb1)
1 // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3 //
4 // SPDX-License-Identifier: BSD-2-Clause
5 //
6 // This file is part of CEED:  http://github.com/ceed
7 
8 #include <ceed-impl.h>
9 #include <ceed.h>
10 #include <ceed/backend.h>
11 #include <ceed/cuda.h>
12 #include <cuda.h>
13 
14 /**
15   @brief Set CUDA function pointer to evaluate action at quadrature points
16 
17   @param[in,out] qf `CeedQFunction` to set device pointer
18   @param[in]     f  Device function pointer to evaluate action at quadrature points
19 
20   @return An error code: 0 - success, otherwise - failure
21 
22   @ref User
23 **/
24 int CeedQFunctionSetCUDAUserFunction(CeedQFunction qf, CUfunction f) {
25   if (!qf->SetCUDAUserFunction) {
26     Ceed ceed;
27 
28     CeedCall(CeedQFunctionGetCeed(qf, &ceed));
29     CeedDebug(ceed, "Backend does not support CUfunction pointers for QFunctions.");
30   } else {
31     CeedCall(qf->SetCUDAUserFunction(qf, f));
32   }
33   return CEED_ERROR_SUCCESS;
34 }
35