Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
febc0d88
Commit
febc0d88
authored
Feb 21, 2022
by
Shucai Xiao
Browse files
refine print out flops and memory throughput
parent
715359a7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
42 deletions
+73
-42
src/include/migraphx/program.hpp
src/include/migraphx/program.hpp
+2
-1
src/program.cpp
src/program.cpp
+71
-41
No files found.
src/include/migraphx/program.hpp
View file @
febc0d88
...
@@ -77,7 +77,8 @@ struct program
...
@@ -77,7 +77,8 @@ struct program
void
debug_print
()
const
;
void
debug_print
()
const
;
void
debug_print
(
instruction_ref
ins
)
const
;
void
debug_print
(
instruction_ref
ins
)
const
;
void
debug_print
(
instruction_ref
ins
,
void
debug_print
(
std
::
ostream
&
os
,
instruction_ref
ins
,
const
std
::
unordered_map
<
instruction_ref
,
std
::
string
>&
names
)
const
;
const
std
::
unordered_map
<
instruction_ref
,
std
::
string
>&
names
)
const
;
void
print
(
std
::
unordered_map
<
instruction_ref
,
std
::
string
>&
names
,
void
print
(
std
::
unordered_map
<
instruction_ref
,
std
::
string
>&
names
,
const
std
::
function
<
void
(
instruction_ref
,
const
std
::
function
<
void
(
instruction_ref
,
...
...
src/program.cpp
View file @
febc0d88
...
@@ -402,24 +402,27 @@ int program::max_ins_length() const
...
@@ -402,24 +402,27 @@ int program::max_ins_length() const
static
auto
&
get_titles
()
static
auto
&
get_titles
()
{
{
static
std
::
vector
<
std
::
string
>
titles
=
{
"Instructions"
,
static
std
::
vector
<
std
::
string
>
titles
=
{
"Instructions"
,
"Time(ms)
\t
"
,
"Time(ms)
"
,
"Percentage
\t
"
,
"Percentage
"
,
"(b, m, n, k)
\t
"
,
"(b, m, n, k) "
,
"Flops(TFlops/s)
\t
"
,
"Flops(TFlops/s) "
,
"Throughput(GB/s)"
};
"Throughput(GB/s)"
};
return
titles
;
return
titles
;
}
}
static
void
print_title
(
std
::
ostream
&
os
,
std
::
size_t
max_ins_len
)
static
void
print_title
(
std
::
ostream
&
os
,
std
::
size_t
max_ins_len
,
bool
print_percentage
=
true
)
{
{
auto
titles
=
get_titles
();
auto
titles
=
get_titles
();
std
::
string
&
str
=
titles
.
front
();
std
::
string
&
str
=
titles
.
front
();
str
.
append
(
max_ins_len
+
1
-
str
.
length
(),
' '
);
str
.
append
(
max_ins_len
+
1
-
str
.
length
(),
' '
);
str
.
append
(
1
,
'\t'
);
str
.
append
(
1
,
'\t'
);
for
(
auto
&
s
:
titles
)
os
<<
str
;
if
(
not
print_percentage
)
titles
.
erase
(
titles
.
begin
()
+
2
);
int
i
=
1
;
for
(;
i
<
titles
.
size
();
++
i
)
{
{
os
<<
s
;
os
<<
titles
[
i
]
;
}
}
os
<<
std
::
endl
;
os
<<
std
::
endl
;
}
}
...
@@ -428,7 +431,8 @@ static void print_ins_perf(std::ostream& os,
...
@@ -428,7 +431,8 @@ static void print_ins_perf(std::ostream& os,
const
std
::
vector
<
std
::
string
>&
titles
,
const
std
::
vector
<
std
::
string
>&
titles
,
instruction_ref
ins
,
instruction_ref
ins
,
double
t
,
double
t
,
double
total_t
)
double
total_t
,
bool
print_percentage
=
true
)
{
{
auto
&
time_str
=
titles
.
at
(
1
);
auto
&
time_str
=
titles
.
at
(
1
);
auto
&
time_per
=
titles
.
at
(
2
);
auto
&
time_per
=
titles
.
at
(
2
);
...
@@ -439,16 +443,19 @@ static void print_ins_perf(std::ostream& os,
...
@@ -439,16 +443,19 @@ static void print_ins_perf(std::ostream& os,
auto
&
flops_funcs
=
get_flops_funcs
();
auto
&
flops_funcs
=
get_flops_funcs
();
std
::
string
tms
=
std
::
to_string
(
t
);
std
::
string
tms
=
std
::
to_string
(
t
);
tms
.
append
(
time_str
.
length
()
-
tms
.
length
(),
' '
);
tms
.
append
(
time_str
.
length
()
-
tms
.
length
(),
' '
);
tms
.
append
(
1
,
'\t'
);
std
::
string
pers
;
if
(
print_percentage
)
{
double
percent
=
100.0
*
t
/
total_t
;
double
percent
=
100.0
*
t
/
total_t
;
std
::
string
pers
=
std
::
to_string
(
percent
);
pers
=
std
::
to_string
(
percent
);
auto
loc
=
pers
.
find
(
'.'
);
auto
loc
=
pers
.
find
(
'.'
);
if
(
loc
!=
std
::
string
::
npos
)
if
(
loc
!=
std
::
string
::
npos
)
{
{
pers
.
erase
(
pers
.
begin
()
+
loc
+
6
,
pers
.
end
());
pers
.
erase
(
pers
.
begin
()
+
loc
+
6
,
pers
.
end
());
}
}
pers
.
append
(
time_per
.
length
()
-
pers
.
length
(),
' '
);
pers
.
append
(
time_per
.
length
()
-
pers
.
length
(),
' '
);
pers
.
append
(
1
,
'\t'
);
}
// calculate flops
// calculate flops
std
::
string
szs
;
std
::
string
szs
;
...
@@ -547,20 +554,33 @@ std::vector<argument> program::eval(parameter_map params) const
...
@@ -547,20 +554,33 @@ std::vector<argument> program::eval(parameter_map params) const
if
(
trace_level
>
0
)
if
(
trace_level
>
0
)
{
{
auto
max_ins_len
=
max_ins_length
();
std
::
unordered_map
<
instruction_ref
,
std
::
string
>
ins_names
;
std
::
unordered_map
<
instruction_ref
,
std
::
string
>
ins_names
;
this
->
print
(
ins_names
,
[
&
](
auto
,
auto
)
{});
this
->
print
(
ins_names
,
[
&
](
auto
,
auto
)
{});
if
(
trace_level
==
3
)
{
std
::
string
prefix
=
"Run instruction: "
;
max_ins_len
+=
prefix
.
length
();
print_title
(
std
::
cout
,
max_ins_len
,
false
);
}
return
generic_eval
(
*
this
,
return
generic_eval
(
*
this
,
ctx
,
ctx
,
std
::
move
(
params
),
std
::
move
(
params
),
with_check_context
([
&
](
auto
&
ins
,
auto
f
,
auto
&&
check_context
)
{
with_check_context
([
&
](
auto
&
ins
,
auto
f
,
auto
&&
check_context
)
{
ctx
.
finish
();
ctx
.
finish
();
std
::
cout
<<
"Run instruction: "
;
std
::
stringstream
ss
;
this
->
debug_print
(
ins
,
ins_names
);
ss
<<
"Run instruction: "
;
this
->
debug_print
(
ss
,
ins
,
ins_names
);
timer
t
{};
timer
t
{};
auto
result
=
check_context
(
f
);
auto
result
=
check_context
(
f
);
double
t1
=
t
.
record
<
milliseconds
>
();
double
t1
=
t
.
record
<
milliseconds
>
();
ctx
.
finish
();
ctx
.
finish
();
double
t2
=
t
.
record
<
milliseconds
>
();
double
t2
=
t
.
record
<
milliseconds
>
();
if
(
trace_level
<
3
)
{
std
::
cout
<<
ss
.
str
()
<<
std
::
endl
;
std
::
cout
<<
"Time: "
<<
t1
<<
"ms, "
<<
t2
std
::
cout
<<
"Time: "
<<
t1
<<
"ms, "
<<
t2
<<
"ms, execution time:
\t
"
;
<<
"ms, execution time:
\t
"
;
if
(
trace_level
==
2
and
ins
->
name
().
front
()
!=
'@'
and
if
(
trace_level
==
2
and
ins
->
name
().
front
()
!=
'@'
and
...
@@ -582,12 +602,22 @@ std::vector<argument> program::eval(parameter_map params) const
...
@@ -582,12 +602,22 @@ std::vector<argument> program::eval(parameter_map params) const
std
::
cout
<<
"Output: "
<<
buffer
<<
std
::
endl
;
std
::
cout
<<
"Output: "
<<
buffer
<<
std
::
endl
;
}
}
}
}
}
else
if
(
trace_level
==
3
)
else
if
(
trace_level
==
3
)
{
{
// count max instruction length
// count max instruction length
if
(
ins
->
get_operator
().
output_alias
({})
==
0
)
{
std
::
cout
<<
ss
.
str
()
<<
std
::
endl
;
return
result
;
}
print_space
(
ss
,
max_ins_len
-
ss
.
str
().
length
());
ss
<<
'\t'
;
std
::
cout
<<
ss
.
str
();
auto
titles
=
get_titles
();
auto
titles
=
get_titles
();
double
exec_t
=
t2
-
t1
;
double
exec_t
=
t2
-
t1
;
print_ins_perf
(
std
::
cout
,
titles
,
ins
,
exec_t
,
exec_t
);
print_ins_perf
(
std
::
cout
,
titles
,
ins
,
exec_t
,
exec_t
,
false
);
}
}
return
result
;
return
result
;
}));
}));
...
@@ -944,28 +974,28 @@ void program::debug_print(instruction_ref ins) const
...
@@ -944,28 +974,28 @@ void program::debug_print(instruction_ref ins) const
});
});
}
}
void
program
::
debug_print
(
instruction_ref
ins
,
void
program
::
debug_print
(
std
::
ostream
&
os
,
instruction_ref
ins
,
const
std
::
unordered_map
<
instruction_ref
,
std
::
string
>&
names
)
const
const
std
::
unordered_map
<
instruction_ref
,
std
::
string
>&
names
)
const
{
{
if
(
std
::
any_of
(
this
->
impl
->
modules
.
begin
(),
this
->
impl
->
modules
.
end
(),
[
&
](
const
auto
&
pp
)
{
if
(
std
::
any_of
(
this
->
impl
->
modules
.
begin
(),
this
->
impl
->
modules
.
end
(),
[
&
](
const
auto
&
pp
)
{
return
is_end
(
pp
.
second
.
end
(),
ins
);
return
is_end
(
pp
.
second
.
end
(),
ins
);
}))
}))
{
{
s
td
::
cout
<<
"End instruction"
<<
std
::
endl
;
o
s
<<
"End instruction"
<<
std
::
endl
;
return
;
return
;
}
}
else
if
(
std
::
none_of
(
this
->
impl
->
modules
.
begin
(),
else
if
(
std
::
none_of
(
this
->
impl
->
modules
.
begin
(),
this
->
impl
->
modules
.
end
(),
this
->
impl
->
modules
.
end
(),
[
&
](
const
auto
&
pp
)
{
return
pp
.
second
.
has_instruction
(
ins
);
}))
[
&
](
const
auto
&
pp
)
{
return
pp
.
second
.
has_instruction
(
ins
);
}))
{
{
s
td
::
cout
<<
"Instruction not part of program"
<<
std
::
endl
;
o
s
<<
"Instruction not part of program"
<<
std
::
endl
;
return
;
return
;
}
}
if
(
contains
(
names
,
ins
))
if
(
contains
(
names
,
ins
))
{
{
instruction
::
print
(
std
::
cout
,
ins
,
names
);
instruction
::
print
(
os
,
ins
,
names
);
std
::
cout
<<
std
::
endl
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment