MyraMath


Source: tests/jobgraph/SequentialJobGraph.cpp

1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
15 #include <myramath/jobgraph/detail/execute_serial.h>
18 
19 #include <tests/myratest.h>
20 
21 #include <cmath>
22 
23 #include <iostream>
24 
25 using namespace myra;
26 
27 ADD_TEST("SequentialJobGraph","[jobgraph]")
28  {
29  std::vector<double> a(4,1.0);
30  std::vector<double> b(4,2.0);
31  std::vector<double> c(4,0.0);
32  std::vector<double> d(4,0.0);
33  SequentialJobGraph graph;
34  graph.push_back( parallelize( make_LambdaJobGraph([&](){ c[0] = a[0]+b[0]; }), make_LambdaJobGraph([&](){ d[0] = a[0]+b[0]; }) ) );
35  graph.push_back( parallelize( make_LambdaJobGraph([&](){ c[1] = a[1]+b[1]; }), make_LambdaJobGraph([&](){ d[1] = a[1]+b[1]; }) ) );
36  graph.push_back( parallelize( make_LambdaJobGraph([&](){ c[2] = a[2]+b[2]; }), make_LambdaJobGraph([&](){ d[2] = a[2]+b[2]; }) ) );
37  graph.push_back( parallelize( make_LambdaJobGraph([&](){ c[3] = a[3]+b[3]; }), make_LambdaJobGraph([&](){ d[3] = a[3]+b[3]; }) ) );
38 
39 
40  // REQUIRE( verify(graph) );
41  graphviz(graph,"graph.dot");
42  // execute_serial(graph);
43 
44  /*
45  double tolerance = 1.0e-12;
46  REQUIRE(std::abs(c[0]-3.0)<tolerance);
47  REQUIRE(std::abs(c[1]-3.0)<tolerance);
48  REQUIRE(std::abs(c[2]-3.0)<tolerance);
49  REQUIRE(std::abs(c[3]-3.0)<tolerance);
50  REQUIRE(std::abs(d[0]-3.0)<tolerance);
51  REQUIRE(std::abs(d[1]-3.0)<tolerance);
52  REQUIRE(std::abs(d[2]-3.0)<tolerance);
53  REQUIRE(std::abs(d[3]-3.0)<tolerance);
54  */
55  }
56 
int push_back(const JobGraph &g)
Appends a JobGraph to *this, to be execute()&#39;d after all the previous Job&#39;s.
Definition: SequentialJobGraph.cpp:124
Given a JobGraph G, verifies it has valid topology.
Contains multiple JobGraph&#39;s, executes()&#39;s them in sequence.
Definition: SequentialJobGraph.h:30
Contains multiple JobGraph&#39;s, execute()&#39;s them in sequence. Used to avoid data hazards.
Definition: syntax.dox:1
Execute&#39;s a JobGraph.
Contains multiple independent JobGraph&#39;s, enabling them to execute() in parallel. ...
JobGraph make_LambdaJobGraph(const Lambda &lambda)
Given a Lambda, returns a JobGraph that calls lambda() when execute()&#39;d.
Definition: LambdaJobGraph.h:129
Given a JobGraph, produces a .dot file for visualization with graphviz.
Encapsulates a Lambda function into a JobGraph of a single Job.


Results: [PASS]


Go back to Summary of /test programs.