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. 31ef3f58fSjeremylt // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 51ef3f58fSjeremylt // 63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 71ef3f58fSjeremylt 849aac155SJeremy L Thompson #include <ceed.h> 9ec3da8bcSJed Brown #include <ceed/backend.h> 103d576824SJeremy L Thompson #include <string.h> 112b730f8bSJeremy L Thompson 121ef3f58fSjeremylt #include "ceed-memcheck.h" 131ef3f58fSjeremylt 14f10650afSjeremylt //------------------------------------------------------------------------------ 15f10650afSjeremylt // Backend Init 16f10650afSjeremylt //------------------------------------------------------------------------------ 171ef3f58fSjeremylt static int CeedInit_Memcheck(const char *resource, Ceed ceed) { 18*6574a04fSJeremy L Thompson CeedCheck(!strcmp(resource, "/cpu/self/memcheck") || !strcmp(resource, "/cpu/self/memcheck/serial"), ceed, CEED_ERROR_BACKEND, 19*6574a04fSJeremy L Thompson "Valgrind Memcheck backend cannot use resource: %s", resource); 201ef3f58fSjeremylt 21ea61e9acSJeremy L Thompson // Create reference Ceed that implementation will be dispatched through unless overridden 22d1d35e2fSjeremylt Ceed ceed_ref; 232b730f8bSJeremy L Thompson CeedCallBackend(CeedInit("/cpu/self/ref/serial", &ceed_ref)); 242b730f8bSJeremy L Thompson CeedCallBackend(CeedSetDelegate(ceed, ceed_ref)); 251ef3f58fSjeremylt 269798701eSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "VectorCreate", CeedVectorCreate_Memcheck)); 272b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionCreate", CeedQFunctionCreate_Memcheck)); 282b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionContextCreate", CeedQFunctionContextCreate_Memcheck)); 291ef3f58fSjeremylt 30e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 311ef3f58fSjeremylt } 321ef3f58fSjeremylt 33f10650afSjeremylt //------------------------------------------------------------------------------ 34f10650afSjeremylt // Backend Register 35f10650afSjeremylt //------------------------------------------------------------------------------ 362b730f8bSJeremy L Thompson CEED_INTERN int CeedRegister_Memcheck_Serial(void) { return CeedRegister("/cpu/self/memcheck/serial", CeedInit_Memcheck, 100); } 37f10650afSjeremylt //------------------------------------------------------------------------------ 38