Skip to content

Commit 86df987

Browse files
committed
Initial commit
0 parents  commit 86df987

31 files changed

+11611
-0
lines changed

.JuliaFormatter.toml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
style = "yas"

.github/workflows/CompatHelper.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CompatHelper
2+
on:
3+
schedule:
4+
- cron: 0 0 * * *
5+
workflow_dispatch:
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
jobs:
10+
CompatHelper:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check if Julia is already available in the PATH
14+
id: julia_in_path
15+
run: which julia
16+
continue-on-error: true
17+
- name: Install Julia, but only if it is not already available in the PATH
18+
uses: julia-actions/setup-julia@v1
19+
with:
20+
version: '1'
21+
arch: ${{ runner.arch }}
22+
if: steps.julia_in_path.outcome != 'success'
23+
- name: "Add the General registry via Git"
24+
run: |
25+
import Pkg
26+
ENV["JULIA_PKG_SERVER"] = ""
27+
Pkg.Registry.add("General")
28+
shell: julia --color=yes {0}
29+
- name: "Install CompatHelper"
30+
run: |
31+
import Pkg
32+
name = "CompatHelper"
33+
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
34+
version = "3"
35+
Pkg.add(; name, uuid, version)
36+
shell: julia --color=yes {0}
37+
- name: "Run CompatHelper"
38+
run: |
39+
import CompatHelper
40+
CompatHelper.main()
41+
shell: julia --color=yes {0}
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
45+
# COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}

.github/workflows/TagBot.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: TagBot
2+
on:
3+
issue_comment:
4+
types:
5+
- created
6+
workflow_dispatch:
7+
inputs:
8+
lookback:
9+
default: 3
10+
permissions:
11+
actions: read
12+
checks: read
13+
contents: write
14+
deployments: read
15+
issues: read
16+
discussions: read
17+
packages: read
18+
pages: read
19+
pull-requests: read
20+
repository-projects: read
21+
security-events: read
22+
statuses: read
23+
jobs:
24+
TagBot:
25+
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: JuliaRegistries/TagBot@v1
29+
with:
30+
token: ${{ secrets.GITHUB_TOKEN }}
31+
# Edit the following line to reflect the actual name of the GitHub Secret containing your private key
32+
ssh: ${{ secrets.DOCUMENTER_KEY }}
33+
# ssh: ${{ secrets.NAME_OF_MY_SSH_PRIVATE_KEY_SECRET }}
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI (Julia nightly)
2+
on:
3+
- push
4+
- pull_request
5+
jobs:
6+
test:
7+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
version:
13+
- 'nightly'
14+
os:
15+
- ubuntu-latest
16+
- macOS-latest
17+
- windows-latest
18+
arch:
19+
- x64
20+
steps:
21+
- uses: actions/checkout@v2
22+
- uses: julia-actions/setup-julia@v1
23+
with:
24+
version: ${{ matrix.version }}
25+
arch: ${{ matrix.arch }}
26+
- uses: julia-actions/julia-buildpkg@latest
27+
- uses: julia-actions/julia-runtest@latest
28+
env:
29+
JULIA_NUM_THREADS: 4
30+
- uses: julia-actions/julia-processcoverage@v1
31+
- uses: codecov/codecov-action@v1
32+
with:
33+
file: lcov.info

.github/workflows/ci.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
on:
3+
- push
4+
- pull_request
5+
jobs:
6+
test:
7+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
version:
13+
- '1.6'
14+
- '1' # automatically expands to the latest stable 1.x release of Julia
15+
os:
16+
- ubuntu-latest
17+
- macOS-latest
18+
- windows-latest
19+
arch:
20+
- x64
21+
steps:
22+
- uses: actions/checkout@v2
23+
- uses: julia-actions/setup-julia@v1
24+
with:
25+
version: ${{ matrix.version }}
26+
arch: ${{ matrix.arch }}
27+
- uses: julia-actions/julia-buildpkg@latest
28+
- uses: julia-actions/julia-runtest@latest
29+
env:
30+
JULIA_NUM_THREADS: 4
31+
- uses: julia-actions/julia-processcoverage@v1
32+
- uses: codecov/codecov-action@v1
33+
with:
34+
file: lcov.info

.github/workflows/format_check.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: format-check
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'release-'
8+
tags: '*'
9+
pull_request:
10+
11+
jobs:
12+
build:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
julia-version: [1]
17+
julia-arch: [x86]
18+
os: [ubuntu-latest]
19+
steps:
20+
- uses: julia-actions/setup-julia@latest
21+
with:
22+
version: ${{ matrix.julia-version }}
23+
24+
- uses: actions/checkout@v1
25+
- name: Install JuliaFormatter and format
26+
# This will use the latest version by default but you can set the version like so:
27+
#
28+
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
29+
run: |
30+
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
31+
julia -e 'using JuliaFormatter; format(".", verbose=true)'
32+
- name: Format check
33+
run: |
34+
julia -e '
35+
out = Cmd(`git diff --name-only`) |> read |> String
36+
if out == ""
37+
exit(0)
38+
else
39+
@error "Some files have not been formatted !!!"
40+
write(stdout, out)
41+
exit(1)
42+
end'

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.jl.cov
2+
*.jl.*.cov
3+
*.jl.mem
4+
Manifest.toml

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 lkdvos
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Project.toml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name = "TensorOperationsTBLIS"
2+
uuid = "1e289f0c-8058-4c3e-8acf-f8ef036bd865"
3+
authors = ["lkdvos <lukas.devos@ugent.be>"]
4+
version = "0.1.0"
5+
6+
[deps]
7+
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
8+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
9+
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
10+
TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6"
11+
tblis_jll = "9c7f617c-f299-5d18-afb6-044c7798b3d0"
12+
13+
[compat]
14+
TensorOperations = "4"
15+
TupleTools = "1"
16+
julia = "1.6 - 1"
17+
tblis_jll = "1.2"
18+
19+
[extras]
20+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
21+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
22+
23+
[targets]
24+
test = ["Test", "LinearAlgebra"]

README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# TensorOperationsTBLIS.jl
2+
[tblis](https://github.com/devinamatthews/tblis) wrapper for [TensorOperations.jl]()
3+
4+
[![CI][ci-img]][ci-url] [![CI (Julia nightly)][ci-julia-nightly-img]][ci-julia-nightly-url] [![][codecov-img]][codecov-url]
5+
6+
[ci-img]: https://github.com/lkdvos/TensorOperationsTBLIS.jl/actions/workflows/ci.yml/badge.svg
7+
[ci-url]: https://github.com/lkdvos/TensorOperationsTBLIS.jl/actions/workflows/ci.yml
8+
9+
[ci-julia-nightly-img]: https://github.com/lkdvos/TensorOperationsTBLIS.jl/actions/workflows/ci-julia-nightly.yml/badge.svg
10+
[ci-julia-nightly-url]: https://github.com/lkdvos/TensorOperationsTBLIS.jl/actions/workflows/ci-julia-nightly.yml
11+
12+
[codecov-img]: https://codecov.io/gh/lkdvos/TensorOperationsTBLIS.jl/branch/master/graph/badge.svg
13+
[codecov-url]: https://codecov.io/gh/lkdvos/TensorOperationsTBLIS.jl
14+
15+
Currently provides implementations of `tensorcontract!` and `tensoradd!` for `StridedArray{<:BlasFloat}`. These can be accessed through the backend system of TensorOperations, i.e.
16+
```julia
17+
using TensorOperations
18+
using TensorOperationsTBLIS
19+
20+
α = randn()
21+
A = randn(5, 5, 5, 5, 5, 5)
22+
B = randn(5, 5, 5)
23+
C = randn(5, 5, 5)
24+
D = zeros(5, 5, 5)
25+
26+
@tensor backend = tblis begin
27+
D2[a, b, c] = A[a, e, f, c, f, g] * B[g, b, e] + α * C[c, a, b]
28+
E2[a, b, c] := A[a, e, f, c, f, g] * B[g, b, e] + α * C[c, a, b]
29+
end
30+
```
31+
32+
Additionally, the number of threads used by tblis can be set by:
33+
```julia
34+
using TensorOperationsTBLIS
35+
tblis_set_num_threads(4)
36+
@show tblis_get_num_threads()
37+
```

gen/Project.toml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[deps]
2+
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
3+
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
4+
tblis_jll = "9c7f617c-f299-5d18-afb6-044c7798b3d0"

gen/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# How to auto-generate the wrappers
2+
3+
1. `cd` to this directory
4+
2. run `julia --project generator.jl`, then you could find the updated wrappers in the `lib` folder
5+
6+
## How to upgrade Clang.jl
7+
8+
1. `cd` to this directory
9+
2. run `julia --project` and then in the Julia REPL, run `pkg> up`

gen/generator.jl

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Pkg
2+
using Pkg.Artifacts
3+
using Clang.Generators
4+
using Clang.Generators.JLLEnvs
5+
using tblis_jll
6+
using JuliaFormatter
7+
8+
cd(@__DIR__)
9+
10+
# headers
11+
include_dir = normpath(joinpath(tblis_jll.artifact_dir, "include"))
12+
13+
tci_h = joinpath(include_dir, "tci.h")
14+
@assert isfile(tci_h)
15+
tblis_h = joinpath(include_dir, "tblis", "tblis.h")
16+
@assert isfile(tblis_h)
17+
18+
# load common option
19+
options = load_options(joinpath(@__DIR__, "generator.toml"))
20+
21+
# run generator for all platforms
22+
for target in JLLEnvs.JLL_ENV_TRIPLES
23+
@info "processing $target"
24+
25+
options["general"]["output_file_path"] = joinpath(@__DIR__, "..", "src", "lib",
26+
"$target.jl")
27+
28+
args = get_default_args(target)
29+
push!(args, "-I$include_dir")
30+
31+
header_files = [tci_h, tblis_h]
32+
33+
ctx = create_context(header_files, args, options)
34+
35+
build!(ctx)
36+
37+
path = options["general"]["output_file_path"]
38+
format_file(path, YASStyle())
39+
end

gen/generator.toml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[general]
2+
3+
library_name = "tblis"
4+
5+
use_julia_native_enum_type = true
6+
use_deterministic_symbol = true
7+
auto_mutability = true
8+
9+
output_ignorelist = [
10+
"TCI_WORK_ITEM_INIT",
11+
"TBLIS_RESTRICT",
12+
"scomplex",
13+
"dcomplex",
14+
]
15+
16+
[codegen]
17+
use_ccall_macro = true
18+
19+
[codegen.macro]
20+
macro_mode = "basic"
21+
22+
functionlike_macro_includelist = [
23+
24+
]

0 commit comments

Comments
 (0)