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 8ec3da8bcSJed Brown #include <ceed/backend.h> 92b730f8bSJeremy L Thompson #include <ceed/ceed.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) { 182b730f8bSJeremy L Thompson if (strcmp(resource, "/cpu/self/memcheck/blocked")) { 191ef3f58fSjeremylt // LCOV_EXCL_START 202b730f8bSJeremy L Thompson return CeedError(ceed, CEED_ERROR_BACKEND, "Valgrind Memcheck backend cannot use resource: %s", resource); 211ef3f58fSjeremylt // LCOV_EXCL_STOP 222b730f8bSJeremy L Thompson } 231ef3f58fSjeremylt 24*ea61e9acSJeremy L Thompson // Create reference Ceed that implementation will be dispatched through unless overridden 25d1d35e2fSjeremylt Ceed ceed_ref; 262b730f8bSJeremy L Thompson CeedCallBackend(CeedInit("/cpu/self/ref/blocked", &ceed_ref)); 272b730f8bSJeremy L Thompson CeedCallBackend(CeedSetDelegate(ceed, ceed_ref)); 281ef3f58fSjeremylt 292b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionCreate", CeedQFunctionCreate_Memcheck)); 302b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionContextCreate", CeedQFunctionContextCreate_Memcheck)); 311ef3f58fSjeremylt 32e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 331ef3f58fSjeremylt } 341ef3f58fSjeremylt 35f10650afSjeremylt //------------------------------------------------------------------------------ 36f10650afSjeremylt // Backend Register 37f10650afSjeremylt //------------------------------------------------------------------------------ 382b730f8bSJeremy L Thompson CEED_INTERN int CeedRegister_Memcheck_Blocked(void) { return CeedRegister("/cpu/self/memcheck/blocked", CeedInit_Memcheck, 110); } 39f10650afSjeremylt //------------------------------------------------------------------------------ 40