Skip to content

Commit 52b92fb

Browse files
committed
gh ci; minor fixes; blas tests
1 parent 28a01a4 commit 52b92fb

File tree

5 files changed

+82
-8
lines changed

5 files changed

+82
-8
lines changed

.github/workflows/CI.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Run tests
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'README.md'
7+
branches:
8+
- main
9+
pull_request:
10+
paths-ignore:
11+
- 'README.md'
12+
branches:
13+
- main
14+
15+
jobs:
16+
test:
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
julia-version: [1.6, 1.8]
22+
julia-arch: [x64]
23+
os: [ubuntu-latest, windows-latest, macOS-latest]
24+
# exclude:
25+
# - os: macOS-latest
26+
# julia-arch: x86
27+
28+
steps:
29+
- uses: actions/checkout@v1.0.0
30+
- uses: julia-actions/setup-julia@latest
31+
with:
32+
version: ${{ matrix.julia-version }}
33+
- uses: julia-actions/julia-buildpkg@master
34+
- uses: julia-actions/julia-runtest@master
35+
- uses: julia-actions/julia-uploadcodecov@master
36+
env:
37+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
38+
# - uses: julia-actions/julia-uploadcoveralls@master
39+
# env:
40+
# COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/Manifest.toml
2+
.vscode

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ blis_jll = "0.9"
1212
julia = "1"
1313

1414
[extras]
15+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1516
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1617

1718
[targets]
18-
test = ["Test"]
19+
test = ["Test", "LinearAlgebra"]

src/BLISBLAS.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ using blis_jll
44
using LinearAlgebra
55

66
function get_num_threads()
7-
err = @ccall blis.bli_thread_get_num_threads()::Cint
8-
err == -1 && throw(ErrorException("return value was -1"))
9-
return nothing
7+
ret = @ccall blis.bli_thread_get_num_threads()::Cint
8+
ret == -1 && throw(ErrorException("return value was -1"))
9+
return ret
1010
end
1111

1212
function set_num_threads(nthreads)
13-
err = @ccall blis.bli_thread_set_num_threads(nthreads::Cint)::Cvoid
14-
err == -1 && throw(ErrorException("return value was -1"))
13+
ret = @ccall blis.bli_thread_set_num_threads(nthreads::Cint)::Cvoid
14+
ret == -1 && throw(ErrorException("return value was -1"))
1515
return nothing
1616
end
1717

test/runtests.jl

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
1-
using BLISBLAS
21
using Test
2+
using LinearAlgebra
3+
4+
function blas()
5+
libs = BLAS.get_config().loaded_libs
6+
lib = lowercase(basename(last(libs).libname))
7+
if contains(lib, "openblas")
8+
return :openblas
9+
elseif contains(lib, "blis")
10+
return :blis
11+
else
12+
return :unknown
13+
end
14+
end
315

416
@testset "BLISBLAS.jl" begin
5-
# Write your tests here.
17+
@testset "Sanity Tests" begin
18+
@test blas() == :openblas
19+
using BLISBLAS
20+
@test blas() == :blis
21+
@test LinearAlgebra.peakflops() > 0
22+
end
23+
24+
@testset "BLAS threads" begin
25+
@test isnothing(BLISBLAS.set_num_threads(1))
26+
@test BLISBLAS.get_num_threads() == 1
27+
@test isnothing(BLISBLAS.set_num_threads(2))
28+
@test BLISBLAS.get_num_threads() == 2
29+
@test isnothing(BLISBLAS.set_num_threads(3))
30+
@test BLISBLAS.get_num_threads() == 3
31+
end
32+
33+
@testset "BLAS" begin
34+
# run all BLAS tests of the LinearAlgebra stdlib (i.e. LinearAlgebra/test/blas.jl)
35+
linalg_stdlib_test_path = joinpath(dirname(pathof(LinearAlgebra)), "..", "test")
36+
include(joinpath(linalg_stdlib_test_path, "blas.jl"))
37+
end
638
end

0 commit comments

Comments
 (0)