Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Src/Base/AMReX_Math.H
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,34 @@ T comp_ellint_2 (T k)
return Kcomp*sum_val;
}

//! Return inverse square root of x
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
double rsqrt (double x)
{
double r;
#if defined(AMREX_USE_SYCL)
AMREX_IF_ON_DEVICE(( r = sycl::rsqrt(x); ))
#else
AMREX_IF_ON_DEVICE(( r = ::rsqrt(x); ))
#endif
AMREX_IF_ON_HOST(( r = 1. / std::sqrt(x); ))
return r;
}

//! Return inverse square root of x
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
float rsqrt (float x)
{
float r;
#if defined(AMREX_USE_SYCL)
AMREX_IF_ON_DEVICE(( r = sycl::rsqrt(x); ))
#else
AMREX_IF_ON_DEVICE(( r = ::rsqrtf(x); ))
#endif
AMREX_IF_ON_HOST(( r = 1.F / std::sqrt(x); ))
return r;
}

/***************************************************************************************************
* Copyright (c) 2017 - 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
Expand Down
Loading