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
55b363c9
Commit
55b363c9
authored
Mar 22, 2023
by
Paul
Browse files
Format
parent
c0e26328
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
tools/tune_ck.py
tools/tune_ck.py
+7
-1
No files found.
tools/tune_ck.py
View file @
55b363c9
...
@@ -46,6 +46,7 @@ def get_device_time(s):
...
@@ -46,6 +46,7 @@ def get_device_time(s):
fields
=
s
.
split
(
','
)
fields
=
s
.
split
(
','
)
return
convert_to_float
(
fields
[
-
1
].
strip
())
return
convert_to_float
(
fields
[
-
1
].
strip
())
def
run_driver_ck
(
config
,
tuning
,
iterations
):
def
run_driver_ck
(
config
,
tuning
,
iterations
):
b
=
{
b
=
{
'settings'
:
{
'settings'
:
{
...
@@ -60,6 +61,7 @@ def run_driver_ck(config, tuning, iterations):
...
@@ -60,6 +61,7 @@ def run_driver_ck(config, tuning, iterations):
}
}
return
run_driver
(
b
)
return
run_driver
(
b
)
def
benchmark_ck
(
config
,
tuning
):
def
benchmark_ck
(
config
,
tuning
):
try
:
try
:
for
line
in
run_driver_ck
(
config
,
tuning
,
100
):
for
line
in
run_driver_ck
(
config
,
tuning
,
100
):
...
@@ -71,6 +73,7 @@ def benchmark_ck(config, tuning):
...
@@ -71,6 +73,7 @@ def benchmark_ck(config, tuning):
except
:
except
:
return
sys
.
float_info
.
max
return
sys
.
float_info
.
max
def
benchmark
(
config
,
size
):
def
benchmark
(
config
,
size
):
times
=
[
benchmark_ck
(
config
,
i
)
for
i
in
range
(
size
)]
times
=
[
benchmark_ck
(
config
,
i
)
for
i
in
range
(
size
)]
return
times
.
index
(
min
(
times
))
return
times
.
index
(
min
(
times
))
...
@@ -85,17 +88,20 @@ def parse_log(f):
...
@@ -85,17 +88,20 @@ def parse_log(f):
config
=
json
.
loads
(
line
)
config
=
json
.
loads
(
line
)
yield
config
yield
config
def
precompile
(
x
):
def
precompile
(
x
):
try
:
try
:
list
(
run_driver_ck
(
x
[
0
],
x
[
1
],
0
))
list
(
run_driver_ck
(
x
[
0
],
x
[
1
],
0
))
except
:
except
:
pass
pass
def
precompile_log
(
f
,
n
):
def
precompile_log
(
f
,
n
):
solutions
=
((
config
,
i
)
for
config
in
parse_log
(
f
)
for
i
in
range
(
n
))
solutions
=
((
config
,
i
)
for
config
in
parse_log
(
f
)
for
i
in
range
(
n
))
with
multiprocessing
.
Pool
(
24
)
as
p
:
with
multiprocessing
.
Pool
(
24
)
as
p
:
list
(
p
.
imap
(
precompile
,
solutions
))
list
(
p
.
imap
(
precompile
,
solutions
))
def
benchmark_log
(
f
,
n
):
def
benchmark_log
(
f
,
n
):
result
=
[]
result
=
[]
for
config
in
parse_log
(
f
):
for
config
in
parse_log
(
f
):
...
@@ -127,7 +133,7 @@ def parse_args():
...
@@ -127,7 +133,7 @@ def parse_args():
def
run
(
args
):
def
run
(
args
):
if
(
args
.
precompile
):
if
(
args
.
precompile
):
precompile_log
(
args
.
log
,
args
.
n
)
precompile_log
(
args
.
log
,
args
.
n
)
tuned
=
benchmark_log
(
args
.
log
,
args
.
n
)
tuned
=
benchmark_log
(
args
.
log
,
args
.
n
)
json
.
dump
(
tuned
,
open
(
args
.
out
,
'w+'
))
json
.
dump
(
tuned
,
open
(
args
.
out
,
'w+'
))
...
...
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