@@ -9,7 +9,7 @@ addprocs(2)
9
9
using ParallelUtilities
10
10
import ParallelUtilities: BinaryTreeNode, RemoteChannelContainer, BranchChannel,
11
11
Sorted, Unsorted, Ordering, pval, value, reducedvalue, reduceTreeNode,
12
- BinaryTree, parentnoderank, nchildren, infer_returntypes
12
+ BinaryTree, parentnoderank, nchildren, infer_returntypes, maybepvalput!
13
13
end
14
14
15
15
@testset " ProductSplit" begin
772
772
@testset " pval" begin
773
773
p = pval (myid (),3 )
774
774
q = pval (3 )
775
- @test p == q
775
+ r = pval {Int} (3.0 )
776
+ s = pval {Int} (3 )
777
+ @test p == q == r == s
776
778
@test value (p) == 3
777
779
@test value (3 ) == 3
778
780
@test value (p) == value (q)
@@ -785,36 +787,77 @@ end
785
787
@testset " infer_returntypes" begin
786
788
iterable = 1 : 10
787
789
iterators = (iterable,)
790
+ iteratorsPS = evenlyscatterproduct (iterators,1 ,1 )
788
791
fmap = x -> 1
789
792
fred = sum
790
793
@test infer_returntypes (fmap,fred,iterators) == (Int,Int)
791
- @test infer_returntypes (fmap,fred,iterable) == (Int,Int)
792
- @test infer_returntypes (fmap,fred,Iterators. product (iterable)) == (Int,Int)
794
+ @test infer_returntypes (fmap,fred,iteratorsPS) == (Int,Int)
793
795
794
796
fmap = x-> ones (Int,1 )
795
797
fred = x-> hcat (x... )
796
798
@test infer_returntypes (fmap,fred,iterators) == (Vector{Int},Matrix{Int})
797
- @test infer_returntypes (fmap,fred,iterable) == (Vector{Int},Matrix{Int})
798
- @test infer_returntypes (fmap,fred,Iterators. product (iterable)) == (Vector{Int},Matrix{Int})
799
+ @test infer_returntypes (fmap,fred,iteratorsPS) == (Vector{Int},Matrix{Int})
800
+
801
+ fmap (x:: ProductSplit ,y) = sum (i[1 ] for i in x) + y
802
+ fred = sum
803
+ @test infer_returntypes (fmap,fred,iteratorsPS,1 ) == (Int,Int)
799
804
end
800
805
801
806
@testset " mapTreeNode" begin
802
807
803
808
@testset " maybepvalput!" begin
804
809
pipe = BranchChannel {Int,Int} (0 )
805
- ParallelUtilities . maybepvalput! (pipe,0 )
810
+ maybepvalput! (pipe,0 )
806
811
@test isready (pipe. selfchannels. out)
807
812
@test take! (pipe. selfchannels. out) == 0
808
813
809
814
pipe = BranchChannel {pval,pval} (0 )
810
- ParallelUtilities . maybepvalput! (pipe,0 )
815
+ maybepvalput! (pipe,0 )
811
816
@test isready (pipe. selfchannels. out)
812
817
@test take! (pipe. selfchannels. out) == pval (0 )
813
818
814
819
pipe = BranchChannel {pval{Int},pval{Int}} (0 )
815
- ParallelUtilities . maybepvalput! (pipe,0 )
820
+ maybepvalput! (pipe,0 )
816
821
@test isready (pipe. selfchannels. out)
817
822
@test take! (pipe. selfchannels. out) == pval (0 )
823
+
824
+ T = Vector{ComplexF64}
825
+ pipe = BranchChannel {pval{T},pval{T}} (1 )
826
+
827
+ val = ones (1 ).* im
828
+ maybepvalput! (pipe,val)
829
+ @test isready (pipe. selfchannels. out)
830
+ @test take! (pipe. selfchannels. out) == pval (ComplexF64[im])
831
+
832
+ val = ones (1 )
833
+ maybepvalput! (pipe,val)
834
+ @test isready (pipe. selfchannels. out)
835
+ @test take! (pipe. selfchannels. out) == pval (ComplexF64[1 ])
836
+
837
+ T = Vector{Float64}
838
+ pipe = BranchChannel {pval{T},pval{T}} (1 )
839
+
840
+ val = ones (1 )
841
+ maybepvalput! (pipe,val)
842
+ @test isready (pipe. selfchannels. out)
843
+ @test take! (pipe. selfchannels. out) == pval (Float64[1 ])
844
+
845
+ val = ones (Int,1 )
846
+ maybepvalput! (pipe,val)
847
+ @test isready (pipe. selfchannels. out)
848
+ @test take! (pipe. selfchannels. out) == pval (Float64[1 ])
849
+
850
+ pipe = BranchChannel {pval,pval} (1 )
851
+
852
+ val = ones (1 )
853
+ maybepvalput! (pipe,val)
854
+ @test isready (pipe. selfchannels. out)
855
+ @test take! (pipe. selfchannels. out) == pval (Float64[1 ])
856
+
857
+ val = ones (Int,1 )
858
+ maybepvalput! (pipe,val)
859
+ @test isready (pipe. selfchannels. out)
860
+ @test take! (pipe. selfchannels. out) == pval (Int[1 ])
818
861
end
819
862
820
863
function test_on_pipe (fn,iterator,pipe,result_expected)
@@ -1082,14 +1125,19 @@ end
1082
1125
res_exp = sum (1 : nworkers ())
1083
1126
@test pmapsum (x-> workerrank (),Int,1 : nworkers ()) == res_exp
1084
1127
@test pmapsum (x-> workerrank (),1 : nworkers ()) == res_exp
1128
+ @test pmapsum (x-> workerrank (),1 : nworkers (),infer_types = false ) == res_exp
1085
1129
@test pmapsum (x-> workerrank (),Int,(1 : nworkers (),)) == res_exp
1086
1130
@test pmapsum (x-> workerrank (),(1 : nworkers (),)) == res_exp
1131
+ @test pmapsum (x-> workerrank (),(1 : nworkers (),),infer_types = false ) == res_exp
1087
1132
@test pmapsum (x-> workerrank (),Int,Iterators. product (1 : nworkers ())) == res_exp
1088
1133
@test pmapsum (x-> workerrank (),Iterators. product (1 : nworkers ())) == res_exp
1134
+ @test pmapsum (x-> workerrank (),Iterators. product (1 : nworkers ()),infer_types = false ) == res_exp
1089
1135
@test pmapsum (x-> workerrank (),Int,(1 : nworkers (),1 : 1 )) == res_exp
1090
1136
@test pmapsum (x-> workerrank (),(1 : nworkers (),1 : 1 )) == res_exp
1137
+ @test pmapsum (x-> workerrank (),(1 : nworkers (),1 : 1 ),infer_types = false ) == res_exp
1091
1138
@test pmapsum (x-> workerrank (),Int,Iterators. product (1 : nworkers (),1 : 1 )) == res_exp
1092
1139
@test pmapsum (x-> workerrank (),Iterators. product (1 : nworkers (),1 : 1 )) == res_exp
1140
+ @test pmapsum (x-> workerrank (),Iterators. product (1 : nworkers (),1 : 1 ),infer_types = false ) == res_exp
1093
1141
@test pmapsum (x-> myid (),1 : nworkers ()) == sum (workers ())
1094
1142
end
1095
1143
@@ -1123,7 +1171,7 @@ end
1123
1171
end
1124
1172
1125
1173
@testset " errors" begin
1126
- @test_throws exceptiontype pmapsum (x-> throws ( BoundsError () ),1 : 10 )
1174
+ @test_throws exceptiontype pmapsum (x-> error ( " map " ),1 : 10 )
1127
1175
end
1128
1176
end
1129
1177
@@ -1159,7 +1207,7 @@ end
1159
1207
end
1160
1208
1161
1209
@testset " errors" begin
1162
- @test_throws exceptiontype pmapsum_elementwise (x-> throws ( BoundsError () ),1 : 10 )
1210
+ @test_throws exceptiontype pmapsum_elementwise (x-> error ( " hi " ),1 : 10 )
1163
1211
end
1164
1212
end
1165
1213
@@ -1175,14 +1223,19 @@ end
1175
1223
res_exp = sum (workers ())
1176
1224
@test pmapreduce_commutative (x-> myid (),Int,sum,Int,1 : nworkers ()) == res_exp
1177
1225
@test pmapreduce_commutative (x-> myid (),sum,1 : nworkers ()) == res_exp
1226
+ @test pmapreduce_commutative (x-> myid (),sum,1 : nworkers (),infer_types = false ) == res_exp
1178
1227
@test pmapreduce_commutative (x-> myid (),Int,sum,Int,(1 : nworkers (),)) == res_exp
1179
1228
@test pmapreduce_commutative (x-> myid (),sum,(1 : nworkers (),)) == res_exp
1229
+ @test pmapreduce_commutative (x-> myid (),sum,(1 : nworkers (),),infer_types = false ) == res_exp
1180
1230
@test pmapreduce_commutative (x-> myid (),Int,sum,Int,Iterators. product (1 : nworkers ())) == res_exp
1181
1231
@test pmapreduce_commutative (x-> myid (),sum,Iterators. product (1 : nworkers ())) == res_exp
1232
+ @test pmapreduce_commutative (x-> myid (),sum,Iterators. product (1 : nworkers ()),infer_types = false ) == res_exp
1182
1233
@test pmapreduce_commutative (x-> myid (),Int,sum,Int,(1 : nworkers (),1 : 1 )) == res_exp
1183
1234
@test pmapreduce_commutative (x-> myid (),sum,(1 : nworkers (),1 : 1 )) == res_exp
1235
+ @test pmapreduce_commutative (x-> myid (),sum,(1 : nworkers (),1 : 1 ),infer_types = false ) == res_exp
1184
1236
@test pmapreduce_commutative (x-> myid (),Int,sum,Int,Iterators. product (1 : nworkers (),1 : 1 )) == res_exp
1185
1237
@test pmapreduce_commutative (x-> myid (),sum,Iterators. product (1 : nworkers (),1 : 1 )) == res_exp
1238
+ @test pmapreduce_commutative (x-> myid (),sum,Iterators. product (1 : nworkers (),1 : 1 ),infer_types = false ) == res_exp
1186
1239
@test pmapreduce_commutative (x-> myid (),sum,1 : nworkers ()) == pmapsum (x-> myid (),1 : nworkers ())
1187
1240
end
1188
1241
@testset " prod" begin
@@ -1203,12 +1256,11 @@ end
1203
1256
1204
1257
@testset " errors" begin
1205
1258
@test_throws exceptiontype pmapreduce_commutative (
1206
- x-> throws ( BoundsError () ),sum,1 : 10 )
1259
+ x-> error ( " map " ),sum,1 : 10 )
1207
1260
@test_throws exceptiontype pmapreduce_commutative (
1208
- identity,x-> throws ( BoundsError () ),1 : 10 )
1261
+ identity,x-> error ( " reduce " ),1 : 10 )
1209
1262
@test_throws exceptiontype pmapreduce_commutative (
1210
- x-> throw (ErrorException (" eh" )),
1211
- x-> throws (BoundsError ()),1 : 10 )
1263
+ x-> error (" map" ),x-> error (" reduce" ),1 : 10 )
1212
1264
end
1213
1265
@testset " type coercion" begin
1214
1266
@test_throws exceptiontype pmapreduce_commutative (x-> [1.1 ],Vector{Int},
@@ -1250,12 +1302,12 @@ end
1250
1302
1251
1303
@testset " errors" begin
1252
1304
@test_throws exceptiontype pmapreduce_commutative_elementwise (
1253
- x-> throws ( BoundsError () ),sum,1 : 10 )
1305
+ x-> error ( " map " ),sum,1 : 10 )
1254
1306
@test_throws exceptiontype pmapreduce_commutative_elementwise (
1255
- identity,x-> throws ( BoundsError () ),1 : 10 )
1307
+ identity,x-> error ( " reduce " ),1 : 10 )
1256
1308
@test_throws exceptiontype pmapreduce_commutative_elementwise (
1257
- x-> throw ( ErrorException ( " eh " ) ),
1258
- x-> throws ( BoundsError () ),1 : 10 )
1309
+ x-> error ( " map " ),
1310
+ x-> error ( " reduce " ),1 : 10 )
1259
1311
end
1260
1312
end
1261
1313
end
@@ -1266,14 +1318,18 @@ end
1266
1318
res_exp = sum (workers ())
1267
1319
@test pmapreduce (x-> myid (),Int,sum,Int,1 : nworkers ()) == res_exp
1268
1320
@test pmapreduce (x-> myid (),sum,1 : nworkers ()) == res_exp
1321
+ @test pmapreduce (x-> myid (),sum,1 : nworkers (),infer_types = false ) == res_exp
1269
1322
@test pmapreduce (x-> myid (),Int,sum,Int,(1 : nworkers (),)) == res_exp
1270
1323
@test pmapreduce (x-> myid (),sum,(1 : nworkers (),)) == res_exp
1324
+ @test pmapreduce (x-> myid (),sum,(1 : nworkers (),),infer_types = false ) == res_exp
1271
1325
@test pmapreduce (x-> myid (),Int,sum,Int,Iterators. product (1 : nworkers ())) == res_exp
1272
1326
@test pmapreduce (x-> myid (),sum,Iterators. product (1 : nworkers ())) == res_exp
1273
1327
@test pmapreduce (x-> myid (),Int,sum,Int,(1 : nworkers (),1 : 1 )) == res_exp
1274
1328
@test pmapreduce (x-> myid (),sum,(1 : nworkers (),1 : 1 )) == res_exp
1329
+ @test pmapreduce (x-> myid (),sum,(1 : nworkers (),1 : 1 ),infer_types = false ) == res_exp
1275
1330
@test pmapreduce (x-> myid (),Int,sum,Int,Iterators. product (1 : nworkers (),1 : 1 )) == res_exp
1276
1331
@test pmapreduce (x-> myid (),sum,Iterators. product (1 : nworkers (),1 : 1 )) == res_exp
1332
+ @test pmapreduce (x-> myid (),sum,Iterators. product (1 : nworkers (),1 : 1 ),infer_types = false ) == res_exp
1277
1333
@test pmapreduce (x-> myid (),Int,sum,Int,1 : nworkers ()) == pmapsum (x-> myid (),Int,1 : nworkers ())
1278
1334
@test pmapreduce (x-> myid (),Int,sum,Int,1 : nworkers ()) == pmapsum (x-> myid (),1 : nworkers ())
1279
1335
@test pmapreduce (x-> myid (),sum,1 : nworkers ()) == pmapsum (x-> myid (),1 : nworkers ())
@@ -1285,6 +1341,7 @@ end
1285
1341
@test pmapreduce (x-> ones (2 ),Vector{Float64},
1286
1342
x-> vcat (x... ),Vector{Float64},1 : nworkers ()) == res_vcat
1287
1343
@test pmapreduce (x-> ones (2 ),x-> vcat (x... ),1 : nworkers ()) == res_vcat
1344
+ @test pmapreduce (x-> ones (2 ),x-> vcat (x... ),1 : nworkers (),infer_types = false ) == res_vcat
1288
1345
@test pmapreduce (x-> ones (2 ),Vector{Float64},
1289
1346
x-> hcat (x... ),Matrix{Float64},1 : nworkers ()) == res_hcat
1290
1347
@test pmapreduce (x-> ones (2 ),x-> hcat (x... ),1 : nworkers ()) == res_hcat
@@ -1308,10 +1365,9 @@ end
1308
1365
end
1309
1366
1310
1367
@testset " errors" begin
1311
- @test_throws exceptiontype pmapreduce (x-> throws (BoundsError ()),sum,1 : 10 )
1312
- @test_throws exceptiontype pmapreduce (identity,x-> throws (BoundsError ()),1 : 10 )
1313
- @test_throws exceptiontype pmapreduce (x-> throw (ErrorException (" eh" )),
1314
- x-> throws (BoundsError ()),1 : 10 )
1368
+ @test_throws exceptiontype pmapreduce (x-> error (" map" ),sum,1 : 10 )
1369
+ @test_throws exceptiontype pmapreduce (identity,x-> error (" reduce" ),1 : 10 )
1370
+ @test_throws exceptiontype pmapreduce (x-> error (" map" ),x-> error (" reduce" ),1 : 10 )
1315
1371
end
1316
1372
1317
1373
@testset " type coercion" begin
0 commit comments