[mpich-discuss] dividing the program
Mandar Gurav
mandarwce at gmail.com
Thu Feb 3 03:40:48 CST 2011
Hi Farooq,
I can give you the pseudo code for your program
main
{
1. Variable initialization .... (int p=26; char exstr[] )
2. MPI Init and all....
3. MPI_Bcast (&p, 1, MPI_INT, 0, MPI_COMM_WORLD);
4. If (myrank == 0) i.e. I am root/master....
{
declare one large array of size (int_size*100*no_of_processes)
this is something similar to two dimensional array stri[k][100]
only root/master needs to have it to gather results.... for
others you need only one array that is exstr[]....
}
5. your for loop...
> for (k=myrank+1;k<=p;k+=size)
> {
> here i am doing some manipulations on the some string string say exstr[]
> and store the result in the stri[k][100]
> }
6.Gather data into a large array of size (int_size*100*no_of_processes)
MPI_Gather( exstr, 100, MPI_INT, stri, 100, MPI_INT, root, MPI_COMM_WORLD);
(refer to
http://www.mcs.anl.gov/research/projects/mpi/www/www3/MPI_Gather.html
http://www.mcs.anl.gov/research/projects/mpi/mpi-standard/mpi-report-1.1/node70.htm
)
7.print/write to file the results of all processes sequentially from stri
8. MPI Finalize .....
}
I hope this helps you.....
---- Mandar Gurav
On Thu, Feb 3, 2011 at 10:45 AM, farooq farooq <farooqnmd1220 at gmail.com> wrote:
> hai friends
>
> i am new user now
> i am working on parallel programs
> ---------i want to devide the program such that
> p=26 is the integer
> stri[30][100] is the string empty array
> and i want to broadcast the p value to all the processes then to
> execute the following code
> for (k=myrank+1;k<=p;k+=size)
> {
> here i am doing some manipulations on the some string string say exstr[]
> and store the result in the stri[k][100]
> }
> at last i want to gather the result in
> stri[][] sequentially from all the processes
> and print the result of all processes sequentially from str[][]
> some one please help me in writing the code
> expecting the reply as early as possible
> --
> --------------------farooq
> _______________________________________________
> mpich-discuss mailing list
> mpich-discuss at mcs.anl.gov
> https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss
>
--
|||| Mandar Gurav ||||
More information about the mpich-discuss
mailing list