3#include <AMReX_Config.H>
34#if (AMREX_SPACEDIM == 3)
36 x = (
x | (
x << 16)) & 0x030000FF;
41 x = (
x | (
x << 8)) & 0x0300F00F;
46 x = (
x | (
x << 4)) & 0x030C30C3;
51 x = (
x | (
x << 2)) & 0x09249249;
57#elif (AMREX_SPACEDIM == 2)
59 x = (
x | (
x << 8)) & 0x00FF00FF;
64 x = (
x | (
x << 4)) & 0x0F0F0F0F;
69 x = (
x | (
x << 2)) & 0x33333333;
74 x = (
x | (
x << 1)) & 0x55555555;
80#elif (AMREX_SPACEDIM == 1)
102 constexpr std::uint32_t code_offset = (1U << 10);
103 constexpr Real rmax =
Real(1.0) - std::numeric_limits<Real>::epsilon();
105 return (std::uint32_t)(r * code_offset);
125 constexpr std::uint32_t code_offset = (1U << 16);
126 constexpr Real rmax =
Real(1.0) - std::numeric_limits<Real>::epsilon();
128 return (std::uint32_t)(r * code_offset);
146 constexpr unsigned long long code_offset = (1ULL << 32);
147 constexpr Real rmax =
Real(1.0) - std::numeric_limits<Real>::epsilon();
149 return (std::uint32_t)(r *
Real(code_offset));
174#if (AMREX_SPACEDIM == 3)
175 std::uint32_t a =
toUInt10(
x, plo[0], phi[0]);
176 std::uint32_t b =
toUInt10(
y, plo[1], phi[1]);
177 std::uint32_t c =
toUInt10(
z, plo[2], phi[2]);
178#elif (AMREX_SPACEDIM == 2)
179 std::uint32_t a =
toUInt16(
x, plo[0], phi[0]);
180 std::uint32_t b =
toUInt16(
y, plo[1], phi[1]);
181#elif (AMREX_SPACEDIM == 1)
182 std::uint32_t a =
toUInt32(
x, plo[0], phi[0]);
198#if (AMREX_SPACEDIM == 3)
General-purpose algorithm utilities available on both host and device.
Fixed-size array types for use on GPU and CPU.
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
Simple structs for 3-component integer and real-valued tuples.
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:124
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:80
__host__ __device__ constexpr const T & Clamp(const T &v, const T &lo, const T &hi)
Definition AMReX_Algorithm.H:122
Definition AMReX_Morton.H:14
__host__ __device__ std::uint32_t toUInt16(amrex::Real x, amrex::Real xmin, amrex::Real xmax) noexcept
Convert a Real to a uint32, keeping only 16 significant bits. This puts the first 16 bits of x into r...
Definition AMReX_Morton.H:123
__host__ __device__ std::uint32_t makeSpace(std::uint32_t x) noexcept
This makes space in the input 32-bit integer by splitting the bits so they can be interleaved.
Definition AMReX_Morton.H:33
__host__ __device__ std::uint32_t toUInt10(amrex::Real x, amrex::Real xmin, amrex::Real xmax) noexcept
Convert a Real to a uint32, keeping only 10 significant bits. This puts the first 10 bits of x into r...
Definition AMReX_Morton.H:100
__host__ __device__ std::uint32_t toUInt32(amrex::Real x, amrex::Real xmin, amrex::Real xmax) noexcept
Convert a Real to a uint32, keeping all significant bits. It is assumed that xmin <= x < xmax....
Definition AMReX_Morton.H:144
__host__ __device__ std::uint32_t get32BitCode(Real x, Real y, Real z, const GpuArray< amrex::Real, 3 > &plo, const GpuArray< amrex::Real, 3 > &phi) noexcept
Given a 3D real-space coordinate, returns a Morton code stored in an unsigned 32 bit integer.
Definition AMReX_Morton.H:171
Fixed-size array that can be used on GPU.
Definition AMReX_Array.H:52
A simple struct holding 3 Real values for a 3D coordinate.
Definition AMReX_Dim3.H:32