Skip to content

Commit

Permalink
feat: add 'arch' option
Browse files Browse the repository at this point in the history
  • Loading branch information
skyleaworlder committed Aug 17, 2023
1 parent f7e4858 commit 7f4eec5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion benchmark/script/mergereports-cli.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if parsed_args["push-result"] && suitable_to_use_result_cache(target_url)
@info "RESULT: $target_url is suitable to push its result to remote"
writeresults(joinpath(@__DIR__, "..", "result-target.json"), target_benchmarkresults)
push_result(target_url, joinpath(@__DIR__, "..", "result-target.json")
; git_push_password = parsed_args["push-password"])
; git_push_password = parsed_args["push-password"], arch = parsed_args["arch"])
end

# generate report.md as the content of comment
Expand Down
2 changes: 1 addition & 1 deletion benchmark/script/runbenchmarks-pr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ try
throw("")
end

global group_baseline = get_benchmarkresults_from_branch(baseline_url)
global group_baseline = get_benchmarkresults_from_branch(baseline_url; arch=parsed_args["arch"])
if isnothing(group_baseline)
@warn "RESULT: cannot get result file, run benchmarks"
throw("")
Expand Down
17 changes: 17 additions & 0 deletions src/env_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ const FLUXML_AVAILABLE_TOP_LEVEL_BENCHMARKS = [
"flux", "nnlib"
]

"""
SUPPORTED_ARCHITECTURES means the supported architecture for this tool.
"""
const SUPPORTED_ARCHITECTURES = [
"cpu", "gpu"
]


"""
Dependency
Expand Down Expand Up @@ -256,6 +263,12 @@ function parse_commandline()
"--push-password"
help = "used to authenticate when pushing"
action = :store_arg

# about architecture
"--arch"
help = "enable gpu benchmarks"
action = :store_arg
default = "cpu"
end
args = parse_args(s)
# script-related arguments cli / pr / merge-report / cache-setup
Expand All @@ -267,6 +280,10 @@ function parse_commandline()
args["push-result"] && isnothing(args["push-password"]) &&
throw(error("Must provide 'push-password' if you want to 'push-result'"))

# if arch is in SUPPORTED_ARCHITECTURES, allow returning args
!(args["arch"] in SUPPORTED_ARCHITECTURES) &&
throw(error("--arch must be in SUPPORTED_ARCHITECTURES"))

# if (deps-list) or (target & baseline) specified, allow returning args
!isnothing(args["deps-list"]) && return args
!isnothing(args["target"]) && !isnothing(args["baseline"]) &&
Expand Down
22 changes: 11 additions & 11 deletions src/judge_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const TARGET_RESULT_FILE_NAME = "result-target.json"


"""
gen_result_filename(single_deps_list::String)::String
gen_result_filename(single_deps_list::String; arch = "cpu")::String
is used to generate the filename of benchmark results.
The name of results doesn't have relationship with BenchmarkResults,
Expand All @@ -25,11 +25,11 @@ we can use the information of dependencies to specify a file.
* single_deps_list: a part of command argument, `deps-list`.
`target` and `baseline` also can passed in.
"""
function gen_result_filename(single_deps_list::String)::String
function gen_result_filename(single_deps_list::String; arch = "cpu")::String
# keep deps in sort, in case impact of different sequence.
sorted_deps = reduce((a, b) -> "$a,$b",
sort(map(string, split(single_deps_list, ","))))
return "$(bytes2hex(sha256(sorted_deps))).json"
return "$(arch)-$(bytes2hex(sha256(sorted_deps))).json"
end


Expand Down Expand Up @@ -61,7 +61,7 @@ end


"""
get_result_file_from_branch(single_deps_list::String)s
get_result_file_from_branch(single_deps_list::String; arch = "cpu")
is used to checkout corresponding result file from benchmark-results branch.
If possible, the result will help to skip benchmarks running.
Expand All @@ -72,8 +72,8 @@ the content of a file checked out by git. It can be "benchmark/result-baseline.j
TODO: badly-designed in semantic, due to the usage of `gen_result_filename``
"""
function get_result_file_from_branch(single_deps_list::String, checkout_filename::String)
result_filename = gen_result_filename(single_deps_list)
function get_result_file_from_branch(single_deps_list::String, checkout_filename::String; arch = "cpu")
result_filename = gen_result_filename(single_deps_list; arch=arch)
cmd = pipeline(`git show $RESULTS_BRANCH:$result_filename`
; stdout=checkout_filename)
try
Expand All @@ -89,13 +89,13 @@ end


"""
get_benchmarkresults_from_branch(single_deps_list::String)::Union{Nothing,BenchmarkResults}
get_benchmarkresults_from_branch(single_deps_list::String; arch = "cpu")::Union{Nothing,BenchmarkResults}
is used to get BenchmarkResults from deps-list.
"""
function get_benchmarkresults_from_branch(single_deps_list::String)::Union{Nothing,BenchmarkResults}
function get_benchmarkresults_from_branch(single_deps_list::String; arch = "cpu")::Union{Nothing,BenchmarkResults}
try
get_result_file_from_branch(single_deps_list, "tmp.json")
get_result_file_from_branch(single_deps_list, "tmp.json"; arch=arch)
catch
@warn "RESULT: get_result_file_from_branch failed to get result file with $single_deps_list."
return
Expand All @@ -115,7 +115,7 @@ TODO: badly-designed in semantic, due to the usage of `gen_result_filename`
TODO: need better way to process git_push_username and git_push_password
"""
function push_result(single_deps_list::String, result_file_path::String
; need_password = true, kwargs...)
; need_password = true, arch = "cpu", kwargs...)
# FIXME: a little bit hacked
REPO = LibGit2.GitRepo(joinpath(@__DIR__, "..", ".git"))
origin_remote = LibGit2.lookup_remote(REPO, "origin")
Expand All @@ -135,7 +135,7 @@ function push_result(single_deps_list::String, result_file_path::String
end

result_file_path_in_br_repo = joinpath(
LibGit2.path(br_repo), gen_result_filename(single_deps_list))
LibGit2.path(br_repo), gen_result_filename(single_deps_list; arch=arch))
mv(result_file_path, result_file_path_in_br_repo)
br_origin_remote = LibGit2.lookup_remote(br_repo, "origin")
if isnothing(br_origin_remote)
Expand Down

0 comments on commit 7f4eec5

Please sign in to comment.