Skip to content

Commit

Permalink
Merge branch 'JuliaGPU:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
vovw authored Jan 29, 2025
2 parents a047a11 + 1b811cb commit b7ec84f
Show file tree
Hide file tree
Showing 43 changed files with 4,226 additions and 720 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ KernelAbstractions = "0.9.1"
LLVM = "7.2, 8, 9"
LLVMDowngrader_jll = "0.6"
LinearAlgebra = "1"
ObjectiveC = "3.2"
ObjectiveC = "3.3"
PrecompileTools = "1"
Preferences = "1"
Printf = "1"
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ importing the package:
julia> using Metal
julia> Metal.versioninfo()
macOS 15.0.0, Darwin 24.0.0
macOS 15.3.0, Darwin 24.3.0
Toolchain:
- Julia: 1.11.0
- Julia: 1.11.3
- LLVM: 16.0.6
Julia packages:
- Metal.jl: 1.4.0
- GPUArrays: 10.3.1
- GPUCompiler: 0.27.8
- KernelAbstractions: 0.9.27
- ObjectiveC: 3.1.0
- LLVM: 9.1.2
- LLVMDowngrader_jll: 0.3.0+1
- Metal.jl: 1.5.1
- GPUArrays: 11.2.1
- GPUCompiler: 1.1.0
- KernelAbstractions: 0.9.33
- ObjectiveC: 3.3.0
- LLVM: 9.2.0
- LLVMDowngrader_jll: 0.6.0+0
1 device:
- Apple M2 Max (64.000 KiB allocated)
Expand Down
5 changes: 3 additions & 2 deletions docs/src/faq/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +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/),
Objective-C object definitions, `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.
interface, remember to add tests! Objective-C object methods and constructors are not yet automtically
generatied, so any contributions there are welcome.

## Mapping to Metal Intrinsics

Expand Down
11 changes: 1 addition & 10 deletions lib/mps/command_buf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,7 @@
# - intermediate commits during encoding of MPS work using `commitAndContinue`
#

# XXX: Not actually inheritance but MPSCommandBuffer conforms to MTLCommandBuffer protocol
@objcwrapper MPSCommandBuffer <: MTLCommandBuffer

@objcproperties MPSCommandBuffer begin
# Identifying the Command Buffer
@autoproperty commandBuffer::id{MTLCommandBuffer}
# @autoproperty heapProvider::id{MPSHeapProvider}
# @autoproperty predicate::id{MPSPredicate}
@autoproperty rootCommandBuffer::id{MTLCommandBuffer}
end
# @objcwrapper MPSCommandBuffer <: MTLCommandBuffer

function MPSCommandBuffer(commandBuffer::MTLCommandBuffer)
handle = @objc [MPSCommandBuffer commandBufferWithCommandBuffer:commandBuffer::id{MTLCommandBuffer}]::id{MPSCommandBuffer}
Expand Down
11 changes: 2 additions & 9 deletions lib/mps/copy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export MPSMatrixCopyDescriptor

@objcwrapper MPSMatrixCopyDescriptor <: NSObject
# @objcwrapper MPSMatrixCopyDescriptor <: NSObject

function MPSMatrixCopyDescriptor(sourceMatrix, destinationMatrix, offsets = MPSMatrixCopyOffsets(Cuint(0), Cuint(0), Cuint(0), Cuint(0)))
desc = @objc [MPSMatrixCopyDescriptor descriptorWithSourceMatrix:sourceMatrix::id{MPSMatrix}
Expand All @@ -16,14 +16,7 @@ end

export MPSMatrixCopy, encode!

@objcwrapper immutable=false MPSMatrixCopy <: MPSKernel

@objcproperties MPSMatrixCopy begin
@autoproperty copyRows::NSUInteger
@autoproperty copyColumns::NSUInteger
@autoproperty sourcesAreTransposed::Bool
@autoproperty destinationsAreTransposed::Bool
end
# @objcwrapper immutable=false MPSMatrixCopy <: MPSKernel

function MPSMatrixCopy(dev, copyRows, copyColumns, sourcesAreTransposed, destinationsAreTransposed)
kernel = @objc [MPSMatrixCopy alloc]::id{MPSMatrixCopy}
Expand Down
4 changes: 2 additions & 2 deletions lib/mps/decomposition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export MPSMatrixDecompositionLU, encode!

@objcwrapper immutable=false MPSMatrixDecompositionLU <: MPSMatrixUnaryKernel
# @objcwrapper immutable=false MPSMatrixDecompositionLU <: MPSMatrixUnaryKernel

function MPSMatrixDecompositionLU(dev, rows, columns)
kernel = @objc [MPSMatrixDecompositionLU alloc]::id{MPSMatrixDecompositionLU}
Expand All @@ -27,7 +27,7 @@ end

export MPSMatrixDecompositionCholesky, encode!

@objcwrapper immutable=false MPSMatrixDecompositionCholesky <: MPSMatrixUnaryKernel
# @objcwrapper immutable=false MPSMatrixDecompositionCholesky <: MPSMatrixUnaryKernel

function MPSMatrixDecompositionCholesky(dev, lower, order)
kernel = @objc [MPSMatrixDecompositionCholesky alloc]::id{MPSMatrixDecompositionCholesky}
Expand Down
23 changes: 4 additions & 19 deletions lib/mps/images.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
## kernels

@objcwrapper immutable=false MPSUnaryImageKernel <: MPSKernel

@objcproperties MPSUnaryImageKernel begin
@autoproperty offset::MPSOffset
@autoproperty clipRect::MTLRegion
@autoproperty edgeMode::MPSImageEdgeMode setter=setEdgeMode
end
# @objcwrapper immutable=false MPSUnaryImageKernel <: MPSKernel

function encode!(cmdbuf::MTLCommandBuffer, kernel::K, sourceTexture::MTLTexture, destinationTexture::MTLTexture) where {K<:MPSUnaryImageKernel}
@objc [kernel::id{K} encodeToCommandBuffer:cmdbuf::id{MTLCommandBuffer}
Expand All @@ -21,22 +15,13 @@ end
# fallbackCopyAllocator:copyAllocator::MPSCopyAllocator]::Bool
# end

@objcwrapper immutable=false MPSBinaryImageKernel <: MPSKernel

@objcproperties MPSBinaryImageKernel begin
@autoproperty primaryOffset::MPSOffset
@autoproperty secondaryOffset::MPSOffset
@autoproperty primaryEdgeMode::MPSImageEdgeMode
@autoproperty secondaryEdgeMode::MPSImageEdgeMode
@autoproperty clipRect::MTLRegion
end

# @objcwrapper immutable=false MPSBinaryImageKernel <: MPSKernel

## gaussian blur

export MPSImageGaussianBlur, encode!

@objcwrapper immutable=false MPSImageGaussianBlur <: MPSUnaryImageKernel
# @objcwrapper immutable=false MPSImageGaussianBlur <: MPSUnaryImageKernel

function MPSImageGaussianBlur(dev, sigma)
kernel = @objc [MPSImageGaussianBlur alloc]::id{MPSImageGaussianBlur}
Expand All @@ -52,7 +37,7 @@ end

export MPSImageBox

@objcwrapper immutable=false MPSImageBox <: MPSUnaryImageKernel
# @objcwrapper immutable=false MPSImageBox <: MPSUnaryImageKernel

function MPSImageBox(dev, kernelWidth, kernelHeight)
kernel = @objc [MPSImageBox alloc]::id{MPSImageBox}
Expand Down
28 changes: 3 additions & 25 deletions lib/mps/kernel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,13 @@
# kernels
#

@objcwrapper MPSKernel <: NSObject

@objcproperties MPSKernel begin
@autoproperty options::MPSKernelOptions setter=setOptions
@autoproperty device::id{MTLDevice}
@autoproperty label::id{NSString} setter=setLabel
end
# @objcwrapper MPSKernel <: NSObject

@autoreleasepool function Base.copy(kernel::K) where {K <: MPSKernel}
obj = @objc [kernel::MPSKernel copy]::id{MPSKernel}
K(reinterpret(id{K}, obj))
end

@objcwrapper immutable=false MPSMatrixUnaryKernel <: MPSKernel

@objcproperties MPSMatrixUnaryKernel begin
@autoproperty sourceMatrixOrigin::id{MTLOrigin} setter=setSourceMatrixOrigin
@autoproperty resultMatrixOrigin::id{MTLOrigin} setter=setResultMatrixOrigin
@autoproperty batchStart::NSUInteger setter=setBatchStart
@autoproperty batchSize::NSUInteger setter=setBatchSize
end
# @objcwrapper immutable=false MPSMatrixUnaryKernel <: MPSKernel


@objcwrapper immutable=false MPSMatrixBinaryKernel <: MPSKernel

@objcproperties MPSMatrixBinaryKernel begin
@autoproperty primarySourceMatrixOrigin::id{MTLOrigin} setter=setPrimarySourceMatrixOrigin
@autoproperty secondarySourceMatrixOrigin::id{MTLOrigin} setter=setSecondarySourceMatrixOrigin
@autoproperty resultMatrixOrigin::id{MTLOrigin} setter=setResultMatrixOrigin
@autoproperty batchStart::NSUInteger setter=setBatchStart
@autoproperty batchSize::NSUInteger setter=setBatchSize
end
# @objcwrapper immutable=false MPSMatrixBinaryKernel <: MPSKernel
Loading

0 comments on commit b7ec84f

Please sign in to comment.