@@ -41,16 +41,18 @@ class BasicCpuContext : public ComputeContext {
4141
4242 std::pair<std::size_t , bool > initiateCalculation (const std::size_t n, const std::size_t id = 0 ,
4343 const std::size_t version = 0 ,
44- const bool debug = false ) override final ;
44+ const Settings settings = {} ) override final ;
4545 std::size_t createInputVariable (double v) override final ;
4646 std::size_t createInputVariable (double * v) override final ;
47- std::vector<std::vector<std::size_t >> createInputVariates (const std::size_t dim, const std:: size_t steps,
48- const std::uint32_t seed ) override final ;
47+ std::vector<std::vector<std::size_t >> createInputVariates (const std::size_t dim,
48+ const std::size_t steps ) override final ;
4949 std::size_t applyOperation (const std::size_t randomVariableOpCode,
5050 const std::vector<std::size_t >& args) override final ;
5151 void freeVariable (const std::size_t id) override final ;
5252 void declareOutputVariable (const std::size_t id) override final ;
53- void finalizeCalculation (std::vector<double *>& output, const Settings& settings = Settings()) override final ;
53+ void finalizeCalculation (std::vector<double *>& output) override final ;
54+
55+ bool supportsDoublePrecision () const override { return true ; }
5456
5557 const DebugInfo& debugInfo () const override final ;
5658
@@ -100,7 +102,7 @@ class BasicCpuContext : public ComputeContext {
100102
101103 std::size_t currentId_ = 0 ;
102104 ComputeState currentState_ = ComputeState::idle;
103- bool debug_ ;
105+ Settings settings_ ;
104106 bool newCalc_;
105107
106108 std::vector<RandomVariable> values_;
@@ -140,12 +142,12 @@ void BasicCpuContext::init() {
140142}
141143
142144std::pair<std::size_t , bool > BasicCpuContext::initiateCalculation (const std::size_t n, const std::size_t id,
143- const std::size_t version, const bool debug ) {
145+ const std::size_t version, const Settings settings ) {
144146
145147 QL_REQUIRE (n > 0 , " BasicCpuContext::initiateCalculation(): n must not be zero" );
146148
147149 newCalc_ = false ;
148- debug_ = debug ;
150+ settings_ = settings ;
149151
150152 if (id == 0 ) {
151153
@@ -220,18 +222,21 @@ std::size_t BasicCpuContext::createInputVariable(double* v) {
220222 return numberOfInputVars_[currentId_ - 1 ]++;
221223}
222224
223- std::vector<std::vector<std::size_t >>
224- BasicCpuContext::createInputVariates ( const std:: size_t dim, const std:: size_t steps, const std::uint32_t seed ) {
225+ std::vector<std::vector<std::size_t >> BasicCpuContext::createInputVariates ( const std:: size_t dim,
226+ const std::size_t steps ) {
225227 QL_REQUIRE (currentState_ == ComputeState::createInput || currentState_ == ComputeState::createVariates,
226- " BasicCpuContext::createInputVariable (): not in state createInput or createVariates ("
228+ " BasicCpuContext::createInputVariates (): not in state createInput or createVariates ("
227229 << static_cast <int >(currentState_) << " )" );
228230 QL_REQUIRE (currentId_ > 0 , " BasicCpuContext::freeVariable(): current id is not set" );
229231 QL_REQUIRE (newCalc_, " BasicCpuContext::createInputVariates(): id (" << currentId_ << " ) in version "
230232 << version_[currentId_ - 1 ] << " is replayed." );
231233 currentState_ = ComputeState::createVariates;
232234
233235 if (rng_ == nullptr ) {
234- rng_ = std::make_unique<MersenneTwisterUniformRng>(seed);
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 );
235240 }
236241
237242 if (variates_.size () < dim * steps) {
@@ -282,7 +287,7 @@ std::size_t BasicCpuContext::applyOperation(const std::size_t randomVariableOpCo
282287
283288 // update num of ops in debug info
284289
285- if (debug_ )
290+ if (settings_. debug )
286291 debugInfo_.numberOfOperations += 1 * size_[currentId_ - 1 ];
287292
288293 // return result id
@@ -314,7 +319,7 @@ void BasicCpuContext::declareOutputVariable(const std::size_t id) {
314319 outputVars_[currentId_ - 1 ].push_back (id);
315320}
316321
317- void BasicCpuContext::finalizeCalculation (std::vector<double *>& output, const Settings& settings ) {
322+ void BasicCpuContext::finalizeCalculation (std::vector<double *>& output) {
318323 struct exitGuard {
319324 exitGuard () {}
320325 ~exitGuard () { *currentState = ComputeState::idle; }
@@ -331,7 +336,7 @@ void BasicCpuContext::finalizeCalculation(std::vector<double*>& output, const Se
331336
332337 const auto & p = program_[currentId_ - 1 ];
333338
334- auto ops = getRandomVariableOps (size_[currentId_ - 1 ], settings .regressionOrder );
339+ auto ops = getRandomVariableOps (size_[currentId_ - 1 ], settings_ .regressionOrder );
335340
336341 // resize values vector to required size
337342
0 commit comments