MCPcopy Create free account
hub / github.com/PX4/eigen / run

Method run

bench/benchmark-blocking-sizes.cpp:153–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153void benchmark_t::run()
154{
155 size_triple_t productsizes(compact_product_size);
156
157 if (use_default_block_size) {
158 eigen_use_specific_block_size = false;
159 } else {
160 // feed eigen with our custom blocking params
161 eigen_use_specific_block_size = true;
162 size_triple_t blocksizes(compact_block_size);
163 eigen_block_size_k = blocksizes.k;
164 eigen_block_size_m = blocksizes.m;
165 eigen_block_size_n = blocksizes.n;
166 }
167
168 // set up the matrix pool
169
170 const size_t combined_three_matrices_sizes =
171 sizeof(Scalar) *
172 (productsizes.k * productsizes.m +
173 productsizes.k * productsizes.n +
174 productsizes.m * productsizes.n);
175
176 // 64 M is large enough that nobody has a cache bigger than that,
177 // while still being small enough that everybody has this much RAM,
178 // so conveniently we don't need to special-case platforms here.
179 const size_t unlikely_large_cache_size = 64 << 20;
180
181 const size_t working_set_size =
182 min_working_set_size ? min_working_set_size : unlikely_large_cache_size;
183
184 const size_t matrix_pool_size =
185 1 + working_set_size / combined_three_matrices_sizes;
186
187 MatrixType *lhs = new MatrixType[matrix_pool_size];
188 MatrixType *rhs = new MatrixType[matrix_pool_size];
189 MatrixType *dst = new MatrixType[matrix_pool_size];
190
191 for (size_t i = 0; i < matrix_pool_size; i++) {
192 lhs[i] = MatrixType::Zero(productsizes.m, productsizes.k);
193 rhs[i] = MatrixType::Zero(productsizes.k, productsizes.n);
194 dst[i] = MatrixType::Zero(productsizes.m, productsizes.n);
195 }
196
197 // main benchmark loop
198
199 int iters_at_a_time = 1;
200 float time_per_iter = 0.0f;
201 size_t matrix_index = 0;
202 while (true) {
203
204 double starttime = timer.getCpuTime();
205 for (int i = 0; i < iters_at_a_time; i++) {
206 dst[matrix_index].noalias() = lhs[matrix_index] * rhs[matrix_index];
207 matrix_index++;
208 if (matrix_index == matrix_pool_size) {
209 matrix_index = 0;
210 }

Callers 3

measure_clock_speedFunction · 0.45
try_run_some_benchmarksFunction · 0.45
mainFunction · 0.45

Calls 2

getCpuTimeMethod · 0.80
noaliasMethod · 0.80

Tested by

no test coverage detected