xref: /libCEED/rust/libceed-sys/c-src/interface/ceed-cuda.c (revision af7ca75e1f63682c5f2228a48165211e28fb04f0)
1*af7ca75eSjeremylt // Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2*af7ca75eSjeremylt // the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3*af7ca75eSjeremylt // reserved. See files LICENSE and NOTICE for details.
4*af7ca75eSjeremylt //
5*af7ca75eSjeremylt // This file is part of CEED, a collection of benchmarks, miniapps, software
6*af7ca75eSjeremylt // libraries and APIs for efficient high-order finite element and spectral
7*af7ca75eSjeremylt // element discretizations for exascale applications. For more information and
8*af7ca75eSjeremylt // source code availability see http://github.com/ceed.
9*af7ca75eSjeremylt //
10*af7ca75eSjeremylt // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11*af7ca75eSjeremylt // a collaborative effort of two U.S. Department of Energy organizations (Office
12*af7ca75eSjeremylt // of Science and the National Nuclear Security Administration) responsible for
13*af7ca75eSjeremylt // the planning and preparation of a capable exascale ecosystem, including
14*af7ca75eSjeremylt // software, applications, hardware, advanced system engineering and early
15*af7ca75eSjeremylt // testbed platforms, in support of the nation's exascale computing imperative.
16*af7ca75eSjeremylt 
17*af7ca75eSjeremylt #include <ceed-impl.h>
18*af7ca75eSjeremylt #include <ceed-cuda.h>
19*af7ca75eSjeremylt 
20*af7ca75eSjeremylt /**
21*af7ca75eSjeremylt   @brief Set CUDA function pointer to evaluate action at quadrature points
22*af7ca75eSjeremylt 
23*af7ca75eSjeremylt   @param qf CeedQFunction to set device pointer
24*af7ca75eSjeremylt   @param f  Device function pointer to evaluate action at quadrature points
25*af7ca75eSjeremylt 
26*af7ca75eSjeremylt   @return An error code: 0 - success, otherwise - failure
27*af7ca75eSjeremylt 
28*af7ca75eSjeremylt   @ref User
29*af7ca75eSjeremylt **/
30*af7ca75eSjeremylt int CeedQFunctionSetCUDAUserFunction(CeedQFunction qf, CUfunction f) {
31*af7ca75eSjeremylt   int ierr;
32*af7ca75eSjeremylt   if (!qf->SetCUDAUserFunction) {
33*af7ca75eSjeremylt     Ceed ceed;
34*af7ca75eSjeremylt     ierr = CeedQFunctionGetCeed(qf, &ceed); CeedChk(ierr);
35*af7ca75eSjeremylt     CeedDebug("Backend does not support CUfunction pointers for QFunctions.");
36*af7ca75eSjeremylt   } else {
37*af7ca75eSjeremylt     ierr = qf->SetCUDAUserFunction(qf, f); CeedChk(ierr);
38*af7ca75eSjeremylt   }
39*af7ca75eSjeremylt   return 0;
40*af7ca75eSjeremylt }
41