ExaDG
Loading...
Searching...
No Matches
throughput.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2021 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef EXADG_COMPRESSIBLE_NAVIER_STOKES_THROUGHPUT_H_
23#define EXADG_COMPRESSIBLE_NAVIER_STOKES_THROUGHPUT_H_
24
25#ifdef EXADG_WITH_LIKWID
26# include <likwid.h>
27#endif
28
29// ExaDG
30#include <exadg/compressible_navier_stokes/driver.h>
31#include <exadg/compressible_navier_stokes/user_interface/declare_get_application.h>
32#include <exadg/operators/finite_element.h>
33#include <exadg/operators/hypercube_resolution_parameters.h>
34#include <exadg/operators/throughput_parameters.h>
35#include <exadg/utilities/general_parameters.h>
36
37namespace ExaDG
38{
39void
40create_input_file(std::string const & input_file)
41{
42 dealii::ParameterHandler prm;
43
44 GeneralParameters general;
45 general.add_parameters(prm);
46
48 resolution.add_parameters(prm);
49
51 throughput.add_parameters(prm);
52
53 try
54 {
55 // we have to assume a default dimension and default Number type
56 // for the automatic generation of a default input file
57 unsigned int const Dim = 2;
58 typedef double Number;
59 CompNS::get_application<Dim, Number>(input_file, MPI_COMM_WORLD)->add_parameters(prm);
60 }
61 catch(...)
62 {
63 }
64
65 prm.print_parameters(input_file,
66 dealii::ParameterHandler::Short |
67 dealii::ParameterHandler::KeepDeclarationOrder);
68}
69
70
71template<int dim, typename Number>
72void
74 std::string const & input_file,
75 unsigned int const degree,
76 unsigned int const refine_space,
77 unsigned int const n_cells_1d,
78 MPI_Comm const & mpi_comm,
79 bool const is_test)
80{
81 std::shared_ptr<CompNS::ApplicationBase<dim, Number>> application =
82 CompNS::get_application<dim, Number>(input_file, mpi_comm);
83
84 application->set_parameters_throughput_study(degree, refine_space, n_cells_1d);
85
86 std::shared_ptr<CompNS::Driver<dim, Number>> driver =
87 std::make_shared<CompNS::Driver<dim, Number>>(mpi_comm, application, is_test, true);
88
89 driver->setup();
90
91 std::tuple<unsigned int, dealii::types::global_dof_index, double> wall_time =
92 driver->apply_operator(throughput.operator_type,
93 throughput.n_repetitions_inner,
94 throughput.n_repetitions_outer);
95
96 throughput.wall_times.push_back(wall_time);
97}
98} // namespace ExaDG
99
100int
101main(int argc, char ** argv)
102{
103#ifdef EXADG_WITH_LIKWID
104 LIKWID_MARKER_INIT;
105#endif
106
107 dealii::Utilities::MPI::MPI_InitFinalize mpi(argc, argv, 1);
108
109 MPI_Comm mpi_comm(MPI_COMM_WORLD);
110
111 std::string input_file;
112
113 if(argc == 1)
114 {
115 if(dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0)
116 {
117 // clang-format off
118 std::cout << "To run the program, use: ./throughput input_file" << std::endl
119 << "To setup the input file, use: ./throughput input_file --help" << std::endl;
120 // clang-format on
121 }
122
123 return 0;
124 }
125 else if(argc >= 2)
126 {
127 input_file = std::string(argv[1]);
128
129 if(argc == 3 and std::string(argv[2]) == "--help")
130 {
131 if(dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0)
132 ExaDG::create_input_file(input_file);
133
134 return 0;
135 }
136 }
137
138 ExaDG::GeneralParameters general(input_file);
139 ExaDG::HypercubeResolutionParameters resolution(input_file, general.dim);
141
142 auto const lambda_get_dofs_per_element =
143 [&](unsigned int const dim, unsigned int const degree, ExaDG::ElementType const element_type) {
144 return ExaDG::get_dofs_per_element(
145 element_type, true /* is_dg */, dim + 2 /* n_components */, degree, dim);
146 };
147
148 // fill resolution vector depending on the operator_type
149 resolution.fill_resolution_vector(lambda_get_dofs_per_element);
150
151 // loop over resolutions vector and run simulations
152 for(auto iter = resolution.resolutions.begin(); iter != resolution.resolutions.end(); ++iter)
153 {
154 unsigned int const degree = std::get<0>(*iter);
155 unsigned int const refine_space = std::get<1>(*iter);
156 unsigned int const n_cells_1d = std::get<2>(*iter);
157
158 if(general.dim == 2 and general.precision == "float")
159 {
160 ExaDG::run<2, float>(
161 throughput, input_file, degree, refine_space, n_cells_1d, mpi_comm, general.is_test);
162 }
163 else if(general.dim == 2 and general.precision == "double")
164 {
165 ExaDG::run<2, double>(
166 throughput, input_file, degree, refine_space, n_cells_1d, mpi_comm, general.is_test);
167 }
168 else if(general.dim == 3 and general.precision == "float")
169 {
170 ExaDG::run<3, float>(
171 throughput, input_file, degree, refine_space, n_cells_1d, mpi_comm, general.is_test);
172 }
173 else if(general.dim == 3 and general.precision == "double")
174 {
175 ExaDG::run<3, double>(
176 throughput, input_file, degree, refine_space, n_cells_1d, mpi_comm, general.is_test);
177 }
178 else
179 {
180 AssertThrow(false,
181 dealii::ExcMessage("Only dim = 2|3 and precision=float|double implemented."));
182 }
183 }
184
185 if(not(general.is_test))
186 throughput.print_results(mpi_comm);
187
188#ifdef EXADG_WITH_LIKWID
189 LIKWID_MARKER_CLOSE;
190#endif
191
192 return 0;
193}
194
195#endif /* EXADG_COMPRESSIBLE_NAVIER_STOKES_THROUGHPUT_H_ */
Definition driver.cpp:33
Definition general_parameters.h:34
Definition hypercube_resolution_parameters.h:183
Definition throughput_parameters.h:91