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
63c6b0a5
Commit
63c6b0a5
authored
Sep 26, 2023
by
ravil-mobile
Browse files
Fixed timing in benchmarking
parent
4637621a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
9 deletions
+21
-9
src/targets/gpu/hip.cpp
src/targets/gpu/hip.cpp
+7
-3
src/targets/gpu/time_op.cpp
src/targets/gpu/time_op.cpp
+14
-6
No files found.
src/targets/gpu/hip.cpp
View file @
63c6b0a5
...
@@ -232,9 +232,13 @@ argument from_gpu(const argument& arg)
...
@@ -232,9 +232,13 @@ argument from_gpu(const argument& arg)
void
set_device
(
std
::
size_t
id
)
void
set_device
(
std
::
size_t
id
)
{
{
auto
status
=
hipSetDevice
(
id
);
static
std
::
size_t
curr_id
{
0
};
if
(
status
!=
hipSuccess
)
if
(
curr_id
!=
id
)
{
MIGRAPHX_THROW
(
"Error setting device"
);
curr_id
=
id
;
auto
status
=
hipSetDevice
(
curr_id
);
if
(
status
!=
hipSuccess
)
MIGRAPHX_THROW
(
"Error setting device"
);
}
}
}
void
gpu_sync
()
void
gpu_sync
()
...
...
src/targets/gpu/time_op.cpp
View file @
63c6b0a5
...
@@ -55,17 +55,25 @@ time_op(context& ictx, operation op, const std::vector<shape>& inputs, int n)
...
@@ -55,17 +55,25 @@ time_op(context& ictx, operation op, const std::vector<shape>& inputs, int n)
op
.
compute
(
ctx
,
output
,
args
);
op
.
compute
(
ctx
,
output
,
args
);
ctx
.
finish
();
ctx
.
finish
();
};
};
gctx
.
enable_perf_measurement
();
run
();
run
();
double
host_time
=
0.0
;
double
device_time
=
0.0
;
shared
<
hip_event_ptr
>
start
=
gctx
.
create_event_for_timing
();
shared
<
hip_event_ptr
>
stop
=
gctx
.
create_event_for_timing
();
gctx
.
get_stream
().
record
(
start
.
get
());
for
(
auto
i
:
range
(
n
))
for
(
auto
i
:
range
(
n
))
{
{
(
void
)
i
;
(
void
)
i
;
host_time
+=
time
<
milliseconds
>
(
run
);
op
.
compute
(
ctx
,
output
,
args
);
device_time
+=
gctx
.
get_elapsed_ms
();
}
}
return
std
::
make_pair
(
host_time
/
n
,
device_time
/
n
);
gctx
.
get_stream
().
record
(
stop
.
get
());
auto
status
=
hipEventSynchronize
(
stop
.
get
());
if
(
status
!=
hipSuccess
)
{
MIGRAPHX_THROW
(
"Failed to `hipEventSynchronize`: "
+
hip_error
(
status
));
}
float
milliseconds
=
0.0
;
status
=
hipEventElapsedTime
(
&
milliseconds
,
start
.
get
(),
stop
.
get
());
if
(
status
!=
hipSuccess
)
{
MIGRAPHX_THROW
(
"Failed to `hipEventElapsedTime`: "
+
hip_error
(
status
));
}
return
std
::
make_pair
(
milliseconds
,
milliseconds
);
}
}
}
// namespace gpu
}
// namespace gpu
...
...
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