Всё откомпелировалось нормально.запускал через Linux Ubuntu.а теперь у меня задача запустить эту прогу на линуксе только уже с помощью OpenMP а не MPI.как мне это сделать?
Код:
#include<mpi.h>
#include<stdlib.h>
#include<stdio.h>
#define Wtime MPI_Wtime
#define MEGABYTE (1024*1024)
#define BUFFER_SIZE (16*MEGABYTE)
#define TAG1 17
#define MASTER_RANK 0
#define MAX_REQUESTS 16
#define MILLION 1000000.0
static int NTIMES = 1000;
static int NTIMES_PREC = 10000;
static int REPEAT_ALL = 1;
static int REPEAT_EACH_TEST = 1;
#define NTIMES_TIMING NTIMES_PREC
#define NTIMES_BARRIER NTIMES_PREC
#define NTIMES_LATENCY NTIMES_PREC
#define TEST_SENDRECV 0
#define MASTER if(i_am_the_master)
int nproc,myid,rank,pool_size;
int i_am_the_master = 0;
static int msglen_min = 1;
static int msglen_max = 1000;
static int msglen_multiplier = 10;
static int msglen_step = 0;
int *buf,*obuf;
FILE *out;
/* йНЕОБ РТПГЕУУПТПЧ, ЙМЙ ХЪМПЧ, ОБ ЛПФПТЩИ ТБВПФБАФ РТПГЕУУЩ ЪБДБЮЙ */
static char nodename[32];
static char* nodenames;
int namelen = 32;
void Test_MPI_Routines(MPI_Comm comm,int len);
int checktick();
int main(int argc,char *argv[]) {
int i,k;
int bufsize = BUFFER_SIZE;
int msglen;
double t_start,t_end;
char processor_name[128],output_file_name[128];
int namelen = 128;
MPI_Status status;
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD,&nproc);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);
i_am_the_master = (myid == MASTER_RANK);
rank = myid;
pool_size = nproc;
out = stdout;
t_start = Wtime();
MASTER printf("MPItest/C 2.1: running %d processes...\n",nproc);
if(nproc < 2) {
MASTER printf("MPItest expects at least 2 processes\n");
MPI_Finalize();
exit(0);
}
MASTER /* read command line parameters */
for(i = 1; i < argc; i ++)
switch(argv[i][0]) {
case 'm': msglen_min = atoi(argv[i]+1); break;
case 'M': msglen_max = atoi(argv[i]+1); break;
case 'K': msglen_multiplier = atoi(argv[i]+1); msglen_step = 0; break;
case 'T': NTIMES = atoi(argv[i]+1); break;
case 't': NTIMES_PREC = atoi(argv[i]+1); break;
case 'R': REPEAT_ALL = atoi(argv[i]+1); break;
case 'r': REPEAT_EACH_TEST = atoi(argv[i]+1); break;
case 'b': bufsize = (atoi(argv[i]+1)*MEGABYTE)/sizeof(int); break;
case 'o':
strcpy(output_file_name,argv[i]+1);
out = fopen(output_file_name,"a+");
if(out == NULL)
{
printf("WARNING: Can't open or create %s, writing to stdout\n",output_file_name);
out = stdout;
}
else
printf("Writing output to %s\n",output_file_name);
break;
default: fprintf(stderr,"WARNING: unrecognized option: %s\n",argv[i]);
break;
}
MPI_Bcast(&NTIMES,1,MPI_INT,MASTER_RANK,MPI_COMM_WORLD);
MPI_Bcast(&NTIMES_PREC,1,MPI_INT,MASTER_RANK,MPI_COMM_WORLD);
MPI_Bcast(&REPEAT_ALL,1,MPI_INT,MASTER_RANK,MPI_COMM_WORLD);
MPI_Bcast(&REPEAT_EACH_TEST,1,MPI_INT,MASTER_RANK,MPI_COMM_WORLD);
MPI_Bcast(&msglen_min,1,MPI_INT,MASTER_RANK,MPI_COMM_WORLD);
MPI_Bcast(&msglen_max,1,MPI_INT,MASTER_RANK,MPI_COMM_WORLD);
MPI_Bcast(&msglen_multiplier,1,MPI_INT,MASTER_RANK,MPI_COMM_WORLD);
MPI_Bcast(&bufsize,1,MPI_INT,MASTER_RANK,MPI_COMM_WORLD);
MPI_Barrier(MPI_COMM_WORLD);
/*
* Determine the minimum difference between these M values.
* This result will be our estimate (in microseconds) for the
* clock granularity.
*/
minDelta = 1000000;
for (i = 1; i < M; i++) {
Delta = (int)( 1.0E6 * (timesfound[i]-timesfound[i-1]));
minDelta = MIN(minDelta, MAX(Delta,0));
}
return(minDelta);
}