MyraMath


Source: tests/jobgraph/UserJobGraph.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 
11 // JobGraph bits.
16 
17 // Reporting.
18 #include <tests/myratest.h>
19 
20 using namespace myra;
21 
22 ADD_TEST("UserJobGraph","[jobgraph]")
23  {
24  // Local variables.
25  int x = 0;
26  int y = 0;
27  int z = 0;
28  // Add jobs.
29  UserJobGraph graph;
30  uint64_t jx = graph.insert([&x](){ x=4; },"x=4");
31  uint64_t jy = graph.insert([&y](){ y=5; },"y=5");
32  uint64_t jsum = graph.insert([&x,&y,&z](){ z=x+y; },"z=x+y");
33  uint64_t jprint = graph.insert([&z](){ myra::out() << "z = " << z << std::endl; }, "print z");
34  // Add dependencies (edges) between jobs.
35  graph.add_edge(jx,jsum);
36  graph.add_edge(jy,jsum);
37  graph.add_edge(jsum,jprint);
38  // Check essential properties.
39  verify(graph);
40  graphviz(graph,"UserJobGraph.dot");
41  // Run graph.
42  execute(graph);
43  // Verify z = 9.
44  REQUIRE(z == 9);
45  }
uint64_t insert(const Functor &f)
Inserts a Job (in the form of a C++11 lambda) to this JobGraph, returns its unique JobID...
Definition: UserJobGraph.h:139
Given a JobGraph G, verifies it has valid topology.
Definition: syntax.dox:1
Execute&#39;s a JobGraph.
void add_edge(uint64_t j0, uint64_t j1)
Adds a dependency, that Job j0 must execute before Job j1.
Definition: UserJobGraph.h:159
Container-like JobGraph class, can be manually populated with user-defined Job&#39;s and dependencies...
Container-like JobGraph class, can be manually populated with user-defined Job&#39;s and dependencies...
Definition: UserJobGraph.h:31
Given a JobGraph, produces a .dot file for visualization with graphviz.


Results: [PASS]

z = 9


Go back to Summary of /test programs.