xref: /libCEED/rust/libceed-sys/c-src/backends/memcheck/ceed-memcheck.h (revision 9937a20e594bfb4e867db08aa6f5f4a7e0ba1b8e)
1 // Copyright (c) 2017-2024, 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   const CeedScalar **inputs;
44   CeedScalar       **outputs;
45   bool               setup_done;
46 } CeedQFunction_Memcheck;
47 
48 typedef struct {
49   int   mem_block_id;
50   void *data;
51   void *data_allocated;
52   void *data_owned;
53   void *data_borrowed;
54   void *data_read_only_copy;
55 } CeedQFunctionContext_Memcheck;
56 
57 CEED_INTERN int CeedVectorCreate_Memcheck(CeedSize n, CeedVector vec);
58 
59 CEED_INTERN int CeedElemRestrictionCreate_Memcheck(CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets, const bool *orients,
60                                                    const CeedInt8 *curl_orients, CeedElemRestriction r);
61 
62 CEED_INTERN int CeedQFunctionCreate_Memcheck(CeedQFunction qf);
63 
64 CEED_INTERN int CeedQFunctionContextCreate_Memcheck(CeedQFunctionContext ctx);
65