1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
2 // Copyright (c) Lawrence Livermore National Security, LLC and other Ascent
3 // Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
4 // other details. No copyright assignment is required to contribute to Ascent.
5 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
6 
7 //-----------------------------------------------------------------------------
8 ///
9 /// file: ascent_mpi_render_2d.cpp
10 ///
11 //-----------------------------------------------------------------------------
12 
13 #include "gtest/gtest.h"
14 
15 #include <ascent.hpp>
16 
17 #include <iostream>
18 #include <math.h>
19 #include <mpi.h>
20 
21 #include <conduit_blueprint.hpp>
22 
23 #include "t_config.hpp"
24 #include "t_utils.hpp"
25 
26 using namespace std;
27 using namespace conduit;
28 using ascent::Ascent;
29 
30 //-----------------------------------------------------------------------------
31 // note: this example was a reproducer for tricky case
32 // involving multiple topos, pipelines + rendering.
TEST(ascent_mpi_mult_topo,test_multi_semi_madness)33 TEST(ascent_mpi_mult_topo, test_multi_semi_madness)
34 {
35     Node n;
36     ascent::about(n);
37     // only run this test if ascent was built with vtkm support
38     if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
39     {
40         ASCENT_INFO("Ascent support disabled, skipping MPI multi topo "
41                       "runtime test");
42         return;
43     }
44 
45 
46     //
47     // Set Up MPI
48     //
49     int par_rank;
50     int par_size;
51     MPI_Comm comm = MPI_COMM_WORLD;
52     MPI_Comm_rank(comm, &par_rank);
53     MPI_Comm_size(comm, &par_size);
54 
55     ASCENT_INFO("Rank "
56                   << par_rank
57                   << " of "
58                   << par_size
59                   << " reporting");
60     //
61     // Create the data.
62     //
63     Node data, verify_info;
64     create_example_multi_domain_multi_topo_dataset(data,par_rank,par_size);
65 
66     EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));
67 
68     // make sure the _output dir exists
69     string output_path = "";
70     if(par_rank == 0)
71     {
72         output_path = prepare_output_dir();
73     }
74     else
75     {
76         output_path = output_dir();
77     }
78 
79     string output_file = conduit::utils::join_file_path(output_path,
80                             "tout_render_mpi_multi_domain_multi_topo");
81 
82     // remove old images before rendering
83     remove_test_image(output_file);
84 
85     //
86     // Create the actions.
87     //
88 
89     conduit::Node actions;
90 
91     conduit::Node &add_plines = actions.append();
92     add_plines["action"] = "add_pipelines";
93     conduit::Node &pipelines = add_plines["pipelines"];
94     pipelines["pl1/f1/type"] = "threshold";
95     pipelines["pl1/f1/params/field"] = "ele_example";
96     pipelines["pl1/f1/params/min_value"] = 2.0;
97     pipelines["pl1/f1/params/max_value"] = 11112.0;
98 
99     conduit::Node &add_plots = actions.append();
100     add_plots["action"] = "add_scenes";
101     conduit::Node &scenes = add_plots["scenes"];
102     scenes["s1/plots/p1/type"]  = "pseudocolor";
103     scenes["s1/plots/p1/field"] = "ele_example";
104     scenes["s1/plots/p1/pipeline"] = "pl1";
105     scenes["s1/plots/p2/type"]  = "pseudocolor";
106     scenes["s1/plots/p2/field"] = "braid";
107     scenes["s1/image_prefix"] = output_file;
108 
109 
110     std::cout << actions.to_yaml() << std::endl;
111 
112     //
113     // Run Ascent
114     //
115 
116     Ascent ascent;
117 
118     Node ascent_opts;
119     // we use the mpi handle provided by the fortran interface
120     // since it is simply an integer
121     ascent_opts["mpi_comm"] = MPI_Comm_c2f(comm);
122     ascent_opts["runtime"] = "ascent";
123     ascent.open(ascent_opts);
124     ascent.publish(data);
125     ascent.execute(actions);
126     ascent.close();
127 
128     MPI_Barrier(comm);
129     // check that we created an image
130     // EXPECT_TRUE(check_test_image(output_file));
131 }
132 
133 
134 //-----------------------------------------------------------------------------
main(int argc,char * argv[])135 int main(int argc, char* argv[])
136 {
137     int result = 0;
138 
139     ::testing::InitGoogleTest(&argc, argv);
140     MPI_Init(&argc, &argv);
141     result = RUN_ALL_TESTS();
142     MPI_Finalize();
143 
144     return result;
145 }
146 
147 
148