OpenQMC API
Loading...
Searching...
No Matches
lookup.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright Contributors to the OpenQMC Project.
3
9
10#pragma once
11
12#include "gpu.h"
13#include "permute.h"
14#include "rotate.h"
15
16#include <cassert>
17#include <cstdint>
18
19namespace oqmc
20{
21
34OQMC_HOST_DEVICE constexpr std::uint32_t
35randomDigitScramble(std::uint32_t value, std::uint32_t hash)
36{
37 return value ^ hash;
38}
39
56template <int Table, int Depth>
57OQMC_HOST_DEVICE inline void
58shuffledScrambledLookup(std::uint32_t index, std::uint32_t hash,
59 const std::uint32_t table[][Table],
60 std::uint32_t sample[Depth])
61{
62 static_assert(Table >= Depth, "Table size is greater or equal to Depth.");
63 static_assert(Depth >= 1, "Pattern depth is greater or equal to one.");
64 static_assert(Depth <= 4, "Pattern depth is less or equal to four.");
65
66 index = shuffle(index, hash);
67
68 for(int i = 0; i < Depth; ++i)
69 {
70 constexpr auto indexMask = 0xffff;
71
72 sample[i] = table[index & indexMask][i];
74 }
75}
76
77} // namespace oqmc
#define OQMC_HOST_DEVICE
Definition gpu.h:13
constexpr std::uint32_t rotateBytes(std::uint32_t value, int distance)
Rotate bytes in an integer value.
Definition rotate.h:41
EncodeKey decodeBits16(std::uint16_t value)
Decode a value back into a key.
Definition encode.h:81
constexpr std::uint32_t shuffle(std::uint32_t value, std::uint32_t seed)
Compute a hash based owen scramble.
Definition permute.h:73
void shuffledScrambledLookup(std::uint32_t index, std::uint32_t hash, const std::uint32_t table[][Table], std::uint32_t sample[Depth])
Compute a randomised value from a pre-computed table.
Definition lookup.h:58
constexpr std::uint32_t randomDigitScramble(std::uint32_t value, std::uint32_t hash)
Random digit scramble an element in a sequence.
Definition lookup.h:35
Definition bntables.h:21