36
36
@test collect (ps) == collect (split_product_across_processors_iterators (iters,np,p))
37
37
@test ntasks (ps) == ntasks_total
38
38
@test ntasks (ps. iterators) == ntasks_total
39
+ @test eltype (ps) == Tuple{map (eltype,iters)... }
39
40
end
40
41
41
42
@test_throws ParallelUtilities. ProcessorNumberError ProductSplit (iters,npmax,npmax+ 1 )
45
46
@test_throws ArgumentError ProductSplit ((),2 ,1 )
46
47
end
47
48
49
+ @testset " cumprod" begin
50
+ @test ParallelUtilities. _cumprod (1 ,()) == ()
51
+ @test ParallelUtilities. _cumprod (1 ,(2 ,)) == (1 ,)
52
+ @test ParallelUtilities. _cumprod (1 ,(2 ,3 )) == (1 ,2 )
53
+ @test ParallelUtilities. _cumprod (1 ,(2 ,3 ,4 )) == (1 ,2 ,6 )
54
+ end
55
+
48
56
@testset " 1D" begin
49
57
iters = (1 : 10 ,)
50
58
checkPSconstructor (iters)
92
100
93
101
@testset " firstlast" begin
94
102
@testset " first" begin
103
+
104
+ @test ParallelUtilities. _first (()) == ()
105
+
95
106
for iters in [(1 : 10 ,),(1 : 10 ,4 : 6 ),(1 : 10 ,4 : 6 ,1 : 4 ),(1 : 2 : 10 ,4 : 1 : 6 )],
96
107
np= 1 : 5 ntasks (iters)
97
108
104
115
@test first (ps) === nothing
105
116
end
106
117
@testset " last" begin
118
+
119
+ @test ParallelUtilities. _last (()) == ()
120
+
107
121
for iters in [(1 : 10 ,),(1 : 10 ,4 : 6 ),(1 : 10 ,4 : 6 ,1 : 4 ),(1 : 2 : 10 ,4 : 1 : 6 )],
108
122
np= 1 : 5 ntasks (iters)
109
123
144
158
end
145
159
146
160
@testset " extremadims" begin
161
+ ps = ProductSplit ((1 : 10 ,),2 ,1 )
162
+ @test ParallelUtilities. _extremadims (ps,1 ,()) == ()
147
163
for iters in [(1 : 10 ,),(1 : 10 ,4 : 6 ),(1 : 10 ,4 : 6 ,1 : 4 ),(1 : 2 : 10 ,4 : 1 : 6 )]
148
164
dims = length (iters)
149
165
for np = 1 : 5 ntasks (iters), proc_id = 1 : np
190
206
for iters in [(1 : 10 ,),(1 : 10 ,4 : 6 ),(1 : 10 ,4 : 6 ,1 : 4 ),(1 : 2 : 10 ,4 : 1 : 6 )]
191
207
checkifpresent (iters)
192
208
end
209
+
210
+ @test ParallelUtilities. _infullrange ((),())
193
211
end
194
212
195
213
@testset " evenlyscatterproduct" begin
268
286
end
269
287
270
288
@testset " getindex" begin
289
+
290
+ @test ParallelUtilities. _getindex ((),1 ) == ()
291
+ @test ParallelUtilities. _getindex ((),1 ,2 ) == ()
292
+
293
+ @test ParallelUtilities. childindex ((),1 ) == (1 ,)
294
+
271
295
for iters in [(1 : 10 ,),(1 : 10 ,4 : 6 ),(1 : 10 ,4 : 6 ,1 : 4 ),(1 : 2 : 10 ,4 : 1 : 6 )]
272
296
for np= 1 : ntasks (iters),p= 1 : np
273
297
ps = ProductSplit (iters,np,p)
430
454
@testset " worker id" begin
431
455
@test pmapsum (x-> workerrank (),1 : nworkers ()) == sum (1 : nworkers ())
432
456
@test pmapsum (x-> workerrank (),(1 : nworkers (),)) == sum (1 : nworkers ())
457
+ @test pmapsum (x-> workerrank (),Iterators. product (1 : nworkers ())) == sum (1 : nworkers ())
433
458
@test pmapsum (x-> workerrank (),(1 : nworkers (),1 : 1 )) == sum (1 : nworkers ())
459
+ @test pmapsum (x-> workerrank (),Iterators. product (1 : nworkers (),1 : 1 )) == sum (1 : nworkers ())
434
460
@test pmapsum (x-> myid (),1 : nworkers ()) == sum (workers ())
435
461
end
436
462
465
491
iterable = 1 : 100
466
492
res = pmapsum_elementwise (identity,iterable)
467
493
@test res == sum (iterable)
494
+ res = pmapsum_elementwise (identity,Iterators. product (iterable))
495
+ @test res == sum (iterable)
496
+ res = pmapsum_elementwise (identity,(iterable,))
497
+ @test res == sum (iterable)
468
498
469
499
iterable = 1 : 100
470
500
res = pmapsum_elementwise (x-> x^ 2 ,iterable)
@@ -483,13 +513,17 @@ end
483
513
@testset " sum" begin
484
514
@test pmapreduce_commutative (x-> myid (),sum,1 : nworkers ()) == sum (workers ())
485
515
@test pmapreduce_commutative (x-> myid (),sum,(1 : nworkers (),)) == sum (workers ())
516
+ @test pmapreduce_commutative (x-> myid (),sum,Iterators. product (1 : nworkers ())) == sum (workers ())
486
517
@test pmapreduce_commutative (x-> myid (),sum,(1 : nworkers (),1 : 1 )) == sum (workers ())
518
+ @test pmapreduce_commutative (x-> myid (),sum,Iterators. product (1 : nworkers (),1 : 1 )) == sum (workers ())
487
519
@test pmapreduce_commutative (x-> myid (),sum,1 : nworkers ()) == pmapsum (x-> myid (),1 : nworkers ())
488
520
end
489
521
@testset " prod" begin
490
522
@test pmapreduce_commutative (x-> myid (),prod,1 : nworkers ()) == prod (workers ())
491
523
@test pmapreduce_commutative (x-> myid (),prod,(1 : nworkers (),)) == prod (workers ())
524
+ @test pmapreduce_commutative (x-> myid (),prod,Iterators. product (1 : nworkers ())) == prod (workers ())
492
525
@test pmapreduce_commutative (x-> myid (),prod,(1 : nworkers (),1 : 1 )) == prod (workers ())
526
+ @test pmapreduce_commutative (x-> myid (),prod,Iterators. product (1 : nworkers (),1 : 1 )) == prod (workers ())
493
527
end
494
528
495
529
@testset " errors" begin
509
543
@test res == sum (x-> x^ 2 ,iter)
510
544
@test res == pmapsum_elementwise (x-> x^ 2 ,iter)
511
545
@test res == pmapsum (plist-> sum (x[1 ]^ 2 for x in plist),iter)
546
+ res = pmapreduce_commutative_elementwise (x-> x^ 2 ,sum,(iter,))
547
+ @test res == sum (x-> x^ 2 ,iter)
548
+ res = pmapreduce_commutative_elementwise (x-> x^ 2 ,sum,Iterators. product (iter))
549
+ @test res == sum (x-> x^ 2 ,iter)
512
550
end
513
551
514
552
@testset " errors" begin
528
566
@testset " sum" begin
529
567
@test pmapreduce (x-> myid (),sum,1 : nworkers ()) == sum (workers ())
530
568
@test pmapreduce (x-> myid (),sum,(1 : nworkers (),)) == sum (workers ())
569
+ @test pmapreduce (x-> myid (),sum,Iterators. product (1 : nworkers ())) == sum (workers ())
531
570
@test pmapreduce (x-> myid (),sum,(1 : nworkers (),1 : 1 )) == sum (workers ())
571
+ @test pmapreduce (x-> myid (),sum,Iterators. product (1 : nworkers (),1 : 1 )) == sum (workers ())
532
572
@test pmapreduce (x-> myid (),sum,1 : nworkers ()) == pmapsum (x-> myid (),1 : nworkers ())
533
573
end
534
574
0 commit comments