Skip to content

Commit 2b269d3

Browse files
pcaspersjenkins
authored andcommitted
QPR-12386 remove test, hardcoded node ids might change in (correct) implementations and then this test will break
1 parent 1c28562 commit 2b269d3

1 file changed

Lines changed: 0 additions & 196 deletions

File tree

QuantExt/test/computeenvironment.cpp

Lines changed: 0 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -259,202 +259,6 @@ BOOST_AUTO_TEST_CASE(testReplayFlowError) {
259259
}
260260
}
261261

262-
// The code below replicates the behavior of one iteration of one of our static backtests
263-
// when executed on our GPGPU Framework.
264-
namespace {
265-
double externalAverage(const std::vector<double>& v) {
266-
boost::accumulators::accumulator_set<double, boost::accumulators::stats<boost::accumulators::tag::mean>> acc;
267-
for (auto const& x : v)
268-
acc(x);
269-
return boost::accumulators::mean(acc);
270-
}
271-
struct S0 {
272-
std::size_t randomVariableOpCode;
273-
std::vector<std::size_t> args;
274-
std::vector<bool> vb;
275-
};
276-
void runBacktest(const std::string &d, const std::size_t id, const std::vector<S0>& v0, double expected) {
277-
278-
BOOST_TEST_MESSAGE("testing backtest iteration on device '" << d << "'.");
279-
ComputeEnvironment::instance().selectContext(d);
280-
281-
const std::size_t n = 10000;
282-
std::size_t externalCalculationId_ = 0;
283-
bool newExternalCalc;
284-
ComputeContext::Settings settings;
285-
settings.regressionOrder = 2;
286-
std::tie(externalCalculationId_, newExternalCalc) =
287-
ComputeEnvironment::instance().context().initiateCalculation(n, externalCalculationId_, 1, settings);
288-
constexpr double max = std::numeric_limits<float>::max();
289-
290-
std::vector<double> v1 = {
291-
-56340, -39240, -37560, -37380, -35460, -30960, -26220, -26160, -24920, -24060, -22820,
292-
-22680, -20640, -18780, -18540, -17480, -16680, -15960, -15380, -15120, -14100, -13380,
293-
-13140, -13080, -13020, -12460, -11120, -10640, -10320, -9480, -9400, -9020, -8920,
294-
-8760, -8740, -8540, -7560, -7300, -7260, -6820, -6320, -5560, -5320, -4820,
295-
-4700, -4460, -4380, -3160, -2, -1, -0.0939, -0.0654, -0.0623, -0.0516, -0.0437,
296-
-0.0378, -0.0278, -0.0266, -0.0235, -0.0223, -0.0219, -0.0158, 0, 0.003, 0.0075, 0.5,
297-
0.8434, 0.8719, 0.875, 0.8857, 0.8936, 0.8995, 0.9095, 0.9107, 0.9138, 0.915, 0.9154,
298-
0.9215, 0.9373, 0.9403, 0.9448, 1, 2, 3, 15, 30, 600, 1200,
299-
1500, 2100, 3000, 30000, 187460, 200000, 400000, max, 0.0242777, 0.000589407, 0.99513,
300-
0.998575, -0.172332, 0.998575};
301-
302-
for (const auto& x : v1)
303-
ComputeEnvironment::instance().context().createInputVariable(x);
304-
305-
std::vector<std::vector<std::size_t>> rv = {{11}};
306-
auto gen = ComputeEnvironment::instance().context().createInputVariates(rv.size(), rv.front().size());
307-
308-
for (const auto& s : v0) {
309-
ComputeEnvironment::instance().context().applyOperation(s.randomVariableOpCode, s.args);
310-
int i = 0;
311-
for (const auto& b : s.vb) {
312-
if (b)
313-
ComputeEnvironment::instance().context().freeVariable(s.args[i]);
314-
i++;
315-
}
316-
}
317-
ComputeEnvironment::instance().context().declareOutputVariable(id);
318-
319-
std::vector<std::vector<double>> externalOutput_ = std::vector<std::vector<double>>(1, std::vector<double>(n));
320-
std::vector<double*> externalOutputPtr_ = std::vector<double*>(1, &externalOutput_.front()[0]);
321-
ComputeEnvironment::instance().context().finalizeCalculation(externalOutputPtr_);
322-
auto baseNpv_ = externalAverage(externalOutput_[0]);
323-
BOOST_CHECK_CLOSE(baseNpv_, expected, 1E-3);
324-
}
325-
} // namespace
326-
327-
BOOST_AUTO_TEST_CASE(testBacktest) {
328-
329-
ComputeEnvironmentFixture fixture;
330-
std::size_t id;
331-
double expected;
332-
std::vector<S0> v;
333-
for (auto const& d : ComputeEnvironment::instance().getAvailableDevices()) {
334-
335-
if (d == "BasicCpu/Default/Default") {
336-
id = 78;
337-
expected = -39400;
338-
v = {
339-
{5, {99, 98}, {false, false}},
340-
{4, {65, 97}, {true, false}},
341-
{15, {103}, {true}},
342-
{3, {65}, {true}},
343-
{2, {103, 104}, {true, true}},
344-
{13, {100}, {false}},
345-
{4, {96, 102}, {false, true}},
346-
{1, {100, 103}, {false, true}},
347-
{1, {105, 65}, {true, true}},
348-
{13, {103}, {true}},
349-
{8, {65, 62}, {false, false}},
350-
{8, {65, 78}, {false, false}},
351-
{2, {81, 105}, {false, true}},
352-
{4, {103, 106}, {true, true}},
353-
{2, {65, 78}, {false, false}},
354-
{4, {94, 106}, {true, true}},
355-
{4, {105, 103}, {false, true}},
356-
{2, {81, 105}, {false, true}},
357-
{8, {65, 78}, {false, false}},
358-
{8, {65, 95}, {false, true}},
359-
{2, {81, 94}, {false, true}},
360-
{4, {105, 95}, {true, true}},
361-
{2, {65, 78}, {true, true}},
362-
{4, {93, 95}, {true, true}},
363-
{1, {106, 78}, {false, true}},
364-
{4, {94, 95}, {false, true}},
365-
{2, {81, 94}, {false, true}},
366-
{4, {95, 106}, {true, true}},
367-
{1, {78, 94}, {true, true}},
368-
{9, {106, 62}, {false, true}},
369-
{1, {89, 106}, {false, false}},
370-
{4, {94, 62}, {false, true}},
371-
{2, {81, 94}, {false, false}},
372-
{4, {62, 89}, {true, true}},
373-
{1, {78, 95}, {true, true}},
374-
{4, {94, 83}, {false, true}},
375-
{2, {81, 94}, {false, true}},
376-
{4, {83, 82}, {true, true}},
377-
{1, {95, 94}, {true, true}},
378-
{9, {89, 91}, {true, true}},
379-
{2, {81, 94}, {false, false}},
380-
{2, {81, 94}, {false, false}},
381-
{5, {81, 101}, {false, false}},
382-
{5, {81, 95}, {false, true}},
383-
{4, {106, 83}, {false, false}},
384-
{4, {94, 95}, {false, true}},
385-
{2, {81, 94}, {false, false}},
386-
{2, {81, 94}, {false, true}},
387-
{4, {106, 83}, {true, true}},
388-
{1, {78, 94}, {false, true}},
389-
{4, {62, 83}, {false, true}},
390-
{2, {81, 62}, {true, true}},
391-
{4, {83, 78}, {true, true}},
392-
{1, {94, 62}, {true, true}},
393-
};
394-
} else {
395-
id = 111;
396-
expected = -39438;
397-
v = {
398-
{5, {99, 98}, {false, false}},
399-
{4, {65, 97}, {true, false}},
400-
{15, {103}, {true}},
401-
{3, {105}, {true}},
402-
{2, {103, 104}, {true, true}},
403-
{13, {100}, {false}},
404-
{4, {96, 102}, {false, true}},
405-
{1, {100, 103}, {false, true}},
406-
{1, {102, 105}, {true, true}},
407-
{13, {103}, {true}},
408-
{8, {105, 62}, {false, false}},
409-
{8, {105, 78}, {false, false}},
410-
{2, {81, 102}, {false, true}},
411-
{4, {103, 106}, {true, true}},
412-
{2, {105, 78}, {false, false}},
413-
{4, {94, 106}, {true, true}},
414-
{4, {102, 103}, {false, true}},
415-
{2, {81, 102}, {false, true}},
416-
{8, {105, 78}, {false, false}},
417-
{8, {105, 95}, {false, true}},
418-
{2, {81, 107}, {false, true}},
419-
{4, {102, 108}, {true, true}},
420-
{2, {105, 78}, {true, true}},
421-
{4, {93, 108}, {true, true}},
422-
{1, {106, 105}, {false, true}},
423-
{4, {107, 108}, {false, true}},
424-
{2, {81, 107}, {false, true}},
425-
{4, {108, 106}, {true, true}},
426-
{1, {105, 107}, {true, true}},
427-
{9, {106, 62}, {false, true}},
428-
{1, {89, 106}, {false, false}},
429-
{4, {107, 105}, {false, true}},
430-
{2, {81, 107}, {false, false}},
431-
{4, {105, 89}, {true, true}},
432-
{1, {108, 102}, {true, true}},
433-
{4, {107, 83}, {false, true}},
434-
{2, {81, 107}, {false, true}},
435-
{4, {108, 82}, {true, true}},
436-
{1, {102, 107}, {true, true}},
437-
{9, {105, 91}, {true, true}},
438-
{2, {81, 107}, {false, false}},
439-
{2, {81, 107}, {false, false}},
440-
{5, {81, 101}, {false, false}},
441-
{5, {81, 109}, {false, true}},
442-
{4, {106, 110}, {false, false}},
443-
{4, {107, 109}, {false, true}},
444-
{2, {81, 107}, {false, false}},
445-
{2, {81, 107}, {false, true}},
446-
{4, {106, 110}, {true, true}},
447-
{1, {111, 107}, {false, true}},
448-
{4, {112, 110}, {false, true}},
449-
{2, {81, 112}, {true, true}},
450-
{4, {110, 111}, {true, true}},
451-
{1, {107, 112}, {true, true}},
452-
};
453-
}
454-
runBacktest(d, id, v, expected);
455-
}
456-
}
457-
458262
BOOST_AUTO_TEST_SUITE_END()
459263

460264
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)