1 #ifndef AMREX_PARSER_H_
2 #define AMREX_PARSER_H_
20 template <
int M=N, std::enable_if_t<M==0,
int> = 0>
28 template <
typename... Ts>
31 operator() (Ts... var)
const noexcept
38 template <
typename... Ts>
41 operator() (Ts... var)
const noexcept
56 explicit operator bool ()
const {
70 Parser (std::string
const& func_body);
72 void define (std::string
const& func_body);
74 explicit operator bool ()
const;
76 void setConstant (std::string
const& name,
double c);
83 [[nodiscard]]
int depth ()
const;
86 [[nodiscard]] std::string
expr ()
const;
88 [[nodiscard]] std::set<std::string>
symbols ()
const;
128 if (!(
m_data->m_host_executor)) {
130 m_data->m_exe_size =
static_cast<int>
139 if (stack_size != 0) {
140 amrex::Abort(
"amrex::Parser: something went wrong with parser stack! "
141 + std::to_string(stack_size));
149 }
catch (
const std::runtime_error& e) {
150 throw std::runtime_error(std::string(e.what()) +
" in Parser expression \""
151 +
m_data->m_expression +
"\"");
169 auto exe = compileHost<N>();
177 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_PARSER_STACK_SIZE
Definition: AMReX_Parser_Exe.H:12
virtual void * alloc(std::size_t sz)=0
Definition: AMReX_Parser.H:68
std::set< std::string > symbols() const
Definition: AMReX_Parser.cpp:115
void print() const
Definition: AMReX_Parser.cpp:77
std::shared_ptr< Data > m_data
Definition: AMReX_Parser.H:117
int maxStackSize() const
Definition: AMReX_Parser.cpp:95
ParserExecutor< N > compileHost() const
This compiles for CPU only.
Definition: AMReX_Parser.H:123
Vector< std::string > m_vars
Definition: AMReX_Parser.H:118
std::string expr() const
Definition: AMReX_Parser.cpp:105
void define(std::string const &func_body)
Definition: AMReX_Parser.cpp:18
ParserExecutor< N > compile() const
This compiles for both GPU and CPU.
Definition: AMReX_Parser.H:167
void printExe() const
Definition: AMReX_Parser.cpp:125
void setConstant(std::string const &name, double c)
Definition: AMReX_Parser.cpp:57
void registerVariables(Vector< std::string > const &vars)
Definition: AMReX_Parser.cpp:65
int depth() const
Definition: AMReX_Parser.cpp:85
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
Arena * The_Pinned_Arena()
Definition: AMReX_Arena.cpp:649
std::size_t parser_exe_size(struct amrex_parser *parser, int &max_stack_size, int &stack_size)
Definition: AMReX_Parser_Exe.H:507
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition: AMReX.cpp:225
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE double parser_exe_eval(const char *p, double const *x)
Definition: AMReX_Parser_Exe.H:222
Arena * The_Arena()
Definition: AMReX_Arena.cpp:609
Vector< char const * > parser_compile(struct amrex_parser *parser, char *p)
Definition: AMReX_Parser_Exe.H:521
Definition: AMReX_Array.H:34
Definition: AMReX_Parser.H:19
char * m_host_executor
Definition: AMReX_Parser.H:61
char * m_device_executor
Definition: AMReX_Parser.H:63
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE double operator()() const noexcept
Definition: AMReX_Parser.H:22
Definition: AMReX_Parser.H:98
~Data()
Definition: AMReX_Parser.cpp:41
int m_max_stack_size
Definition: AMReX_Parser.H:106
int m_exe_size
Definition: AMReX_Parser.H:107
Data & operator=(Data const &)=delete
int m_nvars
Definition: AMReX_Parser.H:101
struct amrex_parser * m_parser
Definition: AMReX_Parser.H:100
std::string m_expression
Definition: AMReX_Parser.H:99
Data(Data const &)=delete
Vector< char const * > m_locals
Definition: AMReX_Parser.H:108
char * m_host_executor
Definition: AMReX_Parser.H:102
char * m_device_executor
Definition: AMReX_Parser.H:104
Definition: AMReX_TypeTraits.H:130
Definition: AMReX_Parser_Y.H:255