15aed82e4SJeremy L Thompson // Copyright (c) 2017-2024, 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. 3241a4b83SYohann // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 5241a4b83SYohann // 63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 7241a4b83SYohann 849aac155SJeremy L Thompson #include <ceed.h> 9ec3da8bcSJed Brown #include <ceed/backend.h> 103d576824SJeremy L Thompson #include <cuda_runtime.h> 112b730f8bSJeremy L Thompson 1249aac155SJeremy L Thompson #include "../cuda/ceed-cuda-common.h" 13241a4b83SYohann #include "ceed-cuda-gen.h" 14241a4b83SYohann 15ab213215SJeremy L Thompson //------------------------------------------------------------------------------ 16ab213215SJeremy L Thompson // Apply QFunction 17ab213215SJeremy L Thompson //------------------------------------------------------------------------------ 182b730f8bSJeremy L Thompson static int CeedQFunctionApply_Cuda_gen(CeedQFunction qf, CeedInt Q, CeedVector *U, CeedVector *V) { 196e536b99SJeremy L Thompson return CeedError(CeedQFunctionReturnCeed(qf), CEED_ERROR_BACKEND, "Backend does not implement QFunctionApply"); 20241a4b83SYohann } 21241a4b83SYohann 22ab213215SJeremy L Thompson //------------------------------------------------------------------------------ 23ab213215SJeremy L Thompson // Destroy QFunction 24ab213215SJeremy L Thompson //------------------------------------------------------------------------------ 25241a4b83SYohann static int CeedQFunctionDestroy_Cuda_gen(CeedQFunction qf) { 26ca735530SJeremy L Thompson CeedQFunction_Cuda_gen *data; 27ca735530SJeremy L Thompson 28ca735530SJeremy L Thompson CeedCallBackend(CeedQFunctionGetData(qf, &data)); 296e536b99SJeremy L Thompson CeedCallCuda(CeedQFunctionReturnCeed(qf), cudaFree(data->d_c)); 302b730f8bSJeremy L Thompson CeedCallBackend(CeedFree(&data)); 31e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 32241a4b83SYohann } 33241a4b83SYohann 34ab213215SJeremy L Thompson //------------------------------------------------------------------------------ 35ab213215SJeremy L Thompson // Create QFunction 36ab213215SJeremy L Thompson //------------------------------------------------------------------------------ 37241a4b83SYohann int CeedQFunctionCreate_Cuda_gen(CeedQFunction qf) { 38241a4b83SYohann Ceed ceed; 39241a4b83SYohann CeedQFunction_Cuda_gen *data; 40ca735530SJeremy L Thompson 41d77c2f5dSJeremy L Thompson CeedCallBackend(CeedQFunctionGetCeed(qf, &ceed)); 422b730f8bSJeremy L Thompson CeedCallBackend(CeedCalloc(1, &data)); 432b730f8bSJeremy L Thompson CeedCallBackend(CeedQFunctionSetData(qf, data)); 44241a4b83SYohann 4509095acaSJeremy L Thompson CeedCallBackend(CeedQFunctionGetKernelName(qf, &data->qfunction_name)); 46241a4b83SYohann 472b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "QFunction", qf, "Apply", CeedQFunctionApply_Cuda_gen)); 482b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "QFunction", qf, "Destroy", CeedQFunctionDestroy_Cuda_gen)); 49*9bc66399SJeremy L Thompson CeedCallBackend(CeedDestroy(&ceed)); 50e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 51241a4b83SYohann } 529e201c85SYohann 53ab213215SJeremy L Thompson //------------------------------------------------------------------------------ 54