Skip to content

Commit

Permalink
rocBLAS: Generate new bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsamaroo committed Mar 8, 2023
1 parent 68f2a1a commit cbc005a
Show file tree
Hide file tree
Showing 10 changed files with 2,884 additions and 316 deletions.
16 changes: 8 additions & 8 deletions gen/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.9.0-DEV"
julia_version = "1.9.0-beta4"
manifest_format = "2.0"
project_hash = "3d1c3440c5f5d2f04d75370d10d97474962219fe"
project_hash = "26a57bd5ee5b16d5abc45095c0840c2c659a6a22"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
Expand Down Expand Up @@ -33,9 +33,9 @@ version = "0.16.6"

[[deps.Clang_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "TOML", "Zlib_jll", "libLLVM_jll"]
git-tree-sha1 = "c7c8938a36b2ab8e5eb9b6c937ba5049e1e666fa"
git-tree-sha1 = "b88c99c9093f9db49a40d0715ea0e3ae5bbd91f7"
uuid = "0ee61d77-7f21-5576-8119-9fcc46b10100"
version = "14.0.6+0"
version = "14.0.6+2"

[[deps.Dates]]
deps = ["Printf"]
Expand Down Expand Up @@ -113,9 +113,9 @@ version = "1.42.0+0"

[[deps.Libiconv_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "42b62845d70a619f063a7da093d995ec8e15e778"
git-tree-sha1 = "c7cb1f5d892775ba13767a87c7ada0b980ea0a71"
uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531"
version = "1.16.1+1"
version = "1.16.1+2"

[[deps.Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
Expand Down Expand Up @@ -152,7 +152,7 @@ version = "1.2.0"
[[deps.Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
version = "1.8.0"
version = "1.9.0"

[[deps.Preferences]]
deps = ["TOML"]
Expand Down Expand Up @@ -209,7 +209,7 @@ uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
[[deps.TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
version = "1.0.0"
version = "1.0.3"

[[deps.Tar]]
deps = ["ArgTools", "SHA"]
Expand Down
1 change: 1 addition & 0 deletions gen/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
MIOpen_jll = "2409bb75-d5ef-542a-ac68-1cfd4c37dc24"
hsa_rocr_jll = "dd59ff1a-a01a-568d-8b29-0669330f116a"
rocBLAS_jll = "1ef8cab2-a151-54b4-a57f-5fbb4046a4ab"
18 changes: 18 additions & 0 deletions gen/rocblas/generator.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Clang.Generators
using rocBLAS_jll

include_dir = normpath(rocBLAS_jll.artifact_dir, "include")
rocblas_dir = joinpath(include_dir, "rocblas")
options = load_options("rocblas/rocblas-generator.toml")

args = get_default_args()
push!(args, "-I$include_dir")

headers = [
joinpath(rocblas_dir, header)
for header in readdir(rocblas_dir)
if endswith(header, ".h")
]

ctx = create_context(headers, args, options)
build!(ctx)
6 changes: 6 additions & 0 deletions gen/rocblas/rocblas-generator.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[general]
module_name = "LibrocBLAS"
library_name = "librocblas"
output_file_path = "./librocblas.jl"
jll_pkg_name = "rocBLAS_jll"
export_symbol_prefixes = []
22 changes: 11 additions & 11 deletions src/blas/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@ export ROCBLASError
import .AMDGPU: @check, check

struct ROCBLASError <: Exception
code::rocblas_status_t
code::rocblas_status
msg::AbstractString
end
Base.show(io::IO, err::ROCBLASError) = print(io, "ROCBLASError(code $(err.code), $(err.msg))")

function ROCBLASError(code::rocblas_status_t)
function ROCBLASError(code::rocblas_status)
msg = status_message(code)
return ROCBLASError(code, msg)
end

function status_message(status)
if status == ROCBLAS_STATUS_SUCCESS
if status == rocblas_status_success
return "the operation completed successfully"
elseif status == ROCBLAS_STATUS_INVALID_HANDLE
elseif status == rocblas_status_invalid_handle
return "handle not initialized, invalid or null"
elseif status == ROCBLAS_STATUS_NOT_IMPLEMENTED
elseif status == rocblas_status_not_implemented
return "this function is not implemented"
elseif status == ROCBLAS_STATUS_INVALID_POINTER
elseif status == rocblas_status_invalid_pointer
return "invalid pointer parameter"
elseif status == ROCBLAS_STATUS_INVALID_SIZE
elseif status == rocblas_status_invalid_size
return "invalid size parameter"
elseif status == ROCBLAS_STATUS_MEMORY_ERROR
elseif status == rocblas_status_memory_error
return "failed internal memory allocation, copy or dealloc"
elseif status == ROCBLAS_STATUS_INTERNAL_ERROR
elseif status == rocblas_status_internal_error
return "an internal operation failed"
else
return "unknown status"
end
end

function check(status::rocblas_status_t)
if status != ROCBLAS_STATUS_SUCCESS
function check(status::rocblas_status)
if status != rocblas_status_success
throw(ROCBLASError(status))
end
return status
Expand Down
Loading

0 comments on commit cbc005a

Please sign in to comment.