-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrng.h
More file actions
82 lines (63 loc) · 1.88 KB
/
rng.h
File metadata and controls
82 lines (63 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// SPDX-License-Identifier: Apache-2.0
// Copyright Contributors to the OpenQMC Project.
#pragma once
#include <oqmc/gpu.h>
#include <oqmc/sampler.h>
#include <oqmc/state.h>
#include <oqmc/unused.h>
#include <cstddef>
#include <cstdint>
class RngImpl
{
friend oqmc::SamplerInterface<RngImpl>;
static constexpr std::size_t cacheSize = 0;
static void initialiseCache(void* cache);
OQMC_HOST_DEVICE RngImpl() = default;
OQMC_HOST_DEVICE RngImpl(oqmc::State64Bit state);
OQMC_HOST_DEVICE RngImpl(int x, int y, int frame, int index,
const void* cache);
OQMC_HOST_DEVICE RngImpl newDomain(int key) const;
OQMC_HOST_DEVICE RngImpl newDomainSplit(int key, int size, int index) const;
OQMC_HOST_DEVICE RngImpl newDomainDistrib(int key, int index) const;
template <int Size>
OQMC_HOST_DEVICE void drawSample(std::uint32_t sample[Size]) const;
template <int Size>
OQMC_HOST_DEVICE void drawRnd(std::uint32_t rnd[Size]) const;
oqmc::State64Bit state;
};
inline void RngImpl::initialiseCache(void* cache)
{
OQMC_MAYBE_UNUSED(cache);
}
inline RngImpl::RngImpl(oqmc::State64Bit state) : state(state)
{
}
inline RngImpl::RngImpl(int x, int y, int frame, int index, const void* cache)
: state(x, y, frame, index)
{
OQMC_MAYBE_UNUSED(cache);
state = state.pixelDecorrelate();
}
inline RngImpl RngImpl::newDomain(int key) const
{
return {state.newDomain(key)};
}
inline RngImpl RngImpl::newDomainSplit(int key, int size, int index) const
{
return {state.newDomainSplit(key, size, index)};
}
inline RngImpl RngImpl::newDomainDistrib(int key, int index) const
{
return {state.newDomainDistrib(key, index)};
}
template <int Size>
void RngImpl::drawSample(std::uint32_t sample[Size]) const
{
drawRnd<Size>(sample);
}
template <int Size>
void RngImpl::drawRnd(std::uint32_t rnd[Size]) const
{
state.drawRnd<Size>(rnd);
}
using RngSampler = oqmc::SamplerInterface<RngImpl>;