Skip to content

Commit

Permalink
auto format files using JuliaFormatter
Browse files Browse the repository at this point in the history
  • Loading branch information
maltezfaria committed Jul 8, 2023
1 parent b584039 commit 18d1348
Show file tree
Hide file tree
Showing 33 changed files with 1,390 additions and 1,285 deletions.
1 change: 1 addition & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
style = "yas"
42 changes: 42 additions & 0 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# modified from https://github.com/SciML/DiffEqDocs.jl/tree/master/.github/workflows
name: format-check

on:
push:
branches:
- 'main'
tags: '*'
pull_request:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1]
julia-arch: [x86]
os: [ubuntu-latest]
steps:
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.julia-version }}

- uses: actions/checkout@v1
- name: Install JuliaFormatter and format
# This will use the latest version by default but you can set the version like so:
#
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
julia -e 'using JuliaFormatter; format(".", verbose=true)'
- name: Format check
run: |
julia -e '
out = Cmd(`git diff --name-only`) |> read |> String
if out == ""
exit(0)
else
@error "Some files have not been formatted !!!"
write(stdout, out)
exit(1)
end'
34 changes: 21 additions & 13 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ K = laplace_matrix(X, Y)
irange = 1:N
jrange = 1:N

compressors = [PartialACA(rtol = rtol), ACA(rtol = rtol), TSVD(rtol = rtol)]
compressors = [PartialACA(; rtol=rtol), ACA(; rtol=rtol), TSVD(; rtol=rtol)]

for comp in compressors
SUITE["Compressors"][string(comp)] = @benchmarkable $comp($K, $irange, $jrange)
Expand Down Expand Up @@ -53,26 +53,34 @@ comp = HMatrices.PartialACA(; rtol)
step = 1.75 * π * radius / sqrt(N)
k = 2 * π / (10 * step) # 10 pts per wavelength

kernels = [
("Laplace", laplace_matrix(X, X), true),
("Helmholtz", helmholtz_matrix(X, X, k), true),
("LaplaceVec", LaplaceMatrixVec(Xp,Xp), false),
("HelmholtzVec", HelmholtzMatrixVec(Xp,Xp,k),false)
]
kernels = [("Laplace", laplace_matrix(X, X), true),
("Helmholtz", helmholtz_matrix(X, X, k), true),
("LaplaceVec", LaplaceMatrixVec(Xp, Xp), false),
("HelmholtzVec", HelmholtzMatrixVec(Xp, Xp, k), false)]

for (name, K, p) in kernels
SUITE[name] = BenchmarkGroup([name, N])
# bench assemble
SUITE[name]["assemble cpu"] = @benchmarkable assemble_hmat($K, $Xclt, $Xclt; adm = $adm, comp = $comp, threads = false, distributed = false, global_index = $p)
SUITE[name]["assemble threads"] = @benchmarkable assemble_hmat($K, $Xclt, $Xclt; adm = $adm, comp = $comp, threads = true, distributed = false, global_index = $p)
SUITE[name]["assemble cpu"] = @benchmarkable assemble_hmat($K, $Xclt, $Xclt; adm=$adm,
comp=$comp, threads=false,
distributed=false,
global_index=$p)
SUITE[name]["assemble threads"] = @benchmarkable assemble_hmat($K, $Xclt, $Xclt;
adm=$adm, comp=$comp,
threads=true,
distributed=false,
global_index=$p)
# SUITE[name]["assemble procs"] = @benchmarkable assemble_hmat($K, $Xclt, $Xclt; adm = $adm, comp = $comp, threads = false, distributed = true, global_index = $p)
# bench gemv only for regular case since the vectorized case should be the same
if p
x = rand(eltype(K), N)
y = zero(x)
H = assemble_hmat(K, Xclt, Xclt; adm, comp, threads = true, distributed = false, global_index = p)
SUITE[name]["gemv cpu"] = @benchmarkable mul!($y, $H, $x, $1, $0; threads = false, global_index = $p)
SUITE[name]["gemv threads"] = @benchmarkable mul!($y, $H, $x, $1, $0; threads = true, global_index = $p)
SUITE[name]["lu"] = @benchmarkable lu!($H;rank=5)
H = assemble_hmat(K, Xclt, Xclt; adm, comp, threads=true, distributed=false,
global_index=p)
SUITE[name]["gemv cpu"] = @benchmarkable mul!($y, $H, $x, $1, $0; threads=false,
global_index=$p)
SUITE[name]["gemv threads"] = @benchmarkable mul!($y, $H, $x, $1, $0; threads=true,
global_index=$p)
SUITE[name]["lu"] = @benchmarkable lu!($H; rank=5)
end
end
19 changes: 9 additions & 10 deletions benchmark/make.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
using PkgBenchmark

function postprocess(results,fname="benchs")
function postprocess(results, fname="benchs")
# writeresults(joinpath(path,fname),results)
dir = @__DIR__
path = joinpath(dir,"../docs/src")
export_markdown(joinpath(path,fname*".md"),results)
path = joinpath(dir, "../docs/src")
return export_markdown(joinpath(path, fname * ".md"), results)
end

env = Dict("JULIA_NUM_THREADS" =>4,
"OPEN_BLAS_NUM_THREADS" => 1
)
env = Dict("JULIA_NUM_THREADS" => 4,
"OPEN_BLAS_NUM_THREADS" => 1)

config = BenchmarkConfig(;juliacmd=`julia -O3`,env)
config = BenchmarkConfig(; juliacmd=`julia -O3`, env)

dir = @__DIR__
retune = false
results = benchmarkpkg("HMatrices",config;retune)
dir = @__DIR__
retune = false
results = benchmarkpkg("HMatrices", config; retune)

postprocess(results)
37 changes: 16 additions & 21 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,21 @@ using Documenter
DocMeta.setdocmeta!(HMatrices, :DocTestSetup, :(using HMatrices); recursive=true)

makedocs(;
modules=[HMatrices],
authors="Luiz M. Faria <maltezfaria@gmail.com> and contributors",
repo="https://github.com/WaveProp/HMatrices.jl/blob/{commit}{path}#{line}",
sitename="HMatrices.jl",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://WaveProp.github.io/HMatrices.jl",
assets=String[],
),
pages=[
"Getting started" => "index.md",
"Kernel matrices" => "kernelmatrix.md",
"Distributed HMatrix" => "dhmatrix.md",
"Notebooks" => "notebooks.md",
"Benchmarks" => ["benchs.md"],
"References" => "references.md"
],
)
modules=[HMatrices],
authors="Luiz M. Faria <maltezfaria@gmail.com> and contributors",
repo="https://github.com/WaveProp/HMatrices.jl/blob/{commit}{path}#{line}",
sitename="HMatrices.jl",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://WaveProp.github.io/HMatrices.jl",
assets=String[]),
pages=["Getting started" => "index.md",
"Kernel matrices" => "kernelmatrix.md",
"Distributed HMatrix" => "dhmatrix.md",
"Notebooks" => "notebooks.md",
"Benchmarks" => ["benchs.md"],
"References" => "references.md"])

deploydocs(;
repo="github.com/WaveProp/HMatrices.jl",
devbranch="main"
)
repo="github.com/WaveProp/HMatrices.jl",
devbranch="main")
Loading

0 comments on commit 18d1348

Please sign in to comment.