Skip to content

Commit ea1d6ad

Browse files
Generate MTL and MPS structs and enums with Clang.jl (#492)
* Add Docs and wrapping readme Co-authored-by: Tim Besard <[email protected]> --------- Co-authored-by: Tim Besard <[email protected]>
1 parent 84447c4 commit ea1d6ad

31 files changed

+2347
-705
lines changed

docs/src/faq/contributing.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ skip the first two steps.
3838
2. Create high-level Julia structures and functionality
3939
3. Create tests for added functionality
4040

41+
`struct`s and `enums` for Objective-C interfaces are automatically generated (see res/wrap/),
42+
so you should not have to define them. If using a struct for the first time in a higher-level
43+
interface, remember to add tests! You may need to define more functions around the structs.
44+
4145
## Mapping to Metal Intrinsics
4246

4347
Some Metal functions map directly to Apple intermediate representation intrinsics. In this
@@ -134,4 +138,4 @@ their free time helping out. Most anything you're able to do is helpful, but if
134138
stuck, seek guidance from Slack or Discourse. Don't feel like your contribution has to be
135139
perfect. If you put in effort and make progress, there will likely be some senior developer
136140
willing to polish your code before merging. Open-source software is a team effort...welcome
137-
to the team!
141+
to the team!

lib/mps/MPS.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Base.convert(::Type{MPSShape}, tuple::Union{Vector{N},NTuple{N, <:Integer}}) whe
2323

2424
is_supported(dev::MTLDevice) = ccall(:MPSSupportsMTLDevice, Bool, (id{MTLDevice},), dev)
2525

26+
# Load in generated enums and structs
27+
include("libmps.jl")
28+
2629
include("size.jl")
2730

2831
# high-level wrappers

lib/mps/copy.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22

33
export MPSMatrixCopyDescriptor
44

5-
struct MPSMatrixCopyOffsets
6-
sourceRowOffset::Cuint
7-
sourceColumnOffset::Cuint
8-
destinationRowOffset::Cuint
9-
destinationColumnOffset::Cuint
10-
end
11-
125
@objcwrapper MPSMatrixCopyDescriptor <: NSObject
136

147
function MPSMatrixCopyDescriptor(sourceMatrix, destinationMatrix, offsets = MPSMatrixCopyOffsets(Cuint(0), Cuint(0), Cuint(0), Cuint(0)))

lib/mps/decomposition.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
@cenum MPSMatrixDecompositionStatus::Cint begin
2-
MPSMatrixDecompositionStatusSuccess = 0
3-
MPSMatrixDecompositionStatusFailure = -1
4-
MPSMatrixDecompositionStatusSingular = -2
5-
MPSMatrixDecompositionStatusNonPositiveDefinite = -3
6-
end
7-
8-
91
## lu
102

113
export MPSMatrixDecompositionLU, encode!

lib/mps/images.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
## kernels
22

3-
@cenum MPSImageEdgeMode::NSUInteger begin
4-
MPSImageEdgeModeZero = 0
5-
MPSImageEdgeModeClamp = 1
6-
MPSImageEdgeModeMirror = 2
7-
MPSImageEdgeModeMirrorWithEdge = 3
8-
MPSImageEdgeModeConstant = 4
9-
end
10-
113
@objcwrapper immutable=false MPSUnaryImageKernel <: MPSKernel
124

135
@objcproperties MPSUnaryImageKernel begin

lib/mps/kernel.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22
# kernels
33
#
44

5-
@cenum MPSKernelOptions::NSUInteger begin
6-
MPSKernelOptionsNone = 0
7-
MPSKernelOptionsSkipAPIValidation = 1 << 0
8-
MPSKernelOptionsAllowReducedPrecision = 1 << 1
9-
MPSKernelOptionsDisableInternalTiling = 1 << 2
10-
MPSKernelOptionsInsertDebugGroups = 1 << 3
11-
MPSKernelOptionsVerbose = 1 << 4
12-
end
13-
14-
155
@objcwrapper MPSKernel <: NSObject
166

177
@objcproperties MPSKernel begin

0 commit comments

Comments
 (0)