xref: /libCEED/interface/ceed-hip.c (revision 49aac155e7a09736f56fb3abac0f57dab29f7cbf)
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*49aac155SJeremy L Thompson #include <ceed.h>
102b730f8bSJeremy L Thompson #include <ceed/backend.h>
112b730f8bSJeremy L Thompson #include <ceed/hip.h>
12*49aac155SJeremy L Thompson #include <hip/hip_runtime_api.h>
13af7ca75eSjeremylt 
14af7ca75eSjeremylt /**
15af7ca75eSjeremylt   @brief Set HIP function pointer to evaluate action at quadrature points
16af7ca75eSjeremylt 
17ea61e9acSJeremy L Thompson   @param[in,out] qf CeedQFunction to set device pointer
18ea61e9acSJeremy L Thompson   @param[in]     f  Device function pointer to evaluate action at quadrature points
19af7ca75eSjeremylt 
20af7ca75eSjeremylt   @return An error code: 0 - success, otherwise - failure
21af7ca75eSjeremylt 
22af7ca75eSjeremylt   @ref User
23af7ca75eSjeremylt **/
24af7ca75eSjeremylt int CeedQFunctionSetHIPUserFunction(CeedQFunction qf, hipFunction_t f) {
25af7ca75eSjeremylt   if (!qf->SetHIPUserFunction) {
26af7ca75eSjeremylt     Ceed ceed;
272b730f8bSJeremy L Thompson     CeedCall(CeedQFunctionGetCeed(qf, &ceed));
282b730f8bSJeremy L Thompson     CeedDebug(ceed, "Backend does not support hipFunction_t pointers for QFunctions.");
29af7ca75eSjeremylt   } else {
302b730f8bSJeremy L Thompson     CeedCall(qf->SetHIPUserFunction(qf, f));
31af7ca75eSjeremylt   }
32e15f9bd0SJeremy L Thompson   return CEED_ERROR_SUCCESS;
33af7ca75eSjeremylt }
34