1 // Copyright (c) 2017-2022, 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 <string.h> 11 12 #include "ceed-memcheck.h" 13 14 //------------------------------------------------------------------------------ 15 // Backend Init 16 //------------------------------------------------------------------------------ 17 static int CeedInit_Memcheck(const char *resource, Ceed ceed) { 18 if (strcmp(resource, "/cpu/self/memcheck") && strcmp(resource, "/cpu/self/memcheck/serial")) { 19 // LCOV_EXCL_START 20 return CeedError(ceed, CEED_ERROR_BACKEND, "Valgrind Memcheck backend cannot use resource: %s", resource); 21 // LCOV_EXCL_STOP 22 } 23 24 // Create reference Ceed that implementation will be dispatched through unless overridden 25 Ceed ceed_ref; 26 CeedCallBackend(CeedInit("/cpu/self/ref/serial", &ceed_ref)); 27 CeedCallBackend(CeedSetDelegate(ceed, ceed_ref)); 28 29 CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "VectorCreate", CeedVectorCreate_Memcheck)); 30 CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionCreate", CeedQFunctionCreate_Memcheck)); 31 CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionContextCreate", CeedQFunctionContextCreate_Memcheck)); 32 33 return CEED_ERROR_SUCCESS; 34 } 35 36 //------------------------------------------------------------------------------ 37 // Backend Register 38 //------------------------------------------------------------------------------ 39 CEED_INTERN int CeedRegister_Memcheck_Serial(void) { return CeedRegister("/cpu/self/memcheck/serial", CeedInit_Memcheck, 100); } 40 //------------------------------------------------------------------------------ 41