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 173d576824SJeremy L Thompson #include <ceed.h> 183d576824SJeremy L Thompson #include <ceed-backend.h> 193d576824SJeremy 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; 29*e15f9bd0SJeremy L Thompson ierr = CeedGetData(ceed, &data); CeedChkBackend(ierr); 30*e15f9bd0SJeremy L Thompson ierr = CeedFree(&data); CeedChkBackend(ierr); 3189c6efa4Sjeremylt 32*e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 3389c6efa4Sjeremylt } 3489c6efa4Sjeremylt 35f10650afSjeremylt //------------------------------------------------------------------------------ 36f10650afSjeremylt // Backend Init 37f10650afSjeremylt //------------------------------------------------------------------------------ 3889c6efa4Sjeremylt static int CeedInit_Opt_Blocked(const char *resource, Ceed ceed) { 3989c6efa4Sjeremylt int ierr; 406f7d248dSjeremylt if (strcmp(resource, "/cpu/self") && strcmp(resource, "/cpu/self/opt") 4189c6efa4Sjeremylt && strcmp(resource, "/cpu/self/opt/blocked")) 42c042f62fSJeremy L Thompson // LCOV_EXCL_START 43*e15f9bd0SJeremy L Thompson return CeedError(ceed, CEED_ERROR_BACKEND, 44*e15f9bd0SJeremy L Thompson "Opt backend cannot use resource: %s", resource); 45c042f62fSJeremy L Thompson // LCOV_EXCL_STOP 46*e15f9bd0SJeremy L Thompson ierr = CeedSetDeterministic(ceed, true); CeedChkBackend(ierr); 4789c6efa4Sjeremylt 485f67fadeSJeremy L Thompson // Create reference CEED that implementation will be dispatched 4989c6efa4Sjeremylt // through unless overridden 506f7d248dSjeremylt Ceed ceedref; 5189c6efa4Sjeremylt CeedInit("/cpu/self/ref/serial", &ceedref); 52*e15f9bd0SJeremy L Thompson ierr = CeedSetDelegate(ceed, ceedref); CeedChkBackend(ierr); 5389c6efa4Sjeremylt 5489c6efa4Sjeremylt ierr = CeedSetBackendFunction(ceed, "Ceed", ceed, "Destroy", 55*e15f9bd0SJeremy L Thompson CeedDestroy_Opt); CeedChkBackend(ierr); 5689c6efa4Sjeremylt ierr = CeedSetBackendFunction(ceed, "Ceed", ceed, "OperatorCreate", 57*e15f9bd0SJeremy L Thompson CeedOperatorCreate_Opt); CeedChkBackend(ierr); 5889c6efa4Sjeremylt 5989c6efa4Sjeremylt // Set blocksize 6089c6efa4Sjeremylt Ceed_Opt *data; 61*e15f9bd0SJeremy L Thompson ierr = CeedCalloc(1, &data); CeedChkBackend(ierr); 6289c6efa4Sjeremylt data->blksize = 8; 63*e15f9bd0SJeremy L Thompson ierr = CeedSetData(ceed, data); CeedChkBackend(ierr); 6489c6efa4Sjeremylt 65*e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 6689c6efa4Sjeremylt } 6789c6efa4Sjeremylt 68f10650afSjeremylt //------------------------------------------------------------------------------ 69f10650afSjeremylt // Backend Register 70f10650afSjeremylt //------------------------------------------------------------------------------ 711d013790SJed Brown CEED_INTERN int CeedRegister_Opt_Blocked(void) { 721d013790SJed Brown return CeedRegister("/cpu/self/opt/blocked", CeedInit_Opt_Blocked, 40); 7389c6efa4Sjeremylt } 74f10650afSjeremylt //------------------------------------------------------------------------------ 75