rachanaj has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use Parallel::MPI qw(:all); # Start up MPI MPI_Init(); # Find out process rank $my_rank = MPI_Comm_rank(MPI_COMM_WORLD); # Find out number of processes $num_procs = MPI_Comm_size(MPI_COMM_WORLD); $infilename = "sequences.txt"; open(INFILE, $infilename); @sequences = <INFILE>; close(INFILE); $num_seq = $#sequences + 1; $seq_per_file = int $num_seq / $num_procs; $start_seq = $my_rank * $seq_per_file; if ($my_rank < $num_procs) { $end_seq = ($my_rank + 1) * $seq_per_file - 1; } else #deal with last processor separately { $end_seq = $num_seq; } foreach ($start_seq..$end_seq) { ; #Stuff to do with sequences } MPI_Finalize();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MPI Module
by muntfish (Chaplain) on Nov 26, 2004 at 10:28 UTC | |
|
Re: MPI Module
by BUU (Prior) on Nov 26, 2004 at 10:16 UTC |