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