13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 30219ea01SJeremy L Thompson // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 50219ea01SJeremy L Thompson // 63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 70219ea01SJeremy L Thompson 8ec3da8bcSJed Brown #include <ceed/backend.h> 9*2b730f8bSJeremy L Thompson #include <ceed/ceed.h> 10*2b730f8bSJeremy L Thompson #include <ceed/jit-source/gallery/ceed-identity.h> 11547dbd6fSJeremy L Thompson #include <stddef.h> 120219ea01SJeremy L Thompson #include <string.h> 130219ea01SJeremy L Thompson 140219ea01SJeremy L Thompson /** 150219ea01SJeremy L Thompson @brief Set fields identity QFunction that copies inputs directly into outputs 160219ea01SJeremy L Thompson **/ 17*2b730f8bSJeremy L Thompson static int CeedQFunctionInit_Identity(Ceed ceed, const char *requested, CeedQFunction qf) { 180219ea01SJeremy L Thompson // Check QFunction name 190219ea01SJeremy L Thompson const char *name = "Identity"; 20*2b730f8bSJeremy L Thompson if (strcmp(name, requested)) { 21f0d2f928Sjeremylt // LCOV_EXCL_START 22*2b730f8bSJeremy L Thompson return CeedError(ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested); 23f0d2f928Sjeremylt // LCOV_EXCL_STOP 24*2b730f8bSJeremy L Thompson } 250219ea01SJeremy L Thompson 2660f77c51Sjeremylt // QFunction fields 'input' and 'output' with requested emodes added 2760f77c51Sjeremylt // by the library rather than being added here 280219ea01SJeremy L Thompson 29*2b730f8bSJeremy L Thompson CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 0)); 306e15d496SJeremy L Thompson 31547dbd6fSJeremy L Thompson // Context data 32547dbd6fSJeremy L Thompson CeedQFunctionContext ctx; 33547dbd6fSJeremy L Thompson IdentityCtx ctx_data = {.size = 1}; 34*2b730f8bSJeremy L Thompson CeedCall(CeedQFunctionContextCreate(ceed, &ctx)); 35*2b730f8bSJeremy L Thompson CeedCall(CeedQFunctionContextSetData(ctx, CEED_MEM_HOST, CEED_COPY_VALUES, sizeof(ctx_data), (void *)&ctx_data)); 36*2b730f8bSJeremy L Thompson CeedCall(CeedQFunctionContextRegisterInt32(ctx, "size", offsetof(IdentityCtx, size), 1, "field size of identity QFunction")); 37*2b730f8bSJeremy L Thompson CeedCall(CeedQFunctionSetContext(qf, ctx)); 38*2b730f8bSJeremy L Thompson CeedCall(CeedQFunctionContextDestroy(&ctx)); 39547dbd6fSJeremy L Thompson 40e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 410219ea01SJeremy L Thompson } 420219ea01SJeremy L Thompson 430219ea01SJeremy L Thompson /** 440219ea01SJeremy L Thompson @brief Register identity QFunction that copies inputs directly into outputs 450219ea01SJeremy L Thompson **/ 461d013790SJed Brown CEED_INTERN int CeedQFunctionRegister_Identity(void) { 47*2b730f8bSJeremy L Thompson return CeedQFunctionRegister("Identity", Identity_loc, 1, Identity, CeedQFunctionInit_Identity); 480219ea01SJeremy L Thompson } 49