Skip to content

Commit

Permalink
Replace variables/arguments named device to dev
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangnrd committed Jun 15, 2024
1 parent 19bfe8d commit c1cc2e5
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions lib/mps/copy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/mps/decomposition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/mps/images.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ 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


@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
Expand Down
12 changes: 6 additions & 6 deletions lib/mps/matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/mps/vector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/mtl/device.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down
14 changes: 7 additions & 7 deletions lib/mtl/library.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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[]))
Expand All @@ -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[]))
Expand All @@ -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[]))
Expand Down
8 changes: 4 additions & 4 deletions lib/mtl/texture.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions test/mps/copy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit c1cc2e5

Please sign in to comment.