1 /*******************************************************************************
2 * Copyright 2017-2018 Intel Corporation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
18 #include "mkldnn_common.hpp"
19 #include "mkldnn_memory.hpp"
21 #include "reorder.hpp"
22 #include "input_reorder.hpp"
26 int bench(int argc, char **argv) {
27 const int num_r = sizeof(reorders) / sizeof(reorders[0]);
28 const int num_q = sizeof(q10ns) / sizeof(q10ns[0]);
29 const int num_s = sizeof(default_scales) / sizeof(default_scales[0]);
31 for (int q = 0; q < num_q; ++q) {
32 if (q10ns[q].scale == 0) {
33 for (int idx = 0; idx < num_s; ++idx) {
34 q10ns[q].scale = default_scales[idx];
35 for (int r = 0; r < num_r; ++r) {
36 const prb_t p(&reorders[r], &q10ns[q]);
41 for (int r = 0; r < num_r; ++r) {
42 const prb_t p(&reorders[r], &q10ns[q]);
51 void check(const prb_t *p) {
53 char pstr[max_prb_len];
54 prb2str(p, &res, pstr);
56 int status = reorder::doit(p, &res);
58 prb2str(p, &res, pstr);
59 bool want_perf_report = false;
61 parse_result(res, want_perf_report, false, status, pstr);
63 if (bench_mode & PERF)
64 perf_report(p, &res, pstr);
66 benchdnn_stat.tests++;
69 void perf_report(const prb_t *p, const res_t *r, const char *pstr) {
70 const auto &t = r->timer;
71 const int max_len = 400;
72 char buffer[max_len], *buf = buffer;
73 int rem_len = max_len - 1;
75 # define DPRINT(...) do { \
76 int l = snprintf(buf, rem_len, __VA_ARGS__); \
77 buf += l; rem_len -= l; \
82 DPRINT("min_ms=%g,", t.ms(benchdnn_timer_t::min));
83 DPRINT("max_ms=%g", t.ms(benchdnn_timer_t::max));
86 print(0, "%s\n", buffer);