diff --git a/lib/mps/copy.jl b/lib/mps/copy.jl index fd13323fc..1a6b1893d 100644 --- a/lib/mps/copy.jl +++ b/lib/mps/copy.jl @@ -32,11 +32,11 @@ export MPSMatrixCopy @autoproperty destinationsAreTransposed::Bool end -function MPSMatrixCopy(device, copyRows, copyColumns, sourcesAreTransposed, destinationsAreTransposed) +function MPSMatrixCopy(dev, copyRows, copyColumns, sourcesAreTransposed, destinationsAreTransposed) kernel = @objc [MPSMatrixCopy alloc]::id{MPSMatrixCopy} obj = MPSMatrixCopy(kernel) finalizer(release, obj) - @objc [obj::id{MPSMatrixCopy} initWithDevice:device::id{MTLDevice} + @objc [obj::id{MPSMatrixCopy} initWithDevice:dev::id{MTLDevice} copyRows:copyRows::NSUInteger copyColumns:copyColumns::NSUInteger sourcesAreTransposed:sourcesAreTransposed::Bool diff --git a/lib/mps/decomposition.jl b/lib/mps/decomposition.jl index 8796367ff..8bf4f67ce 100644 --- a/lib/mps/decomposition.jl +++ b/lib/mps/decomposition.jl @@ -12,11 +12,11 @@ export MPSMatrixDecompositionLU @objcwrapper immutable=false MPSMatrixDecompositionLU <: MPSMatrixUnaryKernel -function MPSMatrixDecompositionLU(device, rows, columns) +function MPSMatrixDecompositionLU(dev, rows, columns) kernel = @objc [MPSMatrixDecompositionLU alloc]::id{MPSMatrixDecompositionLU} obj = MPSMatrixDecompositionLU(kernel) finalizer(release, obj) - @objc [obj::id{MPSMatrixDecompositionLU} initWithDevice:device::id{MTLDevice} + @objc [obj::id{MPSMatrixDecompositionLU} initWithDevice:dev::id{MTLDevice} rows:rows::NSUInteger columns:columns::NSUInteger]::id{MPSMatrixDecompositionLU} return obj @@ -37,11 +37,11 @@ export MPSMatrixDecompositionCholesky @objcwrapper immutable=false MPSMatrixDecompositionCholesky <: MPSMatrixUnaryKernel -function MPSMatrixDecompositionCholesky(device, lower, order) +function MPSMatrixDecompositionCholesky(dev, lower, order) kernel = @objc [MPSMatrixDecompositionCholesky alloc]::id{MPSMatrixDecompositionCholesky} obj = MPSMatrixDecompositionCholesky(kernel) finalizer(release, obj) - @objc [obj::id{MPSMatrixDecompositionCholesky} initWithDevice:device::id{MTLDevice} + @objc [obj::id{MPSMatrixDecompositionCholesky} initWithDevice:dev::id{MTLDevice} lower:lower::Bool order:order::NSUInteger]::id{MPSMatrixDecompositionCholesky} return obj diff --git a/lib/mps/images.jl b/lib/mps/images.jl index 8317e8a9b..c1b6d6f17 100644 --- a/lib/mps/images.jl +++ b/lib/mps/images.jl @@ -39,11 +39,11 @@ end @objcwrapper immutable=false MPSImageGaussianBlur <: MPSUnaryImageKernel -function MPSImageGaussianBlur(device, sigma) +function MPSImageGaussianBlur(dev, sigma) kernel = @objc [MPSImageGaussianBlur alloc]::id{MPSImageGaussianBlur} obj = MPSImageGaussianBlur(kernel) finalizer(release, obj) - @objc [obj::id{MPSImageGaussianBlur} initWithDevice:device::id{MTLDevice} + @objc [obj::id{MPSImageGaussianBlur} initWithDevice:dev::id{MTLDevice} sigma:sigma::Float32]::id{MPSImageGaussianBlur} return obj end @@ -51,11 +51,11 @@ end @objcwrapper immutable=false MPSImageBox <: MPSUnaryImageKernel -function MPSImageBox(device, kernelWidth, kernelHeight) +function MPSImageBox(dev, kernelWidth, kernelHeight) kernel = @objc [MPSImageBox alloc]::id{MPSImageBox} obj = MPSImageBox(kernel) finalizer(release, obj) - @objc [obj::id{MPSImageBox} initWithDevice:device::id{MTLDevice} + @objc [obj::id{MPSImageBox} initWithDevice:dev::id{MTLDevice} kernelWidth:kernelWidth::Int kernelHeight:kernelHeight::Int]::id{MPSImageBox} return obj diff --git a/lib/mps/matrix.jl b/lib/mps/matrix.jl index d8195c7a8..7e1604595 100644 --- a/lib/mps/matrix.jl +++ b/lib/mps/matrix.jl @@ -179,12 +179,12 @@ export MPSMatrixMultiplication, matmul! @autoproperty batchStart::NSUInteger setter=setBatchStart end -function MPSMatrixMultiplication(device, transposeLeft, transposeRight, resultRows, +function MPSMatrixMultiplication(dev, transposeLeft, transposeRight, resultRows, resultColumns, interiorColumns, alpha, beta) kernel = @objc [MPSMatrixMultiplication alloc]::id{MPSMatrixMultiplication} obj = MPSMatrixMultiplication(kernel) finalizer(release, obj) - @objc [obj::id{MPSMatrixMultiplication} initWithDevice:device::id{MTLDevice} + @objc [obj::id{MPSMatrixMultiplication} initWithDevice:dev::id{MTLDevice} transposeLeft:transposeLeft::Bool transposeRight:transposeRight::Bool resultRows:resultRows::NSUInteger @@ -253,11 +253,11 @@ export MPSMatrixFindTopK, topk, topk! @autoproperty sourceRows::NSInteger setter=setSourceRows end -function MPSMatrixFindTopK(device, numberOfTopKValues) +function MPSMatrixFindTopK(dev, numberOfTopKValues) kernel = @objc [MPSMatrixFindTopK alloc]::id{MPSMatrixFindTopK} obj = MPSMatrixFindTopK(kernel) finalizer(release, obj) - @objc [obj::id{MPSMatrixFindTopK} initWithDevice:device::id{MTLDevice} + @objc [obj::id{MPSMatrixFindTopK} initWithDevice:dev::id{MTLDevice} numberOfTopKValues:numberOfTopKValues::NSUInteger]::id{MPSMatrixFindTopK} return obj end @@ -343,11 +343,11 @@ end for f in (:MPSMatrixSoftMax, :MPSMatrixLogSoftMax) @eval begin - function $(f)(device) + function $(f)(dev) kernel = @objc [$(f) alloc]::id{$(f)} obj = $(f)(kernel) finalizer(release, obj) - @objc [obj::id{$(f)} initWithDevice:device::id{MTLDevice}]::id{$(f)} + @objc [obj::id{$(f)} initWithDevice:dev::id{MTLDevice}]::id{$(f)} return obj end diff --git a/lib/mps/vector.jl b/lib/mps/vector.jl index 90c1ef745..4de641dae 100644 --- a/lib/mps/vector.jl +++ b/lib/mps/vector.jl @@ -89,11 +89,11 @@ export MPSMatrixVectorMultiplication, matvecmul! @objcwrapper immutable=false MPSMatrixVectorMultiplication <: MPSMatrixBinaryKernel -function MPSMatrixVectorMultiplication(device, transpose, rows, columns, alpha, beta) +function MPSMatrixVectorMultiplication(dev, transpose, rows, columns, alpha, beta) kernel = @objc [MPSMatrixVectorMultiplication alloc]::id{MPSMatrixVectorMultiplication} obj = MPSMatrixVectorMultiplication(kernel) finalizer(release, obj) - @objc [obj::id{MPSMatrixVectorMultiplication} initWithDevice:device::id{MTLDevice} + @objc [obj::id{MPSMatrixVectorMultiplication} initWithDevice:dev::id{MTLDevice} transpose:transpose::Bool rows:rows::NSUInteger columns:columns::NSUInteger diff --git a/lib/mtl/device.jl b/lib/mtl/device.jl index af43081a5..ce6b2ad73 100644 --- a/lib/mtl/device.jl +++ b/lib/mtl/device.jl @@ -113,8 +113,8 @@ export supports_family, is_m3, is_m2, is_m1 MTLGPUFamilyMac2 = 2002 # Mac family 2 GPU features end -function supports_family(device::MTLDevice, gpufamily::MTLGPUFamily) - @objc [device::MTLDevice supportsFamily:gpufamily::MTLGPUFamily]::Bool +function supports_family(dev::MTLDevice, gpufamily::MTLGPUFamily) + @objc [dev::MTLDevice supportsFamily:gpufamily::MTLGPUFamily]::Bool end is_m1(dev::MTLDevice) = supports_family(dev, MTLGPUFamilyApple7) && diff --git a/lib/mtl/library.jl b/lib/mtl/library.jl index e83feaaa8..f9037b535 100644 --- a/lib/mtl/library.jl +++ b/lib/mtl/library.jl @@ -8,10 +8,10 @@ export MTLLibrary, MTLLibraryFromFile, MTLLibraryFromData @autoproperty functionNames::id{NSArray} type=Vector{NSString} end -function MTLLibrary(device::MTLDevice, src::String, +function MTLLibrary(dev::MTLDevice, src::String, opts::MTLCompileOptions=MTLCompileOptions()) err = Ref{id{NSError}}(nil) - handle = @objc [device::id{MTLDevice} newLibraryWithSource:src::id{NSString} + handle = @objc [dev::id{MTLDevice} newLibraryWithSource:src::id{NSString} options:opts::id{MTLCompileOptions} error:err::Ptr{id{NSError}}]::id{MTLLibrary} err[] == nil || throw(NSError(err[])) @@ -21,14 +21,14 @@ function MTLLibrary(device::MTLDevice, src::String, return obj end -function MTLLibraryFromFile(device::MTLDevice, path::String) +function MTLLibraryFromFile(dev::MTLDevice, path::String) err = Ref{id{NSError}}(nil) handle = if macos_version() >= v"13" url = NSFileURL(path) - @objc [device::id{MTLDevice} newLibraryWithURL:url::id{NSURL} + @objc [dev::id{MTLDevice} newLibraryWithURL:url::id{NSURL} error:err::Ptr{id{NSError}}]::id{MTLLibrary} else - @objc [device::id{MTLDevice} newLibraryWithFile:path::id{NSString} + @objc [dev::id{MTLDevice} newLibraryWithFile:path::id{NSString} error:err::Ptr{id{NSError}}]::id{MTLLibrary} end err[] == nil || throw(NSError(err[])) @@ -38,11 +38,11 @@ function MTLLibraryFromFile(device::MTLDevice, path::String) return obj end -function MTLLibraryFromData(device::MTLDevice, input_data) +function MTLLibraryFromData(dev::MTLDevice, input_data) err = Ref{id{NSError}}(nil) GC.@preserve input_data begin data = dispatch_data(pointer(input_data), sizeof(input_data)) - handle = @objc [device::id{MTLDevice} newLibraryWithData:data::dispatch_data_t + handle = @objc [dev::id{MTLDevice} newLibraryWithData:data::dispatch_data_t error:err::Ptr{id{NSError}}]::id{MTLLibrary} end err[] == nil || throw(NSError(err[])) diff --git a/lib/mtl/texture.jl b/lib/mtl/texture.jl index a51aa342d..de2e35726 100644 --- a/lib/mtl/texture.jl +++ b/lib/mtl/texture.jl @@ -197,8 +197,8 @@ end ## bitwise operations lose type information, so allow conversions Base.convert(::Type{MTLPixelFormat}, x::Integer) = MTLPixelFormat(x) -function minimumLinearTextureAlignmentForPixelFormat(device, format) - return @objc [device::MTLDevice minimumLinearTextureAlignmentForPixelFormat:format::MTLPixelFormat]::NSUInteger +function minimumLinearTextureAlignmentForPixelFormat(dev, format) + return @objc [dev::MTLDevice minimumLinearTextureAlignmentForPixelFormat:format::MTLPixelFormat]::NSUInteger end @cenum MTLTextureUsage::NSUInteger begin @@ -247,8 +247,8 @@ function MTLTexture(buffer, descriptor, offset, bytesPerRow) return obj end -function MTLTexture(device, descriptor) - texture = @objc [device::id{MTLDevice} newTextureWithDescriptor:descriptor::id{MTLTextureDescriptor}]::id{MTLTexture} +function MTLTexture(dev, descriptor) + texture = @objc [dev::id{MTLDevice} newTextureWithDescriptor:descriptor::id{MTLTextureDescriptor}]::id{MTLTexture} obj = MTLTexture(texture) finalizer(release, obj) diff --git a/test/mps/copy.jl b/test/mps/copy.jl index 3d4eb915a..fd2456cd8 100644 --- a/test/mps/copy.jl +++ b/test/mps/copy.jl @@ -4,8 +4,8 @@ using Metal, Test const IGNORE_UNION = Union{Complex, Int64, UInt64} function copytest(src, srctrans, dsttrans) - device = device() - queue = global_queue(device) + dev = device() + queue = global_queue(dev) dst = if srctrans == dsttrans similar(src) else @@ -23,7 +23,7 @@ function copytest(src, srctrans, dsttrans) dstMPS = MPS.MPSMatrix(dst) copydesc = MPS.MPSMatrixCopyDescriptor(srcMPS, dstMPS) - copykern = MPS.MPSMatrixCopy(device, cprows, cpcols, srctrans, dsttrans) + copykern = MPS.MPSMatrixCopy(dev, cprows, cpcols, srctrans, dsttrans) MPS.encode!(cbuf, copykern, copydesc) end wait_completed(cmdbuf)