aboutsummaryrefslogtreecommitdiff
path: root/Source/Parser/wp_parser_y.h
diff options
context:
space:
mode:
authorGravatar Axel Huebl <axel.huebl@plasma.ninja> 2021-04-05 14:04:43 -0700
committerGravatar GitHub <noreply@github.com> 2021-04-05 14:04:43 -0700
commitbc38a8fbd654cce8431a0fd720ca57a073ba050d (patch)
tree8a77fc69f2aa761fcd282fedbac64d9cec91603b /Source/Parser/wp_parser_y.h
parent72cda15299dbc070e0b33bdfb573e2d9dbd96a87 (diff)
downloadWarpX-bc38a8fbd654cce8431a0fd720ca57a073ba050d.tar.gz
WarpX-bc38a8fbd654cce8431a0fd720ca57a073ba050d.tar.zst
WarpX-bc38a8fbd654cce8431a0fd720ca57a073ba050d.zip
Parser: Bessel Function (J_n) (#1854)
* Parser: Bessel Function (J_n) Add the Bessel Function of the First Kind (J_n) to the parser. * Parser: regenerate * Parser: No jn for DPC++ (yet) * Parser: no jnf for Apple At least on AppleClang and also seen in flang source-code, we just call the double variant of `jn` instead of using a specialized call to `jnf`. This might be less efficient than needed with Intel on Apple, but I don't have a system to test this on at the moment and this is thus a save bet for compile stability. Co-authored-by: Tools <warpx@lbl.gov>
Diffstat (limited to 'Source/Parser/wp_parser_y.h')
-rw-r--r--Source/Parser/wp_parser_y.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/Source/Parser/wp_parser_y.h b/Source/Parser/wp_parser_y.h
index 1a66ac944..8a8aec89b 100644
--- a/Source/Parser/wp_parser_y.h
+++ b/Source/Parser/wp_parser_y.h
@@ -7,13 +7,14 @@
#include <AMReX_Math.H>
#include <AMReX_Print.H>
+#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <type_traits>
-enum wp_f1_t { // Bulit-in functions with one argument
+enum wp_f1_t { // Built-in functions with one argument
WP_SQRT = 1,
WP_EXP,
WP_LOG,
@@ -47,6 +48,7 @@ enum wp_f2_t { // Built-in functions with two arguments
WP_AND,
WP_OR,
WP_HEAVISIDE,
+ WP_JN,
WP_MIN,
WP_MAX
};
@@ -237,6 +239,20 @@ wp_call_f2 (enum wp_f2_t type, T a, T b)
return ((a != T(0)) || (b != T(0))) ? 1.0 : 0.0;
case WP_HEAVISIDE:
return (a < 0.0) ? amrex::Real(0.0) : ((a > 0.0) ? amrex::Real(1.0) : b);
+ case WP_JN:
+#ifdef AMREX_USE_DPCPP
+ // neither jn(f) nor std::cyl_bessel_j work yet
+ // https://github.com/oneapi-src/oneAPI-spec/issues/308
+ AMREX_DEVICE_PRINTF("wp_call_f2: Parser does not implement jn (%d) for SYCL/DPC++ yet\n", type);
+ amrex::Abort();
+ return 0.0;
+#else
+# if defined(AMREX_USE_FLOAT) && !defined(__APPLE__)
+ return jnf(a, b);
+# else
+ return jn(a, b);
+# endif
+#endif
case WP_MIN:
return (a < b) ? a : b;
case WP_MAX: