xref: /libCEED/rust/libceed-sys/c-src/backends/xsmm/ceed-xsmm.h (revision f190906abec33cf8d9eb9776bd62dd828c8ae3fd)
18d713cf6Sjeremylt // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
28d713cf6Sjeremylt // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
38d713cf6Sjeremylt // All Rights reserved. See files LICENSE and NOTICE for details.
48d713cf6Sjeremylt //
58d713cf6Sjeremylt // This file is part of CEED, a collection of benchmarks, miniapps, software
68d713cf6Sjeremylt // libraries and APIs for efficient high-order finite element and spectral
78d713cf6Sjeremylt // element discretizations for exascale applications. For more information and
88d713cf6Sjeremylt // source code availability see http://github.com/ceed.
98d713cf6Sjeremylt //
108d713cf6Sjeremylt // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
118d713cf6Sjeremylt // a collaborative effort of two U.S. Department of Energy organizations (Office
128d713cf6Sjeremylt // of Science and the National Nuclear Security Administration) responsible for
138d713cf6Sjeremylt // the planning and preparation of a capable exascale ecosystem, including
148d713cf6Sjeremylt // software, applications, hardware, advanced system engineering and early
158d713cf6Sjeremylt // testbed platforms, in support of the nation's exascale computing imperative.
168d713cf6Sjeremylt 
173d576824SJeremy L Thompson #ifndef _ceed_xsmm_h
183d576824SJeremy L Thompson #define _ceed_xsmm_h
193d576824SJeremy L Thompson 
20*f190906aSJed Brown #include <ceed/ceed.h>
21*f190906aSJed Brown #include <ceed/backend.h>
22*f190906aSJed Brown #include <ceed/hash.h>
23*f190906aSJed Brown #include <libxsmm.h>
24*f190906aSJed Brown 
25*f190906aSJed Brown #if !defined(LIBXSMM_VERSION_GE)
26318af0d1SJeremy L Thompson #define LIBXSMM_VERSION_GE(major, minor, update, patch)                           \
27318af0d1SJeremy L Thompson   (LIBXSMM_VERSION_MAJOR > major ||                                               \
28318af0d1SJeremy L Thompson    (LIBXSMM_VERSION_MAJOR == major &&                                             \
29318af0d1SJeremy L Thompson     (LIBXSMM_VERSION_MINOR > minor ||                                             \
30318af0d1SJeremy L Thompson      (LIBXSMM_VERSION_MINOR == minor &&                                           \
31318af0d1SJeremy L Thompson       (LIBXSMM_VERSION_UPDATE > update ||                                         \
32318af0d1SJeremy L Thompson        (LIBXSMM_VERSION_UPDATE == update && LIBXSMM_VERSION_PATCH >= patch ))))))
33*f190906aSJed Brown #endif
34318af0d1SJeremy L Thompson 
35318af0d1SJeremy L Thompson #if LIBXSMM_VERSION_GE(1, 17, 0, 0)
36318af0d1SJeremy L Thompson # define LIBXSMM_MMFUNCTION_KERNEL(a, b, c) kernel(a, b, c)
37318af0d1SJeremy L Thompson #else
38318af0d1SJeremy L Thompson # define LIBXSMM_MMFUNCTION_KERNEL(a, b, c) kernel(a, b, c, NULL, NULL, NULL)
39318af0d1SJeremy L Thompson #endif
40318af0d1SJeremy L Thompson 
4120aaa365SJeremy L Thompson // Instantiate khash structs and methods
4280a9ef05SNatalie Beams CeedHashIJKLMInit(f32, libxsmm_smmfunction)
4380a9ef05SNatalie Beams CeedHashIJKLMInit(f64, libxsmm_dmmfunction)
4420aaa365SJeremy L Thompson 
453d0fd664Sjeremylt typedef struct {
46d1d35e2fSjeremylt   bool is_tensor;
4720aaa365SJeremy L Thompson   CeedInt P, Q, dim;
4880a9ef05SNatalie Beams   khash_t(f32) *lookup_f32;
4980a9ef05SNatalie Beams   khash_t(f64) *lookup_f64;
503d0fd664Sjeremylt } CeedTensorContract_Xsmm;
513d0fd664Sjeremylt 
5280a9ef05SNatalie Beams CEED_INTERN int CeedTensorContractCreate_f32_Xsmm(CeedBasis basis,
5380a9ef05SNatalie Beams     CeedTensorContract contract);
5480a9ef05SNatalie Beams 
5580a9ef05SNatalie Beams CEED_INTERN int CeedTensorContractCreate_f64_Xsmm(CeedBasis basis,
56c71e1dcdSjeremylt     CeedTensorContract contract);
573d576824SJeremy L Thompson 
583d576824SJeremy L Thompson #endif // _ceed_xsmm_h
59