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
46d6a1d4
Commit
46d6a1d4
authored
Aug 17, 2018
by
Paul
Browse files
Formatting
parent
a83a717a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
28 deletions
+30
-28
src/include/migraph/generate.hpp
src/include/migraph/generate.hpp
+3
-3
src/include/migraph/instruction.hpp
src/include/migraph/instruction.hpp
+9
-9
src/program.cpp
src/program.cpp
+18
-16
No files found.
src/include/migraph/generate.hpp
View file @
46d6a1d4
src/include/migraph/instruction.hpp
View file @
46d6a1d4
...
...
@@ -165,17 +165,17 @@ inline shape compute_shape(operation op, std::vector<instruction_ref> args)
}
// namespace migraph
namespace
std
namespace
std
{
template
<
>
struct
hash
<
migraph
::
instruction_ref
>
{
template
<
>
struct
hash
<
migraph
::
instruction_ref
>
{
using
argument_type
=
migraph
::
instruction_ref
;
using
result_type
=
std
::
size_t
;
result_type
operator
()(
const
argument_type
&
x
)
const
noexcept
{
return
std
::
hash
<
migraph
::
instruction
*>
{}(
&*
x
);
}
};
};
}
// namespace std
#endif
src/program.cpp
View file @
46d6a1d4
...
...
@@ -278,7 +278,7 @@ argument generic_eval(const program& p,
{
assert
(
p
.
validate
()
==
p
.
end
());
std
::
unordered_map
<
instruction_ref
,
argument
>
results
;
results
.
reserve
(
p
.
size
()
*
2
);
results
.
reserve
(
p
.
size
()
*
2
);
std
::
vector
<
argument
>
values
;
values
.
reserve
(
16
);
for
(
auto
ins
:
iterator_for
(
p
))
...
...
@@ -289,7 +289,9 @@ argument generic_eval(const program& p,
}
else
if
(
ins
->
op
.
name
()
==
"@param"
)
{
results
.
emplace
(
ins
,
trace
(
ins
,
[
&
]
{
return
params
.
at
(
any_cast
<
builtin
::
param
>
(
ins
->
op
).
parameter
);
}));
results
.
emplace
(
ins
,
trace
(
ins
,
[
&
]
{
return
params
.
at
(
any_cast
<
builtin
::
param
>
(
ins
->
op
).
parameter
);
}));
}
else
if
(
ins
->
op
.
name
()
==
"@outline"
)
{
...
...
@@ -305,7 +307,8 @@ argument generic_eval(const program& p,
assert
(
results
.
find
(
i
)
!=
results
.
end
());
return
results
[
i
];
});
results
.
emplace
(
ins
,
trace
(
ins
,
[
&
]
{
return
ins
->
op
.
compute
(
ctx
,
ins
->
result
,
values
);
}));
results
.
emplace
(
ins
,
trace
(
ins
,
[
&
]
{
return
ins
->
op
.
compute
(
ctx
,
ins
->
result
,
values
);
}));
}
assert
(
results
.
find
(
ins
)
!=
results
.
end
());
}
...
...
@@ -330,16 +333,16 @@ void program::perf_report(std::ostream& os, std::size_t n, parameter_map params)
}
std
::
unordered_map
<
instruction_ref
,
double
>
ins_acc
;
// Fill the map
generic_eval
(
*
this
,
this
->
impl
->
ctx
,
params
,
[
&
](
auto
ins
,
auto
)
{
ins_acc
[
ins
]
=
0
;
return
argument
{};
});
generic_eval
(
*
this
,
this
->
impl
->
ctx
,
params
,
[
&
](
auto
ins
,
auto
)
{
ins_acc
[
ins
]
=
0
;
return
argument
{};
});
// Run and time each instruction
for
(
std
::
size_t
i
=
0
;
i
<
n
;
i
++
)
{
generic_eval
(
*
this
,
this
->
impl
->
ctx
,
params
,
[
&
](
auto
ins
,
auto
f
)
{
argument
result
;
ins_acc
[
ins
]
+=
time
<
milliseconds
>
([
&
]{
result
=
f
();
});
ins_acc
[
ins
]
+=
time
<
milliseconds
>
([
&
]
{
result
=
f
();
});
return
result
;
});
}
...
...
@@ -347,8 +350,9 @@ void program::perf_report(std::ostream& os, std::size_t n, parameter_map params)
double
overhead_acc
=
0
;
for
(
std
::
size_t
i
=
0
;
i
<
n
;
i
++
)
{
overhead_acc
+=
time
<
milliseconds
>
(
[
&
]
{
generic_eval
(
*
this
,
this
->
impl
->
ctx
,
params
,
[](
auto
...)
{
return
argument
{};
});
});
overhead_acc
+=
time
<
milliseconds
>
([
&
]
{
generic_eval
(
*
this
,
this
->
impl
->
ctx
,
params
,
[](
auto
...)
{
return
argument
{};
});
});
}
double
total_time
=
total_acc
/
n
;
...
...
@@ -360,9 +364,7 @@ void program::perf_report(std::ostream& os, std::size_t n, parameter_map params)
double
calculate_overhead_time
=
total_time
-
total_instruction_time
;
double
calculate_overhead_percent
=
calculate_overhead_time
*
100.0
/
total_time
;
print_program
(
os
,
*
this
,
[
&
](
auto
ins
,
auto
&&
)
{
os
<<
": "
<<
ins_acc
[
ins
]
/
n
<<
"ms"
;
});
print_program
(
os
,
*
this
,
[
&
](
auto
ins
,
auto
&&
)
{
os
<<
": "
<<
ins_acc
[
ins
]
/
n
<<
"ms"
;
});
os
<<
"Total time: "
<<
total_time
<<
"ms"
<<
std
::
endl
;
os
<<
"Total instructions time: "
<<
total_instruction_time
<<
"ms"
<<
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