15aed82e4SJeremy L Thompson // Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors. 20f58c348SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 30f58c348SJeremy L Thompson // 40f58c348SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 50f58c348SJeremy L Thompson // 60f58c348SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 70f58c348SJeremy L Thompson 849aac155SJeremy L Thompson #include <ceed.h> 90f58c348SJeremy L Thompson #include <ceed/backend.h> 1049aac155SJeremy L Thompson #include <stdbool.h> 110f58c348SJeremy L Thompson #include <string.h> 120f58c348SJeremy L Thompson #include <valgrind/memcheck.h> 132b730f8bSJeremy L Thompson 140f58c348SJeremy L Thompson #include "ceed-memcheck.h" 150f58c348SJeremy L Thompson 160f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 170f58c348SJeremy L Thompson // QFunctionContext has valid data 180f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 192b730f8bSJeremy L Thompson static int CeedQFunctionContextHasValidData_Memcheck(CeedQFunctionContext ctx, bool *has_valid_data) { 200f58c348SJeremy L Thompson CeedQFunctionContext_Memcheck *impl; 21ad70ee2cSJeremy L Thompson 229a25c351SJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetBackendData(ctx, &impl)); 23*0307dd02SJeremy L Thompson *has_valid_data = !!impl->data_allocated; 240f58c348SJeremy L Thompson return CEED_ERROR_SUCCESS; 250f58c348SJeremy L Thompson } 260f58c348SJeremy L Thompson 270f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 280f58c348SJeremy L Thompson // QFunctionContext has borrowed data 290f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 302b730f8bSJeremy L Thompson static int CeedQFunctionContextHasBorrowedDataOfType_Memcheck(CeedQFunctionContext ctx, CeedMemType mem_type, bool *has_borrowed_data_of_type) { 31ad70ee2cSJeremy L Thompson CeedQFunctionContext_Memcheck *impl; 32ad70ee2cSJeremy L Thompson 336e536b99SJeremy L Thompson CeedCheck(mem_type == CEED_MEM_HOST, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_BACKEND, "Can only set HOST memory for this backend"); 34*0307dd02SJeremy L Thompson 35*0307dd02SJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetBackendData(ctx, &impl)); 36*0307dd02SJeremy L Thompson *has_borrowed_data_of_type = !!impl->data_borrowed; 370f58c348SJeremy L Thompson return CEED_ERROR_SUCCESS; 380f58c348SJeremy L Thompson } 390f58c348SJeremy L Thompson 400f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 410f58c348SJeremy L Thompson // QFunctionContext Set Data 420f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 432b730f8bSJeremy L Thompson static int CeedQFunctionContextSetData_Memcheck(CeedQFunctionContext ctx, CeedMemType mem_type, CeedCopyMode copy_mode, void *data) { 44ad70ee2cSJeremy L Thompson size_t ctx_size; 45ad70ee2cSJeremy L Thompson CeedQFunctionContext_Memcheck *impl; 46ad70ee2cSJeremy L Thompson 47*0307dd02SJeremy L Thompson CeedCheck(mem_type == CEED_MEM_HOST, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_BACKEND, "Can only set HOST memory for this backend"); 48*0307dd02SJeremy L Thompson 499a25c351SJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetBackendData(ctx, &impl)); 50ad70ee2cSJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetContextSize(ctx, &ctx_size)); 510f58c348SJeremy L Thompson 52*0307dd02SJeremy L Thompson // Clear previous owned data buffers 53*0307dd02SJeremy L Thompson if (impl->data_allocated) { 54*0307dd02SJeremy L Thompson memset(impl->data_allocated, -42, ctx_size); 55*0307dd02SJeremy L Thompson VALGRIND_DISCARD(impl->allocated_block_id); 56*0307dd02SJeremy L Thompson } 572b730f8bSJeremy L Thompson CeedCallBackend(CeedFree(&impl->data_allocated)); 58*0307dd02SJeremy L Thompson if (impl->data_owned) { 59*0307dd02SJeremy L Thompson memset(impl->data_owned, -42, ctx_size); 60*0307dd02SJeremy L Thompson VALGRIND_DISCARD(impl->owned_block_id); 61*0307dd02SJeremy L Thompson } 622b730f8bSJeremy L Thompson CeedCallBackend(CeedFree(&impl->data_owned)); 63*0307dd02SJeremy L Thompson 64*0307dd02SJeremy L Thompson // Clear borrowed block id, if present 65*0307dd02SJeremy L Thompson if (impl->data_borrowed) VALGRIND_DISCARD(impl->borrowed_block_id); 66*0307dd02SJeremy L Thompson 67*0307dd02SJeremy L Thompson // Set internal pointers to external buffers 680f58c348SJeremy L Thompson switch (copy_mode) { 690f58c348SJeremy L Thompson case CEED_COPY_VALUES: 70*0307dd02SJeremy L Thompson impl->data_owned = NULL; 710f58c348SJeremy L Thompson impl->data_borrowed = NULL; 720f58c348SJeremy L Thompson break; 730f58c348SJeremy L Thompson case CEED_OWN_POINTER: 740f58c348SJeremy L Thompson impl->data_owned = data; 750f58c348SJeremy L Thompson impl->data_borrowed = NULL; 76*0307dd02SJeremy L Thompson impl->owned_block_id = VALGRIND_CREATE_BLOCK(impl->data_owned, ctx_size, "Owned external data buffer"); 770f58c348SJeremy L Thompson break; 780f58c348SJeremy L Thompson case CEED_USE_POINTER: 79*0307dd02SJeremy L Thompson impl->data_owned = NULL; 800f58c348SJeremy L Thompson impl->data_borrowed = data; 81*0307dd02SJeremy L Thompson impl->owned_block_id = VALGRIND_CREATE_BLOCK(impl->data_borrowed, ctx_size, "Borrowed external data buffer"); 820f58c348SJeremy L Thompson } 83*0307dd02SJeremy L Thompson 84*0307dd02SJeremy L Thompson // Create internal data buffer 852b730f8bSJeremy L Thompson CeedCallBackend(CeedMallocArray(1, ctx_size, &impl->data_allocated)); 86*0307dd02SJeremy L Thompson impl->allocated_block_id = VALGRIND_CREATE_BLOCK(impl->data_allocated, ctx_size, "'Allocated internal context data buffer"); 87*0307dd02SJeremy L Thompson memcpy(impl->data_allocated, data, ctx_size); 88*0307dd02SJeremy L Thompson return CEED_ERROR_SUCCESS; 89*0307dd02SJeremy L Thompson } 90*0307dd02SJeremy L Thompson 91*0307dd02SJeremy L Thompson //------------------------------------------------------------------------------ 92*0307dd02SJeremy L Thompson // Sync data 93*0307dd02SJeremy L Thompson //------------------------------------------------------------------------------ 94*0307dd02SJeremy L Thompson static int CeedQFunctionContextSyncData_Memcheck(CeedQFunctionContext ctx, CeedMemType mem_type) { 95*0307dd02SJeremy L Thompson size_t ctx_size; 96*0307dd02SJeremy L Thompson CeedQFunctionContext_Memcheck *impl; 97*0307dd02SJeremy L Thompson 98*0307dd02SJeremy L Thompson CeedCheck(mem_type == CEED_MEM_HOST, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_BACKEND, "Can only set HOST memory for this backend"); 99*0307dd02SJeremy L Thompson 100*0307dd02SJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetBackendData(ctx, &impl)); 101*0307dd02SJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetContextSize(ctx, &ctx_size)); 102*0307dd02SJeremy L Thompson 103*0307dd02SJeremy L Thompson // Copy internal buffer back to owned or borrowed data buffer 104*0307dd02SJeremy L Thompson if (impl->data_owned) { 105*0307dd02SJeremy L Thompson memcpy(impl->data_owned, impl->data_allocated, ctx_size); 106*0307dd02SJeremy L Thompson } 107*0307dd02SJeremy L Thompson if (impl->data_borrowed) { 108*0307dd02SJeremy L Thompson memcpy(impl->data_borrowed, impl->data_allocated, ctx_size); 109*0307dd02SJeremy L Thompson } 1100f58c348SJeremy L Thompson return CEED_ERROR_SUCCESS; 1110f58c348SJeremy L Thompson } 1120f58c348SJeremy L Thompson 1130f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 1140f58c348SJeremy L Thompson // QFunctionContext Take Data 1150f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 1162b730f8bSJeremy L Thompson static int CeedQFunctionContextTakeData_Memcheck(CeedQFunctionContext ctx, CeedMemType mem_type, void *data) { 117*0307dd02SJeremy L Thompson size_t ctx_size; 118ad70ee2cSJeremy L Thompson CeedQFunctionContext_Memcheck *impl; 119ad70ee2cSJeremy L Thompson 1206e536b99SJeremy L Thompson CeedCheck(mem_type == CEED_MEM_HOST, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_BACKEND, "Can only provide HOST memory for this backend"); 1210f58c348SJeremy L Thompson 122*0307dd02SJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetBackendData(ctx, &impl)); 123*0307dd02SJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetContextSize(ctx, &ctx_size)); 124*0307dd02SJeremy L Thompson 125*0307dd02SJeremy L Thompson // Synchronize memory 126*0307dd02SJeremy L Thompson CeedCallBackend(CeedQFunctionContextSyncData_Memcheck(ctx, CEED_MEM_HOST)); 127*0307dd02SJeremy L Thompson 128*0307dd02SJeremy L Thompson // Return borrowed buffer 1290f58c348SJeremy L Thompson *(void **)data = impl->data_borrowed; 1300f58c348SJeremy L Thompson impl->data_borrowed = NULL; 131*0307dd02SJeremy L Thompson VALGRIND_DISCARD(impl->borrowed_block_id); 132*0307dd02SJeremy L Thompson 133*0307dd02SJeremy L Thompson // De-allocate internal memory 134*0307dd02SJeremy L Thompson if (impl->data_allocated) { 135*0307dd02SJeremy L Thompson memset(impl->data_allocated, -42, ctx_size); 136*0307dd02SJeremy L Thompson VALGRIND_DISCARD(impl->allocated_block_id); 137*0307dd02SJeremy L Thompson } 1382b730f8bSJeremy L Thompson CeedCallBackend(CeedFree(&impl->data_allocated)); 1390f58c348SJeremy L Thompson return CEED_ERROR_SUCCESS; 1400f58c348SJeremy L Thompson } 1410f58c348SJeremy L Thompson 1420f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 1430f58c348SJeremy L Thompson // QFunctionContext Get Data 1440f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 1452b730f8bSJeremy L Thompson static int CeedQFunctionContextGetData_Memcheck(CeedQFunctionContext ctx, CeedMemType mem_type, void *data) { 146*0307dd02SJeremy L Thompson size_t ctx_size; 147ad70ee2cSJeremy L Thompson CeedQFunctionContext_Memcheck *impl; 148ad70ee2cSJeremy L Thompson 149*0307dd02SJeremy L Thompson CeedCheck(mem_type == CEED_MEM_HOST, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_BACKEND, "Can only set HOST memory for this backend"); 150*0307dd02SJeremy L Thompson 1519a25c351SJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetBackendData(ctx, &impl)); 152*0307dd02SJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetContextSize(ctx, &ctx_size)); 1530f58c348SJeremy L Thompson 154*0307dd02SJeremy L Thompson // Create and return writable buffer 155*0307dd02SJeremy L Thompson CeedCallBackend(CeedMallocArray(1, ctx_size, &impl->data_writable_copy)); 156*0307dd02SJeremy L Thompson impl->writable_block_id = VALGRIND_CREATE_BLOCK(impl->data_writable_copy, ctx_size, "Allocated writeable data buffer copy"); 157*0307dd02SJeremy L Thompson memcpy(impl->data_writable_copy, impl->data_allocated, ctx_size); 158*0307dd02SJeremy L Thompson *(void **)data = impl->data_writable_copy; 1590f58c348SJeremy L Thompson return CEED_ERROR_SUCCESS; 1600f58c348SJeremy L Thompson } 1610f58c348SJeremy L Thompson 1620f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 1638e457467SJeremy L Thompson // QFunctionContext Get Data Read-Only 1648e457467SJeremy L Thompson //------------------------------------------------------------------------------ 1652b730f8bSJeremy L Thompson static int CeedQFunctionContextGetDataRead_Memcheck(CeedQFunctionContext ctx, CeedMemType mem_type, void *data) { 166ad70ee2cSJeremy L Thompson size_t ctx_size; 167ad70ee2cSJeremy L Thompson CeedQFunctionContext_Memcheck *impl; 1688e457467SJeremy L Thompson 169*0307dd02SJeremy L Thompson CeedCheck(mem_type == CEED_MEM_HOST, CeedQFunctionContextReturnCeed(ctx), CEED_ERROR_BACKEND, "Can only set HOST memory for this backend"); 170*0307dd02SJeremy L Thompson 1719a25c351SJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetBackendData(ctx, &impl)); 172ad70ee2cSJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetContextSize(ctx, &ctx_size)); 1738e457467SJeremy L Thompson 174*0307dd02SJeremy L Thompson // Create and return read-only buffer 175*0307dd02SJeremy L Thompson if (!impl->data_read_only_copy) { 1762b730f8bSJeremy L Thompson CeedCallBackend(CeedMallocArray(1, ctx_size, &impl->data_read_only_copy)); 177*0307dd02SJeremy L Thompson impl->writable_block_id = VALGRIND_CREATE_BLOCK(impl->data_read_only_copy, ctx_size, "Allocated read-only data buffer copy"); 178*0307dd02SJeremy L Thompson memcpy(impl->data_read_only_copy, impl->data_allocated, ctx_size); 179*0307dd02SJeremy L Thompson } 180*0307dd02SJeremy L Thompson *(void **)data = impl->data_read_only_copy; 1818e457467SJeremy L Thompson return CEED_ERROR_SUCCESS; 1828e457467SJeremy L Thompson } 1838e457467SJeremy L Thompson 1848e457467SJeremy L Thompson //------------------------------------------------------------------------------ 1850f58c348SJeremy L Thompson // QFunctionContext Restore Data 1860f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 1870f58c348SJeremy L Thompson static int CeedQFunctionContextRestoreData_Memcheck(CeedQFunctionContext ctx) { 1880f58c348SJeremy L Thompson size_t ctx_size; 1890f58c348SJeremy L Thompson CeedQFunctionContext_Memcheck *impl; 190ad70ee2cSJeremy L Thompson 191ad70ee2cSJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetContextSize(ctx, &ctx_size)); 1929a25c351SJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetBackendData(ctx, &impl)); 1930f58c348SJeremy L Thompson 194*0307dd02SJeremy L Thompson // Copy back to internal buffer and sync 195*0307dd02SJeremy L Thompson memcpy(impl->data_allocated, impl->data_writable_copy, ctx_size); 196*0307dd02SJeremy L Thompson CeedCallBackend(CeedQFunctionContextSyncData_Memcheck(ctx, CEED_MEM_HOST)); 197*0307dd02SJeremy L Thompson 198*0307dd02SJeremy L Thompson // Invalidate writable buffer 199*0307dd02SJeremy L Thompson memset(impl->data_writable_copy, -42, ctx_size); 200*0307dd02SJeremy L Thompson CeedCallBackend(CeedFree(&impl->data_writable_copy)); 201*0307dd02SJeremy L Thompson VALGRIND_DISCARD(impl->writable_block_id); 2020f58c348SJeremy L Thompson return CEED_ERROR_SUCCESS; 2030f58c348SJeremy L Thompson } 2040f58c348SJeremy L Thompson 2050f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 2068e457467SJeremy L Thompson // QFunctionContext Restore Data Read-Only 2078e457467SJeremy L Thompson //------------------------------------------------------------------------------ 2082b730f8bSJeremy L Thompson static int CeedQFunctionContextRestoreDataRead_Memcheck(CeedQFunctionContext ctx) { 209*0307dd02SJeremy L Thompson Ceed ceed; 210ad70ee2cSJeremy L Thompson size_t ctx_size; 211ad70ee2cSJeremy L Thompson CeedQFunctionContext_Memcheck *impl; 212ad70ee2cSJeremy L Thompson 213*0307dd02SJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetCeed(ctx, &ceed)); 214ad70ee2cSJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetContextSize(ctx, &ctx_size)); 2159a25c351SJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetBackendData(ctx, &impl)); 2168e457467SJeremy L Thompson 217*0307dd02SJeremy L Thompson // Verify no changes made during read-only access 218*0307dd02SJeremy L Thompson bool is_changed = memcmp(impl->data_allocated, impl->data_read_only_copy, ctx_size); 2198e457467SJeremy L Thompson 220*0307dd02SJeremy L Thompson CeedCheck(!is_changed, ceed, CEED_ERROR_BACKEND, "Context data changed while accessed in read-only mode"); 221*0307dd02SJeremy L Thompson 222*0307dd02SJeremy L Thompson // Invalidate read-only buffer 223*0307dd02SJeremy L Thompson memset(impl->data_read_only_copy, -42, ctx_size); 2242b730f8bSJeremy L Thompson CeedCallBackend(CeedFree(&impl->data_read_only_copy)); 225*0307dd02SJeremy L Thompson VALGRIND_DISCARD(impl->read_only_block_id); 2268e457467SJeremy L Thompson return CEED_ERROR_SUCCESS; 2278e457467SJeremy L Thompson } 2288e457467SJeremy L Thompson 2298e457467SJeremy L Thompson //------------------------------------------------------------------------------ 2302e64a2b9SJeremy L Thompson // QFunctionContext destroy user data 2312e64a2b9SJeremy L Thompson //------------------------------------------------------------------------------ 2322e64a2b9SJeremy L Thompson static int CeedQFunctionContextDataDestroy_Memcheck(CeedQFunctionContext ctx) { 233*0307dd02SJeremy L Thompson Ceed ceed; 234ad70ee2cSJeremy L Thompson CeedMemType data_destroy_mem_type; 235ad70ee2cSJeremy L Thompson CeedQFunctionContextDataDestroyUser data_destroy_function; 236ad70ee2cSJeremy L Thompson CeedQFunctionContext_Memcheck *impl; 237ad70ee2cSJeremy L Thompson 238*0307dd02SJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetCeed(ctx, &ceed)); 239ad70ee2cSJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetBackendData(ctx, &impl)); 240*0307dd02SJeremy L Thompson 241ad70ee2cSJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetDataDestroy(ctx, &data_destroy_mem_type, &data_destroy_function)); 242*0307dd02SJeremy L Thompson CeedCheck(data_destroy_mem_type == CEED_MEM_HOST, ceed, CEED_ERROR_BACKEND, "Can only destroy HOST memory for this backend"); 2432e64a2b9SJeremy L Thompson 244*0307dd02SJeremy L Thompson // Run user destroy routine 2452e64a2b9SJeremy L Thompson if (data_destroy_function) { 246*0307dd02SJeremy L Thompson bool is_borrowed = !!impl->data_borrowed; 247*0307dd02SJeremy L Thompson 248*0307dd02SJeremy L Thompson CeedCallBackend(data_destroy_function(is_borrowed ? impl->data_borrowed : impl->data_owned)); 249*0307dd02SJeremy L Thompson if (is_borrowed) VALGRIND_DISCARD(impl->borrowed_block_id); 250*0307dd02SJeremy L Thompson else VALGRIND_DISCARD(impl->owned_block_id); 2512e64a2b9SJeremy L Thompson } 252*0307dd02SJeremy L Thompson // Free allocations and discard block ids 253*0307dd02SJeremy L Thompson if (impl->data_allocated) { 2542b730f8bSJeremy L Thompson CeedCallBackend(CeedFree(&impl->data_allocated)); 255*0307dd02SJeremy L Thompson VALGRIND_DISCARD(impl->allocated_block_id); 256*0307dd02SJeremy L Thompson } 257*0307dd02SJeremy L Thompson if (impl->data_owned) { 258*0307dd02SJeremy L Thompson CeedCallBackend(CeedFree(&impl->data_owned)); 259*0307dd02SJeremy L Thompson VALGRIND_DISCARD(impl->owned_block_id); 260*0307dd02SJeremy L Thompson } 261*0307dd02SJeremy L Thompson if (impl->data_borrowed) { 262*0307dd02SJeremy L Thompson VALGRIND_DISCARD(impl->borrowed_block_id); 263*0307dd02SJeremy L Thompson } 2642e64a2b9SJeremy L Thompson return CEED_ERROR_SUCCESS; 2652e64a2b9SJeremy L Thompson } 2662e64a2b9SJeremy L Thompson 2672e64a2b9SJeremy L Thompson //------------------------------------------------------------------------------ 2680f58c348SJeremy L Thompson // QFunctionContext Destroy 2690f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 2700f58c348SJeremy L Thompson static int CeedQFunctionContextDestroy_Memcheck(CeedQFunctionContext ctx) { 2710f58c348SJeremy L Thompson CeedQFunctionContext_Memcheck *impl; 2720f58c348SJeremy L Thompson 273*0307dd02SJeremy L Thompson // Free allocations and discard block ids 274ad70ee2cSJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetBackendData(ctx, &impl)); 275*0307dd02SJeremy L Thompson if (impl->data_allocated) { 2762b730f8bSJeremy L Thompson CeedCallBackend(CeedFree(&impl->data_allocated)); 277*0307dd02SJeremy L Thompson VALGRIND_DISCARD(impl->allocated_block_id); 278*0307dd02SJeremy L Thompson } 279*0307dd02SJeremy L Thompson if (impl->data_owned) { 2802b730f8bSJeremy L Thompson CeedCallBackend(CeedFree(&impl->data_owned)); 281*0307dd02SJeremy L Thompson VALGRIND_DISCARD(impl->owned_block_id); 282*0307dd02SJeremy L Thompson } 283*0307dd02SJeremy L Thompson if (impl->data_borrowed) { 284*0307dd02SJeremy L Thompson VALGRIND_DISCARD(impl->borrowed_block_id); 285*0307dd02SJeremy L Thompson } 2862b730f8bSJeremy L Thompson CeedCallBackend(CeedFree(&impl)); 2870f58c348SJeremy L Thompson return CEED_ERROR_SUCCESS; 2880f58c348SJeremy L Thompson } 2890f58c348SJeremy L Thompson 2900f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 2910f58c348SJeremy L Thompson // QFunctionContext Create 2920f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 2930f58c348SJeremy L Thompson int CeedQFunctionContextCreate_Memcheck(CeedQFunctionContext ctx) { 2940f58c348SJeremy L Thompson Ceed ceed; 295ad70ee2cSJeremy L Thompson CeedQFunctionContext_Memcheck *impl; 2960f58c348SJeremy L Thompson 297ad70ee2cSJeremy L Thompson CeedCallBackend(CeedQFunctionContextGetCeed(ctx, &ceed)); 2982b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "QFunctionContext", ctx, "HasValidData", CeedQFunctionContextHasValidData_Memcheck)); 2992b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "QFunctionContext", ctx, "HasBorrowedDataOfType", CeedQFunctionContextHasBorrowedDataOfType_Memcheck)); 3002b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "QFunctionContext", ctx, "SetData", CeedQFunctionContextSetData_Memcheck)); 3012b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "QFunctionContext", ctx, "TakeData", CeedQFunctionContextTakeData_Memcheck)); 3022b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "QFunctionContext", ctx, "GetData", CeedQFunctionContextGetData_Memcheck)); 3032b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "QFunctionContext", ctx, "GetDataRead", CeedQFunctionContextGetDataRead_Memcheck)); 3042b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "QFunctionContext", ctx, "RestoreData", CeedQFunctionContextRestoreData_Memcheck)); 3052b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "QFunctionContext", ctx, "RestoreDataRead", CeedQFunctionContextRestoreDataRead_Memcheck)); 3062b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "QFunctionContext", ctx, "DataDestroy", CeedQFunctionContextDataDestroy_Memcheck)); 3072b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "QFunctionContext", ctx, "Destroy", CeedQFunctionContextDestroy_Memcheck)); 3082b730f8bSJeremy L Thompson CeedCallBackend(CeedCalloc(1, &impl)); 3092b730f8bSJeremy L Thompson CeedCallBackend(CeedQFunctionContextSetBackendData(ctx, impl)); 3100f58c348SJeremy L Thompson return CEED_ERROR_SUCCESS; 3110f58c348SJeremy L Thompson } 3122a86cc9dSSebastian Grimberg 3130f58c348SJeremy L Thompson //------------------------------------------------------------------------------ 314