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