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 17*3d576824SJeremy L Thompson #include <ceed.h> 18*3d576824SJeremy L Thompson #include <ceed-backend.h> 19*3d576824SJeremy L Thompson #include <stdbool.h> 2089c6efa4Sjeremylt #include <string.h> 2189c6efa4Sjeremylt #include "ceed-opt.h" 2289c6efa4Sjeremylt 23f10650afSjeremylt //------------------------------------------------------------------------------ 24f10650afSjeremylt // Backend Destroy 25f10650afSjeremylt //------------------------------------------------------------------------------ 2689c6efa4Sjeremylt static int CeedDestroy_Opt(Ceed ceed) { 2789c6efa4Sjeremylt int ierr; 2889c6efa4Sjeremylt Ceed_Opt *data; 29777ff853SJeremy L Thompson ierr = CeedGetData(ceed, &data); CeedChk(ierr); 3089c6efa4Sjeremylt ierr = CeedFree(&data); CeedChk(ierr); 3189c6efa4Sjeremylt 3289c6efa4Sjeremylt return 0; 3389c6efa4Sjeremylt } 3489c6efa4Sjeremylt 35f10650afSjeremylt //------------------------------------------------------------------------------ 36f10650afSjeremylt // Backend Init 37f10650afSjeremylt //------------------------------------------------------------------------------ 3889c6efa4Sjeremylt static int CeedInit_Opt_Serial(const char *resource, Ceed ceed) { 3989c6efa4Sjeremylt int ierr; 4089c6efa4Sjeremylt if (strcmp(resource, "/cpu/self") 4189c6efa4Sjeremylt && strcmp(resource, "/cpu/self/opt/serial")) 42c042f62fSJeremy L Thompson // LCOV_EXCL_START 4389c6efa4Sjeremylt return CeedError(ceed, 1, "Opt backend cannot use resource: %s", resource); 44c042f62fSJeremy L Thompson // LCOV_EXCL_STOP 459525855cSJeremy L Thompson ierr = CeedSetDeterministic(ceed, true); CeedChk(ierr); 4689c6efa4Sjeremylt 475f67fadeSJeremy L Thompson // Create reference CEED that implementation will be dispatched 4889c6efa4Sjeremylt // through unless overridden 496f7d248dSjeremylt Ceed ceedref; 5089c6efa4Sjeremylt CeedInit("/cpu/self/ref/serial", &ceedref); 51a4999eddSjeremylt ierr = CeedSetDelegate(ceed, ceedref); CeedChk(ierr); 5289c6efa4Sjeremylt 5389c6efa4Sjeremylt ierr = CeedSetBackendFunction(ceed, "Ceed", ceed, "Destroy", 5489c6efa4Sjeremylt CeedDestroy_Opt); CeedChk(ierr); 5589c6efa4Sjeremylt ierr = CeedSetBackendFunction(ceed, "Ceed", ceed, "OperatorCreate", 5689c6efa4Sjeremylt CeedOperatorCreate_Opt); CeedChk(ierr); 5789c6efa4Sjeremylt 5889c6efa4Sjeremylt // Set blocksize 5989c6efa4Sjeremylt Ceed_Opt *data; 6089c6efa4Sjeremylt ierr = CeedCalloc(1, &data); CeedChk(ierr); 6189c6efa4Sjeremylt data->blksize = 1; 62777ff853SJeremy L Thompson ierr = CeedSetData(ceed, data); CeedChk(ierr); 6389c6efa4Sjeremylt 6489c6efa4Sjeremylt return 0; 6589c6efa4Sjeremylt } 6689c6efa4Sjeremylt 67f10650afSjeremylt //------------------------------------------------------------------------------ 68f10650afSjeremylt // Backend Register 69f10650afSjeremylt //------------------------------------------------------------------------------ 701d013790SJed Brown CEED_INTERN int CeedRegister_Opt_Serial(void) { 711d013790SJed Brown return CeedRegister("/cpu/self/opt/serial", CeedInit_Opt_Serial, 45); 7289c6efa4Sjeremylt } 731d013790SJed Brown 74f10650afSjeremylt //------------------------------------------------------------------------------ 75