Skip to content

Instantly share code, notes, and snippets.

@tkf
Last active October 19, 2021 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkf/94b1a4110d90f26251c1d2de4999cab2 to your computer and use it in GitHub Desktop.
Save tkf/94b1a4110d90f26251c1d2de4999cab2 to your computer and use it in GitHub Desktop.
/backup
/build
/report
/tmp
#!/bin/bash
cat <<'EOF'
# Analysis of parallel matrix-matrix multiplication DAG
## Target summary
```
EOF
cat build/target/result.txt
cat <<'EOF'
```
## Baseline summary
```
EOF
cat build/baseline/result.txt
cat <<'EOF'
```
## DAG
| Baseline | Target |
| --- | --- |
| ![][baseline_dag.png] | ![][target_dag.png] |
[baseline_dag.png]: https://gist.githubusercontent.com/tkf/44a71bfb26f27efafa2edafbc0c87092/raw/baseline_dag.png
[target_dag.png]: https://gist.githubusercontent.com/tkf/44a71bfb26f27efafa2edafbc0c87092/raw/target_dag.png
EOF
using FileIO
using Gaius
using TaskDAGAnalyzers
using TaskDAGRecorders
resultlabel() =
if realpath(Base.active_project()) == realpath(joinpath(@__DIR__, "Project.toml"))
"baseline"
elseif realpath(Base.active_project()) == realpath(joinpath(@__DIR__, "build", "target", "Project.toml"))
"target"
else
"tmp"
end
default_resultdir() = joinpath(@__DIR__, "build", resultlabel())
function analyze_dag(resultdir = default_resultdir())
mkpath(resultdir)
n = 256
A = randn(n, n)
B = randn(n, n)
C = zero(B)
samplemul(args...) =
TaskDAGRecorders.sample(args...) do
Gaius.mul!(C, A, B)
end
ctx = samplemul()
ctx = samplemul()
ctx = samplemul()
dag = TaskDAGAnalyzers.dag(ctx)
s = TaskDAGAnalyzers.summary(ctx)
open(joinpath(resultdir, "result.txt"), write = true) do io
println(io, "size(A) = ($n, $n)")
println(io)
show(io, "text/plain", s)
println(io)
end
save(joinpath(resultdir, "dag.png"), dag)
save(joinpath(resultdir, "dag.svg"), dag)
return s
end
if abspath(PROGRAM_FILE) == @__FILE__
resultdir, = ARGS
analyze_dag(resultdir)
end
JULIA ?= julia
JULIA_CMD ?= $(JULIA) --color=yes --startup-file=no
JULIA_PKG_PRECOMPILE_AUTO = 0
export JULIA_PKG_PRECOMPILE_AUTO
.PHONY: analyze report upload update-patch backup
analyze: build/baseline/dag.svg build/target/dag.svg
build/baseline/dag.svg:
$(JULIA_CMD) --project=$(PWD) analyze_mat_mat_mul.jl $$(dirname $@)
build/target/dag.svg: build/target/Manifest.toml
$(JULIA_CMD) --project=$$(dirname $@) analyze_mat_mat_mul.jl $$(dirname $@)
build/target/Manifest.toml: Manifest.toml manifest.patch
mkdir -p build/target tmp
cp --target-directory=tmp Project.toml Manifest.toml
patch --directory=tmp < manifest.patch
JULIA_LOAD_PATH=@:@stdlib $(JULIA_CMD) --project=tmp \
-e 'using Pkg; Pkg.resolve(); Pkg.instantiate()'
mv tmp/Project.toml build/target/
mv tmp/Manifest.toml $@
update-patch:
if diff -u Manifest.toml build/target/Manifest.toml > manifest.patch.tmp; \
then \
exit 1; \
else \
mv manifest.patch.tmp manifest.patch; \
exit 0; \
fi
report:
cp build/baseline/dag.png report/baseline_dag.png
cp build/baseline/dag.svg report/baseline_dag.svg
cp build/target/dag.png report/target_dag.png
cp build/target/dag.svg report/target_dag.svg
./00_mat_mat_mul_dag.md.sh > report/00_mat_mat_mul_dag.md
upload:
git -C report add .
git -C report commit --allow-empty-message -m ""
git -C report push origin master
report/.git:
git clone git@gist.github.com:44a71bfb26f27efafa2edafbc0c87092 report
backup:
mkdir -p backup
mv build backup/build-$$(date +%Y-%m-%d-%H%M%S)
--- Manifest.toml 2021-10-18 22:46:18.667130177 -0400
+++ build/target/Manifest.toml 2021-10-18 23:04:07.848960025 -0400
@@ -79,8 +79,8 @@
[[Gaius]]
deps = ["LinearAlgebra", "LoopVectorization", "Random", "StructArrays", "TaskDAGRecorders", "UnsafeArrays", "VectorizationBase"]
-git-tree-sha1 = "ed69cec7c7bbe9fa9e9b58b8ac15e5e8895aea4d"
-repo-rev = "dag"
+git-tree-sha1 = "c11355a8b11344d0f349e3bb56beb25c220c99a8"
+repo-rev = "mat-mat-mul-dag"
repo-url = "https://github.com/tkf/Gaius.jl.git"
uuid = "bffe22d1-cb55-4f4e-ac2c-f4dd4bf58912"
version = "0.6.5"
# This file is machine-generated - editing it directly is not advised
[[Adapt]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "84918055d15b3114ede17ac6a7182f68870c16f7"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "3.3.1"
[[ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
[[ArrayInterface]]
deps = ["Compat", "IfElse", "LinearAlgebra", "Requires", "SparseArrays", "Static"]
git-tree-sha1 = "b8d49c34c3da35f220e7295659cd0bab8e739fed"
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "3.1.33"
[[Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[BitTwiddlingConvenienceFunctions]]
deps = ["Static"]
git-tree-sha1 = "652aab0fc0d6d4db4cc726425cadf700e9f473f1"
uuid = "62783981-4cbd-42fc-bca8-16325de8dc4b"
version = "0.1.0"
[[CPUSummary]]
deps = ["Hwloc", "IfElse", "Static"]
git-tree-sha1 = "38d0941d2ce6dd96427fd033d45471e1f26c3865"
uuid = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9"
version = "0.1.5"
[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "31d0151f5716b655421d9d75b7fa74cc4e744df2"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.39.0"
[[DataAPI]]
git-tree-sha1 = "cc70b17275652eb47bc9e5f81635981f13cea5c8"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.9.0"
[[DataValueInterfaces]]
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
version = "1.0.0"
[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
[[DelimitedFiles]]
deps = ["Mmap"]
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"
[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
[[DocStringExtensions]]
deps = ["LibGit2"]
git-tree-sha1 = "a32185f5428d3986f47c2ab78b1f216d5e6cc96f"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.8.5"
[[Downloads]]
deps = ["ArgTools", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
[[FileIO]]
deps = ["Pkg", "Requires", "UUIDs"]
git-tree-sha1 = "3c041d2ac0a52a12a27af2782b34900d9c3ee68c"
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
version = "1.11.1"
[[Gaius]]
deps = ["LinearAlgebra", "LoopVectorization", "Random", "StructArrays", "TaskDAGRecorders", "UnsafeArrays", "VectorizationBase"]
git-tree-sha1 = "ed69cec7c7bbe9fa9e9b58b8ac15e5e8895aea4d"
repo-rev = "dag"
repo-url = "https://github.com/tkf/Gaius.jl.git"
uuid = "bffe22d1-cb55-4f4e-ac2c-f4dd4bf58912"
version = "0.6.5"
[[HostCPUFeatures]]
deps = ["BitTwiddlingConvenienceFunctions", "IfElse", "Libdl", "Static"]
git-tree-sha1 = "3169c8b31863f9a409be1d17693751314241e3eb"
uuid = "3e5b6fbb-0976-4d2c-9146-d79de83f2fb0"
version = "0.1.4"
[[Hwloc]]
deps = ["Hwloc_jll"]
git-tree-sha1 = "92d99146066c5c6888d5a3abc871e6a214388b91"
uuid = "0e44f5e4-bd66-52a0-8798-143a42290a1d"
version = "2.0.0"
[[Hwloc_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "3395d4d4aeb3c9d31f5929d32760d8baeee88aaf"
uuid = "e33a78d0-f292-5ffc-b300-72abe9b543c8"
version = "2.5.0+0"
[[IfElse]]
git-tree-sha1 = "28e837ff3e7a6c3cdb252ce49fb412c8eb3caeef"
uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
version = "0.1.0"
[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
[[IteratorInterfaceExtensions]]
git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
uuid = "82899510-4779-5014-852e-03e436cf321d"
version = "1.0.0"
[[JLLWrappers]]
deps = ["Preferences"]
git-tree-sha1 = "642a199af8b68253517b80bd3bfd17eb4e84df6e"
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
version = "1.3.0"
[[LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
[[LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
[[LibGit2]]
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
[[LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
[[LinearAlgebra]]
deps = ["Libdl"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
[[LoopVectorization]]
deps = ["ArrayInterface", "DocStringExtensions", "IfElse", "LinearAlgebra", "OffsetArrays", "Polyester", "Requires", "SLEEFPirates", "Static", "StrideArraysCore", "ThreadingUtilities", "UnPack", "VectorizationBase"]
git-tree-sha1 = "9f23789217866ad9ecd053857ef202de5edcac4b"
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
version = "0.12.65"
[[ManualMemory]]
git-tree-sha1 = "9cb207b18148b2199db259adfa923b45593fe08e"
uuid = "d125e4d3-2237-4719-b19c-fa641b8a4667"
version = "0.1.6"
[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
[[MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
[[MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
[[NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
[[OffsetArrays]]
deps = ["Adapt"]
git-tree-sha1 = "c0e9e582987d36d5a61e650e6e543b9e44d9914b"
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
version = "1.10.7"
[[Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
[[Polyester]]
deps = ["ArrayInterface", "IfElse", "ManualMemory", "Requires", "Static", "StrideArraysCore", "ThreadingUtilities", "VectorizationBase"]
git-tree-sha1 = "3ced65f2f182e5b5335a573eaa98f883eba3678b"
uuid = "f517fe37-dbe3-4b94-8317-1923a5111588"
version = "0.3.9"
[[Preferences]]
deps = ["TOML"]
git-tree-sha1 = "00cfd92944ca9c760982747e9a1d0d5d86ab1e5a"
uuid = "21216c6a-2e73-6563-6e65-726566657250"
version = "1.2.2"
[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[[Requires]]
deps = ["UUIDs"]
git-tree-sha1 = "4036a3bd08ac7e968e27c203d45f5fff15020621"
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.1.3"
[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
[[SLEEFPirates]]
deps = ["IfElse", "Static", "VectorizationBase"]
git-tree-sha1 = "2e8150c7d2a14ac68537c7aac25faa6577aff046"
uuid = "476501e8-09a2-5ece-8869-fb82de89a1fa"
version = "0.6.27"
[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
[[SharedArrays]]
deps = ["Distributed", "Mmap", "Random", "Serialization"]
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
[[ShowGraphviz]]
git-tree-sha1 = "8c6829893fb9e2ca4b1c6d4426a7e383b7da5136"
repo-rev = "master"
repo-url = "https://github.com/tkf/ShowGraphviz.jl.git"
uuid = "14e20f5a-e304-4f94-b7d9-bca841234ddf"
version = "0.1.0-DEV"
[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
[[SparseArrays]]
deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
[[Static]]
deps = ["IfElse"]
git-tree-sha1 = "a8f30abc7c64a39d389680b74e749cf33f872a70"
uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
version = "0.3.3"
[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
[[StrideArraysCore]]
deps = ["ArrayInterface", "ManualMemory", "Requires", "ThreadingUtilities", "VectorizationBase"]
git-tree-sha1 = "9ab16bda5fe1212e0af0bea80f1d11096aeb3248"
uuid = "7792a7ef-975c-4747-a70f-980b88e8d1da"
version = "0.1.18"
[[StructArrays]]
deps = ["Adapt", "DataAPI", "Tables"]
git-tree-sha1 = "44b3afd37b17422a62aea25f04c1f7e09ce6b07f"
uuid = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
version = "0.5.1"
[[TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
[[TableTraits]]
deps = ["IteratorInterfaceExtensions"]
git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39"
uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
version = "1.0.1"
[[Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
git-tree-sha1 = "fed34d0e71b91734bf0a7e10eb1bb05296ddbcd0"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "1.6.0"
[[Tar]]
deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
[[TaskDAGAnalyzers]]
deps = ["ShowGraphviz", "TaskDAGRecorders"]
git-tree-sha1 = "740527d0615a047d51d9eac560e00981850d2ba5"
repo-rev = "master"
repo-url = "https://github.com/tkf/TaskDAGAnalyzers.jl.git"
uuid = "849e3927-aa76-4ecb-a639-b4166e142453"
version = "0.1.0-DEV"
[[TaskDAGRecorders]]
git-tree-sha1 = "9711565bd2dc807f2b4041713f23ca77b27bd98a"
repo-rev = "master"
repo-subdir = "lib/TaskDAGRecorders"
repo-url = "https://github.com/tkf/TaskDAGAnalyzers.jl.git"
uuid = "99c81307-7fbc-43d2-97a2-0be18af3842f"
version = "0.1.0-DEV"
[[Test]]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[ThreadingUtilities]]
deps = ["ManualMemory"]
git-tree-sha1 = "03013c6ae7f1824131b2ae2fc1d49793b51e8394"
uuid = "8290d209-cae3-49c0-8002-c8c24d57dab5"
version = "0.4.6"
[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
[[UnPack]]
git-tree-sha1 = "387c1f73762231e86e0c9c5443ce3b4a0a9a0c2b"
uuid = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
version = "1.0.2"
[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
[[UnsafeArrays]]
git-tree-sha1 = "038cd6ae292c857e6f91be52b81236607627aacd"
uuid = "c4a57d5a-5b31-53a6-b365-19f8c011fbd6"
version = "1.0.3"
[[VectorizationBase]]
deps = ["ArrayInterface", "CPUSummary", "HostCPUFeatures", "Hwloc", "IfElse", "Libdl", "LinearAlgebra", "Static"]
git-tree-sha1 = "5e6e23728d6c8d26d2826f6cb2cd21892a958a43"
uuid = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
version = "0.20.38"
[[Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
[[nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
[[p7zip_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
[deps]
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
Gaius = "bffe22d1-cb55-4f4e-ac2c-f4dd4bf58912"
ShowGraphviz = "14e20f5a-e304-4f94-b7d9-bca841234ddf"
TaskDAGAnalyzers = "849e3927-aa76-4ecb-a639-b4166e142453"
TaskDAGRecorders = "99c81307-7fbc-43d2-97a2-0be18af3842f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment