1 #ifndef AMREX_IPARSER_H_
2 #define AMREX_IPARSER_H_
19 template <
int M=N, std::enable_if_t<M==0,
int> = 0>
27 template <
typename... Ts>
29 std::enable_if_t<
sizeof...(Ts) == N && std::conjunction_v<std::is_integral<Ts>...>,
31 operator() (Ts... var)
const noexcept
46 explicit operator bool ()
const {
60 IParser (std::string
const& func_body);
62 void define (std::string
const& func_body);
64 explicit operator bool ()
const;
66 void setConstant (std::string
const& name,
long long c);
72 [[nodiscard]]
int depth ()
const;
75 [[nodiscard]] std::string
expr ()
const;
77 [[nodiscard]] std::set<std::string>
symbols ()
const;
115 if (!(
m_data->m_host_executor)) {
117 m_data->m_exe_size =
static_cast<int>
122 amrex::Abort(
"amrex::IParser: AMREX_IPARSER_STACK_SIZE, "
126 if (stack_size != 0) {
127 amrex::Abort(
"amrex::IParser: something went wrong with iparser stack! "
128 + std::to_string(stack_size));
135 }
catch (
const std::runtime_error& e) {
136 throw std::runtime_error(std::string(e.what()) +
" in IParser expression \""
137 +
m_data->m_expression +
"\"");
155 auto exe = compileHost<N>();
163 exe.m_device_executor =
m_data->m_device_executor;
#define AMREX_ASSERT(EX)
Definition: AMReX_BLassert.H:38
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_IF_ON_DEVICE(CODE)
Definition: AMReX_GpuQualifiers.H:56
#define AMREX_IF_ON_HOST(CODE)
Definition: AMReX_GpuQualifiers.H:58
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
#define AMREX_IPARSER_STACK_SIZE
Definition: AMReX_IParser_Exe.H:12
virtual void * alloc(std::size_t sz)=0
Definition: AMReX_IParser.H:58
void print() const
Definition: AMReX_IParser.cpp:76
std::set< std::string > symbols() const
Definition: AMReX_IParser.cpp:114
void setConstant(std::string const &name, long long c)
Definition: AMReX_IParser.cpp:57
IParserExecutor< N > compileHost() const
This compiles for CPU only.
Definition: AMReX_IParser.H:110
std::string expr() const
Definition: AMReX_IParser.cpp:104
IParserExecutor< N > compile() const
This compiles for both GPU and CPU.
Definition: AMReX_IParser.H:153
void registerVariables(Vector< std::string > const &vars)
Definition: AMReX_IParser.cpp:65
int depth() const
Definition: AMReX_IParser.cpp:84
void define(std::string const &func_body)
Definition: AMReX_IParser.cpp:18
std::shared_ptr< Data > m_data
Definition: AMReX_IParser.H:105
int maxStackSize() const
Definition: AMReX_IParser.cpp:94
void streamSynchronize() noexcept
Definition: AMReX_GpuDevice.H:237
void htod_memcpy_async(void *p_d, const void *p_h, const std::size_t sz) noexcept
Definition: AMReX_GpuDevice.H:251
Definition: AMReX_Amr.cpp:49
void iparser_compile(struct amrex_iparser *parser, char *p)
Definition: AMReX_IParser_Exe.H:515
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE long long iparser_exe_eval(const char *p, long long const *x)
Definition: AMReX_IParser_Exe.H:231
Arena * The_Pinned_Arena()
Definition: AMReX_Arena.cpp:649
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition: AMReX.cpp:225
Arena * The_Arena()
Definition: AMReX_Arena.cpp:609
std::size_t iparser_exe_size(struct amrex_iparser *parser, int &max_stack_size, int &stack_size)
Definition: AMReX_IParser_Exe.H:502
Definition: AMReX_Array.H:34
Definition: AMReX_IParser.H:18
char * m_device_executor
Definition: AMReX_IParser.H:53
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE long long operator()() const noexcept
Definition: AMReX_IParser.H:21
char * m_host_executor
Definition: AMReX_IParser.H:51
Definition: AMReX_IParser.H:87
int m_exe_size
Definition: AMReX_IParser.H:96
~Data()
Definition: AMReX_IParser.cpp:41
int m_max_stack_size
Definition: AMReX_IParser.H:95
int m_nvars
Definition: AMReX_IParser.H:90
char * m_device_executor
Definition: AMReX_IParser.H:93
std::string m_expression
Definition: AMReX_IParser.H:88
char * m_host_executor
Definition: AMReX_IParser.H:91
Data(Data const &)=delete
struct amrex_iparser * m_iparser
Definition: AMReX_IParser.H:89
Data & operator=(Data const &)=delete
Definition: AMReX_IParser_Y.H:153