19ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, 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
849aac155SJeremy L Thompson #include <ceed.h>
9ec3da8bcSJed Brown #include <ceed/backend.h>
102b730f8bSJeremy 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 /**
15ca94c3ddSJeremy L Thompson @brief Set fields identity `CeedQFunction` that copies inputs directly into outputs
160219ea01SJeremy L Thompson **/
CeedQFunctionInit_Identity(Ceed ceed,const char * requested,CeedQFunction qf)172b730f8bSJeremy 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*6261a418SJeremy L Thompson
216574a04fSJeremy L Thompson CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
220219ea01SJeremy L Thompson
23ea61e9acSJeremy L Thompson // QFunction fields 'input' and 'output' with requested emodes added by the library rather than being added here
240219ea01SJeremy L Thompson
25547dbd6fSJeremy L Thompson // Context data
26547dbd6fSJeremy L Thompson CeedQFunctionContext ctx;
27547dbd6fSJeremy L Thompson IdentityCtx ctx_data = {.size = 1};
28*6261a418SJeremy L Thompson
292b730f8bSJeremy L Thompson CeedCall(CeedQFunctionContextCreate(ceed, &ctx));
309a25c351SJeremy L Thompson CeedCall(CeedQFunctionContextSetData(ctx, CEED_MEM_HOST, CEED_COPY_VALUES, sizeof(ctx_data), &ctx_data));
312b730f8bSJeremy L Thompson CeedCall(CeedQFunctionContextRegisterInt32(ctx, "size", offsetof(IdentityCtx, size), 1, "field size of identity QFunction"));
322b730f8bSJeremy L Thompson CeedCall(CeedQFunctionSetContext(qf, ctx));
332b730f8bSJeremy L Thompson CeedCall(CeedQFunctionContextDestroy(&ctx));
34547dbd6fSJeremy L Thompson
35*6261a418SJeremy L Thompson CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 0));
36e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS;
370219ea01SJeremy L Thompson }
380219ea01SJeremy L Thompson
390219ea01SJeremy L Thompson /**
40ca94c3ddSJeremy L Thompson @brief Register identity `CeedQFunction` that copies inputs directly into outputs
410219ea01SJeremy L Thompson **/
CeedQFunctionRegister_Identity(void)421d013790SJed Brown CEED_INTERN int CeedQFunctionRegister_Identity(void) {
432b730f8bSJeremy L Thompson return CeedQFunctionRegister("Identity", Identity_loc, 1, Identity, CeedQFunctionInit_Identity);
440219ea01SJeremy L Thompson }
45