1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#undef SEEK_SET
#undef SEEK_END
#undef SEEK_CUR
#include <mpi.h>
#include <iostream>
#include <cstdlib>
using namespace std;
/*************************************************
* copyright © 2013 Soheil Hooshdaran *
* The purpose of this program is to sort a *
* nember of randomly generated numbers *
*************************************************/
void generate( int *A/*, m, n, r)*/)
{
/*********initialize random seed*********/
srand( time(0) );
for(int i = 0;i<10;++i)
A[i] = rand() % 10 + 1;
}
/**************************************/
int main( /*int argc, char*argv[]*/)
{
/***************Executed on all processors**************/
int *A; //Array to hold numbers
int i, j, k; //Loop indices
int n, r; //Used as the range for numbers
int m; //m numbers will be generated
/*
m = atoll( argv[1]);
n = atoll( argv[2]);
r = atoll( argv[3]);
*/
A = new int[10];
for(int j=0;j<10;++j)
A[j] = 0;
generate(A/*, m, n, r*/);
for(int j=0;j<m;++j)
cout << A[j];
/*
MPI_Init(&argc, &argv);
int iWorldSize;
MPI_Comm_size( MPI_COMM_WORLD, &iWorldSize);
MPI_Comm_rank( MPI_COMM_WORLD, &iRank);
/***************Executed on all processors**************/
/* if(iRank==0) //The processor is the master processor
{
}
}//END IF processor is the root
}//End Else the processor is a slave
MPI_Finalize();
*/
return 0;
}
|