Skip to content
Snippets Groups Projects
Commit 75735166 authored by JanThorbecke's avatar JanThorbecke
Browse files

OpenMP over nshots

parent af7deb0f
No related branches found
No related tags found
No related merge requests found
...@@ -168,10 +168,10 @@ long *ixpos, long *iypos, long npos, double *tfft, long *isxcount, long *reci_xs ...@@ -168,10 +168,10 @@ long *ixpos, long *iypos, long npos, double *tfft, long *isxcount, long *reci_xs
#ifdef _OPENMP #ifdef _OPENMP
npe = (long)omp_get_max_threads(); npe = (long)omp_get_max_threads();
/* parallelisation is over number of virtual source positions (Nfoc) */ /* parallelisation is over number of shot positions (nshots) */
if (npe > Nfoc) { if (npe > nshots) {
vmess("Number of OpenMP threads set to %li (was %li)", Nfoc, npe); vmess("Number of OpenMP threads set to %li (was %li)", nshots, npe);
omp_set_num_threads((int)Nfoc); omp_set_num_threads((int)nshots);
} }
#endif #endif
...@@ -226,27 +226,28 @@ long *ixpos, long *iypos, long npos, double *tfft, long *isxcount, long *reci_xs ...@@ -226,27 +226,28 @@ long *ixpos, long *iypos, long npos, double *tfft, long *isxcount, long *reci_xs
t1 = wallclock_time(); t1 = wallclock_time();
*tfft += t1 - t0; *tfft += t1 - t0;
/* Loop over total number of shots */
if (reci == 0 || reci == 1) { if (reci == 0 || reci == 1) {
for (k=0; k<nshots; k++) {
if ((xsrc[k] < fxb) || (xsrc[k] > fxe) || (ysrc[k] < fyb) || (ysrc[k] > fye)) continue;
isrc = NINT((ysrc[k] - fysb)/dys)*nxs+NINT((xsrc[k] - fxsb)/dxs);
inx = xnx[k]; /* number of traces per shot */
/*================ SYNTHESIS ================*/ /*================ SYNTHESIS ================*/
#pragma omp parallel default(none) \ #pragma omp parallel default(none) \
shared(iRN, dx, dy, npe, nw, verbose) \ shared(iRN, dx, dy, npe, nw, nshots, verbose) \
shared(Refl, Nfoc, reci, xrcv, xsrc, yrcv, ysrc, xsyn, ysyn) \ shared(Refl, Nfoc, reci, xrcv, xsrc, yrcv, ysrc, xsyn, ysyn) \
shared(fxsb, fxse, fysb, fyse, nxs, nys, nxys, dxs, dys) \ shared(fxsb, fxse, fysb, fyse, nxs, nys, nxys, dxs, dys) \
shared(nx, ny, nxy, dysrc, dxsrc, inx, k, nfreq, nw_low, nw_high) \ shared(nx, ny, nxy, dysrc, dxsrc, nfreq, nw_low, nw_high, xnx) \
shared(Fop, size, nts, ntfft, scl, iyrcv, ixrcv, isrc) \ shared(Fop, size, nts, ntfft, scl, iyrcv, ixrcv, fxb, fxe, fyb, fye) \
private(l, ix, iy, j, m, i, sum, rtrace) private(l, ix, iy, j, m, i, sum, rtrace, k, isrc, inx)
{ /* start of parallel region */ { /* start of parallel region */
sum = (complex *)malloc(nfreq*sizeof(complex)); sum = (complex *)malloc(nfreq*sizeof(complex));
rtrace = (float *)calloc(ntfft,sizeof(float)); rtrace = (float *)calloc(ntfft,sizeof(float));
/* Loop over total number of shots */
#pragma omp for schedule(guided,1) #pragma omp for schedule(guided,1)
for (k=0; k<nshots; k++) {
if ((xsrc[k] < fxb) || (xsrc[k] > fxe) || (ysrc[k] < fyb) || (ysrc[k] > fye)) continue;
isrc = NINT((ysrc[k] - fysb)/dys)*nxs+NINT((xsrc[k] - fxsb)/dxs);
inx = xnx[k]; /* number of traces per shot */
for (l = 0; l < Nfoc; l++) { for (l = 0; l < Nfoc; l++) {
/* compute integral over receiver positions */ /* compute integral over receiver positions */
/* multiply R with Fop and sum over nx */ /* multiply R with Fop and sum over nx */
...@@ -269,19 +270,16 @@ long *ixpos, long *iypos, long npos, double *tfft, long *isxcount, long *reci_xs ...@@ -269,19 +270,16 @@ long *ixpos, long *iypos, long npos, double *tfft, long *isxcount, long *reci_xs
for (j = 0; j < nts; j++) for (j = 0; j < nts; j++)
iRN[l*size+isrc*nts+j] += rtrace[j]*scl*dx*dy; iRN[l*size+isrc*nts+j] += rtrace[j]*scl*dx*dy;
} /* end of parallel Nfoc loop */ } /* end of Nfoc loop */
free(sum);
free(rtrace);
#ifdef _OPENMP if (verbose>4) vmess("*** Shot gather %li processed ***", k);
#pragma omp single
npe = (long)omp_get_num_threads(); } /* end of parallel nshots (k) loop */
#endif free(sum);
} /* end of parallel region */ free(rtrace);
if (verbose>4) vmess("*** Shot gather %li processed ***", k); } /* end of parallel region */
} /* end of nshots (k) loop */
} /* end of if reci */ } /* end of if reci */
t = wallclock_time() - t0; t = wallclock_time() - t0;
...@@ -290,4 +288,4 @@ long *ixpos, long *iypos, long npos, double *tfft, long *isxcount, long *reci_xs ...@@ -290,4 +288,4 @@ long *ixpos, long *iypos, long npos, double *tfft, long *isxcount, long *reci_xs
} }
return; return;
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment