13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 38d713cf6Sjeremylt // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 58d713cf6Sjeremylt // 63d8e8822SJeremy 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 11*49aac155SJeremy L Thompson #include <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 && \ 202b730f8bSJeremy L Thompson (LIBXSMM_VERSION_MINOR > minor || (LIBXSMM_VERSION_MINOR == minor && \ 212b730f8bSJeremy L Thompson (LIBXSMM_VERSION_UPDATE > update || (LIBXSMM_VERSION_UPDATE == update && LIBXSMM_VERSION_PATCH >= patch)))))) 22f190906aSJed Brown #endif 23318af0d1SJeremy L Thompson 24318af0d1SJeremy L Thompson #if LIBXSMM_VERSION_GE(1, 17, 0, 0) 25318af0d1SJeremy L Thompson #define LIBXSMM_MMFUNCTION_KERNEL(a, b, c) kernel(a, b, c) 26318af0d1SJeremy L Thompson #else 27318af0d1SJeremy L Thompson #define LIBXSMM_MMFUNCTION_KERNEL(a, b, c) kernel(a, b, c, NULL, NULL, NULL) 28318af0d1SJeremy L Thompson #endif 29318af0d1SJeremy L Thompson 3020aaa365SJeremy L Thompson // Instantiate khash structs and methods 312b730f8bSJeremy L Thompson CeedHashIJKLMInit(f32, libxsmm_smmfunction) CeedHashIJKLMInit(f64, libxsmm_dmmfunction) 3220aaa365SJeremy L Thompson 333d0fd664Sjeremylt typedef struct { 34d1d35e2fSjeremylt bool is_tensor; 3520aaa365SJeremy L Thompson CeedInt P, Q, dim; 3680a9ef05SNatalie Beams khash_t(f32) * lookup_f32; 3780a9ef05SNatalie Beams khash_t(f64) * lookup_f64; 383d0fd664Sjeremylt } CeedTensorContract_Xsmm; 393d0fd664Sjeremylt 402b730f8bSJeremy L Thompson CEED_INTERN int CeedTensorContractCreate_f32_Xsmm(CeedBasis basis, CeedTensorContract contract); 4180a9ef05SNatalie Beams 422b730f8bSJeremy L Thompson CEED_INTERN int CeedTensorContractCreate_f64_Xsmm(CeedBasis basis, CeedTensorContract contract); 433d576824SJeremy L Thompson 443d576824SJeremy L Thompson #endif // _ceed_xsmm_h 45