@@ -36,6 +36,15 @@ using ChainRulesCore: add!!, is_inplaceable_destination
36
36
@test collect (CUDA. fill (0 , 2 , 2 )) == zeros (Float32, 2 , 2 )
37
37
@test collect (CUDA. fill (1 , 2 , 2 )) == ones (Float32, 2 , 2 )
38
38
39
+ # undef with various forms of dims
40
+ let xs = CuArray {Int, 1, CUDA.DeviceMemory} (undef, (64 ,))
41
+ @test size (xs) == (64 ,)
42
+ end
43
+ let xs = CuArray {Int, 1, CUDA.DeviceMemory} ()
44
+ @test size (xs) == (0 ,)
45
+ end
46
+ # cu with too many memory types
47
+ @test_throws ArgumentError (" Can only specify one of `device`, `unified`, or `host`" ) cu ([1 ]; device= true , host= true )
39
48
let
40
49
@gensym typnam
41
50
typ = @eval begin
62
71
@test_throws ErrorException CuArray {MyBadType, 1} (undef, 64 )
63
72
@test_throws ErrorException CuArray {MyBadType2, 1} (undef, 64 )
64
73
@test_throws ErrorException CuArray {MyBadType3, 1} (undef, 64 )
74
+ @test_throws ErrorException CuArray {BigFloat, 1} (undef, 64 )
65
75
end
66
76
67
77
@testset " synchronization" begin
93
103
@test size (b) == (1 ,)
94
104
end
95
105
end
106
+ let a = cu ([1 ]; device= true )
107
+ p = pointer (a)
108
+ @test_throws ArgumentError (" Can only create a CPU array object from a unified or host CUDA array" ) unsafe_wrap (Array, p, 1 )
109
+ end
96
110
97
111
# unmanaged memory -> CuArray
98
112
# note that the device-side pointer may differ from the host one (i.e., on Tegra)
@@ -747,13 +761,17 @@ end
747
761
748
762
let
749
763
a = CuVector {Int,CUDA.DeviceMemory} (undef, 1 )
764
+ @test is_device (a)
765
+ @test ! is_host (a)
750
766
@test ! is_unified (a)
751
767
@test ! is_managed (pointer (a))
752
768
end
753
769
754
770
let
755
771
a = CuVector {Int,CUDA.UnifiedMemory} (undef, 1 )
772
+ @test ! is_device (a)
756
773
@test is_unified (a)
774
+ @test ! is_host (a)
757
775
@test is_managed (pointer (a))
758
776
a .= 0
759
777
@test Array (a) == [0 ]
0 commit comments