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 *******************************************************************************/
24 #include "mkldnn_memory.hpp"
26 #include "bnorm/bnorm.hpp"
31 See conv/perf_report.cpp for details.
32 See modifiers at the same place.
34 | abbreviation | description
35 |:------------ |:-----------
36 | %d | problem descriptor
37 | %D | expanded problem descriptor (parameters in csv format)
41 | %q | data type (precision)
42 | %f | data format (layout)
45 The definition of expanded problem descriptor is: `mb,ic,ih,iw,eps`.
48 void perf_report(const prb_t *p, const res_t *r, const char *pstr) {
49 const auto &t = r->timer;
50 const int max_len = 400;
51 int rem_len = max_len - 1;
52 char buffer[max_len], *buf = buffer;
54 # define DPRINT(...) do { \
55 int l = snprintf(buf, rem_len, __VA_ARGS__); \
56 buf += l; rem_len -= l; \
59 auto modifier2mode = [](char c) {
60 if (c == '-') return benchdnn_timer_t::min;
61 if (c == '0') return benchdnn_timer_t::avg;
62 if (c == '+') return benchdnn_timer_t::max;
63 return benchdnn_timer_t::min;
66 auto modifier2unit = [](char c) {
67 if (c == 'K') return 1e3;
68 if (c == 'M') return 1e6;
69 if (c == 'G') return 1e9;
73 const char *pt = perf_template;
76 while ((c = *pt++) != '\0') {
77 if (c != '%') { *buf++ = c; rem_len--; continue; }
81 benchdnn_timer_t::mode_t mode = benchdnn_timer_t::min;
84 if (c == '-' || c == '0' || c == '+') {
85 mode = modifier2mode(c);
89 if (c == 'K' || c == 'M' || c == 'G') {
90 unit = modifier2unit(c);
97 DPRINT("%d,%d,%d,%d,%d,%g", p->mb, p->ic, p->id, p->ih, p->iw,
100 DPRINT("%s", p->name);
102 DPRINT("%s", dir2str(p->dir));
104 DPRINT("%s", flags2str(p->flags));
106 DPRINT("%s", dt2str(p->dt));
108 DPRINT("%s", fmt2str(p->fmt));
110 DPRINT("%g", t.ms(mode) / unit);
112 []() { SAFE(FAIL, CRIT); return 0; }();
116 assert(rem_len >= 0);
119 print(0, "%s\n", buffer);