.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "MCE::Util 3pm" .TH MCE::Util 3pm "2023-09-29" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" MCE::Util \- Utility functions .SH "VERSION" .IX Header "VERSION" This document describes MCE::Util version 1.889 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use MCE::Util; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" A utility module for \s-1MCE.\s0 Nothing is exported by default. Exportable is get_ncpu. .SS "\fBget_ncpu()\fP" .IX Subsection "get_ncpu()" Returns the number of logical (online/active/enabled) \s-1CPU\s0 cores; never smaller than one. .PP .Vb 1 \& my $ncpu = MCE::Util::get_ncpu(); .Ve .PP Specifying 'auto' for max_workers calls MCE::Util::get_ncpu automatically. \&\s-1MCE 1.521\s0 sets an upper-limit when specifying 'auto'. The reason is mainly to safeguard apps from spawning 100 workers on a box having 100 cores. This is important for apps which are IO-bound. .PP .Vb 1 \& use MCE; \& \& ## \*(AqAuto\*(Aq is the total # of logical cores (lcores) (8 maximum, MCE 1.521). \& ## The computed value will not exceed the # of logical cores on the box. \& \& my $mce = MCE\->new( \& \& max_workers => \*(Aqauto\*(Aq, ## 1 on HW with 1\-lcores; 2 on 2\-lcores \& max_workers => 16, ## 16 on HW with 4\-lcores; 16 on 32\-lcores \& \& max_workers => \*(Aqauto\*(Aq, ## 4 on HW with 4\-lcores; 8 on 16\-lcores \& max_workers => \*(Aqauto*1.5\*(Aq, ## 4 on HW with 4\-lcores; 12 on 16\-lcores \& max_workers => \*(Aqauto*2.0\*(Aq, ## 4 on HW with 4\-lcores; 16 on 16\-lcores \& max_workers => \*(Aqauto/2.0\*(Aq, ## 2 on HW with 4\-lcores; 4 on 16\-lcores \& max_workers => \*(Aqauto+3\*(Aq, ## 4 on HW with 4\-lcores; 11 on 16\-lcores \& max_workers => \*(Aqauto\-1\*(Aq, ## 3 on HW with 4\-lcores; 7 on 16\-lcores \& \& max_workers => MCE::Util::get_ncpu, ## run on all lcores \& ); .Ve .PP In summary: .PP .Vb 5 \& 1. Auto has an upper\-limit of 8 in MCE 1.521 (# of lcores, 8 maximum) \& 2. Math may be applied with auto (*/+\-) to change the upper limit \& 3. The computed value for auto will not exceed the total # of lcores \& 4. One can specify max_workers explicitly to a hard value \& 5. MCE::Util::get_ncpu returns the actual # of lcores .Ve .SH "ACKNOWLEDGMENTS" .IX Header "ACKNOWLEDGMENTS" The portable code for detecting the number of processors was adopted from Test::Smoke::SysInfo. .SH "INDEX" .IX Header "INDEX" \&\s-1MCE\s0, MCE::Core .SH "AUTHOR" .IX Header "AUTHOR" Mario E. Roy,