@@ -720,13 +720,33 @@ const map_del_wrkr = Set{Int}()
720
720
myid()
721
721
722
722
Get the id of the current process.
723
+
724
+ # Examples
725
+ ```julia-repl
726
+ julia> myid()
727
+ 1
728
+
729
+ julia> remotecall_fetch(() -> myid(), 4)
730
+ 4
731
+ ```
723
732
"""
724
733
myid () = LPROC. id
725
734
726
735
"""
727
736
nprocs()
728
737
729
738
Get the number of available processes.
739
+
740
+ # Examples
741
+ ```julia-repl
742
+ julia> nprocs()
743
+ 3
744
+
745
+ julia> workers()
746
+ 5-element Array{Int64,1}:
747
+ 2
748
+ 3
749
+ ```
730
750
"""
731
751
function nprocs ()
732
752
if myid () == 1 || (PGRP. topology == :all_to_all && ! isclusterlazy ())
746
766
"""
747
767
nworkers()
748
768
749
- Get the number of available worker processes. This is one less than `nprocs()`. Equal to
769
+ Get the number of available worker processes. This is one less than [ `nprocs()`](@ref) . Equal to
750
770
`nprocs()` if `nprocs() == 1`.
771
+
772
+ # Examples
773
+ ```julia-repl
774
+ \$ julia -p 5
775
+
776
+ julia> nprocs()
777
+ 6
778
+
779
+ julia> nworkers()
780
+ 5
781
+ ```
751
782
"""
752
783
function nworkers ()
753
784
n = nprocs ()
757
788
"""
758
789
procs()
759
790
760
- Return a list of all process identifiers.
791
+ Return a list of all process identifiers, including pid 1 (which is not included by [`workers()`](@ref)).
792
+
793
+ # Examples
794
+ ```julia-repl
795
+ \$ julia -p 5
796
+
797
+ julia> procs()
798
+ 3-element Array{Int64,1}:
799
+ 1
800
+ 2
801
+ 3
802
+ ```
761
803
"""
762
804
function procs ()
763
805
if myid () == 1 || (PGRP. topology == :all_to_all && ! isclusterlazy ())
809
851
workers()
810
852
811
853
Return a list of all worker process identifiers.
854
+
855
+ # Examples
856
+ ```julia-repl
857
+ \$ julia -p 5
858
+
859
+ julia> workers()
860
+ 2-element Array{Int64,1}:
861
+ 2
862
+ 3
863
+ ```
812
864
"""
813
865
function workers ()
814
866
allp = procs ()
@@ -832,13 +884,29 @@ Remove the specified workers. Note that only process 1 can add or remove
832
884
workers.
833
885
834
886
Argument `waitfor` specifies how long to wait for the workers to shut down:
835
- - If unspecified, `rmprocs` will wait until all requested `pids` are removed.
836
- - An `ErrorException` is raised if all workers cannot be terminated before
837
- the requested `waitfor` seconds.
838
- - With a `waitfor` value of 0, the call returns immediately with the workers
839
- scheduled for removal in a different task. The scheduled `Task` object is
840
- returned. The user should call `wait` on the task before invoking any other
841
- parallel calls.
887
+ - If unspecified, `rmprocs` will wait until all requested `pids` are removed.
888
+ - An [`ErrorException`](@ref) is raised if all workers cannot be terminated before
889
+ the requested `waitfor` seconds.
890
+ - With a `waitfor` value of 0, the call returns immediately with the workers
891
+ scheduled for removal in a different task. The scheduled [`Task`](@ref) object is
892
+ returned. The user should call [`wait`](@ref) on the task before invoking any other
893
+ parallel calls.
894
+
895
+ # Examples
896
+ ```julia-repl
897
+ \$ julia -p 5
898
+
899
+ julia> t = rmprocs(2, 3, waitfor=0)
900
+ Task (runnable) @0x0000000107c718d0
901
+
902
+ julia> wait(t)
903
+
904
+ julia> workers()
905
+ 3-element Array{Int64,1}:
906
+ 4
907
+ 5
908
+ 6
909
+ ```
842
910
"""
843
911
function rmprocs (pids... ; waitfor= typemax (Int))
844
912
cluster_mgmt_from_master_check ()
0 commit comments