xref: /libCEED/rust/libceed-sys/c-src/backends/memcheck/ceed-memcheck-serial.c (revision d1d35e2f02dc969aee8debf3fd943dd784aa847a) !
11ef3f58fSjeremylt // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
21ef3f58fSjeremylt // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
31ef3f58fSjeremylt // All Rights reserved. See files LICENSE and NOTICE for details.
41ef3f58fSjeremylt //
51ef3f58fSjeremylt // This file is part of CEED, a collection of benchmarks, miniapps, software
61ef3f58fSjeremylt // libraries and APIs for efficient high-order finite element and spectral
71ef3f58fSjeremylt // element discretizations for exascale applications. For more information and
81ef3f58fSjeremylt // source code availability see http://github.com/ceed.
91ef3f58fSjeremylt //
101ef3f58fSjeremylt // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
111ef3f58fSjeremylt // a collaborative effort of two U.S. Department of Energy organizations (Office
121ef3f58fSjeremylt // of Science and the National Nuclear Security Administration) responsible for
131ef3f58fSjeremylt // the planning and preparation of a capable exascale ecosystem, including
141ef3f58fSjeremylt // software, applications, hardware, advanced system engineering and early
151ef3f58fSjeremylt // testbed platforms, in support of the nation's exascale computing imperative.
161ef3f58fSjeremylt 
17ec3da8bcSJed Brown #include <ceed/ceed.h>
18ec3da8bcSJed Brown #include <ceed/backend.h>
193d576824SJeremy L Thompson #include <string.h>
201ef3f58fSjeremylt #include "ceed-memcheck.h"
211ef3f58fSjeremylt 
22f10650afSjeremylt //------------------------------------------------------------------------------
23f10650afSjeremylt // Backend Init
24f10650afSjeremylt //------------------------------------------------------------------------------
251ef3f58fSjeremylt static int CeedInit_Memcheck(const char *resource, Ceed ceed) {
261ef3f58fSjeremylt   int ierr;
27d9995aecSjeremylt   if (strcmp(resource, "/cpu/self/memcheck")
28d9995aecSjeremylt       && strcmp(resource, "/cpu/self/memcheck/serial"))
291ef3f58fSjeremylt     // LCOV_EXCL_START
30e15f9bd0SJeremy L Thompson     return CeedError(ceed, CEED_ERROR_BACKEND,
31e15f9bd0SJeremy L Thompson                      "Valgrind Memcheck backend cannot use resource: %s",
321ef3f58fSjeremylt                      resource);
331ef3f58fSjeremylt   // LCOV_EXCL_STOP
341ef3f58fSjeremylt 
355f67fadeSJeremy L Thompson   // Create reference CEED that implementation will be dispatched
361ef3f58fSjeremylt   //   through unless overridden
37*d1d35e2fSjeremylt   Ceed ceed_ref;
38*d1d35e2fSjeremylt   CeedInit("/cpu/self/ref/serial", &ceed_ref);
39*d1d35e2fSjeremylt   ierr = CeedSetDelegate(ceed, ceed_ref); CeedChkBackend(ierr);
401ef3f58fSjeremylt 
411ef3f58fSjeremylt   ierr = CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionCreate",
42e15f9bd0SJeremy L Thompson                                 CeedQFunctionCreate_Memcheck); CeedChkBackend(ierr);
431ef3f58fSjeremylt 
44e15f9bd0SJeremy L Thompson   return CEED_ERROR_SUCCESS;
451ef3f58fSjeremylt }
461ef3f58fSjeremylt 
47f10650afSjeremylt //------------------------------------------------------------------------------
48f10650afSjeremylt // Backend Register
49f10650afSjeremylt //------------------------------------------------------------------------------
501d013790SJed Brown CEED_INTERN int CeedRegister_Memcheck_Serial(void) {
511d013790SJed Brown   return CeedRegister("/cpu/self/memcheck/serial", CeedInit_Memcheck, 100);
521ef3f58fSjeremylt }
53f10650afSjeremylt //------------------------------------------------------------------------------
54