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 20f10650afSjeremylt //------------------------------------------------------------------------------ 21f10650afSjeremylt // Backend Destroy 22f10650afSjeremylt //------------------------------------------------------------------------------ 2389c6efa4Sjeremylt static int CeedDestroy_Opt(Ceed ceed) { 2489c6efa4Sjeremylt int ierr; 2589c6efa4Sjeremylt Ceed_Opt *data; 2689c6efa4Sjeremylt ierr = CeedGetData(ceed, (void *)&data); CeedChk(ierr); 2789c6efa4Sjeremylt ierr = CeedFree(&data); CeedChk(ierr); 2889c6efa4Sjeremylt 2989c6efa4Sjeremylt return 0; 3089c6efa4Sjeremylt } 3189c6efa4Sjeremylt 32f10650afSjeremylt //------------------------------------------------------------------------------ 33f10650afSjeremylt // Backend Init 34f10650afSjeremylt //------------------------------------------------------------------------------ 3589c6efa4Sjeremylt static int CeedInit_Opt_Serial(const char *resource, Ceed ceed) { 3689c6efa4Sjeremylt int ierr; 3789c6efa4Sjeremylt if (strcmp(resource, "/cpu/self") 3889c6efa4Sjeremylt && strcmp(resource, "/cpu/self/opt/serial")) 39c042f62fSJeremy L Thompson // LCOV_EXCL_START 4089c6efa4Sjeremylt return CeedError(ceed, 1, "Opt backend cannot use resource: %s", resource); 41c042f62fSJeremy L Thompson // LCOV_EXCL_STOP 429525855cSJeremy L Thompson ierr = CeedSetDeterministic(ceed, true); CeedChk(ierr); 4389c6efa4Sjeremylt 44*5f67fadeSJeremy L Thompson // Create reference CEED that implementation will be dispatched 4589c6efa4Sjeremylt // through unless overridden 466f7d248dSjeremylt Ceed ceedref; 4789c6efa4Sjeremylt CeedInit("/cpu/self/ref/serial", &ceedref); 48a4999eddSjeremylt ierr = CeedSetDelegate(ceed, ceedref); CeedChk(ierr); 4989c6efa4Sjeremylt 5089c6efa4Sjeremylt ierr = CeedSetBackendFunction(ceed, "Ceed", ceed, "Destroy", 5189c6efa4Sjeremylt CeedDestroy_Opt); CeedChk(ierr); 5289c6efa4Sjeremylt ierr = CeedSetBackendFunction(ceed, "Ceed", ceed, "OperatorCreate", 5389c6efa4Sjeremylt CeedOperatorCreate_Opt); CeedChk(ierr); 5489c6efa4Sjeremylt 5589c6efa4Sjeremylt // Set blocksize 5689c6efa4Sjeremylt Ceed_Opt *data; 5789c6efa4Sjeremylt ierr = CeedCalloc(1, &data); CeedChk(ierr); 5889c6efa4Sjeremylt data->blksize = 1; 5989c6efa4Sjeremylt ierr = CeedSetData(ceed, (void *)&data); CeedChk(ierr); 6089c6efa4Sjeremylt 6189c6efa4Sjeremylt return 0; 6289c6efa4Sjeremylt } 6389c6efa4Sjeremylt 64f10650afSjeremylt //------------------------------------------------------------------------------ 65f10650afSjeremylt // Backend Register 66f10650afSjeremylt //------------------------------------------------------------------------------ 6789c6efa4Sjeremylt __attribute__((constructor)) 6889c6efa4Sjeremylt static void Register(void) { 6989c6efa4Sjeremylt CeedRegister("/cpu/self/opt/serial", CeedInit_Opt_Serial, 45); 7089c6efa4Sjeremylt } 71f10650afSjeremylt //------------------------------------------------------------------------------ 72