/*************************** * pvm_initsend encoding * ***************************/ /* 0 PvmDataDefault 1 PvmDataRaw 2 PvmDataInPlace */ #define code 1 #define LOC 128 #include #include #include #include #include #include #include "strdef.h" #include "stralloc.h" #include "pvm3.h" #include "pvm_split_load_fun.h" #include "pvm_file2proc1way.h" #include "pvm_fun.h" #include "matfun.h" #include "one_proc.h" #include "fun.h" static double pwrk[_SHMEM_REDUCE_MIN_WRKDATA_SIZE]; static long psync[_SHMEM_REDUCE_SYNC_SIZE]; static double ftime; main() { int xm = 128, ym = 128, num = 0, nproc = 1, maxiter = 250, pe, i; double eps = 1.e-6, secs, secs2, *solvec, stime; char *Afile, *xfile, *bfile; struct timeval t_s, t_f; FILE *fp; /***************** * start timer * *****************/ gettimeofday(&t_s, (struct timezone*)0); pe = _my_pe(); /****************** * files to use * ******************/ solvec = dvector(4*xm*ym); Afile = cvector(80); xfile = cvector(80); bfile = cvector(80); strcpy(Afile, "A.128.128"); strcpy(xfile, "x.128.128"); strcpy(bfile, "b.128.128"); /*********************** * if I'm the master * ***********************/ if (pe == 0) { if (nproc > 1) /* run_mproc(solvec, xm, ym, num, nproc, maxiter, eps, pe, Afile, xfile, bfile); */ run_m(solvec, xm, ym, num, nproc, maxiter, eps, pe, Afile, xfile, bfile); else run_1proc(solvec, xm, ym, num, nproc, maxiter, eps, Afile, xfile, bfile); } /**************************************** * else I'm a slave (possibly lslave) * ****************************************/ else { if (pe == nproc-1) /* run_lproc(xm, ym, num, nproc, maxiter, eps, pe, Afile, xfile, bfile); */ run_l(xm, ym, num, nproc, maxiter, eps, pe, Afile, xfile, bfile); else /* run_sproc(xm, ym, num, nproc, maxiter, eps, pe, Afile, xfile, bfile); */ run_s(xm, ym, num, nproc, maxiter, eps, pe, Afile, xfile, bfile); } /******************************* * perform time computations * *******************************/ gettimeofday(&t_f, (struct timezone*)0); secs = ((t_f.tv_sec-t_s.tv_sec)*1000000 + t_f.tv_usec - t_s.tv_usec)/1000000.; stime = (t_s.tv_sec*1000000 + t_s.tv_usec) / 1000000.; ftime = (t_f.tv_sec*1000000 + t_f.tv_usec) / 1000000.; for(i = 0; i < _SHMEM_REDUCE_SYNC_SIZE; i++) psync[i]=_SHMEM_SYNC_VALUE; barrier(); shmem_double_max_to_all(&ftime, &ftime, 1, 0, 0, nproc, pwrk, psync); barrier(); shmem_double_min_to_all(&stime, &stime, 1, 0, 0, nproc, pwrk, psync); secs2 = ftime - stime; /******************** * print solution * ********************/ if (pe == 0) { printf("\nparallel run time = %lf seconds \n\n", secs2); fp = fopen("out.dat", "a"); fprintf(fp, "%lf\n", secs2); fclose(fp); } pvm_exit(); /******************* * de-allocation * *******************/ free(solvec); free(Afile); free(xfile); free(bfile); } /* end of main */