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
64285523
Commit
64285523
authored
Oct 09, 2022
by
Paul
Browse files
Format
parent
ad19d4dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
tools/tune_ck.py
tools/tune_ck.py
+14
-6
No files found.
tools/tune_ck.py
View file @
64285523
...
...
@@ -4,7 +4,9 @@ import os, json, subprocess, tempfile, sys, argparse
def
benchmark_one
(
config
,
tuning
):
with
tempfile
.
NamedTemporaryFile
(
mode
=
"w+"
)
as
tf
:
b
=
{
'settings'
:
{
'iterations'
:
100
},
'settings'
:
{
'iterations'
:
100
},
'compile_op'
:
{
'name'
:
'ck_gemm'
,
'tuning_val'
:
tuning
,
...
...
@@ -12,7 +14,8 @@ def benchmark_one(config, tuning):
}
}
json
.
dump
(
b
,
tf
)
cp
=
subprocess
.
run
(
'./bin/gpu-driver {}'
.
format
(
tf
.
name
),
capture_output
=
True
)
cp
=
subprocess
.
run
(
'./bin/gpu-driver {}'
.
format
(
tf
.
name
),
capture_output
=
True
)
for
line
in
cp
.
stdout
.
decode
().
split
(
"
\n
"
):
s
=
line
.
strip
()
if
not
s
:
...
...
@@ -22,10 +25,12 @@ def benchmark_one(config, tuning):
return
float
(
dtime
[:
-
2
])
return
sys
.
float_info
.
max
def
benchmark
(
config
,
size
):
times
=
[
benchmark_one
(
config
,
i
)
for
i
in
range
(
size
)]
return
times
.
index
(
max
(
times
))
def
benchmark_log
(
f
):
result
=
[]
for
line
in
open
(
f
).
readlines
():
...
...
@@ -40,21 +45,24 @@ def benchmark_log(f):
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
description
=
"Simple tuner for CK gemms"
)
parser
.
add_argument
(
'--log'
,
'-l'
,
parser
=
argparse
.
ArgumentParser
(
description
=
"Simple tuner for CK gemms"
)
parser
.
add_argument
(
'--log'
,
'-l'
,
type
=
str
,
metavar
=
'file'
,
help
=
'Path to logfile'
)
parser
.
add_argument
(
'--out'
,
'-o'
,
parser
.
add_argument
(
'--out'
,
'-o'
,
type
=
str
,
metavar
=
'file'
,
help
=
'Output json file to save tunings'
)
args
=
parser
.
parse_args
()
return
args
def
run
(
args
):
tuned
=
benchmark_log
(
args
.
log
)
json
.
dump
(
tuned
,
open
(
args
.
out
,
'w+'
))
run
(
parse_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