Skip to content

Commit d14426c

Browse files
Move MTL tests and add a few (#491)
1 parent e6abcc6 commit d14426c

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

lib/mtl/device.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ MTLDevice(i::Integer) = devices()[i]
9393

9494
export supports_family, is_m3, is_m2, is_m1
9595

96-
@cenum MTLGPUFamily::NSUInteger begin
96+
@cenum MTLGPUFamily::NSInteger begin
9797
MTLGPUFamilyMetal3 = 5001 # Metal 3 support
9898

9999
MTLGPUFamilyApple9 = 1009 # M3, M4 & A17

lib/mtl/heap.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# heap enums
33
#
44

5-
@cenum MTLHeapType::NSUInteger begin
5+
@cenum MTLHeapType::NSInteger begin
66
MTLHeapTypeAutomatic = 0
77
MTLHeapTypePlacement = 1
88
end

lib/mtl/size.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ struct MTLRegion
3737
origin::MTLOrigin # The top-left corner of the region
3838
size::MTLSize # The size of the region
3939

40-
MTLRegion(x=0, y=0, z=0) = new(x, y, z)
40+
MTLRegion(origin=MTLOrigin(), size=MTLSize()) = new(origin, size)
4141
end

test/metal.jl renamed to test/mtl/metal.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ let lib = MTLLibrary(dev, "", opts)
6767
@test isempty(lib.functionNames)
6868
end
6969

70-
metal_code = read(joinpath(@__DIR__, "dummy.metal"), String)
70+
metal_code = read(joinpath(@__DIR__, "..", "dummy.metal"), String)
7171
let lib = MTLLibrary(dev, metal_code, opts)
7272
@test lib.device == dev
7373
@test lib.label === nothing
@@ -77,7 +77,7 @@ let lib = MTLLibrary(dev, metal_code, opts)
7777
@test "kernel_2" in fns
7878
end
7979

80-
binary_path = joinpath(@__DIR__, "dummy.metallib")
80+
binary_path = joinpath(@__DIR__, "..", "dummy.metallib")
8181
let lib = MTLLibraryFromFile(dev, binary_path)
8282
@test lib.device == dev
8383
@test lib.label === nothing
@@ -119,7 +119,7 @@ desc.specializedName = "MySpecializedKernel"
119119

120120

121121
dev = first(devices())
122-
lib = MTLLibraryFromFile(dev, joinpath(@__DIR__, "dummy.metallib"))
122+
lib = MTLLibraryFromFile(dev, joinpath(@__DIR__, "..", "dummy.metallib"))
123123
fun = MTLFunction(lib, "kernel_1")
124124

125125
compact_str = sprint(io->show(io, fun))
@@ -347,7 +347,7 @@ end
347347
@testset "compute pipeline" begin
348348

349349
dev = first(devices())
350-
lib = MTLLibraryFromFile(dev, joinpath(@__DIR__, "dummy.metallib"))
350+
lib = MTLLibraryFromFile(dev, joinpath(@__DIR__, "..", "dummy.metallib"))
351351
fun = MTLFunction(lib, "kernel_1")
352352

353353
pipeline = MTLComputePipelineState(dev, fun)
@@ -390,7 +390,7 @@ end
390390
@testset "binary archive" begin
391391

392392
dev = first(devices())
393-
lib = MTLLibraryFromFile(dev, joinpath(@__DIR__, "dummy.metallib"))
393+
lib = MTLLibraryFromFile(dev, joinpath(@__DIR__, "..", "dummy.metallib"))
394394
fun = MTLFunction(lib, "kernel_1")
395395

396396
desc = MTLBinaryArchiveDescriptor()

test/mtl/size.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@testset "size.jl" begin
2+
@testset "size" begin
3+
dim1 = rand(UInt64)
4+
dim2 = rand(UInt64)
5+
dim3 = rand(UInt64)
6+
7+
@test MTL.MTLSize(dim1) == MTL.MTLSize((dim1,))
8+
@test MTL.MTLSize(dim1,dim2) == MTL.MTLSize((dim1,dim2))
9+
@test MTL.MTLSize(dim1,dim2,dim3) == MTL.MTLSize((dim1,dim2,dim3))
10+
end
11+
12+
@testset "origin" begin
13+
dim1 = rand(UInt64)
14+
dim2 = rand(UInt64)
15+
dim3 = rand(UInt64)
16+
17+
orig = MTL.MTLOrigin(dim1,dim2,dim3)
18+
@test orig.x == dim1
19+
@test orig.y == dim2
20+
@test orig.z == dim3
21+
end
22+
23+
@testset "region" begin
24+
reg = MTL.MTLRegion()
25+
@test reg.origin isa MTL.MTLOrigin
26+
@test reg.size isa MTL.MTLSize
27+
end
28+
end

0 commit comments

Comments
 (0)