Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Bagaev Dmitry <bvdmitri@gmail.com>
  • Loading branch information
bartvanerp and bvdmitri authored Nov 22, 2023
1 parent 7e8e9c0 commit 2868647
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Manifest.toml

.vscode
benchmark
exports
benchmarks/**/exports
14 changes: 2 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
SHELL = /bin/bash
.DEFAULT_GOAL = help

# Windows has different commands in shell
# - `RM` command: use for removing files
ifeq ($(OS), Windows_NT)
RM = del /Q /F
PATH_SEP = \\
else
RM = rm -rf
PATH_SEP = /
endif

.PHONY: test

test: ## Run tests, use test_args="folder1:test1 folder2:test2" argument to run reduced testset, use dev=true to use `dev-ed` version of core packages
julia -e 'ENV["USE_DEV"]="$(dev)"; import Pkg; Pkg.activate("."); Pkg.test(test_args = split("$(test_args)") .|> string);'
test: ## Run tests
julia -e 'import Pkg; Pkg.activate("."); Pkg.test();'

.PHONY: benchmark

benchmark: ## Run benchmarks
julia -e '\
ENV["USE_DEV"]="$(dev)"; \
import Pkg; \
Pkg.activate("benchmarks/speed"); \
using PkgBenchmark, FastCholesky, Dates; \
Expand Down
38 changes: 20 additions & 18 deletions benchmarks/speed/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ const SUITE = BenchmarkGroup()
# general benchmarks
for T in (Float32, Float64, BigFloat)

# number
a = rand(T)

SUITE["fastcholesky-" *"Type:"*string(T)] = @benchmarkable fastcholesky($a)
SUITE["fastcholesky!-" *"Type:"*string(T)] = @benchmarkable fastcholesky!($a)
SUITE["cholinv-" *"Type:"*string(T)] = @benchmarkable cholinv($a)
SUITE["cholsqrt-" *"Type:"*string(T)] = @benchmarkable cholsqrt($a)
SUITE["chollogdet-" *"Type:"*string(T)] = @benchmarkable chollogdet($a)
SUITE["cholinv_logdet-"*"Type:"*string(T)] = @benchmarkable cholinv_logdet($a)

for dim in (2, 5, 10, 20, 50, 100, 200, 500)

# generate positive-definite matrix of specified dimensions
A = randn(dim, dim)
B = A * A'
A = randn(T, dim, dim)
B = A * A' + dim * I(dim)
C = similar(B)

# define benchmarks
Expand All @@ -20,26 +30,18 @@ for T in (Float32, Float64, BigFloat)
SUITE["cholsqrt-" *"Type:Matrix{"*string(T)*"}-Dim:"*string(dim)] = @benchmarkable cholsqrt($B)
SUITE["chollogdet-" *"Type:Matrix{"*string(T)*"}-Dim:"*string(dim)] = @benchmarkable chollogdet($B)
SUITE["cholinv_logdet-"*"Type:Matrix{"*string(T)*"}-Dim:"*string(dim)] = @benchmarkable cholinv_logdet($B)


# Diagonal{T} benchmarks
SUITE["fastcholesky-" *"Type:Diagonal{"*string(T)*"}"] = @benchmarkable fastcholesky($(Diagonal(ones(T, dim))))
SUITE["cholinv-" *"Type:Diagonal{"*string(T)*"}"] = @benchmarkable cholinv($(Diagonal(ones(T, dim))))
SUITE["cholsqrt-" *"Type:Diagonal{"*string(T)*"}"] = @benchmarkable cholsqrt($(Diagonal(ones(T, dim))))
SUITE["chollogdet-" *"Type:Diagonal{"*string(T)*"}"] = @benchmarkable chollogdet($(Diagonal(ones(T, dim))))
SUITE["cholinv_logdet-"*"Type:Diagonal{"*string(T)*"}"] = @benchmarkable cholinv_logdet($(Diagonal(ones(T, dim))))

end

end

# Float64 benchmarks
SUITE["fastcholesky-" *"Type:Float64"] = @benchmarkable fastcholesky($3.0)
SUITE["fastcholesky!-" *"Type:Float64"] = @benchmarkable fastcholesky!($3.0)
SUITE["cholinv-" *"Type:Float64"] = @benchmarkable cholinv($3.0)
SUITE["cholsqrt-" *"Type:Float64"] = @benchmarkable cholsqrt($3.0)
SUITE["chollogdet-" *"Type:Float64"] = @benchmarkable chollogdet($3.0)
SUITE["cholinv_logdet-"*"Type:Float64"] = @benchmarkable cholinv_logdet($3.0)

# Diagonal{Float64} benchmarks
SUITE["fastcholesky-" *"Type:Diagonal{Float64}"] = @benchmarkable fastcholesky($(Diagonal(3.0*ones(100))))
SUITE["cholinv-" *"Type:Diagonal{Float64}"] = @benchmarkable cholinv($(Diagonal(3.0*ones(100))))
SUITE["cholsqrt-" *"Type:Diagonal{Float64}"] = @benchmarkable cholsqrt($(Diagonal(3.0*ones(100))))
SUITE["chollogdet-" *"Type:Diagonal{Float64}"] = @benchmarkable chollogdet($(Diagonal(3.0*ones(100))))
SUITE["cholinv_logdet-"*"Type:Diagonal{Float64}"] = @benchmarkable cholinv_logdet($(Diagonal(3.0*ones(100))))

# Uniformscaling benchmarks
SUITE["fastcholesky-" *"Type:UniformScaling"] = @benchmarkable fastcholesky($(3.0I))
SUITE["fastcholesky!-" *"Type:UniformScaling"] = @benchmarkable fastcholesky!($(3.0I))
Expand Down

0 comments on commit 2868647

Please sign in to comment.