1777ff853SJeremy L Thompson // Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2777ff853SJeremy L Thompson // the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3777ff853SJeremy L Thompson // reserved. See files LICENSE and NOTICE for details. 4777ff853SJeremy L Thompson // 5777ff853SJeremy L Thompson // This file is part of CEED, a collection of benchmarks, miniapps, software 6777ff853SJeremy L Thompson // libraries and APIs for efficient high-order finite element and spectral 7777ff853SJeremy L Thompson // element discretizations for exascale applications. For more information and 8777ff853SJeremy L Thompson // source code availability see http://github.com/ceed. 9777ff853SJeremy L Thompson // 10777ff853SJeremy L Thompson // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11777ff853SJeremy L Thompson // a collaborative effort of two U.S. Department of Energy organizations (Office 12777ff853SJeremy L Thompson // of Science and the National Nuclear Security Administration) responsible for 13777ff853SJeremy L Thompson // the planning and preparation of a capable exascale ecosystem, including 14777ff853SJeremy L Thompson // software, applications, hardware, advanced system engineering and early 15777ff853SJeremy L Thompson // testbed platforms, in support of the nation's exascale computing imperative. 16777ff853SJeremy L Thompson 17ec3da8bcSJed Brown #include <ceed/ceed.h> 18ec3da8bcSJed Brown #include <ceed/backend.h> 193d576824SJeremy L Thompson #include <ceed-impl.h> 203d576824SJeremy L Thompson #include <stdint.h> 213d576824SJeremy L Thompson #include <stdio.h> 22777ff853SJeremy L Thompson 23777ff853SJeremy L Thompson /// @file 24777ff853SJeremy L Thompson /// Implementation of public CeedQFunctionContext interfaces 25777ff853SJeremy L Thompson 26777ff853SJeremy L Thompson /// ---------------------------------------------------------------------------- 27777ff853SJeremy L Thompson /// CeedQFunctionContext Backend API 28777ff853SJeremy L Thompson /// ---------------------------------------------------------------------------- 29777ff853SJeremy L Thompson /// @addtogroup CeedQFunctionBackend 30777ff853SJeremy L Thompson /// @{ 31777ff853SJeremy L Thompson 32777ff853SJeremy L Thompson /** 33777ff853SJeremy L Thompson @brief Get the Ceed associated with a CeedQFunctionContext 34777ff853SJeremy L Thompson 35777ff853SJeremy L Thompson @param ctx CeedQFunctionContext 36777ff853SJeremy L Thompson @param[out] ceed Variable to store Ceed 37777ff853SJeremy L Thompson 38777ff853SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 39777ff853SJeremy L Thompson 40777ff853SJeremy L Thompson @ref Backend 41777ff853SJeremy L Thompson **/ 42777ff853SJeremy L Thompson int CeedQFunctionContextGetCeed(CeedQFunctionContext ctx, Ceed *ceed) { 43777ff853SJeremy L Thompson *ceed = ctx->ceed; 44e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 45777ff853SJeremy L Thompson } 46777ff853SJeremy L Thompson 47777ff853SJeremy L Thompson /** 48777ff853SJeremy L Thompson @brief Get the state of a CeedQFunctionContext 49777ff853SJeremy L Thompson 50777ff853SJeremy L Thompson @param ctx CeedQFunctionContext to retrieve state 51777ff853SJeremy L Thompson @param[out] state Variable to store state 52777ff853SJeremy L Thompson 53777ff853SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 54777ff853SJeremy L Thompson 55777ff853SJeremy L Thompson @ref Backend 56777ff853SJeremy L Thompson **/ 57777ff853SJeremy L Thompson int CeedQFunctionContextGetState(CeedQFunctionContext ctx, uint64_t *state) { 58777ff853SJeremy L Thompson *state = ctx->state; 59e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 60777ff853SJeremy L Thompson } 61777ff853SJeremy L Thompson 62777ff853SJeremy L Thompson /** 63777ff853SJeremy L Thompson @brief Get backend data of a CeedQFunctionContext 64777ff853SJeremy L Thompson 65777ff853SJeremy L Thompson @param ctx CeedQFunctionContext 66777ff853SJeremy L Thompson @param[out] data Variable to store data 67777ff853SJeremy L Thompson 68777ff853SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 69777ff853SJeremy L Thompson 70777ff853SJeremy L Thompson @ref Backend 71777ff853SJeremy L Thompson **/ 72777ff853SJeremy L Thompson int CeedQFunctionContextGetBackendData(CeedQFunctionContext ctx, void *data) { 73777ff853SJeremy L Thompson *(void **)data = ctx->data; 74e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 75777ff853SJeremy L Thompson } 76777ff853SJeremy L Thompson 77777ff853SJeremy L Thompson /** 78777ff853SJeremy L Thompson @brief Set backend data of a CeedQFunctionContext 79777ff853SJeremy L Thompson 80777ff853SJeremy L Thompson @param[out] ctx CeedQFunctionContext 81777ff853SJeremy L Thompson @param data Data to set 82777ff853SJeremy L Thompson 83777ff853SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 84777ff853SJeremy L Thompson 85777ff853SJeremy L Thompson @ref Backend 86777ff853SJeremy L Thompson **/ 87777ff853SJeremy L Thompson int CeedQFunctionContextSetBackendData(CeedQFunctionContext ctx, void *data) { 88777ff853SJeremy L Thompson ctx->data = data; 89e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 90777ff853SJeremy L Thompson } 91777ff853SJeremy L Thompson 9234359f16Sjeremylt /** 9334359f16Sjeremylt @brief Increment the reference counter for a CeedQFunctionContext 9434359f16Sjeremylt 9534359f16Sjeremylt @param ctx CeedQFunctionContext to increment the reference counter 9634359f16Sjeremylt 9734359f16Sjeremylt @return An error code: 0 - success, otherwise - failure 9834359f16Sjeremylt 9934359f16Sjeremylt @ref Backend 10034359f16Sjeremylt **/ 1019560d06aSjeremylt int CeedQFunctionContextReference(CeedQFunctionContext ctx) { 10234359f16Sjeremylt ctx->ref_count++; 10334359f16Sjeremylt return CEED_ERROR_SUCCESS; 10434359f16Sjeremylt } 10534359f16Sjeremylt 106777ff853SJeremy L Thompson /// @} 107777ff853SJeremy L Thompson 108777ff853SJeremy L Thompson /// ---------------------------------------------------------------------------- 109777ff853SJeremy L Thompson /// CeedQFunctionContext Public API 110777ff853SJeremy L Thompson /// ---------------------------------------------------------------------------- 111777ff853SJeremy L Thompson /// @addtogroup CeedQFunctionUser 112777ff853SJeremy L Thompson /// @{ 113777ff853SJeremy L Thompson 114777ff853SJeremy L Thompson /** 115777ff853SJeremy L Thompson @brief Create a CeedQFunctionContext for storing CeedQFunction user context data 116777ff853SJeremy L Thompson 117777ff853SJeremy L Thompson @param ceed A Ceed object where the CeedQFunctionContext will be created 118777ff853SJeremy L Thompson @param[out] ctx Address of the variable where the newly created 119777ff853SJeremy L Thompson CeedQFunctionContext will be stored 120777ff853SJeremy L Thompson 121777ff853SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 122777ff853SJeremy L Thompson 123777ff853SJeremy L Thompson @ref User 124777ff853SJeremy L Thompson **/ 125777ff853SJeremy L Thompson int CeedQFunctionContextCreate(Ceed ceed, CeedQFunctionContext *ctx) { 126777ff853SJeremy L Thompson int ierr; 127777ff853SJeremy L Thompson 128777ff853SJeremy L Thompson if (!ceed->QFunctionContextCreate) { 129777ff853SJeremy L Thompson Ceed delegate; 130777ff853SJeremy L Thompson ierr = CeedGetObjectDelegate(ceed, &delegate, "Context"); CeedChk(ierr); 131777ff853SJeremy L Thompson 132777ff853SJeremy L Thompson if (!delegate) 133777ff853SJeremy L Thompson // LCOV_EXCL_START 134e15f9bd0SJeremy L Thompson return CeedError(ceed, CEED_ERROR_UNSUPPORTED, 135e15f9bd0SJeremy L Thompson "Backend does not support ContextCreate"); 136777ff853SJeremy L Thompson // LCOV_EXCL_STOP 137777ff853SJeremy L Thompson 138777ff853SJeremy L Thompson ierr = CeedQFunctionContextCreate(delegate, ctx); CeedChk(ierr); 139e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 140777ff853SJeremy L Thompson } 141777ff853SJeremy L Thompson 142777ff853SJeremy L Thompson ierr = CeedCalloc(1, ctx); CeedChk(ierr); 143777ff853SJeremy L Thompson (*ctx)->ceed = ceed; 1449560d06aSjeremylt ierr = CeedReference(ceed); CeedChk(ierr); 145d1d35e2fSjeremylt (*ctx)->ref_count = 1; 146777ff853SJeremy L Thompson ierr = ceed->QFunctionContextCreate(*ctx); CeedChk(ierr); 147e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 148777ff853SJeremy L Thompson } 149777ff853SJeremy L Thompson 150777ff853SJeremy L Thompson /** 1519560d06aSjeremylt @brief Copy the pointer to a CeedQFunctionContext. Both pointers should 1529560d06aSjeremylt be destroyed with `CeedQFunctionContextDestroy()`; 1539560d06aSjeremylt Note: If `*ctx_copy` is non-NULL, then it is assumed that 1549560d06aSjeremylt `*ctx_copy` is a pointer to a CeedQFunctionContext. This 1559560d06aSjeremylt CeedQFunctionContext will be destroyed if `*ctx_copy` is the 1569560d06aSjeremylt only reference to this CeedQFunctionContext. 1579560d06aSjeremylt 1589560d06aSjeremylt @param ctx CeedQFunctionContext to copy reference to 1599560d06aSjeremylt @param[out] ctx_copy Variable to store copied reference 1609560d06aSjeremylt 1619560d06aSjeremylt @return An error code: 0 - success, otherwise - failure 1629560d06aSjeremylt 1639560d06aSjeremylt @ref User 1649560d06aSjeremylt **/ 1659560d06aSjeremylt int CeedQFunctionContextReferenceCopy(CeedQFunctionContext ctx, 1669560d06aSjeremylt CeedQFunctionContext *ctx_copy) { 1679560d06aSjeremylt int ierr; 1689560d06aSjeremylt 1699560d06aSjeremylt ierr = CeedQFunctionContextReference(ctx); CeedChk(ierr); 1709560d06aSjeremylt ierr = CeedQFunctionContextDestroy(ctx_copy); CeedChk(ierr); 1719560d06aSjeremylt *ctx_copy = ctx; 1729560d06aSjeremylt return CEED_ERROR_SUCCESS; 1739560d06aSjeremylt } 1749560d06aSjeremylt 1759560d06aSjeremylt /** 176777ff853SJeremy L Thompson @brief Set the data used by a CeedQFunctionContext, freeing any previously allocated 177777ff853SJeremy L Thompson data if applicable. The backend may copy values to a different 178777ff853SJeremy L Thompson memtype, such as during @ref CeedQFunctionApply(). 179777ff853SJeremy L Thompson See also @ref CeedQFunctionContextTakeData(). 180777ff853SJeremy L Thompson 181777ff853SJeremy L Thompson @param ctx CeedQFunctionContext 182d1d35e2fSjeremylt @param mem_type Memory type of the data being passed 183d1d35e2fSjeremylt @param copy_mode Copy mode for the data 184891038deSjeremylt @param size Size of data, in bytes 185777ff853SJeremy L Thompson @param data Data to be used 186777ff853SJeremy L Thompson 187777ff853SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 188777ff853SJeremy L Thompson 189777ff853SJeremy L Thompson @ref User 190777ff853SJeremy L Thompson **/ 191d1d35e2fSjeremylt int CeedQFunctionContextSetData(CeedQFunctionContext ctx, CeedMemType mem_type, 192d1d35e2fSjeremylt CeedCopyMode copy_mode, 193777ff853SJeremy L Thompson size_t size, void *data) { 194777ff853SJeremy L Thompson int ierr; 195777ff853SJeremy L Thompson 196777ff853SJeremy L Thompson if (!ctx->SetData) 197777ff853SJeremy L Thompson // LCOV_EXCL_START 198e15f9bd0SJeremy L Thompson return CeedError(ctx->ceed, CEED_ERROR_UNSUPPORTED, 199e15f9bd0SJeremy L Thompson "Backend does not support ContextSetData"); 200777ff853SJeremy L Thompson // LCOV_EXCL_STOP 201777ff853SJeremy L Thompson 202777ff853SJeremy L Thompson if (ctx->state % 2 == 1) 203777ff853SJeremy L Thompson // LCOV_EXCL_START 204777ff853SJeremy L Thompson return CeedError(ctx->ceed, 1, 205777ff853SJeremy L Thompson "Cannot grant CeedQFunctionContext data access, the " 206777ff853SJeremy L Thompson "access lock is already in use"); 207777ff853SJeremy L Thompson // LCOV_EXCL_STOP 208777ff853SJeremy L Thompson 209d1d35e2fSjeremylt ctx->ctx_size = size; 210d1d35e2fSjeremylt ierr = ctx->SetData(ctx, mem_type, copy_mode, data); CeedChk(ierr); 211777ff853SJeremy L Thompson ctx->state += 2; 212e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 213777ff853SJeremy L Thompson } 214777ff853SJeremy L Thompson 215777ff853SJeremy L Thompson /** 216891038deSjeremylt @brief Take ownership of the data in a CeedQFunctionContext via the specified memory type. 217891038deSjeremylt The caller is responsible for managing and freeing the memory. 218891038deSjeremylt 219891038deSjeremylt @param ctx CeedQFunctionContext to access 220891038deSjeremylt @param mem_type Memory type on which to access the data. If the backend 221891038deSjeremylt uses a different memory type, this will perform a copy. 222891038deSjeremylt @param[out] data Data on memory type mem_type 223891038deSjeremylt 224891038deSjeremylt @return An error code: 0 - success, otherwise - failure 225891038deSjeremylt 226891038deSjeremylt @ref User 227891038deSjeremylt **/ 228891038deSjeremylt int CeedQFunctionContextTakeData(CeedQFunctionContext ctx, CeedMemType mem_type, 229891038deSjeremylt void *data) { 230891038deSjeremylt int ierr; 231891038deSjeremylt 232891038deSjeremylt if (!ctx->TakeData) 233891038deSjeremylt // LCOV_EXCL_START 234891038deSjeremylt return CeedError(ctx->ceed, CEED_ERROR_UNSUPPORTED, 235891038deSjeremylt "Backend does not support TakeData"); 236891038deSjeremylt // LCOV_EXCL_STOP 237891038deSjeremylt 238891038deSjeremylt if (ctx->state % 2 == 1) 239891038deSjeremylt // LCOV_EXCL_START 240891038deSjeremylt return CeedError(ctx->ceed, 1, 241891038deSjeremylt "Cannot grant CeedQFunctionContext data access, the " 242891038deSjeremylt "access lock is already in use"); 243891038deSjeremylt // LCOV_EXCL_STOP 244891038deSjeremylt 245891038deSjeremylt void *temp_data = NULL; 246891038deSjeremylt ierr = ctx->TakeData(ctx, mem_type, &temp_data); CeedChk(ierr); 247891038deSjeremylt if (data) (*(void **)data) = temp_data; 248891038deSjeremylt return CEED_ERROR_SUCCESS; 249891038deSjeremylt } 250891038deSjeremylt 251891038deSjeremylt /** 252777ff853SJeremy L Thompson @brief Get read/write access to a CeedQFunctionContext via the specified memory type. 253777ff853SJeremy L Thompson Restore access with @ref CeedQFunctionContextRestoreData(). 254777ff853SJeremy L Thompson 255777ff853SJeremy L Thompson @param ctx CeedQFunctionContext to access 256d1d35e2fSjeremylt @param mem_type Memory type on which to access the data. If the backend 257777ff853SJeremy L Thompson uses a different memory type, this will perform a copy. 258d1d35e2fSjeremylt @param[out] data Data on memory type mem_type 259777ff853SJeremy L Thompson 260777ff853SJeremy L Thompson @note The CeedQFunctionContextGetData() and @ref CeedQFunctionContextRestoreData() functions 261777ff853SJeremy L Thompson provide access to array pointers in the desired memory space. Pairing 262777ff853SJeremy L Thompson get/restore allows the Context to track access. 263777ff853SJeremy L Thompson 264777ff853SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 265777ff853SJeremy L Thompson 266777ff853SJeremy L Thompson @ref User 267777ff853SJeremy L Thompson **/ 268d1d35e2fSjeremylt int CeedQFunctionContextGetData(CeedQFunctionContext ctx, CeedMemType mem_type, 269777ff853SJeremy L Thompson void *data) { 270777ff853SJeremy L Thompson int ierr; 271777ff853SJeremy L Thompson 272777ff853SJeremy L Thompson if (!ctx->GetData) 273777ff853SJeremy L Thompson // LCOV_EXCL_START 274e15f9bd0SJeremy L Thompson return CeedError(ctx->ceed, CEED_ERROR_UNSUPPORTED, 275e15f9bd0SJeremy L Thompson "Backend does not support GetData"); 276777ff853SJeremy L Thompson // LCOV_EXCL_STOP 277777ff853SJeremy L Thompson 278777ff853SJeremy L Thompson if (ctx->state % 2 == 1) 279777ff853SJeremy L Thompson // LCOV_EXCL_START 280777ff853SJeremy L Thompson return CeedError(ctx->ceed, 1, 281777ff853SJeremy L Thompson "Cannot grant CeedQFunctionContext data access, the " 282777ff853SJeremy L Thompson "access lock is already in use"); 283777ff853SJeremy L Thompson // LCOV_EXCL_STOP 284777ff853SJeremy L Thompson 285d1d35e2fSjeremylt ierr = ctx->GetData(ctx, mem_type, data); CeedChk(ierr); 286777ff853SJeremy L Thompson ctx->state += 1; 287e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 288777ff853SJeremy L Thompson } 289777ff853SJeremy L Thompson 290777ff853SJeremy L Thompson /** 291777ff853SJeremy L Thompson @brief Restore data obtained using @ref CeedQFunctionContextGetData() 292777ff853SJeremy L Thompson 293777ff853SJeremy L Thompson @param ctx CeedQFunctionContext to restore 294777ff853SJeremy L Thompson @param data Data to restore 295777ff853SJeremy L Thompson 296777ff853SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 297777ff853SJeremy L Thompson 298777ff853SJeremy L Thompson @ref User 299777ff853SJeremy L Thompson **/ 300777ff853SJeremy L Thompson int CeedQFunctionContextRestoreData(CeedQFunctionContext ctx, void *data) { 301777ff853SJeremy L Thompson int ierr; 302777ff853SJeremy L Thompson 303777ff853SJeremy L Thompson if (!ctx->RestoreData) 304777ff853SJeremy L Thompson // LCOV_EXCL_START 305e15f9bd0SJeremy L Thompson return CeedError(ctx->ceed, CEED_ERROR_UNSUPPORTED, 306e15f9bd0SJeremy L Thompson "Backend does not support RestoreData"); 307777ff853SJeremy L Thompson // LCOV_EXCL_STOP 308777ff853SJeremy L Thompson 309777ff853SJeremy L Thompson if (ctx->state % 2 != 1) 310777ff853SJeremy L Thompson // LCOV_EXCL_START 311777ff853SJeremy L Thompson return CeedError(ctx->ceed, 1, 312777ff853SJeremy L Thompson "Cannot restore CeedQFunctionContext array access, " 313777ff853SJeremy L Thompson "access was not granted"); 314777ff853SJeremy L Thompson // LCOV_EXCL_STOP 315777ff853SJeremy L Thompson 316777ff853SJeremy L Thompson ierr = ctx->RestoreData(ctx); CeedChk(ierr); 317777ff853SJeremy L Thompson *(void **)data = NULL; 318777ff853SJeremy L Thompson ctx->state += 1; 319e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 320777ff853SJeremy L Thompson } 321777ff853SJeremy L Thompson 322777ff853SJeremy L Thompson /** 323*80a9ef05SNatalie Beams @brief Get data size for a Context 324*80a9ef05SNatalie Beams 325*80a9ef05SNatalie Beams @param ctx CeedQFunctionContext 326*80a9ef05SNatalie Beams @param[out] ctx_size Variable to store size of context data values 327*80a9ef05SNatalie Beams 328*80a9ef05SNatalie Beams @return An error code: 0 - success, otherwise - failure 329*80a9ef05SNatalie Beams 330*80a9ef05SNatalie Beams @ref User 331*80a9ef05SNatalie Beams **/ 332*80a9ef05SNatalie Beams int CeedQFunctionContextGetContextSize(CeedQFunctionContext ctx, 333*80a9ef05SNatalie Beams size_t *ctx_size) { 334*80a9ef05SNatalie Beams *ctx_size = ctx->ctx_size; 335*80a9ef05SNatalie Beams return CEED_ERROR_SUCCESS; 336*80a9ef05SNatalie Beams } 337*80a9ef05SNatalie Beams 338*80a9ef05SNatalie Beams 339*80a9ef05SNatalie Beams /** 340777ff853SJeremy L Thompson @brief View a CeedQFunctionContext 341777ff853SJeremy L Thompson 342777ff853SJeremy L Thompson @param[in] ctx CeedQFunctionContext to view 343777ff853SJeremy L Thompson @param[in] stream Filestream to write to 344777ff853SJeremy L Thompson 345777ff853SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 346777ff853SJeremy L Thompson 347777ff853SJeremy L Thompson @ref User 348777ff853SJeremy L Thompson **/ 349777ff853SJeremy L Thompson int CeedQFunctionContextView(CeedQFunctionContext ctx, FILE *stream) { 350777ff853SJeremy L Thompson fprintf(stream, "CeedQFunctionContext\n"); 351d1d35e2fSjeremylt fprintf(stream, " Context Data Size: %ld\n", ctx->ctx_size); 352e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 353777ff853SJeremy L Thompson } 354777ff853SJeremy L Thompson 355777ff853SJeremy L Thompson /** 356777ff853SJeremy L Thompson @brief Destroy a CeedQFunctionContext 357777ff853SJeremy L Thompson 358777ff853SJeremy L Thompson @param ctx CeedQFunctionContext to destroy 359777ff853SJeremy L Thompson 360777ff853SJeremy L Thompson @return An error code: 0 - success, otherwise - failure 361777ff853SJeremy L Thompson 362777ff853SJeremy L Thompson @ref User 363777ff853SJeremy L Thompson **/ 364777ff853SJeremy L Thompson int CeedQFunctionContextDestroy(CeedQFunctionContext *ctx) { 365777ff853SJeremy L Thompson int ierr; 366777ff853SJeremy L Thompson 367d1d35e2fSjeremylt if (!*ctx || --(*ctx)->ref_count > 0) 368e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 369777ff853SJeremy L Thompson 370777ff853SJeremy L Thompson if ((*ctx) && ((*ctx)->state % 2) == 1) 371777ff853SJeremy L Thompson // LCOV_EXCL_START 372777ff853SJeremy L Thompson return CeedError((*ctx)->ceed, 1, 373777ff853SJeremy L Thompson "Cannot destroy CeedQFunctionContext, the access " 374777ff853SJeremy L Thompson "lock is in use"); 375777ff853SJeremy L Thompson // LCOV_EXCL_STOP 376777ff853SJeremy L Thompson 377777ff853SJeremy L Thompson if ((*ctx)->Destroy) { 378777ff853SJeremy L Thompson ierr = (*ctx)->Destroy(*ctx); CeedChk(ierr); 379777ff853SJeremy L Thompson } 380777ff853SJeremy L Thompson ierr = CeedDestroy(&(*ctx)->ceed); CeedChk(ierr); 381777ff853SJeremy L Thompson ierr = CeedFree(ctx); CeedChk(ierr); 382e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 383777ff853SJeremy L Thompson } 384777ff853SJeremy L Thompson 385777ff853SJeremy L Thompson /// @} 386