1 #ifndef AMREX_PARSER_Y_H_
2 #define AMREX_PARSER_Y_H_
3 #include <AMReX_Config.H>
17 #include <string_view>
18 #include <type_traits>
50 #if defined(__INTEL_COMPILER) && defined(__EDG__)
101 #if defined(__INTEL_COMPILER) && defined(__EDG__)
131 #if defined(__INTEL_COMPILER) && defined(__EDG__)
156 #if defined(__INTEL_COMPILER) && defined(__EDG__)
231 static_assert(
sizeof(
parser_f3) <=
sizeof(
parser_node),
"amrex parser: sizeof parser_node too small");
283 std::set<std::string>& local_symbols);
293 template <
typename T>
297 template <
typename T>
301 template <
typename T>
305 template <
typename T>
309 template <
typename T>
313 template <
typename T>
317 template <
typename T>
321 template <
typename T>
325 template <
typename T>
329 template <
typename T>
333 template <
typename T>
337 template <
typename T>
341 template <
typename T>
345 template <
typename T>
349 template <
typename T>
353 template <
typename T>
357 #if defined(__GNUC__) && !defined(__clang__) && !defined(__CUDA_ARCH__) && !defined(__NVCOMPILER)
360 return amrex::Math::comp_ellint_1<T>(k);
364 template <
typename T>
368 #if defined(__GNUC__) && !defined(__clang__) && !defined(__CUDA_ARCH__) && !defined(__NVCOMPILER)
371 return amrex::Math::comp_ellint_2<T>(k);
375 template <
typename T>
382 template <
typename T>
386 template <
typename T>
390 template <
typename T>
394 #if defined AMREX_USE_SYCL || defined __MINGW32__
405 template <
typename T>
409 #if defined AMREX_USE_SYCL || defined __MINGW32__
425 case PARSER_EXP:
return parser_math_exp<double>(a);
426 case PARSER_LOG:
return parser_math_log<double>(a);
428 case PARSER_SIN:
return parser_math_sin<double>(a);
429 case PARSER_COS:
return parser_math_cos<double>(a);
430 case PARSER_TAN:
return parser_math_tan<double>(a);
431 case PARSER_ASIN:
return parser_math_asin<double>(a);
432 case PARSER_ACOS:
return parser_math_acos<double>(a);
433 case PARSER_ATAN:
return parser_math_atan<double>(a);
434 case PARSER_SINH:
return parser_math_sinh<double>(a);
435 case PARSER_COSH:
return parser_math_cosh<double>(a);
436 case PARSER_TANH:
return parser_math_tanh<double>(a);
445 case PARSER_ERF:
return parser_math_erf<double>(a);
457 return parser_math_pow<double>(a,
b);
459 return parser_math_atan2<double>(a,
b);
461 return (a >
b) ? 1.0 : 0.0;
463 return (a <
b) ? 1.0 : 0.0;
465 return (a >=
b) ? 1.0 : 0.0;
467 return (a <=
b) ? 1.0 : 0.0;
469 return (a ==
b) ? 1.0 : 0.0;
471 return (a !=
b) ? 1.0 : 0.0;
473 return ((a != 0.0) && (
b != 0.0)) ? 1.0 : 0.0;
475 return ((a != 0.0) || (
b != 0.0)) ? 1.0 : 0.0;
477 return (a < 0.0) ? 0.0 : ((a > 0.0) ? 1.0 :
b);
479 return parser_math_jn<double>(
int(a),
b);
481 return parser_math_yn<double>(
int(a),
b);
483 return (a <
b) ? a :
b;
485 return (a >
b) ? a :
b;
487 return std::fmod(a,
b);
498 return (a != 0.0) ?
b : c;
#define AMREX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition: AMReX_BLassert.H:49
#define AMREX_NO_INLINE
Definition: AMReX_Extension.H:136
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
void amrex_parsererror(char const *s,...)
Definition: AMReX_Parser_Y.cpp:10
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T comp_ellint_1(T k)
Definition: AMReX_Math.H:231
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T comp_ellint_2(T k)
Definition: AMReX_Math.H:256
Definition: AMReX_Amr.cpp:49
parser_f2_t
Definition: AMReX_Parser_Y.H:81
@ PARSER_LT
Definition: AMReX_Parser_Y.H:85
@ PARSER_AND
Definition: AMReX_Parser_Y.H:90
@ PARSER_NEQ
Definition: AMReX_Parser_Y.H:89
@ PARSER_OR
Definition: AMReX_Parser_Y.H:91
@ PARSER_ATAN2
Definition: AMReX_Parser_Y.H:83
@ PARSER_LEQ
Definition: AMReX_Parser_Y.H:87
@ PARSER_YN
Definition: AMReX_Parser_Y.H:94
@ PARSER_GEQ
Definition: AMReX_Parser_Y.H:86
@ PARSER_POW
Definition: AMReX_Parser_Y.H:82
@ PARSER_JN
Definition: AMReX_Parser_Y.H:93
@ PARSER_MIN
Definition: AMReX_Parser_Y.H:95
@ PARSER_GT
Definition: AMReX_Parser_Y.H:84
@ PARSER_MAX
Definition: AMReX_Parser_Y.H:96
@ PARSER_FMOD
Definition: AMReX_Parser_Y.H:97
@ PARSER_HEAVISIDE
Definition: AMReX_Parser_Y.H:92
@ PARSER_EQ
Definition: AMReX_Parser_Y.H:88
void parser_set_number(struct parser_node *node, double v)
Definition: AMReX_Parser_Y.cpp:1665
struct parser_node * parser_newf2(enum parser_f2_t ftype, struct parser_node *l, struct parser_node *r)
Definition: AMReX_Parser_Y.cpp:99
void parser_regvar(struct amrex_parser *parser, char const *name, int i)
Definition: AMReX_Parser_Y.cpp:1619
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_cosh(T a)
Definition: AMReX_Parser_Y.H:335
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_sinh(T a)
Definition: AMReX_Parser_Y.H:331
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_yn(int a, T b)
Definition: AMReX_Parser_Y.H:407
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE double parser_call_f1(enum parser_f1_t type, double a)
Definition: AMReX_Parser_Y.H:421
parser_f3_t
Definition: AMReX_Parser_Y.H:126
@ PARSER_IF
Definition: AMReX_Parser_Y.H:127
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_atan(T a)
Definition: AMReX_Parser_Y.H:327
void amrex_parser_delete(struct amrex_parser *parser)
Definition: AMReX_Parser_Y.cpp:170
void parser_ast_sort(struct parser_node *node)
Definition: AMReX_Parser_Y.cpp:1456
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > log(const GpuComplex< T > &a_z) noexcept
Complex natural logarithm function.
Definition: AMReX_GpuComplex.H:408
parser_f1_t
Definition: AMReX_Parser_Y.H:24
@ PARSER_ASINH
Definition: AMReX_Parser_Y.H:38
@ PARSER_TANH
Definition: AMReX_Parser_Y.H:37
@ PARSER_COS
Definition: AMReX_Parser_Y.H:30
@ PARSER_COSH
Definition: AMReX_Parser_Y.H:36
@ PARSER_COMP_ELLINT_1
Definition: AMReX_Parser_Y.H:44
@ PARSER_SQRT
Definition: AMReX_Parser_Y.H:25
@ PARSER_COMP_ELLINT_2
Definition: AMReX_Parser_Y.H:45
@ PARSER_TAN
Definition: AMReX_Parser_Y.H:31
@ PARSER_ACOS
Definition: AMReX_Parser_Y.H:33
@ PARSER_ATANH
Definition: AMReX_Parser_Y.H:40
@ PARSER_EXP
Definition: AMReX_Parser_Y.H:26
@ PARSER_LOG
Definition: AMReX_Parser_Y.H:27
@ PARSER_SIN
Definition: AMReX_Parser_Y.H:29
@ PARSER_ERF
Definition: AMReX_Parser_Y.H:46
@ PARSER_ASIN
Definition: AMReX_Parser_Y.H:32
@ PARSER_CEIL
Definition: AMReX_Parser_Y.H:43
@ PARSER_ATAN
Definition: AMReX_Parser_Y.H:34
@ PARSER_ABS
Definition: AMReX_Parser_Y.H:41
@ PARSER_ACOSH
Definition: AMReX_Parser_Y.H:39
@ PARSER_LOG10
Definition: AMReX_Parser_Y.H:28
@ PARSER_FLOOR
Definition: AMReX_Parser_Y.H:42
@ PARSER_SINH
Definition: AMReX_Parser_Y.H:35
void parser_setconst(struct amrex_parser *parser, char const *name, double c)
Definition: AMReX_Parser_Y.cpp:1625
void parser_ast_setconst(struct parser_node *node, char const *name, double c)
Definition: AMReX_Parser_Y.cpp:1539
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_jn(int a, T b)
Definition: AMReX_Parser_Y.H:392
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T abs(const GpuComplex< T > &a_z) noexcept
Return the absolute value of a complex number.
Definition: AMReX_GpuComplex.H:356
int parser_depth(struct amrex_parser *parser)
Definition: AMReX_Parser_Y.cpp:1654
void parser_print(struct amrex_parser *parser)
Definition: AMReX_Parser_Y.cpp:1633
struct parser_node * parser_newnode(enum parser_node_t type, struct parser_node *l, struct parser_node *r)
Definition: AMReX_Parser_Y.cpp:46
struct parser_node * parser_newneg(struct parser_node *n)
Definition: AMReX_Parser_Y.cpp:62
void parser_ast_optimize(struct parser_node *node)
Definition: AMReX_Parser_Y.cpp:678
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_tan(T a)
Definition: AMReX_Parser_Y.H:315
struct parser_node * parser_newassign(struct parser_symbol *sym, struct parser_node *v)
Definition: AMReX_Parser_Y.cpp:123
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_sin(T a)
Definition: AMReX_Parser_Y.H:307
struct parser_node * parser_newf3(enum parser_f3_t ftype, struct parser_node *n1, struct parser_node *n2, struct parser_node *n3)
Definition: AMReX_Parser_Y.cpp:110
int parser_ast_depth(struct parser_node *node)
Definition: AMReX_Parser_Y.cpp:1413
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T parser_math_comp_ellint_1(T k)
Definition: AMReX_Parser_Y.H:355
static constexpr std::string_view parser_f3_s[]
Definition: AMReX_Parser_Y.H:136
std::size_t parser_ast_size(struct parser_node *node)
Definition: AMReX_Parser_Y.cpp:211
void parser_ast_print(struct parser_node *node, std::string const &space, std::ostream &printer)
Definition: AMReX_Parser_Y.cpp:1371
static constexpr std::string_view parser_node_s[]
Definition: AMReX_Parser_Y.H:161
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_exp(T a)
Definition: AMReX_Parser_Y.H:295
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_asin(T a)
Definition: AMReX_Parser_Y.H:319
double parser_get_number(struct parser_node *node)
Definition: AMReX_Parser_Y.cpp:1659
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition: AMReX.H:111
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE double parser_call_f2(enum parser_f2_t type, double a, double b)
Definition: AMReX_Parser_Y.H:453
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T parser_math_comp_ellint_2(T k)
Definition: AMReX_Parser_Y.H:366
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_tanh(T a)
Definition: AMReX_Parser_Y.H:339
std::set< std::string > parser_get_symbols(struct amrex_parser *parser)
Definition: AMReX_Parser_Y.cpp:1642
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_pow(T a, T b)
Definition: AMReX_Parser_Y.H:384
bool parser_node_equal(struct parser_node *a, struct parser_node *b)
Definition: AMReX_Parser_Y.cpp:636
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_log10(T a)
Definition: AMReX_Parser_Y.H:303
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > pow(const GpuComplex< T > &a_z, const T &a_y) noexcept
Raise a complex number to a (real) power.
Definition: AMReX_GpuComplex.H:418
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_log(T a)
Definition: AMReX_Parser_Y.H:299
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE double parser_call_f3(enum parser_f3_t, double a, double b, double c)
Definition: AMReX_Parser_Y.H:495
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_atanh(T a)
Definition: AMReX_Parser_Y.H:351
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition: AMReX.cpp:225
struct parser_node * parser_ast_dup(struct amrex_parser *my_parser, struct parser_node *node, int move)
Definition: AMReX_Parser_Y.cpp:260
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_asinh(T a)
Definition: AMReX_Parser_Y.H:343
void parser_defexpr(struct parser_node *body)
Definition: AMReX_Parser_Y.cpp:28
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > exp(const GpuComplex< T > &a_z) noexcept
Complex expotential function.
Definition: AMReX_GpuComplex.H:334
struct parser_node * parser_newsymbol(struct parser_symbol *symbol)
Definition: AMReX_Parser_Y.cpp:83
parser_node_t
Definition: AMReX_Parser_Y.H:141
@ PARSER_SYMBOL
Definition: AMReX_Parser_Y.H:143
@ PARSER_MUL
Definition: AMReX_Parser_Y.H:146
@ PARSER_SUB
Definition: AMReX_Parser_Y.H:145
@ PARSER_F1
Definition: AMReX_Parser_Y.H:148
@ PARSER_LIST
Definition: AMReX_Parser_Y.H:152
@ PARSER_DIV
Definition: AMReX_Parser_Y.H:147
@ PARSER_ADD
Definition: AMReX_Parser_Y.H:144
@ PARSER_ASSIGN
Definition: AMReX_Parser_Y.H:151
@ PARSER_F3
Definition: AMReX_Parser_Y.H:150
@ PARSER_NUMBER
Definition: AMReX_Parser_Y.H:142
@ PARSER_F2
Definition: AMReX_Parser_Y.H:149
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_erf(T a)
Definition: AMReX_Parser_Y.H:377
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_cos(T a)
Definition: AMReX_Parser_Y.H:311
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_acosh(T a)
Definition: AMReX_Parser_Y.H:347
void parser_ast_get_symbols(struct parser_node *node, std::set< std::string > &symbols, std::set< std::string > &local_symbols)
Definition: AMReX_Parser_Y.cpp:1579
struct parser_symbol * parser_makesymbol(char *name)
Definition: AMReX_Parser_Y.cpp:34
static constexpr std::string_view parser_f2_s[]
Definition: AMReX_Parser_Y.H:106
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_atan2(T a, T b)
Definition: AMReX_Parser_Y.H:388
struct amrex_parser * amrex_parser_new()
Definition: AMReX_Parser_Y.cpp:149
static constexpr std::string_view parser_f1_s[]
Definition: AMReX_Parser_Y.H:55
void parser_ast_regvar(struct parser_node *node, char const *name, int i)
Definition: AMReX_Parser_Y.cpp:1500
AMREX_GPU_HOST_DEVICE AMREX_NO_INLINE T parser_math_acos(T a)
Definition: AMReX_Parser_Y.H:323
struct amrex_parser * parser_dup(struct amrex_parser *source)
Definition: AMReX_Parser_Y.cpp:198
struct parser_node * parser_newnumber(double d)
Definition: AMReX_Parser_Y.cpp:72
struct parser_node * parser_newf1(enum parser_f1_t ftype, struct parser_node *l)
Definition: AMReX_Parser_Y.cpp:89
struct parser_node * parser_newlist(struct parser_node *nl, struct parser_node *nr)
Definition: AMReX_Parser_Y.cpp:133
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > sqrt(const GpuComplex< T > &a_z) noexcept
Return the square root of a complex number.
Definition: AMReX_GpuComplex.H:373
Definition: AMReX_Parser_Y.H:257
void * p_root
Definition: AMReX_Parser_Y.H:258
void * p_free
Definition: AMReX_Parser_Y.H:259
std::size_t sz_mempool
Definition: AMReX_Parser_Y.H:261
struct parser_node * ast
Definition: AMReX_Parser_Y.H:260
Definition: AMReX_Parser_Y.H:225
struct parser_node * v
Definition: AMReX_Parser_Y.H:228
struct parser_symbol * s
Definition: AMReX_Parser_Y.H:227
Definition: AMReX_Parser_Y.H:201
struct parser_node * padding1
Definition: AMReX_Parser_Y.H:205
struct parser_node * l
Definition: AMReX_Parser_Y.H:204
Definition: AMReX_Parser_Y.H:209
struct parser_node * l
Definition: AMReX_Parser_Y.H:212
struct parser_node * r
Definition: AMReX_Parser_Y.H:213
Definition: AMReX_Parser_Y.H:217
struct parser_node * n3
Definition: AMReX_Parser_Y.H:222
struct parser_node * n1
Definition: AMReX_Parser_Y.H:220
struct parser_node * n2
Definition: AMReX_Parser_Y.H:221
Definition: AMReX_Parser_Y.H:182
struct parser_node * l
Definition: AMReX_Parser_Y.H:185
struct parser_node * padding2
Definition: AMReX_Parser_Y.H:187
enum parser_node_t padding
Definition: AMReX_Parser_Y.H:184
struct parser_node * r
Definition: AMReX_Parser_Y.H:186
enum parser_node_t type
Definition: AMReX_Parser_Y.H:183
Definition: AMReX_Parser_Y.H:190
Definition: AMReX_Parser_Y.H:195
char * name
Definition: AMReX_Parser_Y.H:197