xref: /libCEED/backends/memcheck/ceed-memcheck.h (revision ed094490f53e580908aa80e9fe815a6fd76d7526)
1 // Copyright (c) 2017-2025, 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 #pragma once
8 
9 #include <ceed.h>
10 #include <ceed/backend.h>
11 
12 typedef struct {
13   // Internal array buffer
14   int         allocated_block_id;
15   CeedScalar *array_allocated;
16   // Owned external array
17   int         owned_block_id;
18   CeedScalar *array_owned;
19   // Borrowed external array
20   int         borrowed_block_id;
21   CeedScalar *array_borrowed;
22   // Externally viewable read-only array
23   int         read_only_block_id;
24   CeedScalar *array_read_only_copy;
25   // Externally viewable writable array
26   bool        is_write_only_access;
27   int         writable_block_id;
28   CeedScalar *array_writable_copy;
29 } CeedVector_Memcheck;
30 
31 typedef struct {
32   const CeedInt  *offsets;
33   CeedInt        *offsets_allocated;
34   const bool     *orients; /* Orientation, if it exists, is true when the dof must be flipped */
35   bool           *orients_allocated;
36   const CeedInt8 *curl_orients; /* Tridiagonal matrix (row-major) for a general transformation during restriction */
37   CeedInt8       *curl_orients_allocated;
38   int (*Apply)(CeedElemRestriction, CeedInt, CeedInt, CeedInt, CeedInt, CeedInt, CeedTransposeMode, bool, bool, CeedVector, CeedVector,
39                CeedRequest *);
40 } CeedElemRestriction_Memcheck;
41 
42 typedef struct {
43   bool               setup_done;
44   const CeedScalar **inputs;
45   CeedScalar       **outputs;
46 } CeedQFunction_Memcheck;
47 
48 typedef struct {
49   // Internal data buffer
50   int   allocated_block_id;
51   void *data_allocated;
52   // Owned external data
53   int   owned_block_id;
54   void *data_owned;
55   // Borrowed external data
56   int   borrowed_block_id;
57   void *data_borrowed;
58   // Externally viewable read-only data
59   int   read_only_block_id;
60   void *data_read_only_copy;
61   // Externally viewable writable data
62   int   writable_block_id;
63   void *data_writable_copy;
64 } CeedQFunctionContext_Memcheck;
65 
66 CEED_INTERN int CeedVectorCreate_Memcheck(CeedSize n, CeedVector vec);
67 
68 CEED_INTERN int CeedElemRestrictionCreate_Memcheck(CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets, const bool *orients,
69                                                    const CeedInt8 *curl_orients, CeedElemRestriction r);
70 
71 CEED_INTERN int CeedQFunctionCreate_Memcheck(CeedQFunction qf);
72 
73 CEED_INTERN int CeedQFunctionContextCreate_Memcheck(CeedQFunctionContext ctx);
74