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. 38d713cf6Sjeremylt // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 58d713cf6Sjeremylt // 63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 78d713cf6Sjeremylt 849aac155SJeremy L Thompson #include <ceed.h> 9ec3da8bcSJed Brown #include <ceed/backend.h> 103d576824SJeremy L Thompson #include <stdbool.h> 113d576824SJeremy L Thompson #include <string.h> 122b730f8bSJeremy L Thompson 138d713cf6Sjeremylt #include "ceed-xsmm.h" 148d713cf6Sjeremylt 15f10650afSjeremylt //------------------------------------------------------------------------------ 16f10650afSjeremylt // Backend Init 17f10650afSjeremylt //------------------------------------------------------------------------------ 188d713cf6Sjeremylt static int CeedInit_Xsmm_Serial(const char *resource, Ceed ceed) { 196574a04fSJeremy L Thompson CeedCheck(!strcmp(resource, "/cpu/self") || !strcmp(resource, "/cpu/self/xsmm/serial"), ceed, CEED_ERROR_BACKEND, 206574a04fSJeremy L Thompson "serial libXSMM backend cannot use resource: %s", resource); 212b730f8bSJeremy L Thompson CeedCallBackend(CeedSetDeterministic(ceed, true)); 228d713cf6Sjeremylt 23ea61e9acSJeremy L Thompson // Create reference Ceed that implementation will be dispatched through unless overridden 24d1d35e2fSjeremylt Ceed ceed_ref; 252b730f8bSJeremy L Thompson CeedCallBackend(CeedInit("/cpu/self/opt/serial", &ceed_ref)); 262b730f8bSJeremy L Thompson CeedCallBackend(CeedSetDelegate(ceed, ceed_ref)); 278d713cf6Sjeremylt 28*4548da4eSSebastian Grimberg CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "TensorContractCreate", CeedTensorContractCreate_Xsmm)); 298d713cf6Sjeremylt 30e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 318d713cf6Sjeremylt } 328d713cf6Sjeremylt 33f10650afSjeremylt //------------------------------------------------------------------------------ 34f10650afSjeremylt // Backend Register 35f10650afSjeremylt //------------------------------------------------------------------------------ 362b730f8bSJeremy L Thompson CEED_INTERN int CeedRegister_Xsmm_Serial(void) { return CeedRegister("/cpu/self/xsmm/serial", CeedInit_Xsmm_Serial, 25); } 372a86cc9dSSebastian Grimberg 38f10650afSjeremylt //------------------------------------------------------------------------------ 39