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
7d5365d0
Commit
7d5365d0
authored
Jul 06, 2022
by
Paul
Browse files
Format
parent
b7b44c01
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
25 deletions
+47
-25
src/targets/gpu/driver/compile_op.cpp
src/targets/gpu/driver/compile_op.cpp
+1
-1
src/targets/gpu/driver/include/migraphx/gpu/driver/perf.hpp
src/targets/gpu/driver/include/migraphx/gpu/driver/perf.hpp
+2
-1
src/targets/gpu/driver/perf.cpp
src/targets/gpu/driver/perf.cpp
+6
-5
src/targets/gpu/include/migraphx/gpu/context.hpp
src/targets/gpu/include/migraphx/gpu/context.hpp
+8
-9
src/targets/gpu/include/migraphx/gpu/kernel.hpp
src/targets/gpu/include/migraphx/gpu/kernel.hpp
+7
-3
src/targets/gpu/kernel.cpp
src/targets/gpu/kernel.cpp
+23
-6
No files found.
src/targets/gpu/driver/compile_op.cpp
View file @
7d5365d0
src/targets/gpu/driver/include/migraphx/gpu/driver/perf.hpp
View file @
7d5365d0
...
@@ -33,7 +33,8 @@ inline namespace MIGRAPHX_INLINE_NS {
...
@@ -33,7 +33,8 @@ inline namespace MIGRAPHX_INLINE_NS {
namespace
gpu
{
namespace
gpu
{
namespace
driver
{
namespace
driver
{
std
::
pair
<
double
,
double
>
time_op
(
context
&
ictx
,
operation
op
,
const
std
::
vector
<
shape
>&
inputs
,
int
n
=
100
);
std
::
pair
<
double
,
double
>
time_op
(
context
&
ictx
,
operation
op
,
const
std
::
vector
<
shape
>&
inputs
,
int
n
=
100
);
}
// namespace driver
}
// namespace driver
}
// namespace gpu
}
// namespace gpu
...
...
src/targets/gpu/driver/perf.cpp
View file @
7d5365d0
...
@@ -42,7 +42,8 @@ std::vector<argument> generate_arguments(const std::vector<shape>& shapes, unsig
...
@@ -42,7 +42,8 @@ std::vector<argument> generate_arguments(const std::vector<shape>& shapes, unsig
}
}
using
milliseconds
=
std
::
chrono
::
duration
<
double
,
std
::
milli
>
;
using
milliseconds
=
std
::
chrono
::
duration
<
double
,
std
::
milli
>
;
std
::
pair
<
double
,
double
>
time_op
(
context
&
ictx
,
operation
op
,
const
std
::
vector
<
shape
>&
inputs
,
int
n
)
std
::
pair
<
double
,
double
>
time_op
(
context
&
ictx
,
operation
op
,
const
std
::
vector
<
shape
>&
inputs
,
int
n
)
{
{
// TODO: Use std::ref
// TODO: Use std::ref
...
@@ -59,7 +60,7 @@ std::pair<double, double> time_op(context& ictx, operation op, const std::vector
...
@@ -59,7 +60,7 @@ std::pair<double, double> time_op(context& ictx, operation op, const std::vector
run
();
run
();
double
host_time
=
0.0
;
double
host_time
=
0.0
;
double
device_time
=
0.0
;
double
device_time
=
0.0
;
for
(
auto
i
:
range
(
n
))
for
(
auto
i
:
range
(
n
))
{
{
(
void
)
i
;
(
void
)
i
;
host_time
+=
time
<
milliseconds
>
(
run
);
host_time
+=
time
<
milliseconds
>
(
run
);
...
...
src/targets/gpu/include/migraphx/gpu/context.hpp
View file @
7d5365d0
...
@@ -199,7 +199,6 @@ struct context
...
@@ -199,7 +199,6 @@ struct context
context
(
std
::
size_t
device_id
=
0
,
std
::
size_t
n
=
value_of
(
MIGRAPHX_NSTREAMS
{},
1
))
context
(
std
::
size_t
device_id
=
0
,
std
::
size_t
n
=
value_of
(
MIGRAPHX_NSTREAMS
{},
1
))
:
current_device
(
std
::
make_shared
<
hip_device
>
(
device_id
,
n
))
:
current_device
(
std
::
make_shared
<
hip_device
>
(
device_id
,
n
))
{
{
}
}
hip_device
&
get_current_device
()
hip_device
&
get_current_device
()
...
@@ -279,7 +278,7 @@ struct context
...
@@ -279,7 +278,7 @@ struct context
void
enable_perf_measurement
(
bool
b
=
true
)
void
enable_perf_measurement
(
bool
b
=
true
)
{
{
if
(
b
)
if
(
b
)
{
{
start_event
=
create_event_for_timing
();
start_event
=
create_event_for_timing
();
stop_event
=
create_event_for_timing
();
stop_event
=
create_event_for_timing
();
...
@@ -296,7 +295,7 @@ struct context
...
@@ -296,7 +295,7 @@ struct context
std
::
pair
<
hipEvent_t
,
hipEvent_t
>
get_perf_events
()
const
std
::
pair
<
hipEvent_t
,
hipEvent_t
>
get_perf_events
()
const
{
{
if
(
measure_perf
)
if
(
measure_perf
)
return
std
::
make_pair
(
start_event
.
get
(),
stop_event
.
get
());
return
std
::
make_pair
(
start_event
.
get
(),
stop_event
.
get
());
return
std
::
make_pair
(
nullptr
,
nullptr
);
return
std
::
make_pair
(
nullptr
,
nullptr
);
}
}
...
@@ -304,10 +303,10 @@ struct context
...
@@ -304,10 +303,10 @@ struct context
float
get_elapsed_ms
()
const
float
get_elapsed_ms
()
const
{
{
float
result
=
0
;
float
result
=
0
;
if
(
start_event
!=
nullptr
and
stop_event
!=
nullptr
)
if
(
start_event
!=
nullptr
and
stop_event
!=
nullptr
)
{
{
auto
status
=
hipEventElapsedTime
(
&
result
,
start_event
.
get
(),
stop_event
.
get
());
auto
status
=
hipEventElapsedTime
(
&
result
,
start_event
.
get
(),
stop_event
.
get
());
if
(
status
!=
hipSuccess
)
if
(
status
!=
hipSuccess
)
MIGRAPHX_THROW
(
"Failed hipEventElapsedTime: "
+
hip_error
(
status
));
MIGRAPHX_THROW
(
"Failed hipEventElapsedTime: "
+
hip_error
(
status
));
}
}
return
result
;
return
result
;
...
...
src/targets/gpu/include/migraphx/gpu/kernel.hpp
View file @
7d5365d0
...
@@ -50,14 +50,18 @@ struct kernel
...
@@ -50,14 +50,18 @@ struct kernel
void
launch
(
hipStream_t
stream
,
void
launch
(
hipStream_t
stream
,
std
::
size_t
global
,
std
::
size_t
global
,
std
::
size_t
local
,
std
::
size_t
local
,
const
std
::
vector
<
kernel_argument
>&
args
,
hipEvent_t
start
=
nullptr
,
hipEvent_t
stop
=
nullptr
)
const
;
const
std
::
vector
<
kernel_argument
>&
args
,
hipEvent_t
start
=
nullptr
,
hipEvent_t
stop
=
nullptr
)
const
;
void
launch
(
hipStream_t
stream
,
void
launch
(
hipStream_t
stream
,
std
::
size_t
global
,
std
::
size_t
global
,
std
::
size_t
local
,
std
::
size_t
local
,
std
::
vector
<
void
*>
args
,
hipEvent_t
start
=
nullptr
,
hipEvent_t
stop
=
nullptr
)
const
;
std
::
vector
<
void
*>
args
,
hipEvent_t
start
=
nullptr
,
hipEvent_t
stop
=
nullptr
)
const
;
template
<
class
...
Ts
>
template
<
class
...
Ts
>
auto
launch
(
hipStream_t
stream
,
std
::
size_t
global
,
std
::
size_t
local
,
Ts
...
zs
)
const
auto
launch
(
hipStream_t
stream
,
std
::
size_t
global
,
std
::
size_t
local
,
Ts
...
zs
)
const
{
{
return
[
=
](
auto
&&
...
xs
)
{
return
[
=
](
auto
&&
...
xs
)
{
...
...
src/targets/gpu/kernel.cpp
View file @
7d5365d0
...
@@ -80,7 +80,9 @@ void launch_kernel(hipFunction_t fun,
...
@@ -80,7 +80,9 @@ void launch_kernel(hipFunction_t fun,
std
::
size_t
global
,
std
::
size_t
global
,
std
::
size_t
local
,
std
::
size_t
local
,
void
*
kernargs
,
void
*
kernargs
,
std
::
size_t
size
,
hipEvent_t
start
,
hipEvent_t
stop
)
std
::
size_t
size
,
hipEvent_t
start
,
hipEvent_t
stop
)
{
{
assert
(
global
>
0
);
assert
(
global
>
0
);
assert
(
local
>
0
);
assert
(
local
>
0
);
...
@@ -97,11 +99,22 @@ void launch_kernel(hipFunction_t fun,
...
@@ -97,11 +99,22 @@ void launch_kernel(hipFunction_t fun,
#endif
#endif
};
};
auto
status
=
hipExtModuleLaunchKernel
(
auto
status
=
hipExtModuleLaunchKernel
(
fun
,
fun
,
global
,
1
,
1
,
local
,
1
,
1
,
0
,
stream
,
nullptr
,
reinterpret_cast
<
void
**>
(
&
config
),
start
,
stop
);
global
,
1
,
1
,
local
,
1
,
1
,
0
,
stream
,
nullptr
,
reinterpret_cast
<
void
**>
(
&
config
),
start
,
stop
);
if
(
status
!=
hipSuccess
)
if
(
status
!=
hipSuccess
)
MIGRAPHX_THROW
(
"Failed to launch kernel: "
+
hip_error
(
status
));
MIGRAPHX_THROW
(
"Failed to launch kernel: "
+
hip_error
(
status
));
if
(
stop
)
if
(
stop
)
{
{
status
=
hipEventSynchronize
(
stop
);
status
=
hipEventSynchronize
(
stop
);
if
(
status
!=
hipSuccess
)
if
(
status
!=
hipSuccess
)
...
@@ -112,7 +125,9 @@ void launch_kernel(hipFunction_t fun,
...
@@ -112,7 +125,9 @@ void launch_kernel(hipFunction_t fun,
void
kernel
::
launch
(
hipStream_t
stream
,
void
kernel
::
launch
(
hipStream_t
stream
,
std
::
size_t
global
,
std
::
size_t
global
,
std
::
size_t
local
,
std
::
size_t
local
,
std
::
vector
<
void
*>
args
,
hipEvent_t
start
,
hipEvent_t
stop
)
const
std
::
vector
<
void
*>
args
,
hipEvent_t
start
,
hipEvent_t
stop
)
const
{
{
assert
(
impl
!=
nullptr
);
assert
(
impl
!=
nullptr
);
void
*
kernargs
=
args
.
data
();
void
*
kernargs
=
args
.
data
();
...
@@ -124,7 +139,9 @@ void kernel::launch(hipStream_t stream,
...
@@ -124,7 +139,9 @@ void kernel::launch(hipStream_t stream,
void
kernel
::
launch
(
hipStream_t
stream
,
void
kernel
::
launch
(
hipStream_t
stream
,
std
::
size_t
global
,
std
::
size_t
global
,
std
::
size_t
local
,
std
::
size_t
local
,
const
std
::
vector
<
kernel_argument
>&
args
,
hipEvent_t
start
,
hipEvent_t
stop
)
const
const
std
::
vector
<
kernel_argument
>&
args
,
hipEvent_t
start
,
hipEvent_t
stop
)
const
{
{
assert
(
impl
!=
nullptr
);
assert
(
impl
!=
nullptr
);
std
::
vector
<
char
>
kernargs
=
pack_args
(
args
);
std
::
vector
<
char
>
kernargs
=
pack_args
(
args
);
...
...
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