1*89c6efa4Sjeremylt // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC. 2*89c6efa4Sjeremylt // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. 3*89c6efa4Sjeremylt // All Rights reserved. See files LICENSE and NOTICE for details. 4*89c6efa4Sjeremylt // 5*89c6efa4Sjeremylt // This file is part of CEED, a collection of benchmarks, miniapps, software 6*89c6efa4Sjeremylt // libraries and APIs for efficient high-order finite element and spectral 7*89c6efa4Sjeremylt // element discretizations for exascale applications. For more information and 8*89c6efa4Sjeremylt // source code availability see http://github.com/ceed. 9*89c6efa4Sjeremylt // 10*89c6efa4Sjeremylt // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11*89c6efa4Sjeremylt // a collaborative effort of two U.S. Department of Energy organizations (Office 12*89c6efa4Sjeremylt // of Science and the National Nuclear Security Administration) responsible for 13*89c6efa4Sjeremylt // the planning and preparation of a capable exascale ecosystem, including 14*89c6efa4Sjeremylt // software, applications, hardware, advanced system engineering and early 15*89c6efa4Sjeremylt // testbed platforms, in support of the nation's exascale computing imperative. 16*89c6efa4Sjeremylt 17*89c6efa4Sjeremylt #include <string.h> 18*89c6efa4Sjeremylt #include "ceed-opt.h" 19*89c6efa4Sjeremylt 20*89c6efa4Sjeremylt static int CeedDestroy_Opt(Ceed ceed) { 21*89c6efa4Sjeremylt int ierr; 22*89c6efa4Sjeremylt Ceed_Opt *data; 23*89c6efa4Sjeremylt ierr = CeedGetData(ceed, (void *)&data); CeedChk(ierr); 24*89c6efa4Sjeremylt ierr = CeedFree(&data); CeedChk(ierr); 25*89c6efa4Sjeremylt 26*89c6efa4Sjeremylt return 0; 27*89c6efa4Sjeremylt } 28*89c6efa4Sjeremylt 29*89c6efa4Sjeremylt static int CeedInit_Opt_Serial(const char *resource, Ceed ceed) { 30*89c6efa4Sjeremylt int ierr; 31*89c6efa4Sjeremylt if (strcmp(resource, "/cpu/self") 32*89c6efa4Sjeremylt && strcmp(resource, "/cpu/self/opt/serial")) 33*89c6efa4Sjeremylt return CeedError(ceed, 1, "Opt backend cannot use resource: %s", resource); 34*89c6efa4Sjeremylt 35*89c6efa4Sjeremylt Ceed ceedref; 36*89c6efa4Sjeremylt 37*89c6efa4Sjeremylt // Create refrence CEED that implementation will be dispatched 38*89c6efa4Sjeremylt // through unless overridden 39*89c6efa4Sjeremylt CeedInit("/cpu/self/ref/serial", &ceedref); 40*89c6efa4Sjeremylt ierr = CeedSetDelegate(ceed, &ceedref); CeedChk(ierr); 41*89c6efa4Sjeremylt 42*89c6efa4Sjeremylt ierr = CeedSetBackendFunction(ceed, "Ceed", ceed, "Destroy", 43*89c6efa4Sjeremylt CeedDestroy_Opt); CeedChk(ierr); 44*89c6efa4Sjeremylt ierr = CeedSetBackendFunction(ceed, "Ceed", ceed, "OperatorCreate", 45*89c6efa4Sjeremylt CeedOperatorCreate_Opt); CeedChk(ierr); 46*89c6efa4Sjeremylt 47*89c6efa4Sjeremylt // Set blocksize 48*89c6efa4Sjeremylt Ceed_Opt *data; 49*89c6efa4Sjeremylt ierr = CeedCalloc(1, &data); CeedChk(ierr); 50*89c6efa4Sjeremylt data->blksize = 1; 51*89c6efa4Sjeremylt ierr = CeedSetData(ceed, (void *)&data); CeedChk(ierr); 52*89c6efa4Sjeremylt 53*89c6efa4Sjeremylt return 0; 54*89c6efa4Sjeremylt } 55*89c6efa4Sjeremylt 56*89c6efa4Sjeremylt __attribute__((constructor)) 57*89c6efa4Sjeremylt static void Register(void) { 58*89c6efa4Sjeremylt CeedRegister("/cpu/self/opt/serial", CeedInit_Opt_Serial, 45); 59*89c6efa4Sjeremylt } 60