Skip to content

Commit

Permalink
Generate MTL and MPS structs and enums with Clang.jl (#492)
Browse files Browse the repository at this point in the history
* Add Docs and wrapping readme

Co-authored-by: Tim Besard <[email protected]>

---------

Co-authored-by: Tim Besard <[email protected]>
  • Loading branch information
christiangnrd and maleadt authored Dec 20, 2024
1 parent 84447c4 commit ea1d6ad
Show file tree
Hide file tree
Showing 31 changed files with 2,347 additions and 705 deletions.
6 changes: 5 additions & 1 deletion docs/src/faq/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ skip the first two steps.
2. Create high-level Julia structures and functionality
3. Create tests for added functionality

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

## Mapping to Metal Intrinsics

Some Metal functions map directly to Apple intermediate representation intrinsics. In this
Expand Down Expand Up @@ -134,4 +138,4 @@ their free time helping out. Most anything you're able to do is helpful, but if
stuck, seek guidance from Slack or Discourse. Don't feel like your contribution has to be
perfect. If you put in effort and make progress, there will likely be some senior developer
willing to polish your code before merging. Open-source software is a team effort...welcome
to the team!
to the team!
3 changes: 3 additions & 0 deletions lib/mps/MPS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Base.convert(::Type{MPSShape}, tuple::Union{Vector{N},NTuple{N, <:Integer}}) whe

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

# Load in generated enums and structs
include("libmps.jl")

include("size.jl")

# high-level wrappers
Expand Down
7 changes: 0 additions & 7 deletions lib/mps/copy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

export MPSMatrixCopyDescriptor

struct MPSMatrixCopyOffsets
sourceRowOffset::Cuint
sourceColumnOffset::Cuint
destinationRowOffset::Cuint
destinationColumnOffset::Cuint
end

@objcwrapper MPSMatrixCopyDescriptor <: NSObject

function MPSMatrixCopyDescriptor(sourceMatrix, destinationMatrix, offsets = MPSMatrixCopyOffsets(Cuint(0), Cuint(0), Cuint(0), Cuint(0)))
Expand Down
8 changes: 0 additions & 8 deletions lib/mps/decomposition.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
@cenum MPSMatrixDecompositionStatus::Cint begin
MPSMatrixDecompositionStatusSuccess = 0
MPSMatrixDecompositionStatusFailure = -1
MPSMatrixDecompositionStatusSingular = -2
MPSMatrixDecompositionStatusNonPositiveDefinite = -3
end


## lu

export MPSMatrixDecompositionLU, encode!
Expand Down
8 changes: 0 additions & 8 deletions lib/mps/images.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
## kernels

@cenum MPSImageEdgeMode::NSUInteger begin
MPSImageEdgeModeZero = 0
MPSImageEdgeModeClamp = 1
MPSImageEdgeModeMirror = 2
MPSImageEdgeModeMirrorWithEdge = 3
MPSImageEdgeModeConstant = 4
end

@objcwrapper immutable=false MPSUnaryImageKernel <: MPSKernel

@objcproperties MPSUnaryImageKernel begin
Expand Down
10 changes: 0 additions & 10 deletions lib/mps/kernel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@
# kernels
#

@cenum MPSKernelOptions::NSUInteger begin
MPSKernelOptionsNone = 0
MPSKernelOptionsSkipAPIValidation = 1 << 0
MPSKernelOptionsAllowReducedPrecision = 1 << 1
MPSKernelOptionsDisableInternalTiling = 1 << 2
MPSKernelOptionsInsertDebugGroups = 1 << 3
MPSKernelOptionsVerbose = 1 << 4
end


@objcwrapper MPSKernel <: NSObject

@objcproperties MPSKernel begin
Expand Down
Loading

0 comments on commit ea1d6ad

Please sign in to comment.