xref: /libCEED/rust/libceed-sys/c-src/backends/xsmm/ceed-xsmm-serial.c (revision d4cc18453651bd0f94c1a2e078b2646a92dafdcc)
1 // Copyright (c) 2017-2026, 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.h>
9 #include <ceed/backend.h>
10 #include <stdbool.h>
11 #include <string.h>
12 
13 #include "ceed-xsmm.h"
14 
15 //------------------------------------------------------------------------------
16 // Backend Init
17 //------------------------------------------------------------------------------
CeedInit_Xsmm_Serial(const char * resource,Ceed ceed)18 static int CeedInit_Xsmm_Serial(const char *resource, Ceed ceed) {
19   Ceed ceed_ref;
20 
21   CeedCheck(!strcmp(resource, "/cpu/self") || !strcmp(resource, "/cpu/self/xsmm/serial"), ceed, CEED_ERROR_BACKEND,
22             "serial libXSMM backend cannot use resource: %s", resource);
23   CeedCallBackend(CeedSetDeterministic(ceed, true));
24 
25   // Create reference Ceed that implementation will be dispatched through unless overridden
26   CeedCallBackend(CeedInit("/cpu/self/opt/serial", &ceed_ref));
27   CeedCallBackend(CeedSetDelegate(ceed, ceed_ref));
28   CeedCallBackend(CeedDestroy(&ceed_ref));
29 
30   CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "TensorContractCreate", CeedTensorContractCreate_Xsmm));
31   return CEED_ERROR_SUCCESS;
32 }
33 
34 //------------------------------------------------------------------------------
35 // Backend Register
36 //------------------------------------------------------------------------------
CeedRegister_Xsmm_Serial(void)37 CEED_INTERN int CeedRegister_Xsmm_Serial(void) { return CeedRegister("/cpu/self/xsmm/serial", CeedInit_Xsmm_Serial, 25); }
38 
39 //------------------------------------------------------------------------------
40