ceed-memcheck-qfunction.c (cb03979f09f11f2f58ca1dff8031348aa48729d3) ceed-memcheck-qfunction.c (fb02a1652bbc3fc0caa8288bcc9fd5bfd4ec4903)
1// Copyright (c) 2017-2022, 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
8#include <ceed/ceed.h>

--- 6 unchanged lines hidden (view full) ---

15// QFunction Apply
16//------------------------------------------------------------------------------
17static int CeedQFunctionApply_Memcheck(CeedQFunction qf, CeedInt Q,
18 CeedVector *U, CeedVector *V) {
19 int ierr;
20 CeedQFunction_Memcheck *impl;
21 ierr = CeedQFunctionGetData(qf, &impl); CeedChkBackend(ierr);
22
1// Copyright (c) 2017-2022, 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
8#include <ceed/ceed.h>

--- 6 unchanged lines hidden (view full) ---

15// QFunction Apply
16//------------------------------------------------------------------------------
17static int CeedQFunctionApply_Memcheck(CeedQFunction qf, CeedInt Q,
18 CeedVector *U, CeedVector *V) {
19 int ierr;
20 CeedQFunction_Memcheck *impl;
21 ierr = CeedQFunctionGetData(qf, &impl); CeedChkBackend(ierr);
22
23 CeedQFunctionContext ctx;
24 ierr = CeedQFunctionGetContext(qf, &ctx); CeedChkBackend(ierr);
25 void *ctxData = NULL;
26 if (ctx) {
27 ierr = CeedQFunctionContextGetData(ctx, CEED_MEM_HOST, &ctxData);
28 CeedChkBackend(ierr);
29 }
23 void *ctx_data = NULL;
24 ierr = CeedQFunctionGetContextData(qf, CEED_MEM_HOST, &ctx_data);
25 CeedChkBackend(ierr);
30
31 CeedQFunctionUser f = NULL;
32 ierr = CeedQFunctionGetUserFunction(qf, &f); CeedChkBackend(ierr);
33
34 CeedInt num_in, num_out;
35 ierr = CeedQFunctionGetNumArgs(qf, &num_in, &num_out); CeedChkBackend(ierr);
36
37 for (CeedInt i = 0; i<num_in; i++) {

--- 10 unchanged lines hidden (view full) ---

48
49 ierr = CeedVectorGetLength(V[i], &len); CeedChkBackend(ierr);
50 VALGRIND_MAKE_MEM_UNDEFINED(impl->outputs[i], len);
51
52 snprintf(name, 30, "'QFunction output %" CeedInt_FMT "'", i);
53 mem_block_ids[i] = VALGRIND_CREATE_BLOCK(impl->outputs[i], len, name);
54 }
55
26
27 CeedQFunctionUser f = NULL;
28 ierr = CeedQFunctionGetUserFunction(qf, &f); CeedChkBackend(ierr);
29
30 CeedInt num_in, num_out;
31 ierr = CeedQFunctionGetNumArgs(qf, &num_in, &num_out); CeedChkBackend(ierr);
32
33 for (CeedInt i = 0; i<num_in; i++) {

--- 10 unchanged lines hidden (view full) ---

44
45 ierr = CeedVectorGetLength(V[i], &len); CeedChkBackend(ierr);
46 VALGRIND_MAKE_MEM_UNDEFINED(impl->outputs[i], len);
47
48 snprintf(name, 30, "'QFunction output %" CeedInt_FMT "'", i);
49 mem_block_ids[i] = VALGRIND_CREATE_BLOCK(impl->outputs[i], len, name);
50 }
51
56 ierr = f(ctxData, Q, impl->inputs, impl->outputs); CeedChkBackend(ierr);
52 ierr = f(ctx_data, Q, impl->inputs, impl->outputs); CeedChkBackend(ierr);
57
58 for (CeedInt i = 0; i<num_in; i++) {
59 ierr = CeedVectorRestoreArrayRead(U[i], &impl->inputs[i]); CeedChkBackend(ierr);
60 }
61 for (CeedInt i = 0; i<num_out; i++) {
62 ierr = CeedVectorRestoreArray(V[i], &impl->outputs[i]); CeedChkBackend(ierr);
63 VALGRIND_DISCARD(mem_block_ids[i]);
64 }
53
54 for (CeedInt i = 0; i<num_in; i++) {
55 ierr = CeedVectorRestoreArrayRead(U[i], &impl->inputs[i]); CeedChkBackend(ierr);
56 }
57 for (CeedInt i = 0; i<num_out; i++) {
58 ierr = CeedVectorRestoreArray(V[i], &impl->outputs[i]); CeedChkBackend(ierr);
59 VALGRIND_DISCARD(mem_block_ids[i]);
60 }
65 if (ctx) {
66 ierr = CeedQFunctionContextRestoreData(ctx, &ctxData); CeedChkBackend(ierr);
67 }
61 ierr = CeedQFunctionRestoreContextData(qf, &ctx_data); CeedChkBackend(ierr);
68
69 return CEED_ERROR_SUCCESS;
70}
71
72//------------------------------------------------------------------------------
73// QFunction Destroy
74//------------------------------------------------------------------------------
75static int CeedQFunctionDestroy_Memcheck(CeedQFunction qf) {

--- 33 unchanged lines hidden ---
62
63 return CEED_ERROR_SUCCESS;
64}
65
66//------------------------------------------------------------------------------
67// QFunction Destroy
68//------------------------------------------------------------------------------
69static int CeedQFunctionDestroy_Memcheck(CeedQFunction qf) {

--- 33 unchanged lines hidden ---