alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
PhiloxConstants.hpp
Go to the documentation of this file.
1/* Copyright 2022 Jiri Vyskocil, Bernhard Manfred Gruber
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
8
9#include <cstdint>
10#include <utility>
11
13{
14 /** Constants used in the Philox algorithm
15 *
16 * The numbers are taken from the reference Philox implementation:
17 *
18 * J. K. Salmon, M. A. Moraes, R. O. Dror and D. E. Shaw, "Parallel random numbers: As easy as 1, 2, 3,"
19 * SC '11: Proceedings of 2011 International Conference for High Performance Computing, Networking,
20 * Storage and Analysis, 2011, pp. 1-12, doi: 10.1145/2063384.2063405.
21 *
22 * static const data members are transformed into functions, because GCC
23 * assumes types with static data members to be not mappable and makes not
24 * exception for constexpr ones. This is a valid interpretation of the
25 * OpenMP <= 4.5 standard. In OpenMP >= 5.0 types with any kind of static
26 * data member are mappable.
27 */
29 {
30 public:
31 /// First Weyl sequence parameter: the golden ratio
32 static consteval std::uint64_t WEYL_64_0()
33 {
34 return 0x9E37'79B9'7F4A'7C15;
35 }
36
37 /// Second Weyl sequence parameter: \f$ \sqrt{3}-1 \f$
38 static consteval std::uint64_t WEYL_64_1()
39 {
40 return 0xBB67'AE85'84CA'A73B;
41 }
42
43 /// 1st Weyl sequence parameter, 32 bits
44 static consteval std::uint32_t WEYL_32_0()
45 {
46 return high32Bits(WEYL_64_0());
47 }
48
49 /// 2nd Weyl sequence parameter, 32 bits
50 static consteval std::uint32_t WEYL_32_1()
51 {
52 return high32Bits(WEYL_64_1());
53 }
54
55 /// First Philox S-box multiplier
56 static consteval std::uint32_t MULTIPLITER_4x32_0()
57 {
58 return 0xCD9E'8D57;
59 }
60
61 /// Second Philox S-box multiplier
62 static consteval std::uint32_t MULTIPLITER_4x32_1()
63 {
64 return 0xD251'1F53;
65 }
66 };
67} // namespace alpaka::rand::engine::internal
Constants used in the Philox algorithm.
static consteval std::uint32_t MULTIPLITER_4x32_1()
Second Philox S-box multiplier.
static consteval std::uint32_t MULTIPLITER_4x32_0()
First Philox S-box multiplier.
static consteval std::uint32_t WEYL_32_0()
1st Weyl sequence parameter, 32 bits
static consteval std::uint64_t WEYL_64_1()
Second Weyl sequence parameter: .
static consteval std::uint32_t WEYL_32_1()
2nd Weyl sequence parameter, 32 bits
static consteval std::uint64_t WEYL_64_0()
First Weyl sequence parameter: the golden ratio.
constexpr auto high32Bits(std::uint64_t const x) -> std::uint32_t
Get high 32 bits of a 64-bit number.