DisCostiC v2.0.0
Distributed Cost in Cluster: a cross-architecture simulator for massively parallel MPI programs
Loading...
Searching...
No Matches
CompModel.hpp
Go to the documentation of this file.
1
7
8#ifndef COMPMODEL_HPP
9#define COMPMODEL_HPP
10
11#pragma once
12
13#include <numeric>
14#include <functional>
15#include <chrono>
16//#include <string>
17#include <vector>
18#include <algorithm>
19using namespace std::chrono;
20
21#include "macro.hpp"
22#include "YAMLParser.hpp"
23
24namespace DisCosTiC {
25
26 class CompModel {
27 private:
29
30 public:
33
38 /*CompModel( DisCosTiC_Timetype _unit_converter, DisCosTiC_Datatype node) :
39 unit_converter(_unit_converter),
40 node(node),
41 start_time(0)
42 {}*/
43
44
45
47 {
51 std::string micro_architecture = CFG_args->getValue<std::string>("micro_architecture");
52 DisCosTiC_Datatype FP_instructions_per_cycle = CFG_args->getValue<DisCosTiC_Datatype>("FP_instructions_per_cycle");
53 DisCosTiC_Datatype FP_ops_per_instruction_SP = YAML_args.FP_ops_per_instruction_SP;
54 DisCosTiC_Datatype FP_ops_per_instruction_DP = YAML_args.FP_ops_per_instruction_DP;
55 real_t clk_freq_in_GHz = YAML_args.clk_freq_in_GHz;
56 DisCosTiC_Datatype cores_per_chip = YAML_args.cores_per_chip;
57 static bool streaming_stores = CFG_args->getValue<bool>("streaming_stores");
58
59 std::vector<DisCosTiC_Datatype> cores(cores_per_chip) ;
60 std::iota (std::begin(cores), std::end(cores), 1);
61
65 DisCosTiC_Datatype FLOPs_per_cycle_SP = FP_instructions_per_cycle * FP_ops_per_instruction_SP;
66 DisCosTiC_Datatype FLOPs_per_cycle_DP = FP_instructions_per_cycle * FP_ops_per_instruction_DP;
67
68 real_t max_perf_per_core_SP = clk_freq_in_GHz * FLOPs_per_cycle_SP;
69 real_t max_perf_per_core_DP = clk_freq_in_GHz * FLOPs_per_cycle_DP;
70
72 std::vector<real_t> chip_max_perf_SP(cores_per_chip);
73 std::transform( cores.begin(),
74 cores.end(),
75 chip_max_perf_SP.begin(),
76 std::bind( std::multiplies<real_t>(),
77 std::placeholders::_1,
78 max_perf_per_core_SP ));
79
80 std::vector<real_t> chip_max_perf_DP(cores_per_chip);
81 std::transform(cores.begin(), cores.end(), chip_max_perf_DP.begin(),
82 std::bind(std::multiplies<real_t>(), std::placeholders::_1, max_perf_per_core_DP ));
83
84if (process_Rank == 0){
85 std::cout << "\n\n----------------------------------------------------------------"<< std::endl;
86 std::cout << "COMPUTATIONAL PERFORMANCE MODEL (Chip+Kernel):" << std::endl;
87 std::cout << "----------------------------------------------------------------"<< std::endl;
88 std::cout << "Core-bound workload on " << micro_architecture <<": " << std::endl;
89 std::cout << "cores: " ;
90 print_vec1T(cores);
91 std::cout << "single-precision maximum chip performance [GF/s]: ";
92 print_vec1T(chip_max_perf_SP);
93 std::cout << "double-precision maximum chip performance [GF/s]: ";
94 print_vec1T(chip_max_perf_DP);
95}
99// std::string benchmark_kernel = CFG_args->getValue<std::string>("benchmark_kernel");
100 DisCosTiC_Datatype FLOPs_per_iteration = CFG_args->getValue<DisCosTiC_Datatype>("FLOPs_per_iteration");
101 DisCosTiC_Datatype R_streams = CFG_args->getValue<DisCosTiC_Datatype>("R_streams");
102 //DisCosTiC_Datatype R_streams_in_bytes = CFG_args->getValue<DisCosTiC_Datatype>("R_streams_in_bytes");
103 DisCosTiC_Datatype W_streams = CFG_args->getValue<DisCosTiC_Datatype>("W_streams");
104 //DisCosTiC_Datatype W_streams_in_bytes = CFG_args->getValue<DisCosTiC_Datatype>("W_streams_in_bytes");
105 real_t datasize_in_GB = CFG_args->getValue<real_t>("datasize_in_GB");
106
111 real_t WA_factor;
112 if (streaming_stores){
113 R_streams = R_streams;
114 WA_factor = 1.0;
115 }
116 else{
117 real_t Read_streams = R_streams;
118 R_streams = R_streams + W_streams;
119 WA_factor = (R_streams + W_streams)/(Read_streams + W_streams) ; // Normal stores are performed (disables generation of streaming stores for optimization)
120 }
121
122 real_t MEMBw_1C = CFG_args->getValue<real_t>("MEMBw_1C_in_GBpers");
123 real_t MEMBw_2C = CFG_args->getValue<real_t>("MEMBw_2C_in_GBpers");
124 real_t MEMBw_3C = CFG_args->getValue<real_t>("MEMBw_3C_in_GBpers");
125 real_t MEMBw_4C = CFG_args->getValue<real_t>("MEMBw_4C_in_GBpers");
126 real_t MEMBw_5C = CFG_args->getValue<real_t>("MEMBw_5C_in_GBpers");
127 real_t MEMBw_6C = CFG_args->getValue<real_t>("MEMBw_6C_in_GBpers");
128 real_t MEMBw_7C = CFG_args->getValue<real_t>("MEMBw_7C_in_GBpers");
129 real_t MEMBw_8C = CFG_args->getValue<real_t>("MEMBw_8C_in_GBpers");
130 real_t MEMBw_9C = CFG_args->getValue<real_t>("MEMBw_9C_in_GBpers");
131 real_t MEMBw_10C = CFG_args->getValue<real_t>("MEMBw_10C_in_GBpers");
132
133 std::vector<real_t> MEM_bandwidth = YAML_args.MEM_bandwidth;
134
135
137 std::transform( MEM_bandwidth.begin(),
138 MEM_bandwidth.end(),
139 MEM_bandwidth.begin(),
140 std::bind( std::multiplies<real_t>(),
141 std::placeholders::_1,
142 WA_factor));
143
144 real_t bytes_transfered = (R_streams + W_streams) * sizeof(real_t);
145
146 real_t arith_intens_in_FLOPperB = FLOPs_per_iteration/bytes_transfered;
147
148 std::vector<real_t> perf_in_FLOPpers(cores_per_chip);
149 std::transform( MEM_bandwidth.begin(),
150 MEM_bandwidth.end(),
151 perf_in_FLOPpers.begin(),
152 std::bind( std::multiplies<real_t>(),
153 std::placeholders::_1,
154 arith_intens_in_FLOPperB));
155
156 std::vector<real_t> time_in_s(cores_per_chip);
157 std::transform (MEM_bandwidth.begin(), MEM_bandwidth.end(), time_in_s.begin(),
158 [&datasize_in_GB](double v) { return datasize_in_GB / v; });
159
160 // std::vector<DisCosTiC_Timetype> time_in_s = { datasize_in_GB/ MEMBw_1C, datasize_in_GB/ MEMBw_2C,
161 // datasize_in_GB / MEMBw_3C, datasize_in_GB / MEMBw_4C, datasize_in_GB / MEMBw_5C,
162 // datasize_in_GB / MEMBw_6C, datasize_in_GB / MEMBw_7C, datasize_in_GB / MEMBw_8C,
163 // datasize_in_GB / MEMBw_9C, datasize_in_GB / MEMBw_10C};
164
165 for (auto const& i : time_in_s)
166 {
167 if(i < 0)
168 throw std::runtime_error("negative operation time\n");
169 }
170
171 std::vector<DisCosTiC_Timetype> time_in_ns(cores_per_chip);
172 std::transform( time_in_s.begin(),
173 time_in_s.end(),
174 time_in_ns.begin(),
175 std::bind( std::multiplies<real_t>(),
176 std::placeholders::_1,
177 1000000000));
178if (process_Rank == 0){
179// std::cout << "\nMemory-bound (" << benchmark_kernel << ") on " << micro_architecture <<": " << std::endl;
180 std::cout << "\nCode running on " << micro_architecture <<": " << std::endl;
181 std::cout << "bytes transfer [B]: " << bytes_transfered << std::endl;
182 std::cout << "arithmetic intensity [F/B]: " << arith_intens_in_FLOPperB << std::endl;
183 std::cout << "memory bandwidth [GB/s]: " << std::endl;
184 print_vec1T(MEM_bandwidth);
185 std::cout << "performnace [GF/s]: " << std::endl;
186 print_vec1T(perf_in_FLOPpers);
187 std::cout << "runtime [ns]: " << std::endl;
188 print_vec1T(time_in_ns);
189}
190 }
191 };
192
193} // end namespace DisCosTiC
194
195#endif
UserInterface::ConfigParser CFG_args("config.cfg")
< configuration file parser
std::size_t DisCosTiC_Datatype
Definition DataType.hpp:52
double real_t
Definition DataType.hpp:48
double DisCosTiC_Timetype
Definition DataType.hpp:51
DisCosTiC_Timetype start_time
start time for this local operation
Definition CompModel.hpp:32
DisCosTiC_Datatype node
core to execute on
Definition CompModel.hpp:31
DisCosTiC_Timetype unit_converter
multiplier - relative to microseconds
Definition CompModel.hpp:28
CompModel(UserInterface::ConfigParser *CFG_args, UserInterface::YAMLParser YAML_args, int process_Rank)
constructor that initializes the coordinates for unit_converter, node and start time
Definition CompModel.hpp:46
a wrapper class which contains functions for parsing the configuration file end class configParser
scalarT getValue(const std::string &key, scalarT const &defaultValue=scalarT()) const
a function that retrieves the value of a specific key
end class YAMLParser
DisCosTiC_Datatype cores_per_chip
DisCosTiC_Datatype FP_ops_per_instruction_SP
std::vector< real_t > MEM_bandwidth
DisCosTiC_Datatype FP_ops_per_instruction_DP
#define print_vec1T(vec)
Definition macro.hpp:23
< benchmark test cases