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. 3ec3da8bcSJed Brown // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 5ec3da8bcSJed Brown // 63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 7ec3da8bcSJed Brown 8ec3da8bcSJed Brown /// @file 9ec3da8bcSJed Brown /// Public header for backend components of libCEED 10ec3da8bcSJed Brown #ifndef _ceed_backend_h 11ec3da8bcSJed Brown #define _ceed_backend_h 12ec3da8bcSJed Brown 1349aac155SJeremy L Thompson #include <ceed.h> 14d0c91ce9Sjeremylt #include <limits.h> 15ec3da8bcSJed Brown #include <stdbool.h> 16ec3da8bcSJed Brown 172b730f8bSJeremy L Thompson #if defined(__clang_analyzer__) 182b730f8bSJeremy L Thompson #define CEED_INTERN 192b730f8bSJeremy L Thompson #elif defined(__cplusplus) 203b271f31SJed Brown #define CEED_INTERN extern "C" CEED_VISIBILITY(hidden) 213b271f31SJed Brown #else 223b271f31SJed Brown #define CEED_INTERN extern CEED_VISIBILITY(hidden) 233b271f31SJed Brown #endif 243b271f31SJed Brown 25ec3da8bcSJed Brown #define CEED_UNUSED __attribute__((unused)) 26ec3da8bcSJed Brown 27ec3da8bcSJed Brown #define CEED_MAX_RESOURCE_LEN 1024 28d0c91ce9Sjeremylt #define CEED_MAX_BACKEND_PRIORITY UINT_MAX 29ec3da8bcSJed Brown #define CEED_ALIGN 64 30ec3da8bcSJed Brown #define CEED_COMPOSITE_MAX 16 31bf4cb664SJeremy L Thompson #define CEED_FIELD_MAX 16 32ec3da8bcSJed Brown 3303d18186Sjeremylt #ifndef CeedPragmaOptimizeOff 3403d18186Sjeremylt #if defined(__clang__) 351f97d2f1SJeremy L Thompson /// This macro provides the ability to disable optimization flags for functions that are sensitive to floating point optimizations. 361f97d2f1SJeremy L Thompson /// @ingroup Ceed 3703d18186Sjeremylt #define CeedPragmaOptimizeOff _Pragma("clang optimize off") 3803d18186Sjeremylt #elif defined(__GNUC__) 3903d18186Sjeremylt #define CeedPragmaOptimizeOff _Pragma("GCC push_options") _Pragma("GCC optimize 0") 4003d18186Sjeremylt #elif defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER) 4103d18186Sjeremylt #define CeedPragmaOptimizeOff _Pragma("optimize('', off)") 4203d18186Sjeremylt #else 4303d18186Sjeremylt #define CeedPragmaOptimizeOff 4403d18186Sjeremylt #endif 4503d18186Sjeremylt #endif 4603d18186Sjeremylt 4703d18186Sjeremylt #ifndef CeedPragmaOptimizeOn 4803d18186Sjeremylt #if defined(__clang__) 491f97d2f1SJeremy L Thompson /// This macro restores previously set optimization flags after CeedPragmaOptimizeOff. 501f97d2f1SJeremy L Thompson /// @ingroup Ceed 5103d18186Sjeremylt #define CeedPragmaOptimizeOn _Pragma("clang optimize on") 5203d18186Sjeremylt #elif defined(__GNUC__) 5303d18186Sjeremylt #define CeedPragmaOptimizeOn _Pragma("GCC pop_options") 5403d18186Sjeremylt #elif defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER) 5503d18186Sjeremylt #define CeedPragmaOptimizeOff _Pragma("optimize('', on)") 5603d18186Sjeremylt #else 5703d18186Sjeremylt #define CeedPragmaOptimizeOn 5803d18186Sjeremylt #endif 5903d18186Sjeremylt #endif 6003d18186Sjeremylt 611f97d2f1SJeremy L Thompson /** 621f97d2f1SJeremy L Thompson This enum supples common colors for CeedDebug256 debugging output. 631f97d2f1SJeremy L Thompson Set the environment variable `CEED_DEBUG = 1` to activate debugging output. 641f97d2f1SJeremy L Thompson 651f97d2f1SJeremy L Thompson @ingroup Ceed 661f97d2f1SJeremy L Thompson @ref Backend 671f97d2f1SJeremy L Thompson **/ 6823d4529eSJeremy L Thompson typedef enum { 6923d4529eSJeremy L Thompson /// Success color 7023d4529eSJeremy L Thompson CEED_DEBUG_COLOR_SUCCESS = 108, 7123d4529eSJeremy L Thompson /// Warning color 7223d4529eSJeremy L Thompson CEED_DEBUG_COLOR_WARNING = 208, 7323d4529eSJeremy L Thompson /// Error color 7423d4529eSJeremy L Thompson CEED_DEBUG_COLOR_ERROR = 196, 7523d4529eSJeremy L Thompson /// Use native terminal coloring 7623d4529eSJeremy L Thompson CEED_DEBUG_COLOR_NONE = 255, 7723d4529eSJeremy L Thompson } CeedDebugColor; 783f21f6b1SJeremy L Thompson 793f21f6b1SJeremy L Thompson CEED_EXTERN void CeedDebugImpl256(const unsigned char, const char *, ...); 803f21f6b1SJeremy L Thompson CEED_EXTERN bool CeedDebugFlag(const Ceed ceed); 813f21f6b1SJeremy L Thompson CEED_EXTERN bool CeedDebugFlagEnv(void); 821f97d2f1SJeremy L Thompson /** 831f97d2f1SJeremy L Thompson Print debugging information in color 841f97d2f1SJeremy L Thompson 851f97d2f1SJeremy L Thompson @param[in] ceed Ceed 861f97d2f1SJeremy L Thompson @param[in] color Color to print with 871f97d2f1SJeremy L Thompson 881f97d2f1SJeremy L Thompson @ingroup Ceed 891f97d2f1SJeremy L Thompson @ref Backend 901f97d2f1SJeremy L Thompson **/ 913f21f6b1SJeremy L Thompson #define CeedDebug256(ceed, color, ...) \ 922b730f8bSJeremy L Thompson { \ 932b730f8bSJeremy L Thompson if (CeedDebugFlag(ceed)) CeedDebugImpl256(color, ##__VA_ARGS__); \ 942b730f8bSJeremy L Thompson } 951f97d2f1SJeremy L Thompson /** 961f97d2f1SJeremy L Thompson Print debugging information to terminal 971f97d2f1SJeremy L Thompson 981f97d2f1SJeremy L Thompson @param[in] ceed Ceed 991f97d2f1SJeremy L Thompson 1001f97d2f1SJeremy L Thompson @ingroup Ceed 1011f97d2f1SJeremy L Thompson @ref Backend 1021f97d2f1SJeremy L Thompson **/ 1033f21f6b1SJeremy L Thompson #define CeedDebug(ceed, ...) CeedDebug256(ceed, (unsigned char)CEED_DEBUG_COLOR_NONE, ##__VA_ARGS__) 1041f97d2f1SJeremy L Thompson /** 1051f97d2f1SJeremy L Thompson Print debugging information in color without Ceed to reference 1061f97d2f1SJeremy L Thompson 1071f97d2f1SJeremy L Thompson @param[in] color Color to print with 1081f97d2f1SJeremy L Thompson 1091f97d2f1SJeremy L Thompson @ingroup Ceed 1101f97d2f1SJeremy L Thompson @ref Backend 1111f97d2f1SJeremy L Thompson **/ 1123f21f6b1SJeremy L Thompson #define CeedDebugEnv256(color, ...) \ 1132b730f8bSJeremy L Thompson { \ 1142b730f8bSJeremy L Thompson if (CeedDebugFlagEnv()) CeedDebugImpl256(color, ##__VA_ARGS__); \ 1152b730f8bSJeremy L Thompson } 1161f97d2f1SJeremy L Thompson /** 1171f97d2f1SJeremy L Thompson Print debugging information to terminal without Ceed to reference 1181f97d2f1SJeremy L Thompson 1191f97d2f1SJeremy L Thompson @ingroup Ceed 1201f97d2f1SJeremy L Thompson @ref Backend 1211f97d2f1SJeremy L Thompson **/ 1223f21f6b1SJeremy L Thompson #define CeedDebugEnv(...) CeedDebugEnv256((unsigned char)CEED_DEBUG_COLOR_NONE, ##__VA_ARGS__) 123aca496beSJeremy L Thompson /** 124aca496beSJeremy L Thompson Print warning information in color 125aca496beSJeremy L Thompson 126aca496beSJeremy L Thompson @ingroup Ceed 127aca496beSJeremy L Thompson @ref Backend 128aca496beSJeremy L Thompson **/ 129aca496beSJeremy L Thompson #define CeedWarn(...) \ 130aca496beSJeremy L Thompson { CeedDebugImpl256(CEED_DEBUG_COLOR_WARNING, ##__VA_ARGS__); } 131ec3da8bcSJed Brown 1321c66c397SJeremy L Thompson /** 1331c66c397SJeremy L Thompson Swap the values of two CeedScalars 1341c66c397SJeremy L Thompson 1351c66c397SJeremy L Thompson @param[in,out] a First CeedScalar 1361c66c397SJeremy L Thompson @param[in,out] b Second CeedScalar 1371c66c397SJeremy L Thompson 1381c66c397SJeremy L Thompson @ingroup Ceed 1391c66c397SJeremy L Thompson @ref Backend 1401c66c397SJeremy L Thompson **/ 1411c66c397SJeremy L Thompson #define CeedScalarSwap(a, b) \ 1421c66c397SJeremy L Thompson { \ 1431c66c397SJeremy L Thompson const CeedScalar temp_ = a; \ 1441c66c397SJeremy L Thompson a = b; \ 1451c66c397SJeremy L Thompson b = temp_; \ 1461c66c397SJeremy L Thompson } 1471c66c397SJeremy L Thompson 148ec3da8bcSJed Brown /// Handle for object handling TensorContraction 149ec3da8bcSJed Brown /// @ingroup CeedBasis 150ec3da8bcSJed Brown typedef struct CeedTensorContract_private *CeedTensorContract; 151ec3da8bcSJed Brown 152480fae85SJeremy L Thompson /// Handle for object handling assembled QFunction data 153480fae85SJeremy L Thompson /// @ingroup CeedOperator 154480fae85SJeremy L Thompson typedef struct CeedQFunctionAssemblyData_private *CeedQFunctionAssemblyData; 155480fae85SJeremy L Thompson 156ed9e99e6SJeremy L Thompson /// Handle for object handling assembled Operator data 157ed9e99e6SJeremy L Thompson /// @ingroup CeedOperator 158ed9e99e6SJeremy L Thompson typedef struct CeedOperatorAssemblyData_private *CeedOperatorAssemblyData; 159ed9e99e6SJeremy L Thompson 160ea61e9acSJeremy L Thompson /* In the next 3 functions, p has to be the address of a pointer type, i.e. p has to be a pointer to a pointer. */ 161ec3da8bcSJed Brown CEED_INTERN int CeedMallocArray(size_t n, size_t unit, void *p); 162ec3da8bcSJed Brown CEED_INTERN int CeedCallocArray(size_t n, size_t unit, void *p); 163ec3da8bcSJed Brown CEED_INTERN int CeedReallocArray(size_t n, size_t unit, void *p); 164f7e22acaSJeremy L Thompson CEED_INTERN int CeedStringAllocCopy(const char *source, char **copy); 165ec3da8bcSJed Brown CEED_INTERN int CeedFree(void *p); 166ec3da8bcSJed Brown 167d109957bSJeremy L Thompson /** 168d109957bSJeremy L Thompson @brief Calls a libCEED function and then checks the resulting error code. 169d109957bSJeremy L Thompson If the error code is non-zero, then the error handler is called and the call from the current function with the error code. 1702b730f8bSJeremy L Thompson 171d109957bSJeremy L Thompson @ref Developer 172d109957bSJeremy L Thompson **/ 1732b730f8bSJeremy L Thompson #define CeedCall(...) \ 1742b730f8bSJeremy L Thompson do { \ 175d109957bSJeremy L Thompson int ierr_ = __VA_ARGS__; \ 176d109957bSJeremy L Thompson if (ierr_) return ierr_; \ 1770126412dSJeremy L Thompson } while (0) 1782b730f8bSJeremy L Thompson 179d109957bSJeremy L Thompson /** 180d109957bSJeremy L Thompson @brief Calls a libCEED function and then checks the resulting error code. 181d109957bSJeremy L Thompson If the error code is non-zero, then the error handler is called and the call from the current function with the error code. 182d109957bSJeremy L Thompson All interface level error codes are upgraded to `CEED_ERROR_BACKEND`. 183d109957bSJeremy L Thompson 184d109957bSJeremy L Thompson @ref Developer 185d109957bSJeremy L Thompson **/ 186d109957bSJeremy L Thompson #define CeedCallBackend(...) \ 187d109957bSJeremy L Thompson do { \ 188d109957bSJeremy L Thompson int ierr_ = __VA_ARGS__; \ 189d109957bSJeremy L Thompson if (ierr_) return (ierr_ > CEED_ERROR_SUCCESS) ? CEED_ERROR_BACKEND : ierr_; \ 190d109957bSJeremy L Thompson } while (0) 191d109957bSJeremy L Thompson 192d109957bSJeremy L Thompson /** 193d109957bSJeremy L Thompson @brief Check that a particular condition is true and returns a `CeedError` if not. 194d109957bSJeremy L Thompson 195d109957bSJeremy L Thompson @ref Developer 196d109957bSJeremy L Thompson **/ 1976574a04fSJeremy L Thompson #define CeedCheck(cond, ceed, ecode, ...) \ 1986574a04fSJeremy L Thompson do { \ 199d109957bSJeremy L Thompson if (!(cond)) return CeedError(ceed, ecode, __VA_ARGS__); \ 2006574a04fSJeremy L Thompson } while (0) 2016574a04fSJeremy L Thompson 202d109957bSJeremy L Thompson /* Note - these are legacy macros that should be removed eventually */ 203d109957bSJeremy L Thompson #define CeedChk(...) CeedCall(__VA_ARGS__) 204d109957bSJeremy L Thompson #define CeedChkBackend(...) CeedCallBackend(__VA_ARGS__) 205d109957bSJeremy L Thompson 206ea61e9acSJeremy L Thompson /* Note that CeedMalloc and CeedCalloc will, generally, return pointers with different memory alignments: 207ea61e9acSJeremy L Thompson CeedMalloc returns pointers aligned at CEED_ALIGN bytes, while CeedCalloc uses the alignment of calloc. */ 208ec3da8bcSJed Brown #define CeedMalloc(n, p) CeedMallocArray((n), sizeof(**(p)), p) 209ec3da8bcSJed Brown #define CeedCalloc(n, p) CeedCallocArray((n), sizeof(**(p)), p) 210ec3da8bcSJed Brown #define CeedRealloc(n, p) CeedReallocArray((n), sizeof(**(p)), p) 211ec3da8bcSJed Brown 2122b730f8bSJeremy L Thompson CEED_EXTERN int CeedRegister(const char *prefix, int (*init)(const char *, Ceed), unsigned int priority); 2132b730f8bSJeremy L Thompson CEED_EXTERN int CeedRegisterImpl(const char *prefix, int (*init)(const char *, Ceed), unsigned int priority); 214ec3da8bcSJed Brown 215d1d35e2fSjeremylt CEED_EXTERN int CeedIsDebug(Ceed ceed, bool *is_debug); 216bc246734SJeremy L Thompson CEED_EXTERN int CeedGetResourceRoot(Ceed ceed, const char *resource, const char *delineator, char **resource_root); 217ec3da8bcSJed Brown CEED_EXTERN int CeedGetParent(Ceed ceed, Ceed *parent); 218ec3da8bcSJed Brown CEED_EXTERN int CeedGetDelegate(Ceed ceed, Ceed *delegate); 219ec3da8bcSJed Brown CEED_EXTERN int CeedSetDelegate(Ceed ceed, Ceed delegate); 2202b730f8bSJeremy L Thompson CEED_EXTERN int CeedGetObjectDelegate(Ceed ceed, Ceed *delegate, const char *obj_name); 2212b730f8bSJeremy L Thompson CEED_EXTERN int CeedSetObjectDelegate(Ceed ceed, Ceed delegate, const char *obj_name); 2222b730f8bSJeremy L Thompson CEED_EXTERN int CeedGetOperatorFallbackResource(Ceed ceed, const char **resource); 2238687e1d4SJeremy L Thompson CEED_EXTERN int CeedGetOperatorFallbackCeed(Ceed ceed, Ceed *fallback_ceed); 2242b730f8bSJeremy L Thompson CEED_EXTERN int CeedSetOperatorFallbackResource(Ceed ceed, const char *resource); 225d1d35e2fSjeremylt CEED_EXTERN int CeedSetDeterministic(Ceed ceed, bool is_deterministic); 2262b730f8bSJeremy L Thompson CEED_EXTERN int CeedSetBackendFunction(Ceed ceed, const char *type, void *object, const char *func_name, int (*f)()); 227ec3da8bcSJed Brown CEED_EXTERN int CeedGetData(Ceed ceed, void *data); 228ec3da8bcSJed Brown CEED_EXTERN int CeedSetData(Ceed ceed, void *data); 2299560d06aSjeremylt CEED_EXTERN int CeedReference(Ceed ceed); 230ec3da8bcSJed Brown 2319c774eddSJeremy L Thompson CEED_EXTERN int CeedVectorHasValidArray(CeedVector vec, bool *has_valid_array); 2322b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorHasBorrowedArrayOfType(CeedVector vec, CeedMemType mem_type, bool *has_borrowed_array_of_type); 2339c774eddSJeremy L Thompson CEED_EXTERN int CeedVectorHasValidArray(CeedVector vec, bool *has_valid_array); 234ec3da8bcSJed Brown CEED_EXTERN int CeedVectorGetState(CeedVector vec, uint64_t *state); 235ec3da8bcSJed Brown CEED_EXTERN int CeedVectorGetData(CeedVector vec, void *data); 236ec3da8bcSJed Brown CEED_EXTERN int CeedVectorSetData(CeedVector vec, void *data); 2379560d06aSjeremylt CEED_EXTERN int CeedVectorReference(CeedVector vec); 238ec3da8bcSJed Brown 239fcbe8c06SSebastian Grimberg /// Type of element restriction; 240fcbe8c06SSebastian Grimberg /// @ingroup CeedElemRestriction 241fcbe8c06SSebastian Grimberg typedef enum { 24261a27d74SSebastian Grimberg /// Standard element restriction with offsets 24361a27d74SSebastian Grimberg CEED_RESTRICTION_STANDARD = 1, 244fcbe8c06SSebastian Grimberg /// Oriented element restriction 245fcbe8c06SSebastian Grimberg CEED_RESTRICTION_ORIENTED = 2, 246fcbe8c06SSebastian Grimberg /// Curl-oriented element restriction 247fcbe8c06SSebastian Grimberg CEED_RESTRICTION_CURL_ORIENTED = 3, 248fcbe8c06SSebastian Grimberg /// Strided element restriction 249fcbe8c06SSebastian Grimberg CEED_RESTRICTION_STRIDED = 4, 250fcbe8c06SSebastian Grimberg } CeedRestrictionType; 251fcbe8c06SSebastian Grimberg 252fcbe8c06SSebastian Grimberg CEED_EXTERN int CeedElemRestrictionGetType(CeedElemRestriction rstr, CeedRestrictionType *rstr_type); 25377d1c127SSebastian Grimberg CEED_EXTERN int CeedElemRestrictionIsStrided(CeedElemRestriction rstr, bool *is_strided); 2542b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetStrides(CeedElemRestriction rstr, CeedInt (*strides)[3]); 25577d1c127SSebastian Grimberg CEED_EXTERN int CeedElemRestrictionHasBackendStrides(CeedElemRestriction rstr, bool *has_backend_strides); 2562b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetOffsets(CeedElemRestriction rstr, CeedMemType mem_type, const CeedInt **offsets); 2572b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionRestoreOffsets(CeedElemRestriction rstr, const CeedInt **offsets); 25877d1c127SSebastian Grimberg CEED_EXTERN int CeedElemRestrictionGetOrientations(CeedElemRestriction rstr, CeedMemType mem_type, const bool **orients); 25977d1c127SSebastian Grimberg CEED_EXTERN int CeedElemRestrictionRestoreOrientations(CeedElemRestriction rstr, const bool **orients); 2600c73c039SSebastian Grimberg CEED_EXTERN int CeedElemRestrictionGetCurlOrientations(CeedElemRestriction rstr, CeedMemType mem_type, const CeedInt8 **curl_orients); 2610c73c039SSebastian Grimberg CEED_EXTERN int CeedElemRestrictionRestoreCurlOrientations(CeedElemRestriction rstr, const CeedInt8 **curl_orients); 2622b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetELayout(CeedElemRestriction rstr, CeedInt (*layout)[3]); 2632b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionSetELayout(CeedElemRestriction rstr, CeedInt layout[3]); 2642b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetData(CeedElemRestriction rstr, void *data); 2652b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionSetData(CeedElemRestriction rstr, void *data); 2669560d06aSjeremylt CEED_EXTERN int CeedElemRestrictionReference(CeedElemRestriction rstr); 2679d36ca50SJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetFlopsEstimate(CeedElemRestriction rstr, CeedTransposeMode t_mode, CeedSize *flops); 268ec3da8bcSJed Brown 2696f117663SJeremy L Thompson /// Type of FE space; 2706f117663SJeremy L Thompson /// @ingroup CeedBasis 2716f117663SJeremy L Thompson typedef enum { 272c4e3f59bSSebastian Grimberg /// H^1 FE space 2736f117663SJeremy L Thompson CEED_FE_SPACE_H1 = 1, 2746f117663SJeremy L Thompson /// H(div) FE space 2756f117663SJeremy L Thompson CEED_FE_SPACE_HDIV = 2, 276c4e3f59bSSebastian Grimberg /// H(curl) FE space 277c4e3f59bSSebastian Grimberg CEED_FE_SPACE_HCURL = 3, 2786f117663SJeremy L Thompson } CeedFESpace; 2796f117663SJeremy L Thompson CEED_EXTERN const char *const CeedFESpaces[]; 2806f117663SJeremy L Thompson 2812b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetCollocatedGrad(CeedBasis basis, CeedScalar *colo_grad_1d); 282d1d35e2fSjeremylt CEED_EXTERN int CeedBasisIsTensor(CeedBasis basis, bool *is_tensor); 283ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetData(CeedBasis basis, void *data); 284ec3da8bcSJed Brown CEED_EXTERN int CeedBasisSetData(CeedBasis basis, void *data); 2859560d06aSjeremylt CEED_EXTERN int CeedBasisReference(CeedBasis basis); 286c4e3f59bSSebastian Grimberg CEED_EXTERN int CeedBasisGetNumQuadratureComponents(CeedBasis basis, CeedEvalMode eval_mode, CeedInt *q_comp); 2879d36ca50SJeremy L Thompson CEED_EXTERN int CeedBasisGetFlopsEstimate(CeedBasis basis, CeedTransposeMode t_mode, CeedEvalMode eval_mode, CeedSize *flops); 288c4e3f59bSSebastian Grimberg CEED_EXTERN int CeedBasisGetFESpace(CeedBasis basis, CeedFESpace *fe_space); 2892b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetTopologyDimension(CeedElemTopology topo, CeedInt *dim); 2902b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetTensorContract(CeedBasis basis, CeedTensorContract *contract); 2912b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisSetTensorContract(CeedBasis basis, CeedTensorContract contract); 292c4e3f59bSSebastian Grimberg 2932b730f8bSJeremy L Thompson CEED_EXTERN int CeedTensorContractCreate(Ceed ceed, CeedBasis basis, CeedTensorContract *contract); 2942b730f8bSJeremy L Thompson CEED_EXTERN int CeedTensorContractApply(CeedTensorContract contract, CeedInt A, CeedInt B, CeedInt C, CeedInt J, const CeedScalar *__restrict__ t, 2952b730f8bSJeremy L Thompson CeedTransposeMode t_mode, const CeedInt Add, const CeedScalar *__restrict__ u, CeedScalar *__restrict__ v); 296c4e3f59bSSebastian Grimberg CEED_EXTERN int CeedTensorContractStridedApply(CeedTensorContract contract, CeedInt A, CeedInt B, CeedInt C, CeedInt D, CeedInt J, 297c4e3f59bSSebastian Grimberg const CeedScalar *__restrict__ t, CeedTransposeMode t_mode, const CeedInt add, 298c4e3f59bSSebastian Grimberg const CeedScalar *__restrict__ u, CeedScalar *__restrict__ v); 2992b730f8bSJeremy L Thompson CEED_EXTERN int CeedTensorContractGetCeed(CeedTensorContract contract, Ceed *ceed); 3002b730f8bSJeremy L Thompson CEED_EXTERN int CeedTensorContractGetData(CeedTensorContract contract, void *data); 3012b730f8bSJeremy L Thompson CEED_EXTERN int CeedTensorContractSetData(CeedTensorContract contract, void *data); 3029560d06aSjeremylt CEED_EXTERN int CeedTensorContractReference(CeedTensorContract contract); 303585a562dSJeremy L Thompson CEED_EXTERN int CeedTensorContractReferenceCopy(CeedTensorContract tensor, CeedTensorContract *tensor_copy); 304ec3da8bcSJed Brown CEED_EXTERN int CeedTensorContractDestroy(CeedTensorContract *contract); 305ec3da8bcSJed Brown 306509668d5SJeremy L Thompson CEED_EXTERN int CeedQFunctionRegister(const char *name, const char *source, CeedInt vec_length, CeedQFunctionUser f, 307509668d5SJeremy L Thompson int (*init)(Ceed, const char *, CeedQFunction)); 308ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionSetFortranStatus(CeedQFunction qf, bool status); 3092b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetVectorLength(CeedQFunction qf, CeedInt *vec_length); 3102b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetNumArgs(CeedQFunction qf, CeedInt *num_input_fields, CeedInt *num_output_fields); 31143e1b16fSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetKernelName(CeedQFunction qf, char **kernel_name); 31243e1b16fSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetSourcePath(CeedQFunction qf, char **source_path); 3133d3250a0SJeremy L Thompson CEED_EXTERN int CeedQFunctionLoadSourceToBuffer(CeedQFunction qf, char **source_buffer); 3142b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetUserFunction(CeedQFunction qf, CeedQFunctionUser *f); 3152b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetContext(CeedQFunction qf, CeedQFunctionContext *ctx); 316441428dfSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetContextData(CeedQFunction qf, CeedMemType mem_type, void *data); 317441428dfSJeremy L Thompson CEED_EXTERN int CeedQFunctionRestoreContextData(CeedQFunction qf, void *data); 3182b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetInnerContext(CeedQFunction qf, CeedQFunctionContext *ctx); 319441428dfSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetInnerContextData(CeedQFunction qf, CeedMemType mem_type, void *data); 320441428dfSJeremy L Thompson CEED_EXTERN int CeedQFunctionRestoreInnerContextData(CeedQFunction qf, void *data); 321d1d35e2fSjeremylt CEED_EXTERN int CeedQFunctionIsIdentity(CeedQFunction qf, bool *is_identity); 322441428dfSJeremy L Thompson CEED_EXTERN int CeedQFunctionIsContextWritable(CeedQFunction qf, bool *is_writable); 323ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionGetData(CeedQFunction qf, void *data); 324ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionSetData(CeedQFunction qf, void *data); 3259560d06aSjeremylt CEED_EXTERN int CeedQFunctionReference(CeedQFunction qf); 3269d36ca50SJeremy L Thompson CEED_EXTERN int CeedQFunctionGetFlopsEstimate(CeedQFunction qf, CeedSize *flops); 327ec3da8bcSJed Brown 3282b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetCeed(CeedQFunctionContext ctx, Ceed *ceed); 3292b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextHasValidData(CeedQFunctionContext ctx, bool *has_valid_data); 3302b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextHasBorrowedDataOfType(CeedQFunctionContext ctx, CeedMemType mem_type, bool *has_borrowed_data_of_type); 3312b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetState(CeedQFunctionContext ctx, uint64_t *state); 3322b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetBackendData(CeedQFunctionContext ctx, void *data); 3332b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextSetBackendData(CeedQFunctionContext ctx, void *data); 3342b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetFieldLabel(CeedQFunctionContext ctx, const char *field_name, CeedContextFieldLabel *field_label); 3352b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextSetGeneric(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, CeedContextFieldType field_type, 3362b730f8bSJeremy L Thompson void *value); 3372788fa27SJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetGenericRead(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, CeedContextFieldType field_type, 3382788fa27SJeremy L Thompson size_t *num_values, void *value); 3392788fa27SJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRestoreGenericRead(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, CeedContextFieldType field_type, 3402788fa27SJeremy L Thompson void *value); 3412b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextSetDouble(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, double *values); 3422788fa27SJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetDoubleRead(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, size_t *num_values, 3432788fa27SJeremy L Thompson const double **values); 3442788fa27SJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRestoreDoubleRead(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, const double **values); 3452b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextSetInt32(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, int *values); 3462788fa27SJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetInt32Read(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, size_t *num_values, const int **values); 3472788fa27SJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRestoreInt32Read(CeedQFunctionContext ctx, CeedContextFieldLabel field_label, const int **values); 3482b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetDataDestroy(CeedQFunctionContext ctx, CeedMemType *f_mem_type, CeedQFunctionContextDataDestroyUser *f); 3499560d06aSjeremylt CEED_EXTERN int CeedQFunctionContextReference(CeedQFunctionContext ctx); 350ec3da8bcSJed Brown 351480fae85SJeremy L Thompson CEED_EXTERN int CeedQFunctionAssemblyDataCreate(Ceed ceed, CeedQFunctionAssemblyData *data); 352480fae85SJeremy L Thompson CEED_EXTERN int CeedQFunctionAssemblyDataReference(CeedQFunctionAssemblyData data); 353beecbf24SJeremy L Thompson CEED_EXTERN int CeedQFunctionAssemblyDataSetReuse(CeedQFunctionAssemblyData data, bool reuse_assembly_data); 354beecbf24SJeremy L Thompson CEED_EXTERN int CeedQFunctionAssemblyDataSetUpdateNeeded(CeedQFunctionAssemblyData data, bool needs_data_update); 3558b919e6bSJeremy L Thompson CEED_EXTERN int CeedQFunctionAssemblyDataIsUpdateNeeded(CeedQFunctionAssemblyData data, bool *is_update_needed); 356480fae85SJeremy L Thompson CEED_EXTERN int CeedQFunctionAssemblyDataReferenceCopy(CeedQFunctionAssemblyData data, CeedQFunctionAssemblyData *data_copy); 357480fae85SJeremy L Thompson CEED_EXTERN int CeedQFunctionAssemblyDataIsSetup(CeedQFunctionAssemblyData data, bool *is_setup); 358480fae85SJeremy L Thompson CEED_EXTERN int CeedQFunctionAssemblyDataSetObjects(CeedQFunctionAssemblyData data, CeedVector vec, CeedElemRestriction rstr); 359480fae85SJeremy L Thompson CEED_EXTERN int CeedQFunctionAssemblyDataGetObjects(CeedQFunctionAssemblyData data, CeedVector *vec, CeedElemRestriction *rstr); 360480fae85SJeremy L Thompson CEED_EXTERN int CeedQFunctionAssemblyDataDestroy(CeedQFunctionAssemblyData *data); 361480fae85SJeremy L Thompson 362ed9e99e6SJeremy L Thompson CEED_EXTERN int CeedOperatorAssemblyDataCreate(Ceed ceed, CeedOperator op, CeedOperatorAssemblyData *data); 363437c7c90SJeremy L Thompson CEED_EXTERN int CeedOperatorAssemblyDataGetEvalModes(CeedOperatorAssemblyData data, CeedInt *num_active_bases, CeedInt **num_eval_modes_in, 364437c7c90SJeremy L Thompson const CeedEvalMode ***eval_modes_in, CeedSize ***eval_mode_offsets_in, 365437c7c90SJeremy L Thompson CeedInt **num_eval_modes_out, const CeedEvalMode ***eval_modes_out, 366437c7c90SJeremy L Thompson CeedSize ***eval_mode_offsets_out, CeedSize *num_output_components); 367437c7c90SJeremy L Thompson CEED_EXTERN int CeedOperatorAssemblyDataGetBases(CeedOperatorAssemblyData data, CeedInt *num_active_bases, CeedBasis **active_bases, 368437c7c90SJeremy L Thompson const CeedScalar ***assembled_bases_in, const CeedScalar ***assembled_bases_out); 369437c7c90SJeremy L Thompson CEED_EXTERN int CeedOperatorAssemblyDataGetElemRestrictions(CeedOperatorAssemblyData data, CeedInt *num_active_elem_rstrs, 370437c7c90SJeremy L Thompson CeedElemRestriction **active_elem_rstrs); 371ed9e99e6SJeremy L Thompson CEED_EXTERN int CeedOperatorAssemblyDataDestroy(CeedOperatorAssemblyData *data); 372ed9e99e6SJeremy L Thompson 373ed9e99e6SJeremy L Thompson CEED_EXTERN int CeedOperatorGetOperatorAssemblyData(CeedOperator op, CeedOperatorAssemblyData *data); 3742b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorGetActiveBasis(CeedOperator op, CeedBasis *active_basis); 375ed9e99e6SJeremy L Thompson CEED_EXTERN int CeedOperatorGetActiveElemRestriction(CeedOperator op, CeedElemRestriction *active_rstr); 376d1d35e2fSjeremylt CEED_EXTERN int CeedOperatorGetNumArgs(CeedOperator op, CeedInt *num_args); 377d1d35e2fSjeremylt CEED_EXTERN int CeedOperatorIsSetupDone(CeedOperator op, bool *is_setup_done); 378ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorGetQFunction(CeedOperator op, CeedQFunction *qf); 379d1d35e2fSjeremylt CEED_EXTERN int CeedOperatorIsComposite(CeedOperator op, bool *is_composite); 380ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorGetData(CeedOperator op, void *data); 381ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorSetData(CeedOperator op, void *data); 3829560d06aSjeremylt CEED_EXTERN int CeedOperatorReference(CeedOperator op); 383*bb229da9SJeremy L Thompson CEED_EXTERN int CeedOperatorGetFallback(CeedOperator op, CeedOperator *op_fallback); 384*bb229da9SJeremy L Thompson CEED_EXTERN int CeedOperatorGetFallbackParent(CeedOperator op, CeedOperator *parent); 385*bb229da9SJeremy L Thompson CEED_EXTERN int CeedOperatorGetFallbackParentCeed(CeedOperator op, Ceed *parent); 386ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorSetSetupDone(CeedOperator op); 387ec3da8bcSJed Brown 3882b730f8bSJeremy L Thompson CEED_INTERN int CeedMatrixMatrixMultiply(Ceed ceed, const CeedScalar *mat_A, const CeedScalar *mat_B, CeedScalar *mat_C, CeedInt m, CeedInt n, 3892b730f8bSJeremy L Thompson CeedInt kk); 390ba59ac12SSebastian Grimberg CEED_EXTERN int CeedQRFactorization(Ceed ceed, CeedScalar *mat, CeedScalar *tau, CeedInt m, CeedInt n); 391ba59ac12SSebastian Grimberg CEED_EXTERN int CeedHouseholderApplyQ(CeedScalar *mat_A, const CeedScalar *mat_Q, const CeedScalar *tau, CeedTransposeMode t_mode, CeedInt m, 392ba59ac12SSebastian Grimberg CeedInt n, CeedInt k, CeedInt row, CeedInt col); 393ba59ac12SSebastian Grimberg CEED_EXTERN int CeedSymmetricSchurDecomposition(Ceed ceed, CeedScalar *mat, CeedScalar *lambda, CeedInt n); 394ba59ac12SSebastian Grimberg CEED_EXTERN int CeedSimultaneousDiagonalization(Ceed ceed, CeedScalar *mat_A, CeedScalar *mat_B, CeedScalar *x, CeedScalar *lambda, CeedInt n); 395ec3da8bcSJed Brown 396ec3da8bcSJed Brown #endif 397