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