@@ -722,15 +722,16 @@ let a = zeros(nthreads())
722
722
end
723
723
724
724
# static schedule
725
- function _atthreads_static_schedule ()
726
- ids = zeros (Int, nthreads () )
727
- Threads. @threads :static for i = 1 : nthreads ()
725
+ function _atthreads_static_schedule (n )
726
+ ids = zeros (Int, n )
727
+ Threads. @threads :static for i = 1 : n
728
728
ids[i] = Threads. threadid ()
729
729
end
730
730
return ids
731
731
end
732
- @test _atthreads_static_schedule () == [1 : nthreads ();]
733
- @test_throws TaskFailedException @threads for i = 1 : 1 ; _atthreads_static_schedule (); end
732
+ @test _atthreads_static_schedule (nthreads ()) == [1 : nthreads ();]
733
+ @test _atthreads_static_schedule (1 ) == [1 ;]
734
+ @test_throws TaskFailedException @threads for i = 1 : 1 ; _atthreads_static_schedule (nthreads ()); end
734
735
735
736
# dynamic schedule
736
737
function _atthreads_dynamic_schedule (n)
@@ -757,8 +758,7 @@ function _atthreads_dynamic_dynamic_schedule()
757
758
end
758
759
return inc[]
759
760
end
760
- inc = _atthreads_dynamic_dynamic_schedule ()
761
- @test inc == nthreads () * nthreads ()
761
+ @test _atthreads_dynamic_dynamic_schedule () == nthreads () * nthreads ()
762
762
763
763
function _atthreads_static_dynamic_schedule ()
764
764
ids = zeros (Int, nthreads ())
@@ -771,9 +771,16 @@ function _atthreads_static_dynamic_schedule()
771
771
end
772
772
return ids, inc[]
773
773
end
774
- ids, inc = _atthreads_static_dynamic_schedule ()
775
- @test ids == [1 : nthreads ();]
776
- @test inc == nthreads () * nthreads ()
774
+ @test _atthreads_static_dynamic_schedule () == ([1 : nthreads ();], nthreads () * nthreads ())
775
+
776
+ # errors inside @threads :dynamic
777
+ function _atthreads_dynamic_with_error (a)
778
+ Threads. @threads :dynamic for i in eachindex (a)
779
+ error (" failed" )
780
+ end
781
+ a
782
+ end
783
+ @test_throws TaskFailedException _atthreads_dynamic_with_error (zeros (nthreads ()))
777
784
778
785
try
779
786
@macroexpand @threads (for i = 1 : 10 , j = 1 : 10 ; end )
0 commit comments