diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml new file mode 100644 index 0000000..9613e05 --- /dev/null +++ b/.JuliaFormatter.toml @@ -0,0 +1 @@ +style = "yas" \ No newline at end of file diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml new file mode 100644 index 0000000..3dfba52 --- /dev/null +++ b/.github/workflows/CompatHelper.yml @@ -0,0 +1,45 @@ +name: CompatHelper +on: + schedule: + - cron: 0 0 * * * + workflow_dispatch: +permissions: + contents: write + pull-requests: write +jobs: + CompatHelper: + runs-on: ubuntu-latest + steps: + - name: Check if Julia is already available in the PATH + id: julia_in_path + run: which julia + continue-on-error: true + - name: Install Julia, but only if it is not already available in the PATH + uses: julia-actions/setup-julia@v1 + with: + version: '1' + arch: ${{ runner.arch }} + if: steps.julia_in_path.outcome != 'success' + - name: "Add the General registry via Git" + run: | + import Pkg + ENV["JULIA_PKG_SERVER"] = "" + Pkg.Registry.add("General") + shell: julia --color=yes {0} + - name: "Install CompatHelper" + run: | + import Pkg + name = "CompatHelper" + uuid = "aa819f21-2bde-4658-8897-bab36330d9b7" + version = "3" + Pkg.add(; name, uuid, version) + shell: julia --color=yes {0} + - name: "Run CompatHelper" + run: | + import CompatHelper + CompatHelper.main() + shell: julia --color=yes {0} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} + # COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }} \ No newline at end of file diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml new file mode 100644 index 0000000..3042569 --- /dev/null +++ b/.github/workflows/TagBot.yml @@ -0,0 +1,33 @@ +name: TagBot +on: + issue_comment: + types: + - created + workflow_dispatch: + inputs: + lookback: + default: 3 +permissions: + actions: read + checks: read + contents: write + deployments: read + issues: read + discussions: read + packages: read + pages: read + pull-requests: read + repository-projects: read + security-events: read + statuses: read +jobs: + TagBot: + if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' + runs-on: ubuntu-latest + steps: + - uses: JuliaRegistries/TagBot@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + # Edit the following line to reflect the actual name of the GitHub Secret containing your private key + ssh: ${{ secrets.DOCUMENTER_KEY }} + # ssh: ${{ secrets.NAME_OF_MY_SSH_PRIVATE_KEY_SECRET }} \ No newline at end of file diff --git a/.github/workflows/ci-julia-nightly.yml b/.github/workflows/ci-julia-nightly.yml new file mode 100644 index 0000000..3bd44c5 --- /dev/null +++ b/.github/workflows/ci-julia-nightly.yml @@ -0,0 +1,33 @@ +name: CI (Julia nightly) +on: + - push + - pull_request +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + version: + - 'nightly' + os: + - ubuntu-latest + - macOS-latest + - windows-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + env: + JULIA_NUM_THREADS: 4 + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v1 + with: + file: lcov.info diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ea73d3a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI +on: + - push + - pull_request +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + version: + - '1.6' + - '1' # automatically expands to the latest stable 1.x release of Julia + os: + - ubuntu-latest + - macOS-latest + - windows-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + env: + JULIA_NUM_THREADS: 4 + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v1 + with: + file: lcov.info diff --git a/.github/workflows/format_check.yml b/.github/workflows/format_check.yml new file mode 100644 index 0000000..eb7d11d --- /dev/null +++ b/.github/workflows/format_check.yml @@ -0,0 +1,42 @@ +name: format-check + +on: + push: + branches: + - 'master' + - 'release-' + 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' \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0ee3d17 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.jl.cov +*.jl.*.cov +*.jl.mem +Manifest.toml \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ae6d431 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 lkdvos + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Project.toml b/Project.toml new file mode 100644 index 0000000..ffd970e --- /dev/null +++ b/Project.toml @@ -0,0 +1,24 @@ +name = "TensorOperationsTBLIS" +uuid = "1e289f0c-8058-4c3e-8acf-f8ef036bd865" +authors = ["lkdvos "] +version = "0.1.0" + +[deps] +Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2" +TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6" +tblis_jll = "9c7f617c-f299-5d18-afb6-044c7798b3d0" + +[compat] +TensorOperations = "4" +TupleTools = "1" +julia = "1.6 - 1" +tblis_jll = "1.2" + +[extras] +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[targets] +test = ["Test", "LinearAlgebra"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..4093753 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# TensorOperationsTBLIS.jl +[tblis](https://github.com/devinamatthews/tblis) wrapper for [TensorOperations.jl]() + +[![CI][ci-img]][ci-url] [![CI (Julia nightly)][ci-julia-nightly-img]][ci-julia-nightly-url] [![][codecov-img]][codecov-url] + +[ci-img]: https://github.com/lkdvos/TensorOperationsTBLIS.jl/actions/workflows/ci.yml/badge.svg +[ci-url]: https://github.com/lkdvos/TensorOperationsTBLIS.jl/actions/workflows/ci.yml + +[ci-julia-nightly-img]: https://github.com/lkdvos/TensorOperationsTBLIS.jl/actions/workflows/ci-julia-nightly.yml/badge.svg +[ci-julia-nightly-url]: https://github.com/lkdvos/TensorOperationsTBLIS.jl/actions/workflows/ci-julia-nightly.yml + +[codecov-img]: https://codecov.io/gh/lkdvos/TensorOperationsTBLIS.jl/branch/master/graph/badge.svg +[codecov-url]: https://codecov.io/gh/lkdvos/TensorOperationsTBLIS.jl + +Currently provides implementations of `tensorcontract!` and `tensoradd!` for `StridedArray{<:BlasFloat}`. These can be accessed through the backend system of TensorOperations, i.e. +```julia +using TensorOperations +using TensorOperationsTBLIS + +α = randn() +A = randn(5, 5, 5, 5, 5, 5) +B = randn(5, 5, 5) +C = randn(5, 5, 5) +D = zeros(5, 5, 5) + +@tensor backend = tblis begin + D2[a, b, c] = A[a, e, f, c, f, g] * B[g, b, e] + α * C[c, a, b] + E2[a, b, c] := A[a, e, f, c, f, g] * B[g, b, e] + α * C[c, a, b] +end +``` + +Additionally, the number of threads used by tblis can be set by: +```julia +using TensorOperationsTBLIS +tblis_set_num_threads(4) +@show tblis_get_num_threads() +``` diff --git a/gen/Project.toml b/gen/Project.toml new file mode 100644 index 0000000..478732e --- /dev/null +++ b/gen/Project.toml @@ -0,0 +1,4 @@ +[deps] +Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31" +JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" +tblis_jll = "9c7f617c-f299-5d18-afb6-044c7798b3d0" diff --git a/gen/README.md b/gen/README.md new file mode 100644 index 0000000..2e9b80b --- /dev/null +++ b/gen/README.md @@ -0,0 +1,9 @@ +# How to auto-generate the wrappers + +1. `cd` to this directory +2. run `julia --project generator.jl`, then you could find the updated wrappers in the `lib` folder + +## How to upgrade Clang.jl + +1. `cd` to this directory +2. run `julia --project` and then in the Julia REPL, run `pkg> up` diff --git a/gen/generator.jl b/gen/generator.jl new file mode 100644 index 0000000..45d1d81 --- /dev/null +++ b/gen/generator.jl @@ -0,0 +1,39 @@ +using Pkg +using Pkg.Artifacts +using Clang.Generators +using Clang.Generators.JLLEnvs +using tblis_jll +using JuliaFormatter + +cd(@__DIR__) + +# headers +include_dir = normpath(joinpath(tblis_jll.artifact_dir, "include")) + +tci_h = joinpath(include_dir, "tci.h") +@assert isfile(tci_h) +tblis_h = joinpath(include_dir, "tblis", "tblis.h") +@assert isfile(tblis_h) + +# load common option +options = load_options(joinpath(@__DIR__, "generator.toml")) + +# run generator for all platforms +for target in JLLEnvs.JLL_ENV_TRIPLES + @info "processing $target" + + options["general"]["output_file_path"] = joinpath(@__DIR__, "..", "src", "lib", + "$target.jl") + + args = get_default_args(target) + push!(args, "-I$include_dir") + + header_files = [tci_h, tblis_h] + + ctx = create_context(header_files, args, options) + + build!(ctx) + + path = options["general"]["output_file_path"] + format_file(path, YASStyle()) +end diff --git a/gen/generator.toml b/gen/generator.toml new file mode 100644 index 0000000..8f1c64a --- /dev/null +++ b/gen/generator.toml @@ -0,0 +1,24 @@ +[general] + +library_name = "tblis" + +use_julia_native_enum_type = true +use_deterministic_symbol = true +auto_mutability = true + +output_ignorelist = [ + "TCI_WORK_ITEM_INIT", + "TBLIS_RESTRICT", + "scomplex", + "dcomplex", +] + +[codegen] +use_ccall_macro = true + +[codegen.macro] +macro_mode = "basic" + +functionlike_macro_includelist = [ + +] \ No newline at end of file diff --git a/src/LibTblis.jl b/src/LibTblis.jl new file mode 100644 index 0000000..013ec79 --- /dev/null +++ b/src/LibTblis.jl @@ -0,0 +1,146 @@ +module LibTblis + +using tblis_jll +using LinearAlgebra: BlasFloat + +export tblis_scalar, tblis_matrix, tblis_tensor +export tblis_tensor_add, tblis_tensor_mult, tblis_tensor_dot +export tblis_set_num_threads, tblis_get_num_threads + +const ptrdiff_t = Cptrdiff_t + +const scomplex = ComplexF32 +const dcomplex = ComplexF64 + +const IS_LIBC_MUSL = occursin("musl", Base.BUILD_TRIPLET) +if Sys.isapple() && Sys.ARCH === :aarch64 + include("lib/aarch64-apple-darwin20.jl") +elseif Sys.islinux() && Sys.ARCH === :aarch64 && !IS_LIBC_MUSL + include("lib/aarch64-linux-gnu.jl") +elseif Sys.islinux() && Sys.ARCH === :aarch64 && IS_LIBC_MUSL + include("lib/aarch64-linux-musl.jl") +elseif Sys.islinux() && startswith(string(Sys.ARCH), "arm") && !IS_LIBC_MUSL + include("lib/armv7l-linux-gnueabihf.jl") +elseif Sys.islinux() && startswith(string(Sys.ARCH), "arm") && IS_LIBC_MUSL + include("lib/armv7l-linux-musleabihf.jl") +elseif Sys.islinux() && Sys.ARCH === :i686 && !IS_LIBC_MUSL + include("lib/i686-linux-gnu.jl") +elseif Sys.islinux() && Sys.ARCH === :i686 && IS_LIBC_MUSL + include("lib/i686-linux-musl.jl") +elseif Sys.iswindows() && Sys.ARCH === :i686 + include("lib/i686-w64-mingw32.jl") +elseif Sys.islinux() && Sys.ARCH === :powerpc64le + include("lib/powerpc64le-linux-gnu.jl") +elseif Sys.isapple() && Sys.ARCH === :x86_64 + include("lib/x86_64-apple-darwin14.jl") +elseif Sys.islinux() && Sys.ARCH === :x86_64 && !IS_LIBC_MUSL + include("lib/x86_64-linux-gnu.jl") +elseif Sys.islinux() && Sys.ARCH === :x86_64 && IS_LIBC_MUSL + include("lib/x86_64-linux-musl.jl") +elseif Sys.isbsd() && !Sys.isapple() + include("lib/x86_64-unknown-freebsd.jl") +elseif Sys.iswindows() && Sys.ARCH === :x86_64 + include("lib/x86_64-w64-mingw32.jl") +else + error("Unknown platform: $(Base.BUILD_TRIPLET)") +end + +# tblis_scalar +# ------------ +""" + tblis_scalar(s::Number) + +Initializes a tblis scalar from a number. +""" +function tblis_scalar end +function tblis_scalar(s::Float32) + t = Ref{tblis_scalar}() + tblis_init_scalar_s(t, s) + return t[] +end +function tblis_scalar(s::Float64) + t = Ref{tblis_scalar}() + tblis_init_scalar_d(t, s) + return t[] +end +function tblis_scalar(s::ComplexF32) + t = Ref{tblis_scalar}() + tblis_init_scalar_c(t, s) + return t[] +end +function tblis_scalar(s::ComplexF64) + t = Ref{tblis_scalar}() + tblis_init_scalar_z(t, s) + return t[] +end + +# tblis_tensor +# ------------ +""" + tblis_tensor(A::StridedArray{T<:BlasFloat}, szA::Vector{Int}, strA::Vector{Int}, s=one(T)) + +Initializes a tblis tensor from a strided array. This operation is deemed unsafe, in the +sense that the user is responsible for ensuring that the reference to the array and the +sizes and strides stays alive during the lifetime of the tensor. +""" +function tblis_tensor end + +function tblis_tensor(A::StridedArray{Float32,N}, szA::Vector{Int}, strA::Vector{Int}, + s::Number=one(Float32)) where {N} + t = Ref{tblis_tensor}() + if isone(s) + tblis_init_tensor_s(t, N, pointer(szA), pointer(A), pointer(strA)) + else + tblis_init_tensor_scaled_s(t, Float32(s), N, pointer(szA), pointer(A), + pointer(strA)) + end + return t[] +end +function tblis_tensor(A::StridedArray{Float64,N}, szA::Vector{Int}, strA::Vector{Int}, + s::Number=one(Float64)) where {N} + t = Ref{tblis_tensor}() + if isone(s) + tblis_init_tensor_d(t, N, pointer(szA), pointer(A), pointer(strA)) + else + tblis_init_tensor_scaled_d(t, Float64(s), N, pointer(szA), pointer(A), + pointer(strA)) + end + return t[] +end +function tblis_tensor(A::StridedArray{ComplexF32,N}, szA::Vector{Int}, strA::Vector{Int}, + s::Number=one(ComplexF32)) where {N} + t = Ref{tblis_tensor}() + if isone(s) + tblis_init_tensor_c(t, N, pointer(szA), pointer(A), pointer(strA)) + else + tblis_init_tensor_scaled_c(t, ComplexF32(s), N, pointer(szA), pointer(A), + pointer(strA)) + end + return t[] +end +function tblis_tensor(A::StridedArray{ComplexF64,N}, szA::Vector{Int}, strA::Vector{Int}, + s::Number=one(ComplexF64)) where {N} + t = Ref{tblis_tensor}() + if isone(s) + tblis_init_tensor_z(t, N, pointer(szA), pointer(A), pointer(strA)) + else + tblis_init_tensor_scaled_z(t, ComplexF64(s), N, pointer(szA), pointer(A), + pointer(strA)) + end + return t[] +end + +function tblis_tensor_add(A::tblis_tensor, idxA, B::tblis_tensor, idxB) + return tblis_tensor_add(C_NULL, C_NULL, Ref(A), idxA, Ref(B), idxB) +end + +function tblis_tensor_mult(A::tblis_tensor, idxA, B::tblis_tensor, idxB, C::tblis_tensor, + idxC) + return tblis_tensor_mult(C_NULL, C_NULL, Ref(A), idxA, Ref(B), idxB, Ref(C), idxC) +end + +function tblis_tensor_dot(A::tblis_tensor, idxA, B::tblis_tensor, idxB, C::tblis_scalar) + return tblis_tensor_dot(C_NULL, C_NULL, Ref(A), idxA, Ref(B), idxB, Ref(C)) +end + +end diff --git a/src/TensorOperationsTBLIS.jl b/src/TensorOperationsTBLIS.jl new file mode 100644 index 0000000..1d0142a --- /dev/null +++ b/src/TensorOperationsTBLIS.jl @@ -0,0 +1,77 @@ +module TensorOperationsTBLIS + +using TensorOperations +using TensorOperations: Index2Tuple, IndexTuple, linearize, IndexError +using LinearAlgebra: BlasFloat, rmul! +using TupleTools + +include("LibTblis.jl") +using .LibTblis + +export tblis_set_num_threads, tblis_get_num_threads + +# TensorOperations +#------------------ + +const TblisBackend = TensorOperations.Backend{:tblis} + +function TensorOperations.tensoradd!(C::StridedArray{T}, pC::Index2Tuple, + A::StridedArray{T}, conjA::Symbol, + α::Number, β::Number, + ::TblisBackend) where {T<:BlasFloat} + TensorOperations.argcheck_tensoradd(C, pC, A) + # check dimensions + size(C) == getindex.(Ref(size(A)), linearize(pC)) || + throw(DimensionMismatch("incompatible sizes")) + + szC = collect(size(C)) + strC = collect(strides(C)) + C_tblis = tblis_tensor(C, szC, strC, β) + + szA = collect(size(A)) + strA = collect(strides(A)) + A_tblis = tblis_tensor(conjA == :C ? conj(A) : A, szA, strA, α) + + einA, einC = TensorOperations.add_labels(pC) + tblis_tensor_add(A_tblis, string(einA...), C_tblis, string(einC...)) + + return C +end + +function TensorOperations.tensorcontract!(C::StridedArray{T}, pC::Index2Tuple, + A::StridedArray{T}, pA::Index2Tuple, + conjA::Symbol, B::StridedArray{T}, + pB::Index2Tuple, conjB::Symbol, α::Number, + β::Number, ::TblisBackend) where {T<:BlasFloat} + TensorOperations.argcheck_tensorcontract(C, pC, A, pA, B, pB) + TensorOperations.dimcheck_tensorcontract(C, pC, A, pA, B, pB) + + rmul!(C, β) + szC = ndims(C) == 0 ? Int[] : collect(size(C)) + strC = ndims(C) == 0 ? Int[] : collect(strides(C)) + C_tblis = tblis_tensor(C, szC, strC) + + szA = collect(size(A)) + strA = collect(strides(A)) + A_tblis = tblis_tensor(conjA == :C ? conj(A) : A, szA, strA, α) + + szB = collect(size(B)) + strB = collect(strides(B)) + B_tblis = tblis_tensor(conjB == :C ? conj(B) : B, szB, strB, 1) + + einA, einB, einC = TensorOperations.contract_labels(pA, pB, pC) + tblis_tensor_mult(A_tblis, string(einA...), B_tblis, string(einB...), C_tblis, + string(einC...)) + + return C +end + +# partial traces do not exist in tblis afaik -> use default implementation +function TensorOperations.tensortrace!(C::StridedArray{T}, pC::Index2Tuple, + A::StridedArray{T}, pA::Index2Tuple, conjA::Symbol, + α::Number, β::Number, + ::TblisBackend) where {T<:BlasFloat} + return tensortrace!(C, pC, A, pA, conjA, α, β) +end + +end # module TensorOperationsTBLIS diff --git a/src/lib/aarch64-apple-darwin20.jl b/src/lib/aarch64-apple-darwin20.jl new file mode 100644 index 0000000..3b87799 --- /dev/null +++ b/src/lib/aarch64-apple-darwin20.jl @@ -0,0 +1,779 @@ +# no prototype is found for this function at yield.h:27:17, please use with caution +function tci_yield() + @ccall tblis.tci_yield()::Cvoid +end + +const tci_mutex = Cchar + +function tci_mutex_init(mutex) + @ccall tblis.tci_mutex_init(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_destroy(mutex) + @ccall tblis.tci_mutex_destroy(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_lock(mutex) + @ccall tblis.tci_mutex_lock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutexrylock(mutex) + @ccall tblis.tci_mutexrylock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_unlock(mutex) + @ccall tblis.tci_mutex_unlock(mutex::Ptr{tci_mutex})::Cint +end + +struct tci_barrier_node + parent::Ptr{tci_barrier_node} + nchildren::Cuint + step::Cuint + nwaiting::Cuint +end + +function tci_barrier_node_init(barrier, parent, nchildren) + @ccall tblis.tci_barrier_node_init(barrier::Ptr{tci_barrier_node}, + parent::Ptr{tci_barrier_node}, + nchildren::Cuint)::Cint +end + +function tci_barrier_node_destroy(barrier) + @ccall tblis.tci_barrier_node_destroy(barrier::Ptr{tci_barrier_node})::Cint +end + +function tci_barrier_node_wait(barrier) + @ccall tblis.tci_barrier_node_wait(barrier::Ptr{tci_barrier_node})::Cint +end + +struct __JL_Ctag_18 + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{__JL_Ctag_18}, f::Symbol) + f === :array && return Ptr{Ptr{tci_barrier_node}}(x + 0) + f === :single && return Ptr{tci_barrier_node}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::__JL_Ctag_18, f::Symbol) + r = Ref{__JL_Ctag_18}(x) + ptr = Base.unsafe_convert(Ptr{__JL_Ctag_18}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{__JL_Ctag_18}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tci_barrier + data::NTuple{40,UInt8} +end + +function Base.getproperty(x::Ptr{tci_barrier}, f::Symbol) + f === :barrier && return Ptr{__JL_Ctag_18}(x + 0) + f === :nthread && return Ptr{Cuint}(x + 24) + f === :group_size && return Ptr{Cuint}(x + 28) + f === :is_tree && return Ptr{Cint}(x + 32) + return getfield(x, f) +end + +function Base.getproperty(x::tci_barrier, f::Symbol) + r = Ref{tci_barrier}(x) + ptr = Base.unsafe_convert(Ptr{tci_barrier}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tci_barrier}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tci_barrier_is_tree(barrier) + @ccall tblis.tci_barrier_is_tree(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_init(barrier, nthread, group_size) + @ccall tblis.tci_barrier_init(barrier::Ptr{tci_barrier}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_barrier_destroy(barrier) + @ccall tblis.tci_barrier_destroy(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_wait(barrier, tid) + @ccall tblis.tci_barrier_wait(barrier::Ptr{tci_barrier}, tid::Cuint)::Cint +end + +struct tci_context + barrier::tci_barrier + buffer::Ptr{Cvoid} + refcount::Cuint +end + +function tci_context_init(context, nthread, group_size) + @ccall tblis.tci_context_init(context::Ptr{Ptr{tci_context}}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_context_attach(context) + @ccall tblis.tci_context_attach(context::Ptr{tci_context})::Cint +end + +function tci_context_detach(context) + @ccall tblis.tci_context_detach(context::Ptr{tci_context})::Cint +end + +function tci_context_barrier(context, tid) + @ccall tblis.tci_context_barrier(context::Ptr{tci_context}, tid::Cuint)::Cint +end + +function tci_context_send(context, tid, object) + @ccall tblis.tci_context_send(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_send_nowait(context, tid, object) + @ccall tblis.tci_context_send_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_receive(context, tid, object) + @ccall tblis.tci_context_receive(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +function tci_context_receive_nowait(context, tid, object) + @ccall tblis.tci_context_receive_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +struct tci_comm + context::Ptr{tci_context} + ngang::Cuint + gid::Cuint + nthread::Cuint + tid::Cuint +end + +@enum __JL_Ctag_4::UInt32 begin + TCI_EVENLY = 2 + TCI_CYCLIC = 4 + TCI_BLOCK_CYCLIC = 6 + TCI_BLOCKED = 8 + TCI_NO_CONTEXT = 1 +end + +mutable struct tci_range + size::UInt64 + grain::UInt64 + tci_range() = new() +end + +# typedef void ( * tci_range_func ) ( tci_comm * , uint64_t , uint64_t , void * ) +const tci_range_func = Ptr{Cvoid} + +# typedef void ( * tci_range_2d_func ) ( tci_comm * , uint64_t , uint64_t , uint64_t , uint64_t , void * ) +const tci_range_2d_func = Ptr{Cvoid} + +function tci_comm_init_single(comm) + @ccall tblis.tci_comm_init_single(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_init(comm, context, nthread, tid, ngang, gid) + @ccall tblis.tci_comm_init(comm::Ptr{tci_comm}, context::Ptr{tci_context}, + nthread::Cuint, tid::Cuint, ngang::Cuint, gid::Cuint)::Cint +end + +function tci_comm_destroy(comm) + @ccall tblis.tci_comm_destroy(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_is_master(comm) + @ccall tblis.tci_comm_is_master(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_barrier(comm) + @ccall tblis.tci_comm_barrier(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_bcast(comm, object, root) + @ccall tblis.tci_comm_bcast(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_bcast_nowait(comm, object, root) + @ccall tblis.tci_comm_bcast_nowait(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_gang(parent, child, type, n, bs) + @ccall tblis.tci_comm_gang(parent::Ptr{tci_comm}, child::Ptr{tci_comm}, type::Cint, + n::Cuint, bs::Cuint)::Cint +end + +function tci_comm_distribute_over_gangs(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_threads(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_gangs_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs_2d(comm::Ptr{tci_comm}, range_m::tci_range, + range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_threads_2d(comm::Ptr{tci_comm}, + range_m::tci_range, range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +# typedef void ( * tci_thread_func ) ( tci_comm * , void * ) +const tci_thread_func = Ptr{Cvoid} + +function tci_parallelize(func, payload, nthread, arity) + @ccall tblis.tci_parallelize(func::tci_thread_func, payload::Ptr{Cvoid}, nthread::Cuint, + arity::Cuint)::Cint +end + +struct tci_prime_factors + n::Cuint + sqrt_n::Cuint + f::Cuint +end + +function tci_prime_factorization(n, factors) + @ccall tblis.tci_prime_factorization(n::Cuint, factors::Ptr{tci_prime_factors})::Cvoid +end + +function tci_next_prime_factor(factors) + @ccall tblis.tci_next_prime_factor(factors::Ptr{tci_prime_factors})::Cuint +end + +function tci_partition_2x2(nthread, work1, max1, work2, max2, nt1, nt2) + @ccall tblis.tci_partition_2x2(nthread::Cuint, work1::UInt64, max1::Cuint, + work2::UInt64, max2::Cuint, nt1::Ptr{Cuint}, + nt2::Ptr{Cuint})::Cvoid +end + +const tci_slot = Cint + +function tci_slot_init(slot, empty) + @ccall tblis.tci_slot_init(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_is_filled(slot, empty) + @ccall tblis.tci_slot_is_filled(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_try_fill(slot, empty, value) + @ccall tblis.tci_slot_try_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cint +end + +function tci_slot_fill(slot, empty, value) + @ccall tblis.tci_slot_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cvoid +end + +function tci_slot_clear(slot, empty) + @ccall tblis.tci_slot_clear(slot::Ptr{tci_slot}, empty::Cint)::Cvoid +end + +@enum __JL_Ctag_5::UInt32 begin + TCI_NOT_WORKED_ON = 0 + TCI_IN_PROGRESS = 1 + TCI_RESERVED = 2 + TCI_FINISHED = 3 +end + +const tci_work_item = Cint + +function tci_work_item_try_work(item) + @ccall tblis.tci_work_item_try_work(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_finish(item) + @ccall tblis.tci_work_item_finish(item::Ptr{tci_work_item})::Cvoid +end + +function tci_work_item_status(item) + @ccall tblis.tci_work_item_status(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_wait(item) + @ccall tblis.tci_work_item_wait(item::Ptr{tci_work_item})::Cvoid +end + +mutable struct tblis_config_s end + +const tblis_config = tblis_config_s + +@enum reduce_t::UInt32 begin + REDUCE_SUM = 0 + REDUCE_SUM_ABS = 1 + REDUCE_MAX = 2 + REDUCE_MAX_ABS = 3 + REDUCE_MIN = 4 + REDUCE_MIN_ABS = 5 + # REDUCE_NORM_1 = 1 + REDUCE_NORM_2 = 6 + # REDUCE_NORM_INF = 3 +end + +@enum type_t::UInt32 begin + TYPE_SINGLE = 0 + # TYPE_FLOAT = 0 + TYPE_DOUBLE = 1 + TYPE_SCOMPLEX = 2 + TYPE_DCOMPLEX = 3 +end + +const len_type = Cptrdiff_t + +const stride_type = Cptrdiff_t + +const label_type = Cchar + +mutable struct fake_scomplex + real::Cfloat + imag::Cfloat + fake_scomplex() = new() +end + +mutable struct fake_dcomplex + real::Cdouble + imag::Cdouble + fake_dcomplex() = new() +end + +struct scalar + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{scalar}, f::Symbol) + f === :s && return Ptr{Cfloat}(x + 0) + f === :d && return Ptr{Cdouble}(x + 0) + f === :c && return Ptr{scomplex}(x + 0) + f === :z && return Ptr{dcomplex}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::scalar, f::Symbol) + r = Ref{scalar}(x) + ptr = Base.unsafe_convert(Ptr{scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tblis_scalar + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{tblis_scalar}, f::Symbol) + f === :data && return Ptr{scalar}(x + 0) + f === :type && return Ptr{type_t}(x + 16) + return getfield(x, f) +end + +function Base.getproperty(x::tblis_scalar, f::Symbol) + r = Ref{tblis_scalar}(x) + ptr = Base.unsafe_convert(Ptr{tblis_scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tblis_scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tblis_init_scalar_s(s, value) + @ccall tblis.tblis_init_scalar_s(s::Ptr{tblis_scalar}, value::Cfloat)::Cvoid +end + +function tblis_init_scalar_d(s, value) + @ccall tblis.tblis_init_scalar_d(s::Ptr{tblis_scalar}, value::Cdouble)::Cvoid +end + +function tblis_init_scalar_c(s, value) + @ccall tblis.tblis_init_scalar_c(s::Ptr{tblis_scalar}, value::scomplex)::Cvoid +end + +function tblis_init_scalar_z(s, value) + @ccall tblis.tblis_init_scalar_z(s::Ptr{tblis_scalar}, value::dcomplex)::Cvoid +end + +mutable struct tblis_vector + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + n::len_type + inc::stride_type + tblis_vector() = new() +end + +function tblis_init_vector_scaled_s(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_s(v::Ptr{tblis_vector}, scalar_::Cfloat, + n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_d(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_d(v::Ptr{tblis_vector}, scalar_::Cdouble, + n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_c(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_c(v::Ptr{tblis_vector}, scalar_::scomplex, + n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_z(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_z(v::Ptr{tblis_vector}, scalar_::dcomplex, + n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_s(v, n, data, inc) + @ccall tblis.tblis_init_vector_s(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_d(v, n, data, inc) + @ccall tblis.tblis_init_vector_d(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_c(v, n, data, inc) + @ccall tblis.tblis_init_vector_c(v::Ptr{tblis_vector}, n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_z(v, n, data, inc) + @ccall tblis.tblis_init_vector_z(v::Ptr{tblis_vector}, n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +mutable struct tblis_matrix + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + m::len_type + n::len_type + rs::stride_type + cs::stride_type + tblis_matrix() = new() +end + +function tblis_init_matrix_scaled_s(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_s(mat::Ptr{tblis_matrix}, scalar_::Cfloat, + m::len_type, n::len_type, data::Ptr{Cfloat}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_d(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_d(mat::Ptr{tblis_matrix}, scalar_::Cdouble, + m::len_type, n::len_type, data::Ptr{Cdouble}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_c(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_c(mat::Ptr{tblis_matrix}, scalar_::scomplex, + m::len_type, n::len_type, data::Ptr{scomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_z(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_z(mat::Ptr{tblis_matrix}, scalar_::dcomplex, + m::len_type, n::len_type, data::Ptr{dcomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_s(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_s(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cfloat}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_d(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_d(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cdouble}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_c(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_c(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{scomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_z(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_z(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{dcomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +struct tblis_tensor + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + ndim::Cuint + len::Ptr{len_type} + stride::Ptr{stride_type} +end + +function tblis_init_tensor_scaled_s(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_s(t::Ptr{tblis_tensor}, scalar_::Cfloat, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_d(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_d(t::Ptr{tblis_tensor}, scalar_::Cdouble, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_c(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_c(t::Ptr{tblis_tensor}, scalar_::scomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_z(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_z(t::Ptr{tblis_tensor}, scalar_::dcomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_s(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_s(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_d(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_d(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_c(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_c(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_z(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_z(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_get_config(name) + @ccall tblis.tblis_get_config(name::Ptr{Cchar})::Ptr{tblis_config} +end + +const tblis_comm = tci_comm + +# no prototype is found for this function at thread.h:21:10, please use with caution +function tblis_get_num_threads() + @ccall tblis.tblis_get_num_threads()::Cuint +end + +function tblis_set_num_threads(num_threads) + @ccall tblis.tblis_set_num_threads(num_threads::Cuint)::Cvoid +end + +function tblis_vector_add(comm, cfg, A, B) + @ccall tblis.tblis_vector_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_vector_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_vector_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_vector_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_vector}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_vector_scale(comm, cfg, A) + @ccall tblis.tblis_vector_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_set(comm, cfg, alpha, A) + @ccall tblis.tblis_vector_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_vector})::Cvoid +end + +function tblis_matrix_add(comm, cfg, A, B) + @ccall tblis.tblis_matrix_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_matrix_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_matrix_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_matrix_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_matrix_scale(comm, cfg, A) + @ccall tblis.tblis_matrix_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_set(comm, cfg, alpha, A) + @ccall tblis.tblis_matrix_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_add(comm, cfg, A, idx_A, B, idx_B) + @ccall tblis.tblis_tensor_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type})::Cvoid +end + +function tblis_tensor_dot(comm, cfg, A, idx_A, B, idx_B, result) + @ccall tblis.tblis_tensor_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_tensor_reduce(comm, cfg, op, A, idx_A, result, idx) + @ccall tblis.tblis_tensor_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type}, result::Ptr{tblis_scalar}, + idx::Ptr{len_type})::Cvoid +end + +function tblis_tensor_scale(comm, cfg, A, idx_A) + @ccall tblis.tblis_tensor_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type})::Cvoid +end + +function tblis_tensor_set(comm, cfg, alpha, A, idx_A) + @ccall tblis.tblis_tensor_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type})::Cvoid +end + +function tblis_matrix_mult(comm, cfg, A, B, C) + @ccall tblis.tblis_matrix_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_mult_diag(comm, cfg, A, D, B, C) + @ccall tblis.tblis_matrix_mult_diag(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, D::Ptr{tblis_vector}, + B::Ptr{tblis_matrix}, C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_mult(comm, cfg, A, idx_A, B, idx_B, C, idx_C) + @ccall tblis.tblis_tensor_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + C::Ptr{tblis_tensor}, idx_C::Ptr{label_type})::Cvoid +end + +const TCI_USE_ATOMIC_SPINLOCK = 1 + +const TCI_USE_OMP_LOCK = 0 + +const TCI_USE_OPENMP_THREADS = 1 + +const TCI_USE_WINDOWS_THREADS = 0 + +const TCI_USE_TBB_THREADS = 0 + +const TCI_USE_PPL_THREADS = 0 + +const TCI_USE_OMPTASK_THREADS = 0 + +const TCI_USE_DISPATCH_THREADS = 0 + +const TCI_USE_OSX_SPINLOCK = 0 + +const TCI_USE_PTHREADS_THREADS = 0 + +const TCI_USE_PTHREAD_BARRIER = 0 + +const TCI_USE_PTHREAD_MUTEX = 0 + +const TCI_USE_PTHREAD_SPINLOCK = 0 + +const TCI_USE_SPIN_BARRIER = 1 + +const TCI_ARCH_ARM64 = 1 + +# Skipping MacroDefinition: TCI_INLINE static inline + +const TBLIS_HAVE_SYSCONF = 1 + +const TBLIS_HAVE_SYSCTL = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_CONF = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_ONLN = 1 + +const TBLIS_LABEL_TYPE = Cchar + +const TBLIS_LEN_TYPE = ptrdiff_t + +const TBLIS_LT_OBJDIR = ".libs/" + +const TBLIS_PACKAGE = "tblis" + +const TBLIS_PACKAGE_BUGREPORT = "dmatthews@utexas.edu" + +const TBLIS_PACKAGE_NAME = "tblis" + +const TBLIS_PACKAGE_STRING = "tblis 1.2.0" + +const TBLIS_PACKAGE_TARNAME = "tblis" + +const TBLIS_PACKAGE_URL = "http://www.github.com/devinamatthews/tblis" + +const TBLIS_PACKAGE_VERSION = "1.2.0" + +# Skipping MacroDefinition: _tblis_restrict __restrict + +const TBLIS_STDC_HEADERS = 1 + +const TBLIS_STRIDE_TYPE = ptrdiff_t + +const TBLIS_TOPDIR = "/workspace/srcdir/tblis" + +const TBLIS_VERSION = "1.2.0" diff --git a/src/lib/aarch64-linux-gnu.jl b/src/lib/aarch64-linux-gnu.jl new file mode 100644 index 0000000..cdb81c6 --- /dev/null +++ b/src/lib/aarch64-linux-gnu.jl @@ -0,0 +1,779 @@ +# no prototype is found for this function at yield.h:27:17, please use with caution +function tci_yield() + @ccall tblis.tci_yield()::Cvoid +end + +const tci_mutex = Cchar + +function tci_mutex_init(mutex) + @ccall tblis.tci_mutex_init(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_destroy(mutex) + @ccall tblis.tci_mutex_destroy(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_lock(mutex) + @ccall tblis.tci_mutex_lock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutexrylock(mutex) + @ccall tblis.tci_mutexrylock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_unlock(mutex) + @ccall tblis.tci_mutex_unlock(mutex::Ptr{tci_mutex})::Cint +end + +struct tci_barrier_node + parent::Ptr{tci_barrier_node} + nchildren::Cuint + step::Cuint + nwaiting::Cuint +end + +function tci_barrier_node_init(barrier, parent, nchildren) + @ccall tblis.tci_barrier_node_init(barrier::Ptr{tci_barrier_node}, + parent::Ptr{tci_barrier_node}, + nchildren::Cuint)::Cint +end + +function tci_barrier_node_destroy(barrier) + @ccall tblis.tci_barrier_node_destroy(barrier::Ptr{tci_barrier_node})::Cint +end + +function tci_barrier_node_wait(barrier) + @ccall tblis.tci_barrier_node_wait(barrier::Ptr{tci_barrier_node})::Cint +end + +struct __JL_Ctag_33 + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{__JL_Ctag_33}, f::Symbol) + f === :array && return Ptr{Ptr{tci_barrier_node}}(x + 0) + f === :single && return Ptr{tci_barrier_node}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::__JL_Ctag_33, f::Symbol) + r = Ref{__JL_Ctag_33}(x) + ptr = Base.unsafe_convert(Ptr{__JL_Ctag_33}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{__JL_Ctag_33}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tci_barrier + data::NTuple{40,UInt8} +end + +function Base.getproperty(x::Ptr{tci_barrier}, f::Symbol) + f === :barrier && return Ptr{__JL_Ctag_33}(x + 0) + f === :nthread && return Ptr{Cuint}(x + 24) + f === :group_size && return Ptr{Cuint}(x + 28) + f === :is_tree && return Ptr{Cint}(x + 32) + return getfield(x, f) +end + +function Base.getproperty(x::tci_barrier, f::Symbol) + r = Ref{tci_barrier}(x) + ptr = Base.unsafe_convert(Ptr{tci_barrier}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tci_barrier}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tci_barrier_is_tree(barrier) + @ccall tblis.tci_barrier_is_tree(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_init(barrier, nthread, group_size) + @ccall tblis.tci_barrier_init(barrier::Ptr{tci_barrier}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_barrier_destroy(barrier) + @ccall tblis.tci_barrier_destroy(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_wait(barrier, tid) + @ccall tblis.tci_barrier_wait(barrier::Ptr{tci_barrier}, tid::Cuint)::Cint +end + +struct tci_context + barrier::tci_barrier + buffer::Ptr{Cvoid} + refcount::Cuint +end + +function tci_context_init(context, nthread, group_size) + @ccall tblis.tci_context_init(context::Ptr{Ptr{tci_context}}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_context_attach(context) + @ccall tblis.tci_context_attach(context::Ptr{tci_context})::Cint +end + +function tci_context_detach(context) + @ccall tblis.tci_context_detach(context::Ptr{tci_context})::Cint +end + +function tci_context_barrier(context, tid) + @ccall tblis.tci_context_barrier(context::Ptr{tci_context}, tid::Cuint)::Cint +end + +function tci_context_send(context, tid, object) + @ccall tblis.tci_context_send(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_send_nowait(context, tid, object) + @ccall tblis.tci_context_send_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_receive(context, tid, object) + @ccall tblis.tci_context_receive(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +function tci_context_receive_nowait(context, tid, object) + @ccall tblis.tci_context_receive_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +struct tci_comm + context::Ptr{tci_context} + ngang::Cuint + gid::Cuint + nthread::Cuint + tid::Cuint +end + +@enum __JL_Ctag_3::UInt32 begin + TCI_EVENLY = 2 + TCI_CYCLIC = 4 + TCI_BLOCK_CYCLIC = 6 + TCI_BLOCKED = 8 + TCI_NO_CONTEXT = 1 +end + +mutable struct tci_range + size::UInt64 + grain::UInt64 + tci_range() = new() +end + +# typedef void ( * tci_range_func ) ( tci_comm * , uint64_t , uint64_t , void * ) +const tci_range_func = Ptr{Cvoid} + +# typedef void ( * tci_range_2d_func ) ( tci_comm * , uint64_t , uint64_t , uint64_t , uint64_t , void * ) +const tci_range_2d_func = Ptr{Cvoid} + +function tci_comm_init_single(comm) + @ccall tblis.tci_comm_init_single(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_init(comm, context, nthread, tid, ngang, gid) + @ccall tblis.tci_comm_init(comm::Ptr{tci_comm}, context::Ptr{tci_context}, + nthread::Cuint, tid::Cuint, ngang::Cuint, gid::Cuint)::Cint +end + +function tci_comm_destroy(comm) + @ccall tblis.tci_comm_destroy(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_is_master(comm) + @ccall tblis.tci_comm_is_master(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_barrier(comm) + @ccall tblis.tci_comm_barrier(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_bcast(comm, object, root) + @ccall tblis.tci_comm_bcast(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_bcast_nowait(comm, object, root) + @ccall tblis.tci_comm_bcast_nowait(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_gang(parent, child, type, n, bs) + @ccall tblis.tci_comm_gang(parent::Ptr{tci_comm}, child::Ptr{tci_comm}, type::Cint, + n::Cuint, bs::Cuint)::Cint +end + +function tci_comm_distribute_over_gangs(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_threads(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_gangs_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs_2d(comm::Ptr{tci_comm}, range_m::tci_range, + range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_threads_2d(comm::Ptr{tci_comm}, + range_m::tci_range, range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +# typedef void ( * tci_thread_func ) ( tci_comm * , void * ) +const tci_thread_func = Ptr{Cvoid} + +function tci_parallelize(func, payload, nthread, arity) + @ccall tblis.tci_parallelize(func::tci_thread_func, payload::Ptr{Cvoid}, nthread::Cuint, + arity::Cuint)::Cint +end + +struct tci_prime_factors + n::Cuint + sqrt_n::Cuint + f::Cuint +end + +function tci_prime_factorization(n, factors) + @ccall tblis.tci_prime_factorization(n::Cuint, factors::Ptr{tci_prime_factors})::Cvoid +end + +function tci_next_prime_factor(factors) + @ccall tblis.tci_next_prime_factor(factors::Ptr{tci_prime_factors})::Cuint +end + +function tci_partition_2x2(nthread, work1, max1, work2, max2, nt1, nt2) + @ccall tblis.tci_partition_2x2(nthread::Cuint, work1::UInt64, max1::Cuint, + work2::UInt64, max2::Cuint, nt1::Ptr{Cuint}, + nt2::Ptr{Cuint})::Cvoid +end + +const tci_slot = Cint + +function tci_slot_init(slot, empty) + @ccall tblis.tci_slot_init(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_is_filled(slot, empty) + @ccall tblis.tci_slot_is_filled(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_try_fill(slot, empty, value) + @ccall tblis.tci_slot_try_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cint +end + +function tci_slot_fill(slot, empty, value) + @ccall tblis.tci_slot_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cvoid +end + +function tci_slot_clear(slot, empty) + @ccall tblis.tci_slot_clear(slot::Ptr{tci_slot}, empty::Cint)::Cvoid +end + +@enum __JL_Ctag_4::UInt32 begin + TCI_NOT_WORKED_ON = 0 + TCI_IN_PROGRESS = 1 + TCI_RESERVED = 2 + TCI_FINISHED = 3 +end + +const tci_work_item = Cint + +function tci_work_item_try_work(item) + @ccall tblis.tci_work_item_try_work(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_finish(item) + @ccall tblis.tci_work_item_finish(item::Ptr{tci_work_item})::Cvoid +end + +function tci_work_item_status(item) + @ccall tblis.tci_work_item_status(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_wait(item) + @ccall tblis.tci_work_item_wait(item::Ptr{tci_work_item})::Cvoid +end + +mutable struct tblis_config_s end + +const tblis_config = tblis_config_s + +@enum reduce_t::UInt32 begin + REDUCE_SUM = 0 + REDUCE_SUM_ABS = 1 + REDUCE_MAX = 2 + REDUCE_MAX_ABS = 3 + REDUCE_MIN = 4 + REDUCE_MIN_ABS = 5 + # REDUCE_NORM_1 = 1 + REDUCE_NORM_2 = 6 + # REDUCE_NORM_INF = 3 +end + +@enum type_t::UInt32 begin + TYPE_SINGLE = 0 + # TYPE_FLOAT = 0 + TYPE_DOUBLE = 1 + TYPE_SCOMPLEX = 2 + TYPE_DCOMPLEX = 3 +end + +const len_type = Cptrdiff_t + +const stride_type = Cptrdiff_t + +const label_type = Cchar + +mutable struct fake_scomplex + real::Cfloat + imag::Cfloat + fake_scomplex() = new() +end + +mutable struct fake_dcomplex + real::Cdouble + imag::Cdouble + fake_dcomplex() = new() +end + +struct scalar + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{scalar}, f::Symbol) + f === :s && return Ptr{Cfloat}(x + 0) + f === :d && return Ptr{Cdouble}(x + 0) + f === :c && return Ptr{scomplex}(x + 0) + f === :z && return Ptr{dcomplex}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::scalar, f::Symbol) + r = Ref{scalar}(x) + ptr = Base.unsafe_convert(Ptr{scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tblis_scalar + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{tblis_scalar}, f::Symbol) + f === :data && return Ptr{scalar}(x + 0) + f === :type && return Ptr{type_t}(x + 16) + return getfield(x, f) +end + +function Base.getproperty(x::tblis_scalar, f::Symbol) + r = Ref{tblis_scalar}(x) + ptr = Base.unsafe_convert(Ptr{tblis_scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tblis_scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tblis_init_scalar_s(s, value) + @ccall tblis.tblis_init_scalar_s(s::Ptr{tblis_scalar}, value::Cfloat)::Cvoid +end + +function tblis_init_scalar_d(s, value) + @ccall tblis.tblis_init_scalar_d(s::Ptr{tblis_scalar}, value::Cdouble)::Cvoid +end + +function tblis_init_scalar_c(s, value) + @ccall tblis.tblis_init_scalar_c(s::Ptr{tblis_scalar}, value::scomplex)::Cvoid +end + +function tblis_init_scalar_z(s, value) + @ccall tblis.tblis_init_scalar_z(s::Ptr{tblis_scalar}, value::dcomplex)::Cvoid +end + +mutable struct tblis_vector + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + n::len_type + inc::stride_type + tblis_vector() = new() +end + +function tblis_init_vector_scaled_s(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_s(v::Ptr{tblis_vector}, scalar_::Cfloat, + n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_d(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_d(v::Ptr{tblis_vector}, scalar_::Cdouble, + n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_c(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_c(v::Ptr{tblis_vector}, scalar_::scomplex, + n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_z(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_z(v::Ptr{tblis_vector}, scalar_::dcomplex, + n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_s(v, n, data, inc) + @ccall tblis.tblis_init_vector_s(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_d(v, n, data, inc) + @ccall tblis.tblis_init_vector_d(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_c(v, n, data, inc) + @ccall tblis.tblis_init_vector_c(v::Ptr{tblis_vector}, n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_z(v, n, data, inc) + @ccall tblis.tblis_init_vector_z(v::Ptr{tblis_vector}, n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +mutable struct tblis_matrix + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + m::len_type + n::len_type + rs::stride_type + cs::stride_type + tblis_matrix() = new() +end + +function tblis_init_matrix_scaled_s(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_s(mat::Ptr{tblis_matrix}, scalar_::Cfloat, + m::len_type, n::len_type, data::Ptr{Cfloat}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_d(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_d(mat::Ptr{tblis_matrix}, scalar_::Cdouble, + m::len_type, n::len_type, data::Ptr{Cdouble}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_c(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_c(mat::Ptr{tblis_matrix}, scalar_::scomplex, + m::len_type, n::len_type, data::Ptr{scomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_z(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_z(mat::Ptr{tblis_matrix}, scalar_::dcomplex, + m::len_type, n::len_type, data::Ptr{dcomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_s(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_s(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cfloat}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_d(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_d(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cdouble}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_c(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_c(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{scomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_z(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_z(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{dcomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +struct tblis_tensor + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + ndim::Cuint + len::Ptr{len_type} + stride::Ptr{stride_type} +end + +function tblis_init_tensor_scaled_s(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_s(t::Ptr{tblis_tensor}, scalar_::Cfloat, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_d(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_d(t::Ptr{tblis_tensor}, scalar_::Cdouble, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_c(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_c(t::Ptr{tblis_tensor}, scalar_::scomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_z(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_z(t::Ptr{tblis_tensor}, scalar_::dcomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_s(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_s(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_d(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_d(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_c(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_c(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_z(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_z(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_get_config(name) + @ccall tblis.tblis_get_config(name::Ptr{Cchar})::Ptr{tblis_config} +end + +const tblis_comm = tci_comm + +# no prototype is found for this function at thread.h:21:10, please use with caution +function tblis_get_num_threads() + @ccall tblis.tblis_get_num_threads()::Cuint +end + +function tblis_set_num_threads(num_threads) + @ccall tblis.tblis_set_num_threads(num_threads::Cuint)::Cvoid +end + +function tblis_vector_add(comm, cfg, A, B) + @ccall tblis.tblis_vector_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_vector_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_vector_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_vector_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_vector}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_vector_scale(comm, cfg, A) + @ccall tblis.tblis_vector_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_set(comm, cfg, alpha, A) + @ccall tblis.tblis_vector_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_vector})::Cvoid +end + +function tblis_matrix_add(comm, cfg, A, B) + @ccall tblis.tblis_matrix_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_matrix_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_matrix_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_matrix_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_matrix_scale(comm, cfg, A) + @ccall tblis.tblis_matrix_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_set(comm, cfg, alpha, A) + @ccall tblis.tblis_matrix_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_add(comm, cfg, A, idx_A, B, idx_B) + @ccall tblis.tblis_tensor_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type})::Cvoid +end + +function tblis_tensor_dot(comm, cfg, A, idx_A, B, idx_B, result) + @ccall tblis.tblis_tensor_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_tensor_reduce(comm, cfg, op, A, idx_A, result, idx) + @ccall tblis.tblis_tensor_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type}, result::Ptr{tblis_scalar}, + idx::Ptr{len_type})::Cvoid +end + +function tblis_tensor_scale(comm, cfg, A, idx_A) + @ccall tblis.tblis_tensor_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type})::Cvoid +end + +function tblis_tensor_set(comm, cfg, alpha, A, idx_A) + @ccall tblis.tblis_tensor_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type})::Cvoid +end + +function tblis_matrix_mult(comm, cfg, A, B, C) + @ccall tblis.tblis_matrix_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_mult_diag(comm, cfg, A, D, B, C) + @ccall tblis.tblis_matrix_mult_diag(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, D::Ptr{tblis_vector}, + B::Ptr{tblis_matrix}, C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_mult(comm, cfg, A, idx_A, B, idx_B, C, idx_C) + @ccall tblis.tblis_tensor_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + C::Ptr{tblis_tensor}, idx_C::Ptr{label_type})::Cvoid +end + +const TCI_USE_ATOMIC_SPINLOCK = 1 + +const TCI_USE_OMP_LOCK = 0 + +const TCI_USE_OPENMP_THREADS = 1 + +const TCI_USE_WINDOWS_THREADS = 0 + +const TCI_USE_TBB_THREADS = 0 + +const TCI_USE_PPL_THREADS = 0 + +const TCI_USE_OMPTASK_THREADS = 0 + +const TCI_USE_DISPATCH_THREADS = 0 + +const TCI_USE_OSX_SPINLOCK = 0 + +const TCI_USE_PTHREADS_THREADS = 0 + +const TCI_USE_PTHREAD_BARRIER = 0 + +const TCI_USE_PTHREAD_MUTEX = 0 + +const TCI_USE_PTHREAD_SPINLOCK = 0 + +const TCI_USE_SPIN_BARRIER = 1 + +const TCI_ARCH_ARM64 = 1 + +# Skipping MacroDefinition: TCI_INLINE static inline + +const TBLIS_HAVE_SYSCONF = 1 + +const TBLIS_HAVE_SYSCTL = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_CONF = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_ONLN = 1 + +const TBLIS_LABEL_TYPE = Cchar + +const TBLIS_LEN_TYPE = ptrdiff_t + +const TBLIS_LT_OBJDIR = ".libs/" + +const TBLIS_PACKAGE = "tblis" + +const TBLIS_PACKAGE_BUGREPORT = "dmatthews@utexas.edu" + +const TBLIS_PACKAGE_NAME = "tblis" + +const TBLIS_PACKAGE_STRING = "tblis 1.2.0" + +const TBLIS_PACKAGE_TARNAME = "tblis" + +const TBLIS_PACKAGE_URL = "http://www.github.com/devinamatthews/tblis" + +const TBLIS_PACKAGE_VERSION = "1.2.0" + +# Skipping MacroDefinition: _tblis_restrict __restrict + +const TBLIS_STDC_HEADERS = 1 + +const TBLIS_STRIDE_TYPE = ptrdiff_t + +const TBLIS_TOPDIR = "/workspace/srcdir/tblis" + +const TBLIS_VERSION = "1.2.0" diff --git a/src/lib/aarch64-linux-musl.jl b/src/lib/aarch64-linux-musl.jl new file mode 100644 index 0000000..8697feb --- /dev/null +++ b/src/lib/aarch64-linux-musl.jl @@ -0,0 +1,779 @@ +# no prototype is found for this function at yield.h:27:17, please use with caution +function tci_yield() + @ccall tblis.tci_yield()::Cvoid +end + +const tci_mutex = Cchar + +function tci_mutex_init(mutex) + @ccall tblis.tci_mutex_init(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_destroy(mutex) + @ccall tblis.tci_mutex_destroy(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_lock(mutex) + @ccall tblis.tci_mutex_lock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutexrylock(mutex) + @ccall tblis.tci_mutexrylock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_unlock(mutex) + @ccall tblis.tci_mutex_unlock(mutex::Ptr{tci_mutex})::Cint +end + +struct tci_barrier_node + parent::Ptr{tci_barrier_node} + nchildren::Cuint + step::Cuint + nwaiting::Cuint +end + +function tci_barrier_node_init(barrier, parent, nchildren) + @ccall tblis.tci_barrier_node_init(barrier::Ptr{tci_barrier_node}, + parent::Ptr{tci_barrier_node}, + nchildren::Cuint)::Cint +end + +function tci_barrier_node_destroy(barrier) + @ccall tblis.tci_barrier_node_destroy(barrier::Ptr{tci_barrier_node})::Cint +end + +function tci_barrier_node_wait(barrier) + @ccall tblis.tci_barrier_node_wait(barrier::Ptr{tci_barrier_node})::Cint +end + +struct __JL_Ctag_25 + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{__JL_Ctag_25}, f::Symbol) + f === :array && return Ptr{Ptr{tci_barrier_node}}(x + 0) + f === :single && return Ptr{tci_barrier_node}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::__JL_Ctag_25, f::Symbol) + r = Ref{__JL_Ctag_25}(x) + ptr = Base.unsafe_convert(Ptr{__JL_Ctag_25}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{__JL_Ctag_25}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tci_barrier + data::NTuple{40,UInt8} +end + +function Base.getproperty(x::Ptr{tci_barrier}, f::Symbol) + f === :barrier && return Ptr{__JL_Ctag_25}(x + 0) + f === :nthread && return Ptr{Cuint}(x + 24) + f === :group_size && return Ptr{Cuint}(x + 28) + f === :is_tree && return Ptr{Cint}(x + 32) + return getfield(x, f) +end + +function Base.getproperty(x::tci_barrier, f::Symbol) + r = Ref{tci_barrier}(x) + ptr = Base.unsafe_convert(Ptr{tci_barrier}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tci_barrier}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tci_barrier_is_tree(barrier) + @ccall tblis.tci_barrier_is_tree(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_init(barrier, nthread, group_size) + @ccall tblis.tci_barrier_init(barrier::Ptr{tci_barrier}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_barrier_destroy(barrier) + @ccall tblis.tci_barrier_destroy(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_wait(barrier, tid) + @ccall tblis.tci_barrier_wait(barrier::Ptr{tci_barrier}, tid::Cuint)::Cint +end + +struct tci_context + barrier::tci_barrier + buffer::Ptr{Cvoid} + refcount::Cuint +end + +function tci_context_init(context, nthread, group_size) + @ccall tblis.tci_context_init(context::Ptr{Ptr{tci_context}}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_context_attach(context) + @ccall tblis.tci_context_attach(context::Ptr{tci_context})::Cint +end + +function tci_context_detach(context) + @ccall tblis.tci_context_detach(context::Ptr{tci_context})::Cint +end + +function tci_context_barrier(context, tid) + @ccall tblis.tci_context_barrier(context::Ptr{tci_context}, tid::Cuint)::Cint +end + +function tci_context_send(context, tid, object) + @ccall tblis.tci_context_send(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_send_nowait(context, tid, object) + @ccall tblis.tci_context_send_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_receive(context, tid, object) + @ccall tblis.tci_context_receive(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +function tci_context_receive_nowait(context, tid, object) + @ccall tblis.tci_context_receive_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +struct tci_comm + context::Ptr{tci_context} + ngang::Cuint + gid::Cuint + nthread::Cuint + tid::Cuint +end + +@enum __JL_Ctag_3::UInt32 begin + TCI_EVENLY = 2 + TCI_CYCLIC = 4 + TCI_BLOCK_CYCLIC = 6 + TCI_BLOCKED = 8 + TCI_NO_CONTEXT = 1 +end + +mutable struct tci_range + size::UInt64 + grain::UInt64 + tci_range() = new() +end + +# typedef void ( * tci_range_func ) ( tci_comm * , uint64_t , uint64_t , void * ) +const tci_range_func = Ptr{Cvoid} + +# typedef void ( * tci_range_2d_func ) ( tci_comm * , uint64_t , uint64_t , uint64_t , uint64_t , void * ) +const tci_range_2d_func = Ptr{Cvoid} + +function tci_comm_init_single(comm) + @ccall tblis.tci_comm_init_single(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_init(comm, context, nthread, tid, ngang, gid) + @ccall tblis.tci_comm_init(comm::Ptr{tci_comm}, context::Ptr{tci_context}, + nthread::Cuint, tid::Cuint, ngang::Cuint, gid::Cuint)::Cint +end + +function tci_comm_destroy(comm) + @ccall tblis.tci_comm_destroy(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_is_master(comm) + @ccall tblis.tci_comm_is_master(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_barrier(comm) + @ccall tblis.tci_comm_barrier(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_bcast(comm, object, root) + @ccall tblis.tci_comm_bcast(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_bcast_nowait(comm, object, root) + @ccall tblis.tci_comm_bcast_nowait(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_gang(parent, child, type, n, bs) + @ccall tblis.tci_comm_gang(parent::Ptr{tci_comm}, child::Ptr{tci_comm}, type::Cint, + n::Cuint, bs::Cuint)::Cint +end + +function tci_comm_distribute_over_gangs(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_threads(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_gangs_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs_2d(comm::Ptr{tci_comm}, range_m::tci_range, + range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_threads_2d(comm::Ptr{tci_comm}, + range_m::tci_range, range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +# typedef void ( * tci_thread_func ) ( tci_comm * , void * ) +const tci_thread_func = Ptr{Cvoid} + +function tci_parallelize(func, payload, nthread, arity) + @ccall tblis.tci_parallelize(func::tci_thread_func, payload::Ptr{Cvoid}, nthread::Cuint, + arity::Cuint)::Cint +end + +struct tci_prime_factors + n::Cuint + sqrt_n::Cuint + f::Cuint +end + +function tci_prime_factorization(n, factors) + @ccall tblis.tci_prime_factorization(n::Cuint, factors::Ptr{tci_prime_factors})::Cvoid +end + +function tci_next_prime_factor(factors) + @ccall tblis.tci_next_prime_factor(factors::Ptr{tci_prime_factors})::Cuint +end + +function tci_partition_2x2(nthread, work1, max1, work2, max2, nt1, nt2) + @ccall tblis.tci_partition_2x2(nthread::Cuint, work1::UInt64, max1::Cuint, + work2::UInt64, max2::Cuint, nt1::Ptr{Cuint}, + nt2::Ptr{Cuint})::Cvoid +end + +const tci_slot = Cint + +function tci_slot_init(slot, empty) + @ccall tblis.tci_slot_init(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_is_filled(slot, empty) + @ccall tblis.tci_slot_is_filled(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_try_fill(slot, empty, value) + @ccall tblis.tci_slot_try_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cint +end + +function tci_slot_fill(slot, empty, value) + @ccall tblis.tci_slot_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cvoid +end + +function tci_slot_clear(slot, empty) + @ccall tblis.tci_slot_clear(slot::Ptr{tci_slot}, empty::Cint)::Cvoid +end + +@enum __JL_Ctag_4::UInt32 begin + TCI_NOT_WORKED_ON = 0 + TCI_IN_PROGRESS = 1 + TCI_RESERVED = 2 + TCI_FINISHED = 3 +end + +const tci_work_item = Cint + +function tci_work_item_try_work(item) + @ccall tblis.tci_work_item_try_work(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_finish(item) + @ccall tblis.tci_work_item_finish(item::Ptr{tci_work_item})::Cvoid +end + +function tci_work_item_status(item) + @ccall tblis.tci_work_item_status(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_wait(item) + @ccall tblis.tci_work_item_wait(item::Ptr{tci_work_item})::Cvoid +end + +mutable struct tblis_config_s end + +const tblis_config = tblis_config_s + +@enum reduce_t::UInt32 begin + REDUCE_SUM = 0 + REDUCE_SUM_ABS = 1 + REDUCE_MAX = 2 + REDUCE_MAX_ABS = 3 + REDUCE_MIN = 4 + REDUCE_MIN_ABS = 5 + # REDUCE_NORM_1 = 1 + REDUCE_NORM_2 = 6 + # REDUCE_NORM_INF = 3 +end + +@enum type_t::UInt32 begin + TYPE_SINGLE = 0 + # TYPE_FLOAT = 0 + TYPE_DOUBLE = 1 + TYPE_SCOMPLEX = 2 + TYPE_DCOMPLEX = 3 +end + +const len_type = Cptrdiff_t + +const stride_type = Cptrdiff_t + +const label_type = Cchar + +mutable struct fake_scomplex + real::Cfloat + imag::Cfloat + fake_scomplex() = new() +end + +mutable struct fake_dcomplex + real::Cdouble + imag::Cdouble + fake_dcomplex() = new() +end + +struct scalar + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{scalar}, f::Symbol) + f === :s && return Ptr{Cfloat}(x + 0) + f === :d && return Ptr{Cdouble}(x + 0) + f === :c && return Ptr{scomplex}(x + 0) + f === :z && return Ptr{dcomplex}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::scalar, f::Symbol) + r = Ref{scalar}(x) + ptr = Base.unsafe_convert(Ptr{scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tblis_scalar + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{tblis_scalar}, f::Symbol) + f === :data && return Ptr{scalar}(x + 0) + f === :type && return Ptr{type_t}(x + 16) + return getfield(x, f) +end + +function Base.getproperty(x::tblis_scalar, f::Symbol) + r = Ref{tblis_scalar}(x) + ptr = Base.unsafe_convert(Ptr{tblis_scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tblis_scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tblis_init_scalar_s(s, value) + @ccall tblis.tblis_init_scalar_s(s::Ptr{tblis_scalar}, value::Cfloat)::Cvoid +end + +function tblis_init_scalar_d(s, value) + @ccall tblis.tblis_init_scalar_d(s::Ptr{tblis_scalar}, value::Cdouble)::Cvoid +end + +function tblis_init_scalar_c(s, value) + @ccall tblis.tblis_init_scalar_c(s::Ptr{tblis_scalar}, value::scomplex)::Cvoid +end + +function tblis_init_scalar_z(s, value) + @ccall tblis.tblis_init_scalar_z(s::Ptr{tblis_scalar}, value::dcomplex)::Cvoid +end + +mutable struct tblis_vector + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + n::len_type + inc::stride_type + tblis_vector() = new() +end + +function tblis_init_vector_scaled_s(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_s(v::Ptr{tblis_vector}, scalar_::Cfloat, + n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_d(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_d(v::Ptr{tblis_vector}, scalar_::Cdouble, + n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_c(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_c(v::Ptr{tblis_vector}, scalar_::scomplex, + n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_z(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_z(v::Ptr{tblis_vector}, scalar_::dcomplex, + n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_s(v, n, data, inc) + @ccall tblis.tblis_init_vector_s(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_d(v, n, data, inc) + @ccall tblis.tblis_init_vector_d(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_c(v, n, data, inc) + @ccall tblis.tblis_init_vector_c(v::Ptr{tblis_vector}, n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_z(v, n, data, inc) + @ccall tblis.tblis_init_vector_z(v::Ptr{tblis_vector}, n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +mutable struct tblis_matrix + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + m::len_type + n::len_type + rs::stride_type + cs::stride_type + tblis_matrix() = new() +end + +function tblis_init_matrix_scaled_s(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_s(mat::Ptr{tblis_matrix}, scalar_::Cfloat, + m::len_type, n::len_type, data::Ptr{Cfloat}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_d(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_d(mat::Ptr{tblis_matrix}, scalar_::Cdouble, + m::len_type, n::len_type, data::Ptr{Cdouble}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_c(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_c(mat::Ptr{tblis_matrix}, scalar_::scomplex, + m::len_type, n::len_type, data::Ptr{scomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_z(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_z(mat::Ptr{tblis_matrix}, scalar_::dcomplex, + m::len_type, n::len_type, data::Ptr{dcomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_s(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_s(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cfloat}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_d(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_d(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cdouble}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_c(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_c(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{scomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_z(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_z(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{dcomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +struct tblis_tensor + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + ndim::Cuint + len::Ptr{len_type} + stride::Ptr{stride_type} +end + +function tblis_init_tensor_scaled_s(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_s(t::Ptr{tblis_tensor}, scalar_::Cfloat, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_d(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_d(t::Ptr{tblis_tensor}, scalar_::Cdouble, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_c(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_c(t::Ptr{tblis_tensor}, scalar_::scomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_z(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_z(t::Ptr{tblis_tensor}, scalar_::dcomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_s(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_s(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_d(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_d(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_c(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_c(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_z(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_z(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_get_config(name) + @ccall tblis.tblis_get_config(name::Ptr{Cchar})::Ptr{tblis_config} +end + +const tblis_comm = tci_comm + +# no prototype is found for this function at thread.h:21:10, please use with caution +function tblis_get_num_threads() + @ccall tblis.tblis_get_num_threads()::Cuint +end + +function tblis_set_num_threads(num_threads) + @ccall tblis.tblis_set_num_threads(num_threads::Cuint)::Cvoid +end + +function tblis_vector_add(comm, cfg, A, B) + @ccall tblis.tblis_vector_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_vector_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_vector_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_vector_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_vector}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_vector_scale(comm, cfg, A) + @ccall tblis.tblis_vector_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_set(comm, cfg, alpha, A) + @ccall tblis.tblis_vector_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_vector})::Cvoid +end + +function tblis_matrix_add(comm, cfg, A, B) + @ccall tblis.tblis_matrix_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_matrix_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_matrix_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_matrix_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_matrix_scale(comm, cfg, A) + @ccall tblis.tblis_matrix_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_set(comm, cfg, alpha, A) + @ccall tblis.tblis_matrix_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_add(comm, cfg, A, idx_A, B, idx_B) + @ccall tblis.tblis_tensor_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type})::Cvoid +end + +function tblis_tensor_dot(comm, cfg, A, idx_A, B, idx_B, result) + @ccall tblis.tblis_tensor_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_tensor_reduce(comm, cfg, op, A, idx_A, result, idx) + @ccall tblis.tblis_tensor_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type}, result::Ptr{tblis_scalar}, + idx::Ptr{len_type})::Cvoid +end + +function tblis_tensor_scale(comm, cfg, A, idx_A) + @ccall tblis.tblis_tensor_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type})::Cvoid +end + +function tblis_tensor_set(comm, cfg, alpha, A, idx_A) + @ccall tblis.tblis_tensor_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type})::Cvoid +end + +function tblis_matrix_mult(comm, cfg, A, B, C) + @ccall tblis.tblis_matrix_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_mult_diag(comm, cfg, A, D, B, C) + @ccall tblis.tblis_matrix_mult_diag(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, D::Ptr{tblis_vector}, + B::Ptr{tblis_matrix}, C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_mult(comm, cfg, A, idx_A, B, idx_B, C, idx_C) + @ccall tblis.tblis_tensor_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + C::Ptr{tblis_tensor}, idx_C::Ptr{label_type})::Cvoid +end + +const TCI_USE_ATOMIC_SPINLOCK = 1 + +const TCI_USE_OMP_LOCK = 0 + +const TCI_USE_OPENMP_THREADS = 1 + +const TCI_USE_WINDOWS_THREADS = 0 + +const TCI_USE_TBB_THREADS = 0 + +const TCI_USE_PPL_THREADS = 0 + +const TCI_USE_OMPTASK_THREADS = 0 + +const TCI_USE_DISPATCH_THREADS = 0 + +const TCI_USE_OSX_SPINLOCK = 0 + +const TCI_USE_PTHREADS_THREADS = 0 + +const TCI_USE_PTHREAD_BARRIER = 0 + +const TCI_USE_PTHREAD_MUTEX = 0 + +const TCI_USE_PTHREAD_SPINLOCK = 0 + +const TCI_USE_SPIN_BARRIER = 1 + +const TCI_ARCH_ARM64 = 1 + +# Skipping MacroDefinition: TCI_INLINE static inline + +const TBLIS_HAVE_SYSCONF = 1 + +const TBLIS_HAVE_SYSCTL = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_CONF = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_ONLN = 1 + +const TBLIS_LABEL_TYPE = Cchar + +const TBLIS_LEN_TYPE = ptrdiff_t + +const TBLIS_LT_OBJDIR = ".libs/" + +const TBLIS_PACKAGE = "tblis" + +const TBLIS_PACKAGE_BUGREPORT = "dmatthews@utexas.edu" + +const TBLIS_PACKAGE_NAME = "tblis" + +const TBLIS_PACKAGE_STRING = "tblis 1.2.0" + +const TBLIS_PACKAGE_TARNAME = "tblis" + +const TBLIS_PACKAGE_URL = "http://www.github.com/devinamatthews/tblis" + +const TBLIS_PACKAGE_VERSION = "1.2.0" + +# Skipping MacroDefinition: _tblis_restrict __restrict + +const TBLIS_STDC_HEADERS = 1 + +const TBLIS_STRIDE_TYPE = ptrdiff_t + +const TBLIS_TOPDIR = "/workspace/srcdir/tblis" + +const TBLIS_VERSION = "1.2.0" diff --git a/src/lib/armv7l-linux-gnueabihf.jl b/src/lib/armv7l-linux-gnueabihf.jl new file mode 100644 index 0000000..73da682 --- /dev/null +++ b/src/lib/armv7l-linux-gnueabihf.jl @@ -0,0 +1,779 @@ +# no prototype is found for this function at yield.h:27:17, please use with caution +function tci_yield() + @ccall tblis.tci_yield()::Cvoid +end + +const tci_mutex = Cchar + +function tci_mutex_init(mutex) + @ccall tblis.tci_mutex_init(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_destroy(mutex) + @ccall tblis.tci_mutex_destroy(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_lock(mutex) + @ccall tblis.tci_mutex_lock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutexrylock(mutex) + @ccall tblis.tci_mutexrylock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_unlock(mutex) + @ccall tblis.tci_mutex_unlock(mutex::Ptr{tci_mutex})::Cint +end + +struct tci_barrier_node + parent::Ptr{tci_barrier_node} + nchildren::Cuint + step::Cuint + nwaiting::Cuint +end + +function tci_barrier_node_init(barrier, parent, nchildren) + @ccall tblis.tci_barrier_node_init(barrier::Ptr{tci_barrier_node}, + parent::Ptr{tci_barrier_node}, + nchildren::Cuint)::Cint +end + +function tci_barrier_node_destroy(barrier) + @ccall tblis.tci_barrier_node_destroy(barrier::Ptr{tci_barrier_node})::Cint +end + +function tci_barrier_node_wait(barrier) + @ccall tblis.tci_barrier_node_wait(barrier::Ptr{tci_barrier_node})::Cint +end + +struct __JL_Ctag_33 + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{__JL_Ctag_33}, f::Symbol) + f === :array && return Ptr{Ptr{tci_barrier_node}}(x + 0) + f === :single && return Ptr{tci_barrier_node}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::__JL_Ctag_33, f::Symbol) + r = Ref{__JL_Ctag_33}(x) + ptr = Base.unsafe_convert(Ptr{__JL_Ctag_33}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{__JL_Ctag_33}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tci_barrier + data::NTuple{28,UInt8} +end + +function Base.getproperty(x::Ptr{tci_barrier}, f::Symbol) + f === :barrier && return Ptr{__JL_Ctag_33}(x + 0) + f === :nthread && return Ptr{Cuint}(x + 16) + f === :group_size && return Ptr{Cuint}(x + 20) + f === :is_tree && return Ptr{Cint}(x + 24) + return getfield(x, f) +end + +function Base.getproperty(x::tci_barrier, f::Symbol) + r = Ref{tci_barrier}(x) + ptr = Base.unsafe_convert(Ptr{tci_barrier}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tci_barrier}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tci_barrier_is_tree(barrier) + @ccall tblis.tci_barrier_is_tree(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_init(barrier, nthread, group_size) + @ccall tblis.tci_barrier_init(barrier::Ptr{tci_barrier}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_barrier_destroy(barrier) + @ccall tblis.tci_barrier_destroy(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_wait(barrier, tid) + @ccall tblis.tci_barrier_wait(barrier::Ptr{tci_barrier}, tid::Cuint)::Cint +end + +struct tci_context + barrier::tci_barrier + buffer::Ptr{Cvoid} + refcount::Cuint +end + +function tci_context_init(context, nthread, group_size) + @ccall tblis.tci_context_init(context::Ptr{Ptr{tci_context}}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_context_attach(context) + @ccall tblis.tci_context_attach(context::Ptr{tci_context})::Cint +end + +function tci_context_detach(context) + @ccall tblis.tci_context_detach(context::Ptr{tci_context})::Cint +end + +function tci_context_barrier(context, tid) + @ccall tblis.tci_context_barrier(context::Ptr{tci_context}, tid::Cuint)::Cint +end + +function tci_context_send(context, tid, object) + @ccall tblis.tci_context_send(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_send_nowait(context, tid, object) + @ccall tblis.tci_context_send_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_receive(context, tid, object) + @ccall tblis.tci_context_receive(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +function tci_context_receive_nowait(context, tid, object) + @ccall tblis.tci_context_receive_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +struct tci_comm + context::Ptr{tci_context} + ngang::Cuint + gid::Cuint + nthread::Cuint + tid::Cuint +end + +@enum __JL_Ctag_3::UInt32 begin + TCI_EVENLY = 2 + TCI_CYCLIC = 4 + TCI_BLOCK_CYCLIC = 6 + TCI_BLOCKED = 8 + TCI_NO_CONTEXT = 1 +end + +mutable struct tci_range + size::UInt64 + grain::UInt64 + tci_range() = new() +end + +# typedef void ( * tci_range_func ) ( tci_comm * , uint64_t , uint64_t , void * ) +const tci_range_func = Ptr{Cvoid} + +# typedef void ( * tci_range_2d_func ) ( tci_comm * , uint64_t , uint64_t , uint64_t , uint64_t , void * ) +const tci_range_2d_func = Ptr{Cvoid} + +function tci_comm_init_single(comm) + @ccall tblis.tci_comm_init_single(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_init(comm, context, nthread, tid, ngang, gid) + @ccall tblis.tci_comm_init(comm::Ptr{tci_comm}, context::Ptr{tci_context}, + nthread::Cuint, tid::Cuint, ngang::Cuint, gid::Cuint)::Cint +end + +function tci_comm_destroy(comm) + @ccall tblis.tci_comm_destroy(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_is_master(comm) + @ccall tblis.tci_comm_is_master(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_barrier(comm) + @ccall tblis.tci_comm_barrier(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_bcast(comm, object, root) + @ccall tblis.tci_comm_bcast(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_bcast_nowait(comm, object, root) + @ccall tblis.tci_comm_bcast_nowait(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_gang(parent, child, type, n, bs) + @ccall tblis.tci_comm_gang(parent::Ptr{tci_comm}, child::Ptr{tci_comm}, type::Cint, + n::Cuint, bs::Cuint)::Cint +end + +function tci_comm_distribute_over_gangs(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_threads(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_gangs_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs_2d(comm::Ptr{tci_comm}, range_m::tci_range, + range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_threads_2d(comm::Ptr{tci_comm}, + range_m::tci_range, range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +# typedef void ( * tci_thread_func ) ( tci_comm * , void * ) +const tci_thread_func = Ptr{Cvoid} + +function tci_parallelize(func, payload, nthread, arity) + @ccall tblis.tci_parallelize(func::tci_thread_func, payload::Ptr{Cvoid}, nthread::Cuint, + arity::Cuint)::Cint +end + +struct tci_prime_factors + n::Cuint + sqrt_n::Cuint + f::Cuint +end + +function tci_prime_factorization(n, factors) + @ccall tblis.tci_prime_factorization(n::Cuint, factors::Ptr{tci_prime_factors})::Cvoid +end + +function tci_next_prime_factor(factors) + @ccall tblis.tci_next_prime_factor(factors::Ptr{tci_prime_factors})::Cuint +end + +function tci_partition_2x2(nthread, work1, max1, work2, max2, nt1, nt2) + @ccall tblis.tci_partition_2x2(nthread::Cuint, work1::UInt64, max1::Cuint, + work2::UInt64, max2::Cuint, nt1::Ptr{Cuint}, + nt2::Ptr{Cuint})::Cvoid +end + +const tci_slot = Cint + +function tci_slot_init(slot, empty) + @ccall tblis.tci_slot_init(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_is_filled(slot, empty) + @ccall tblis.tci_slot_is_filled(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_try_fill(slot, empty, value) + @ccall tblis.tci_slot_try_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cint +end + +function tci_slot_fill(slot, empty, value) + @ccall tblis.tci_slot_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cvoid +end + +function tci_slot_clear(slot, empty) + @ccall tblis.tci_slot_clear(slot::Ptr{tci_slot}, empty::Cint)::Cvoid +end + +@enum __JL_Ctag_4::UInt32 begin + TCI_NOT_WORKED_ON = 0 + TCI_IN_PROGRESS = 1 + TCI_RESERVED = 2 + TCI_FINISHED = 3 +end + +const tci_work_item = Cint + +function tci_work_item_try_work(item) + @ccall tblis.tci_work_item_try_work(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_finish(item) + @ccall tblis.tci_work_item_finish(item::Ptr{tci_work_item})::Cvoid +end + +function tci_work_item_status(item) + @ccall tblis.tci_work_item_status(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_wait(item) + @ccall tblis.tci_work_item_wait(item::Ptr{tci_work_item})::Cvoid +end + +mutable struct tblis_config_s end + +const tblis_config = tblis_config_s + +@enum reduce_t::UInt32 begin + REDUCE_SUM = 0 + REDUCE_SUM_ABS = 1 + REDUCE_MAX = 2 + REDUCE_MAX_ABS = 3 + REDUCE_MIN = 4 + REDUCE_MIN_ABS = 5 + # REDUCE_NORM_1 = 1 + REDUCE_NORM_2 = 6 + # REDUCE_NORM_INF = 3 +end + +@enum type_t::UInt32 begin + TYPE_SINGLE = 0 + # TYPE_FLOAT = 0 + TYPE_DOUBLE = 1 + TYPE_SCOMPLEX = 2 + TYPE_DCOMPLEX = 3 +end + +const len_type = Cptrdiff_t + +const stride_type = Cptrdiff_t + +const label_type = Cchar + +mutable struct fake_scomplex + real::Cfloat + imag::Cfloat + fake_scomplex() = new() +end + +mutable struct fake_dcomplex + real::Cdouble + imag::Cdouble + fake_dcomplex() = new() +end + +struct scalar + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{scalar}, f::Symbol) + f === :s && return Ptr{Cfloat}(x + 0) + f === :d && return Ptr{Cdouble}(x + 0) + f === :c && return Ptr{scomplex}(x + 0) + f === :z && return Ptr{dcomplex}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::scalar, f::Symbol) + r = Ref{scalar}(x) + ptr = Base.unsafe_convert(Ptr{scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tblis_scalar + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{tblis_scalar}, f::Symbol) + f === :data && return Ptr{scalar}(x + 0) + f === :type && return Ptr{type_t}(x + 16) + return getfield(x, f) +end + +function Base.getproperty(x::tblis_scalar, f::Symbol) + r = Ref{tblis_scalar}(x) + ptr = Base.unsafe_convert(Ptr{tblis_scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tblis_scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tblis_init_scalar_s(s, value) + @ccall tblis.tblis_init_scalar_s(s::Ptr{tblis_scalar}, value::Cfloat)::Cvoid +end + +function tblis_init_scalar_d(s, value) + @ccall tblis.tblis_init_scalar_d(s::Ptr{tblis_scalar}, value::Cdouble)::Cvoid +end + +function tblis_init_scalar_c(s, value) + @ccall tblis.tblis_init_scalar_c(s::Ptr{tblis_scalar}, value::scomplex)::Cvoid +end + +function tblis_init_scalar_z(s, value) + @ccall tblis.tblis_init_scalar_z(s::Ptr{tblis_scalar}, value::dcomplex)::Cvoid +end + +mutable struct tblis_vector + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + n::len_type + inc::stride_type + tblis_vector() = new() +end + +function tblis_init_vector_scaled_s(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_s(v::Ptr{tblis_vector}, scalar_::Cfloat, + n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_d(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_d(v::Ptr{tblis_vector}, scalar_::Cdouble, + n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_c(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_c(v::Ptr{tblis_vector}, scalar_::scomplex, + n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_z(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_z(v::Ptr{tblis_vector}, scalar_::dcomplex, + n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_s(v, n, data, inc) + @ccall tblis.tblis_init_vector_s(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_d(v, n, data, inc) + @ccall tblis.tblis_init_vector_d(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_c(v, n, data, inc) + @ccall tblis.tblis_init_vector_c(v::Ptr{tblis_vector}, n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_z(v, n, data, inc) + @ccall tblis.tblis_init_vector_z(v::Ptr{tblis_vector}, n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +mutable struct tblis_matrix + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + m::len_type + n::len_type + rs::stride_type + cs::stride_type + tblis_matrix() = new() +end + +function tblis_init_matrix_scaled_s(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_s(mat::Ptr{tblis_matrix}, scalar_::Cfloat, + m::len_type, n::len_type, data::Ptr{Cfloat}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_d(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_d(mat::Ptr{tblis_matrix}, scalar_::Cdouble, + m::len_type, n::len_type, data::Ptr{Cdouble}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_c(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_c(mat::Ptr{tblis_matrix}, scalar_::scomplex, + m::len_type, n::len_type, data::Ptr{scomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_z(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_z(mat::Ptr{tblis_matrix}, scalar_::dcomplex, + m::len_type, n::len_type, data::Ptr{dcomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_s(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_s(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cfloat}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_d(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_d(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cdouble}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_c(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_c(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{scomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_z(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_z(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{dcomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +struct tblis_tensor + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + ndim::Cuint + len::Ptr{len_type} + stride::Ptr{stride_type} +end + +function tblis_init_tensor_scaled_s(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_s(t::Ptr{tblis_tensor}, scalar_::Cfloat, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_d(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_d(t::Ptr{tblis_tensor}, scalar_::Cdouble, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_c(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_c(t::Ptr{tblis_tensor}, scalar_::scomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_z(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_z(t::Ptr{tblis_tensor}, scalar_::dcomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_s(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_s(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_d(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_d(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_c(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_c(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_z(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_z(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_get_config(name) + @ccall tblis.tblis_get_config(name::Ptr{Cchar})::Ptr{tblis_config} +end + +const tblis_comm = tci_comm + +# no prototype is found for this function at thread.h:21:10, please use with caution +function tblis_get_num_threads() + @ccall tblis.tblis_get_num_threads()::Cuint +end + +function tblis_set_num_threads(num_threads) + @ccall tblis.tblis_set_num_threads(num_threads::Cuint)::Cvoid +end + +function tblis_vector_add(comm, cfg, A, B) + @ccall tblis.tblis_vector_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_vector_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_vector_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_vector_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_vector}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_vector_scale(comm, cfg, A) + @ccall tblis.tblis_vector_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_set(comm, cfg, alpha, A) + @ccall tblis.tblis_vector_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_vector})::Cvoid +end + +function tblis_matrix_add(comm, cfg, A, B) + @ccall tblis.tblis_matrix_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_matrix_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_matrix_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_matrix_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_matrix_scale(comm, cfg, A) + @ccall tblis.tblis_matrix_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_set(comm, cfg, alpha, A) + @ccall tblis.tblis_matrix_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_add(comm, cfg, A, idx_A, B, idx_B) + @ccall tblis.tblis_tensor_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type})::Cvoid +end + +function tblis_tensor_dot(comm, cfg, A, idx_A, B, idx_B, result) + @ccall tblis.tblis_tensor_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_tensor_reduce(comm, cfg, op, A, idx_A, result, idx) + @ccall tblis.tblis_tensor_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type}, result::Ptr{tblis_scalar}, + idx::Ptr{len_type})::Cvoid +end + +function tblis_tensor_scale(comm, cfg, A, idx_A) + @ccall tblis.tblis_tensor_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type})::Cvoid +end + +function tblis_tensor_set(comm, cfg, alpha, A, idx_A) + @ccall tblis.tblis_tensor_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type})::Cvoid +end + +function tblis_matrix_mult(comm, cfg, A, B, C) + @ccall tblis.tblis_matrix_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_mult_diag(comm, cfg, A, D, B, C) + @ccall tblis.tblis_matrix_mult_diag(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, D::Ptr{tblis_vector}, + B::Ptr{tblis_matrix}, C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_mult(comm, cfg, A, idx_A, B, idx_B, C, idx_C) + @ccall tblis.tblis_tensor_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + C::Ptr{tblis_tensor}, idx_C::Ptr{label_type})::Cvoid +end + +const TCI_USE_ATOMIC_SPINLOCK = 1 + +const TCI_USE_OMP_LOCK = 0 + +const TCI_USE_OPENMP_THREADS = 1 + +const TCI_USE_WINDOWS_THREADS = 0 + +const TCI_USE_TBB_THREADS = 0 + +const TCI_USE_PPL_THREADS = 0 + +const TCI_USE_OMPTASK_THREADS = 0 + +const TCI_USE_DISPATCH_THREADS = 0 + +const TCI_USE_OSX_SPINLOCK = 0 + +const TCI_USE_PTHREADS_THREADS = 0 + +const TCI_USE_PTHREAD_BARRIER = 0 + +const TCI_USE_PTHREAD_MUTEX = 0 + +const TCI_USE_PTHREAD_SPINLOCK = 0 + +const TCI_USE_SPIN_BARRIER = 1 + +const TCI_ARCH_ARM32 = 1 + +# Skipping MacroDefinition: TCI_INLINE static inline + +const TBLIS_HAVE_SYSCONF = 1 + +const TBLIS_HAVE_SYSCTL = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_CONF = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_ONLN = 1 + +const TBLIS_LABEL_TYPE = Cchar + +const TBLIS_LEN_TYPE = ptrdiff_t + +const TBLIS_LT_OBJDIR = ".libs/" + +const TBLIS_PACKAGE = "tblis" + +const TBLIS_PACKAGE_BUGREPORT = "dmatthews@utexas.edu" + +const TBLIS_PACKAGE_NAME = "tblis" + +const TBLIS_PACKAGE_STRING = "tblis 1.2.0" + +const TBLIS_PACKAGE_TARNAME = "tblis" + +const TBLIS_PACKAGE_URL = "http://www.github.com/devinamatthews/tblis" + +const TBLIS_PACKAGE_VERSION = "1.2.0" + +# Skipping MacroDefinition: _tblis_restrict __restrict + +const TBLIS_STDC_HEADERS = 1 + +const TBLIS_STRIDE_TYPE = ptrdiff_t + +const TBLIS_TOPDIR = "/workspace/srcdir/tblis" + +const TBLIS_VERSION = "1.2.0" diff --git a/src/lib/armv7l-linux-musleabihf.jl b/src/lib/armv7l-linux-musleabihf.jl new file mode 100644 index 0000000..a6e8f32 --- /dev/null +++ b/src/lib/armv7l-linux-musleabihf.jl @@ -0,0 +1,779 @@ +# no prototype is found for this function at yield.h:27:17, please use with caution +function tci_yield() + @ccall tblis.tci_yield()::Cvoid +end + +const tci_mutex = Cchar + +function tci_mutex_init(mutex) + @ccall tblis.tci_mutex_init(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_destroy(mutex) + @ccall tblis.tci_mutex_destroy(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_lock(mutex) + @ccall tblis.tci_mutex_lock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutexrylock(mutex) + @ccall tblis.tci_mutexrylock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_unlock(mutex) + @ccall tblis.tci_mutex_unlock(mutex::Ptr{tci_mutex})::Cint +end + +struct tci_barrier_node + parent::Ptr{tci_barrier_node} + nchildren::Cuint + step::Cuint + nwaiting::Cuint +end + +function tci_barrier_node_init(barrier, parent, nchildren) + @ccall tblis.tci_barrier_node_init(barrier::Ptr{tci_barrier_node}, + parent::Ptr{tci_barrier_node}, + nchildren::Cuint)::Cint +end + +function tci_barrier_node_destroy(barrier) + @ccall tblis.tci_barrier_node_destroy(barrier::Ptr{tci_barrier_node})::Cint +end + +function tci_barrier_node_wait(barrier) + @ccall tblis.tci_barrier_node_wait(barrier::Ptr{tci_barrier_node})::Cint +end + +struct __JL_Ctag_25 + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{__JL_Ctag_25}, f::Symbol) + f === :array && return Ptr{Ptr{tci_barrier_node}}(x + 0) + f === :single && return Ptr{tci_barrier_node}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::__JL_Ctag_25, f::Symbol) + r = Ref{__JL_Ctag_25}(x) + ptr = Base.unsafe_convert(Ptr{__JL_Ctag_25}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{__JL_Ctag_25}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tci_barrier + data::NTuple{28,UInt8} +end + +function Base.getproperty(x::Ptr{tci_barrier}, f::Symbol) + f === :barrier && return Ptr{__JL_Ctag_25}(x + 0) + f === :nthread && return Ptr{Cuint}(x + 16) + f === :group_size && return Ptr{Cuint}(x + 20) + f === :is_tree && return Ptr{Cint}(x + 24) + return getfield(x, f) +end + +function Base.getproperty(x::tci_barrier, f::Symbol) + r = Ref{tci_barrier}(x) + ptr = Base.unsafe_convert(Ptr{tci_barrier}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tci_barrier}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tci_barrier_is_tree(barrier) + @ccall tblis.tci_barrier_is_tree(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_init(barrier, nthread, group_size) + @ccall tblis.tci_barrier_init(barrier::Ptr{tci_barrier}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_barrier_destroy(barrier) + @ccall tblis.tci_barrier_destroy(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_wait(barrier, tid) + @ccall tblis.tci_barrier_wait(barrier::Ptr{tci_barrier}, tid::Cuint)::Cint +end + +struct tci_context + barrier::tci_barrier + buffer::Ptr{Cvoid} + refcount::Cuint +end + +function tci_context_init(context, nthread, group_size) + @ccall tblis.tci_context_init(context::Ptr{Ptr{tci_context}}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_context_attach(context) + @ccall tblis.tci_context_attach(context::Ptr{tci_context})::Cint +end + +function tci_context_detach(context) + @ccall tblis.tci_context_detach(context::Ptr{tci_context})::Cint +end + +function tci_context_barrier(context, tid) + @ccall tblis.tci_context_barrier(context::Ptr{tci_context}, tid::Cuint)::Cint +end + +function tci_context_send(context, tid, object) + @ccall tblis.tci_context_send(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_send_nowait(context, tid, object) + @ccall tblis.tci_context_send_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_receive(context, tid, object) + @ccall tblis.tci_context_receive(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +function tci_context_receive_nowait(context, tid, object) + @ccall tblis.tci_context_receive_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +struct tci_comm + context::Ptr{tci_context} + ngang::Cuint + gid::Cuint + nthread::Cuint + tid::Cuint +end + +@enum __JL_Ctag_3::UInt32 begin + TCI_EVENLY = 2 + TCI_CYCLIC = 4 + TCI_BLOCK_CYCLIC = 6 + TCI_BLOCKED = 8 + TCI_NO_CONTEXT = 1 +end + +mutable struct tci_range + size::UInt64 + grain::UInt64 + tci_range() = new() +end + +# typedef void ( * tci_range_func ) ( tci_comm * , uint64_t , uint64_t , void * ) +const tci_range_func = Ptr{Cvoid} + +# typedef void ( * tci_range_2d_func ) ( tci_comm * , uint64_t , uint64_t , uint64_t , uint64_t , void * ) +const tci_range_2d_func = Ptr{Cvoid} + +function tci_comm_init_single(comm) + @ccall tblis.tci_comm_init_single(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_init(comm, context, nthread, tid, ngang, gid) + @ccall tblis.tci_comm_init(comm::Ptr{tci_comm}, context::Ptr{tci_context}, + nthread::Cuint, tid::Cuint, ngang::Cuint, gid::Cuint)::Cint +end + +function tci_comm_destroy(comm) + @ccall tblis.tci_comm_destroy(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_is_master(comm) + @ccall tblis.tci_comm_is_master(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_barrier(comm) + @ccall tblis.tci_comm_barrier(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_bcast(comm, object, root) + @ccall tblis.tci_comm_bcast(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_bcast_nowait(comm, object, root) + @ccall tblis.tci_comm_bcast_nowait(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_gang(parent, child, type, n, bs) + @ccall tblis.tci_comm_gang(parent::Ptr{tci_comm}, child::Ptr{tci_comm}, type::Cint, + n::Cuint, bs::Cuint)::Cint +end + +function tci_comm_distribute_over_gangs(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_threads(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_gangs_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs_2d(comm::Ptr{tci_comm}, range_m::tci_range, + range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_threads_2d(comm::Ptr{tci_comm}, + range_m::tci_range, range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +# typedef void ( * tci_thread_func ) ( tci_comm * , void * ) +const tci_thread_func = Ptr{Cvoid} + +function tci_parallelize(func, payload, nthread, arity) + @ccall tblis.tci_parallelize(func::tci_thread_func, payload::Ptr{Cvoid}, nthread::Cuint, + arity::Cuint)::Cint +end + +struct tci_prime_factors + n::Cuint + sqrt_n::Cuint + f::Cuint +end + +function tci_prime_factorization(n, factors) + @ccall tblis.tci_prime_factorization(n::Cuint, factors::Ptr{tci_prime_factors})::Cvoid +end + +function tci_next_prime_factor(factors) + @ccall tblis.tci_next_prime_factor(factors::Ptr{tci_prime_factors})::Cuint +end + +function tci_partition_2x2(nthread, work1, max1, work2, max2, nt1, nt2) + @ccall tblis.tci_partition_2x2(nthread::Cuint, work1::UInt64, max1::Cuint, + work2::UInt64, max2::Cuint, nt1::Ptr{Cuint}, + nt2::Ptr{Cuint})::Cvoid +end + +const tci_slot = Cint + +function tci_slot_init(slot, empty) + @ccall tblis.tci_slot_init(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_is_filled(slot, empty) + @ccall tblis.tci_slot_is_filled(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_try_fill(slot, empty, value) + @ccall tblis.tci_slot_try_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cint +end + +function tci_slot_fill(slot, empty, value) + @ccall tblis.tci_slot_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cvoid +end + +function tci_slot_clear(slot, empty) + @ccall tblis.tci_slot_clear(slot::Ptr{tci_slot}, empty::Cint)::Cvoid +end + +@enum __JL_Ctag_4::UInt32 begin + TCI_NOT_WORKED_ON = 0 + TCI_IN_PROGRESS = 1 + TCI_RESERVED = 2 + TCI_FINISHED = 3 +end + +const tci_work_item = Cint + +function tci_work_item_try_work(item) + @ccall tblis.tci_work_item_try_work(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_finish(item) + @ccall tblis.tci_work_item_finish(item::Ptr{tci_work_item})::Cvoid +end + +function tci_work_item_status(item) + @ccall tblis.tci_work_item_status(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_wait(item) + @ccall tblis.tci_work_item_wait(item::Ptr{tci_work_item})::Cvoid +end + +mutable struct tblis_config_s end + +const tblis_config = tblis_config_s + +@enum reduce_t::UInt32 begin + REDUCE_SUM = 0 + REDUCE_SUM_ABS = 1 + REDUCE_MAX = 2 + REDUCE_MAX_ABS = 3 + REDUCE_MIN = 4 + REDUCE_MIN_ABS = 5 + # REDUCE_NORM_1 = 1 + REDUCE_NORM_2 = 6 + # REDUCE_NORM_INF = 3 +end + +@enum type_t::UInt32 begin + TYPE_SINGLE = 0 + # TYPE_FLOAT = 0 + TYPE_DOUBLE = 1 + TYPE_SCOMPLEX = 2 + TYPE_DCOMPLEX = 3 +end + +const len_type = Cptrdiff_t + +const stride_type = Cptrdiff_t + +const label_type = Cchar + +mutable struct fake_scomplex + real::Cfloat + imag::Cfloat + fake_scomplex() = new() +end + +mutable struct fake_dcomplex + real::Cdouble + imag::Cdouble + fake_dcomplex() = new() +end + +struct scalar + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{scalar}, f::Symbol) + f === :s && return Ptr{Cfloat}(x + 0) + f === :d && return Ptr{Cdouble}(x + 0) + f === :c && return Ptr{scomplex}(x + 0) + f === :z && return Ptr{dcomplex}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::scalar, f::Symbol) + r = Ref{scalar}(x) + ptr = Base.unsafe_convert(Ptr{scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tblis_scalar + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{tblis_scalar}, f::Symbol) + f === :data && return Ptr{scalar}(x + 0) + f === :type && return Ptr{type_t}(x + 16) + return getfield(x, f) +end + +function Base.getproperty(x::tblis_scalar, f::Symbol) + r = Ref{tblis_scalar}(x) + ptr = Base.unsafe_convert(Ptr{tblis_scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tblis_scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tblis_init_scalar_s(s, value) + @ccall tblis.tblis_init_scalar_s(s::Ptr{tblis_scalar}, value::Cfloat)::Cvoid +end + +function tblis_init_scalar_d(s, value) + @ccall tblis.tblis_init_scalar_d(s::Ptr{tblis_scalar}, value::Cdouble)::Cvoid +end + +function tblis_init_scalar_c(s, value) + @ccall tblis.tblis_init_scalar_c(s::Ptr{tblis_scalar}, value::scomplex)::Cvoid +end + +function tblis_init_scalar_z(s, value) + @ccall tblis.tblis_init_scalar_z(s::Ptr{tblis_scalar}, value::dcomplex)::Cvoid +end + +mutable struct tblis_vector + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + n::len_type + inc::stride_type + tblis_vector() = new() +end + +function tblis_init_vector_scaled_s(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_s(v::Ptr{tblis_vector}, scalar_::Cfloat, + n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_d(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_d(v::Ptr{tblis_vector}, scalar_::Cdouble, + n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_c(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_c(v::Ptr{tblis_vector}, scalar_::scomplex, + n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_z(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_z(v::Ptr{tblis_vector}, scalar_::dcomplex, + n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_s(v, n, data, inc) + @ccall tblis.tblis_init_vector_s(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_d(v, n, data, inc) + @ccall tblis.tblis_init_vector_d(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_c(v, n, data, inc) + @ccall tblis.tblis_init_vector_c(v::Ptr{tblis_vector}, n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_z(v, n, data, inc) + @ccall tblis.tblis_init_vector_z(v::Ptr{tblis_vector}, n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +mutable struct tblis_matrix + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + m::len_type + n::len_type + rs::stride_type + cs::stride_type + tblis_matrix() = new() +end + +function tblis_init_matrix_scaled_s(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_s(mat::Ptr{tblis_matrix}, scalar_::Cfloat, + m::len_type, n::len_type, data::Ptr{Cfloat}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_d(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_d(mat::Ptr{tblis_matrix}, scalar_::Cdouble, + m::len_type, n::len_type, data::Ptr{Cdouble}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_c(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_c(mat::Ptr{tblis_matrix}, scalar_::scomplex, + m::len_type, n::len_type, data::Ptr{scomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_z(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_z(mat::Ptr{tblis_matrix}, scalar_::dcomplex, + m::len_type, n::len_type, data::Ptr{dcomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_s(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_s(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cfloat}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_d(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_d(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cdouble}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_c(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_c(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{scomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_z(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_z(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{dcomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +struct tblis_tensor + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + ndim::Cuint + len::Ptr{len_type} + stride::Ptr{stride_type} +end + +function tblis_init_tensor_scaled_s(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_s(t::Ptr{tblis_tensor}, scalar_::Cfloat, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_d(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_d(t::Ptr{tblis_tensor}, scalar_::Cdouble, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_c(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_c(t::Ptr{tblis_tensor}, scalar_::scomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_z(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_z(t::Ptr{tblis_tensor}, scalar_::dcomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_s(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_s(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_d(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_d(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_c(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_c(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_z(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_z(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_get_config(name) + @ccall tblis.tblis_get_config(name::Ptr{Cchar})::Ptr{tblis_config} +end + +const tblis_comm = tci_comm + +# no prototype is found for this function at thread.h:21:10, please use with caution +function tblis_get_num_threads() + @ccall tblis.tblis_get_num_threads()::Cuint +end + +function tblis_set_num_threads(num_threads) + @ccall tblis.tblis_set_num_threads(num_threads::Cuint)::Cvoid +end + +function tblis_vector_add(comm, cfg, A, B) + @ccall tblis.tblis_vector_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_vector_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_vector_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_vector_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_vector}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_vector_scale(comm, cfg, A) + @ccall tblis.tblis_vector_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_set(comm, cfg, alpha, A) + @ccall tblis.tblis_vector_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_vector})::Cvoid +end + +function tblis_matrix_add(comm, cfg, A, B) + @ccall tblis.tblis_matrix_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_matrix_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_matrix_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_matrix_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_matrix_scale(comm, cfg, A) + @ccall tblis.tblis_matrix_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_set(comm, cfg, alpha, A) + @ccall tblis.tblis_matrix_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_add(comm, cfg, A, idx_A, B, idx_B) + @ccall tblis.tblis_tensor_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type})::Cvoid +end + +function tblis_tensor_dot(comm, cfg, A, idx_A, B, idx_B, result) + @ccall tblis.tblis_tensor_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_tensor_reduce(comm, cfg, op, A, idx_A, result, idx) + @ccall tblis.tblis_tensor_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type}, result::Ptr{tblis_scalar}, + idx::Ptr{len_type})::Cvoid +end + +function tblis_tensor_scale(comm, cfg, A, idx_A) + @ccall tblis.tblis_tensor_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type})::Cvoid +end + +function tblis_tensor_set(comm, cfg, alpha, A, idx_A) + @ccall tblis.tblis_tensor_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type})::Cvoid +end + +function tblis_matrix_mult(comm, cfg, A, B, C) + @ccall tblis.tblis_matrix_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_mult_diag(comm, cfg, A, D, B, C) + @ccall tblis.tblis_matrix_mult_diag(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, D::Ptr{tblis_vector}, + B::Ptr{tblis_matrix}, C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_mult(comm, cfg, A, idx_A, B, idx_B, C, idx_C) + @ccall tblis.tblis_tensor_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + C::Ptr{tblis_tensor}, idx_C::Ptr{label_type})::Cvoid +end + +const TCI_USE_ATOMIC_SPINLOCK = 1 + +const TCI_USE_OMP_LOCK = 0 + +const TCI_USE_OPENMP_THREADS = 1 + +const TCI_USE_WINDOWS_THREADS = 0 + +const TCI_USE_TBB_THREADS = 0 + +const TCI_USE_PPL_THREADS = 0 + +const TCI_USE_OMPTASK_THREADS = 0 + +const TCI_USE_DISPATCH_THREADS = 0 + +const TCI_USE_OSX_SPINLOCK = 0 + +const TCI_USE_PTHREADS_THREADS = 0 + +const TCI_USE_PTHREAD_BARRIER = 0 + +const TCI_USE_PTHREAD_MUTEX = 0 + +const TCI_USE_PTHREAD_SPINLOCK = 0 + +const TCI_USE_SPIN_BARRIER = 1 + +const TCI_ARCH_ARM32 = 1 + +# Skipping MacroDefinition: TCI_INLINE static inline + +const TBLIS_HAVE_SYSCONF = 1 + +const TBLIS_HAVE_SYSCTL = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_CONF = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_ONLN = 1 + +const TBLIS_LABEL_TYPE = Cchar + +const TBLIS_LEN_TYPE = ptrdiff_t + +const TBLIS_LT_OBJDIR = ".libs/" + +const TBLIS_PACKAGE = "tblis" + +const TBLIS_PACKAGE_BUGREPORT = "dmatthews@utexas.edu" + +const TBLIS_PACKAGE_NAME = "tblis" + +const TBLIS_PACKAGE_STRING = "tblis 1.2.0" + +const TBLIS_PACKAGE_TARNAME = "tblis" + +const TBLIS_PACKAGE_URL = "http://www.github.com/devinamatthews/tblis" + +const TBLIS_PACKAGE_VERSION = "1.2.0" + +# Skipping MacroDefinition: _tblis_restrict __restrict + +const TBLIS_STDC_HEADERS = 1 + +const TBLIS_STRIDE_TYPE = ptrdiff_t + +const TBLIS_TOPDIR = "/workspace/srcdir/tblis" + +const TBLIS_VERSION = "1.2.0" diff --git a/src/lib/i686-linux-gnu.jl b/src/lib/i686-linux-gnu.jl new file mode 100644 index 0000000..631e87c --- /dev/null +++ b/src/lib/i686-linux-gnu.jl @@ -0,0 +1,779 @@ +# no prototype is found for this function at yield.h:19:17, please use with caution +function tci_yield() + @ccall tblis.tci_yield()::Cvoid +end + +const tci_mutex = Cchar + +function tci_mutex_init(mutex) + @ccall tblis.tci_mutex_init(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_destroy(mutex) + @ccall tblis.tci_mutex_destroy(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_lock(mutex) + @ccall tblis.tci_mutex_lock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutexrylock(mutex) + @ccall tblis.tci_mutexrylock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_unlock(mutex) + @ccall tblis.tci_mutex_unlock(mutex::Ptr{tci_mutex})::Cint +end + +struct tci_barrier_node + parent::Ptr{tci_barrier_node} + nchildren::Cuint + step::Cuint + nwaiting::Cuint +end + +function tci_barrier_node_init(barrier, parent, nchildren) + @ccall tblis.tci_barrier_node_init(barrier::Ptr{tci_barrier_node}, + parent::Ptr{tci_barrier_node}, + nchildren::Cuint)::Cint +end + +function tci_barrier_node_destroy(barrier) + @ccall tblis.tci_barrier_node_destroy(barrier::Ptr{tci_barrier_node})::Cint +end + +function tci_barrier_node_wait(barrier) + @ccall tblis.tci_barrier_node_wait(barrier::Ptr{tci_barrier_node})::Cint +end + +struct __JL_Ctag_50 + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{__JL_Ctag_50}, f::Symbol) + f === :array && return Ptr{Ptr{tci_barrier_node}}(x + 0) + f === :single && return Ptr{tci_barrier_node}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::__JL_Ctag_50, f::Symbol) + r = Ref{__JL_Ctag_50}(x) + ptr = Base.unsafe_convert(Ptr{__JL_Ctag_50}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{__JL_Ctag_50}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tci_barrier + data::NTuple{28,UInt8} +end + +function Base.getproperty(x::Ptr{tci_barrier}, f::Symbol) + f === :barrier && return Ptr{__JL_Ctag_50}(x + 0) + f === :nthread && return Ptr{Cuint}(x + 16) + f === :group_size && return Ptr{Cuint}(x + 20) + f === :is_tree && return Ptr{Cint}(x + 24) + return getfield(x, f) +end + +function Base.getproperty(x::tci_barrier, f::Symbol) + r = Ref{tci_barrier}(x) + ptr = Base.unsafe_convert(Ptr{tci_barrier}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tci_barrier}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tci_barrier_is_tree(barrier) + @ccall tblis.tci_barrier_is_tree(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_init(barrier, nthread, group_size) + @ccall tblis.tci_barrier_init(barrier::Ptr{tci_barrier}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_barrier_destroy(barrier) + @ccall tblis.tci_barrier_destroy(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_wait(barrier, tid) + @ccall tblis.tci_barrier_wait(barrier::Ptr{tci_barrier}, tid::Cuint)::Cint +end + +struct tci_context + barrier::tci_barrier + buffer::Ptr{Cvoid} + refcount::Cuint +end + +function tci_context_init(context, nthread, group_size) + @ccall tblis.tci_context_init(context::Ptr{Ptr{tci_context}}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_context_attach(context) + @ccall tblis.tci_context_attach(context::Ptr{tci_context})::Cint +end + +function tci_context_detach(context) + @ccall tblis.tci_context_detach(context::Ptr{tci_context})::Cint +end + +function tci_context_barrier(context, tid) + @ccall tblis.tci_context_barrier(context::Ptr{tci_context}, tid::Cuint)::Cint +end + +function tci_context_send(context, tid, object) + @ccall tblis.tci_context_send(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_send_nowait(context, tid, object) + @ccall tblis.tci_context_send_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_receive(context, tid, object) + @ccall tblis.tci_context_receive(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +function tci_context_receive_nowait(context, tid, object) + @ccall tblis.tci_context_receive_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +struct tci_comm + context::Ptr{tci_context} + ngang::Cuint + gid::Cuint + nthread::Cuint + tid::Cuint +end + +@enum __JL_Ctag_19::UInt32 begin + TCI_EVENLY = 2 + TCI_CYCLIC = 4 + TCI_BLOCK_CYCLIC = 6 + TCI_BLOCKED = 8 + TCI_NO_CONTEXT = 1 +end + +mutable struct tci_range + size::UInt64 + grain::UInt64 + tci_range() = new() +end + +# typedef void ( * tci_range_func ) ( tci_comm * , uint64_t , uint64_t , void * ) +const tci_range_func = Ptr{Cvoid} + +# typedef void ( * tci_range_2d_func ) ( tci_comm * , uint64_t , uint64_t , uint64_t , uint64_t , void * ) +const tci_range_2d_func = Ptr{Cvoid} + +function tci_comm_init_single(comm) + @ccall tblis.tci_comm_init_single(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_init(comm, context, nthread, tid, ngang, gid) + @ccall tblis.tci_comm_init(comm::Ptr{tci_comm}, context::Ptr{tci_context}, + nthread::Cuint, tid::Cuint, ngang::Cuint, gid::Cuint)::Cint +end + +function tci_comm_destroy(comm) + @ccall tblis.tci_comm_destroy(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_is_master(comm) + @ccall tblis.tci_comm_is_master(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_barrier(comm) + @ccall tblis.tci_comm_barrier(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_bcast(comm, object, root) + @ccall tblis.tci_comm_bcast(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_bcast_nowait(comm, object, root) + @ccall tblis.tci_comm_bcast_nowait(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_gang(parent, child, type, n, bs) + @ccall tblis.tci_comm_gang(parent::Ptr{tci_comm}, child::Ptr{tci_comm}, type::Cint, + n::Cuint, bs::Cuint)::Cint +end + +function tci_comm_distribute_over_gangs(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_threads(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_gangs_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs_2d(comm::Ptr{tci_comm}, range_m::tci_range, + range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_threads_2d(comm::Ptr{tci_comm}, + range_m::tci_range, range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +# typedef void ( * tci_thread_func ) ( tci_comm * , void * ) +const tci_thread_func = Ptr{Cvoid} + +function tci_parallelize(func, payload, nthread, arity) + @ccall tblis.tci_parallelize(func::tci_thread_func, payload::Ptr{Cvoid}, nthread::Cuint, + arity::Cuint)::Cint +end + +struct tci_prime_factors + n::Cuint + sqrt_n::Cuint + f::Cuint +end + +function tci_prime_factorization(n, factors) + @ccall tblis.tci_prime_factorization(n::Cuint, factors::Ptr{tci_prime_factors})::Cvoid +end + +function tci_next_prime_factor(factors) + @ccall tblis.tci_next_prime_factor(factors::Ptr{tci_prime_factors})::Cuint +end + +function tci_partition_2x2(nthread, work1, max1, work2, max2, nt1, nt2) + @ccall tblis.tci_partition_2x2(nthread::Cuint, work1::UInt64, max1::Cuint, + work2::UInt64, max2::Cuint, nt1::Ptr{Cuint}, + nt2::Ptr{Cuint})::Cvoid +end + +const tci_slot = Cint + +function tci_slot_init(slot, empty) + @ccall tblis.tci_slot_init(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_is_filled(slot, empty) + @ccall tblis.tci_slot_is_filled(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_try_fill(slot, empty, value) + @ccall tblis.tci_slot_try_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cint +end + +function tci_slot_fill(slot, empty, value) + @ccall tblis.tci_slot_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cvoid +end + +function tci_slot_clear(slot, empty) + @ccall tblis.tci_slot_clear(slot::Ptr{tci_slot}, empty::Cint)::Cvoid +end + +@enum __JL_Ctag_20::UInt32 begin + TCI_NOT_WORKED_ON = 0 + TCI_IN_PROGRESS = 1 + TCI_RESERVED = 2 + TCI_FINISHED = 3 +end + +const tci_work_item = Cint + +function tci_work_item_try_work(item) + @ccall tblis.tci_work_item_try_work(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_finish(item) + @ccall tblis.tci_work_item_finish(item::Ptr{tci_work_item})::Cvoid +end + +function tci_work_item_status(item) + @ccall tblis.tci_work_item_status(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_wait(item) + @ccall tblis.tci_work_item_wait(item::Ptr{tci_work_item})::Cvoid +end + +mutable struct tblis_config_s end + +const tblis_config = tblis_config_s + +@enum reduce_t::UInt32 begin + REDUCE_SUM = 0 + REDUCE_SUM_ABS = 1 + REDUCE_MAX = 2 + REDUCE_MAX_ABS = 3 + REDUCE_MIN = 4 + REDUCE_MIN_ABS = 5 + # REDUCE_NORM_1 = 1 + REDUCE_NORM_2 = 6 + # REDUCE_NORM_INF = 3 +end + +@enum type_t::UInt32 begin + TYPE_SINGLE = 0 + # TYPE_FLOAT = 0 + TYPE_DOUBLE = 1 + TYPE_SCOMPLEX = 2 + TYPE_DCOMPLEX = 3 +end + +const len_type = Cptrdiff_t + +const stride_type = Cptrdiff_t + +const label_type = Cchar + +mutable struct fake_scomplex + real::Cfloat + imag::Cfloat + fake_scomplex() = new() +end + +mutable struct fake_dcomplex + real::Cdouble + imag::Cdouble + fake_dcomplex() = new() +end + +struct scalar + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{scalar}, f::Symbol) + f === :s && return Ptr{Cfloat}(x + 0) + f === :d && return Ptr{Cdouble}(x + 0) + f === :c && return Ptr{scomplex}(x + 0) + f === :z && return Ptr{dcomplex}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::scalar, f::Symbol) + r = Ref{scalar}(x) + ptr = Base.unsafe_convert(Ptr{scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tblis_scalar + data::NTuple{20,UInt8} +end + +function Base.getproperty(x::Ptr{tblis_scalar}, f::Symbol) + f === :data && return Ptr{scalar}(x + 0) + f === :type && return Ptr{type_t}(x + 16) + return getfield(x, f) +end + +function Base.getproperty(x::tblis_scalar, f::Symbol) + r = Ref{tblis_scalar}(x) + ptr = Base.unsafe_convert(Ptr{tblis_scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tblis_scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tblis_init_scalar_s(s, value) + @ccall tblis.tblis_init_scalar_s(s::Ptr{tblis_scalar}, value::Cfloat)::Cvoid +end + +function tblis_init_scalar_d(s, value) + @ccall tblis.tblis_init_scalar_d(s::Ptr{tblis_scalar}, value::Cdouble)::Cvoid +end + +function tblis_init_scalar_c(s, value) + @ccall tblis.tblis_init_scalar_c(s::Ptr{tblis_scalar}, value::scomplex)::Cvoid +end + +function tblis_init_scalar_z(s, value) + @ccall tblis.tblis_init_scalar_z(s::Ptr{tblis_scalar}, value::dcomplex)::Cvoid +end + +mutable struct tblis_vector + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + n::len_type + inc::stride_type + tblis_vector() = new() +end + +function tblis_init_vector_scaled_s(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_s(v::Ptr{tblis_vector}, scalar_::Cfloat, + n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_d(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_d(v::Ptr{tblis_vector}, scalar_::Cdouble, + n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_c(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_c(v::Ptr{tblis_vector}, scalar_::scomplex, + n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_z(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_z(v::Ptr{tblis_vector}, scalar_::dcomplex, + n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_s(v, n, data, inc) + @ccall tblis.tblis_init_vector_s(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_d(v, n, data, inc) + @ccall tblis.tblis_init_vector_d(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_c(v, n, data, inc) + @ccall tblis.tblis_init_vector_c(v::Ptr{tblis_vector}, n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_z(v, n, data, inc) + @ccall tblis.tblis_init_vector_z(v::Ptr{tblis_vector}, n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +mutable struct tblis_matrix + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + m::len_type + n::len_type + rs::stride_type + cs::stride_type + tblis_matrix() = new() +end + +function tblis_init_matrix_scaled_s(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_s(mat::Ptr{tblis_matrix}, scalar_::Cfloat, + m::len_type, n::len_type, data::Ptr{Cfloat}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_d(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_d(mat::Ptr{tblis_matrix}, scalar_::Cdouble, + m::len_type, n::len_type, data::Ptr{Cdouble}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_c(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_c(mat::Ptr{tblis_matrix}, scalar_::scomplex, + m::len_type, n::len_type, data::Ptr{scomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_z(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_z(mat::Ptr{tblis_matrix}, scalar_::dcomplex, + m::len_type, n::len_type, data::Ptr{dcomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_s(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_s(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cfloat}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_d(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_d(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cdouble}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_c(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_c(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{scomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_z(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_z(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{dcomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +struct tblis_tensor + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + ndim::Cuint + len::Ptr{len_type} + stride::Ptr{stride_type} +end + +function tblis_init_tensor_scaled_s(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_s(t::Ptr{tblis_tensor}, scalar_::Cfloat, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_d(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_d(t::Ptr{tblis_tensor}, scalar_::Cdouble, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_c(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_c(t::Ptr{tblis_tensor}, scalar_::scomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_z(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_z(t::Ptr{tblis_tensor}, scalar_::dcomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_s(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_s(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_d(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_d(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_c(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_c(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_z(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_z(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_get_config(name) + @ccall tblis.tblis_get_config(name::Ptr{Cchar})::Ptr{tblis_config} +end + +const tblis_comm = tci_comm + +# no prototype is found for this function at thread.h:21:10, please use with caution +function tblis_get_num_threads() + @ccall tblis.tblis_get_num_threads()::Cuint +end + +function tblis_set_num_threads(num_threads) + @ccall tblis.tblis_set_num_threads(num_threads::Cuint)::Cvoid +end + +function tblis_vector_add(comm, cfg, A, B) + @ccall tblis.tblis_vector_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_vector_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_vector_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_vector_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_vector}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_vector_scale(comm, cfg, A) + @ccall tblis.tblis_vector_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_set(comm, cfg, alpha, A) + @ccall tblis.tblis_vector_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_vector})::Cvoid +end + +function tblis_matrix_add(comm, cfg, A, B) + @ccall tblis.tblis_matrix_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_matrix_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_matrix_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_matrix_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_matrix_scale(comm, cfg, A) + @ccall tblis.tblis_matrix_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_set(comm, cfg, alpha, A) + @ccall tblis.tblis_matrix_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_add(comm, cfg, A, idx_A, B, idx_B) + @ccall tblis.tblis_tensor_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type})::Cvoid +end + +function tblis_tensor_dot(comm, cfg, A, idx_A, B, idx_B, result) + @ccall tblis.tblis_tensor_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_tensor_reduce(comm, cfg, op, A, idx_A, result, idx) + @ccall tblis.tblis_tensor_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type}, result::Ptr{tblis_scalar}, + idx::Ptr{len_type})::Cvoid +end + +function tblis_tensor_scale(comm, cfg, A, idx_A) + @ccall tblis.tblis_tensor_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type})::Cvoid +end + +function tblis_tensor_set(comm, cfg, alpha, A, idx_A) + @ccall tblis.tblis_tensor_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type})::Cvoid +end + +function tblis_matrix_mult(comm, cfg, A, B, C) + @ccall tblis.tblis_matrix_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_mult_diag(comm, cfg, A, D, B, C) + @ccall tblis.tblis_matrix_mult_diag(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, D::Ptr{tblis_vector}, + B::Ptr{tblis_matrix}, C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_mult(comm, cfg, A, idx_A, B, idx_B, C, idx_C) + @ccall tblis.tblis_tensor_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + C::Ptr{tblis_tensor}, idx_C::Ptr{label_type})::Cvoid +end + +const TCI_USE_ATOMIC_SPINLOCK = 1 + +const TCI_USE_OMP_LOCK = 0 + +const TCI_USE_OPENMP_THREADS = 1 + +const TCI_USE_WINDOWS_THREADS = 0 + +const TCI_USE_TBB_THREADS = 0 + +const TCI_USE_PPL_THREADS = 0 + +const TCI_USE_OMPTASK_THREADS = 0 + +const TCI_USE_DISPATCH_THREADS = 0 + +const TCI_USE_OSX_SPINLOCK = 0 + +const TCI_USE_PTHREADS_THREADS = 0 + +const TCI_USE_PTHREAD_BARRIER = 0 + +const TCI_USE_PTHREAD_MUTEX = 0 + +const TCI_USE_PTHREAD_SPINLOCK = 0 + +const TCI_USE_SPIN_BARRIER = 1 + +const TCI_ARCH_X86 = 1 + +# Skipping MacroDefinition: TCI_INLINE static inline + +const TBLIS_HAVE_SYSCONF = 1 + +const TBLIS_HAVE_SYSCTL = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_CONF = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_ONLN = 1 + +const TBLIS_LABEL_TYPE = Cchar + +const TBLIS_LEN_TYPE = ptrdiff_t + +const TBLIS_LT_OBJDIR = ".libs/" + +const TBLIS_PACKAGE = "tblis" + +const TBLIS_PACKAGE_BUGREPORT = "dmatthews@utexas.edu" + +const TBLIS_PACKAGE_NAME = "tblis" + +const TBLIS_PACKAGE_STRING = "tblis 1.2.0" + +const TBLIS_PACKAGE_TARNAME = "tblis" + +const TBLIS_PACKAGE_URL = "http://www.github.com/devinamatthews/tblis" + +const TBLIS_PACKAGE_VERSION = "1.2.0" + +# Skipping MacroDefinition: _tblis_restrict __restrict + +const TBLIS_STDC_HEADERS = 1 + +const TBLIS_STRIDE_TYPE = ptrdiff_t + +const TBLIS_TOPDIR = "/workspace/srcdir/tblis" + +const TBLIS_VERSION = "1.2.0" diff --git a/src/lib/i686-linux-musl.jl b/src/lib/i686-linux-musl.jl new file mode 100644 index 0000000..3734c15 --- /dev/null +++ b/src/lib/i686-linux-musl.jl @@ -0,0 +1,779 @@ +# no prototype is found for this function at yield.h:19:17, please use with caution +function tci_yield() + @ccall tblis.tci_yield()::Cvoid +end + +const tci_mutex = Cchar + +function tci_mutex_init(mutex) + @ccall tblis.tci_mutex_init(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_destroy(mutex) + @ccall tblis.tci_mutex_destroy(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_lock(mutex) + @ccall tblis.tci_mutex_lock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutexrylock(mutex) + @ccall tblis.tci_mutexrylock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_unlock(mutex) + @ccall tblis.tci_mutex_unlock(mutex::Ptr{tci_mutex})::Cint +end + +struct tci_barrier_node + parent::Ptr{tci_barrier_node} + nchildren::Cuint + step::Cuint + nwaiting::Cuint +end + +function tci_barrier_node_init(barrier, parent, nchildren) + @ccall tblis.tci_barrier_node_init(barrier::Ptr{tci_barrier_node}, + parent::Ptr{tci_barrier_node}, + nchildren::Cuint)::Cint +end + +function tci_barrier_node_destroy(barrier) + @ccall tblis.tci_barrier_node_destroy(barrier::Ptr{tci_barrier_node})::Cint +end + +function tci_barrier_node_wait(barrier) + @ccall tblis.tci_barrier_node_wait(barrier::Ptr{tci_barrier_node})::Cint +end + +struct __JL_Ctag_28 + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{__JL_Ctag_28}, f::Symbol) + f === :array && return Ptr{Ptr{tci_barrier_node}}(x + 0) + f === :single && return Ptr{tci_barrier_node}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::__JL_Ctag_28, f::Symbol) + r = Ref{__JL_Ctag_28}(x) + ptr = Base.unsafe_convert(Ptr{__JL_Ctag_28}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{__JL_Ctag_28}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tci_barrier + data::NTuple{28,UInt8} +end + +function Base.getproperty(x::Ptr{tci_barrier}, f::Symbol) + f === :barrier && return Ptr{__JL_Ctag_28}(x + 0) + f === :nthread && return Ptr{Cuint}(x + 16) + f === :group_size && return Ptr{Cuint}(x + 20) + f === :is_tree && return Ptr{Cint}(x + 24) + return getfield(x, f) +end + +function Base.getproperty(x::tci_barrier, f::Symbol) + r = Ref{tci_barrier}(x) + ptr = Base.unsafe_convert(Ptr{tci_barrier}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tci_barrier}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tci_barrier_is_tree(barrier) + @ccall tblis.tci_barrier_is_tree(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_init(barrier, nthread, group_size) + @ccall tblis.tci_barrier_init(barrier::Ptr{tci_barrier}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_barrier_destroy(barrier) + @ccall tblis.tci_barrier_destroy(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_wait(barrier, tid) + @ccall tblis.tci_barrier_wait(barrier::Ptr{tci_barrier}, tid::Cuint)::Cint +end + +struct tci_context + barrier::tci_barrier + buffer::Ptr{Cvoid} + refcount::Cuint +end + +function tci_context_init(context, nthread, group_size) + @ccall tblis.tci_context_init(context::Ptr{Ptr{tci_context}}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_context_attach(context) + @ccall tblis.tci_context_attach(context::Ptr{tci_context})::Cint +end + +function tci_context_detach(context) + @ccall tblis.tci_context_detach(context::Ptr{tci_context})::Cint +end + +function tci_context_barrier(context, tid) + @ccall tblis.tci_context_barrier(context::Ptr{tci_context}, tid::Cuint)::Cint +end + +function tci_context_send(context, tid, object) + @ccall tblis.tci_context_send(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_send_nowait(context, tid, object) + @ccall tblis.tci_context_send_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_receive(context, tid, object) + @ccall tblis.tci_context_receive(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +function tci_context_receive_nowait(context, tid, object) + @ccall tblis.tci_context_receive_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +struct tci_comm + context::Ptr{tci_context} + ngang::Cuint + gid::Cuint + nthread::Cuint + tid::Cuint +end + +@enum __JL_Ctag_6::UInt32 begin + TCI_EVENLY = 2 + TCI_CYCLIC = 4 + TCI_BLOCK_CYCLIC = 6 + TCI_BLOCKED = 8 + TCI_NO_CONTEXT = 1 +end + +mutable struct tci_range + size::UInt64 + grain::UInt64 + tci_range() = new() +end + +# typedef void ( * tci_range_func ) ( tci_comm * , uint64_t , uint64_t , void * ) +const tci_range_func = Ptr{Cvoid} + +# typedef void ( * tci_range_2d_func ) ( tci_comm * , uint64_t , uint64_t , uint64_t , uint64_t , void * ) +const tci_range_2d_func = Ptr{Cvoid} + +function tci_comm_init_single(comm) + @ccall tblis.tci_comm_init_single(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_init(comm, context, nthread, tid, ngang, gid) + @ccall tblis.tci_comm_init(comm::Ptr{tci_comm}, context::Ptr{tci_context}, + nthread::Cuint, tid::Cuint, ngang::Cuint, gid::Cuint)::Cint +end + +function tci_comm_destroy(comm) + @ccall tblis.tci_comm_destroy(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_is_master(comm) + @ccall tblis.tci_comm_is_master(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_barrier(comm) + @ccall tblis.tci_comm_barrier(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_bcast(comm, object, root) + @ccall tblis.tci_comm_bcast(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_bcast_nowait(comm, object, root) + @ccall tblis.tci_comm_bcast_nowait(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_gang(parent, child, type, n, bs) + @ccall tblis.tci_comm_gang(parent::Ptr{tci_comm}, child::Ptr{tci_comm}, type::Cint, + n::Cuint, bs::Cuint)::Cint +end + +function tci_comm_distribute_over_gangs(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_threads(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_gangs_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs_2d(comm::Ptr{tci_comm}, range_m::tci_range, + range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_threads_2d(comm::Ptr{tci_comm}, + range_m::tci_range, range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +# typedef void ( * tci_thread_func ) ( tci_comm * , void * ) +const tci_thread_func = Ptr{Cvoid} + +function tci_parallelize(func, payload, nthread, arity) + @ccall tblis.tci_parallelize(func::tci_thread_func, payload::Ptr{Cvoid}, nthread::Cuint, + arity::Cuint)::Cint +end + +struct tci_prime_factors + n::Cuint + sqrt_n::Cuint + f::Cuint +end + +function tci_prime_factorization(n, factors) + @ccall tblis.tci_prime_factorization(n::Cuint, factors::Ptr{tci_prime_factors})::Cvoid +end + +function tci_next_prime_factor(factors) + @ccall tblis.tci_next_prime_factor(factors::Ptr{tci_prime_factors})::Cuint +end + +function tci_partition_2x2(nthread, work1, max1, work2, max2, nt1, nt2) + @ccall tblis.tci_partition_2x2(nthread::Cuint, work1::UInt64, max1::Cuint, + work2::UInt64, max2::Cuint, nt1::Ptr{Cuint}, + nt2::Ptr{Cuint})::Cvoid +end + +const tci_slot = Cint + +function tci_slot_init(slot, empty) + @ccall tblis.tci_slot_init(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_is_filled(slot, empty) + @ccall tblis.tci_slot_is_filled(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_try_fill(slot, empty, value) + @ccall tblis.tci_slot_try_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cint +end + +function tci_slot_fill(slot, empty, value) + @ccall tblis.tci_slot_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cvoid +end + +function tci_slot_clear(slot, empty) + @ccall tblis.tci_slot_clear(slot::Ptr{tci_slot}, empty::Cint)::Cvoid +end + +@enum __JL_Ctag_7::UInt32 begin + TCI_NOT_WORKED_ON = 0 + TCI_IN_PROGRESS = 1 + TCI_RESERVED = 2 + TCI_FINISHED = 3 +end + +const tci_work_item = Cint + +function tci_work_item_try_work(item) + @ccall tblis.tci_work_item_try_work(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_finish(item) + @ccall tblis.tci_work_item_finish(item::Ptr{tci_work_item})::Cvoid +end + +function tci_work_item_status(item) + @ccall tblis.tci_work_item_status(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_wait(item) + @ccall tblis.tci_work_item_wait(item::Ptr{tci_work_item})::Cvoid +end + +mutable struct tblis_config_s end + +const tblis_config = tblis_config_s + +@enum reduce_t::UInt32 begin + REDUCE_SUM = 0 + REDUCE_SUM_ABS = 1 + REDUCE_MAX = 2 + REDUCE_MAX_ABS = 3 + REDUCE_MIN = 4 + REDUCE_MIN_ABS = 5 + # REDUCE_NORM_1 = 1 + REDUCE_NORM_2 = 6 + # REDUCE_NORM_INF = 3 +end + +@enum type_t::UInt32 begin + TYPE_SINGLE = 0 + # TYPE_FLOAT = 0 + TYPE_DOUBLE = 1 + TYPE_SCOMPLEX = 2 + TYPE_DCOMPLEX = 3 +end + +const len_type = Cptrdiff_t + +const stride_type = Cptrdiff_t + +const label_type = Cchar + +mutable struct fake_scomplex + real::Cfloat + imag::Cfloat + fake_scomplex() = new() +end + +mutable struct fake_dcomplex + real::Cdouble + imag::Cdouble + fake_dcomplex() = new() +end + +struct scalar + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{scalar}, f::Symbol) + f === :s && return Ptr{Cfloat}(x + 0) + f === :d && return Ptr{Cdouble}(x + 0) + f === :c && return Ptr{scomplex}(x + 0) + f === :z && return Ptr{dcomplex}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::scalar, f::Symbol) + r = Ref{scalar}(x) + ptr = Base.unsafe_convert(Ptr{scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tblis_scalar + data::NTuple{20,UInt8} +end + +function Base.getproperty(x::Ptr{tblis_scalar}, f::Symbol) + f === :data && return Ptr{scalar}(x + 0) + f === :type && return Ptr{type_t}(x + 16) + return getfield(x, f) +end + +function Base.getproperty(x::tblis_scalar, f::Symbol) + r = Ref{tblis_scalar}(x) + ptr = Base.unsafe_convert(Ptr{tblis_scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tblis_scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tblis_init_scalar_s(s, value) + @ccall tblis.tblis_init_scalar_s(s::Ptr{tblis_scalar}, value::Cfloat)::Cvoid +end + +function tblis_init_scalar_d(s, value) + @ccall tblis.tblis_init_scalar_d(s::Ptr{tblis_scalar}, value::Cdouble)::Cvoid +end + +function tblis_init_scalar_c(s, value) + @ccall tblis.tblis_init_scalar_c(s::Ptr{tblis_scalar}, value::scomplex)::Cvoid +end + +function tblis_init_scalar_z(s, value) + @ccall tblis.tblis_init_scalar_z(s::Ptr{tblis_scalar}, value::dcomplex)::Cvoid +end + +mutable struct tblis_vector + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + n::len_type + inc::stride_type + tblis_vector() = new() +end + +function tblis_init_vector_scaled_s(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_s(v::Ptr{tblis_vector}, scalar_::Cfloat, + n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_d(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_d(v::Ptr{tblis_vector}, scalar_::Cdouble, + n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_c(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_c(v::Ptr{tblis_vector}, scalar_::scomplex, + n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_z(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_z(v::Ptr{tblis_vector}, scalar_::dcomplex, + n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_s(v, n, data, inc) + @ccall tblis.tblis_init_vector_s(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_d(v, n, data, inc) + @ccall tblis.tblis_init_vector_d(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_c(v, n, data, inc) + @ccall tblis.tblis_init_vector_c(v::Ptr{tblis_vector}, n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_z(v, n, data, inc) + @ccall tblis.tblis_init_vector_z(v::Ptr{tblis_vector}, n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +mutable struct tblis_matrix + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + m::len_type + n::len_type + rs::stride_type + cs::stride_type + tblis_matrix() = new() +end + +function tblis_init_matrix_scaled_s(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_s(mat::Ptr{tblis_matrix}, scalar_::Cfloat, + m::len_type, n::len_type, data::Ptr{Cfloat}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_d(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_d(mat::Ptr{tblis_matrix}, scalar_::Cdouble, + m::len_type, n::len_type, data::Ptr{Cdouble}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_c(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_c(mat::Ptr{tblis_matrix}, scalar_::scomplex, + m::len_type, n::len_type, data::Ptr{scomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_z(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_z(mat::Ptr{tblis_matrix}, scalar_::dcomplex, + m::len_type, n::len_type, data::Ptr{dcomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_s(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_s(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cfloat}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_d(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_d(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cdouble}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_c(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_c(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{scomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_z(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_z(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{dcomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +struct tblis_tensor + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + ndim::Cuint + len::Ptr{len_type} + stride::Ptr{stride_type} +end + +function tblis_init_tensor_scaled_s(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_s(t::Ptr{tblis_tensor}, scalar_::Cfloat, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_d(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_d(t::Ptr{tblis_tensor}, scalar_::Cdouble, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_c(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_c(t::Ptr{tblis_tensor}, scalar_::scomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_z(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_z(t::Ptr{tblis_tensor}, scalar_::dcomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_s(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_s(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_d(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_d(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_c(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_c(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_z(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_z(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_get_config(name) + @ccall tblis.tblis_get_config(name::Ptr{Cchar})::Ptr{tblis_config} +end + +const tblis_comm = tci_comm + +# no prototype is found for this function at thread.h:21:10, please use with caution +function tblis_get_num_threads() + @ccall tblis.tblis_get_num_threads()::Cuint +end + +function tblis_set_num_threads(num_threads) + @ccall tblis.tblis_set_num_threads(num_threads::Cuint)::Cvoid +end + +function tblis_vector_add(comm, cfg, A, B) + @ccall tblis.tblis_vector_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_vector_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_vector_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_vector_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_vector}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_vector_scale(comm, cfg, A) + @ccall tblis.tblis_vector_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_set(comm, cfg, alpha, A) + @ccall tblis.tblis_vector_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_vector})::Cvoid +end + +function tblis_matrix_add(comm, cfg, A, B) + @ccall tblis.tblis_matrix_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_matrix_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_matrix_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_matrix_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_matrix_scale(comm, cfg, A) + @ccall tblis.tblis_matrix_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_set(comm, cfg, alpha, A) + @ccall tblis.tblis_matrix_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_add(comm, cfg, A, idx_A, B, idx_B) + @ccall tblis.tblis_tensor_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type})::Cvoid +end + +function tblis_tensor_dot(comm, cfg, A, idx_A, B, idx_B, result) + @ccall tblis.tblis_tensor_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_tensor_reduce(comm, cfg, op, A, idx_A, result, idx) + @ccall tblis.tblis_tensor_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type}, result::Ptr{tblis_scalar}, + idx::Ptr{len_type})::Cvoid +end + +function tblis_tensor_scale(comm, cfg, A, idx_A) + @ccall tblis.tblis_tensor_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type})::Cvoid +end + +function tblis_tensor_set(comm, cfg, alpha, A, idx_A) + @ccall tblis.tblis_tensor_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type})::Cvoid +end + +function tblis_matrix_mult(comm, cfg, A, B, C) + @ccall tblis.tblis_matrix_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_mult_diag(comm, cfg, A, D, B, C) + @ccall tblis.tblis_matrix_mult_diag(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, D::Ptr{tblis_vector}, + B::Ptr{tblis_matrix}, C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_mult(comm, cfg, A, idx_A, B, idx_B, C, idx_C) + @ccall tblis.tblis_tensor_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + C::Ptr{tblis_tensor}, idx_C::Ptr{label_type})::Cvoid +end + +const TCI_USE_ATOMIC_SPINLOCK = 1 + +const TCI_USE_OMP_LOCK = 0 + +const TCI_USE_OPENMP_THREADS = 1 + +const TCI_USE_WINDOWS_THREADS = 0 + +const TCI_USE_TBB_THREADS = 0 + +const TCI_USE_PPL_THREADS = 0 + +const TCI_USE_OMPTASK_THREADS = 0 + +const TCI_USE_DISPATCH_THREADS = 0 + +const TCI_USE_OSX_SPINLOCK = 0 + +const TCI_USE_PTHREADS_THREADS = 0 + +const TCI_USE_PTHREAD_BARRIER = 0 + +const TCI_USE_PTHREAD_MUTEX = 0 + +const TCI_USE_PTHREAD_SPINLOCK = 0 + +const TCI_USE_SPIN_BARRIER = 1 + +const TCI_ARCH_X86 = 1 + +# Skipping MacroDefinition: TCI_INLINE static inline + +const TBLIS_HAVE_SYSCONF = 1 + +const TBLIS_HAVE_SYSCTL = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_CONF = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_ONLN = 1 + +const TBLIS_LABEL_TYPE = Cchar + +const TBLIS_LEN_TYPE = ptrdiff_t + +const TBLIS_LT_OBJDIR = ".libs/" + +const TBLIS_PACKAGE = "tblis" + +const TBLIS_PACKAGE_BUGREPORT = "dmatthews@utexas.edu" + +const TBLIS_PACKAGE_NAME = "tblis" + +const TBLIS_PACKAGE_STRING = "tblis 1.2.0" + +const TBLIS_PACKAGE_TARNAME = "tblis" + +const TBLIS_PACKAGE_URL = "http://www.github.com/devinamatthews/tblis" + +const TBLIS_PACKAGE_VERSION = "1.2.0" + +# Skipping MacroDefinition: _tblis_restrict __restrict + +const TBLIS_STDC_HEADERS = 1 + +const TBLIS_STRIDE_TYPE = ptrdiff_t + +const TBLIS_TOPDIR = "/workspace/srcdir/tblis" + +const TBLIS_VERSION = "1.2.0" diff --git a/src/lib/i686-w64-mingw32.jl b/src/lib/i686-w64-mingw32.jl new file mode 100644 index 0000000..d6a6adc --- /dev/null +++ b/src/lib/i686-w64-mingw32.jl @@ -0,0 +1,779 @@ +# no prototype is found for this function at yield.h:19:17, please use with caution +function tci_yield() + @ccall tblis.tci_yield()::Cvoid +end + +const tci_mutex = Cchar + +function tci_mutex_init(mutex) + @ccall tblis.tci_mutex_init(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_destroy(mutex) + @ccall tblis.tci_mutex_destroy(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_lock(mutex) + @ccall tblis.tci_mutex_lock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutexrylock(mutex) + @ccall tblis.tci_mutexrylock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_unlock(mutex) + @ccall tblis.tci_mutex_unlock(mutex::Ptr{tci_mutex})::Cint +end + +struct tci_barrier_node + parent::Ptr{tci_barrier_node} + nchildren::Cuint + step::Cuint + nwaiting::Cuint +end + +function tci_barrier_node_init(barrier, parent, nchildren) + @ccall tblis.tci_barrier_node_init(barrier::Ptr{tci_barrier_node}, + parent::Ptr{tci_barrier_node}, + nchildren::Cuint)::Cint +end + +function tci_barrier_node_destroy(barrier) + @ccall tblis.tci_barrier_node_destroy(barrier::Ptr{tci_barrier_node})::Cint +end + +function tci_barrier_node_wait(barrier) + @ccall tblis.tci_barrier_node_wait(barrier::Ptr{tci_barrier_node})::Cint +end + +struct __JL_Ctag_25 + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{__JL_Ctag_25}, f::Symbol) + f === :array && return Ptr{Ptr{tci_barrier_node}}(x + 0) + f === :single && return Ptr{tci_barrier_node}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::__JL_Ctag_25, f::Symbol) + r = Ref{__JL_Ctag_25}(x) + ptr = Base.unsafe_convert(Ptr{__JL_Ctag_25}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{__JL_Ctag_25}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tci_barrier + data::NTuple{28,UInt8} +end + +function Base.getproperty(x::Ptr{tci_barrier}, f::Symbol) + f === :barrier && return Ptr{__JL_Ctag_25}(x + 0) + f === :nthread && return Ptr{Cuint}(x + 16) + f === :group_size && return Ptr{Cuint}(x + 20) + f === :is_tree && return Ptr{Cint}(x + 24) + return getfield(x, f) +end + +function Base.getproperty(x::tci_barrier, f::Symbol) + r = Ref{tci_barrier}(x) + ptr = Base.unsafe_convert(Ptr{tci_barrier}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tci_barrier}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tci_barrier_is_tree(barrier) + @ccall tblis.tci_barrier_is_tree(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_init(barrier, nthread, group_size) + @ccall tblis.tci_barrier_init(barrier::Ptr{tci_barrier}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_barrier_destroy(barrier) + @ccall tblis.tci_barrier_destroy(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_wait(barrier, tid) + @ccall tblis.tci_barrier_wait(barrier::Ptr{tci_barrier}, tid::Cuint)::Cint +end + +struct tci_context + barrier::tci_barrier + buffer::Ptr{Cvoid} + refcount::Cuint +end + +function tci_context_init(context, nthread, group_size) + @ccall tblis.tci_context_init(context::Ptr{Ptr{tci_context}}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_context_attach(context) + @ccall tblis.tci_context_attach(context::Ptr{tci_context})::Cint +end + +function tci_context_detach(context) + @ccall tblis.tci_context_detach(context::Ptr{tci_context})::Cint +end + +function tci_context_barrier(context, tid) + @ccall tblis.tci_context_barrier(context::Ptr{tci_context}, tid::Cuint)::Cint +end + +function tci_context_send(context, tid, object) + @ccall tblis.tci_context_send(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_send_nowait(context, tid, object) + @ccall tblis.tci_context_send_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_receive(context, tid, object) + @ccall tblis.tci_context_receive(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +function tci_context_receive_nowait(context, tid, object) + @ccall tblis.tci_context_receive_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +struct tci_comm + context::Ptr{tci_context} + ngang::Cuint + gid::Cuint + nthread::Cuint + tid::Cuint +end + +@enum __JL_Ctag_10::UInt32 begin + TCI_EVENLY = 2 + TCI_CYCLIC = 4 + TCI_BLOCK_CYCLIC = 6 + TCI_BLOCKED = 8 + TCI_NO_CONTEXT = 1 +end + +mutable struct tci_range + size::UInt64 + grain::UInt64 + tci_range() = new() +end + +# typedef void ( * tci_range_func ) ( tci_comm * , uint64_t , uint64_t , void * ) +const tci_range_func = Ptr{Cvoid} + +# typedef void ( * tci_range_2d_func ) ( tci_comm * , uint64_t , uint64_t , uint64_t , uint64_t , void * ) +const tci_range_2d_func = Ptr{Cvoid} + +function tci_comm_init_single(comm) + @ccall tblis.tci_comm_init_single(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_init(comm, context, nthread, tid, ngang, gid) + @ccall tblis.tci_comm_init(comm::Ptr{tci_comm}, context::Ptr{tci_context}, + nthread::Cuint, tid::Cuint, ngang::Cuint, gid::Cuint)::Cint +end + +function tci_comm_destroy(comm) + @ccall tblis.tci_comm_destroy(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_is_master(comm) + @ccall tblis.tci_comm_is_master(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_barrier(comm) + @ccall tblis.tci_comm_barrier(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_bcast(comm, object, root) + @ccall tblis.tci_comm_bcast(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_bcast_nowait(comm, object, root) + @ccall tblis.tci_comm_bcast_nowait(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_gang(parent, child, type, n, bs) + @ccall tblis.tci_comm_gang(parent::Ptr{tci_comm}, child::Ptr{tci_comm}, type::Cint, + n::Cuint, bs::Cuint)::Cint +end + +function tci_comm_distribute_over_gangs(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_threads(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_gangs_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs_2d(comm::Ptr{tci_comm}, range_m::tci_range, + range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_threads_2d(comm::Ptr{tci_comm}, + range_m::tci_range, range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +# typedef void ( * tci_thread_func ) ( tci_comm * , void * ) +const tci_thread_func = Ptr{Cvoid} + +function tci_parallelize(func, payload, nthread, arity) + @ccall tblis.tci_parallelize(func::tci_thread_func, payload::Ptr{Cvoid}, nthread::Cuint, + arity::Cuint)::Cint +end + +struct tci_prime_factors + n::Cuint + sqrt_n::Cuint + f::Cuint +end + +function tci_prime_factorization(n, factors) + @ccall tblis.tci_prime_factorization(n::Cuint, factors::Ptr{tci_prime_factors})::Cvoid +end + +function tci_next_prime_factor(factors) + @ccall tblis.tci_next_prime_factor(factors::Ptr{tci_prime_factors})::Cuint +end + +function tci_partition_2x2(nthread, work1, max1, work2, max2, nt1, nt2) + @ccall tblis.tci_partition_2x2(nthread::Cuint, work1::UInt64, max1::Cuint, + work2::UInt64, max2::Cuint, nt1::Ptr{Cuint}, + nt2::Ptr{Cuint})::Cvoid +end + +const tci_slot = Cint + +function tci_slot_init(slot, empty) + @ccall tblis.tci_slot_init(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_is_filled(slot, empty) + @ccall tblis.tci_slot_is_filled(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_try_fill(slot, empty, value) + @ccall tblis.tci_slot_try_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cint +end + +function tci_slot_fill(slot, empty, value) + @ccall tblis.tci_slot_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cvoid +end + +function tci_slot_clear(slot, empty) + @ccall tblis.tci_slot_clear(slot::Ptr{tci_slot}, empty::Cint)::Cvoid +end + +@enum __JL_Ctag_11::UInt32 begin + TCI_NOT_WORKED_ON = 0 + TCI_IN_PROGRESS = 1 + TCI_RESERVED = 2 + TCI_FINISHED = 3 +end + +const tci_work_item = Cint + +function tci_work_item_try_work(item) + @ccall tblis.tci_work_item_try_work(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_finish(item) + @ccall tblis.tci_work_item_finish(item::Ptr{tci_work_item})::Cvoid +end + +function tci_work_item_status(item) + @ccall tblis.tci_work_item_status(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_wait(item) + @ccall tblis.tci_work_item_wait(item::Ptr{tci_work_item})::Cvoid +end + +mutable struct tblis_config_s end + +const tblis_config = tblis_config_s + +@enum reduce_t::UInt32 begin + REDUCE_SUM = 0 + REDUCE_SUM_ABS = 1 + REDUCE_MAX = 2 + REDUCE_MAX_ABS = 3 + REDUCE_MIN = 4 + REDUCE_MIN_ABS = 5 + # REDUCE_NORM_1 = 1 + REDUCE_NORM_2 = 6 + # REDUCE_NORM_INF = 3 +end + +@enum type_t::UInt32 begin + TYPE_SINGLE = 0 + # TYPE_FLOAT = 0 + TYPE_DOUBLE = 1 + TYPE_SCOMPLEX = 2 + TYPE_DCOMPLEX = 3 +end + +const len_type = Cptrdiff_t + +const stride_type = Cptrdiff_t + +const label_type = Cchar + +mutable struct fake_scomplex + real::Cfloat + imag::Cfloat + fake_scomplex() = new() +end + +mutable struct fake_dcomplex + real::Cdouble + imag::Cdouble + fake_dcomplex() = new() +end + +struct scalar + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{scalar}, f::Symbol) + f === :s && return Ptr{Cfloat}(x + 0) + f === :d && return Ptr{Cdouble}(x + 0) + f === :c && return Ptr{scomplex}(x + 0) + f === :z && return Ptr{dcomplex}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::scalar, f::Symbol) + r = Ref{scalar}(x) + ptr = Base.unsafe_convert(Ptr{scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tblis_scalar + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{tblis_scalar}, f::Symbol) + f === :data && return Ptr{scalar}(x + 0) + f === :type && return Ptr{type_t}(x + 16) + return getfield(x, f) +end + +function Base.getproperty(x::tblis_scalar, f::Symbol) + r = Ref{tblis_scalar}(x) + ptr = Base.unsafe_convert(Ptr{tblis_scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tblis_scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tblis_init_scalar_s(s, value) + @ccall tblis.tblis_init_scalar_s(s::Ptr{tblis_scalar}, value::Cfloat)::Cvoid +end + +function tblis_init_scalar_d(s, value) + @ccall tblis.tblis_init_scalar_d(s::Ptr{tblis_scalar}, value::Cdouble)::Cvoid +end + +function tblis_init_scalar_c(s, value) + @ccall tblis.tblis_init_scalar_c(s::Ptr{tblis_scalar}, value::scomplex)::Cvoid +end + +function tblis_init_scalar_z(s, value) + @ccall tblis.tblis_init_scalar_z(s::Ptr{tblis_scalar}, value::dcomplex)::Cvoid +end + +mutable struct tblis_vector + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + n::len_type + inc::stride_type + tblis_vector() = new() +end + +function tblis_init_vector_scaled_s(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_s(v::Ptr{tblis_vector}, scalar_::Cfloat, + n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_d(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_d(v::Ptr{tblis_vector}, scalar_::Cdouble, + n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_c(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_c(v::Ptr{tblis_vector}, scalar_::scomplex, + n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_z(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_z(v::Ptr{tblis_vector}, scalar_::dcomplex, + n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_s(v, n, data, inc) + @ccall tblis.tblis_init_vector_s(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_d(v, n, data, inc) + @ccall tblis.tblis_init_vector_d(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_c(v, n, data, inc) + @ccall tblis.tblis_init_vector_c(v::Ptr{tblis_vector}, n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_z(v, n, data, inc) + @ccall tblis.tblis_init_vector_z(v::Ptr{tblis_vector}, n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +mutable struct tblis_matrix + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + m::len_type + n::len_type + rs::stride_type + cs::stride_type + tblis_matrix() = new() +end + +function tblis_init_matrix_scaled_s(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_s(mat::Ptr{tblis_matrix}, scalar_::Cfloat, + m::len_type, n::len_type, data::Ptr{Cfloat}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_d(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_d(mat::Ptr{tblis_matrix}, scalar_::Cdouble, + m::len_type, n::len_type, data::Ptr{Cdouble}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_c(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_c(mat::Ptr{tblis_matrix}, scalar_::scomplex, + m::len_type, n::len_type, data::Ptr{scomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_z(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_z(mat::Ptr{tblis_matrix}, scalar_::dcomplex, + m::len_type, n::len_type, data::Ptr{dcomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_s(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_s(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cfloat}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_d(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_d(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cdouble}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_c(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_c(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{scomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_z(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_z(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{dcomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +struct tblis_tensor + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + ndim::Cuint + len::Ptr{len_type} + stride::Ptr{stride_type} +end + +function tblis_init_tensor_scaled_s(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_s(t::Ptr{tblis_tensor}, scalar_::Cfloat, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_d(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_d(t::Ptr{tblis_tensor}, scalar_::Cdouble, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_c(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_c(t::Ptr{tblis_tensor}, scalar_::scomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_z(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_z(t::Ptr{tblis_tensor}, scalar_::dcomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_s(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_s(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_d(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_d(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_c(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_c(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_z(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_z(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_get_config(name) + @ccall tblis.tblis_get_config(name::Ptr{Cchar})::Ptr{tblis_config} +end + +const tblis_comm = tci_comm + +# no prototype is found for this function at thread.h:21:10, please use with caution +function tblis_get_num_threads() + @ccall tblis.tblis_get_num_threads()::Cuint +end + +function tblis_set_num_threads(num_threads) + @ccall tblis.tblis_set_num_threads(num_threads::Cuint)::Cvoid +end + +function tblis_vector_add(comm, cfg, A, B) + @ccall tblis.tblis_vector_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_vector_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_vector_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_vector_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_vector}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_vector_scale(comm, cfg, A) + @ccall tblis.tblis_vector_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_set(comm, cfg, alpha, A) + @ccall tblis.tblis_vector_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_vector})::Cvoid +end + +function tblis_matrix_add(comm, cfg, A, B) + @ccall tblis.tblis_matrix_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_matrix_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_matrix_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_matrix_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_matrix_scale(comm, cfg, A) + @ccall tblis.tblis_matrix_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_set(comm, cfg, alpha, A) + @ccall tblis.tblis_matrix_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_add(comm, cfg, A, idx_A, B, idx_B) + @ccall tblis.tblis_tensor_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type})::Cvoid +end + +function tblis_tensor_dot(comm, cfg, A, idx_A, B, idx_B, result) + @ccall tblis.tblis_tensor_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_tensor_reduce(comm, cfg, op, A, idx_A, result, idx) + @ccall tblis.tblis_tensor_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type}, result::Ptr{tblis_scalar}, + idx::Ptr{len_type})::Cvoid +end + +function tblis_tensor_scale(comm, cfg, A, idx_A) + @ccall tblis.tblis_tensor_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type})::Cvoid +end + +function tblis_tensor_set(comm, cfg, alpha, A, idx_A) + @ccall tblis.tblis_tensor_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type})::Cvoid +end + +function tblis_matrix_mult(comm, cfg, A, B, C) + @ccall tblis.tblis_matrix_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_mult_diag(comm, cfg, A, D, B, C) + @ccall tblis.tblis_matrix_mult_diag(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, D::Ptr{tblis_vector}, + B::Ptr{tblis_matrix}, C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_mult(comm, cfg, A, idx_A, B, idx_B, C, idx_C) + @ccall tblis.tblis_tensor_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + C::Ptr{tblis_tensor}, idx_C::Ptr{label_type})::Cvoid +end + +const TCI_USE_ATOMIC_SPINLOCK = 1 + +const TCI_USE_OMP_LOCK = 0 + +const TCI_USE_OPENMP_THREADS = 1 + +const TCI_USE_WINDOWS_THREADS = 0 + +const TCI_USE_TBB_THREADS = 0 + +const TCI_USE_PPL_THREADS = 0 + +const TCI_USE_OMPTASK_THREADS = 0 + +const TCI_USE_DISPATCH_THREADS = 0 + +const TCI_USE_OSX_SPINLOCK = 0 + +const TCI_USE_PTHREADS_THREADS = 0 + +const TCI_USE_PTHREAD_BARRIER = 0 + +const TCI_USE_PTHREAD_MUTEX = 0 + +const TCI_USE_PTHREAD_SPINLOCK = 0 + +const TCI_USE_SPIN_BARRIER = 1 + +const TCI_ARCH_X86 = 1 + +# Skipping MacroDefinition: TCI_INLINE static inline + +const TBLIS_HAVE_SYSCONF = 1 + +const TBLIS_HAVE_SYSCTL = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_CONF = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_ONLN = 1 + +const TBLIS_LABEL_TYPE = Cchar + +const TBLIS_LEN_TYPE = ptrdiff_t + +const TBLIS_LT_OBJDIR = ".libs/" + +const TBLIS_PACKAGE = "tblis" + +const TBLIS_PACKAGE_BUGREPORT = "dmatthews@utexas.edu" + +const TBLIS_PACKAGE_NAME = "tblis" + +const TBLIS_PACKAGE_STRING = "tblis 1.2.0" + +const TBLIS_PACKAGE_TARNAME = "tblis" + +const TBLIS_PACKAGE_URL = "http://www.github.com/devinamatthews/tblis" + +const TBLIS_PACKAGE_VERSION = "1.2.0" + +# Skipping MacroDefinition: _tblis_restrict __restrict + +const TBLIS_STDC_HEADERS = 1 + +const TBLIS_STRIDE_TYPE = ptrdiff_t + +const TBLIS_TOPDIR = "/workspace/srcdir/tblis" + +const TBLIS_VERSION = "1.2.0" diff --git a/src/lib/powerpc64le-linux-gnu.jl b/src/lib/powerpc64le-linux-gnu.jl new file mode 100644 index 0000000..78c3f27 --- /dev/null +++ b/src/lib/powerpc64le-linux-gnu.jl @@ -0,0 +1,779 @@ +# no prototype is found for this function at yield.h:27:17, please use with caution +function tci_yield() + @ccall tblis.tci_yield()::Cvoid +end + +const tci_mutex = Cchar + +function tci_mutex_init(mutex) + @ccall tblis.tci_mutex_init(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_destroy(mutex) + @ccall tblis.tci_mutex_destroy(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_lock(mutex) + @ccall tblis.tci_mutex_lock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutexrylock(mutex) + @ccall tblis.tci_mutexrylock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_unlock(mutex) + @ccall tblis.tci_mutex_unlock(mutex::Ptr{tci_mutex})::Cint +end + +struct tci_barrier_node + parent::Ptr{tci_barrier_node} + nchildren::Cuint + step::Cuint + nwaiting::Cuint +end + +function tci_barrier_node_init(barrier, parent, nchildren) + @ccall tblis.tci_barrier_node_init(barrier::Ptr{tci_barrier_node}, + parent::Ptr{tci_barrier_node}, + nchildren::Cuint)::Cint +end + +function tci_barrier_node_destroy(barrier) + @ccall tblis.tci_barrier_node_destroy(barrier::Ptr{tci_barrier_node})::Cint +end + +function tci_barrier_node_wait(barrier) + @ccall tblis.tci_barrier_node_wait(barrier::Ptr{tci_barrier_node})::Cint +end + +struct __JL_Ctag_33 + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{__JL_Ctag_33}, f::Symbol) + f === :array && return Ptr{Ptr{tci_barrier_node}}(x + 0) + f === :single && return Ptr{tci_barrier_node}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::__JL_Ctag_33, f::Symbol) + r = Ref{__JL_Ctag_33}(x) + ptr = Base.unsafe_convert(Ptr{__JL_Ctag_33}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{__JL_Ctag_33}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tci_barrier + data::NTuple{40,UInt8} +end + +function Base.getproperty(x::Ptr{tci_barrier}, f::Symbol) + f === :barrier && return Ptr{__JL_Ctag_33}(x + 0) + f === :nthread && return Ptr{Cuint}(x + 24) + f === :group_size && return Ptr{Cuint}(x + 28) + f === :is_tree && return Ptr{Cint}(x + 32) + return getfield(x, f) +end + +function Base.getproperty(x::tci_barrier, f::Symbol) + r = Ref{tci_barrier}(x) + ptr = Base.unsafe_convert(Ptr{tci_barrier}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tci_barrier}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tci_barrier_is_tree(barrier) + @ccall tblis.tci_barrier_is_tree(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_init(barrier, nthread, group_size) + @ccall tblis.tci_barrier_init(barrier::Ptr{tci_barrier}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_barrier_destroy(barrier) + @ccall tblis.tci_barrier_destroy(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_wait(barrier, tid) + @ccall tblis.tci_barrier_wait(barrier::Ptr{tci_barrier}, tid::Cuint)::Cint +end + +struct tci_context + barrier::tci_barrier + buffer::Ptr{Cvoid} + refcount::Cuint +end + +function tci_context_init(context, nthread, group_size) + @ccall tblis.tci_context_init(context::Ptr{Ptr{tci_context}}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_context_attach(context) + @ccall tblis.tci_context_attach(context::Ptr{tci_context})::Cint +end + +function tci_context_detach(context) + @ccall tblis.tci_context_detach(context::Ptr{tci_context})::Cint +end + +function tci_context_barrier(context, tid) + @ccall tblis.tci_context_barrier(context::Ptr{tci_context}, tid::Cuint)::Cint +end + +function tci_context_send(context, tid, object) + @ccall tblis.tci_context_send(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_send_nowait(context, tid, object) + @ccall tblis.tci_context_send_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_receive(context, tid, object) + @ccall tblis.tci_context_receive(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +function tci_context_receive_nowait(context, tid, object) + @ccall tblis.tci_context_receive_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +struct tci_comm + context::Ptr{tci_context} + ngang::Cuint + gid::Cuint + nthread::Cuint + tid::Cuint +end + +@enum __JL_Ctag_3::UInt32 begin + TCI_EVENLY = 2 + TCI_CYCLIC = 4 + TCI_BLOCK_CYCLIC = 6 + TCI_BLOCKED = 8 + TCI_NO_CONTEXT = 1 +end + +mutable struct tci_range + size::UInt64 + grain::UInt64 + tci_range() = new() +end + +# typedef void ( * tci_range_func ) ( tci_comm * , uint64_t , uint64_t , void * ) +const tci_range_func = Ptr{Cvoid} + +# typedef void ( * tci_range_2d_func ) ( tci_comm * , uint64_t , uint64_t , uint64_t , uint64_t , void * ) +const tci_range_2d_func = Ptr{Cvoid} + +function tci_comm_init_single(comm) + @ccall tblis.tci_comm_init_single(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_init(comm, context, nthread, tid, ngang, gid) + @ccall tblis.tci_comm_init(comm::Ptr{tci_comm}, context::Ptr{tci_context}, + nthread::Cuint, tid::Cuint, ngang::Cuint, gid::Cuint)::Cint +end + +function tci_comm_destroy(comm) + @ccall tblis.tci_comm_destroy(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_is_master(comm) + @ccall tblis.tci_comm_is_master(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_barrier(comm) + @ccall tblis.tci_comm_barrier(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_bcast(comm, object, root) + @ccall tblis.tci_comm_bcast(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_bcast_nowait(comm, object, root) + @ccall tblis.tci_comm_bcast_nowait(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_gang(parent, child, type, n, bs) + @ccall tblis.tci_comm_gang(parent::Ptr{tci_comm}, child::Ptr{tci_comm}, type::Cint, + n::Cuint, bs::Cuint)::Cint +end + +function tci_comm_distribute_over_gangs(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_threads(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_gangs_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs_2d(comm::Ptr{tci_comm}, range_m::tci_range, + range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_threads_2d(comm::Ptr{tci_comm}, + range_m::tci_range, range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +# typedef void ( * tci_thread_func ) ( tci_comm * , void * ) +const tci_thread_func = Ptr{Cvoid} + +function tci_parallelize(func, payload, nthread, arity) + @ccall tblis.tci_parallelize(func::tci_thread_func, payload::Ptr{Cvoid}, nthread::Cuint, + arity::Cuint)::Cint +end + +struct tci_prime_factors + n::Cuint + sqrt_n::Cuint + f::Cuint +end + +function tci_prime_factorization(n, factors) + @ccall tblis.tci_prime_factorization(n::Cuint, factors::Ptr{tci_prime_factors})::Cvoid +end + +function tci_next_prime_factor(factors) + @ccall tblis.tci_next_prime_factor(factors::Ptr{tci_prime_factors})::Cuint +end + +function tci_partition_2x2(nthread, work1, max1, work2, max2, nt1, nt2) + @ccall tblis.tci_partition_2x2(nthread::Cuint, work1::UInt64, max1::Cuint, + work2::UInt64, max2::Cuint, nt1::Ptr{Cuint}, + nt2::Ptr{Cuint})::Cvoid +end + +const tci_slot = Cint + +function tci_slot_init(slot, empty) + @ccall tblis.tci_slot_init(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_is_filled(slot, empty) + @ccall tblis.tci_slot_is_filled(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_try_fill(slot, empty, value) + @ccall tblis.tci_slot_try_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cint +end + +function tci_slot_fill(slot, empty, value) + @ccall tblis.tci_slot_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cvoid +end + +function tci_slot_clear(slot, empty) + @ccall tblis.tci_slot_clear(slot::Ptr{tci_slot}, empty::Cint)::Cvoid +end + +@enum __JL_Ctag_4::UInt32 begin + TCI_NOT_WORKED_ON = 0 + TCI_IN_PROGRESS = 1 + TCI_RESERVED = 2 + TCI_FINISHED = 3 +end + +const tci_work_item = Cint + +function tci_work_item_try_work(item) + @ccall tblis.tci_work_item_try_work(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_finish(item) + @ccall tblis.tci_work_item_finish(item::Ptr{tci_work_item})::Cvoid +end + +function tci_work_item_status(item) + @ccall tblis.tci_work_item_status(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_wait(item) + @ccall tblis.tci_work_item_wait(item::Ptr{tci_work_item})::Cvoid +end + +mutable struct tblis_config_s end + +const tblis_config = tblis_config_s + +@enum reduce_t::UInt32 begin + REDUCE_SUM = 0 + REDUCE_SUM_ABS = 1 + REDUCE_MAX = 2 + REDUCE_MAX_ABS = 3 + REDUCE_MIN = 4 + REDUCE_MIN_ABS = 5 + # REDUCE_NORM_1 = 1 + REDUCE_NORM_2 = 6 + # REDUCE_NORM_INF = 3 +end + +@enum type_t::UInt32 begin + TYPE_SINGLE = 0 + # TYPE_FLOAT = 0 + TYPE_DOUBLE = 1 + TYPE_SCOMPLEX = 2 + TYPE_DCOMPLEX = 3 +end + +const len_type = Cptrdiff_t + +const stride_type = Cptrdiff_t + +const label_type = Cchar + +mutable struct fake_scomplex + real::Cfloat + imag::Cfloat + fake_scomplex() = new() +end + +mutable struct fake_dcomplex + real::Cdouble + imag::Cdouble + fake_dcomplex() = new() +end + +struct scalar + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{scalar}, f::Symbol) + f === :s && return Ptr{Cfloat}(x + 0) + f === :d && return Ptr{Cdouble}(x + 0) + f === :c && return Ptr{scomplex}(x + 0) + f === :z && return Ptr{dcomplex}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::scalar, f::Symbol) + r = Ref{scalar}(x) + ptr = Base.unsafe_convert(Ptr{scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tblis_scalar + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{tblis_scalar}, f::Symbol) + f === :data && return Ptr{scalar}(x + 0) + f === :type && return Ptr{type_t}(x + 16) + return getfield(x, f) +end + +function Base.getproperty(x::tblis_scalar, f::Symbol) + r = Ref{tblis_scalar}(x) + ptr = Base.unsafe_convert(Ptr{tblis_scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tblis_scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tblis_init_scalar_s(s, value) + @ccall tblis.tblis_init_scalar_s(s::Ptr{tblis_scalar}, value::Cfloat)::Cvoid +end + +function tblis_init_scalar_d(s, value) + @ccall tblis.tblis_init_scalar_d(s::Ptr{tblis_scalar}, value::Cdouble)::Cvoid +end + +function tblis_init_scalar_c(s, value) + @ccall tblis.tblis_init_scalar_c(s::Ptr{tblis_scalar}, value::scomplex)::Cvoid +end + +function tblis_init_scalar_z(s, value) + @ccall tblis.tblis_init_scalar_z(s::Ptr{tblis_scalar}, value::dcomplex)::Cvoid +end + +mutable struct tblis_vector + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + n::len_type + inc::stride_type + tblis_vector() = new() +end + +function tblis_init_vector_scaled_s(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_s(v::Ptr{tblis_vector}, scalar_::Cfloat, + n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_d(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_d(v::Ptr{tblis_vector}, scalar_::Cdouble, + n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_c(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_c(v::Ptr{tblis_vector}, scalar_::scomplex, + n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_z(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_z(v::Ptr{tblis_vector}, scalar_::dcomplex, + n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_s(v, n, data, inc) + @ccall tblis.tblis_init_vector_s(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_d(v, n, data, inc) + @ccall tblis.tblis_init_vector_d(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_c(v, n, data, inc) + @ccall tblis.tblis_init_vector_c(v::Ptr{tblis_vector}, n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_z(v, n, data, inc) + @ccall tblis.tblis_init_vector_z(v::Ptr{tblis_vector}, n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +mutable struct tblis_matrix + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + m::len_type + n::len_type + rs::stride_type + cs::stride_type + tblis_matrix() = new() +end + +function tblis_init_matrix_scaled_s(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_s(mat::Ptr{tblis_matrix}, scalar_::Cfloat, + m::len_type, n::len_type, data::Ptr{Cfloat}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_d(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_d(mat::Ptr{tblis_matrix}, scalar_::Cdouble, + m::len_type, n::len_type, data::Ptr{Cdouble}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_c(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_c(mat::Ptr{tblis_matrix}, scalar_::scomplex, + m::len_type, n::len_type, data::Ptr{scomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_z(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_z(mat::Ptr{tblis_matrix}, scalar_::dcomplex, + m::len_type, n::len_type, data::Ptr{dcomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_s(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_s(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cfloat}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_d(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_d(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cdouble}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_c(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_c(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{scomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_z(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_z(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{dcomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +struct tblis_tensor + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + ndim::Cuint + len::Ptr{len_type} + stride::Ptr{stride_type} +end + +function tblis_init_tensor_scaled_s(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_s(t::Ptr{tblis_tensor}, scalar_::Cfloat, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_d(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_d(t::Ptr{tblis_tensor}, scalar_::Cdouble, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_c(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_c(t::Ptr{tblis_tensor}, scalar_::scomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_z(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_z(t::Ptr{tblis_tensor}, scalar_::dcomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_s(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_s(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_d(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_d(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_c(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_c(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_z(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_z(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_get_config(name) + @ccall tblis.tblis_get_config(name::Ptr{Cchar})::Ptr{tblis_config} +end + +const tblis_comm = tci_comm + +# no prototype is found for this function at thread.h:21:10, please use with caution +function tblis_get_num_threads() + @ccall tblis.tblis_get_num_threads()::Cuint +end + +function tblis_set_num_threads(num_threads) + @ccall tblis.tblis_set_num_threads(num_threads::Cuint)::Cvoid +end + +function tblis_vector_add(comm, cfg, A, B) + @ccall tblis.tblis_vector_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_vector_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_vector_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_vector_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_vector}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_vector_scale(comm, cfg, A) + @ccall tblis.tblis_vector_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_set(comm, cfg, alpha, A) + @ccall tblis.tblis_vector_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_vector})::Cvoid +end + +function tblis_matrix_add(comm, cfg, A, B) + @ccall tblis.tblis_matrix_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_matrix_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_matrix_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_matrix_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_matrix_scale(comm, cfg, A) + @ccall tblis.tblis_matrix_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_set(comm, cfg, alpha, A) + @ccall tblis.tblis_matrix_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_add(comm, cfg, A, idx_A, B, idx_B) + @ccall tblis.tblis_tensor_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type})::Cvoid +end + +function tblis_tensor_dot(comm, cfg, A, idx_A, B, idx_B, result) + @ccall tblis.tblis_tensor_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_tensor_reduce(comm, cfg, op, A, idx_A, result, idx) + @ccall tblis.tblis_tensor_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type}, result::Ptr{tblis_scalar}, + idx::Ptr{len_type})::Cvoid +end + +function tblis_tensor_scale(comm, cfg, A, idx_A) + @ccall tblis.tblis_tensor_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type})::Cvoid +end + +function tblis_tensor_set(comm, cfg, alpha, A, idx_A) + @ccall tblis.tblis_tensor_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type})::Cvoid +end + +function tblis_matrix_mult(comm, cfg, A, B, C) + @ccall tblis.tblis_matrix_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_mult_diag(comm, cfg, A, D, B, C) + @ccall tblis.tblis_matrix_mult_diag(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, D::Ptr{tblis_vector}, + B::Ptr{tblis_matrix}, C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_mult(comm, cfg, A, idx_A, B, idx_B, C, idx_C) + @ccall tblis.tblis_tensor_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + C::Ptr{tblis_tensor}, idx_C::Ptr{label_type})::Cvoid +end + +const TCI_USE_ATOMIC_SPINLOCK = 1 + +const TCI_USE_OMP_LOCK = 0 + +const TCI_USE_OPENMP_THREADS = 1 + +const TCI_USE_WINDOWS_THREADS = 0 + +const TCI_USE_TBB_THREADS = 0 + +const TCI_USE_PPL_THREADS = 0 + +const TCI_USE_OMPTASK_THREADS = 0 + +const TCI_USE_DISPATCH_THREADS = 0 + +const TCI_USE_OSX_SPINLOCK = 0 + +const TCI_USE_PTHREADS_THREADS = 0 + +const TCI_USE_PTHREAD_BARRIER = 0 + +const TCI_USE_PTHREAD_MUTEX = 0 + +const TCI_USE_PTHREAD_SPINLOCK = 0 + +const TCI_USE_SPIN_BARRIER = 1 + +const TCI_ARCH_PPC64 = 1 + +# Skipping MacroDefinition: TCI_INLINE static inline + +const TBLIS_HAVE_SYSCONF = 1 + +const TBLIS_HAVE_SYSCTL = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_CONF = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_ONLN = 1 + +const TBLIS_LABEL_TYPE = Cchar + +const TBLIS_LEN_TYPE = ptrdiff_t + +const TBLIS_LT_OBJDIR = ".libs/" + +const TBLIS_PACKAGE = "tblis" + +const TBLIS_PACKAGE_BUGREPORT = "dmatthews@utexas.edu" + +const TBLIS_PACKAGE_NAME = "tblis" + +const TBLIS_PACKAGE_STRING = "tblis 1.2.0" + +const TBLIS_PACKAGE_TARNAME = "tblis" + +const TBLIS_PACKAGE_URL = "http://www.github.com/devinamatthews/tblis" + +const TBLIS_PACKAGE_VERSION = "1.2.0" + +# Skipping MacroDefinition: _tblis_restrict __restrict + +const TBLIS_STDC_HEADERS = 1 + +const TBLIS_STRIDE_TYPE = ptrdiff_t + +const TBLIS_TOPDIR = "/workspace/srcdir/tblis" + +const TBLIS_VERSION = "1.2.0" diff --git a/src/lib/x86_64-apple-darwin14.jl b/src/lib/x86_64-apple-darwin14.jl new file mode 100644 index 0000000..ff95f62 --- /dev/null +++ b/src/lib/x86_64-apple-darwin14.jl @@ -0,0 +1,779 @@ +# no prototype is found for this function at yield.h:19:17, please use with caution +function tci_yield() + @ccall tblis.tci_yield()::Cvoid +end + +const tci_mutex = Cchar + +function tci_mutex_init(mutex) + @ccall tblis.tci_mutex_init(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_destroy(mutex) + @ccall tblis.tci_mutex_destroy(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_lock(mutex) + @ccall tblis.tci_mutex_lock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutexrylock(mutex) + @ccall tblis.tci_mutexrylock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_unlock(mutex) + @ccall tblis.tci_mutex_unlock(mutex::Ptr{tci_mutex})::Cint +end + +struct tci_barrier_node + parent::Ptr{tci_barrier_node} + nchildren::Cuint + step::Cuint + nwaiting::Cuint +end + +function tci_barrier_node_init(barrier, parent, nchildren) + @ccall tblis.tci_barrier_node_init(barrier::Ptr{tci_barrier_node}, + parent::Ptr{tci_barrier_node}, + nchildren::Cuint)::Cint +end + +function tci_barrier_node_destroy(barrier) + @ccall tblis.tci_barrier_node_destroy(barrier::Ptr{tci_barrier_node})::Cint +end + +function tci_barrier_node_wait(barrier) + @ccall tblis.tci_barrier_node_wait(barrier::Ptr{tci_barrier_node})::Cint +end + +struct __JL_Ctag_22 + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{__JL_Ctag_22}, f::Symbol) + f === :array && return Ptr{Ptr{tci_barrier_node}}(x + 0) + f === :single && return Ptr{tci_barrier_node}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::__JL_Ctag_22, f::Symbol) + r = Ref{__JL_Ctag_22}(x) + ptr = Base.unsafe_convert(Ptr{__JL_Ctag_22}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{__JL_Ctag_22}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tci_barrier + data::NTuple{40,UInt8} +end + +function Base.getproperty(x::Ptr{tci_barrier}, f::Symbol) + f === :barrier && return Ptr{__JL_Ctag_22}(x + 0) + f === :nthread && return Ptr{Cuint}(x + 24) + f === :group_size && return Ptr{Cuint}(x + 28) + f === :is_tree && return Ptr{Cint}(x + 32) + return getfield(x, f) +end + +function Base.getproperty(x::tci_barrier, f::Symbol) + r = Ref{tci_barrier}(x) + ptr = Base.unsafe_convert(Ptr{tci_barrier}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tci_barrier}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tci_barrier_is_tree(barrier) + @ccall tblis.tci_barrier_is_tree(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_init(barrier, nthread, group_size) + @ccall tblis.tci_barrier_init(barrier::Ptr{tci_barrier}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_barrier_destroy(barrier) + @ccall tblis.tci_barrier_destroy(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_wait(barrier, tid) + @ccall tblis.tci_barrier_wait(barrier::Ptr{tci_barrier}, tid::Cuint)::Cint +end + +struct tci_context + barrier::tci_barrier + buffer::Ptr{Cvoid} + refcount::Cuint +end + +function tci_context_init(context, nthread, group_size) + @ccall tblis.tci_context_init(context::Ptr{Ptr{tci_context}}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_context_attach(context) + @ccall tblis.tci_context_attach(context::Ptr{tci_context})::Cint +end + +function tci_context_detach(context) + @ccall tblis.tci_context_detach(context::Ptr{tci_context})::Cint +end + +function tci_context_barrier(context, tid) + @ccall tblis.tci_context_barrier(context::Ptr{tci_context}, tid::Cuint)::Cint +end + +function tci_context_send(context, tid, object) + @ccall tblis.tci_context_send(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_send_nowait(context, tid, object) + @ccall tblis.tci_context_send_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_receive(context, tid, object) + @ccall tblis.tci_context_receive(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +function tci_context_receive_nowait(context, tid, object) + @ccall tblis.tci_context_receive_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +struct tci_comm + context::Ptr{tci_context} + ngang::Cuint + gid::Cuint + nthread::Cuint + tid::Cuint +end + +@enum __JL_Ctag_8::UInt32 begin + TCI_EVENLY = 2 + TCI_CYCLIC = 4 + TCI_BLOCK_CYCLIC = 6 + TCI_BLOCKED = 8 + TCI_NO_CONTEXT = 1 +end + +mutable struct tci_range + size::UInt64 + grain::UInt64 + tci_range() = new() +end + +# typedef void ( * tci_range_func ) ( tci_comm * , uint64_t , uint64_t , void * ) +const tci_range_func = Ptr{Cvoid} + +# typedef void ( * tci_range_2d_func ) ( tci_comm * , uint64_t , uint64_t , uint64_t , uint64_t , void * ) +const tci_range_2d_func = Ptr{Cvoid} + +function tci_comm_init_single(comm) + @ccall tblis.tci_comm_init_single(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_init(comm, context, nthread, tid, ngang, gid) + @ccall tblis.tci_comm_init(comm::Ptr{tci_comm}, context::Ptr{tci_context}, + nthread::Cuint, tid::Cuint, ngang::Cuint, gid::Cuint)::Cint +end + +function tci_comm_destroy(comm) + @ccall tblis.tci_comm_destroy(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_is_master(comm) + @ccall tblis.tci_comm_is_master(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_barrier(comm) + @ccall tblis.tci_comm_barrier(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_bcast(comm, object, root) + @ccall tblis.tci_comm_bcast(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_bcast_nowait(comm, object, root) + @ccall tblis.tci_comm_bcast_nowait(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_gang(parent, child, type, n, bs) + @ccall tblis.tci_comm_gang(parent::Ptr{tci_comm}, child::Ptr{tci_comm}, type::Cint, + n::Cuint, bs::Cuint)::Cint +end + +function tci_comm_distribute_over_gangs(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_threads(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_gangs_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs_2d(comm::Ptr{tci_comm}, range_m::tci_range, + range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_threads_2d(comm::Ptr{tci_comm}, + range_m::tci_range, range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +# typedef void ( * tci_thread_func ) ( tci_comm * , void * ) +const tci_thread_func = Ptr{Cvoid} + +function tci_parallelize(func, payload, nthread, arity) + @ccall tblis.tci_parallelize(func::tci_thread_func, payload::Ptr{Cvoid}, nthread::Cuint, + arity::Cuint)::Cint +end + +struct tci_prime_factors + n::Cuint + sqrt_n::Cuint + f::Cuint +end + +function tci_prime_factorization(n, factors) + @ccall tblis.tci_prime_factorization(n::Cuint, factors::Ptr{tci_prime_factors})::Cvoid +end + +function tci_next_prime_factor(factors) + @ccall tblis.tci_next_prime_factor(factors::Ptr{tci_prime_factors})::Cuint +end + +function tci_partition_2x2(nthread, work1, max1, work2, max2, nt1, nt2) + @ccall tblis.tci_partition_2x2(nthread::Cuint, work1::UInt64, max1::Cuint, + work2::UInt64, max2::Cuint, nt1::Ptr{Cuint}, + nt2::Ptr{Cuint})::Cvoid +end + +const tci_slot = Cint + +function tci_slot_init(slot, empty) + @ccall tblis.tci_slot_init(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_is_filled(slot, empty) + @ccall tblis.tci_slot_is_filled(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_try_fill(slot, empty, value) + @ccall tblis.tci_slot_try_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cint +end + +function tci_slot_fill(slot, empty, value) + @ccall tblis.tci_slot_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cvoid +end + +function tci_slot_clear(slot, empty) + @ccall tblis.tci_slot_clear(slot::Ptr{tci_slot}, empty::Cint)::Cvoid +end + +@enum __JL_Ctag_9::UInt32 begin + TCI_NOT_WORKED_ON = 0 + TCI_IN_PROGRESS = 1 + TCI_RESERVED = 2 + TCI_FINISHED = 3 +end + +const tci_work_item = Cint + +function tci_work_item_try_work(item) + @ccall tblis.tci_work_item_try_work(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_finish(item) + @ccall tblis.tci_work_item_finish(item::Ptr{tci_work_item})::Cvoid +end + +function tci_work_item_status(item) + @ccall tblis.tci_work_item_status(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_wait(item) + @ccall tblis.tci_work_item_wait(item::Ptr{tci_work_item})::Cvoid +end + +mutable struct tblis_config_s end + +const tblis_config = tblis_config_s + +@enum reduce_t::UInt32 begin + REDUCE_SUM = 0 + REDUCE_SUM_ABS = 1 + REDUCE_MAX = 2 + REDUCE_MAX_ABS = 3 + REDUCE_MIN = 4 + REDUCE_MIN_ABS = 5 + # REDUCE_NORM_1 = 1 + REDUCE_NORM_2 = 6 + # REDUCE_NORM_INF = 3 +end + +@enum type_t::UInt32 begin + TYPE_SINGLE = 0 + # TYPE_FLOAT = 0 + TYPE_DOUBLE = 1 + TYPE_SCOMPLEX = 2 + TYPE_DCOMPLEX = 3 +end + +const len_type = Cptrdiff_t + +const stride_type = Cptrdiff_t + +const label_type = Cchar + +mutable struct fake_scomplex + real::Cfloat + imag::Cfloat + fake_scomplex() = new() +end + +mutable struct fake_dcomplex + real::Cdouble + imag::Cdouble + fake_dcomplex() = new() +end + +struct scalar + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{scalar}, f::Symbol) + f === :s && return Ptr{Cfloat}(x + 0) + f === :d && return Ptr{Cdouble}(x + 0) + f === :c && return Ptr{scomplex}(x + 0) + f === :z && return Ptr{dcomplex}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::scalar, f::Symbol) + r = Ref{scalar}(x) + ptr = Base.unsafe_convert(Ptr{scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tblis_scalar + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{tblis_scalar}, f::Symbol) + f === :data && return Ptr{scalar}(x + 0) + f === :type && return Ptr{type_t}(x + 16) + return getfield(x, f) +end + +function Base.getproperty(x::tblis_scalar, f::Symbol) + r = Ref{tblis_scalar}(x) + ptr = Base.unsafe_convert(Ptr{tblis_scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tblis_scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tblis_init_scalar_s(s, value) + @ccall tblis.tblis_init_scalar_s(s::Ptr{tblis_scalar}, value::Cfloat)::Cvoid +end + +function tblis_init_scalar_d(s, value) + @ccall tblis.tblis_init_scalar_d(s::Ptr{tblis_scalar}, value::Cdouble)::Cvoid +end + +function tblis_init_scalar_c(s, value) + @ccall tblis.tblis_init_scalar_c(s::Ptr{tblis_scalar}, value::scomplex)::Cvoid +end + +function tblis_init_scalar_z(s, value) + @ccall tblis.tblis_init_scalar_z(s::Ptr{tblis_scalar}, value::dcomplex)::Cvoid +end + +mutable struct tblis_vector + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + n::len_type + inc::stride_type + tblis_vector() = new() +end + +function tblis_init_vector_scaled_s(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_s(v::Ptr{tblis_vector}, scalar_::Cfloat, + n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_d(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_d(v::Ptr{tblis_vector}, scalar_::Cdouble, + n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_c(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_c(v::Ptr{tblis_vector}, scalar_::scomplex, + n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_z(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_z(v::Ptr{tblis_vector}, scalar_::dcomplex, + n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_s(v, n, data, inc) + @ccall tblis.tblis_init_vector_s(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_d(v, n, data, inc) + @ccall tblis.tblis_init_vector_d(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_c(v, n, data, inc) + @ccall tblis.tblis_init_vector_c(v::Ptr{tblis_vector}, n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_z(v, n, data, inc) + @ccall tblis.tblis_init_vector_z(v::Ptr{tblis_vector}, n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +mutable struct tblis_matrix + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + m::len_type + n::len_type + rs::stride_type + cs::stride_type + tblis_matrix() = new() +end + +function tblis_init_matrix_scaled_s(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_s(mat::Ptr{tblis_matrix}, scalar_::Cfloat, + m::len_type, n::len_type, data::Ptr{Cfloat}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_d(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_d(mat::Ptr{tblis_matrix}, scalar_::Cdouble, + m::len_type, n::len_type, data::Ptr{Cdouble}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_c(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_c(mat::Ptr{tblis_matrix}, scalar_::scomplex, + m::len_type, n::len_type, data::Ptr{scomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_z(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_z(mat::Ptr{tblis_matrix}, scalar_::dcomplex, + m::len_type, n::len_type, data::Ptr{dcomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_s(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_s(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cfloat}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_d(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_d(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cdouble}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_c(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_c(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{scomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_z(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_z(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{dcomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +struct tblis_tensor + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + ndim::Cuint + len::Ptr{len_type} + stride::Ptr{stride_type} +end + +function tblis_init_tensor_scaled_s(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_s(t::Ptr{tblis_tensor}, scalar_::Cfloat, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_d(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_d(t::Ptr{tblis_tensor}, scalar_::Cdouble, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_c(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_c(t::Ptr{tblis_tensor}, scalar_::scomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_z(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_z(t::Ptr{tblis_tensor}, scalar_::dcomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_s(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_s(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_d(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_d(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_c(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_c(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_z(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_z(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_get_config(name) + @ccall tblis.tblis_get_config(name::Ptr{Cchar})::Ptr{tblis_config} +end + +const tblis_comm = tci_comm + +# no prototype is found for this function at thread.h:21:10, please use with caution +function tblis_get_num_threads() + @ccall tblis.tblis_get_num_threads()::Cuint +end + +function tblis_set_num_threads(num_threads) + @ccall tblis.tblis_set_num_threads(num_threads::Cuint)::Cvoid +end + +function tblis_vector_add(comm, cfg, A, B) + @ccall tblis.tblis_vector_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_vector_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_vector_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_vector_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_vector}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_vector_scale(comm, cfg, A) + @ccall tblis.tblis_vector_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_set(comm, cfg, alpha, A) + @ccall tblis.tblis_vector_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_vector})::Cvoid +end + +function tblis_matrix_add(comm, cfg, A, B) + @ccall tblis.tblis_matrix_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_matrix_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_matrix_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_matrix_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_matrix_scale(comm, cfg, A) + @ccall tblis.tblis_matrix_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_set(comm, cfg, alpha, A) + @ccall tblis.tblis_matrix_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_add(comm, cfg, A, idx_A, B, idx_B) + @ccall tblis.tblis_tensor_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type})::Cvoid +end + +function tblis_tensor_dot(comm, cfg, A, idx_A, B, idx_B, result) + @ccall tblis.tblis_tensor_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_tensor_reduce(comm, cfg, op, A, idx_A, result, idx) + @ccall tblis.tblis_tensor_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type}, result::Ptr{tblis_scalar}, + idx::Ptr{len_type})::Cvoid +end + +function tblis_tensor_scale(comm, cfg, A, idx_A) + @ccall tblis.tblis_tensor_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type})::Cvoid +end + +function tblis_tensor_set(comm, cfg, alpha, A, idx_A) + @ccall tblis.tblis_tensor_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type})::Cvoid +end + +function tblis_matrix_mult(comm, cfg, A, B, C) + @ccall tblis.tblis_matrix_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_mult_diag(comm, cfg, A, D, B, C) + @ccall tblis.tblis_matrix_mult_diag(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, D::Ptr{tblis_vector}, + B::Ptr{tblis_matrix}, C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_mult(comm, cfg, A, idx_A, B, idx_B, C, idx_C) + @ccall tblis.tblis_tensor_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + C::Ptr{tblis_tensor}, idx_C::Ptr{label_type})::Cvoid +end + +const TCI_USE_ATOMIC_SPINLOCK = 1 + +const TCI_USE_OMP_LOCK = 0 + +const TCI_USE_OPENMP_THREADS = 1 + +const TCI_USE_WINDOWS_THREADS = 0 + +const TCI_USE_TBB_THREADS = 0 + +const TCI_USE_PPL_THREADS = 0 + +const TCI_USE_OMPTASK_THREADS = 0 + +const TCI_USE_DISPATCH_THREADS = 0 + +const TCI_USE_OSX_SPINLOCK = 0 + +const TCI_USE_PTHREADS_THREADS = 0 + +const TCI_USE_PTHREAD_BARRIER = 0 + +const TCI_USE_PTHREAD_MUTEX = 0 + +const TCI_USE_PTHREAD_SPINLOCK = 0 + +const TCI_USE_SPIN_BARRIER = 1 + +const TCI_ARCH_X64 = 1 + +# Skipping MacroDefinition: TCI_INLINE static inline + +const TBLIS_HAVE_SYSCONF = 1 + +const TBLIS_HAVE_SYSCTL = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_CONF = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_ONLN = 1 + +const TBLIS_LABEL_TYPE = Cchar + +const TBLIS_LEN_TYPE = ptrdiff_t + +const TBLIS_LT_OBJDIR = ".libs/" + +const TBLIS_PACKAGE = "tblis" + +const TBLIS_PACKAGE_BUGREPORT = "dmatthews@utexas.edu" + +const TBLIS_PACKAGE_NAME = "tblis" + +const TBLIS_PACKAGE_STRING = "tblis 1.2.0" + +const TBLIS_PACKAGE_TARNAME = "tblis" + +const TBLIS_PACKAGE_URL = "http://www.github.com/devinamatthews/tblis" + +const TBLIS_PACKAGE_VERSION = "1.2.0" + +# Skipping MacroDefinition: _tblis_restrict __restrict + +const TBLIS_STDC_HEADERS = 1 + +const TBLIS_STRIDE_TYPE = ptrdiff_t + +const TBLIS_TOPDIR = "/workspace/srcdir/tblis" + +const TBLIS_VERSION = "1.2.0" diff --git a/src/lib/x86_64-linux-gnu.jl b/src/lib/x86_64-linux-gnu.jl new file mode 100644 index 0000000..e1f2e05 --- /dev/null +++ b/src/lib/x86_64-linux-gnu.jl @@ -0,0 +1,779 @@ +# no prototype is found for this function at yield.h:19:17, please use with caution +function tci_yield() + @ccall tblis.tci_yield()::Cvoid +end + +const tci_mutex = Cchar + +function tci_mutex_init(mutex) + @ccall tblis.tci_mutex_init(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_destroy(mutex) + @ccall tblis.tci_mutex_destroy(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_lock(mutex) + @ccall tblis.tci_mutex_lock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutexrylock(mutex) + @ccall tblis.tci_mutexrylock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_unlock(mutex) + @ccall tblis.tci_mutex_unlock(mutex::Ptr{tci_mutex})::Cint +end + +struct tci_barrier_node + parent::Ptr{tci_barrier_node} + nchildren::Cuint + step::Cuint + nwaiting::Cuint +end + +function tci_barrier_node_init(barrier, parent, nchildren) + @ccall tblis.tci_barrier_node_init(barrier::Ptr{tci_barrier_node}, + parent::Ptr{tci_barrier_node}, + nchildren::Cuint)::Cint +end + +function tci_barrier_node_destroy(barrier) + @ccall tblis.tci_barrier_node_destroy(barrier::Ptr{tci_barrier_node})::Cint +end + +function tci_barrier_node_wait(barrier) + @ccall tblis.tci_barrier_node_wait(barrier::Ptr{tci_barrier_node})::Cint +end + +struct __JL_Ctag_50 + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{__JL_Ctag_50}, f::Symbol) + f === :array && return Ptr{Ptr{tci_barrier_node}}(x + 0) + f === :single && return Ptr{tci_barrier_node}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::__JL_Ctag_50, f::Symbol) + r = Ref{__JL_Ctag_50}(x) + ptr = Base.unsafe_convert(Ptr{__JL_Ctag_50}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{__JL_Ctag_50}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tci_barrier + data::NTuple{40,UInt8} +end + +function Base.getproperty(x::Ptr{tci_barrier}, f::Symbol) + f === :barrier && return Ptr{__JL_Ctag_50}(x + 0) + f === :nthread && return Ptr{Cuint}(x + 24) + f === :group_size && return Ptr{Cuint}(x + 28) + f === :is_tree && return Ptr{Cint}(x + 32) + return getfield(x, f) +end + +function Base.getproperty(x::tci_barrier, f::Symbol) + r = Ref{tci_barrier}(x) + ptr = Base.unsafe_convert(Ptr{tci_barrier}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tci_barrier}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tci_barrier_is_tree(barrier) + @ccall tblis.tci_barrier_is_tree(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_init(barrier, nthread, group_size) + @ccall tblis.tci_barrier_init(barrier::Ptr{tci_barrier}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_barrier_destroy(barrier) + @ccall tblis.tci_barrier_destroy(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_wait(barrier, tid) + @ccall tblis.tci_barrier_wait(barrier::Ptr{tci_barrier}, tid::Cuint)::Cint +end + +struct tci_context + barrier::tci_barrier + buffer::Ptr{Cvoid} + refcount::Cuint +end + +function tci_context_init(context, nthread, group_size) + @ccall tblis.tci_context_init(context::Ptr{Ptr{tci_context}}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_context_attach(context) + @ccall tblis.tci_context_attach(context::Ptr{tci_context})::Cint +end + +function tci_context_detach(context) + @ccall tblis.tci_context_detach(context::Ptr{tci_context})::Cint +end + +function tci_context_barrier(context, tid) + @ccall tblis.tci_context_barrier(context::Ptr{tci_context}, tid::Cuint)::Cint +end + +function tci_context_send(context, tid, object) + @ccall tblis.tci_context_send(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_send_nowait(context, tid, object) + @ccall tblis.tci_context_send_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_receive(context, tid, object) + @ccall tblis.tci_context_receive(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +function tci_context_receive_nowait(context, tid, object) + @ccall tblis.tci_context_receive_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +struct tci_comm + context::Ptr{tci_context} + ngang::Cuint + gid::Cuint + nthread::Cuint + tid::Cuint +end + +@enum __JL_Ctag_19::UInt32 begin + TCI_EVENLY = 2 + TCI_CYCLIC = 4 + TCI_BLOCK_CYCLIC = 6 + TCI_BLOCKED = 8 + TCI_NO_CONTEXT = 1 +end + +mutable struct tci_range + size::UInt64 + grain::UInt64 + tci_range() = new() +end + +# typedef void ( * tci_range_func ) ( tci_comm * , uint64_t , uint64_t , void * ) +const tci_range_func = Ptr{Cvoid} + +# typedef void ( * tci_range_2d_func ) ( tci_comm * , uint64_t , uint64_t , uint64_t , uint64_t , void * ) +const tci_range_2d_func = Ptr{Cvoid} + +function tci_comm_init_single(comm) + @ccall tblis.tci_comm_init_single(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_init(comm, context, nthread, tid, ngang, gid) + @ccall tblis.tci_comm_init(comm::Ptr{tci_comm}, context::Ptr{tci_context}, + nthread::Cuint, tid::Cuint, ngang::Cuint, gid::Cuint)::Cint +end + +function tci_comm_destroy(comm) + @ccall tblis.tci_comm_destroy(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_is_master(comm) + @ccall tblis.tci_comm_is_master(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_barrier(comm) + @ccall tblis.tci_comm_barrier(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_bcast(comm, object, root) + @ccall tblis.tci_comm_bcast(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_bcast_nowait(comm, object, root) + @ccall tblis.tci_comm_bcast_nowait(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_gang(parent, child, type, n, bs) + @ccall tblis.tci_comm_gang(parent::Ptr{tci_comm}, child::Ptr{tci_comm}, type::Cint, + n::Cuint, bs::Cuint)::Cint +end + +function tci_comm_distribute_over_gangs(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_threads(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_gangs_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs_2d(comm::Ptr{tci_comm}, range_m::tci_range, + range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_threads_2d(comm::Ptr{tci_comm}, + range_m::tci_range, range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +# typedef void ( * tci_thread_func ) ( tci_comm * , void * ) +const tci_thread_func = Ptr{Cvoid} + +function tci_parallelize(func, payload, nthread, arity) + @ccall tblis.tci_parallelize(func::tci_thread_func, payload::Ptr{Cvoid}, nthread::Cuint, + arity::Cuint)::Cint +end + +struct tci_prime_factors + n::Cuint + sqrt_n::Cuint + f::Cuint +end + +function tci_prime_factorization(n, factors) + @ccall tblis.tci_prime_factorization(n::Cuint, factors::Ptr{tci_prime_factors})::Cvoid +end + +function tci_next_prime_factor(factors) + @ccall tblis.tci_next_prime_factor(factors::Ptr{tci_prime_factors})::Cuint +end + +function tci_partition_2x2(nthread, work1, max1, work2, max2, nt1, nt2) + @ccall tblis.tci_partition_2x2(nthread::Cuint, work1::UInt64, max1::Cuint, + work2::UInt64, max2::Cuint, nt1::Ptr{Cuint}, + nt2::Ptr{Cuint})::Cvoid +end + +const tci_slot = Cint + +function tci_slot_init(slot, empty) + @ccall tblis.tci_slot_init(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_is_filled(slot, empty) + @ccall tblis.tci_slot_is_filled(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_try_fill(slot, empty, value) + @ccall tblis.tci_slot_try_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cint +end + +function tci_slot_fill(slot, empty, value) + @ccall tblis.tci_slot_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cvoid +end + +function tci_slot_clear(slot, empty) + @ccall tblis.tci_slot_clear(slot::Ptr{tci_slot}, empty::Cint)::Cvoid +end + +@enum __JL_Ctag_20::UInt32 begin + TCI_NOT_WORKED_ON = 0 + TCI_IN_PROGRESS = 1 + TCI_RESERVED = 2 + TCI_FINISHED = 3 +end + +const tci_work_item = Cint + +function tci_work_item_try_work(item) + @ccall tblis.tci_work_item_try_work(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_finish(item) + @ccall tblis.tci_work_item_finish(item::Ptr{tci_work_item})::Cvoid +end + +function tci_work_item_status(item) + @ccall tblis.tci_work_item_status(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_wait(item) + @ccall tblis.tci_work_item_wait(item::Ptr{tci_work_item})::Cvoid +end + +mutable struct tblis_config_s end + +const tblis_config = tblis_config_s + +@enum reduce_t::UInt32 begin + REDUCE_SUM = 0 + REDUCE_SUM_ABS = 1 + REDUCE_MAX = 2 + REDUCE_MAX_ABS = 3 + REDUCE_MIN = 4 + REDUCE_MIN_ABS = 5 + # REDUCE_NORM_1 = 1 + REDUCE_NORM_2 = 6 + # REDUCE_NORM_INF = 3 +end + +@enum type_t::UInt32 begin + TYPE_SINGLE = 0 + # TYPE_FLOAT = 0 + TYPE_DOUBLE = 1 + TYPE_SCOMPLEX = 2 + TYPE_DCOMPLEX = 3 +end + +const len_type = Cptrdiff_t + +const stride_type = Cptrdiff_t + +const label_type = Cchar + +mutable struct fake_scomplex + real::Cfloat + imag::Cfloat + fake_scomplex() = new() +end + +mutable struct fake_dcomplex + real::Cdouble + imag::Cdouble + fake_dcomplex() = new() +end + +struct scalar + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{scalar}, f::Symbol) + f === :s && return Ptr{Cfloat}(x + 0) + f === :d && return Ptr{Cdouble}(x + 0) + f === :c && return Ptr{scomplex}(x + 0) + f === :z && return Ptr{dcomplex}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::scalar, f::Symbol) + r = Ref{scalar}(x) + ptr = Base.unsafe_convert(Ptr{scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tblis_scalar + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{tblis_scalar}, f::Symbol) + f === :data && return Ptr{scalar}(x + 0) + f === :type && return Ptr{type_t}(x + 16) + return getfield(x, f) +end + +function Base.getproperty(x::tblis_scalar, f::Symbol) + r = Ref{tblis_scalar}(x) + ptr = Base.unsafe_convert(Ptr{tblis_scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tblis_scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tblis_init_scalar_s(s, value) + @ccall tblis.tblis_init_scalar_s(s::Ptr{tblis_scalar}, value::Cfloat)::Cvoid +end + +function tblis_init_scalar_d(s, value) + @ccall tblis.tblis_init_scalar_d(s::Ptr{tblis_scalar}, value::Cdouble)::Cvoid +end + +function tblis_init_scalar_c(s, value) + @ccall tblis.tblis_init_scalar_c(s::Ptr{tblis_scalar}, value::scomplex)::Cvoid +end + +function tblis_init_scalar_z(s, value) + @ccall tblis.tblis_init_scalar_z(s::Ptr{tblis_scalar}, value::dcomplex)::Cvoid +end + +mutable struct tblis_vector + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + n::len_type + inc::stride_type + tblis_vector() = new() +end + +function tblis_init_vector_scaled_s(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_s(v::Ptr{tblis_vector}, scalar_::Cfloat, + n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_d(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_d(v::Ptr{tblis_vector}, scalar_::Cdouble, + n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_c(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_c(v::Ptr{tblis_vector}, scalar_::scomplex, + n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_z(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_z(v::Ptr{tblis_vector}, scalar_::dcomplex, + n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_s(v, n, data, inc) + @ccall tblis.tblis_init_vector_s(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_d(v, n, data, inc) + @ccall tblis.tblis_init_vector_d(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_c(v, n, data, inc) + @ccall tblis.tblis_init_vector_c(v::Ptr{tblis_vector}, n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_z(v, n, data, inc) + @ccall tblis.tblis_init_vector_z(v::Ptr{tblis_vector}, n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +mutable struct tblis_matrix + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + m::len_type + n::len_type + rs::stride_type + cs::stride_type + tblis_matrix() = new() +end + +function tblis_init_matrix_scaled_s(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_s(mat::Ptr{tblis_matrix}, scalar_::Cfloat, + m::len_type, n::len_type, data::Ptr{Cfloat}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_d(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_d(mat::Ptr{tblis_matrix}, scalar_::Cdouble, + m::len_type, n::len_type, data::Ptr{Cdouble}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_c(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_c(mat::Ptr{tblis_matrix}, scalar_::scomplex, + m::len_type, n::len_type, data::Ptr{scomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_z(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_z(mat::Ptr{tblis_matrix}, scalar_::dcomplex, + m::len_type, n::len_type, data::Ptr{dcomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_s(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_s(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cfloat}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_d(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_d(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cdouble}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_c(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_c(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{scomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_z(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_z(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{dcomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +struct tblis_tensor + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + ndim::Cuint + len::Ptr{len_type} + stride::Ptr{stride_type} +end + +function tblis_init_tensor_scaled_s(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_s(t::Ptr{tblis_tensor}, scalar_::Cfloat, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_d(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_d(t::Ptr{tblis_tensor}, scalar_::Cdouble, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_c(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_c(t::Ptr{tblis_tensor}, scalar_::scomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_z(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_z(t::Ptr{tblis_tensor}, scalar_::dcomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_s(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_s(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_d(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_d(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_c(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_c(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_z(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_z(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_get_config(name) + @ccall tblis.tblis_get_config(name::Ptr{Cchar})::Ptr{tblis_config} +end + +const tblis_comm = tci_comm + +# no prototype is found for this function at thread.h:21:10, please use with caution +function tblis_get_num_threads() + @ccall tblis.tblis_get_num_threads()::Cuint +end + +function tblis_set_num_threads(num_threads) + @ccall tblis.tblis_set_num_threads(num_threads::Cuint)::Cvoid +end + +function tblis_vector_add(comm, cfg, A, B) + @ccall tblis.tblis_vector_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_vector_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_vector_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_vector_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_vector}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_vector_scale(comm, cfg, A) + @ccall tblis.tblis_vector_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_set(comm, cfg, alpha, A) + @ccall tblis.tblis_vector_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_vector})::Cvoid +end + +function tblis_matrix_add(comm, cfg, A, B) + @ccall tblis.tblis_matrix_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_matrix_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_matrix_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_matrix_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_matrix_scale(comm, cfg, A) + @ccall tblis.tblis_matrix_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_set(comm, cfg, alpha, A) + @ccall tblis.tblis_matrix_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_add(comm, cfg, A, idx_A, B, idx_B) + @ccall tblis.tblis_tensor_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type})::Cvoid +end + +function tblis_tensor_dot(comm, cfg, A, idx_A, B, idx_B, result) + @ccall tblis.tblis_tensor_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_tensor_reduce(comm, cfg, op, A, idx_A, result, idx) + @ccall tblis.tblis_tensor_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type}, result::Ptr{tblis_scalar}, + idx::Ptr{len_type})::Cvoid +end + +function tblis_tensor_scale(comm, cfg, A, idx_A) + @ccall tblis.tblis_tensor_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type})::Cvoid +end + +function tblis_tensor_set(comm, cfg, alpha, A, idx_A) + @ccall tblis.tblis_tensor_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type})::Cvoid +end + +function tblis_matrix_mult(comm, cfg, A, B, C) + @ccall tblis.tblis_matrix_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_mult_diag(comm, cfg, A, D, B, C) + @ccall tblis.tblis_matrix_mult_diag(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, D::Ptr{tblis_vector}, + B::Ptr{tblis_matrix}, C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_mult(comm, cfg, A, idx_A, B, idx_B, C, idx_C) + @ccall tblis.tblis_tensor_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + C::Ptr{tblis_tensor}, idx_C::Ptr{label_type})::Cvoid +end + +const TCI_USE_ATOMIC_SPINLOCK = 1 + +const TCI_USE_OMP_LOCK = 0 + +const TCI_USE_OPENMP_THREADS = 1 + +const TCI_USE_WINDOWS_THREADS = 0 + +const TCI_USE_TBB_THREADS = 0 + +const TCI_USE_PPL_THREADS = 0 + +const TCI_USE_OMPTASK_THREADS = 0 + +const TCI_USE_DISPATCH_THREADS = 0 + +const TCI_USE_OSX_SPINLOCK = 0 + +const TCI_USE_PTHREADS_THREADS = 0 + +const TCI_USE_PTHREAD_BARRIER = 0 + +const TCI_USE_PTHREAD_MUTEX = 0 + +const TCI_USE_PTHREAD_SPINLOCK = 0 + +const TCI_USE_SPIN_BARRIER = 1 + +const TCI_ARCH_X64 = 1 + +# Skipping MacroDefinition: TCI_INLINE static inline + +const TBLIS_HAVE_SYSCONF = 1 + +const TBLIS_HAVE_SYSCTL = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_CONF = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_ONLN = 1 + +const TBLIS_LABEL_TYPE = Cchar + +const TBLIS_LEN_TYPE = ptrdiff_t + +const TBLIS_LT_OBJDIR = ".libs/" + +const TBLIS_PACKAGE = "tblis" + +const TBLIS_PACKAGE_BUGREPORT = "dmatthews@utexas.edu" + +const TBLIS_PACKAGE_NAME = "tblis" + +const TBLIS_PACKAGE_STRING = "tblis 1.2.0" + +const TBLIS_PACKAGE_TARNAME = "tblis" + +const TBLIS_PACKAGE_URL = "http://www.github.com/devinamatthews/tblis" + +const TBLIS_PACKAGE_VERSION = "1.2.0" + +# Skipping MacroDefinition: _tblis_restrict __restrict + +const TBLIS_STDC_HEADERS = 1 + +const TBLIS_STRIDE_TYPE = ptrdiff_t + +const TBLIS_TOPDIR = "/workspace/srcdir/tblis" + +const TBLIS_VERSION = "1.2.0" diff --git a/src/lib/x86_64-linux-musl.jl b/src/lib/x86_64-linux-musl.jl new file mode 100644 index 0000000..c0300a5 --- /dev/null +++ b/src/lib/x86_64-linux-musl.jl @@ -0,0 +1,779 @@ +# no prototype is found for this function at yield.h:19:17, please use with caution +function tci_yield() + @ccall tblis.tci_yield()::Cvoid +end + +const tci_mutex = Cchar + +function tci_mutex_init(mutex) + @ccall tblis.tci_mutex_init(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_destroy(mutex) + @ccall tblis.tci_mutex_destroy(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_lock(mutex) + @ccall tblis.tci_mutex_lock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutexrylock(mutex) + @ccall tblis.tci_mutexrylock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_unlock(mutex) + @ccall tblis.tci_mutex_unlock(mutex::Ptr{tci_mutex})::Cint +end + +struct tci_barrier_node + parent::Ptr{tci_barrier_node} + nchildren::Cuint + step::Cuint + nwaiting::Cuint +end + +function tci_barrier_node_init(barrier, parent, nchildren) + @ccall tblis.tci_barrier_node_init(barrier::Ptr{tci_barrier_node}, + parent::Ptr{tci_barrier_node}, + nchildren::Cuint)::Cint +end + +function tci_barrier_node_destroy(barrier) + @ccall tblis.tci_barrier_node_destroy(barrier::Ptr{tci_barrier_node})::Cint +end + +function tci_barrier_node_wait(barrier) + @ccall tblis.tci_barrier_node_wait(barrier::Ptr{tci_barrier_node})::Cint +end + +struct __JL_Ctag_28 + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{__JL_Ctag_28}, f::Symbol) + f === :array && return Ptr{Ptr{tci_barrier_node}}(x + 0) + f === :single && return Ptr{tci_barrier_node}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::__JL_Ctag_28, f::Symbol) + r = Ref{__JL_Ctag_28}(x) + ptr = Base.unsafe_convert(Ptr{__JL_Ctag_28}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{__JL_Ctag_28}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tci_barrier + data::NTuple{40,UInt8} +end + +function Base.getproperty(x::Ptr{tci_barrier}, f::Symbol) + f === :barrier && return Ptr{__JL_Ctag_28}(x + 0) + f === :nthread && return Ptr{Cuint}(x + 24) + f === :group_size && return Ptr{Cuint}(x + 28) + f === :is_tree && return Ptr{Cint}(x + 32) + return getfield(x, f) +end + +function Base.getproperty(x::tci_barrier, f::Symbol) + r = Ref{tci_barrier}(x) + ptr = Base.unsafe_convert(Ptr{tci_barrier}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tci_barrier}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tci_barrier_is_tree(barrier) + @ccall tblis.tci_barrier_is_tree(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_init(barrier, nthread, group_size) + @ccall tblis.tci_barrier_init(barrier::Ptr{tci_barrier}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_barrier_destroy(barrier) + @ccall tblis.tci_barrier_destroy(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_wait(barrier, tid) + @ccall tblis.tci_barrier_wait(barrier::Ptr{tci_barrier}, tid::Cuint)::Cint +end + +struct tci_context + barrier::tci_barrier + buffer::Ptr{Cvoid} + refcount::Cuint +end + +function tci_context_init(context, nthread, group_size) + @ccall tblis.tci_context_init(context::Ptr{Ptr{tci_context}}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_context_attach(context) + @ccall tblis.tci_context_attach(context::Ptr{tci_context})::Cint +end + +function tci_context_detach(context) + @ccall tblis.tci_context_detach(context::Ptr{tci_context})::Cint +end + +function tci_context_barrier(context, tid) + @ccall tblis.tci_context_barrier(context::Ptr{tci_context}, tid::Cuint)::Cint +end + +function tci_context_send(context, tid, object) + @ccall tblis.tci_context_send(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_send_nowait(context, tid, object) + @ccall tblis.tci_context_send_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_receive(context, tid, object) + @ccall tblis.tci_context_receive(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +function tci_context_receive_nowait(context, tid, object) + @ccall tblis.tci_context_receive_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +struct tci_comm + context::Ptr{tci_context} + ngang::Cuint + gid::Cuint + nthread::Cuint + tid::Cuint +end + +@enum __JL_Ctag_6::UInt32 begin + TCI_EVENLY = 2 + TCI_CYCLIC = 4 + TCI_BLOCK_CYCLIC = 6 + TCI_BLOCKED = 8 + TCI_NO_CONTEXT = 1 +end + +mutable struct tci_range + size::UInt64 + grain::UInt64 + tci_range() = new() +end + +# typedef void ( * tci_range_func ) ( tci_comm * , uint64_t , uint64_t , void * ) +const tci_range_func = Ptr{Cvoid} + +# typedef void ( * tci_range_2d_func ) ( tci_comm * , uint64_t , uint64_t , uint64_t , uint64_t , void * ) +const tci_range_2d_func = Ptr{Cvoid} + +function tci_comm_init_single(comm) + @ccall tblis.tci_comm_init_single(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_init(comm, context, nthread, tid, ngang, gid) + @ccall tblis.tci_comm_init(comm::Ptr{tci_comm}, context::Ptr{tci_context}, + nthread::Cuint, tid::Cuint, ngang::Cuint, gid::Cuint)::Cint +end + +function tci_comm_destroy(comm) + @ccall tblis.tci_comm_destroy(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_is_master(comm) + @ccall tblis.tci_comm_is_master(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_barrier(comm) + @ccall tblis.tci_comm_barrier(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_bcast(comm, object, root) + @ccall tblis.tci_comm_bcast(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_bcast_nowait(comm, object, root) + @ccall tblis.tci_comm_bcast_nowait(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_gang(parent, child, type, n, bs) + @ccall tblis.tci_comm_gang(parent::Ptr{tci_comm}, child::Ptr{tci_comm}, type::Cint, + n::Cuint, bs::Cuint)::Cint +end + +function tci_comm_distribute_over_gangs(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_threads(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_gangs_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs_2d(comm::Ptr{tci_comm}, range_m::tci_range, + range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_threads_2d(comm::Ptr{tci_comm}, + range_m::tci_range, range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +# typedef void ( * tci_thread_func ) ( tci_comm * , void * ) +const tci_thread_func = Ptr{Cvoid} + +function tci_parallelize(func, payload, nthread, arity) + @ccall tblis.tci_parallelize(func::tci_thread_func, payload::Ptr{Cvoid}, nthread::Cuint, + arity::Cuint)::Cint +end + +struct tci_prime_factors + n::Cuint + sqrt_n::Cuint + f::Cuint +end + +function tci_prime_factorization(n, factors) + @ccall tblis.tci_prime_factorization(n::Cuint, factors::Ptr{tci_prime_factors})::Cvoid +end + +function tci_next_prime_factor(factors) + @ccall tblis.tci_next_prime_factor(factors::Ptr{tci_prime_factors})::Cuint +end + +function tci_partition_2x2(nthread, work1, max1, work2, max2, nt1, nt2) + @ccall tblis.tci_partition_2x2(nthread::Cuint, work1::UInt64, max1::Cuint, + work2::UInt64, max2::Cuint, nt1::Ptr{Cuint}, + nt2::Ptr{Cuint})::Cvoid +end + +const tci_slot = Cint + +function tci_slot_init(slot, empty) + @ccall tblis.tci_slot_init(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_is_filled(slot, empty) + @ccall tblis.tci_slot_is_filled(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_try_fill(slot, empty, value) + @ccall tblis.tci_slot_try_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cint +end + +function tci_slot_fill(slot, empty, value) + @ccall tblis.tci_slot_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cvoid +end + +function tci_slot_clear(slot, empty) + @ccall tblis.tci_slot_clear(slot::Ptr{tci_slot}, empty::Cint)::Cvoid +end + +@enum __JL_Ctag_7::UInt32 begin + TCI_NOT_WORKED_ON = 0 + TCI_IN_PROGRESS = 1 + TCI_RESERVED = 2 + TCI_FINISHED = 3 +end + +const tci_work_item = Cint + +function tci_work_item_try_work(item) + @ccall tblis.tci_work_item_try_work(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_finish(item) + @ccall tblis.tci_work_item_finish(item::Ptr{tci_work_item})::Cvoid +end + +function tci_work_item_status(item) + @ccall tblis.tci_work_item_status(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_wait(item) + @ccall tblis.tci_work_item_wait(item::Ptr{tci_work_item})::Cvoid +end + +mutable struct tblis_config_s end + +const tblis_config = tblis_config_s + +@enum reduce_t::UInt32 begin + REDUCE_SUM = 0 + REDUCE_SUM_ABS = 1 + REDUCE_MAX = 2 + REDUCE_MAX_ABS = 3 + REDUCE_MIN = 4 + REDUCE_MIN_ABS = 5 + # REDUCE_NORM_1 = 1 + REDUCE_NORM_2 = 6 + # REDUCE_NORM_INF = 3 +end + +@enum type_t::UInt32 begin + TYPE_SINGLE = 0 + # TYPE_FLOAT = 0 + TYPE_DOUBLE = 1 + TYPE_SCOMPLEX = 2 + TYPE_DCOMPLEX = 3 +end + +const len_type = Cptrdiff_t + +const stride_type = Cptrdiff_t + +const label_type = Cchar + +mutable struct fake_scomplex + real::Cfloat + imag::Cfloat + fake_scomplex() = new() +end + +mutable struct fake_dcomplex + real::Cdouble + imag::Cdouble + fake_dcomplex() = new() +end + +struct scalar + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{scalar}, f::Symbol) + f === :s && return Ptr{Cfloat}(x + 0) + f === :d && return Ptr{Cdouble}(x + 0) + f === :c && return Ptr{scomplex}(x + 0) + f === :z && return Ptr{dcomplex}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::scalar, f::Symbol) + r = Ref{scalar}(x) + ptr = Base.unsafe_convert(Ptr{scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tblis_scalar + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{tblis_scalar}, f::Symbol) + f === :data && return Ptr{scalar}(x + 0) + f === :type && return Ptr{type_t}(x + 16) + return getfield(x, f) +end + +function Base.getproperty(x::tblis_scalar, f::Symbol) + r = Ref{tblis_scalar}(x) + ptr = Base.unsafe_convert(Ptr{tblis_scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tblis_scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tblis_init_scalar_s(s, value) + @ccall tblis.tblis_init_scalar_s(s::Ptr{tblis_scalar}, value::Cfloat)::Cvoid +end + +function tblis_init_scalar_d(s, value) + @ccall tblis.tblis_init_scalar_d(s::Ptr{tblis_scalar}, value::Cdouble)::Cvoid +end + +function tblis_init_scalar_c(s, value) + @ccall tblis.tblis_init_scalar_c(s::Ptr{tblis_scalar}, value::scomplex)::Cvoid +end + +function tblis_init_scalar_z(s, value) + @ccall tblis.tblis_init_scalar_z(s::Ptr{tblis_scalar}, value::dcomplex)::Cvoid +end + +mutable struct tblis_vector + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + n::len_type + inc::stride_type + tblis_vector() = new() +end + +function tblis_init_vector_scaled_s(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_s(v::Ptr{tblis_vector}, scalar_::Cfloat, + n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_d(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_d(v::Ptr{tblis_vector}, scalar_::Cdouble, + n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_c(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_c(v::Ptr{tblis_vector}, scalar_::scomplex, + n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_z(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_z(v::Ptr{tblis_vector}, scalar_::dcomplex, + n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_s(v, n, data, inc) + @ccall tblis.tblis_init_vector_s(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_d(v, n, data, inc) + @ccall tblis.tblis_init_vector_d(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_c(v, n, data, inc) + @ccall tblis.tblis_init_vector_c(v::Ptr{tblis_vector}, n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_z(v, n, data, inc) + @ccall tblis.tblis_init_vector_z(v::Ptr{tblis_vector}, n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +mutable struct tblis_matrix + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + m::len_type + n::len_type + rs::stride_type + cs::stride_type + tblis_matrix() = new() +end + +function tblis_init_matrix_scaled_s(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_s(mat::Ptr{tblis_matrix}, scalar_::Cfloat, + m::len_type, n::len_type, data::Ptr{Cfloat}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_d(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_d(mat::Ptr{tblis_matrix}, scalar_::Cdouble, + m::len_type, n::len_type, data::Ptr{Cdouble}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_c(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_c(mat::Ptr{tblis_matrix}, scalar_::scomplex, + m::len_type, n::len_type, data::Ptr{scomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_z(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_z(mat::Ptr{tblis_matrix}, scalar_::dcomplex, + m::len_type, n::len_type, data::Ptr{dcomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_s(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_s(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cfloat}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_d(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_d(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cdouble}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_c(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_c(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{scomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_z(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_z(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{dcomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +struct tblis_tensor + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + ndim::Cuint + len::Ptr{len_type} + stride::Ptr{stride_type} +end + +function tblis_init_tensor_scaled_s(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_s(t::Ptr{tblis_tensor}, scalar_::Cfloat, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_d(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_d(t::Ptr{tblis_tensor}, scalar_::Cdouble, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_c(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_c(t::Ptr{tblis_tensor}, scalar_::scomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_z(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_z(t::Ptr{tblis_tensor}, scalar_::dcomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_s(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_s(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_d(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_d(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_c(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_c(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_z(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_z(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_get_config(name) + @ccall tblis.tblis_get_config(name::Ptr{Cchar})::Ptr{tblis_config} +end + +const tblis_comm = tci_comm + +# no prototype is found for this function at thread.h:21:10, please use with caution +function tblis_get_num_threads() + @ccall tblis.tblis_get_num_threads()::Cuint +end + +function tblis_set_num_threads(num_threads) + @ccall tblis.tblis_set_num_threads(num_threads::Cuint)::Cvoid +end + +function tblis_vector_add(comm, cfg, A, B) + @ccall tblis.tblis_vector_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_vector_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_vector_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_vector_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_vector}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_vector_scale(comm, cfg, A) + @ccall tblis.tblis_vector_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_set(comm, cfg, alpha, A) + @ccall tblis.tblis_vector_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_vector})::Cvoid +end + +function tblis_matrix_add(comm, cfg, A, B) + @ccall tblis.tblis_matrix_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_matrix_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_matrix_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_matrix_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_matrix_scale(comm, cfg, A) + @ccall tblis.tblis_matrix_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_set(comm, cfg, alpha, A) + @ccall tblis.tblis_matrix_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_add(comm, cfg, A, idx_A, B, idx_B) + @ccall tblis.tblis_tensor_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type})::Cvoid +end + +function tblis_tensor_dot(comm, cfg, A, idx_A, B, idx_B, result) + @ccall tblis.tblis_tensor_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_tensor_reduce(comm, cfg, op, A, idx_A, result, idx) + @ccall tblis.tblis_tensor_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type}, result::Ptr{tblis_scalar}, + idx::Ptr{len_type})::Cvoid +end + +function tblis_tensor_scale(comm, cfg, A, idx_A) + @ccall tblis.tblis_tensor_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type})::Cvoid +end + +function tblis_tensor_set(comm, cfg, alpha, A, idx_A) + @ccall tblis.tblis_tensor_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type})::Cvoid +end + +function tblis_matrix_mult(comm, cfg, A, B, C) + @ccall tblis.tblis_matrix_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_mult_diag(comm, cfg, A, D, B, C) + @ccall tblis.tblis_matrix_mult_diag(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, D::Ptr{tblis_vector}, + B::Ptr{tblis_matrix}, C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_mult(comm, cfg, A, idx_A, B, idx_B, C, idx_C) + @ccall tblis.tblis_tensor_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + C::Ptr{tblis_tensor}, idx_C::Ptr{label_type})::Cvoid +end + +const TCI_USE_ATOMIC_SPINLOCK = 1 + +const TCI_USE_OMP_LOCK = 0 + +const TCI_USE_OPENMP_THREADS = 1 + +const TCI_USE_WINDOWS_THREADS = 0 + +const TCI_USE_TBB_THREADS = 0 + +const TCI_USE_PPL_THREADS = 0 + +const TCI_USE_OMPTASK_THREADS = 0 + +const TCI_USE_DISPATCH_THREADS = 0 + +const TCI_USE_OSX_SPINLOCK = 0 + +const TCI_USE_PTHREADS_THREADS = 0 + +const TCI_USE_PTHREAD_BARRIER = 0 + +const TCI_USE_PTHREAD_MUTEX = 0 + +const TCI_USE_PTHREAD_SPINLOCK = 0 + +const TCI_USE_SPIN_BARRIER = 1 + +const TCI_ARCH_X64 = 1 + +# Skipping MacroDefinition: TCI_INLINE static inline + +const TBLIS_HAVE_SYSCONF = 1 + +const TBLIS_HAVE_SYSCTL = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_CONF = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_ONLN = 1 + +const TBLIS_LABEL_TYPE = Cchar + +const TBLIS_LEN_TYPE = ptrdiff_t + +const TBLIS_LT_OBJDIR = ".libs/" + +const TBLIS_PACKAGE = "tblis" + +const TBLIS_PACKAGE_BUGREPORT = "dmatthews@utexas.edu" + +const TBLIS_PACKAGE_NAME = "tblis" + +const TBLIS_PACKAGE_STRING = "tblis 1.2.0" + +const TBLIS_PACKAGE_TARNAME = "tblis" + +const TBLIS_PACKAGE_URL = "http://www.github.com/devinamatthews/tblis" + +const TBLIS_PACKAGE_VERSION = "1.2.0" + +# Skipping MacroDefinition: _tblis_restrict __restrict + +const TBLIS_STDC_HEADERS = 1 + +const TBLIS_STRIDE_TYPE = ptrdiff_t + +const TBLIS_TOPDIR = "/workspace/srcdir/tblis" + +const TBLIS_VERSION = "1.2.0" diff --git a/src/lib/x86_64-unknown-freebsd.jl b/src/lib/x86_64-unknown-freebsd.jl new file mode 100644 index 0000000..51f6401 --- /dev/null +++ b/src/lib/x86_64-unknown-freebsd.jl @@ -0,0 +1,779 @@ +# no prototype is found for this function at yield.h:19:17, please use with caution +function tci_yield() + @ccall tblis.tci_yield()::Cvoid +end + +const tci_mutex = Cchar + +function tci_mutex_init(mutex) + @ccall tblis.tci_mutex_init(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_destroy(mutex) + @ccall tblis.tci_mutex_destroy(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_lock(mutex) + @ccall tblis.tci_mutex_lock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutexrylock(mutex) + @ccall tblis.tci_mutexrylock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_unlock(mutex) + @ccall tblis.tci_mutex_unlock(mutex::Ptr{tci_mutex})::Cint +end + +struct tci_barrier_node + parent::Ptr{tci_barrier_node} + nchildren::Cuint + step::Cuint + nwaiting::Cuint +end + +function tci_barrier_node_init(barrier, parent, nchildren) + @ccall tblis.tci_barrier_node_init(barrier::Ptr{tci_barrier_node}, + parent::Ptr{tci_barrier_node}, + nchildren::Cuint)::Cint +end + +function tci_barrier_node_destroy(barrier) + @ccall tblis.tci_barrier_node_destroy(barrier::Ptr{tci_barrier_node})::Cint +end + +function tci_barrier_node_wait(barrier) + @ccall tblis.tci_barrier_node_wait(barrier::Ptr{tci_barrier_node})::Cint +end + +struct __JL_Ctag_23 + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{__JL_Ctag_23}, f::Symbol) + f === :array && return Ptr{Ptr{tci_barrier_node}}(x + 0) + f === :single && return Ptr{tci_barrier_node}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::__JL_Ctag_23, f::Symbol) + r = Ref{__JL_Ctag_23}(x) + ptr = Base.unsafe_convert(Ptr{__JL_Ctag_23}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{__JL_Ctag_23}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tci_barrier + data::NTuple{40,UInt8} +end + +function Base.getproperty(x::Ptr{tci_barrier}, f::Symbol) + f === :barrier && return Ptr{__JL_Ctag_23}(x + 0) + f === :nthread && return Ptr{Cuint}(x + 24) + f === :group_size && return Ptr{Cuint}(x + 28) + f === :is_tree && return Ptr{Cint}(x + 32) + return getfield(x, f) +end + +function Base.getproperty(x::tci_barrier, f::Symbol) + r = Ref{tci_barrier}(x) + ptr = Base.unsafe_convert(Ptr{tci_barrier}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tci_barrier}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tci_barrier_is_tree(barrier) + @ccall tblis.tci_barrier_is_tree(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_init(barrier, nthread, group_size) + @ccall tblis.tci_barrier_init(barrier::Ptr{tci_barrier}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_barrier_destroy(barrier) + @ccall tblis.tci_barrier_destroy(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_wait(barrier, tid) + @ccall tblis.tci_barrier_wait(barrier::Ptr{tci_barrier}, tid::Cuint)::Cint +end + +struct tci_context + barrier::tci_barrier + buffer::Ptr{Cvoid} + refcount::Cuint +end + +function tci_context_init(context, nthread, group_size) + @ccall tblis.tci_context_init(context::Ptr{Ptr{tci_context}}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_context_attach(context) + @ccall tblis.tci_context_attach(context::Ptr{tci_context})::Cint +end + +function tci_context_detach(context) + @ccall tblis.tci_context_detach(context::Ptr{tci_context})::Cint +end + +function tci_context_barrier(context, tid) + @ccall tblis.tci_context_barrier(context::Ptr{tci_context}, tid::Cuint)::Cint +end + +function tci_context_send(context, tid, object) + @ccall tblis.tci_context_send(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_send_nowait(context, tid, object) + @ccall tblis.tci_context_send_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_receive(context, tid, object) + @ccall tblis.tci_context_receive(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +function tci_context_receive_nowait(context, tid, object) + @ccall tblis.tci_context_receive_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +struct tci_comm + context::Ptr{tci_context} + ngang::Cuint + gid::Cuint + nthread::Cuint + tid::Cuint +end + +@enum __JL_Ctag_8::UInt32 begin + TCI_EVENLY = 2 + TCI_CYCLIC = 4 + TCI_BLOCK_CYCLIC = 6 + TCI_BLOCKED = 8 + TCI_NO_CONTEXT = 1 +end + +mutable struct tci_range + size::UInt64 + grain::UInt64 + tci_range() = new() +end + +# typedef void ( * tci_range_func ) ( tci_comm * , uint64_t , uint64_t , void * ) +const tci_range_func = Ptr{Cvoid} + +# typedef void ( * tci_range_2d_func ) ( tci_comm * , uint64_t , uint64_t , uint64_t , uint64_t , void * ) +const tci_range_2d_func = Ptr{Cvoid} + +function tci_comm_init_single(comm) + @ccall tblis.tci_comm_init_single(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_init(comm, context, nthread, tid, ngang, gid) + @ccall tblis.tci_comm_init(comm::Ptr{tci_comm}, context::Ptr{tci_context}, + nthread::Cuint, tid::Cuint, ngang::Cuint, gid::Cuint)::Cint +end + +function tci_comm_destroy(comm) + @ccall tblis.tci_comm_destroy(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_is_master(comm) + @ccall tblis.tci_comm_is_master(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_barrier(comm) + @ccall tblis.tci_comm_barrier(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_bcast(comm, object, root) + @ccall tblis.tci_comm_bcast(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_bcast_nowait(comm, object, root) + @ccall tblis.tci_comm_bcast_nowait(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_gang(parent, child, type, n, bs) + @ccall tblis.tci_comm_gang(parent::Ptr{tci_comm}, child::Ptr{tci_comm}, type::Cint, + n::Cuint, bs::Cuint)::Cint +end + +function tci_comm_distribute_over_gangs(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_threads(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_gangs_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs_2d(comm::Ptr{tci_comm}, range_m::tci_range, + range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_threads_2d(comm::Ptr{tci_comm}, + range_m::tci_range, range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +# typedef void ( * tci_thread_func ) ( tci_comm * , void * ) +const tci_thread_func = Ptr{Cvoid} + +function tci_parallelize(func, payload, nthread, arity) + @ccall tblis.tci_parallelize(func::tci_thread_func, payload::Ptr{Cvoid}, nthread::Cuint, + arity::Cuint)::Cint +end + +struct tci_prime_factors + n::Cuint + sqrt_n::Cuint + f::Cuint +end + +function tci_prime_factorization(n, factors) + @ccall tblis.tci_prime_factorization(n::Cuint, factors::Ptr{tci_prime_factors})::Cvoid +end + +function tci_next_prime_factor(factors) + @ccall tblis.tci_next_prime_factor(factors::Ptr{tci_prime_factors})::Cuint +end + +function tci_partition_2x2(nthread, work1, max1, work2, max2, nt1, nt2) + @ccall tblis.tci_partition_2x2(nthread::Cuint, work1::UInt64, max1::Cuint, + work2::UInt64, max2::Cuint, nt1::Ptr{Cuint}, + nt2::Ptr{Cuint})::Cvoid +end + +const tci_slot = Cint + +function tci_slot_init(slot, empty) + @ccall tblis.tci_slot_init(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_is_filled(slot, empty) + @ccall tblis.tci_slot_is_filled(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_try_fill(slot, empty, value) + @ccall tblis.tci_slot_try_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cint +end + +function tci_slot_fill(slot, empty, value) + @ccall tblis.tci_slot_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cvoid +end + +function tci_slot_clear(slot, empty) + @ccall tblis.tci_slot_clear(slot::Ptr{tci_slot}, empty::Cint)::Cvoid +end + +@enum __JL_Ctag_9::UInt32 begin + TCI_NOT_WORKED_ON = 0 + TCI_IN_PROGRESS = 1 + TCI_RESERVED = 2 + TCI_FINISHED = 3 +end + +const tci_work_item = Cint + +function tci_work_item_try_work(item) + @ccall tblis.tci_work_item_try_work(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_finish(item) + @ccall tblis.tci_work_item_finish(item::Ptr{tci_work_item})::Cvoid +end + +function tci_work_item_status(item) + @ccall tblis.tci_work_item_status(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_wait(item) + @ccall tblis.tci_work_item_wait(item::Ptr{tci_work_item})::Cvoid +end + +mutable struct tblis_config_s end + +const tblis_config = tblis_config_s + +@enum reduce_t::UInt32 begin + REDUCE_SUM = 0 + REDUCE_SUM_ABS = 1 + REDUCE_MAX = 2 + REDUCE_MAX_ABS = 3 + REDUCE_MIN = 4 + REDUCE_MIN_ABS = 5 + # REDUCE_NORM_1 = 1 + REDUCE_NORM_2 = 6 + # REDUCE_NORM_INF = 3 +end + +@enum type_t::UInt32 begin + TYPE_SINGLE = 0 + # TYPE_FLOAT = 0 + TYPE_DOUBLE = 1 + TYPE_SCOMPLEX = 2 + TYPE_DCOMPLEX = 3 +end + +const len_type = Cptrdiff_t + +const stride_type = Cptrdiff_t + +const label_type = Cchar + +mutable struct fake_scomplex + real::Cfloat + imag::Cfloat + fake_scomplex() = new() +end + +mutable struct fake_dcomplex + real::Cdouble + imag::Cdouble + fake_dcomplex() = new() +end + +struct scalar + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{scalar}, f::Symbol) + f === :s && return Ptr{Cfloat}(x + 0) + f === :d && return Ptr{Cdouble}(x + 0) + f === :c && return Ptr{scomplex}(x + 0) + f === :z && return Ptr{dcomplex}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::scalar, f::Symbol) + r = Ref{scalar}(x) + ptr = Base.unsafe_convert(Ptr{scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tblis_scalar + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{tblis_scalar}, f::Symbol) + f === :data && return Ptr{scalar}(x + 0) + f === :type && return Ptr{type_t}(x + 16) + return getfield(x, f) +end + +function Base.getproperty(x::tblis_scalar, f::Symbol) + r = Ref{tblis_scalar}(x) + ptr = Base.unsafe_convert(Ptr{tblis_scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tblis_scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tblis_init_scalar_s(s, value) + @ccall tblis.tblis_init_scalar_s(s::Ptr{tblis_scalar}, value::Cfloat)::Cvoid +end + +function tblis_init_scalar_d(s, value) + @ccall tblis.tblis_init_scalar_d(s::Ptr{tblis_scalar}, value::Cdouble)::Cvoid +end + +function tblis_init_scalar_c(s, value) + @ccall tblis.tblis_init_scalar_c(s::Ptr{tblis_scalar}, value::scomplex)::Cvoid +end + +function tblis_init_scalar_z(s, value) + @ccall tblis.tblis_init_scalar_z(s::Ptr{tblis_scalar}, value::dcomplex)::Cvoid +end + +mutable struct tblis_vector + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + n::len_type + inc::stride_type + tblis_vector() = new() +end + +function tblis_init_vector_scaled_s(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_s(v::Ptr{tblis_vector}, scalar_::Cfloat, + n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_d(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_d(v::Ptr{tblis_vector}, scalar_::Cdouble, + n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_c(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_c(v::Ptr{tblis_vector}, scalar_::scomplex, + n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_z(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_z(v::Ptr{tblis_vector}, scalar_::dcomplex, + n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_s(v, n, data, inc) + @ccall tblis.tblis_init_vector_s(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_d(v, n, data, inc) + @ccall tblis.tblis_init_vector_d(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_c(v, n, data, inc) + @ccall tblis.tblis_init_vector_c(v::Ptr{tblis_vector}, n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_z(v, n, data, inc) + @ccall tblis.tblis_init_vector_z(v::Ptr{tblis_vector}, n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +mutable struct tblis_matrix + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + m::len_type + n::len_type + rs::stride_type + cs::stride_type + tblis_matrix() = new() +end + +function tblis_init_matrix_scaled_s(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_s(mat::Ptr{tblis_matrix}, scalar_::Cfloat, + m::len_type, n::len_type, data::Ptr{Cfloat}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_d(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_d(mat::Ptr{tblis_matrix}, scalar_::Cdouble, + m::len_type, n::len_type, data::Ptr{Cdouble}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_c(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_c(mat::Ptr{tblis_matrix}, scalar_::scomplex, + m::len_type, n::len_type, data::Ptr{scomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_z(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_z(mat::Ptr{tblis_matrix}, scalar_::dcomplex, + m::len_type, n::len_type, data::Ptr{dcomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_s(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_s(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cfloat}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_d(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_d(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cdouble}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_c(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_c(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{scomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_z(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_z(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{dcomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +struct tblis_tensor + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + ndim::Cuint + len::Ptr{len_type} + stride::Ptr{stride_type} +end + +function tblis_init_tensor_scaled_s(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_s(t::Ptr{tblis_tensor}, scalar_::Cfloat, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_d(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_d(t::Ptr{tblis_tensor}, scalar_::Cdouble, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_c(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_c(t::Ptr{tblis_tensor}, scalar_::scomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_z(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_z(t::Ptr{tblis_tensor}, scalar_::dcomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_s(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_s(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_d(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_d(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_c(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_c(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_z(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_z(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_get_config(name) + @ccall tblis.tblis_get_config(name::Ptr{Cchar})::Ptr{tblis_config} +end + +const tblis_comm = tci_comm + +# no prototype is found for this function at thread.h:21:10, please use with caution +function tblis_get_num_threads() + @ccall tblis.tblis_get_num_threads()::Cuint +end + +function tblis_set_num_threads(num_threads) + @ccall tblis.tblis_set_num_threads(num_threads::Cuint)::Cvoid +end + +function tblis_vector_add(comm, cfg, A, B) + @ccall tblis.tblis_vector_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_vector_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_vector_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_vector_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_vector}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_vector_scale(comm, cfg, A) + @ccall tblis.tblis_vector_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_set(comm, cfg, alpha, A) + @ccall tblis.tblis_vector_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_vector})::Cvoid +end + +function tblis_matrix_add(comm, cfg, A, B) + @ccall tblis.tblis_matrix_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_matrix_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_matrix_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_matrix_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_matrix_scale(comm, cfg, A) + @ccall tblis.tblis_matrix_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_set(comm, cfg, alpha, A) + @ccall tblis.tblis_matrix_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_add(comm, cfg, A, idx_A, B, idx_B) + @ccall tblis.tblis_tensor_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type})::Cvoid +end + +function tblis_tensor_dot(comm, cfg, A, idx_A, B, idx_B, result) + @ccall tblis.tblis_tensor_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_tensor_reduce(comm, cfg, op, A, idx_A, result, idx) + @ccall tblis.tblis_tensor_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type}, result::Ptr{tblis_scalar}, + idx::Ptr{len_type})::Cvoid +end + +function tblis_tensor_scale(comm, cfg, A, idx_A) + @ccall tblis.tblis_tensor_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type})::Cvoid +end + +function tblis_tensor_set(comm, cfg, alpha, A, idx_A) + @ccall tblis.tblis_tensor_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type})::Cvoid +end + +function tblis_matrix_mult(comm, cfg, A, B, C) + @ccall tblis.tblis_matrix_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_mult_diag(comm, cfg, A, D, B, C) + @ccall tblis.tblis_matrix_mult_diag(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, D::Ptr{tblis_vector}, + B::Ptr{tblis_matrix}, C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_mult(comm, cfg, A, idx_A, B, idx_B, C, idx_C) + @ccall tblis.tblis_tensor_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + C::Ptr{tblis_tensor}, idx_C::Ptr{label_type})::Cvoid +end + +const TCI_USE_ATOMIC_SPINLOCK = 1 + +const TCI_USE_OMP_LOCK = 0 + +const TCI_USE_OPENMP_THREADS = 1 + +const TCI_USE_WINDOWS_THREADS = 0 + +const TCI_USE_TBB_THREADS = 0 + +const TCI_USE_PPL_THREADS = 0 + +const TCI_USE_OMPTASK_THREADS = 0 + +const TCI_USE_DISPATCH_THREADS = 0 + +const TCI_USE_OSX_SPINLOCK = 0 + +const TCI_USE_PTHREADS_THREADS = 0 + +const TCI_USE_PTHREAD_BARRIER = 0 + +const TCI_USE_PTHREAD_MUTEX = 0 + +const TCI_USE_PTHREAD_SPINLOCK = 0 + +const TCI_USE_SPIN_BARRIER = 1 + +const TCI_ARCH_X64 = 1 + +# Skipping MacroDefinition: TCI_INLINE static inline + +const TBLIS_HAVE_SYSCONF = 1 + +const TBLIS_HAVE_SYSCTL = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_CONF = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_ONLN = 1 + +const TBLIS_LABEL_TYPE = Cchar + +const TBLIS_LEN_TYPE = ptrdiff_t + +const TBLIS_LT_OBJDIR = ".libs/" + +const TBLIS_PACKAGE = "tblis" + +const TBLIS_PACKAGE_BUGREPORT = "dmatthews@utexas.edu" + +const TBLIS_PACKAGE_NAME = "tblis" + +const TBLIS_PACKAGE_STRING = "tblis 1.2.0" + +const TBLIS_PACKAGE_TARNAME = "tblis" + +const TBLIS_PACKAGE_URL = "http://www.github.com/devinamatthews/tblis" + +const TBLIS_PACKAGE_VERSION = "1.2.0" + +# Skipping MacroDefinition: _tblis_restrict __restrict + +const TBLIS_STDC_HEADERS = 1 + +const TBLIS_STRIDE_TYPE = ptrdiff_t + +const TBLIS_TOPDIR = "/workspace/srcdir/tblis" + +const TBLIS_VERSION = "1.2.0" diff --git a/src/lib/x86_64-w64-mingw32.jl b/src/lib/x86_64-w64-mingw32.jl new file mode 100644 index 0000000..fa29445 --- /dev/null +++ b/src/lib/x86_64-w64-mingw32.jl @@ -0,0 +1,779 @@ +# no prototype is found for this function at yield.h:19:17, please use with caution +function tci_yield() + @ccall tblis.tci_yield()::Cvoid +end + +const tci_mutex = Cchar + +function tci_mutex_init(mutex) + @ccall tblis.tci_mutex_init(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_destroy(mutex) + @ccall tblis.tci_mutex_destroy(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_lock(mutex) + @ccall tblis.tci_mutex_lock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutexrylock(mutex) + @ccall tblis.tci_mutexrylock(mutex::Ptr{tci_mutex})::Cint +end + +function tci_mutex_unlock(mutex) + @ccall tblis.tci_mutex_unlock(mutex::Ptr{tci_mutex})::Cint +end + +struct tci_barrier_node + parent::Ptr{tci_barrier_node} + nchildren::Cuint + step::Cuint + nwaiting::Cuint +end + +function tci_barrier_node_init(barrier, parent, nchildren) + @ccall tblis.tci_barrier_node_init(barrier::Ptr{tci_barrier_node}, + parent::Ptr{tci_barrier_node}, + nchildren::Cuint)::Cint +end + +function tci_barrier_node_destroy(barrier) + @ccall tblis.tci_barrier_node_destroy(barrier::Ptr{tci_barrier_node})::Cint +end + +function tci_barrier_node_wait(barrier) + @ccall tblis.tci_barrier_node_wait(barrier::Ptr{tci_barrier_node})::Cint +end + +struct __JL_Ctag_25 + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{__JL_Ctag_25}, f::Symbol) + f === :array && return Ptr{Ptr{tci_barrier_node}}(x + 0) + f === :single && return Ptr{tci_barrier_node}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::__JL_Ctag_25, f::Symbol) + r = Ref{__JL_Ctag_25}(x) + ptr = Base.unsafe_convert(Ptr{__JL_Ctag_25}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{__JL_Ctag_25}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tci_barrier + data::NTuple{40,UInt8} +end + +function Base.getproperty(x::Ptr{tci_barrier}, f::Symbol) + f === :barrier && return Ptr{__JL_Ctag_25}(x + 0) + f === :nthread && return Ptr{Cuint}(x + 24) + f === :group_size && return Ptr{Cuint}(x + 28) + f === :is_tree && return Ptr{Cint}(x + 32) + return getfield(x, f) +end + +function Base.getproperty(x::tci_barrier, f::Symbol) + r = Ref{tci_barrier}(x) + ptr = Base.unsafe_convert(Ptr{tci_barrier}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tci_barrier}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tci_barrier_is_tree(barrier) + @ccall tblis.tci_barrier_is_tree(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_init(barrier, nthread, group_size) + @ccall tblis.tci_barrier_init(barrier::Ptr{tci_barrier}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_barrier_destroy(barrier) + @ccall tblis.tci_barrier_destroy(barrier::Ptr{tci_barrier})::Cint +end + +function tci_barrier_wait(barrier, tid) + @ccall tblis.tci_barrier_wait(barrier::Ptr{tci_barrier}, tid::Cuint)::Cint +end + +struct tci_context + barrier::tci_barrier + buffer::Ptr{Cvoid} + refcount::Cuint +end + +function tci_context_init(context, nthread, group_size) + @ccall tblis.tci_context_init(context::Ptr{Ptr{tci_context}}, nthread::Cuint, + group_size::Cuint)::Cint +end + +function tci_context_attach(context) + @ccall tblis.tci_context_attach(context::Ptr{tci_context})::Cint +end + +function tci_context_detach(context) + @ccall tblis.tci_context_detach(context::Ptr{tci_context})::Cint +end + +function tci_context_barrier(context, tid) + @ccall tblis.tci_context_barrier(context::Ptr{tci_context}, tid::Cuint)::Cint +end + +function tci_context_send(context, tid, object) + @ccall tblis.tci_context_send(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_send_nowait(context, tid, object) + @ccall tblis.tci_context_send_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Cvoid})::Cint +end + +function tci_context_receive(context, tid, object) + @ccall tblis.tci_context_receive(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +function tci_context_receive_nowait(context, tid, object) + @ccall tblis.tci_context_receive_nowait(context::Ptr{tci_context}, tid::Cuint, + object::Ptr{Ptr{Cvoid}})::Cint +end + +struct tci_comm + context::Ptr{tci_context} + ngang::Cuint + gid::Cuint + nthread::Cuint + tid::Cuint +end + +@enum __JL_Ctag_10::UInt32 begin + TCI_EVENLY = 2 + TCI_CYCLIC = 4 + TCI_BLOCK_CYCLIC = 6 + TCI_BLOCKED = 8 + TCI_NO_CONTEXT = 1 +end + +mutable struct tci_range + size::UInt64 + grain::UInt64 + tci_range() = new() +end + +# typedef void ( * tci_range_func ) ( tci_comm * , uint64_t , uint64_t , void * ) +const tci_range_func = Ptr{Cvoid} + +# typedef void ( * tci_range_2d_func ) ( tci_comm * , uint64_t , uint64_t , uint64_t , uint64_t , void * ) +const tci_range_2d_func = Ptr{Cvoid} + +function tci_comm_init_single(comm) + @ccall tblis.tci_comm_init_single(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_init(comm, context, nthread, tid, ngang, gid) + @ccall tblis.tci_comm_init(comm::Ptr{tci_comm}, context::Ptr{tci_context}, + nthread::Cuint, tid::Cuint, ngang::Cuint, gid::Cuint)::Cint +end + +function tci_comm_destroy(comm) + @ccall tblis.tci_comm_destroy(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_is_master(comm) + @ccall tblis.tci_comm_is_master(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_barrier(comm) + @ccall tblis.tci_comm_barrier(comm::Ptr{tci_comm})::Cint +end + +function tci_comm_bcast(comm, object, root) + @ccall tblis.tci_comm_bcast(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_bcast_nowait(comm, object, root) + @ccall tblis.tci_comm_bcast_nowait(comm::Ptr{tci_comm}, object::Ptr{Ptr{Cvoid}}, + root::Cuint)::Cint +end + +function tci_comm_gang(parent, child, type, n, bs) + @ccall tblis.tci_comm_gang(parent::Ptr{tci_comm}, child::Ptr{tci_comm}, type::Cint, + n::Cuint, bs::Cuint)::Cint +end + +function tci_comm_distribute_over_gangs(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads(comm, range, func, payload) + @ccall tblis.tci_comm_distribute_over_threads(comm::Ptr{tci_comm}, range::tci_range, + func::tci_range_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_gangs_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_gangs_2d(comm::Ptr{tci_comm}, range_m::tci_range, + range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +function tci_comm_distribute_over_threads_2d(comm, range_m, range_n, func, payload) + @ccall tblis.tci_comm_distribute_over_threads_2d(comm::Ptr{tci_comm}, + range_m::tci_range, range_n::tci_range, + func::tci_range_2d_func, + payload::Ptr{Cvoid})::Cvoid +end + +# typedef void ( * tci_thread_func ) ( tci_comm * , void * ) +const tci_thread_func = Ptr{Cvoid} + +function tci_parallelize(func, payload, nthread, arity) + @ccall tblis.tci_parallelize(func::tci_thread_func, payload::Ptr{Cvoid}, nthread::Cuint, + arity::Cuint)::Cint +end + +struct tci_prime_factors + n::Cuint + sqrt_n::Cuint + f::Cuint +end + +function tci_prime_factorization(n, factors) + @ccall tblis.tci_prime_factorization(n::Cuint, factors::Ptr{tci_prime_factors})::Cvoid +end + +function tci_next_prime_factor(factors) + @ccall tblis.tci_next_prime_factor(factors::Ptr{tci_prime_factors})::Cuint +end + +function tci_partition_2x2(nthread, work1, max1, work2, max2, nt1, nt2) + @ccall tblis.tci_partition_2x2(nthread::Cuint, work1::UInt64, max1::Cuint, + work2::UInt64, max2::Cuint, nt1::Ptr{Cuint}, + nt2::Ptr{Cuint})::Cvoid +end + +const tci_slot = Cint + +function tci_slot_init(slot, empty) + @ccall tblis.tci_slot_init(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_is_filled(slot, empty) + @ccall tblis.tci_slot_is_filled(slot::Ptr{tci_slot}, empty::Cint)::Cint +end + +function tci_slot_try_fill(slot, empty, value) + @ccall tblis.tci_slot_try_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cint +end + +function tci_slot_fill(slot, empty, value) + @ccall tblis.tci_slot_fill(slot::Ptr{tci_slot}, empty::Cint, value::Cint)::Cvoid +end + +function tci_slot_clear(slot, empty) + @ccall tblis.tci_slot_clear(slot::Ptr{tci_slot}, empty::Cint)::Cvoid +end + +@enum __JL_Ctag_11::UInt32 begin + TCI_NOT_WORKED_ON = 0 + TCI_IN_PROGRESS = 1 + TCI_RESERVED = 2 + TCI_FINISHED = 3 +end + +const tci_work_item = Cint + +function tci_work_item_try_work(item) + @ccall tblis.tci_work_item_try_work(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_finish(item) + @ccall tblis.tci_work_item_finish(item::Ptr{tci_work_item})::Cvoid +end + +function tci_work_item_status(item) + @ccall tblis.tci_work_item_status(item::Ptr{tci_work_item})::Cint +end + +function tci_work_item_wait(item) + @ccall tblis.tci_work_item_wait(item::Ptr{tci_work_item})::Cvoid +end + +mutable struct tblis_config_s end + +const tblis_config = tblis_config_s + +@enum reduce_t::UInt32 begin + REDUCE_SUM = 0 + REDUCE_SUM_ABS = 1 + REDUCE_MAX = 2 + REDUCE_MAX_ABS = 3 + REDUCE_MIN = 4 + REDUCE_MIN_ABS = 5 + # REDUCE_NORM_1 = 1 + REDUCE_NORM_2 = 6 + # REDUCE_NORM_INF = 3 +end + +@enum type_t::UInt32 begin + TYPE_SINGLE = 0 + # TYPE_FLOAT = 0 + TYPE_DOUBLE = 1 + TYPE_SCOMPLEX = 2 + TYPE_DCOMPLEX = 3 +end + +const len_type = Cptrdiff_t + +const stride_type = Cptrdiff_t + +const label_type = Cchar + +mutable struct fake_scomplex + real::Cfloat + imag::Cfloat + fake_scomplex() = new() +end + +mutable struct fake_dcomplex + real::Cdouble + imag::Cdouble + fake_dcomplex() = new() +end + +struct scalar + data::NTuple{16,UInt8} +end + +function Base.getproperty(x::Ptr{scalar}, f::Symbol) + f === :s && return Ptr{Cfloat}(x + 0) + f === :d && return Ptr{Cdouble}(x + 0) + f === :c && return Ptr{scomplex}(x + 0) + f === :z && return Ptr{dcomplex}(x + 0) + return getfield(x, f) +end + +function Base.getproperty(x::scalar, f::Symbol) + r = Ref{scalar}(x) + ptr = Base.unsafe_convert(Ptr{scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +struct tblis_scalar + data::NTuple{24,UInt8} +end + +function Base.getproperty(x::Ptr{tblis_scalar}, f::Symbol) + f === :data && return Ptr{scalar}(x + 0) + f === :type && return Ptr{type_t}(x + 16) + return getfield(x, f) +end + +function Base.getproperty(x::tblis_scalar, f::Symbol) + r = Ref{tblis_scalar}(x) + ptr = Base.unsafe_convert(Ptr{tblis_scalar}, r) + fptr = getproperty(ptr, f) + GC.@preserve r unsafe_load(fptr) +end + +function Base.setproperty!(x::Ptr{tblis_scalar}, f::Symbol, v) + return unsafe_store!(getproperty(x, f), v) +end + +function tblis_init_scalar_s(s, value) + @ccall tblis.tblis_init_scalar_s(s::Ptr{tblis_scalar}, value::Cfloat)::Cvoid +end + +function tblis_init_scalar_d(s, value) + @ccall tblis.tblis_init_scalar_d(s::Ptr{tblis_scalar}, value::Cdouble)::Cvoid +end + +function tblis_init_scalar_c(s, value) + @ccall tblis.tblis_init_scalar_c(s::Ptr{tblis_scalar}, value::scomplex)::Cvoid +end + +function tblis_init_scalar_z(s, value) + @ccall tblis.tblis_init_scalar_z(s::Ptr{tblis_scalar}, value::dcomplex)::Cvoid +end + +mutable struct tblis_vector + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + n::len_type + inc::stride_type + tblis_vector() = new() +end + +function tblis_init_vector_scaled_s(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_s(v::Ptr{tblis_vector}, scalar_::Cfloat, + n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_d(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_d(v::Ptr{tblis_vector}, scalar_::Cdouble, + n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_c(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_c(v::Ptr{tblis_vector}, scalar_::scomplex, + n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_scaled_z(v, scalar_, n, data, inc) + @ccall tblis.tblis_init_vector_scaled_z(v::Ptr{tblis_vector}, scalar_::dcomplex, + n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_s(v, n, data, inc) + @ccall tblis.tblis_init_vector_s(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cfloat}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_d(v, n, data, inc) + @ccall tblis.tblis_init_vector_d(v::Ptr{tblis_vector}, n::len_type, data::Ptr{Cdouble}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_c(v, n, data, inc) + @ccall tblis.tblis_init_vector_c(v::Ptr{tblis_vector}, n::len_type, data::Ptr{scomplex}, + inc::stride_type)::Cvoid +end + +function tblis_init_vector_z(v, n, data, inc) + @ccall tblis.tblis_init_vector_z(v::Ptr{tblis_vector}, n::len_type, data::Ptr{dcomplex}, + inc::stride_type)::Cvoid +end + +mutable struct tblis_matrix + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + m::len_type + n::len_type + rs::stride_type + cs::stride_type + tblis_matrix() = new() +end + +function tblis_init_matrix_scaled_s(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_s(mat::Ptr{tblis_matrix}, scalar_::Cfloat, + m::len_type, n::len_type, data::Ptr{Cfloat}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_d(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_d(mat::Ptr{tblis_matrix}, scalar_::Cdouble, + m::len_type, n::len_type, data::Ptr{Cdouble}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_c(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_c(mat::Ptr{tblis_matrix}, scalar_::scomplex, + m::len_type, n::len_type, data::Ptr{scomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_scaled_z(mat, scalar_, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_scaled_z(mat::Ptr{tblis_matrix}, scalar_::dcomplex, + m::len_type, n::len_type, data::Ptr{dcomplex}, + rs::stride_type, cs::stride_type)::Cvoid +end + +function tblis_init_matrix_s(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_s(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cfloat}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_d(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_d(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{Cdouble}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_c(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_c(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{scomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +function tblis_init_matrix_z(mat, m, n, data, rs, cs) + @ccall tblis.tblis_init_matrix_z(mat::Ptr{tblis_matrix}, m::len_type, n::len_type, + data::Ptr{dcomplex}, rs::stride_type, + cs::stride_type)::Cvoid +end + +struct tblis_tensor + type::type_t + conj::Cint + scalar::tblis_scalar + data::Ptr{Cvoid} + ndim::Cuint + len::Ptr{len_type} + stride::Ptr{stride_type} +end + +function tblis_init_tensor_scaled_s(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_s(t::Ptr{tblis_tensor}, scalar_::Cfloat, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_d(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_d(t::Ptr{tblis_tensor}, scalar_::Cdouble, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_c(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_c(t::Ptr{tblis_tensor}, scalar_::scomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_scaled_z(t, scalar_, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_scaled_z(t::Ptr{tblis_tensor}, scalar_::dcomplex, + ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, + stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_s(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_s(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cfloat}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_d(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_d(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{Cdouble}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_c(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_c(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{scomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_init_tensor_z(t, ndim, len, data, stride) + @ccall tblis.tblis_init_tensor_z(t::Ptr{tblis_tensor}, ndim::Cuint, len::Ptr{len_type}, + data::Ptr{dcomplex}, stride::Ptr{stride_type})::Cvoid +end + +function tblis_get_config(name) + @ccall tblis.tblis_get_config(name::Ptr{Cchar})::Ptr{tblis_config} +end + +const tblis_comm = tci_comm + +# no prototype is found for this function at thread.h:21:10, please use with caution +function tblis_get_num_threads() + @ccall tblis.tblis_get_num_threads()::Cuint +end + +function tblis_set_num_threads(num_threads) + @ccall tblis.tblis_set_num_threads(num_threads::Cuint)::Cvoid +end + +function tblis_vector_add(comm, cfg, A, B) + @ccall tblis.tblis_vector_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_vector_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector}, B::Ptr{tblis_vector}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_vector_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_vector_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_vector}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_vector_scale(comm, cfg, A) + @ccall tblis.tblis_vector_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_vector})::Cvoid +end + +function tblis_vector_set(comm, cfg, alpha, A) + @ccall tblis.tblis_vector_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_vector})::Cvoid +end + +function tblis_matrix_add(comm, cfg, A, B) + @ccall tblis.tblis_matrix_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_dot(comm, cfg, A, B, result) + @ccall tblis.tblis_matrix_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_matrix_reduce(comm, cfg, op, A, result, idx) + @ccall tblis.tblis_matrix_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_matrix}, + result::Ptr{tblis_scalar}, idx::Ptr{len_type})::Cvoid +end + +function tblis_matrix_scale(comm, cfg, A) + @ccall tblis.tblis_matrix_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_set(comm, cfg, alpha, A) + @ccall tblis.tblis_matrix_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_add(comm, cfg, A, idx_A, B, idx_B) + @ccall tblis.tblis_tensor_add(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type})::Cvoid +end + +function tblis_tensor_dot(comm, cfg, A, idx_A, B, idx_B, result) + @ccall tblis.tblis_tensor_dot(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + result::Ptr{tblis_scalar})::Cvoid +end + +function tblis_tensor_reduce(comm, cfg, op, A, idx_A, result, idx) + @ccall tblis.tblis_tensor_reduce(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + op::reduce_t, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type}, result::Ptr{tblis_scalar}, + idx::Ptr{len_type})::Cvoid +end + +function tblis_tensor_scale(comm, cfg, A, idx_A) + @ccall tblis.tblis_tensor_scale(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type})::Cvoid +end + +function tblis_tensor_set(comm, cfg, alpha, A, idx_A) + @ccall tblis.tblis_tensor_set(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + alpha::Ptr{tblis_scalar}, A::Ptr{tblis_tensor}, + idx_A::Ptr{label_type})::Cvoid +end + +function tblis_matrix_mult(comm, cfg, A, B, C) + @ccall tblis.tblis_matrix_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, B::Ptr{tblis_matrix}, + C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_matrix_mult_diag(comm, cfg, A, D, B, C) + @ccall tblis.tblis_matrix_mult_diag(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_matrix}, D::Ptr{tblis_vector}, + B::Ptr{tblis_matrix}, C::Ptr{tblis_matrix})::Cvoid +end + +function tblis_tensor_mult(comm, cfg, A, idx_A, B, idx_B, C, idx_C) + @ccall tblis.tblis_tensor_mult(comm::Ptr{tblis_comm}, cfg::Ptr{tblis_config}, + A::Ptr{tblis_tensor}, idx_A::Ptr{label_type}, + B::Ptr{tblis_tensor}, idx_B::Ptr{label_type}, + C::Ptr{tblis_tensor}, idx_C::Ptr{label_type})::Cvoid +end + +const TCI_USE_ATOMIC_SPINLOCK = 1 + +const TCI_USE_OMP_LOCK = 0 + +const TCI_USE_OPENMP_THREADS = 1 + +const TCI_USE_WINDOWS_THREADS = 0 + +const TCI_USE_TBB_THREADS = 0 + +const TCI_USE_PPL_THREADS = 0 + +const TCI_USE_OMPTASK_THREADS = 0 + +const TCI_USE_DISPATCH_THREADS = 0 + +const TCI_USE_OSX_SPINLOCK = 0 + +const TCI_USE_PTHREADS_THREADS = 0 + +const TCI_USE_PTHREAD_BARRIER = 0 + +const TCI_USE_PTHREAD_MUTEX = 0 + +const TCI_USE_PTHREAD_SPINLOCK = 0 + +const TCI_USE_SPIN_BARRIER = 1 + +const TCI_ARCH_X64 = 1 + +# Skipping MacroDefinition: TCI_INLINE static inline + +const TBLIS_HAVE_SYSCONF = 1 + +const TBLIS_HAVE_SYSCTL = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_CONF = 1 + +const TBLIS_HAVE__SC_NPROCESSORS_ONLN = 1 + +const TBLIS_LABEL_TYPE = Cchar + +const TBLIS_LEN_TYPE = ptrdiff_t + +const TBLIS_LT_OBJDIR = ".libs/" + +const TBLIS_PACKAGE = "tblis" + +const TBLIS_PACKAGE_BUGREPORT = "dmatthews@utexas.edu" + +const TBLIS_PACKAGE_NAME = "tblis" + +const TBLIS_PACKAGE_STRING = "tblis 1.2.0" + +const TBLIS_PACKAGE_TARNAME = "tblis" + +const TBLIS_PACKAGE_URL = "http://www.github.com/devinamatthews/tblis" + +const TBLIS_PACKAGE_VERSION = "1.2.0" + +# Skipping MacroDefinition: _tblis_restrict __restrict + +const TBLIS_STDC_HEADERS = 1 + +const TBLIS_STRIDE_TYPE = ptrdiff_t + +const TBLIS_TOPDIR = "/workspace/srcdir/tblis" + +const TBLIS_VERSION = "1.2.0" diff --git a/test/runtests.jl b/test/runtests.jl new file mode 100644 index 0000000..ba8a057 --- /dev/null +++ b/test/runtests.jl @@ -0,0 +1,132 @@ +using TensorOperations +using TensorOperationsTBLIS +using Test +using LinearAlgebra: norm + +@testset "elementary operations" verbose = true begin + @testset "tensorcopy" begin + A = randn(Float32, (3, 5, 4, 6)) + @tensor C1[4, 1, 3, 2] := A[1, 2, 3, 4] + @tensor backend = tblis C2[4, 1, 3, 2] := A[1, 2, 3, 4] + @test C2 ≈ C1 + end + + @testset "tensoradd" begin + A = randn(Float32, (5, 6, 3, 4)) + B = randn(Float32, (5, 6, 3, 4)) + α = randn(Float32) + @tensor C1[a, b, c, d] := A[a, b, c, d] + α * B[a, b, c, d] + @tensor backend = tblis C2[a, b, c, d] := A[a, b, c, d] + α * B[a, b, c, d] + @test collect(C2) ≈ C1 + + C = randn(ComplexF32, (5, 6, 3, 4)) + D = randn(ComplexF32, (5, 3, 4, 6)) + β = randn(ComplexF32) + @tensor E1[a, b, c, d] := C[a, b, c, d] + β * conj(D[a, c, d, b]) + @tensor backend = tblis E2[a, b, c, d] := C[a, b, c, d] + β * conj(D[a, c, d, b]) + @test collect(E2) ≈ E1 + end + + # @testset "tensortrace" begin + # A = randn(Float32, (5, 10, 10)) + # @tensor B1[a] := A[a, b′, b′] + # @tensor B2[a] := CuArray(A)[a, b′, b′] + # @test collect(B2) ≈ B1 + + # C = randn(ComplexF32, (3, 20, 5, 3, 20, 4, 5)) + # @tensor D1[e, a, d] := C[a, b, c, d, b, e, c] + # @tensor D2[e, a, d] := CuArray(C)[a, b, c, d, b, e, c] + # @test collect(D2) ≈ D1 + + # @tensor D3[a, e, d] := conj(C[a, b, c, d, b, e, c]) + # @tensor D4[a, e, d] := conj(CuArray(C)[a, b, c, d, b, e, c]) + # @test collect(D4) ≈ D3 + + # α = randn(ComplexF32) + # @tensor D5[d, e, a] := α * C[a, b, c, d, b, e, c] + # @tensor D6[d, e, a] := α * CuArray(C)[a, b, c, d, b, e, c] + # @test collect(D6) ≈ D5 + # end + + @testset "tensorcontract" begin + A = randn(Float32, (3, 20, 5, 3, 4)) + B = randn(Float32, (5, 6, 20, 3)) + @tensor C1[a, g, e, d, f] := A[a, b, c, d, e] * B[c, f, b, g] + @tensor backend = tblis C2[a, g, e, d, f] := A[a, b, c, d, e] * B[c, f, b, g] + @test C2 ≈ C1 + + D = randn(ComplexF64, (3, 3, 3)) + E = rand(ComplexF64, (3, 3, 3)) + @tensor F1[a, b, c, d, e, f] := D[a, b, c] * conj(E[d, e, f]) + @tensor backend = tblis F2[a, b, c, d, e, f] := D[a, b, c] * conj(E[d, e, f]) + @test F2 ≈ F1 atol = 1e-12 + end +end + +@testset "more complicated expressions" verbose = true begin + Da, Db, Dc, Dd, De, Df, Dg, Dh = 10, 15, 4, 8, 6, 7, 3, 2 + A = rand(ComplexF64, (Dc, Da, Df, Da, De, Db, Db, Dg)) + B = rand(ComplexF64, (Dc, Dh, Dg, De, Dd)) + C = rand(ComplexF64, (Dd, Dh, Df)) + α = rand(ComplexF64) + # α = 1 + + @tensor D1[d, f, h] := A[c, a, f, a, e, b, b, g] * B[c, h, g, e, d] + α * C[d, h, f] + @tensor backend = tblis D2[d, f, h] := A[c, a, f, a, e, b, b, g] * B[c, h, g, e, d] + + α * C[d, h, f] + @test D2 ≈ D1 rtol = 1e-8 + + @test norm(vec(D1)) ≈ sqrt(abs(@tensor D1[d, f, h] * conj(D1[d, f, h]))) + @test norm(D2) ≈ sqrt(abs(@tensor backend = tblis D2[d, f, h] * conj(D2[d, f, h]))) + + @testset "readme example" begin + α = randn() + A = randn(5, 5, 5, 5, 5, 5) + B = randn(5, 5, 5) + C = randn(5, 5, 5) + D = zeros(5, 5, 5) + D2 = copy(D) + @tensor begin + D[a, b, c] = A[a, e, f, c, f, g] * B[g, b, e] + α * C[c, a, b] + E[a, b, c] := A[a, e, f, c, f, g] * B[g, b, e] + α * C[c, a, b] + end + @tensor backend = tblis begin + D2[a, b, c] = A[a, e, f, c, f, g] * B[g, b, e] + α * C[c, a, b] + E2[a, b, c] := A[a, e, f, c, f, g] * B[g, b, e] + α * C[c, a, b] + end + @test D2 ≈ D + @test E2 ≈ E + end + + @testset "tensor network examples ($T)" for T in + (Float32, Float64, ComplexF32, ComplexF64) + D1, D2, D3 = 30, 40, 20 + d1, d2 = 2, 3 + + A1 = randn(T, D1, d1, D2) + A2 = randn(T, D2, d2, D3) + ρₗ = randn(T, D1, D1) + ρᵣ = randn(T, D3, D3) + H = randn(T, d1, d2, d1, d2) + + @tensor begin + HrA12[a, s1, s2, c] := ρₗ[a, a'] * A1[a', t1, b] * A2[b, t2, c'] * ρᵣ[c', c] * + H[s1, s2, t1, t2] + end + @tensor backend = tblis begin + HrA12′[a, s1, s2, c] := ρₗ[a, a'] * A1[a', t1, b] * A2[b, t2, c'] * ρᵣ[c', c] * + H[s1, s2, t1, t2] + end + @test HrA12′ ≈ HrA12 + + @tensor begin + E1 = ρₗ[a', a] * A1[a, s, b] * A2[b, s', c] * ρᵣ[c, c'] * H[t, t', s, s'] * + conj(A1[a', t, b']) * conj(A2[b', t', c']) + end + @tensor backend = tblis begin + E2 = ρₗ[a', a] * A1[a, s, b] * A2[b, s', c] * ρᵣ[c, c'] * H[t, t', s, s'] * + conj(A1[a', t, b']) * conj(A2[b', t', c']) + end + @test E2 ≈ E1 + end +end