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 INCLUDE_EXADG_COMPRESSIBLE_NAVIER_STOKES_THROUGHPUT_H_
23#define INCLUDE_EXADG_COMPRESSIBLE_NAVIER_STOKES_THROUGHPUT_H_
24
25#ifdef EXADG_WITH_LIKWID
26# include <likwid.h>
27#endif
28
29// driver
30#include <exadg/compressible_navier_stokes/driver.h>
31
32// utilities
33#include <exadg/operators/finite_element.h>
34#include <exadg/operators/hypercube_resolution_parameters.h>
35#include <exadg/operators/throughput_parameters.h>
36#include <exadg/utilities/general_parameters.h>
37
38// application
39#include <exadg/compressible_navier_stokes/user_interface/declare_get_application.h>
40
41namespace ExaDG
42{
43void
44create_input_file(std::string const & input_file)
45{
46 dealii::ParameterHandler prm;
47
48 GeneralParameters general;
49 general.add_parameters(prm);
50
51 HypercubeResolutionParameters resolution;
52 resolution.add_parameters(prm);
53
54 ThroughputParameters<CompNS::OperatorType> throughput;
55 throughput.add_parameters(prm);
56
57 try
58 {
59 // we have to assume a default dimension and default Number type
60 // for the automatic generation of a default input file
61 unsigned int const Dim = 2;
62 typedef double Number;
63 CompNS::get_application<Dim, Number>(input_file, MPI_COMM_WORLD)->add_parameters(prm);
64 }
65 catch(...)
66 {
67 }
68
69 prm.print_parameters(input_file,
70 dealii::ParameterHandler::Short |
71 dealii::ParameterHandler::KeepDeclarationOrder);
72}
73
74
75template<int dim, typename Number>
76void
77run(ThroughputParameters<CompNS::OperatorType> const & throughput,
78 std::string const & input_file,
79 unsigned int const degree,
80 unsigned int const refine_space,
81 unsigned int const n_cells_1d,
82 MPI_Comm const & mpi_comm,
83 bool const is_test)
84{
85 std::shared_ptr<CompNS::ApplicationBase<dim, Number>> application =
86 CompNS::get_application<dim, Number>(input_file, mpi_comm);
87
88 application->set_parameters_throughput_study(degree, refine_space, n_cells_1d);
89
90 std::shared_ptr<CompNS::Driver<dim, Number>> driver =
91 std::make_shared<CompNS::Driver<dim, Number>>(mpi_comm, application, is_test, true);
92
93 driver->setup();
94
95 std::tuple<unsigned int, dealii::types::global_dof_index, double> wall_time =
96 driver->apply_operator(throughput.operator_type,
97 throughput.n_repetitions_inner,
98 throughput.n_repetitions_outer);
99
100 throughput.wall_times.push_back(wall_time);
101}
102} // namespace ExaDG
103
104int
105main(int argc, char ** argv)
106{
107#ifdef EXADG_WITH_LIKWID
108 LIKWID_MARKER_INIT;
109#endif
110
111 dealii::Utilities::MPI::MPI_InitFinalize mpi(argc, argv, 1);
112
113 MPI_Comm mpi_comm(MPI_COMM_WORLD);
114
115 std::string input_file;
116
117 if(argc == 1)
118 {
119 if(dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0)
120 {
121 // clang-format off
122 std::cout << "To run the program, use: ./throughput input_file" << std::endl
123 << "To setup the input file, use: ./throughput input_file --help" << std::endl;
124 // clang-format on
125 }
126
127 return 0;
128 }
129 else if(argc >= 2)
130 {
131 input_file = std::string(argv[1]);
132
133 if(argc == 3 and std::string(argv[2]) == "--help")
134 {
135 if(dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0)
136 ExaDG::create_input_file(input_file);
137
138 return 0;
139 }
140 }
141
142 ExaDG::GeneralParameters general(input_file);
143 ExaDG::HypercubeResolutionParameters resolution(input_file, general.dim);
145
146 auto const lambda_get_dofs_per_element =
147 [&](unsigned int const dim, unsigned int const degree, ExaDG::ElementType const element_type) {
148 return ExaDG::get_dofs_per_element(
149 element_type, true /* is_dg */, dim + 2 /* n_components */, degree, dim);
150 };
151
152 // fill resolution vector depending on the operator_type
153 resolution.fill_resolution_vector(lambda_get_dofs_per_element);
154
155 // loop over resolutions vector and run simulations
156 for(auto iter = resolution.resolutions.begin(); iter != resolution.resolutions.end(); ++iter)
157 {
158 unsigned int const degree = std::get<0>(*iter);
159 unsigned int const refine_space = std::get<1>(*iter);
160 unsigned int const n_cells_1d = std::get<2>(*iter);
161
162 if(general.dim == 2 and general.precision == "float")
163 {
164 ExaDG::run<2, float>(
165 throughput, input_file, degree, refine_space, n_cells_1d, mpi_comm, general.is_test);
166 }
167 else if(general.dim == 2 and general.precision == "double")
168 {
169 ExaDG::run<2, double>(
170 throughput, input_file, degree, refine_space, n_cells_1d, mpi_comm, general.is_test);
171 }
172 else if(general.dim == 3 and general.precision == "float")
173 {
174 ExaDG::run<3, float>(
175 throughput, input_file, degree, refine_space, n_cells_1d, mpi_comm, general.is_test);
176 }
177 else if(general.dim == 3 and general.precision == "double")
178 {
179 ExaDG::run<3, double>(
180 throughput, input_file, degree, refine_space, n_cells_1d, mpi_comm, general.is_test);
181 }
182 else
183 {
184 AssertThrow(false,
185 dealii::ExcMessage("Only dim = 2|3 and precision=float|double implemented."));
186 }
187 }
188
189 if(not(general.is_test))
190 throughput.print_results(mpi_comm);
191
192#ifdef EXADG_WITH_LIKWID
193 LIKWID_MARKER_CLOSE;
194#endif
195
196 return 0;
197}
198
199#endif /* INCLUDE_EXADG_COMPRESSIBLE_NAVIER_STOKES_THROUGHPUT_H_ */
Definition driver.cpp:33
Definition general_parameters.h:32
Definition hypercube_resolution_parameters.h:182
Definition throughput_parameters.h:92