alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
include
alpaka
rand
engine
philox
multiplyAndSplit64to32.hpp
Go to the documentation of this file.
1
/* Copyright 2023 Jiří Vyskočil, Bernhard Manfred Gruber, Jan Stephan
2
* SPDX-License-Identifier: MPL-2.0
3
*/
4
5
#pragma once
6
7
#include "
alpaka/core/common.hpp
"
8
9
#include <cstdint>
10
11
namespace
alpaka::rand::engine::internal
12
{
13
/// Get high 32 bits of a 64-bit number
14
constexpr
auto
high32Bits
(std::uint64_t
const
x) -> std::uint32_t
15
{
16
return
static_cast<
std::uint32_t
>
(x >> 32);
17
}
18
19
/// Get low 32 bits of a 64-bit number
20
constexpr
auto
low32Bits
(std::uint64_t
const
x) -> std::uint32_t
21
{
22
return
static_cast<
std::uint32_t
>
(x & 0xffff'ffff);
23
}
24
25
/** Multiply two 64-bit numbers and split the result into high and low 32 bits, also known as "mulhilo32"
26
*
27
* @param a first 64-bit multiplier
28
* @param b second 64-bit multiplier
29
* @param resultHigh high 32 bits of the product a*b
30
* @param resultLow low 32 bits of the product a*b
31
*/
32
// TODO: See single-instruction implementations in original Philox source code
33
constexpr
void
multiplyAndSplit64to32
(
34
std::uint64_t
const
a,
35
std::uint64_t
const
b,
36
std::uint32_t& resultHigh,
37
std::uint32_t& resultLow)
38
{
39
std::uint64_t
const
res64 = a * b;
40
resultHigh =
high32Bits
(res64);
41
resultLow =
low32Bits
(res64);
42
}
43
}
// namespace alpaka::rand::engine::internal
common.hpp
alpaka::rand::engine::internal
Definition
multiplyAndSplit64to32.hpp:12
alpaka::rand::engine::internal::low32Bits
constexpr auto low32Bits(std::uint64_t const x) -> std::uint32_t
Get low 32 bits of a 64-bit number.
Definition
multiplyAndSplit64to32.hpp:20
alpaka::rand::engine::internal::multiplyAndSplit64to32
constexpr void multiplyAndSplit64to32(std::uint64_t const a, std::uint64_t const b, std::uint32_t &resultHigh, std::uint32_t &resultLow)
Multiply two 64-bit numbers and split the result into high and low 32 bits, also known as "mulhilo32"...
Definition
multiplyAndSplit64to32.hpp:33
alpaka::rand::engine::internal::high32Bits
constexpr auto high32Bits(std::uint64_t const x) -> std::uint32_t
Get high 32 bits of a 64-bit number.
Definition
multiplyAndSplit64to32.hpp:14
Generated on
for alpaka by
1.16.1