FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
statistics.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
9#include <kernel/util/dist.hpp>
10#include <kernel/util/statistics.hpp>
11#include <kernel/util/memory_usage.hpp>
12
13namespace FEAT
14{
15 namespace Control
16 {
18 {
19 public:
20
31 template <typename SystemLevelType_, typename DomainType_>
32 static void report(double solver_toe, int statistics_check, int DOXY(shape_dimension),
33 std::deque<std::shared_ptr<SystemLevelType_>> & system_levels,
34 DomainType_ & domain)
35 {
37 int rank(comm.rank());
38 int nranks(comm.size());
39
40 FEAT::Statistics::toe_solve = solver_toe;
41
42 std::size_t la_size(0);
43 std::size_t mpi_size(0);
44 for(const auto& sl : system_levels)
45 {
46 la_size += sl->bytes();
47 mpi_size += sl->gate_sys.bytes() + sl->coarse_muxer_sys.bytes();
48 }
49
50 String op_timings = FEAT::Statistics::get_formatted_times(solver_toe);
51
52 Index cells_coarse_local = domain.back()->get_mesh().get_num_elements();
53 Index cells_coarse_max;
54 Index cells_coarse_min;
55 comm.allreduce(&cells_coarse_local, &cells_coarse_max, std::size_t(1), Dist::op_max);
56 comm.allreduce(&cells_coarse_local, &cells_coarse_min, std::size_t(1), Dist::op_min);
57 Index cells_fine_local = domain.front()->get_mesh().get_num_elements();
58 Index cells_fine_max;
59 Index cells_fine_min;
60 comm.allreduce(&cells_fine_local, &cells_fine_max, std::size_t(1), Dist::op_max);
61 comm.allreduce(&cells_fine_local, &cells_fine_min, std::size_t(1), Dist::op_min);
62
63 Index dofs_coarse_local = system_levels.back()->matrix_sys.local().columns();
64 Index dofs_coarse_max;
65 Index dofs_coarse_min;
66 comm.allreduce(&dofs_coarse_local, &dofs_coarse_max, std::size_t(1), Dist::op_max);
67 comm.allreduce(&dofs_coarse_local, &dofs_coarse_min, std::size_t(1), Dist::op_min);
68 Index dofs_fine_local = system_levels.front()->matrix_sys.local().columns();
69 Index dofs_fine_max;
70 Index dofs_fine_min;
71 comm.allreduce(&dofs_fine_local, &dofs_fine_max, std::size_t(1), Dist::op_max);
72 comm.allreduce(&dofs_fine_local, &dofs_fine_min, std::size_t(1), Dist::op_min);
73
74 Index nzes_coarse_local = system_levels.back()->matrix_sys.local().used_elements();
75 Index nzes_coarse_max;
76 Index nzes_coarse_min;
77 comm.allreduce(&nzes_coarse_local, &nzes_coarse_max, std::size_t(1), Dist::op_max);
78 comm.allreduce(&nzes_coarse_local, &nzes_coarse_min, std::size_t(1), Dist::op_min);
79 Index nzes_fine_local = system_levels.front()->matrix_sys.local().used_elements();
80 Index nzes_fine_max;
81 Index nzes_fine_min;
82 comm.allreduce(&nzes_fine_local, &nzes_fine_max, std::size_t(1), Dist::op_max);
83 comm.allreduce(&nzes_fine_local, &nzes_fine_min, std::size_t(1), Dist::op_min);
84
85 if (rank == 0 && statistics_check >= 0)
86 {
87 std::cout<< "\n";
88 std::cout << String("TOE partition:").pad_back(20) << FEAT::Statistics::toe_partition << "\n";
89 std::cout << String("TOE assembly:").pad_back(20) << FEAT::Statistics::toe_assembly << "\n";
90 std::cout << String("TOE solve:").pad_back(20) << FEAT::Statistics::toe_solve << "\n";
91 std::cout << "\n" << FEAT::Statistics::get_formatted_solver_tree().trim() <<"\n";
92
93 String flops = FEAT::Statistics::get_formatted_flops(solver_toe, nranks);
94 std::cout<<flops<<"\n\n";
95 std::cout<<op_timings<<"\n\n";
96 std::cout<<String("Domain size:").pad_back(20) << double(domain.bytes()) / (1024. * 1024.) << " MByte\n";
97 std::cout<<String("MPI size:").pad_back(20) << double(mpi_size) / (1024. * 1024.) << " MByte\n";
98 std::cout<<String("LA size:").pad_back(20) << double(la_size) / (1024. * 1024.) << " MByte\n\n";
99 MemoryUsage mu;
100 std::cout<<mu.get_formatted_memory_usage()<<"\n";
101 std::cout<<String("#Mesh cells:").pad_back(20) << "coarse " << cells_coarse_max << "/" << cells_coarse_min << ", fine " << cells_fine_max << "/" << cells_fine_min << "\n";
102 std::cout<<String("#DOFs:").pad_back(20) << "coarse " << dofs_coarse_max << "/" << dofs_coarse_min << ", fine " << dofs_fine_max << "/" << dofs_fine_min << "\n";
103 std::cout<<String("#NZEs").pad_back(20) << "coarse " << nzes_coarse_max << "/" << nzes_coarse_min << ", fine " << nzes_fine_max << "/" << nzes_fine_min << "\n";
104 std::cout<<"\n";
105 }
106 if (statistics_check > 0) // provided parameter full or whatever
107 {
109 /*FEAT::Statistics::write_out_solver_statistics_scheduled(rank, la_size, domain.bytes(), mpi_size,
110 domain.get_levels().back()->get_mesh().get_num_entities(shape_dimension), (*system_levels.back()->matrix_sys).columns(),
111 (*system_levels.back()->matrix_sys).used_elements());*/
112 }
113 }
114
115 }; // StatisticsControl
116 } // namespace Control
117} // namespace FEAT
FEAT Kernel base header.
static void report(double solver_toe, int statistics_check, int shape_dimension, std::deque< std::shared_ptr< SystemLevelType_ > > &system_levels, DomainType_ &domain)
Create a detailed report about the application execution.
Definition: statistics.hpp:32
Communicator class.
Definition: dist.hpp:1349
void allreduce(const void *sendbuf, void *recvbuf, std::size_t count, const Datatype &datatype, const Operation &op) const
Blocking All-Reduce.
Definition: dist.cpp:655
int size() const
Returns the size of this communicator.
Definition: dist.hpp:1506
int rank() const
Returns the rank of this process in this communicator.
Definition: dist.hpp:1494
static Comm world()
Returns a copy of the world communicator.
Definition: dist.cpp:429
Memory usage info object.
String get_formatted_memory_usage() const
Retrieve formatted memory usage string.
static String get_formatted_solver_tree(String target="default")
Returns a descriptive string of the complete solver tree.
Definition: statistics.hpp:361
static String get_formatted_times(double total_time)
Retrieve formatted time consumption overview in percent relative to some provided total time.
Definition: statistics.cpp:473
static double toe_solve
time of solution in seconds, needs initialization
Definition: statistics.hpp:171
static String get_formatted_flops(double seconds, int ranks=1)
Retrieve formatted flops per second string.
Definition: statistics.hpp:218
static double toe_partition
time of partitioning in seconds, needs initialization
Definition: statistics.hpp:167
static double toe_assembly
time of assembly in seconds, needs initialization
Definition: statistics.hpp:169
String class implementation.
Definition: string.hpp:46
String pad_back(size_type len, char c=' ') const
Pads the back of the string up to a desired length.
Definition: string.hpp:415
String trim(const String &charset) const
Trims the string.
Definition: string.hpp:327
const Operation op_min(MPI_MIN)
Operation wrapper for MPI_MIN.
Definition: dist.hpp:275
const Operation op_max(MPI_MAX)
Operation wrapper for MPI_MAX.
Definition: dist.hpp:273
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.