janmartin has asked for the wisdom of the Perl Monks concerning the following question:
This is about Parallel::ForkManager on 64 bit strawberryperl.
I need to process 1000s of images. Each totally independent of the others.
Processing has CPU intensive parts, and parts that hardly use the CPU, but the GPU instead. The hardware has 8 cores, so I think of 8 processes? Each process to start multi-thread programs.
Each image is of different size, and I know the processing time is different according to it. Therefore processes should run a different length.
If a process is finished, a new process should start. To always have 8 processes.
This should level the CPU usage after a few rounds due to the different time each process runs. But it doesn't.
Looking at the Windows 8 Resource Monitor I see that all 8 processes run perfectly synchronized even after a long time.
It looks like 8 process are started, then only after all 8 are finished 8 new processes are started?
Code is straight from: http://search.cpan.org/~szabgab/Parallel-ForkManager-1.06/lib/Parallel/ForkManager.pm
use Parallel::ForkManager; ... @links=( ["http://www.foo.bar/rulez.data","rulez_data.txt"], ["http://new.host/more_data.doc","more_data.doc"], ... ); ... # Max 30 processes for parallel download my $pm = Parallel::ForkManager->new(30); foreach my $linkarray (@links) { $pm->start and next; # do the fork my ($link,$fn) = @$linkarray; warn "Cannot get $fn from $link" if getstore($link,$fn) != RC_OK; $pm->finish; # do the exit in the child process } $pm->wait_all_children;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parallel::ForkManager and CPU usage?
by BrowserUk (Patriarch) on Sep 19, 2014 at 15:58 UTC | |
|
Re: Parallel::ForkManager and CPU usage?
by Laurent_R (Canon) on Sep 19, 2014 at 21:38 UTC | |
by BrowserUk (Patriarch) on Sep 19, 2014 at 22:15 UTC | |
|
Re: Parallel::ForkManager and CPU usage?
by CountZero (Bishop) on Sep 19, 2014 at 19:45 UTC | |
|
Re: Parallel::ForkManager and CPU usage?
by codiac (Beadle) on Sep 20, 2014 at 02:35 UTC | |
|
Re: Parallel::ForkManager and CPU usage?
by locked_user sundialsvc4 (Abbot) on Sep 20, 2014 at 16:12 UTC | |
by Jenda (Abbot) on Sep 21, 2014 at 01:56 UTC | |
by karlgoethebier (Abbot) on Sep 20, 2014 at 18:02 UTC | |
| |
by trippledubs (Deacon) on Sep 23, 2014 at 02:09 UTC |