xref: /libCEED/backends/memcheck/ceed-memcheck-blocked.c (revision d4cc18453651bd0f94c1a2e078b2646a92dafdcc)
1*9ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, 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 //------------------------------------------------------------------------------
CeedInit_Memcheck(const char * resource,Ceed ceed)171ef3f58fSjeremylt static int CeedInit_Memcheck(const char *resource, Ceed ceed) {
18ad70ee2cSJeremy L Thompson   Ceed ceed_ref;
19ad70ee2cSJeremy L Thompson 
206574a04fSJeremy L Thompson   CeedCheck(!strcmp(resource, "/cpu/self/memcheck/blocked"), ceed, CEED_ERROR_BACKEND, "Valgrind Memcheck backend cannot use resource: %s", resource);
211ef3f58fSjeremylt 
22ea61e9acSJeremy L Thompson   // Create reference Ceed that implementation will be dispatched through unless overridden
232b730f8bSJeremy L Thompson   CeedCallBackend(CeedInit("/cpu/self/ref/blocked", &ceed_ref));
242b730f8bSJeremy L Thompson   CeedCallBackend(CeedSetDelegate(ceed, ceed_ref));
259bc66399SJeremy L Thompson   CeedCallBackend(CeedDestroy(&ceed_ref));
261ef3f58fSjeremylt 
279798701eSJeremy L Thompson   CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "VectorCreate", CeedVectorCreate_Memcheck));
289e82028bSJeremy L Thompson   CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "ElemRestrictionCreate", CeedElemRestrictionCreate_Memcheck));
299e82028bSJeremy L Thompson   CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "ElemRestrictionCreateBlocked", CeedElemRestrictionCreate_Memcheck));
309e82028bSJeremy L Thompson   CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "ElemRestrictionCreateAtPoints", CeedElemRestrictionCreate_Memcheck));
312b730f8bSJeremy L Thompson   CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionCreate", CeedQFunctionCreate_Memcheck));
322b730f8bSJeremy L Thompson   CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionContextCreate", CeedQFunctionContextCreate_Memcheck));
33e15f9bd0SJeremy L Thompson   return CEED_ERROR_SUCCESS;
341ef3f58fSjeremylt }
351ef3f58fSjeremylt 
36f10650afSjeremylt //------------------------------------------------------------------------------
37f10650afSjeremylt // Backend Register
38f10650afSjeremylt //------------------------------------------------------------------------------
CeedRegister_Memcheck_Blocked(void)392b730f8bSJeremy L Thompson CEED_INTERN int CeedRegister_Memcheck_Blocked(void) { return CeedRegister("/cpu/self/memcheck/blocked", CeedInit_Memcheck, 110); }
402a86cc9dSSebastian Grimberg 
41f10650afSjeremylt //------------------------------------------------------------------------------
42