MFEM
v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
general
enzyme.hpp
Go to the documentation of this file.
1
// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced
2
// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3
// LICENSE and NOTICE for details. LLNL-CODE-806117.
4
//
5
// This file is part of the MFEM library. For more information and source code
6
// availability visit https://mfem.org.
7
//
8
// MFEM is free software; you can redistribute it and/or modify it under the
9
// terms of the BSD-3 license. We welcome feedback and contributions, see file
10
// CONTRIBUTING.md for details.
11
12
#include "
../config/config.hpp
"
13
14
#ifndef MFEM_ENZYME_HPP
15
#define MFEM_ENZYME_HPP
16
17
#ifdef MFEM_USE_ENZYME
18
/*
19
* Variables prefixed with enzyme_* or function types prefixed with __enzyme_*,
20
* are variables which will get preprocessed in the LLVM intermediate
21
* representation when the Enzyme LLVM plugin is loaded. See the Enzyme
22
* documentation (https://enzyme.mit.edu) for more information.
23
*/
24
25
extern
int
enzyme_dup
;
26
extern
int
enzyme_dupnoneed
;
27
extern
int
enzyme_out
;
28
extern
int
enzyme_const
;
29
extern
int
enzyme_interleave
;
30
31
#if defined(MFEM_USE_CUDA) || defined(MFEM_USE_HIP)
32
#define MFEM_DEVICE_EXTERN_STMT(name) extern __device__ int name;
33
#else
34
#define MFEM_DEVICE_EXTERN_STMT(name)
35
#endif
36
37
MFEM_DEVICE_EXTERN_STMT
(
enzyme_dup
)
38
MFEM_DEVICE_EXTERN_STMT
(
enzyme_dupnoneed
)
39
MFEM_DEVICE_EXTERN_STMT
(
enzyme_out
)
40
MFEM_DEVICE_EXTERN_STMT
(
enzyme_const
)
41
MFEM_DEVICE_EXTERN_STMT
(
enzyme_interleave
)
42
43
// warning: if inlined, triggers function '__enzyme_autodiff' is not defined
44
template
<
typename
return_type,
typename
... Args>
45
MFEM_HOST_DEVICE
46
return_type
__enzyme_autodiff
(Args...);
47
48
// warning: if inlined, triggers function '__enzyme_fwddiff' is not defined
49
template
<
typename
return_type,
typename
... Args>
50
MFEM_HOST_DEVICE
51
return_type
__enzyme_fwddiff
(Args...);
52
53
#define MFEM_ENZYME_INACTIVENOFREE __attribute__((enzyme_inactive, enzyme_nofree))
54
#define MFEM_ENZYME_INACTIVE __attribute__((enzyme_inactive))
55
#define MFEM_ENZYME_FN_LIKE(x) __attribute__((enzyme_function_like(#x)))
56
57
#else
58
#define MFEM_ENZYME_INACTIVENOFREE
59
#define MFEM_ENZYME_INACTIVE
60
#define MFEM_ENZYME_FN_LIKE(x)
61
#endif
62
63
#define MFEM_ENZYME_FN_LIKE_FREE MFEM_ENZYME_FN_LIKE(free)
64
#define MFEM_ENZYME_FN_LIKE_DYNCAST MFEM_ENZYME_FN_LIKE(__dynamic_cast)
65
66
#endif
config.hpp
enzyme_dup
int enzyme_dup
MFEM_DEVICE_EXTERN_STMT
MFEM_DEVICE_EXTERN_STMT(enzyme_dup) MFEM_DEVICE_EXTERN_STMT(enzyme_dupnoneed) MFEM_DEVICE_EXTERN_STMT(enzyme_out) MFEM_DEVICE_EXTERN_STMT(enzyme_const) MFEM_DEVICE_EXTERN_STMT(enzyme_interleave) template< typename return_type
enzyme_dupnoneed
int enzyme_dupnoneed
enzyme_out
int enzyme_out
enzyme_interleave
int enzyme_interleave
__enzyme_autodiff
typename Args MFEM_HOST_DEVICE return_type __enzyme_autodiff(Args...)
__enzyme_fwddiff
MFEM_HOST_DEVICE return_type __enzyme_fwddiff(Args...)
enzyme_const
int enzyme_const
Generated on Thu Dec 11 2025 11:52:54 for MFEM by
1.11.0