Skip to content

Commit 11d9082

Browse files
pcaspersjenkins
authored andcommitted
Resolve QPR-12386 add mersenne twister to opencl
1 parent df601ba commit 11d9082

5 files changed

Lines changed: 282 additions & 121 deletions

File tree

Docs/ComputeEnvironment/computeenvironment.tex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ \subsection{Initiation of a calculation}
389389
\begin{minted}[fontsize=\footnotesize]{xml}
390390
std::tie(externalCalculationId_, newExternalCalc) =
391391
ComputeEnvironment::instance().context()
392-
.initiateCalculation(model_->size(), externalCalculationId_, cgVersion_);
392+
.initiateCalculation(model_->size(), externalCalculationId_, cgVersion_, settings);
393393
\end{minted}
394394

395395
providing
@@ -400,6 +400,8 @@ \subsection{Initiation of a calculation}
400400
to get a new id and for subsequent calculations of the same trade this id is reused
401401
\item \verb+cgVersion_+: a version number (initially zero). The version is incremented whenever a repricing requires a
402402
different sequence of operations to be performed, which is the case when the evaluation date changes
403+
\item \verb+settings+: the settings to be used, see \ref{implComputeFramework} for details. Notice that for a replayed
404+
calculation the settings must match the ones from the initial calculation.
403405
\end{itemize}
404406

405407
and retrieving the external calc id and a flag indicating whether the calculation requires a resubmission of an

OREData/ored/scripting/engines/scriptedinstrumentpricingenginecg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ void ScriptedInstrumentPricingEngineCG::calculate() const {
186186
settings.debug = false;
187187
settings.useDoublePrecision = useDoublePrecisionForExternalCalculation_;
188188
settings.rngSequenceType = mcParams_.sequenceType;
189-
settings.seed = mcParams_.seed;
189+
settings.rngSeed = mcParams_.seed;
190190
settings.regressionOrder = mcParams_.regressionOrder;
191191
std::tie(externalCalculationId_, newExternalCalc) =
192192
ComputeEnvironment::instance().context().initiateCalculation(model_->size(), externalCalculationId_,

QuantExt/qle/math/basiccpuenvironment.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,7 @@ std::vector<std::vector<std::size_t>> BasicCpuContext::createInputVariates(const
233233
currentState_ = ComputeState::createVariates;
234234

235235
if (rng_ == nullptr) {
236-
QL_REQUIRE(settings_.rngSequenceType == QuantExt::SequenceType::MersenneTwister,
237-
"BasiCpuContext::createInputVariates(): sequence type "
238-
<< settings_.rngSequenceType << " not supported, expected 'MersenneTwister'");
239-
rng_ = std::make_unique<MersenneTwisterUniformRng>(settings_.seed);
236+
rng_ = std::make_unique<MersenneTwisterUniformRng>(settings_.rngSeed);
240237
}
241238

242239
if (variates_.size() < dim * steps) {

QuantExt/qle/math/computeenvironment.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ class ComputeContext {
6666
struct Settings {
6767
Settings()
6868
: debug(false), useDoublePrecision(false), rngSequenceType(QuantExt::SequenceType::MersenneTwister),
69-
seed(42), regressionOrder(4) {}
69+
rngSeed(42), regressionOrder(4) {}
7070
bool debug;
7171
bool useDoublePrecision;
7272
QuantExt::SequenceType rngSequenceType;
73-
std::size_t seed;
73+
std::size_t rngSeed;
7474
std::size_t regressionOrder;
7575
};
7676

0 commit comments

Comments
 (0)