1 // Copyright (c) 2017-2026, 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.h> 9 #include <ceed/backend.h> 10 #include <hip/hip_runtime.h> 11 12 #include "../hip/ceed-hip-common.h" 13 #include "ceed-hip-gen.h" 14 15 //------------------------------------------------------------------------------ 16 // Apply QFunction 17 //------------------------------------------------------------------------------ 18 static int CeedQFunctionApply_Hip_gen(CeedQFunction qf, CeedInt Q, CeedVector *U, CeedVector *V) { 19 return CeedError(CeedQFunctionReturnCeed(qf), CEED_ERROR_BACKEND, "Backend does not implement QFunctionApply"); 20 } 21 22 //------------------------------------------------------------------------------ 23 // Destroy QFunction 24 //------------------------------------------------------------------------------ 25 static int CeedQFunctionDestroy_Hip_gen(CeedQFunction qf) { 26 CeedQFunction_Hip_gen *data; 27 28 CeedCallBackend(CeedQFunctionGetData(qf, &data)); 29 CeedCallHip(CeedQFunctionReturnCeed(qf), hipFree(data->d_c)); 30 CeedCallBackend(CeedFree(&data)); 31 return CEED_ERROR_SUCCESS; 32 } 33 34 //------------------------------------------------------------------------------ 35 // Create QFunction 36 //------------------------------------------------------------------------------ 37 int CeedQFunctionCreate_Hip_gen(CeedQFunction qf) { 38 Ceed ceed; 39 CeedQFunction_Hip_gen *data; 40 41 CeedCallBackend(CeedQFunctionGetCeed(qf, &ceed)); 42 CeedCallBackend(CeedCalloc(1, &data)); 43 CeedCallBackend(CeedQFunctionSetData(qf, data)); 44 45 CeedCallBackend(CeedQFunctionGetKernelName(qf, &data->qfunction_name)); 46 47 CeedCallBackend(CeedSetBackendFunction(ceed, "QFunction", qf, "Apply", CeedQFunctionApply_Hip_gen)); 48 CeedCallBackend(CeedSetBackendFunction(ceed, "QFunction", qf, "Destroy", CeedQFunctionDestroy_Hip_gen)); 49 CeedCallBackend(CeedDestroy(&ceed)); 50 return CEED_ERROR_SUCCESS; 51 } 52 53 //------------------------------------------------------------------------------ 54