Skip to content

Commit

Permalink
SPIRVIntrinsics: add import/export helpers. (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt authored Oct 22, 2024
1 parent a3ca010 commit 2c81f84
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ LinearAlgebra = "1"
OpenCL_jll = "=2024.5.8"
Printf = "1"
Reexport = "1"
SPIRVIntrinsics = "0.1"
SPIRVIntrinsics = "0.2"
SPIRV_LLVM_Translator_unified_jll = "0.6"
StaticArrays = "1"
julia = "1.10"
2 changes: 1 addition & 1 deletion lib/intrinsics/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SPIRVIntrinsics"
uuid = "71d1d633-e7e8-4a92-83a1-de8814b09ba8"
authors = ["Tim Besard <[email protected]>"]
version = "0.1.1"
version = "0.2.0"

[deps]
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
Expand Down
26 changes: 26 additions & 0 deletions lib/intrinsics/src/SPIRVIntrinsics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,30 @@ include("math.jl")
include("integer.jl")
include("atomic.jl")

# helper macro to import all names from this package, even non-exported ones.
macro import_all()
code = quote end

for name in names(SPIRVIntrinsics; all=true)
# bring all the names of this module in scope
name in (:SPIRVIntrinsics, :eval, :include) && continue
startswith(string(name), "#") && continue
push!(code.args, :(using .SPIRVIntrinsics: $name))
end

return code
end

# helper macro to re-export public names from this package
macro reexport_public()
code = quote end

for name in names(SPIRVIntrinsics)
name == :SPIRVIntrinsics && continue
push!(code.args, :(export $name))
end

return code
end

end
19 changes: 2 additions & 17 deletions src/OpenCL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,8 @@ export cl
# device functionality
include("device/runtime.jl")
import SPIRVIntrinsics
let
# re-export functionality from SPIRVIntrinsics
for name in names(SPIRVIntrinsics)
name == :SPIRVIntrinsics && continue
@eval export $name
end

# import all the others so that the user can refer to them through the OpenCL module
for name in names(SPIRVIntrinsics; all=true)
# bring all the names of this module in scope
name in (:SPIRVIntrinsics, :eval, :include) && continue
startswith(string(name), "#") && continue
@eval begin
using .SPIRVIntrinsics: $name
end
end
end
SPIRVIntrinsics.@import_all
SPIRVIntrinsics.@reexport_public
include("device/array.jl")
include("device/quirks.jl")

Expand Down

2 comments on commit 2c81f84

@maleadt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register subdir="lib/intrinsics"

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/117814

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a intrinsics-v0.2.0 -m "<description of version>" 2c81f84ba90e6f3443b728b93df39f4db6bb5174
git push origin intrinsics-v0.2.0

Please sign in to comment.