xref: /libCEED/rust/libceed-sys/c-src/backends/xsmm/ceed-xsmm.h (revision 3d8e882215d238700cdceb37404f76ca7fa24eaa)
1*3d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2*3d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
38d713cf6Sjeremylt //
4*3d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
58d713cf6Sjeremylt //
6*3d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
78d713cf6Sjeremylt 
83d576824SJeremy L Thompson #ifndef _ceed_xsmm_h
93d576824SJeremy L Thompson #define _ceed_xsmm_h
103d576824SJeremy L Thompson 
11f190906aSJed Brown #include <ceed/ceed.h>
12f190906aSJed Brown #include <ceed/backend.h>
13f190906aSJed Brown #include <ceed/hash.h>
14f190906aSJed Brown #include <libxsmm.h>
15f190906aSJed Brown 
16f190906aSJed Brown #if !defined(LIBXSMM_VERSION_GE)
17318af0d1SJeremy L Thompson #define LIBXSMM_VERSION_GE(major, minor, update, patch)                           \
18318af0d1SJeremy L Thompson   (LIBXSMM_VERSION_MAJOR > major ||                                               \
19318af0d1SJeremy L Thompson    (LIBXSMM_VERSION_MAJOR == major &&                                             \
20318af0d1SJeremy L Thompson     (LIBXSMM_VERSION_MINOR > minor ||                                             \
21318af0d1SJeremy L Thompson      (LIBXSMM_VERSION_MINOR == minor &&                                           \
22318af0d1SJeremy L Thompson       (LIBXSMM_VERSION_UPDATE > update ||                                         \
23318af0d1SJeremy L Thompson        (LIBXSMM_VERSION_UPDATE == update && LIBXSMM_VERSION_PATCH >= patch ))))))
24f190906aSJed Brown #endif
25318af0d1SJeremy L Thompson 
26318af0d1SJeremy L Thompson #if LIBXSMM_VERSION_GE(1, 17, 0, 0)
27318af0d1SJeremy L Thompson # define LIBXSMM_MMFUNCTION_KERNEL(a, b, c) kernel(a, b, c)
28318af0d1SJeremy L Thompson #else
29318af0d1SJeremy L Thompson # define LIBXSMM_MMFUNCTION_KERNEL(a, b, c) kernel(a, b, c, NULL, NULL, NULL)
30318af0d1SJeremy L Thompson #endif
31318af0d1SJeremy L Thompson 
3220aaa365SJeremy L Thompson // Instantiate khash structs and methods
3380a9ef05SNatalie Beams CeedHashIJKLMInit(f32, libxsmm_smmfunction)
3480a9ef05SNatalie Beams CeedHashIJKLMInit(f64, libxsmm_dmmfunction)
3520aaa365SJeremy L Thompson 
363d0fd664Sjeremylt typedef struct {
37d1d35e2fSjeremylt   bool is_tensor;
3820aaa365SJeremy L Thompson   CeedInt P, Q, dim;
3980a9ef05SNatalie Beams   khash_t(f32) *lookup_f32;
4080a9ef05SNatalie Beams   khash_t(f64) *lookup_f64;
413d0fd664Sjeremylt } CeedTensorContract_Xsmm;
423d0fd664Sjeremylt 
4380a9ef05SNatalie Beams CEED_INTERN int CeedTensorContractCreate_f32_Xsmm(CeedBasis basis,
4480a9ef05SNatalie Beams     CeedTensorContract contract);
4580a9ef05SNatalie Beams 
4680a9ef05SNatalie Beams CEED_INTERN int CeedTensorContractCreate_f64_Xsmm(CeedBasis basis,
47c71e1dcdSjeremylt     CeedTensorContract contract);
483d576824SJeremy L Thompson 
493d576824SJeremy L Thompson #endif // _ceed_xsmm_h
50