xref: /libCEED/rust/libceed-sys/c-src/backends/xsmm/ceed-xsmm.h (revision f190906abec33cf8d9eb9776bd62dd828c8ae3fd)
1 // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
2 // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
3 // All Rights reserved. See files LICENSE and NOTICE for details.
4 //
5 // This file is part of CEED, a collection of benchmarks, miniapps, software
6 // libraries and APIs for efficient high-order finite element and spectral
7 // element discretizations for exascale applications. For more information and
8 // source code availability see http://github.com/ceed.
9 //
10 // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11 // a collaborative effort of two U.S. Department of Energy organizations (Office
12 // of Science and the National Nuclear Security Administration) responsible for
13 // the planning and preparation of a capable exascale ecosystem, including
14 // software, applications, hardware, advanced system engineering and early
15 // testbed platforms, in support of the nation's exascale computing imperative.
16 
17 #ifndef _ceed_xsmm_h
18 #define _ceed_xsmm_h
19 
20 #include <ceed/ceed.h>
21 #include <ceed/backend.h>
22 #include <ceed/hash.h>
23 #include <libxsmm.h>
24 
25 #if !defined(LIBXSMM_VERSION_GE)
26 #define LIBXSMM_VERSION_GE(major, minor, update, patch)                           \
27   (LIBXSMM_VERSION_MAJOR > major ||                                               \
28    (LIBXSMM_VERSION_MAJOR == major &&                                             \
29     (LIBXSMM_VERSION_MINOR > minor ||                                             \
30      (LIBXSMM_VERSION_MINOR == minor &&                                           \
31       (LIBXSMM_VERSION_UPDATE > update ||                                         \
32        (LIBXSMM_VERSION_UPDATE == update && LIBXSMM_VERSION_PATCH >= patch ))))))
33 #endif
34 
35 #if LIBXSMM_VERSION_GE(1, 17, 0, 0)
36 # define LIBXSMM_MMFUNCTION_KERNEL(a, b, c) kernel(a, b, c)
37 #else
38 # define LIBXSMM_MMFUNCTION_KERNEL(a, b, c) kernel(a, b, c, NULL, NULL, NULL)
39 #endif
40 
41 // Instantiate khash structs and methods
42 CeedHashIJKLMInit(f32, libxsmm_smmfunction)
43 CeedHashIJKLMInit(f64, libxsmm_dmmfunction)
44 
45 typedef struct {
46   bool is_tensor;
47   CeedInt P, Q, dim;
48   khash_t(f32) *lookup_f32;
49   khash_t(f64) *lookup_f64;
50 } CeedTensorContract_Xsmm;
51 
52 CEED_INTERN int CeedTensorContractCreate_f32_Xsmm(CeedBasis basis,
53     CeedTensorContract contract);
54 
55 CEED_INTERN int CeedTensorContractCreate_f64_Xsmm(CeedBasis basis,
56     CeedTensorContract contract);
57 
58 #endif // _ceed_xsmm_h
59