From bc38a8fbd654cce8431a0fd720ca57a073ba050d Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 5 Apr 2021 14:04:43 -0700 Subject: 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 --- Source/Parser/wp_parser_y.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Source/Parser/wp_parser_y.h') 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 #include +#include #include #include #include #include #include -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: -- cgit v1.2.3