OpenQMC API
Loading...
Searching...
No Matches
bntables.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright Contributors to the OpenQMC Project.
3
12
13#pragma once
14
15#include "encode.h"
16#include "gpu.h"
17
18#include <cstdint>
19
20namespace oqmc
21{
22
23namespace bntables
24{
25
31{
32 std::uint32_t key;
33 std::uint32_t rank;
34};
35
50template <int XBits, int YBits, int ZBits>
52tableValue(std::uint16_t pixel, std::uint16_t shift,
53 const std::uint32_t keyTable[], const std::uint32_t rankTable[])
54{
55 const auto pixelOffset = decodeBits16<XBits, YBits, ZBits>(pixel);
57
58 const auto x = pixelOffset.x + shiftOffset.x;
59 const auto y = pixelOffset.y + shiftOffset.y;
60 const auto z = pixelOffset.z + shiftOffset.z;
61 const auto index = encodeBits16<XBits, YBits, ZBits>({x, y, z});
62
63 return {
64 keyTable[index],
65 rankTable[index],
66 };
67}
68
69constexpr auto xBits = 8;
70constexpr auto yBits = 8;
71constexpr auto size = 1 << (xBits + yBits);
72
73static_assert(xBits == yBits,
74 "Optimisation tables have equal resolution in x and y");
75
76// Following optimised blue noise randomisation values were generated using the
77// optimise cli tool found in the source file src/tools/lib/optimise.cpp.
78
79namespace pmj
80{
81
82#if defined(OQMC_ENABLE_BINARY)
83
85extern const std::uint32_t keyTable[size];
86
88extern const std::uint32_t rankTable[size];
89
90#else
91
93constexpr std::uint32_t keyTable[] = {
94#include "data/pmj/keys.txt"
95};
96
98constexpr std::uint32_t rankTable[] = {
99#include "data/pmj/ranks.txt"
100};
101
102#endif
103
104} // namespace pmj
105
106namespace sobol
107{
108
109#if defined(OQMC_ENABLE_BINARY)
110
112extern const std::uint32_t keyTable[size];
113
115extern const std::uint32_t rankTable[size];
116
117#else
118
120constexpr std::uint32_t keyTable[] = {
121#include "data/sobol/keys.txt"
122};
123
125constexpr std::uint32_t rankTable[] = {
126#include "data/sobol/ranks.txt"
127};
128
129#endif
130
131} // namespace sobol
132
133namespace lattice
134{
135
136#if defined(OQMC_ENABLE_BINARY)
137
139extern const std::uint32_t keyTable[size];
140
142extern const std::uint32_t rankTable[size];
143
144#else
145
147constexpr std::uint32_t keyTable[] = {
148#include "data/lattice/keys.txt"
149};
150
152constexpr std::uint32_t rankTable[] = {
153#include "data/lattice/ranks.txt"
154};
155
156#endif
157
158} // namespace lattice
159
160} // namespace bntables
161
162} // namespace oqmc
#define OQMC_HOST_DEVICE
Definition gpu.h:13
int y
y axis coordinate.
Definition encode.h:27
int z
z axis coordinate.
Definition encode.h:28
int x
x axis coordinate.
Definition encode.h:26
EncodeKey decodeBits16(std::uint16_t value)
Decode a value back into a key.
Definition encode.h:81
constexpr std::uint32_t rankTable[]
Optimised blue noise rank table for lattice.
Definition bntables.h:152
constexpr std::uint32_t keyTable[]
Optimised blue noise key table for lattice.
Definition bntables.h:147
constexpr std::uint32_t keyTable[]
Optimised blue noise key table for pmj.
Definition bntables.h:93
constexpr std::uint32_t rankTable[]
Optimised blue noise rank table for pmj.
Definition bntables.h:98
constexpr std::uint32_t rankTable[]
Optimised blue noise rank table for sobol.
Definition bntables.h:125
constexpr std::uint32_t keyTable[]
Optimised blue noise key table for sobol.
Definition bntables.h:120
constexpr auto size
2^16 table size.
Definition bntables.h:71
constexpr auto yBits
256 pixels in y.
Definition bntables.h:70
constexpr auto xBits
256 pixels in x.
Definition bntables.h:69
constexpr TableReturnValue tableValue(std::uint16_t pixel, std::uint16_t shift, const std::uint32_t keyTable[], const std::uint32_t rankTable[])
Lookup value pair from table.
Definition bntables.h:52
Definition bntables.h:21
Return type for table value.
Definition bntables.h:31
std::uint32_t rank
rank value to shuffle.
Definition bntables.h:33
std::uint32_t key
key value to randomise.
Definition bntables.h:32