1 // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3 // 4 // SPDX-License-Identifier: BSD-2-Clause 5 // 6 // This file is part of CEED: http://github.com/ceed 7 8 #include <ceed/backend.h> 9 #include <ceed/ceed.h> 10 #include <stdbool.h> 11 #include <string.h> 12 13 #include "ceed-xsmm.h" 14 15 //------------------------------------------------------------------------------ 16 // Backend Init 17 //------------------------------------------------------------------------------ 18 static int CeedInit_Xsmm_Serial(const char *resource, Ceed ceed) { 19 if (strcmp(resource, "/cpu/self") && strcmp(resource, "/cpu/self/xsmm/serial")) { 20 // LCOV_EXCL_START 21 return CeedError(ceed, CEED_ERROR_BACKEND, "serial libXSMM backend cannot use resource: %s", resource); 22 // LCOV_EXCL_STOP 23 } 24 CeedCallBackend(CeedSetDeterministic(ceed, true)); 25 26 // Create reference CEED that implementation will be dispatched 27 // through unless overridden 28 Ceed ceed_ref; 29 CeedCallBackend(CeedInit("/cpu/self/opt/serial", &ceed_ref)); 30 CeedCallBackend(CeedSetDelegate(ceed, ceed_ref)); 31 32 if (CEED_SCALAR_TYPE == CEED_SCALAR_FP64) { 33 CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "TensorContractCreate", CeedTensorContractCreate_f64_Xsmm)); 34 } else { 35 CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "TensorContractCreate", CeedTensorContractCreate_f32_Xsmm)); 36 } 37 38 return CEED_ERROR_SUCCESS; 39 } 40 41 //------------------------------------------------------------------------------ 42 // Backend Register 43 //------------------------------------------------------------------------------ 44 CEED_INTERN int CeedRegister_Xsmm_Serial(void) { return CeedRegister("/cpu/self/xsmm/serial", CeedInit_Xsmm_Serial, 25); } 45 //------------------------------------------------------------------------------ 46