xref: /libCEED/rust/libceed-sys/c-src/backends/xsmm/ceed-xsmm.h (revision 3d8e882215d238700cdceb37404f76ca7fa24eaa)
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 #ifndef _ceed_xsmm_h
9 #define _ceed_xsmm_h
10 
11 #include <ceed/ceed.h>
12 #include <ceed/backend.h>
13 #include <ceed/hash.h>
14 #include <libxsmm.h>
15 
16 #if !defined(LIBXSMM_VERSION_GE)
17 #define LIBXSMM_VERSION_GE(major, minor, update, patch)                           \
18   (LIBXSMM_VERSION_MAJOR > major ||                                               \
19    (LIBXSMM_VERSION_MAJOR == major &&                                             \
20     (LIBXSMM_VERSION_MINOR > minor ||                                             \
21      (LIBXSMM_VERSION_MINOR == minor &&                                           \
22       (LIBXSMM_VERSION_UPDATE > update ||                                         \
23        (LIBXSMM_VERSION_UPDATE == update && LIBXSMM_VERSION_PATCH >= patch ))))))
24 #endif
25 
26 #if LIBXSMM_VERSION_GE(1, 17, 0, 0)
27 # define LIBXSMM_MMFUNCTION_KERNEL(a, b, c) kernel(a, b, c)
28 #else
29 # define LIBXSMM_MMFUNCTION_KERNEL(a, b, c) kernel(a, b, c, NULL, NULL, NULL)
30 #endif
31 
32 // Instantiate khash structs and methods
33 CeedHashIJKLMInit(f32, libxsmm_smmfunction)
34 CeedHashIJKLMInit(f64, libxsmm_dmmfunction)
35 
36 typedef struct {
37   bool is_tensor;
38   CeedInt P, Q, dim;
39   khash_t(f32) *lookup_f32;
40   khash_t(f64) *lookup_f64;
41 } CeedTensorContract_Xsmm;
42 
43 CEED_INTERN int CeedTensorContractCreate_f32_Xsmm(CeedBasis basis,
44     CeedTensorContract contract);
45 
46 CEED_INTERN int CeedTensorContractCreate_f64_Xsmm(CeedBasis basis,
47     CeedTensorContract contract);
48 
49 #endif // _ceed_xsmm_h
50