13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 34a2e7687Sjeremylt // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 54a2e7687Sjeremylt // 63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 74a2e7687Sjeremylt 8*2b730f8bSJeremy L Thompson #include "ceed-blocked.h" 9*2b730f8bSJeremy L Thompson 10ec3da8bcSJed Brown #include <ceed/backend.h> 11*2b730f8bSJeremy L Thompson #include <ceed/ceed.h> 123d576824SJeremy L Thompson #include <stdbool.h> 133d576824SJeremy L Thompson #include <string.h> 144a2e7687Sjeremylt 15f10650afSjeremylt //------------------------------------------------------------------------------ 16f10650afSjeremylt // Backend Init 17f10650afSjeremylt //------------------------------------------------------------------------------ 181d013790SJed Brown CEED_INTERN int CeedInit_Blocked(const char *resource, Ceed ceed) { 19*2b730f8bSJeremy L Thompson if (strcmp(resource, "/cpu/self") && strcmp(resource, "/cpu/self/ref/blocked")) { 20c042f62fSJeremy L Thompson // LCOV_EXCL_START 21*2b730f8bSJeremy L Thompson return CeedError(ceed, CEED_ERROR_BACKEND, "Blocked backend cannot use resource: %s", resource); 22c042f62fSJeremy L Thompson // LCOV_EXCL_STOP 23*2b730f8bSJeremy L Thompson } 24*2b730f8bSJeremy L Thompson CeedCallBackend(CeedSetDeterministic(ceed, true)); 254a2e7687Sjeremylt 265f67fadeSJeremy L Thompson // Create reference CEED that implementation will be dispatched 274a2e7687Sjeremylt // through unless overridden 28d1d35e2fSjeremylt Ceed ceed_ref; 29*2b730f8bSJeremy L Thompson CeedCallBackend(CeedInit("/cpu/self/ref/serial", &ceed_ref)); 30*2b730f8bSJeremy L Thompson CeedCallBackend(CeedSetDelegate(ceed, ceed_ref)); 314a2e7687Sjeremylt 32e2f04181SAndrew T. Barker // Set fallback CEED resource for advanced operator functionality 33e2f04181SAndrew T. Barker const char fallbackresource[] = "/cpu/self/ref/serial"; 34*2b730f8bSJeremy L Thompson CeedCallBackend(CeedSetOperatorFallbackResource(ceed, fallbackresource)); 35e2f04181SAndrew T. Barker 36*2b730f8bSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "OperatorCreate", CeedOperatorCreate_Blocked)); 374a2e7687Sjeremylt 38e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 394a2e7687Sjeremylt } 404a2e7687Sjeremylt 41f10650afSjeremylt //------------------------------------------------------------------------------ 42f10650afSjeremylt // Backend Register 43f10650afSjeremylt //------------------------------------------------------------------------------ 44*2b730f8bSJeremy L Thompson CEED_INTERN int CeedRegister_Ref_Blocked(void) { return CeedRegister("/cpu/self/ref/blocked", CeedInit_Blocked, 55); } 45f10650afSjeremylt //------------------------------------------------------------------------------ 46