xref: /libCEED/rust/libceed-sys/c-src/backends/opt/ceed-opt-blocked.c (revision 6f7d248d47a62b82d193827cb08f70763bbb868d)
189c6efa4Sjeremylt // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
289c6efa4Sjeremylt // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
389c6efa4Sjeremylt // All Rights reserved. See files LICENSE and NOTICE for details.
489c6efa4Sjeremylt //
589c6efa4Sjeremylt // This file is part of CEED, a collection of benchmarks, miniapps, software
689c6efa4Sjeremylt // libraries and APIs for efficient high-order finite element and spectral
789c6efa4Sjeremylt // element discretizations for exascale applications. For more information and
889c6efa4Sjeremylt // source code availability see http://github.com/ceed.
989c6efa4Sjeremylt //
1089c6efa4Sjeremylt // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
1189c6efa4Sjeremylt // a collaborative effort of two U.S. Department of Energy organizations (Office
1289c6efa4Sjeremylt // of Science and the National Nuclear Security Administration) responsible for
1389c6efa4Sjeremylt // the planning and preparation of a capable exascale ecosystem, including
1489c6efa4Sjeremylt // software, applications, hardware, advanced system engineering and early
1589c6efa4Sjeremylt // testbed platforms, in support of the nation's exascale computing imperative.
1689c6efa4Sjeremylt 
1789c6efa4Sjeremylt #include <string.h>
1889c6efa4Sjeremylt #include "ceed-opt.h"
1989c6efa4Sjeremylt 
2089c6efa4Sjeremylt static int CeedDestroy_Opt(Ceed ceed) {
2189c6efa4Sjeremylt   int ierr;
2289c6efa4Sjeremylt   Ceed_Opt *data;
2389c6efa4Sjeremylt   ierr = CeedGetData(ceed, (void *)&data); CeedChk(ierr);
2489c6efa4Sjeremylt   ierr = CeedFree(&data); CeedChk(ierr);
2589c6efa4Sjeremylt 
2689c6efa4Sjeremylt   return 0;
2789c6efa4Sjeremylt }
2889c6efa4Sjeremylt 
2989c6efa4Sjeremylt static int CeedInit_Opt_Blocked(const char *resource, Ceed ceed) {
3089c6efa4Sjeremylt   int ierr;
31*6f7d248dSjeremylt   if (strcmp(resource, "/cpu/self") && strcmp(resource, "/cpu/self/opt")
3289c6efa4Sjeremylt       && strcmp(resource, "/cpu/self/opt/blocked"))
3389c6efa4Sjeremylt     return CeedError(ceed, 1, "Opt backend cannot use resource: %s", resource);
3489c6efa4Sjeremylt 
3589c6efa4Sjeremylt   // Create refrence CEED that implementation will be dispatched
3689c6efa4Sjeremylt   //   through unless overridden
37*6f7d248dSjeremylt   Ceed ceedref;
3889c6efa4Sjeremylt   CeedInit("/cpu/self/ref/serial", &ceedref);
39a4999eddSjeremylt   ierr = CeedSetDelegate(ceed, ceedref); CeedChk(ierr);
4089c6efa4Sjeremylt 
4189c6efa4Sjeremylt   ierr = CeedSetBackendFunction(ceed, "Ceed", ceed, "Destroy",
4289c6efa4Sjeremylt                                 CeedDestroy_Opt); CeedChk(ierr);
4389c6efa4Sjeremylt   ierr = CeedSetBackendFunction(ceed, "Ceed", ceed, "OperatorCreate",
4489c6efa4Sjeremylt                                 CeedOperatorCreate_Opt); CeedChk(ierr);
4589c6efa4Sjeremylt 
4689c6efa4Sjeremylt   // Set blocksize
4789c6efa4Sjeremylt   Ceed_Opt *data;
4889c6efa4Sjeremylt   ierr = CeedCalloc(1, &data); CeedChk(ierr);
4989c6efa4Sjeremylt   data->blksize = 8;
5089c6efa4Sjeremylt   ierr = CeedSetData(ceed, (void *)&data); CeedChk(ierr);
5189c6efa4Sjeremylt 
5289c6efa4Sjeremylt   return 0;
5389c6efa4Sjeremylt }
5489c6efa4Sjeremylt 
5589c6efa4Sjeremylt __attribute__((constructor))
5689c6efa4Sjeremylt static void Register(void) {
5789c6efa4Sjeremylt   CeedRegister("/cpu/self/opt/blocked", CeedInit_Opt_Blocked, 40);
5889c6efa4Sjeremylt }
59