xref: /libCEED/interface/ceed-cuda.c (revision 3d8e882215d238700cdceb37404f76ca7fa24eaa)
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/ceed.h>
9 #include <ceed/backend.h>
10 #include <ceed/cuda.h>
11 #include <ceed-impl.h>
12 
13 /**
14   @brief Set CUDA function pointer to evaluate action at quadrature points
15 
16   @param qf  CeedQFunction to set device pointer
17   @param f   Device function pointer to evaluate action at quadrature points
18 
19   @return An error code: 0 - success, otherwise - failure
20 
21   @ref User
22 **/
23 int CeedQFunctionSetCUDAUserFunction(CeedQFunction qf, CUfunction f) {
24   int ierr;
25   if (!qf->SetCUDAUserFunction) {
26     Ceed ceed;
27     ierr = CeedQFunctionGetCeed(qf, &ceed); CeedChk(ierr);
28     CeedDebug(ceed, "Backend does not support CUfunction pointers for QFunctions.");
29   } else {
30     ierr = qf->SetCUDAUserFunction(qf, f); CeedChk(ierr);
31   }
32   return CEED_ERROR_SUCCESS;
33 }
34