filename
stringlengths
78
241
omp_pragma_line
stringlengths
24
416
context_chars
int64
100
100
text
stringlengths
152
177k
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/vlkale/lw-sched/share/ukernels/matVec-mpi.c
#pragma omp parallel for num_threads(16)
100
o, except that entry J_ONE will be 1. Pick any value of J_ONE between 1 and M. */ j_one = 17; <LOOP-START>for ( i = 0; i < n; i++ ) { x[i] = sqrt ( 2.0 / ( double ) ( n + 1 ) ) * sin ( ( double ) ( ( i + 1 ) * j_one ) * pi / ( double ) ( n + 1 ) ); printf("thread %d doing iteration %d \n", omp_get_thread_num(), i); }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(16)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/vlkale/lw-sched/share/ukernels/matVec-mpi.c
#pragma omp parallel for
100
printf ( " Process %d shutting down.\n", my_id ); break; } ans = 0.0; <LOOP-START>for ( i = 0; i < n; i++ ) { ans = ans + a_row[i] * x[i]; }<LOOP-END> <OMP-START>#pragma omp parallel for <OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/garciparedes/cc-examples/parallel/openmp/uva/proof3.c
#pragma omp parallel for firstprivate(a) lastprivate(b)
100
h> #include<omp.h> int main() { omp_set_num_threads(4); int i; int a = 0; int b = 5; <LOOP-START>for (i=0; i<4; i++) { b = a + 1; a = b; }<LOOP-END> <OMP-START>#pragma omp parallel for firstprivate(a) lastprivate(b)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/garciparedes/cc-examples/parallel/openmp/uva/proof2.c
#pragma omp parallel for
100
lib.h> #include<omp.h> int main() { omp_set_num_threads(4); int i, v[4]; int a = 2; <LOOP-START>for (i=0; i<4; i++) v[i] = i; #pragma omp parallel for for (i=0; i<4; i++) { v[i] = a + v[i]; a = a + 1; }<LOOP-END> <OMP-START>#pragma omp parallel for <OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/garciparedes/cc-examples/parallel/openmp/uva/proof2.c
#pragma omp parallel for
100
int i, v[4]; int a = 2; #pragma omp parallel for for (i=0; i<4; i++) v[i] = i; <LOOP-START>for (i=0; i<4; i++) { v[i] = a + v[i]; a = a + 1; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/mcanalesmayo/jacobi-mpi/jacobi_par.c
#pragma omp parallel for
100
not ensured to be contiguous rows = (double*) malloc(sizeof(double)*subprob_size*subprob_size); <LOOP-START>for (i=0;i<subprob_size;i++) { a[i] = &rows[i*subprob_size]; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/mcanalesmayo/jacobi-mpi/jacobi_par.c
#pragma omp parallel for collapse(2)
100
n_num, int row_num) { int i, j; // Initialize matrix // First time all values are INITIAL_GRID <LOOP-START>for(i=0; i<subprob_size; i++) { for(j=0; j<subprob_size; j++) a[i][j] = INITIAL_GRID; }<LOOP-END> <OMP-START>#pragma omp parallel for collapse(2)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/mcanalesmayo/jacobi-mpi/jacobi_par.c
#pragma omp parallel for
100
in the first column if (column_num == 0){ // I'm in the first row column if (row_num == 0){ <LOOP-START>for(i=0; i<subprob_size; i++){ rlcbuff[i] = INITIAL_GRID; rfcbuff[i] = BC_HOT; rlrbuff[i] = INITIAL_GRID; rfrbuff[i] = BC_HOT; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/mcanalesmayo/jacobi-mpi/jacobi_par.c
#pragma omp parallel for
100
i] = BC_HOT; } } // I'm in the last row else if(row_num == ((int) sqrt(n_subprobs))-1){ <LOOP-START>for(i=0; i<subprob_size; i++){ rlcbuff[i] = INITIAL_GRID; rfcbuff[i] = BC_HOT; rlrbuff[i] = BC_COLD; rfrbuff[i] = INITIAL_GRID; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/mcanalesmayo/jacobi-mpi/jacobi_par.c
#pragma omp parallel for
100
lse if(column_num == ((int) sqrt(n_subprobs))-1){ // I'm in the first row if (row_num == 0){ <LOOP-START>for(i=0; i<subprob_size; i++){ rlcbuff[i] = BC_HOT; rfcbuff[i] = INITIAL_GRID; rlrbuff[i] = INITIAL_GRID; rfrbuff[i] = BC_HOT; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/mcanalesmayo/jacobi-mpi/jacobi_par.c
#pragma omp parallel for
100
i] = BC_HOT; } } // I'm in the last row else if(row_num == ((int) sqrt(n_subprobs))-1){ <LOOP-START>for(i=0; i<subprob_size; i++){ rlcbuff[i] = BC_HOT; rfcbuff[i] = INITIAL_GRID; rlrbuff[i] = BC_COLD; rfrbuff[i] = INITIAL_GRID; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/mcanalesmayo/jacobi-mpi/jacobi_par.c
#pragma omp parallel for
100
f (column_num != ((int) sqrt(n_subprobs))-1){ // send the last column of my subproblem matrix <LOOP-START>for(i=0; i<subprob_size; i++) slcbuff[i] = a[i][subprob_size-1]; MPI_Isend(slcbuff, subprob_size, MPI_DOUBLE, my_rank+1, iteration, MPI_COMM_WORLD, slcreq); // post receive last column + 1 MPI_Irecv(rlcbuff, subprob_size, MPI_DOUBLE, my_rank+1, iteration, MPI_COMM_WORLD, rlcreq); } // I'm not in the first column if (column_num != 0){ // send the first column of my subproblem matrix #pragma omp parallel for for(i=0; i<subprob_size; i++) sfcbuff[i] = a[i][0]; MPI_Isend(sfcbuff, subprob_size, MPI_DOUBLE, my_rank-1, iteration, MPI_COMM_WORLD, sfcreq); // post receive first column - 1 MPI_Irecv(rfcbuff, subprob_size, MPI_DOUBLE, my_rank-1, iteration, MPI_COMM_WORLD, rfcreq); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/mcanalesmayo/jacobi-mpi/jacobi_par.c
#pragma omp parallel for
100
in the first column if (column_num != 0){ // send the first column of my subproblem matrix <LOOP-START>for(i=0; i<subprob_size; i++) sfcbuff[i] = a[i][0]; MPI_Isend(sfcbuff, subprob_size, MPI_DOUBLE, my_rank-1, iteration, MPI_COMM_WORLD, sfcreq); // post receive first column - 1 MPI_Irecv(rfcbuff, subprob_size, MPI_DOUBLE, my_rank-1, iteration, MPI_COMM_WORLD, rfcreq); } // Send my outer rows values // I'm not in the last row if (row_num != ((int) sqrt(n_subprobs))-1){ // send the last row of my subproblem matrix memcpy(slrbuff, a[subprob_size-1], subprob_size*sizeof(double)); MPI_Isend(slrbuff, subprob_size, MPI_DOUBLE, (int) (my_rank+sqrt(n_subprobs)), iteration, MPI_COMM_WORLD, slrreq); // post receive last row + 1 MPI_Irecv(rlrbuff, subprob_size, MPI_DOUBLE, (int) (my_rank+sqrt(n_subprobs)), iteration, MPI_COMM_WORLD, rlrreq); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/mcanalesmayo/jacobi-mpi/jacobi_par.c
#pragma omp parallel for reduction(max:maxdiff) collapse(2)
100
EL = 0.2*( EL + UP + DOWN + LEFT + RIGHT ); // Inner rows i=[1...subprob_size-2] <LOOP-START>for(i=1;i<subprob_size-1;i++) { // j=[1...subprob_size-2] for(j=1;j<subprob_size-1;j++) { b[i][j] = 0.2*(a[i][j]+a[i-1][j]+a[i+1][j]+a[i][j-1]+a[i][j+1]); if (fabs(b[i][j]-a[i][j]) > maxdiff) maxdiff = fabs(b[i][j]-a[i][j]); } }<LOOP-END> <OMP-START>#pragma omp parallel for reduction(max:maxdiff) collapse(2)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/mcanalesmayo/jacobi-mpi/jacobi_par.c
#pragma omp parallel for reduction(max:maxdiff)
100
if (fabs(b[i][j]-a[i][j]) > maxdiff) maxdiff = fabs(b[i][j]-a[i][j]); // j=[1...subprob_size-2] <LOOP-START>for(j=1;j<subprob_size-1;j++){ b[i][j] = 0.2*(a[i][j]+rfrbuff[j]+a[i+1][j]+a[i][j-1]+a[i][j+1]); if (fabs(b[i][j]-a[i][j]) > maxdiff) maxdiff = fabs(b[i][j]-a[i][j]); }<LOOP-END> <OMP-START>#pragma omp parallel for reduction(max:maxdiff)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/mcanalesmayo/jacobi-mpi/jacobi_par.c
#pragma omp parallel for reduction(max:maxdiff)
100
][j]-a[i][j]) > maxdiff) maxdiff = fabs(b[i][j]-a[i][j]); // Inner rows i=[1...subprob_size-2] <LOOP-START>for(i=1;i<subprob_size-1;i++) { // j=0 j=0; b[i][j] = 0.2*(a[i][j]+a[i-1][j]+a[i+1][j]+rfcbuff[i]+a[i][j+1]); if (fabs(b[i][j]-a[i][j]) > maxdiff) maxdiff = fabs(b[i][j]-a[i][j]); }<LOOP-END> <OMP-START>#pragma omp parallel for reduction(max:maxdiff)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/mcanalesmayo/jacobi-mpi/jacobi_par.c
#pragma omp parallel for reduction(max:maxdiff)
100
ff[i]+a[i][j+1]); if (fabs(b[i][j]-a[i][j]) > maxdiff) maxdiff = fabs(b[i][j]-a[i][j]); } <LOOP-START>for(i=1;i<subprob_size-1;i++){ // j=subprob_size-1 j=subprob_size-1; b[i][j] = 0.2*(a[i][j]+a[i-1][j]+a[i+1][j]+a[i][j-1]+rlcbuff[i]); if (fabs(b[i][j]-a[i][j]) > maxdiff) maxdiff = fabs(b[i][j]-a[i][j]); }<LOOP-END> <OMP-START>#pragma omp parallel for reduction(max:maxdiff)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/mcanalesmayo/jacobi-mpi/jacobi_par.c
#pragma omp parallel for reduction(max:maxdiff)
100
if (fabs(b[i][j]-a[i][j]) > maxdiff) maxdiff = fabs(b[i][j]-a[i][j]); // j=[1...subprob_size-2] <LOOP-START>for(j=1;j<subprob_size-1;j++){ b[i][j] = 0.2*(a[i][j]+a[i-1][j]+rlrbuff[j]+a[i][j-1]+a[i][j+1]); if (fabs(b[i][j]-a[i][j]) > maxdiff) maxdiff = fabs(b[i][j]-a[i][j]); }<LOOP-END> <OMP-START>#pragma omp parallel for reduction(max:maxdiff)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/abhishekgupta-1/Parallel-Computing-Assignment/submission/tsp_openmp/tsp_openmp.c
#pragma omp parallel for default(none) \
100
); final_res = curr_res; } } return; } int i; <LOOP-START>firstprivate(curr_bound, curr_weight, level)\ shared(curr_pat, vis,adj,final_res,N) for (i=0; i<N; i++) { int visited[N]; int curr_path[N]; int j; for (j=0;j<N;j++) {visited[j] = vis[j];} for (j=0;j<N;j++) curr_path[j] = curr_pat[j]; if (adj[curr_path[level-1]][i] != 0 && visited[i] == 0) { int temp = curr_bound; curr_weight += adj[curr_path[level-1]][i]; if (level==1) curr_bound -= ((firstMin(adj, curr_path[level-1]) + firstMin(adj, i))/2); else curr_bound -= ((secondMin(adj, curr_path[level-1]) + firstMin(adj, i))/2); if (curr_bound + curr_weight < final_res) { curr_path[level] = i; visited[i] = 1; // call TSPRec for the next level TSPRec(adj, curr_bound, curr_weight, level+1, curr_path,visited); } curr_weight -= adj[curr_path[level-1]][i]; curr_bound = temp; } }<LOOP-END> <OMP-START>#pragma omp parallel for default(none) \<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/abhishekgupta-1/Parallel-Computing-Assignment/submission/tsp_openmp/tsp_openmp.c
#pragma omp parallel for reduction(+:curr_bound)
100
memset(curr_path, -1,sizeof(curr_path)); memset(visited, 0, sizeof(visited)); int i; <LOOP-START>for (i=0; i<N; i++) curr_bound += (firstMin(adj, i) + secondMin(adj, i)); curr_bound = (curr_bound&1)? curr_bound/2 + 1 : curr_bound/2; visited[0] = 1; curr_path[0] = 0; TSPRec(adj, curr_bound, 0, 1, curr_path,visited); } int main() { omp_set_num_threads(4); int n; scanf("%d",&n); final_path = (int*)malloc(n*sizeof(int)); int *data = (int*)malloc(n*n*sizeof(int)); int **adj = (int**)malloc(n*sizeof(int*)); int i,j; for (i=0;i<n;i++) adj[i] = &(data[i*n]); N = n; for (i=0;i<n;i++) for (j=0;j<n;j++) scanf("%d",&adj[i][j]); TSP(adj); printf("Minimum cost : %d\n", final_res); printf("Path Taken : "); for (i=0; i<=N; i++) printf("%d ", final_path[i]); return 0; }<LOOP-END> <OMP-START>#pragma omp parallel for reduction(+:curr_bound)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/fmorenovr/ComputerScience_UNI/CC301-Algoritmos_Paralelos/Clase_7/Ejercicio_3/minMaxVector_openmp.c
#pragma omp parallel for ordered schedule(static,chunksize)
100
%d\n",*(minMax_array+1)); return 0; } void llenar(int *a) { int i; omp_set_num_threads(4); <LOOP-START>for(i=0;i<SIZE;i++) *(a+i)=rand()%50; } int* minMax(int*a) { int i,min_val=a[0],max_val=a[0]; omp_set_num_threads(4); #pragma omp parallel for ordered schedule(static,chunksize) \ reduction(max:max_val) reduction(min:min_val) for(i=1;i<SIZE;i++) { if(a[i]>max_val) max_val=a[i]; if(min_val>a[i]) min_val=a[i]; } static int b[2]; b[0]=min_val; b[1]=max_val; return b; }<LOOP-END> <OMP-START>#pragma omp parallel for ordered schedule(static,chunksize)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/fmorenovr/ComputerScience_UNI/CC301-Algoritmos_Paralelos/Clase_7/Ejercicio_3/minMaxVector_openmp.c
#pragma omp parallel for ordered schedule(static,chunksize) \
100
)=rand()%50; } int* minMax(int*a) { int i,min_val=a[0],max_val=a[0]; omp_set_num_threads(4); <LOOP-START>reduction(max:max_val) reduction(min:min_val) for(i=1;i<SIZE;i++) { if(a[i]>max_val) max_val=a[i]; if(min_val>a[i]) min_val=a[i]; }<LOOP-END> <OMP-START>#pragma omp parallel for ordered schedule(static,chunksize) \<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/fmorenovr/ComputerScience_UNI/CC301-Algoritmos_Paralelos/Clase_7/Ejercicio_2/ordered_openmp.c
#pragma omp parallel for ordered schedule(static,chunksize)
100
alelo\nEl vector a es:\n"); for(i=0;i<n;i++) printf("a[%d]:%d\n",i,a[i]); printf("\n\n"); <LOOP-START>for(i=0;i<n;i++){ a[i]=i; printf("%d del hilo %d\n",i,omp_get_thread_num()); }<LOOP-END> <OMP-START>#pragma omp parallel for ordered schedule(static,chunksize)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/fmorenovr/ComputerScience_UNI/CC301-Algoritmos_Paralelos/Clase_10/Ejercicio_1/bitonicSort_openmp.c
#pragma omp parallel for private(start) shared(sequence, end, up, distance)
100
p, int * sequence, int size) { int distance = size/2; int * start, * end = sequence+distance; <LOOP-START>for(start = sequence; start < end; start++) if( (*start > *(start+distance)) == up) swap(start, start+distance); } void swap(int * x, int * y) { int temp = *x; *x = *y; *y = temp; }<LOOP-END> <OMP-START>#pragma omp parallel for private(start) shared(sequence, end, up, distance)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/fmorenovr/ComputerScience_UNI/CC301-Algoritmos_Paralelos/Clase_10/Ejercicio_1/generateBitonicArray.c
#pragma omp parallel for ordered schedule(static,5)
100
// 2^14 = 16384 maximo omp_set_num_threads(4); fprintf(fp,"%li\n",n); <LOOP-START>for(i=0;i<n;i++){ numero = rand()%n; #pragma omp ordered fprintf(fp,"%li",numero); if(i<n-1) #pragma omp ordered fprintf(fp," "); }<LOOP-END> <OMP-START>#pragma omp parallel for ordered schedule(static,5)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/fmorenovr/ComputerScience_UNI/CC462-Sistemas_Concurrentes_y_Distribuidos/Labo_1/example/matrix.c
#pragma omp parallel for
100
trix(quantum_matrix m) { int i, j, z=0; /* int l; */ while ((1 << z++) < m.rows); z--; <LOOP-START>{ /* for (l=z-1; l>=0; l--) { if ((l % 4 == 3)) printf(" "); printf("%i", (i >> l) & 1); } */ #pragma omp parallel for for(j=0; j<m.cols; j++) printf("%g %+gi ", quantum_real(M(m, j, i)), quantum_imag(M(m, j, i))); printf("\n"); }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/fmorenovr/ComputerScience_UNI/CC462-Sistemas_Concurrentes_y_Distribuidos/Labo_1/example/matrix.c
#pragma omp parallel for
100
l>=0; l--) { if ((l % 4 == 3)) printf(" "); printf("%i", (i >> l) & 1); } */ <LOOP-START>for(j=0; j<m.cols; j++) printf("%g %+gi ", quantum_real(M(m, j, i)), quantum_imag(M(m, j, i))); printf("\n"); } printf("\n"); } /* Matrix multiplication */ quantum_matrix quantum_mmult(quantum_matrix A, quantum_matrix B) { int i, j, k; quantum_matrix C; if(A.cols != B.rows) quantum_error(QUANTUM_EMSIZE); C = quantum_new_matrix(B.cols, A.rows); #pragma omp parallel for for(i=0; i<B.cols; i++) { for(j=0; j<A.rows; j++) { for(k=0; k<B.rows; k++) M(C, i, j) += M(A, k, j) * M(B, i, k); } } return C; }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/fmorenovr/ComputerScience_UNI/CC462-Sistemas_Concurrentes_y_Distribuidos/Labo_1/example/matrix.c
#pragma omp parallel for
100
f(A.cols != B.rows) quantum_error(QUANTUM_EMSIZE); C = quantum_new_matrix(B.cols, A.rows); <LOOP-START>for(i=0; i<B.cols; i++) { for(j=0; j<A.rows; j++) { for(k=0; k<B.rows; k++) M(C, i, j) += M(A, k, j) * M(B, i, k); } }<LOOP-END> <OMP-START>#pragma omp parallel for<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/slopes.C
#pragma omp parallel for private(currentPtr,Curr_El)
100
-------- //-------------------and -------------------------- /* mdj 2007-02 */ //<LOOP-START>for(ti_ndx_t ndx = 0; ndx < El_Table->size(); ndx++) { if(El_Table->adapted_[ndx] > 0)//if this element does not belong on this processor don't involve!!! { El_Table->elenode_[ndx].get_slopes(El_Table, NodeTable, matprops_ptr->gamma); } }<LOOP-END> <OMP-START>#pragma omp parallel for private(currentPtr,Curr_El)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/integrators.C
#pragma omp parallel for \
100
double VxVy[2]; double dt2 = .5 * dt; // dt2 is set as dt/2 ! Element* Curr_El; //<LOOP-START>//private(currentPtr,Curr_El,IF_STOPPED,influx,j,k,curr_time,flux_src_coef,VxVy) for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { if(adapted_[ndx] <= 0)continue;//if this element does not belong on this processor don't involve!!! Curr_El = &(elements_[ndx]); elements_[ndx].update_prev_state_vars(); influx[0] = Influx_[0][ndx]; influx[1] = Influx_[1][ndx]; influx[2] = Influx_[2][ndx]; //note, now there is no check for fluxes from non-local elements if(!(influx[0] >= 0.0)) { printf("negative influx=%g\n", influx[0]); assert(0); } // -- calc contribution of flux source curr_time = (timeprops_ptr->cur_time) * (timeprops_ptr->TIME_SCALE); //VxVy[2]; if(h[ndx] > GEOFLOW_TINY) { VxVy[0] = hVx[ndx] / h[ndx]; VxVy[1] = hVy[ndx] / h[ndx]; } else { VxVy[0] = VxVy[1] = 0.0; } #ifdef STOPCRIT_CHANGE_SOURCE IF_STOPPED=Curr_El->stoppedflags(); #else IF_STOPPED = !(!(Curr_El->stoppedflags())); double g[3]{gravity_[0][ndx],gravity_[1][ndx],gravity_[2][ndx]}; double d_g[3]{d_gravity_[0][ndx],d_gravity_[1][ndx],d_gravity_[2][ndx]}; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// //predictor itself //NOTE: d(g[2]*Elm->state_vars(0))/dx is approximated by g[2]*dUvec[0]/dx !!! double c_sq; double h_inv; double tanbed; double VxVyS[2]; double unitvx, unitvy; double tmp, sgn_dudy,sgn_dvdx; double forcegrav; double forceintx,forceinty, forcebedx,forcebedy; double forcebedequil, forcebedmax; double speed; // curv := inverse of radius of curvature = second derivative of // position normal to tangent with respect to distance along tangent, // if dz/dx=0 curve=d2z/dx2, otherwise rotate coordinate system so // dz/dx=0, that is mathematical definition of curvature I believe // laercio returns d2z/dx2 whether or not dz/dx=0 in his GIS functions if (IF_STOPPED == 2) { VxVy[0] = 0.0; VxVy[1] = 0.0; VxVyS[0] = 0.0; VxVyS[1] = 0.0; } else { //VxVy[0] = VxVy[0]; //Elm->state_vars(1)/Elm->state_vars(0); //VxVy[1] = VxVy[1]; //Elm->state_vars(2)/Elm->state_vars(0); VxVyS[0] = VxVy[0]; VxVyS[1] = VxVy[1]; } c_sq = kactxy_[0][ndx] * g[2] * h[ndx]; //h_inv := 1/h[ndx]; h[ndx]=h[ndx] - dt2 * (dhVx_dx[ndx] + dhVy_dy[ndx] + influx[0]); h[ndx]=c_dmax1(h[ndx], 0.0); //dF/dU, dG/dU and S terms if h[ndx] > TINY ! if (h[ndx] > tiny) { h_inv = 1.0 / h[ndx]; tanbed = tan(matprops_ptr->bedfrict[material_[ndx]]); //here speed is speed squared speed = VxVy[0] * VxVy[0] + VxVy[1] * VxVy[1]; if (speed > 0.0) { //here speed is speed speed = sqrt(speed); unitvx = VxVy[0] / speed; unitvy = VxVy[1] / speed; } else { unitvx = 0.0; unitvy = 0.0; } //dnorm=dsqrt(Uprev[1]**2+Uprev[2]**2+tiny**2) //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc //****** X-dir ****** //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // dF/dU and dG/dU terms hVx[ndx]=hVx[ndx] - dt2 * ((c_sq - VxVy[0] * VxVy[0]) * dh_dx[ndx] + 2.0 * VxVy[0] * dhVx_dx[ndx] - VxVy[0] * VxVy[1] * dh_dy[ndx] + VxVy[1] * dhVx_dy[ndx] + VxVy[0] * dhVy_dy[ndx] + influx[1]); // x direction source terms // the gravity force in the x direction forcegrav = g[0] * h[ndx]; // the internal friction force tmp = h_inv * (dhVx_dy[ndx] - VxVyS[0] * dh_dy[ndx]); sgn_dudy = sgn_tiny(tmp, frict_tiny); forceintx = sgn_dudy * h[ndx] * kactxy_[0][ndx] * (g[2] * dh_dy[ndx] + d_g[1] * h[ndx]) * sin(int_frict); // the bed friction force for fast moving flow forcebedx = unitvx * c_dmax1(g[2] * h[ndx] + VxVyS[0] * hVx[ndx] * curvature_[0][ndx], 0.0) * tanbed; if (IF_STOPPED == 2 && 1 == 0) { //the bed friction force for stopped or nearly stopped flow //the static friction force is LESS THAN or equal to the friction //coefficient times the normal force but it can NEVER exceed the //NET force it is opposing //maximum friction force the bed friction can support forcebedmax = c_dmax1(g[2] * h[ndx] + VxVyS[0] * hVx[ndx] * curvature_[0][ndx], 0.0) * tanbed; // the NET force the bed friction force is opposing forcebedequil = forcegrav - forceintx; // -kactxy*g[2]*Elm->state_vars(0)*dh_dx // the "correct" stopped or nearly stopped flow bed friction force // (this force is not entirely "correct" it will leave a "negligible" // (determined by stopping criteria) amount of momentum in the cell forcebedx = sgn_tiny(forcebedequil, c_dmin1(forcebedmax, dabs(forcebedx) + dabs(forcebedequil))); // forcebedx= // sgn(forcebed2,dmin1(forcebed1,dabs(forcebed2))) // else } // all the x source terms hVx[ndx]=hVx[ndx] + dt2 * (forcegrav - forcebedx - forceintx); // write(*,*) 'int', forceintx, 'bed', forcebedx //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc //****** Y-dir ****** //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc //dF/dU and dG/dU terms hVy[ndx]=hVy[ndx] - dt2 * ((c_sq - VxVy[1] * VxVy[1]) * dh_dy[ndx] + 2.0 * VxVy[1] * dhVy_dy[ndx] - VxVy[0] * VxVy[1] * dh_dx[ndx] + VxVy[1] * dhVx_dx[ndx] + VxVy[0] * dhVy_dx[ndx] + influx[2]); //the gravity force in the y direction forcegrav = g[1] * h[ndx]; //the internal friction force tmp = h_inv * (dhVy_dx[ndx] - VxVyS[1] * dh_dx[ndx]); sgn_dvdx = sgn_tiny(tmp, frict_tiny); forceinty = sgn_dvdx * h[ndx] * kactxy_[0][ndx] * (g[2] * dh_dx[ndx] + d_g[0] * h[ndx]) * sin(int_frict); //the bed friction force for fast moving flow forcebedy = unitvy * c_dmax1(g[2] * h[ndx] + VxVyS[1] * hVy[ndx] * curvature_[1][ndx], 0.0) * tanbed; if (IF_STOPPED == 2 && 1 == 0) { //the bed friction force for stopped or nearly stopped flow forcebedmax = c_dmax1(g[2] * h[ndx] + VxVyS[1] * hVy[ndx] * curvature_[1][ndx], 0.0) * tanbed; //the NET force the bed friction force is opposing forcebedequil = forcegrav // $ -kactxy*g[2]*Elm->state_vars(0)*dh_dy - forceinty; //the "correct" stopped or nearly stopped flow bed friction force //(this force is not entirely "correct" it will leave a "negligible" //(determined by stopping criteria) amount of momentum in the cell forcebedy = sgn_tiny(forcebedequil, c_dmin1(forcebedmax, fabs(forcebedy) + fabs(forcebedequil))); // forcebedy=sgn(forcebed2,dmin1(forcebed1,dabs(forcebed2))) // else } // all the y source terms hVy[ndx]=hVy[ndx] + dt2 * (forcegrav - forcebedy - forceinty); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // apply bc's for(int j = 0; j < 4; j++) if(Curr_El->neigh_proc(j) == INIT) // this is a boundary! for(int k = 0; k < NUM_STATE_VARS; k++) state_vars_[k][ndx]=0.0; }<LOOP-END> <OMP-START>#pragma omp parallel for \<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/integrators.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_MIDIUM_CHUNK) \
100
ISPC_cor); //ANNOTATE_TASK_BEGIN(Integrator_SinglePhase_Coulomb_FirstOrder_corrector_loop); <LOOP-START>reduction(+: m_forceint, m_forcebed, m_eroded, m_deposited, m_realvolume) for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { //ANNOTATE_ITERATION_TASK(ISPC_cor_iter); if(adapted_[ndx] <= 0)continue;//if this element does not belong on this processor don't involve!!! //if first order states was not updated as there is no predictor if(order==1) { for (int i = 0; i < NUM_STATE_VARS; i++) prev_state_vars_[i][ndx]=state_vars_[i][ndx]; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// double elem_forceint; double elem_forcebed; double elem_eroded; double elem_deposited; double dxdy = dx_[0][ndx] * dx_[1][ndx]; double dtdx = dt / dx_[0][ndx]; double dtdy = dt / dx_[1][ndx]; int xp = positive_x_side_[ndx]; int yp = (xp + 1) % 4; int xm = (xp + 2) % 4; int ym = (xp + 3) % 4; int ivar, j, k; double fluxxp[MAX_NUM_STATE_VARS], fluxyp[MAX_NUM_STATE_VARS]; double fluxxm[MAX_NUM_STATE_VARS], fluxym[MAX_NUM_STATE_VARS]; ti_ndx_t nxp = node_key_ndx_[xp + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxxp[ivar] = node_flux_[ivar][nxp]; ti_ndx_t nyp = node_key_ndx_[yp + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxyp[ivar] = node_flux_[ivar][nyp]; ti_ndx_t nxm = node_key_ndx_[xm + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxxm[ivar] = node_flux_[ivar][nxm]; ti_ndx_t nym = node_key_ndx_[ym + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxym[ivar] = node_flux_[ivar][nym]; /* the values being passed to correct are for a SINGLE element, NOT a region, as such the only change that having variable bedfriction requires is to pass the bedfriction angle for the current element rather than the only bedfriction I wonder if this is legacy code, it seems odd that it is only called for the SUN Operating System zee ../geoflow/correct.f */ #ifdef STOPPED_FLOWS #ifdef STOPCRIT_CHANGE_SOURCE int IF_STOPPED=stoppedflags_[ndx]; #else int IF_STOPPED = !(!stoppedflags_[ndx]); double VxVy[2]; if(h[ndx] > tiny) { VxVy[0] = hVx[ndx] / h[ndx]; VxVy[1] = hVy[ndx] / h[ndx]; } else { VxVy[0] = VxVy[1] = 0.0; } elements_[ndx].convect_dryline(VxVy[0], VxVy[1], dt); //this is necessary /////////////////////////////////////////////////////////////////////////////////////////////////////////////// //corrector itself double speed; double forceintx, forceinty; double forcebedx, forcebedy; double forcebedx_curv, forcebedy_curv; double forcebedmax, forcebedequil, forcegravx , forcegravy; double unitvx, unitvy; double tanbed; double Ustore[3]; double h_inv; double sgn_dudy, sgn_dvdx, tmp; double es, totalShear; Ustore[0] = prev_state_vars_[0][ndx] - dtdx * (fluxxp[0] - fluxxm[0]) - dtdy * (fluxyp[0] - fluxym[0]) + dt * Influx_[0][ndx]; Ustore[0] = c_dmax1(Ustore[0], 0.0); Ustore[1] = prev_state_vars_[1][ndx] - dtdx * (fluxxp[1] - fluxxm[1]) - dtdy * (fluxyp[1] - fluxym[1]) + dt * Influx_[1][ndx]; Ustore[2] = prev_state_vars_[2][ndx] - dtdx * (fluxxp[2] - fluxxm[2]) - dtdy * (fluxyp[2] - fluxym[2]) + dt * Influx_[2][ndx]; // initialize to zero forceintx = 0.0; forcebedx = 0.0; forcebedx_curv = 0.0; forcebedy_curv = 0.0; forceinty = 0.0; forcebedy = 0.0; unitvx = 0.0; unitvy = 0.0; elem_eroded = 0.0; if(h[ndx] > tiny) { double inertial_x,inertial_y,drag_x, drag_y; // S terms // here speed is speed squared speed = VxVy[0] * VxVy[0] + VxVy[1] * VxVy[1]; if (speed > 0.0) { // here speed is speed speed = sqrt(speed); unitvx = VxVy[0] / speed; unitvy = VxVy[1] / speed; } else { unitvx = 0.0; unitvy = 0.0; } tanbed = tan(bedfrictang[ndx]); h_inv = 1.0 / h[ndx]; //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // x direction source terms //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // the gravity force in the x direction forcegravx = g[0][ndx] * h[ndx]; // the internal friction force tmp = h_inv * (dhVx_dy[ndx] - VxVy[0] * dh_dy[ndx]); sgn_dudy = sgn_tiny(tmp, frict_tiny); forceintx = sgn_dudy * h[ndx]* kactxy[ndx] * (g[2][ndx] * dh_dy[ndx] + dgdx[1][ndx] * h[ndx]) * sin_intfrictang; // the bed friction force for fast moving flow tmp = c_dmax1(g[2][ndx] * h[ndx] + VxVy[0] * hVx[ndx] * curvature_[0][ndx], 0.0); if (tmp > 0.0){ forcebedx = unitvx * tanbed * g[2][ndx] * h[ndx]; forcebedx_curv = unitvx * tanbed * VxVy[0] * hVx[ndx] * curvature_[0][ndx]; } #ifdef STOPPED_FLOWS if (IF_STOPPED == 2 && 1 == 0) { // the bed friction force for stopped or nearly stopped flow // the static friction force is LESS THAN or equal to the friction // coefficient times the normal force but it can NEVER exceed the // NET force it is opposing // maximum friction force the bed friction can support forcebedmax = g[2][ndx] * h[ndx] * tanbed; // the NET force the bed friction force is opposing forcebedequil = forcegrav - forceintx; // $ -kactxy*g[2]*EmTemp->state_vars(0)*dh_dx // the "correct" stopped or nearly stopped flow bed friction force // (this force is not entirely "correct" it will leave a "negligible" // (determined by stopping criteria) amount of momentum in the cell forcebedx = sgn_tiny(forcebedequil, c_dmin1(forcebedmax, fabs(forcebedx) + fabs(forcebedequil))); // forcebedx=sgn_tiny(forcebed2,dmin1(forcebed1,fabs(forcebed2))) // not really 1 but this makes friction statistics accurate unitvx = 1.0; // else } tmp = Ustore[1] + dt * (forcegravx - forcebedx - forcebedx_curv - forceintx); //STOPPING CRITERIA if(stopping_criteria==1) { inertial_x = fabs(Ustore[1] + dt * forcegravx); drag_x = fabs(dt * (forcebedx + forcebedx_curv + forceintx) ); if (inertial_x <= drag_x) tmp = 0.0; } Ustore[1] = tmp; //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // y direction source terms //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // the gravity force in the y direction forcegravy = g[1][ndx] * h[ndx]; // the internal friction force tmp = h_inv * (dhVy_dx[ndx] - VxVy[1] * dh_dx[ndx]); sgn_dvdx = sgn_tiny(tmp, frict_tiny); forceinty = sgn_dvdx * h[ndx] * kactxy[ndx] * (g[2][ndx] * dh_dx[ndx] + dgdx[0][ndx] * h[ndx]) * sin_intfrictang; // the bed friction force for fast moving flow tmp = c_dmax1(g[2][ndx] * h[ndx] + VxVy[1] * hVy[ndx] * curvature_[1][ndx], 0.0); if (tmp > 0.0){ forcebedy = unitvy * tanbed * g[2][ndx] * h[ndx]; forcebedy_curv = unitvy * tanbed * VxVy[1] * hVy[ndx] * curvature_[1][ndx]; } #ifdef STOPPED_FLOWS if (IF_STOPPED == 2 && 1 == 0) { // the bed friction force for stopped or nearly stopped flow // the NET force the bed friction force is opposing forcebedequil = forcegrav - forceinty; // $ -kactxy*g[2]*EmTemp->state_vars(0)*dh_dy // the "correct" stopped or nearly stopped flow bed friction force // (this force is not entirely "correct" it will leave a "negligible" // (determined by stopping criteria) amount of momentum in the cell forcebedy = sgn_tiny(forcebedequil, c_dmin1(forcebedmax, fabs(forcebedy) + fabs(forcebedequil))); // not really 1 but this makes friction statistics accurate unitvy = 1.0; // else } tmp = Ustore[2] + dt * (forcegravy - forcebedy - forcebedy_curv - forceinty); //STOPPING CRITERIA if(stopping_criteria==1) { inertial_y = fabs(Ustore[2] + dt * forcegravy); drag_y = fabs(dt * (forcebedy + forcebedy_curv + forceinty) ); if (inertial_y <= drag_y) tmp = 0.0; } Ustore[2] = tmp; #ifdef STOPPED_FLOWS //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // (erosion terms) this is Camil's logic, Keith changed some variable //names for clarity //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc if ((false) && (do_erosion != 0) && (IF_STOPPED == 0)) { totalShear = sqrt(forcebedx * forcebedx + forcebedy * forcebedy); if ((totalShear > threshold) && (h[ndx] > 0.004)) { es = erosion_rate * sqrt(fabs(totalShear - threshold)); elem_eroded = dt*es; Ustore[0] = Ustore[0] + elem_eroded; Ustore[1] = Ustore[1] + elem_eroded * VxVy[0]; Ustore[2] = Ustore[2] + elem_eroded * VxVy[1]; //write (*,*) 'Doing Keith Erosion Model' } } if ((do_erosion != 0) && (h[ndx] > threshold)) { es = erosion_rate * sqrt(hVx[ndx] * hVx[ndx] + hVy[ndx] * hVy[ndx]) / h[ndx]; Ustore[0] = Ustore[0] + dt * es; Ustore[1] = Ustore[1] + dt * es * Ustore[1]; Ustore[2] = Ustore[2] + dt * es * Ustore[2]; //write (*,*) 'Doing Camil Erosion Model' } } // computation of magnitude of friction forces for statistics elem_forceint = unitvx * forceintx + unitvy*forceinty; elem_forcebed = unitvx * forcebedx + unitvy*forcebedy; // update the state variables h[ndx]=Ustore[0]; hVx[ndx]=Ustore[1]; hVy[ndx]=Ustore[2]; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// elem_forceint *= dxdy; elem_forcebed *= dxdy; elem_eroded *= dxdy; if(stoppedflags_[ndx] == 2) elem_deposited = h[ndx] * dxdy; else elem_deposited = 0.0; if(stoppedflags_[ndx]) elem_eroded = 0.0; elements_[ndx].calc_shortspeed(1.0 / dt); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// m_forceint += fabs(elem_forceint); m_forcebed += fabs(elem_forcebed); m_realvolume += dxdy * h[ndx]; m_eroded += elem_eroded; m_deposited += elem_deposited; // apply bc's for (int j = 0; j < 4; j++) if (neigh_proc_[j][ndx] == INIT) // this is a boundary! for (int k = 0; k < NUM_STATE_VARS; k++) state_vars_[k][ndx] = 0.0; }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_MIDIUM_CHUNK) \<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/integrators.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_MIDIUM_CHUNK)
100
cosphiSQ*=cosphiSQ; // Updating K_act/pass based on updated state vars and their derivatives. <LOOP-START>for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { if(adapted_[ndx] <= 0) { double vel; double Kactx, Kacty; if(h[ndx] > tiny) { double hSQ = h[ndx] * h[ndx]; double tanbed = tan(bedfrictang[ndx]); double tandelSQ = tanbed * tanbed; vel=dhVx_dx[ndx]/h[ndx] - hVx[ndx]*dh_dx[ndx]/hSQ+ dhVy_dy[ndx]/h[ndx] - hVy[ndx]*dh_dy[ndx]/hSQ; Kactx=(2.0/cosphiSQ)*(1.0-sgn_tiny(vel,tiny)* sqrt(fabs(1.0-(1.0+tandelSQ)*cosphiSQ) )) -1.0; Kacty=(2.0/cosphiSQ)*(1.0-sgn_tiny(vel,tiny)* sqrt(fabs(1.0-(1.0+tandelSQ)*cosphiSQ) )) -1.0; //if there is no yielding... if(fabs(hVx[ndx]/h[ndx]) < tiny && fabs(hVy[ndx]/h[ndx]) < tiny) { Kactx = 1.0; Kacty = 1.0; } } else { vel = 0.0; Kactx = 1.0; Kacty = 1.0; } effect_kactxy_[0][ndx] = Kactx * scale_.epsilon; effect_kactxy_[1][ndx] = Kacty * scale_.epsilon; } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_MIDIUM_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/integrators.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_MIDIUM_CHUNK) \
100
lquants_ptr->TimeInts[iloc].resize(0); } tivector<double> &kactxy=effect_kactxy_[0]; <LOOP-START>reduction(+: m_force_transx, m_force_transy, m_force_conx, m_force_cony, m_force_gx, m_force_gy) \ reduction(+: m_force_bx, m_force_by, m_force_bcx, m_force_bcy, m_force_rx, m_force_ry) \ reduction(+: m_power_trans, m_power_con, m_power_g, m_power_b, m_power_bc, m_power_r, m_Fr, m_vol) for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { if(adapted_[ndx] <= 0)continue;//if this element does not belong on this processor don't involve!!! if(h[ndx] > localquants_ptr->thr) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////// double dxdy = dx_[0][ndx] * dx_[1][ndx]; double dtdx = dt / dx_[0][ndx]; double dtdy = dt / dx_[1][ndx]; int xp = positive_x_side_[ndx]; int yp = (xp + 1) % 4; int xm = (xp + 2) % 4; int ym = (xp + 3) % 4; int ivar; double fluxxp[MAX_NUM_STATE_VARS], fluxyp[MAX_NUM_STATE_VARS]; double fluxxm[MAX_NUM_STATE_VARS], fluxym[MAX_NUM_STATE_VARS]; ti_ndx_t nxp = node_key_ndx_[xp + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxxp[ivar] = node_flux_[ivar][nxp]; ti_ndx_t nyp = node_key_ndx_[yp + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxyp[ivar] = node_flux_[ivar][nyp]; ti_ndx_t nxm = node_key_ndx_[xm + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxxm[ivar] = node_flux_[ivar][nxm]; ti_ndx_t nym = node_key_ndx_[ym + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxym[ivar] = node_flux_[ivar][nym]; double VxVy[2]; double tanbed = tan(bedfrictang[ndx]); VxVy[0] = hVx[ndx] / h[ndx]; VxVy[1] = hVy[ndx] / h[ndx]; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// double speed, h_inv; double forcetransx, forcetransy; double forceconvectx, forceconvecty; double forceintx, forceinty; double forcebedx, forcebedy; double forcebedx_curv, forcebedy_curv; double forcegravx , forcegravy; double unitvx, unitvy, Local_Fr; double sgn_dudy, sgn_dvdx, tmp; // initialize to zero forcetransx = forcetransy = 0.0; forceconvectx = forceconvecty = 0.0; forceintx = forcebedx = 0.0; forcebedx_curv = forcebedy_curv = 0.0; forceinty = forcebedy = 0.0; unitvx = unitvy = 0.0; // S terms // here speed is speed squared speed = VxVy[0] * VxVy[0] + VxVy[1] * VxVy[1]; if (speed > 0.0) { // here speed is speed speed = sqrt(speed); unitvx = VxVy[0] / speed; unitvy = VxVy[1] / speed; } else { unitvx = unitvy = 0.0; } h_inv = 1.0 / h[ndx]; Local_Fr = speed / sqrt( g[2][ndx] * h[ndx] * scale_.epsilon); //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // x direction source terms //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // the transient force in the x direction forcetransx = (hVx[ndx] - prev_state_vars_[1][ndx]) / dt; // the convective in x direction forceconvectx = (fluxxp[1] - fluxxm[1]) / dx_[0][ndx] + (fluxyp[1] - fluxym[1]) / dx_[1][ndx]; // the gravity force in the x direction forcegravx = g[0][ndx] * h[ndx]; // the internal friction force tmp = h_inv * (dhVx_dy[ndx] - VxVy[0] * dh_dy[ndx]); sgn_dudy = sgn_tiny(tmp, frict_tiny); forceintx = sgn_dudy * h[ndx] * kactxy[ndx] * (g[2][ndx] * dh_dy[ndx] + dgdx[1][ndx] * h[ndx]) * sin_intfrictang; // the bed friction force for fast moving flow tmp = c_dmax1(g[2][ndx] * h[ndx] + VxVy[0] * hVx[ndx] * curvature_[0][ndx], 0.0); if (tmp > 0.0){ forcebedx = unitvx * tanbed * g[2][ndx] * h[ndx]; forcebedx_curv = unitvx * tanbed * VxVy[0] * hVx[ndx] * curvature_[0][ndx]; } //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // y direction source terms //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // the transient force in the y direction forcetransy = (hVy[ndx] - prev_state_vars_[2][ndx]) / dt; // the convective in y direction forceconvecty = (fluxxp[2] - fluxxm[2]) / dx_[0][ndx] + (fluxyp[2] - fluxym[2]) / dx_[1][ndx]; // the gravity force in the y direction forcegravy = g[1][ndx] * h[ndx]; // the internal friction force tmp = h_inv * (dhVy_dx[ndx] - VxVy[1] * dh_dx[ndx]); sgn_dvdx = sgn_tiny(tmp, frict_tiny); forceinty = sgn_dvdx * h[ndx] * kactxy[ndx] * (g[2][ndx] * dh_dx[ndx] + dgdx[0][ndx] * h[ndx]) * sin_intfrictang; // the bed friction force for fast moving flow tmp = c_dmax1(g[2][ndx] * h[ndx] + VxVy[1] * hVy[ndx] * curvature_[1][ndx], 0.0); if (tmp > 0.0){ forcebedy = unitvy * tanbed * g[2][ndx] * h[ndx]; forcebedy_curv = unitvy * tanbed * VxVy[1] * hVy[ndx] * curvature_[1][ndx]; } ///////////////////////////////////////////////////////////////////////////// // Recording QoIs globally from updated cells m_force_transx += (forcetransx * dxdy); m_force_transy += (forcetransy * dxdy); m_force_conx += (forceconvectx * dxdy); m_force_cony += (forceconvecty * dxdy); m_force_gx += (forcegravx * dxdy); m_force_gy += (forcegravy * dxdy); m_force_bx -= (forcebedx * dxdy); m_force_by -= (forcebedy * dxdy); m_force_bcx -= (forcebedx_curv * dxdy); m_force_bcy -= (forcebedy_curv * dxdy); m_force_rx -= (forceintx * dxdy); m_force_ry -= (forceinty * dxdy); m_power_trans += (forcetransx * VxVy[0] + forcetransy * VxVy[1]) * dxdy; m_power_con += (forceconvectx * VxVy[0] + forceconvecty * VxVy[1]) * dxdy; m_power_g += (forcegravx * VxVy[0] + forcegravy * VxVy[1]) * dxdy; m_power_b -= (forcebedx * VxVy[0] + forcebedy * VxVy[1]) * dxdy; m_power_bc -= (forcebedx_curv * VxVy[0] + forcebedy_curv * VxVy[1]) * dxdy; m_power_r -= (forceintx * VxVy[0] + forceinty * VxVy[1]) * dxdy; m_Fr += (Local_Fr * dxdy * h[ndx]); m_vol += dxdy * h[ndx]; // Searching user-defined locations to record QoIs if (localquants_ptr->no_locations > 0) localquants_ptr->FindElement(dt, dx_[0][ndx], dx_[1][ndx], coord_[0][ndx], coord_[1][ndx], h[ndx], hVx[ndx], hVy[ndx], forcetransx, forcetransy, forceconvectx, forceconvecty, forcegravx, forcegravy, -forcebedx, -forcebedy, -forcebedx_curv, -forcebedy_curv, -forceintx, -forceinty, zeta_[0][ndx], zeta_[1][ndx], Local_Fr); } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_MIDIUM_CHUNK) \<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/integrators.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) \
100
me = 0.0; double inv_xi= 1.0/xi; //convinience ref tivector<double> *g=gravity_; <LOOP-START>reduction(+: m_forceint, m_forcebed, m_eroded, m_deposited, m_realvolume) for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { if(adapted_[ndx] <= 0)continue;//if this element does not belong on this processor don't involve!!! //if first order states was not updated as there is no predictor if(order==1) { for (int i = 0; i < NUM_STATE_VARS; i++) prev_state_vars_[i][ndx]=state_vars_[i][ndx]; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// double elem_forceint; double elem_forcebed; double elem_eroded; double elem_deposited; double dxdy = dx_[0][ndx] * dx_[1][ndx]; double dtdx = dt / dx_[0][ndx]; double dtdy = dt / dx_[1][ndx]; int xp = positive_x_side_[ndx]; int yp = (xp + 1) % 4; int xm = (xp + 2) % 4; int ym = (xp + 3) % 4; int ivar, j, k; double fluxxp[NUM_STATE_VARS], fluxyp[NUM_STATE_VARS]; double fluxxm[NUM_STATE_VARS], fluxym[NUM_STATE_VARS]; ti_ndx_t nxp = node_key_ndx_[xp + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxxp[ivar] = node_flux_[ivar][nxp]; ti_ndx_t nyp = node_key_ndx_[yp + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxyp[ivar] = node_flux_[ivar][nyp]; ti_ndx_t nxm = node_key_ndx_[xm + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxxm[ivar] = node_flux_[ivar][nxm]; ti_ndx_t nym = node_key_ndx_[ym + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxym[ivar] = node_flux_[ivar][nym]; double VxVy[2]; if(h[ndx] > tiny) { VxVy[0] = hVx[ndx] / h[ndx]; VxVy[1] = hVy[ndx] / h[ndx]; } else { VxVy[0] = VxVy[1] = 0.0; } elements_[ndx].convect_dryline(VxVy[0], VxVy[1], dt); //this is necessary /////////////////////////////////////////////////////////////////////////////////////////////////////////////// //corrector itself double speed, speed_squared; double forceintx, forceinty; double forcebedx, forcebedy; double forcebedx_curv, forcebedy_curv; double forcegravx,forcegravy; double unitvx, unitvy, tmp; double Ustore[3]; double inertial_x, inertial_y; double drag_x, drag_y; Ustore[0] = prev_state_vars_[0][ndx] - dtdx * (fluxxp[0] - fluxxm[0]) - dtdy * (fluxyp[0] - fluxym[0]) + dt * Influx_[0][ndx]; Ustore[0] = c_dmax1(Ustore[0], 0.0); Ustore[1] = prev_state_vars_[1][ndx] - dtdx * (fluxxp[1] - fluxxm[1]) - dtdy * (fluxyp[1] - fluxym[1]) + dt * Influx_[1][ndx]; Ustore[2] = prev_state_vars_[2][ndx] - dtdx * (fluxxp[2] - fluxxm[2]) - dtdy * (fluxyp[2] - fluxym[2]) + dt * Influx_[2][ndx]; // initialize to zero forceintx = 0.0; forcebedx = 0.0; forcebedx_curv = 0.0; forcebedy_curv = 0.0; forceinty = 0.0; forcebedy = 0.0; unitvx = 0.0; unitvy = 0.0; elem_eroded = 0.0; double total_gravity = sqrt(g[0][ndx]*g[0][ndx] + g[1][ndx]*g[1][ndx] + g[2][ndx]*g[2][ndx]); if(h[ndx] > tiny) { // S terms speed_squared = VxVy[0] * VxVy[0] + VxVy[1] * VxVy[1]; if (speed_squared > 0.0) { speed = sqrt(speed_squared); unitvx = VxVy[0] / speed; unitvy = VxVy[1] / speed; } else { unitvx = 0.0; unitvy = 0.0; } //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // x direction source terms //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // The gravity force in the x direction forcegravx = g[0][ndx] * h[ndx]; // The basal type friction force in x direction tmp = c_dmax1(g[2][ndx] * h[ndx] + VxVy[0] * hVx[ndx] * curvature_[0][ndx], 0.0); if (tmp > 0.0){ forcebedx = unitvx * mu * g[2][ndx] * h[ndx]; forcebedx_curv = unitvx * mu * VxVy[0] * hVx[ndx] * curvature_[0][ndx]; } // The velocity-dependent resisting force in x direction forceintx = unitvx * total_gravity * speed_squared * inv_xi / scale_.epsilon; //STOPPING CRITERIA inertial_x = fabs( Ustore[1] + dt * forcegravx ); drag_x = fabs( dt * ( forceintx + forcebedx + forcebedx_curv) ); //Ustore[1] = Ustore[1] + dt * (forcegravx - forcebedx - forcebedx_curv - forceintx); if ( inertial_x > drag_x ) Ustore[1] = Ustore[1] + dt * (forcegravx - forcebedx - forcebedx_curv - forceintx); else Ustore[1] = 0.0; //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // y direction source terms //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // The gravity force in the y direction forcegravy = g[1][ndx] * h[ndx]; // The basal friction force in y direction tmp = c_dmax1(g[2][ndx] * h[ndx] + VxVy[1] * hVy[ndx] * curvature_[1][ndx], 0.0); if (tmp > 0.0){ forcebedy = unitvy * mu * g[2][ndx] * h[ndx]; forcebedy_curv = unitvy * mu * VxVy[1] * hVy[ndx] * curvature_[1][ndx]; } // The velocity-dependent resisting force in y direction forceinty = unitvy * total_gravity * speed_squared * inv_xi / scale_.epsilon; //STOPPING CRITERIA inertial_y = fabs( Ustore[2] + dt * forcegravy ); drag_y = fabs( dt * ( forceinty + forcebedy + forcebedy_curv) ); //Ustore[2] = Ustore[2] + dt * (forcegravy - forcebedy - forcebedy_curv - forceinty); if ( inertial_y > drag_y ) Ustore[2] = Ustore[2] + dt * (forcegravy - forcebedy - forcebedy_curv - forceinty); else Ustore[2] = 0.0; } // computation of magnitude of friction forces for statistics elem_forceint = speed_squared * inv_xi / scale_.epsilon; elem_forcebed = unitvx * forcebedx + unitvy*forcebedy; // update the state variables h[ndx]=Ustore[0]; hVx[ndx]=Ustore[1]; hVy[ndx]=Ustore[2]; //end of correct /////////////////////////////////////////////////////////////////////////////////////////////////////////////// elem_forceint *= dxdy; elem_forcebed *= dxdy; elem_eroded *= dxdy; if(stoppedflags_[ndx] == 2) elem_deposited = h[ndx] * dxdy; else elem_deposited = 0.0; if(stoppedflags_[ndx]) elem_eroded = 0.0; elements_[ndx].calc_shortspeed(1.0 / dt); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// m_forceint += fabs(elem_forceint); m_forcebed += fabs(elem_forcebed); m_realvolume += dxdy * h[ndx]; m_eroded += elem_eroded; m_deposited += elem_deposited; // apply bc's for (int j = 0; j < 4; j++) if (neigh_proc_[j][ndx] == INIT) // this is a boundary! for (int k = 0; k < NUM_STATE_VARS; k++) state_vars_[k][ndx] = 0.0; }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) \<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/integrators.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_MIDIUM_CHUNK) \
100
ocalquants_ptr->temps[iloc].resize(0); localquants_ptr->TimeInts[iloc].resize(0); } <LOOP-START>reduction(+: m_force_transx, m_force_transy, m_force_conx, m_force_cony, m_force_gx, m_force_gy) \ reduction(+: m_force_bx, m_force_by, m_force_bcx, m_force_bcy, m_force_rx, m_force_ry) \ reduction(+: m_power_trans, m_power_con, m_power_g, m_power_b, m_power_bc, m_power_r, m_Fr, m_vol) for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { if(adapted_[ndx] <= 0)continue;//if this element does not belong on this processor don't involve!!! if(h[ndx] > localquants_ptr->thr) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////// double dxdy = dx_[0][ndx] * dx_[1][ndx]; double dtdx = dt / dx_[0][ndx]; double dtdy = dt / dx_[1][ndx]; int xp = positive_x_side_[ndx]; int yp = (xp + 1) % 4; int xm = (xp + 2) % 4; int ym = (xp + 3) % 4; int ivar; double fluxxp[MAX_NUM_STATE_VARS], fluxyp[MAX_NUM_STATE_VARS]; double fluxxm[MAX_NUM_STATE_VARS], fluxym[MAX_NUM_STATE_VARS]; ti_ndx_t nxp = node_key_ndx_[xp + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxxp[ivar] = node_flux_[ivar][nxp]; ti_ndx_t nyp = node_key_ndx_[yp + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxyp[ivar] = node_flux_[ivar][nyp]; ti_ndx_t nxm = node_key_ndx_[xm + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxxm[ivar] = node_flux_[ivar][nxm]; ti_ndx_t nym = node_key_ndx_[ym + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxym[ivar] = node_flux_[ivar][nym]; double VxVy[2]; VxVy[0] = hVx[ndx] / h[ndx]; VxVy[1] = hVy[ndx] / h[ndx]; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// double speed, speed_squared, tmp; double forcetransx, forcetransy; double forceconvectx, forceconvecty; double forceintx, forceinty; double forcebedx, forcebedy; double forcebedx_curv, forcebedy_curv; double forcegravx , forcegravy; double unitvx, unitvy, Local_Fr; // initialize to zero forcetransx = forcetransy = 0.0; forceintx = forcebedx = 0.0; forcebedx_curv = forcebedy_curv = 0.0; forceinty = forcebedy = 0.0; unitvx = unitvy = 0.0; // S terms // here speed is speed squared speed_squared = VxVy[0] * VxVy[0] + VxVy[1] * VxVy[1]; if (speed_squared > 0.0) { speed = sqrt(speed_squared); unitvx = VxVy[0] / speed; unitvy = VxVy[1] / speed; } else { unitvx = 0.0; unitvy = 0.0; } Local_Fr = speed / sqrt( g[2][ndx] * h[ndx] * scale_.epsilon); //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // x direction source terms //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // the transient force in the x direction forcetransx = (hVx[ndx] - prev_state_vars_[1][ndx]) / dt; // the convective in x direction forceconvectx = (fluxxp[1] - fluxxm[1]) / dx_[0][ndx] + (fluxyp[1] - fluxym[1]) / dx_[1][ndx]; // The gravity force in the x direction forcegravx = g[0][ndx] * h[ndx]; // The basal friction force in x direction tmp = c_dmax1(g[2][ndx] * h[ndx] + VxVy[0] * hVx[ndx] * curvature_[0][ndx], 0.0); if (tmp > 0.0) { forcebedx = unitvx * mu * g[2][ndx] * h[ndx]; forcebedx_curv = unitvx * mu * VxVy[0] * hVx[ndx] * curvature_[0][ndx]; } // The velocity-dependent resisting force in x direction forceintx = unitvx * speed_squared * inv_xi / scale_.epsilon; //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // y direction source terms //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // the transient force in the y direction forcetransy = (hVy[ndx] - prev_state_vars_[2][ndx]) / dt; // the convective in y direction forceconvecty = (fluxxp[2] - fluxxm[2]) / dx_[0][ndx] + (fluxyp[2] - fluxym[2]) / dx_[1][ndx]; // The gravity force in the y direction forcegravy = g[1][ndx] * h[ndx]; // The basal friction force in y direction tmp = c_dmax1(g[2][ndx] * h[ndx] + VxVy[1] * hVy[ndx] * curvature_[1][ndx], 0.0); if (tmp > 0.0) { forcebedy = unitvy * mu * g[2][ndx] * h[ndx]; forcebedy_curv = unitvy * mu * VxVy[1] * hVy[ndx] * curvature_[1][ndx]; } // The velocity-dependent resisting force in y direction forceinty = unitvy * speed_squared * inv_xi / scale_.epsilon; ///////////////////////////////////////////////////////////////////////////// // Recording QoIs globally from updated cells at current time m_force_transx += (forcetransx * dxdy); m_force_transy += (forcetransy * dxdy); m_force_conx += (forceconvectx * dxdy); m_force_cony += (forceconvecty * dxdy); m_force_gx += (forcegravx * dxdy); m_force_gy += (forcegravy * dxdy); m_force_bx -= (forcebedx * dxdy); m_force_by -= (forcebedy * dxdy); m_force_bcx -= (forcebedx_curv * dxdy); m_force_bcy -= (forcebedy_curv * dxdy); m_force_rx -= (forceintx * dxdy); m_force_ry -= (forceinty * dxdy); m_power_trans += (forcetransx * VxVy[0] + forcetransy * VxVy[1]) * dxdy; m_power_con += (forceconvectx * VxVy[0] + forceconvecty * VxVy[1]) * dxdy; m_power_g += (forcegravx * VxVy[0] + forcegravy * VxVy[1]) * dxdy; m_power_b -= (forcebedx * VxVy[0] + forcebedy * VxVy[1]) * dxdy; m_power_bc -= (forcebedx_curv * VxVy[0] + forcebedy_curv * VxVy[1]) * dxdy; m_power_r -= (forceintx * VxVy[0] + forceinty * VxVy[1]) * dxdy; m_Fr += (Local_Fr * dxdy * h[ndx]); m_vol += dxdy * h[ndx]; // Searching user-defined locations to record QoIs if (localquants_ptr->no_locations > 0) localquants_ptr->FindElement(dt, dx_[0][ndx], dx_[1][ndx], coord_[0][ndx], coord_[1][ndx], h[ndx], hVx[ndx], hVy[ndx], forcetransx, forcetransy, forceconvectx, forceconvecty, forcegravx, forcegravy, -forcebedx, -forcebedy, -forcebedx_curv, -forcebedy_curv, -forceintx, -forceinty, zeta_[0][ndx], zeta_[1][ndx], Local_Fr); } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_MIDIUM_CHUNK) \<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/integrators.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) \
100
n(phi2); double mu_3 = tan(phi3); //convinience ref tivector<double> *g=gravity_; <LOOP-START>reduction(+: m_forceint, m_forcebed, m_eroded, m_deposited, m_realvolume) for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { if(adapted_[ndx] <= 0)continue;//if this element does not belong on this processor don't involve!!! //if first order states was not updated as there is no predictor if(order==1) { for (int i = 0; i < NUM_STATE_VARS; i++) prev_state_vars_[i][ndx]=state_vars_[i][ndx]; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// double elem_forceint; double elem_forcebed; double elem_eroded; double elem_deposited; double dxdy = dx_[0][ndx] * dx_[1][ndx]; double dtdx = dt / dx_[0][ndx]; double dtdy = dt / dx_[1][ndx]; int xp = positive_x_side_[ndx]; int yp = (xp + 1) % 4; int xm = (xp + 2) % 4; int ym = (xp + 3) % 4; int ivar, j, k; double fluxxp[NUM_STATE_VARS], fluxyp[NUM_STATE_VARS]; double fluxxm[NUM_STATE_VARS], fluxym[NUM_STATE_VARS]; ti_ndx_t nxp = node_key_ndx_[xp + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxxp[ivar] = node_flux_[ivar][nxp]; ti_ndx_t nyp = node_key_ndx_[yp + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxyp[ivar] = node_flux_[ivar][nyp]; ti_ndx_t nxm = node_key_ndx_[xm + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxxm[ivar] = node_flux_[ivar][nxm]; ti_ndx_t nym = node_key_ndx_[ym + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxym[ivar] = node_flux_[ivar][nym]; double VxVy[2]; if(h[ndx] > tiny) { VxVy[0] = hVx[ndx] / h[ndx]; VxVy[1] = hVy[ndx] / h[ndx]; } else { VxVy[0] = VxVy[1] = 0.0; } elements_[ndx].convect_dryline(VxVy[0], VxVy[1], dt); //this is necessary /////////////////////////////////////////////////////////////////////////////////////////////////////////////// //corrector itself double speed; double forceintx, forceinty; double forcebedx, forcebedy; double forcebedx_curv, forcebedy_curv; double forcegravx, forcegravy; double unitvx, unitvy, tmp; double Ustore[3]; double mu_bed, Local_Fr; Ustore[0] = prev_state_vars_[0][ndx] - dtdx * (fluxxp[0] - fluxxm[0]) - dtdy * (fluxyp[0] - fluxym[0]) + dt * Influx_[0][ndx]; Ustore[0] = c_dmax1(Ustore[0], 0.0); Ustore[1] = prev_state_vars_[1][ndx] - dtdx * (fluxxp[1] - fluxxm[1]) - dtdy * (fluxyp[1] - fluxym[1]) + dt * Influx_[1][ndx]; Ustore[2] = prev_state_vars_[2][ndx] - dtdx * (fluxxp[2] - fluxxm[2]) - dtdy * (fluxyp[2] - fluxym[2]) + dt * Influx_[2][ndx]; // initialize to zero forceintx = 0.0; forcebedx = 0.0; forcebedx_curv = 0.0; forcebedy_curv = 0.0; forceinty = 0.0; forcebedy = 0.0; unitvx = 0.0; unitvy = 0.0; elem_eroded = 0.0; mu_bed = 0.0; if(h[ndx] > tiny) { double inertial_x,inertial_y,drag_x, drag_y; // S terms // here speed is speed squared speed = VxVy[0] * VxVy[0] + VxVy[1] * VxVy[1]; if (speed > 0.0) { // here speed is speed speed = sqrt(speed); unitvx = VxVy[0] / speed; unitvy = VxVy[1] / speed; } else { unitvx = 0.0; unitvy = 0.0; } // Calculation of Froude number Local_Fr = speed / sqrt( g[2][ndx] * h[ndx] * scale_.epsilon); //ccccccccccccccc Calculation of mu_bed(Local_Fr,h) ccccccccccccccccc //Dynamic flow regime if ( Local_Fr >= Beta ) mu_bed = mu_1 + ( mu_2 - mu_1 ) / ( 1.0 + h[ndx] * Beta / ( L_material * Local_Fr ) ); //Intermediate flow regime else if ( ( Local_Fr < Beta ) && ( Local_Fr > 0.0 ) ) mu_bed = mu_3 + pow( ( Local_Fr / Beta ), 0.001 ) * ( mu_1 - mu_3 ) + ( mu_2 - mu_1 ) / ( 1.0 + h[ndx] / L_material ); //Static regime else if ( Local_Fr == 0.0 ) mu_bed = mu_3 + ( mu_2 - mu_1 ) / ( 1.0 + h[ndx] / L_material); //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // x direction source terms //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // The gravity force in the x direction forcegravx = g[0][ndx] * h[ndx]; // The basal friction forces in x direction tmp = c_dmax1(g[2][ndx] * h[ndx] + VxVy[0] * hVx[ndx] * curvature_[0][ndx], 0.0); if (tmp > 0.0){ forcebedx = unitvx * mu_bed * g[2][ndx] * h[ndx]; forcebedx_curv = unitvx * mu_bed * VxVy[0] * hVx[ndx] * curvature_[0][ndx]; } // The resisting forces due to flow thickness gradient in x direction forceintx = h[ndx] * g[2][ndx] * dh_dx[ndx] * scale_.epsilon; //STOPPING CRITERIA inertial_x = fabs( Ustore[1] + dt * forcegravx ); drag_x = fabs( dt * ( forcebedx + forcebedx_curv + forceintx ) ); if ( inertial_x > drag_x ) Ustore[1] = Ustore[1] + dt * ( forcegravx - forcebedx - forcebedx_curv - forceintx ); else Ustore[1] = 0.0; //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // y direction source terms //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // The gravity force in the y direction forcegravy = g[1][ndx] * h[ndx]; // The basal friction forces in y direction tmp = c_dmax1(g[2][ndx] * h[ndx] + VxVy[1] * hVy[ndx] * curvature_[1][ndx], 0.0); if (tmp > 0.0){ forcebedy = unitvy * mu_bed * g[2][ndx] * h[ndx]; forcebedy_curv = unitvy * mu_bed * VxVy[1] * hVy[ndx] * curvature_[1][ndx]; } // The resisting forces due to flow thickness gradient in y direction forceinty = h[ndx] * g[2][ndx] * dh_dy[ndx] * scale_.epsilon; //STOPPING CRITERIA inertial_y = fabs( Ustore[2] + dt * forcegravy ); drag_y = fabs( dt * ( forcebedy + forcebedy_curv + forceinty ) ); if ( inertial_y > drag_y ) Ustore[2] = Ustore[2] + dt * ( forcegravy - forcebedy - forcebedy_curv - forceinty ); else Ustore[2] = 0.0; } // computation of magnitude of friction forces for statistics elem_forceint = unitvx * forceintx + unitvy*forceinty; elem_forcebed = unitvx * forcebedx + unitvy*forcebedy; // update the state variables h[ndx]=Ustore[0]; hVx[ndx]=Ustore[1]; hVy[ndx]=Ustore[2]; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// elem_forceint *= dxdy; elem_forcebed *= dxdy; elem_eroded *= dxdy; if(stoppedflags_[ndx] == 2) elem_deposited = h[ndx] * dxdy; else elem_deposited = 0.0; if(stoppedflags_[ndx]) elem_eroded = 0.0; elements_[ndx].calc_shortspeed(1.0 / dt); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// m_forceint += fabs(elem_forceint); m_forcebed += fabs(elem_forcebed); m_realvolume += dxdy * h[ndx]; m_eroded += elem_eroded; m_deposited += elem_deposited; // apply bc's for (int j = 0; j < 4; j++) if (neigh_proc_[j][ndx] == INIT) // this is a boundary! for (int k = 0; k < NUM_STATE_VARS; k++) state_vars_[k][ndx] = 0.0; }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) \<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/integrators.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_MIDIUM_CHUNK) \
100
ocalquants_ptr->temps[iloc].resize(0); localquants_ptr->TimeInts[iloc].resize(0); } <LOOP-START>reduction(+: m_force_transx, m_force_transy, m_force_conx, m_force_cony, m_force_gx, m_force_gy) \ reduction(+: m_force_bx, m_force_by, m_force_bcx, m_force_bcy, m_force_rx, m_force_ry) \ reduction(+: m_power_con, m_power_g, m_power_b, m_power_bc, m_power_r, m_Fr, m_vol) for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { if(adapted_[ndx] <= 0)continue;//if this element does not belong on this processor don't involve!!! if(h[ndx] > localquants_ptr->thr) { /////////////////////////////////////////////////////////////////////////////////////////////////////////////// double dxdy = dx_[0][ndx] * dx_[1][ndx]; double dtdx = dt / dx_[0][ndx]; double dtdy = dt / dx_[1][ndx]; int xp = positive_x_side_[ndx]; int yp = (xp + 1) % 4; int xm = (xp + 2) % 4; int ym = (xp + 3) % 4; int ivar; double fluxxp[MAX_NUM_STATE_VARS], fluxyp[MAX_NUM_STATE_VARS]; double fluxxm[MAX_NUM_STATE_VARS], fluxym[MAX_NUM_STATE_VARS]; ti_ndx_t nxp = node_key_ndx_[xp + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxxp[ivar] = node_flux_[ivar][nxp]; ti_ndx_t nyp = node_key_ndx_[yp + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxyp[ivar] = node_flux_[ivar][nyp]; ti_ndx_t nxm = node_key_ndx_[xm + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxxm[ivar] = node_flux_[ivar][nxm]; ti_ndx_t nym = node_key_ndx_[ym + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxym[ivar] = node_flux_[ivar][nym]; double VxVy[2]; VxVy[0] = hVx[ndx] / h[ndx]; VxVy[1] = hVy[ndx] / h[ndx]; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// double speed; double forcetransx, forcetransy; double forceconvectx, forceconvecty; double forceintx, forceinty; double forcebedx, forcebedy; double forcebedx_curv, forcebedy_curv; double forcegravx , forcegravy; double unitvx, unitvy, tmp; double mu_bed, Local_Fr; // initialize to zero forcetransx = forcetransy = 0.0; forceconvectx = forceconvecty = 0.0; forceintx = forcebedx = 0.0; forcebedx_curv = forcebedy_curv = 0.0; forceinty = forcebedy = 0.0; unitvx = unitvy = 0.0; // S terms // here speed is speed squared speed = VxVy[0] * VxVy[0] + VxVy[1] * VxVy[1]; if (speed > 0.0) { speed = sqrt(speed); unitvx = VxVy[0] / speed; unitvy = VxVy[1] / speed; } else { unitvx = 0.0; unitvy = 0.0; } Local_Fr = speed / sqrt( g[2][ndx] * h[ndx] * scale_.epsilon); //ccccccccccccccc Calculation of mu_bed(Local_Fr,h) ccccccccccccccccc //Dynamic flow regime if ( Local_Fr >= Beta ) mu_bed = mu_1 + ( mu_2 - mu_1 ) / ( 1.0 + h[ndx] * Beta / ( L_material * Local_Fr ) ); //Intermediate flow regime else if ( ( Local_Fr < Beta ) && ( Local_Fr > 0.0 ) ) mu_bed = mu_3 + pow( ( Local_Fr / Beta ), 0.001 ) * ( mu_1 - mu_3 ) + ( mu_2 - mu_1 ) / ( 1.0 + h[ndx] / L_material ); //Static regime else if ( Local_Fr == 0.0 ) mu_bed = mu_3 + ( mu_2 - mu_1 ) / ( 1.0 + h[ndx] / L_material); //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // x direction source terms //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // the transient force in the x direction forcetransx = (hVx[ndx] - prev_state_vars_[1][ndx]) / dt; // the convective in x direction forceconvectx = (fluxxp[1] - fluxxm[1]) / dx_[0][ndx] + (fluxyp[1] - fluxym[1]) / dx_[1][ndx]; // The gravity force in the x direction forcegravx = g[0][ndx] * h[ndx]; // The basal friction forces in x direction tmp = c_dmax1(g[2][ndx] * h[ndx] + VxVy[0] * hVx[ndx] * curvature_[0][ndx], 0.0); if (tmp > 0.0){ forcebedx = unitvx * mu_bed * g[2][ndx] * h[ndx]; forcebedx_curv = unitvx * mu_bed * VxVy[0] * hVx[ndx] * curvature_[0][ndx]; } // The resisting forces due to flow thickness gradient in x direction forceintx = h[ndx] * g[2][ndx] * dh_dx[ndx] * scale_.epsilon; //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // y direction source terms //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // the transient force in the y direction forcetransy = (hVy[ndx] - prev_state_vars_[2][ndx]) / dt; // the convective in y direction forceconvecty = (fluxxp[2] - fluxxm[2]) / dx_[0][ndx] + (fluxyp[2] - fluxym[2]) / dx_[1][ndx]; // The gravity force in the y direction forcegravy = g[1][ndx] * h[ndx]; // The basal friction forces in y direction tmp = c_dmax1(g[2][ndx] * h[ndx] + VxVy[1] * hVy[ndx] * curvature_[1][ndx], 0.0); if (tmp > 0.0){ forcebedy = unitvy * mu_bed * g[2][ndx] * h[ndx]; forcebedy_curv = unitvy * mu_bed * VxVy[1] * hVy[ndx] * curvature_[1][ndx]; } // The resisting forces due to flow thickness gradient in y direction forceinty = h[ndx] * g[2][ndx] * dh_dy[ndx] * scale_.epsilon; ///////////////////////////////////////////////////////////////////////////// // Recording QoIs globally from updated cells at current time m_force_transx += (forcetransx * dxdy); m_force_transy += (forcetransy * dxdy); m_force_conx += (forceconvectx * dxdy); m_force_cony += (forceconvecty * dxdy); m_force_gx += (forcegravx * dxdy); m_force_gy += (forcegravy * dxdy); m_force_bx -= (forcebedx * dxdy); m_force_by -= (forcebedy * dxdy); m_force_bcx -= (forcebedx_curv * dxdy); m_force_bcy -= (forcebedy_curv * dxdy); m_force_rx -= (forceintx * dxdy); m_force_ry -= (forceinty * dxdy); m_power_trans += (forcetransx * VxVy[0] + forcetransy * VxVy[1]) * dxdy; m_power_con += (forceconvectx * VxVy[0] + forceconvecty * VxVy[1]) * dxdy; m_power_g += (forcegravx * VxVy[0] + forcegravy * VxVy[1]) * dxdy; m_power_b -= (forcebedx * VxVy[0] + forcebedy * VxVy[1]) * dxdy; m_power_bc -= (forcebedx_curv * VxVy[0] + forcebedy_curv * VxVy[1]) * dxdy; m_power_r -= (forceintx * VxVy[0] + forceinty * VxVy[1]) * dxdy; m_Fr += (Local_Fr * dxdy * h[ndx]); m_vol += dxdy * h[ndx]; // Searching user-defined locations to record QoIs if (localquants_ptr->no_locations > 0) localquants_ptr->FindElement(dt, dx_[0][ndx], dx_[1][ndx], coord_[0][ndx], coord_[1][ndx], h[ndx], hVx[ndx], hVy[ndx], forcetransx, forcetransy, forceconvectx, forceconvecty, forcegravx, forcegravy, -forcebedx, -forcebedy, -forcebedx_curv, -forcebedy_curv, -forceintx, -forceinty, zeta_[0][ndx], zeta_[1][ndx], Local_Fr); } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_MIDIUM_CHUNK) \<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/integrators.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) \
100
a dependency in the Element class that causes incorrect // results <LOOP-START>reduction(+: m_forceint, m_forcebed, m_eroded, m_deposited, m_realvolume) for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { if(adapted_[ndx] <= 0)continue;//if this element does not belong on this processor don't involve!!! //if first order states was not updated as there is no predictor if(order==1) { for (int i = 0; i < NUM_STATE_VARS; i++) prev_state_vars_[i][ndx]=state_vars_[i][ndx]; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// double elem_forceint; double elem_forcebed; double elem_eroded; double elem_deposited; double dxdy = dx_[0][ndx] * dx_[1][ndx]; double dtdx = dt / dx_[0][ndx]; double dtdy = dt / dx_[1][ndx]; int xp = positive_x_side_[ndx]; int yp = (xp + 1) % 4; int xm = (xp + 2) % 4; int ym = (xp + 3) % 4; int ivar, j, k; double fluxxp[NUM_STATE_VARS], fluxyp[NUM_STATE_VARS]; double fluxxm[NUM_STATE_VARS], fluxym[NUM_STATE_VARS]; ti_ndx_t nxp = node_key_ndx_[xp + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxxp[ivar] = node_flux_[ivar][nxp]; ti_ndx_t nyp = node_key_ndx_[yp + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxyp[ivar] = node_flux_[ivar][nyp]; ti_ndx_t nxm = node_key_ndx_[xm + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxxm[ivar] = node_flux_[ivar][nxm]; ti_ndx_t nym = node_key_ndx_[ym + 4][ndx]; for(ivar = 0; ivar < NUM_STATE_VARS; ivar++) fluxym[ivar] = node_flux_[ivar][nym]; /* the values being passed to correct are for a SINGLE element, NOT a region, as such the only change that having variable bedfriction requires is to pass the bedfriction angle for the current element rather than the only bedfriction I wonder if this is legacy code, it seems odd that it is only called for the SUN Operating System zee ../geoflow/correct.f */ //#ifdef STOPPED_FLOWS #ifdef STOPCRIT_CHANGE_SOURCE int IF_STOPPED=stoppedflags_[ndx]; #else int IF_STOPPED = !(!stoppedflags_[ndx]); // double g[3]{gravity_[0][ndx],gravity_[1][ndx],gravity_[2][ndx]}; double d_g[3]{d_gravity_[0][ndx],d_gravity_[1][ndx],d_gravity_[2][ndx]}; int i; double kactxy[DIMENSION]; double bedfrict = effect_bedfrict_[ndx]; double Vfluid[DIMENSION]; double volf; if(h[ndx] > GEOFLOW_TINY) { for(i = 0; i < DIMENSION; i++) kactxy[i] = effect_kactxy_[i][ndx]; // fluid velocities Vfluid[0] = hVx_liq[ndx] / h[ndx]; Vfluid[1] = hVy_liq[ndx] / h[ndx]; // volume fractions volf = h_liq[ndx] / h[ndx]; } else { for(i = 0; i < DIMENSION; i++) { kactxy[i] = matprops2_ptr->scale.epsilon; Vfluid[i] = 0.; } volf = 1.; bedfrict = matprops2_ptr->bedfrict[material_[ndx]]; } double Vsolid[DIMENSION]; if(h_liq[ndx] > GEOFLOW_TINY) { Vsolid[0] = hVx_sol[ndx] / h_liq[ndx]; Vsolid[1] = hVy_sol[ndx] / h_liq[ndx]; } else { Vsolid[0] = Vsolid[1] = 0.0; } double V_avg[DIMENSION]; V_avg[0] = Vsolid[0] * volf + Vfluid[0] * (1. - volf); V_avg[1] = Vsolid[1] * volf + Vfluid[1] * (1. - volf); elements_[ndx].convect_dryline(V_avg[0],V_avg[1], dt); //this is necessary double curv_x=curvature_[0][ndx]; double curv_y=curvature_[1][ndx]; double xslope=zeta_[0][ndx]; double yslope=zeta_[1][ndx]; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// //corrector double speed; double forceintx, forceinty; double forcebedx, forcebedy; double forcebedmax, forcebedequil, forcegrav; double unitvx, unitvy; double den_frac; double alphaxx, alphayy, alphaxy, alphaxz, alphayz; double tanbed; double Ustore[6]; double h_inv, hphi_inv; double sgn_dudy, sgn_dvdx, tmp; double slope; double t1, t2, t3, t4, t5; double es, totalShear; double drag[4]; // initialize to zero forceintx = 0.0; forcebedx = 0.0; forceinty = 0.0; forcebedy = 0.0; unitvx = 0.0; unitvy = 0.0; elem_eroded = 0.0; slope = sqrt(xslope * xslope + yslope * yslope); den_frac = den_fluid / den_solid; for (i = 0; i < 6; ++i) Ustore[i] = prev_state_vars_[i][ndx] + dt * Influx_[i][ndx] - dtdx * (fluxxp[i] - fluxxm[i]) - dtdy * (fluxyp[i] - fluxym[i]); if (Ustore[0] > tiny) { // Source terms ... // here speed is speed squared speed = Vsolid[0] * Vsolid[0] + Vsolid[1] * Vsolid[1]; if (speed > 0.0) { // here speed is speed speed = sqrt(speed); unitvx = Vsolid[0] / speed; unitvy = Vsolid[1] / speed; } else { unitvx = 0.0; unitvy = 0.0; } tanbed = tan(bedfrict); h_inv = 1.0 / h[ndx]; hphi_inv = 1.0 / h_liq[ndx]; alphaxx = kactxy[0]; alphayy = kactxy[0]; den_frac = den_fluid / den_solid; calc_drag_force(ndx, Vsolid, Vfluid, den_solid, den_fluid,terminal_vel, drag); //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // solid fraction x-direction source terms //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // alphaxy -- see pitman-le (2005) tmp = hphi_inv * (dhVx_sol_dy[ndx] - Vsolid[0] * dh_liq_dy[ndx]); sgn_dudy = sgn_tiny(tmp, frict_tiny); alphaxy = sgn_dudy * sin_intfrictang * kactxy[0]; // alphaxz (includes centrifugal effects) alphaxz = -unitvx * tanbed * (1.0 + (Vsolid[0] * Vsolid[0]) * curv_x / g[2]); // evaluate t1 t1 = (1.0 - den_frac) * (-alphaxx * xslope - alphaxy * yslope + alphaxz) * h_liq[ndx] * g[2]; // evaluate t2 t2 = epsilon * den_frac * h_liq[ndx] * g[2] * dh_dx[ndx]; // evaluate t3 t3 = epsilon * den_frac * h_liq[ndx] * g[2] * xslope; // evaluate t4 t4 = h_liq[ndx] * g[0]; // evaluate drag t5 = drag[0]; // update Ustore Ustore[2] = Ustore[2] + dt * (t1 - t2 - t3 + t4 + t5); //ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // solid fraction y-direction source terms //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // alphaxy -- see pitman-le (2005) for definitions tmp = hphi_inv * (dhVy_sol_dx[ndx] - Vsolid[1] * dh_liq_dx[ndx]); sgn_dvdx = sgn_tiny(tmp, frict_tiny); alphaxy = sgn_dvdx * sin_intfrictang * kactxy[0]; // alphayz alphayz = -unitvy * tanbed * (1.0 + (Vsolid[1] * Vsolid[1]) * curv_y / g[2]); // evaluate t1 t1 = (1.0 - den_frac) * (-alphaxy * xslope - alphayy * yslope + alphayz) * h_liq[ndx] * g[2]; // evaluate t2 t2 = epsilon * den_frac * h_liq[ndx] * dh_dy[ndx]; // evaluate t3 t3 = epsilon * den_frac * h_liq[ndx] * g[2] * yslope; // evaluate t4 ( gravity along y-dir ) t4 = h_liq[ndx] * g[1]; // drag term t5 = drag[1]; Ustore[3] = Ustore[3] + dt * (t1 - t2 - t3 + t4 + t5); //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // fluid fraction x-direction source terms //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // gravity on fluid t4 = h[ndx] * g[0]; // drag force on fluid t5 = drag[2]; Ustore[4] = Ustore[4] + dt * (t4 - t5); //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // fluid fraction y-direction source terms //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // gravity on fluid t4 = h[ndx] * g[1]; // drag force on fluid t5 = drag[3]; Ustore[5] = Ustore[5] + dt * (t4 - t5); } // computation of magnitude of friction forces for statistics elem_forceint = unitvx * forceintx + unitvy * forceinty; elem_forcebed = unitvx * forcebedx + unitvy * forcebedy; // update the state variables for (i = 0; i < 6; ++i) state_vars_[i][ndx]=Ustore[i]; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// elem_forceint *= dxdy; elem_forcebed *= dxdy; elem_eroded *= dxdy; if(stoppedflags_[ndx] == 2) elem_deposited = h[ndx] * dxdy; else elem_deposited = 0.0; if(stoppedflags_[ndx]) elem_eroded = 0.0; elements_[ndx].calc_shortspeed(1.0 / dt); //correct(elementType, NodeTable, ElemTable, dt, matprops_ptr, fluxprops_ptr, timeprops_ptr, this, Curr_El_out, &elemforceint, // &elemforcebed, &elemeroded, &elemdeposited); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// m_forceint += fabs(elem_forceint); m_forcebed += fabs(elem_forcebed); m_realvolume += dxdy * h[ndx]; m_eroded += elem_eroded; m_deposited += elem_deposited; // apply bc's for(int j = 0; j < 4; j++) if(neigh_proc_[j][ndx] == INIT) // this is a boundary! for(int k = 0; k < NUM_STATE_VARS; k++) state_vars_[k][ndx]=0.0; }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) \<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/integrators.C
#pragma omp parallel for \
100
; double VxVy[2]; double dt2 = .5 * dt; // dt2 is set as dt/2 ! Element* Curr_El; //<LOOP-START>//private(currentPtr,Curr_El,IF_STOPPED,influx,j,k,curr_time,flux_src_coef,VxVy) for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { Curr_El = &(elements_[ndx]); elements_[ndx].update_prev_state_vars(); influx[0] = Curr_El->Influx(0); influx[1] = Curr_El->Influx(1); influx[2] = Curr_El->Influx(2); //note, now there is no check for fluxes from non-local elements if(!(influx[0] >= 0.0)) { printf("negative influx=%g\n", influx[0]); assert(0); } // -- calc contribution of flux source curr_time = (timeprops_ptr->cur_time) * (timeprops_ptr->TIME_SCALE); //VxVy[2]; if(Curr_El->state_vars(0) > GEOFLOW_TINY) { VxVy[0] = Curr_El->state_vars(1) / Curr_El->state_vars(0); VxVy[1] = Curr_El->state_vars(2) / Curr_El->state_vars(0); } else VxVy[0] = VxVy[1] = 0.0; #ifdef STOPCRIT_CHANGE_SOURCE IF_STOPPED=Curr_El->stoppedflags(); #else IF_STOPPED = !(!(Curr_El->stoppedflags())); double gravity[3]{Curr_El->gravity(0),Curr_El->gravity(1),Curr_El->gravity(2)}; double d_gravity[3]{Curr_El->d_gravity(0),Curr_El->d_gravity(1),Curr_El->d_gravity(2)}; if(elementType == ElementType::TwoPhases) { //nothing there } if(elementType == ElementType::SinglePhase) { predict(Curr_El, Curr_El->dh_dx(), Curr_El->dhVx_dx(), Curr_El->dhVy_dx(), Curr_El->dh_dy(), Curr_El->dhVx_dy(), Curr_El->dhVy_dy(), tiny, Curr_El->kactxy(0), dt2, gravity, Curr_El->curvature(0), Curr_El->curvature(1), matprops_ptr->bedfrict[Curr_El->material()], matprops_ptr->intfrict, d_gravity, matprops_ptr->frict_tiny, order, VxVy, IF_STOPPED, influx); } // apply bc's for(int j = 0; j < 4; j++) if(Curr_El->neigh_proc(j) == INIT) // this is a boundary! for(int k = 0; k < NUM_STATE_VARS; k++) Curr_El->state_vars(k,0.0); }<LOOP-END> <OMP-START>#pragma omp parallel for \<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/stats.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) \
100
NOTATE_SITE_BEGIN(StatProps_calc_stats); //ANNOTATE_TASK_BEGIN(StatProps_calc_stats_loop); <LOOP-START>reduction(min:m_x_min,m_y_min,testpointmindist2) \ reduction(max:m_x_max,m_y_max,m_v_max,testpointreach) \ reduction(max:m_max_height) \ reduction(+:xC,yC,rC,m_area,m_v_ave,m_vx_ave,m_vy_ave)\ reduction(+:m_Vol_,m_Area_,m_Velmean_) \ reduction(+:m_piler2,testvolume,m_xVar,m_yVar) /*m_slope_ave,m_slopevolume*/ for(ti_ndx_t ndx = 0; ndx < N; ndx++) { if(adapted_[ndx] > 0 && myid == myprocess_[ndx]) { Element* Curr_El = &(ElemTable->elenode_[ndx]); if(discharge->num_planes>0) { //calculate volume passing through "discharge planes" double nodescoord[9][2]; Node* node; for(int inode = 0; inode < 8; inode++) { nodescoord[inode][0] = coord_[0][node_key_ndx_[inode][ndx]]; nodescoord[inode][1] = coord_[1][node_key_ndx_[inode][ndx]]; } nodescoord[8][0] = coord_[0][ndx]; nodescoord[8][1] = coord_[1][ndx]; discharge->update(nodescoord, hVx[ndx], hVy[ndx], d_time); } // rule out non physical fast moving thin layers //if(state_vars_[0][ndx] >= cutoffheight){ if(h[ndx] > min_height) { if(h[ndx] > m_max_height) m_max_height = h[ndx]; if(h[ndx] >= hxyminmax) { m_x_min = min(m_x_min,coord_[0][ndx]); m_x_max = max(m_x_max,coord_[0][ndx]); m_y_min = min(m_y_min,coord_[1][ndx]); m_y_max = max(m_y_max,coord_[1][ndx]); } //to test if pileheight of depth testpointheight //has reached the testpoint double testpointdist2 = (coord_[0][ndx] - testpointx) * (coord_[0][ndx] - testpointx) + (coord_[1][ndx] - testpointy) * (coord_[1][ndx] - testpointy); if(testpointdist2 < testpointmindist2) { testpointmindist2 = testpointdist2; testpointreach = h[ndx] >= testpointheight; } double dA = dx_[0][ndx] * dx_[1][ndx]; m_area += dA; double dVol = state_vars_[0][ndx] * dA; testvolume += dVol; xC += coord_[0][ndx] * dVol; yC += coord_[1][ndx] * dVol; m_xVar += coord_[0][ndx] * coord_[0][ndx] * dVol; m_yVar += coord_[1][ndx] * coord_[1][ndx] * dVol; m_piler2 += (coord_[0][ndx] * coord_[0][ndx] + coord_[1][ndx] * coord_[1][ndx]) * dVol; rC += sqrt((coord_[0][ndx] - m_xCen) * (coord_[0][ndx] - m_xCen) + (coord_[1][ndx] - m_yCen) * (coord_[1][ndx] - m_yCen)) * dVol; m_v_ave += sqrt(hVx[ndx] * hVx[ndx] + hVy[ndx] * hVy[ndx]) * dA; double VxVy[2]; Curr_El->eval_velocity(0.0, 0.0, VxVy); if(elementType == ElementType::TwoPhases) { if(std::isnan(m_v_ave)||std::isnan(state_vars_[0][ndx])||std::isnan(state_vars_[1][ndx])||std::isnan(state_vars_[2][ndx]) ||std::isnan(state_vars_[3][ndx])||std::isnan(state_vars_[4][ndx])||std::isnan(state_vars_[5][ndx])) { //v_ave is NaN cout<<"calc_stats(): NaN detected in element={"<<ElemTable->key_[ndx]<<"} at iter="<<timeprops->iter<<"\n"; printf("prevu={%12.6g,%12.6g,%12.6g,%12.6g,%12.6g,%12.6g}\n", prev_state_vars_[0][ndx], prev_state_vars_[1][ndx], prev_state_vars_[2][ndx], prev_state_vars_[3][ndx], prev_state_vars_[4][ndx], prev_state_vars_[5][ndx]); printf(" u={%12.6g,%12.6g,%12.6g,%12.6g,%12.6g,%12.6g}\n", state_vars_[0][ndx], state_vars_[1][ndx], state_vars_[2][ndx], state_vars_[3][ndx], state_vars_[4][ndx], state_vars_[5][ndx]); printf("prev {Vx_s, Vy_s, Vx_f, Vy_f}={%12.6g,%12.6g,%12.6g,%12.6g}\n", prev_state_vars_[2][ndx] / (prev_state_vars_[1][ndx]), prev_state_vars_[3][ndx] / (prev_state_vars_[1][ndx]), prev_state_vars_[4][ndx] / (prev_state_vars_[0][ndx]), prev_state_vars_[5][ndx] / (prev_state_vars_[0][ndx])); printf("this {Vx_s, Vy_s, Vx_f, Vy_f}={%12.6g,%12.6g,%12.6g,%12.6g}\n", state_vars_[2][ndx] / state_vars_[1][ndx], state_vars_[3][ndx] / state_vars_[1][ndx], state_vars_[4][ndx] / state_vars_[0][ndx], state_vars_[5][ndx] / state_vars_[0][ndx]); ElemBackgroundCheck2(ElemTable, NodeTable, &(ElemTable->elenode_[ndx]), stdout); assert(0); } } if(elementType == ElementType::SinglePhase) { if(std::isnan(m_v_ave)||std::isnan(state_vars_[0][ndx])||std::isnan(state_vars_[1][ndx])||std::isnan(state_vars_[2][ndx])) { //v_ave is NaN cout<<"calc_stats(): NaN detected in element={"<<ElemTable->key_[ndx]<<"} at iter="<<timeprops->iter<<"\n"; printf("prevu={%12.6g,%12.6g,%12.6g}\n", prev_state_vars_[0][ndx], prev_state_vars_[1][ndx], prev_state_vars_[2][ndx]); printf(" u={%12.6g,%12.6g,%12.6g}\n", state_vars_[0][ndx], state_vars_[1][ndx], state_vars_[2][ndx]); printf("prev {hVx/h,hVy/h}={%12.6g,%12.6g}\n", prev_state_vars_[1][ndx] / prev_state_vars_[0][ndx], prev_state_vars_[2][ndx] / prev_state_vars_[0][ndx]); printf("this {hVx/h,hVy/h}={%12.6g,%12.6g}\n", state_vars_[1][ndx] / state_vars_[0][ndx], state_vars_[2][ndx] / state_vars_[0][ndx]); ElemBackgroundCheck2(ElemTable, NodeTable, &(ElemTable->elenode_[ndx]), stdout); assert(0); } } double temp = sqrt(VxVy[0] * VxVy[0] + VxVy[1] * VxVy[1]); m_v_max = max(m_v_max,temp); m_vx_ave += hVx[ndx] * dA; m_vy_ave += hVy[ndx] * dA; //these are garbage, Bin Yu wanted them when he was trying to come up //with a global stopping criteria (to stop the calculation, not the pile) //volume averaged slope in the direction of velocity //a negative number means the flow is headed uphill /*double xslope = 0, yslope = 0; Get_slope(resolution, coord_[0][ndx] * matprops->scale.length, coord_[1][ndx] * matprops->scale.length, xslope, yslope); if(temp > GEOFLOW_TINY) { m_slope_ave += -(hVx[ndx] * xslope + hVy[ndx] * yslope) * dA / temp; m_slopevolume += dVol; }*/ } if (_LocalQuants->no_locations > 0 && h[ndx] > _LocalQuants->thr) { dA_ = dx_[0][ndx] * dx_[1][ndx]; m_Area_ += dA_; m_Vol_ += h[ndx] * dA_; m_Velmean_ += sqrt(hVx[ndx] * hVx[ndx] + hVy[ndx] * hVy[ndx]) * dA_; } } } //ANNOTATE_TASK_END(StatProps_calc_stats_loop); //ANNOTATE_SITE_END(StatProps_calc_stats); #ifdef USE_MPI MPI_Reduce(&m_x_min, xyminmax, 1, MPI_DOUBLE, MPI_MIN, 0, MPI_COMM_WORLD); MPI_Reduce(&m_x_max, xyminmax+1, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); MPI_Reduce(&m_y_min, xyminmax+2, 1, MPI_DOUBLE, MPI_MIN, 0, MPI_COMM_WORLD); MPI_Reduce(&m_y_max, xyminmax+3, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); #else //USE_MPI xyminmax[0]=m_x_min; xyminmax[1]=m_x_max; xyminmax[2]=m_y_min; xyminmax[3]=m_y_max; //USE_MPI if(myid == 0) { xyminmax[0] *= matprops->scale.length; xyminmax[1] *= matprops->scale.length; xyminmax[2] *= matprops->scale.length; xyminmax[3] *= matprops->scale.length; } int inttempout; double tempin[17], tempout[17], temp2in[2], temp2out[2]; //find the minimum distance (squared) to the test point #ifdef USE_MPI MPI_Allreduce(&testpointmindist2, tempout, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); #else //USE_MPI tempout[0]=testpointmindist2; //USE_MPI //if this processor isn't the closest to the test point it doesn't count as it's flow reaching the point if(tempout[0] < testpointmindist2) testpointreach = 0; //did the closest point to the test point get reached by the flow? #ifdef USE_MPI MPI_Reduce(&testpointreach, &inttempout, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD); #else //USE_MPI inttempout=testpointreach; //USE_MPI testpointreach = inttempout; tempin[0] = xC; tempin[1] = yC; tempin[2] = rC; tempin[3] = m_area; tempin[4] = m_v_ave; tempin[5] = m_vx_ave; tempin[6] = m_vy_ave; tempin[7] = 0.0;//m_slope_ave; tempin[8] = m_piler2; tempin[9] = 0.0;//m_slopevolume; tempin[10] = testvolume; tempin[11] = m_xVar; tempin[12] = m_yVar; tempin[13] = ElemTable->get_no_of_entries(); tempin[14] = m_Vol_; tempin[15] = m_Area_; tempin[16] = m_Velmean_; #ifdef USE_MPI i = MPI_Reduce(tempin, tempout, 16, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); #else //USE_MPI for(int i=0;i<17;++i)tempout[i]=tempin[i]; //USE_MPI temp2in[0] = m_max_height; temp2in[1] = m_v_max; #ifdef USE_MPI i = MPI_Reduce(temp2in, temp2out, 2, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); #else //USE_MPI for(int i=0;i<2;++i)temp2out[i]=temp2in[i]; //USE_MPI if(myid == 0) { if(testpointreach && (timereached < 0.0)) timereached = timeprops->timesec(); double AREA_SCALE = (matprops->scale.length) * (matprops->scale.length); double VOL_SCALE = AREA_SCALE * (matprops->scale.height); double VELOCITY_SCALE = sqrt(matprops->scale.length * matprops->scale.gravity); //dimensionalize xcen = tempout[0] * (matprops->scale.length) / tempout[10]; ycen = tempout[1] * (matprops->scale.length) / tempout[10]; xvar = tempout[11] * AREA_SCALE / tempout[10] - (xcen) * (xcen); yvar = tempout[12] * AREA_SCALE / tempout[10] - (ycen) * (ycen); rmean = tempout[2] * (matprops->scale.length) / tempout[10]; area = tempout[3] * AREA_SCALE; vmean = tempout[4] * VELOCITY_SCALE / tempout[10]; vxmean = tempout[5] * VELOCITY_SCALE / tempout[10]; vymean = tempout[6] * VELOCITY_SCALE / tempout[10]; //slopemean = (tempout[9] > 0) ? tempout[7] / tempout[9] : 0.0; realvolume = m_realvolume * VOL_SCALE; //statvolume is really testvolume which is statvolume if it's not disabled statvolume = tempout[10] * VOL_SCALE; cutoffheight = m_cutoffheight * (matprops->scale.height);//@TODO m_cutoffheight is not init testvolume = tempout[10] / m_statvolume;//@TODO m_statvolume is not init /* the factor of 3^0.5 is a safety factor, this value was chosen because * it makes the "radius" of a uniformly distributed line equal to half * the line length */ //3 standard deviations out ~ 99.5% of the material piler = 3.0 * sqrt(xvar + yvar); hmax = temp2out[0] * (matprops->scale.height); vmax = temp2out[1] * VELOCITY_SCALE; /* v_star is the nondimensional global average velocity by v_slump once v_slump HAS BEEN CALIBRATED (not yet done see ../main/datread.C) the calculation will terminate when v_star reaches 1 */ vstar = vmean / matprops->Vslump; Vol_ = tempout[14] * VOL_SCALE; Area_ = tempout[15] * AREA_SCALE; Velmean_ = VELOCITY_SCALE * tempout[16] / tempout[14]; /******************/ /* output section */ /******************/ /* output Center Of Mass and x and y components of mean velocity to assist the dynamic gis update daemon */ if(elementType == ElementType::SinglePhase) { FILE* fp2 = fopen("com.up", "w"); fprintf(fp2, "%d, %g, %g, %g, %g, %g, %g\n", timeprops->iter, timeprops->timesec(), xcen, ycen, vxmean, vymean, piler); fclose(fp2); if(_LocalQuants->no_locations > 0 && timeprops->iter % 5 == 4) { FILE* fp3 = fopen("Elements.info", "a"); fprintf(fp3, "%.0f, %g\n", tempout[13], timeprops->cur_time * timeprops->TIME_SCALE); fclose(fp3); } } /* standard to screen output */ d_time *= timeprops->TIME_SCALE; //chunk time int hours, minutes; double seconds; timeprops->chunktime(&hours, &minutes, &seconds); printf("At the end of time step %d the time is %d:%02d:%g (hrs:min:sec),\n", timeprops->iter, hours, minutes, seconds); printf("\ttime step length is %g [sec], volume is %g [m^3],\n", d_time, statvolume); printf("\tmax height is %g [m], max velocity is %g [m/s],\n", hmax, vmax); printf("\tave velocity is %g [m/s], v* = %g,\n", vmean, vstar); printf("\ttotal number of elements %.0f\n", tempout[13]); printf("\txyminmax %.9e %.9e %.9e %.9e\n", xyminmax[0], xyminmax[1], xyminmax[2], xyminmax[3]); printf("\n"); } return; }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) \<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/flux_srcs.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
>size(); if(fluxprops->MaxInfluxNow(matprops, timeprops) > 0.0) { <LOOP-START>for (ti_ndx_t ndx = 0; ndx < N; ndx++) { if (adapted[ndx] > 0) //if this element doesn't belong on this processor don't involve ElemTable->ElemProp->calc_flux(ndx, fluxprops, timeprops); }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/flux_srcs.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
p->calc_flux(ndx, fluxprops, timeprops); } } else { <LOOP-START>for (ti_ndx_t ndx = 0; ndx < N; ndx++) { if (adapted[ndx] > 0) //if this element doesn't belong on this processor don't involve elements[ndx].zero_influx(); }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/flux_srcs.C
#pragma omp parallel for private(entryptr,EmTemp)
100
rt(0); } */ // mdj 2007-04 Element *EmTemp; //<LOOP-START>//@ElementsBucketDoubleLoop for(int ibuck = 0; ibuck < no_of_buckets; ibuck++) { for(int ielm = 0; ielm < bucket[ibuck].ndx.size(); ielm++) { EmTemp = &(elenode_[bucket[ibuck].ndx[ielm]]); if(EmTemp->adapted_flag() > 0) //if this element doesn't belong on this processor don't involve EmTemp->calc_flux(NodeTable, fluxprops, timeprops); } }<LOOP-END> <OMP-START>#pragma omp parallel for private(entryptr,EmTemp)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/flux_srcs.C
#pragma omp parallel for private(entryptr,EmTemp)
100
} } else { // mdj 2007-04 Element *EmTemp; //<LOOP-START>//@ElementsBucketDoubleLoop for(int ibuck = 0; ibuck < no_of_buckets; ibuck++) { for(int ielm = 0; ielm < bucket[ibuck].ndx.size(); ielm++) { EmTemp = &(elenode_[bucket[ibuck].ndx[ielm]]); if(EmTemp->adapted_flag() > 0) //if this element doesn't belong on this processor don't involve EmTemp->zero_influx(); } }<LOOP-END> <OMP-START>#pragma omp parallel for private(entryptr,EmTemp)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/edge_states.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
ICAL_OMP vector<double> &localoutflow=dtmp; localoutflow.resize(elements_.size()); <LOOP-START>for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { localoutflow[ndx]=0.0; if(adapted_[ndx] > 0)//if this element does not belong on this processor don't involve!!! { //if this element doesn't belong on this processor don't involve double pheight = state_vars_[0][ndx]; elements_[ndx].calc_edge_states(ElemTable, NodeTable, matprops_ptr, integrator, myid, timeprops_ptr->dtime, order, &(localoutflow[ndx])); double pheight2 = state_vars_[0][ndx]; if(pheight != pheight2) printf("prolbem of changing height here,,,.....\n"); } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/edge_states.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) reduction(+:localoutflow_sum)
100
nts_.size(); ndx++) outflow+=localoutflow[ndx]; #else double localoutflow_sum=0.0; <LOOP-START>for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { if(adapted_[ndx] > 0)//if this element does not belong on this processor don't involve!!! { //if this element doesn't belong on this processor don't involve double pheight = state_vars_[0][ndx]; double localoutflow; elements_[ndx].calc_edge_states(ElemTable, NodeTable, matprops_ptr, integrator, myid, timeprops_ptr->dtime, order, &localoutflow); localoutflow_sum+=localoutflow; double pheight2 = state_vars_[0][ndx]; if(pheight != pheight2) printf("prolbem of changing height here,,,.....\n"); } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) reduction(+:localoutflow_sum)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/get_coef_and_eigen.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) reduction(min:min_dx_dy_evalue) reduction(max:hmax)
100
dt[2] = c_dmin1(dttemp, dttemp2); } //end of section that SHOULD ____NOT___ be openmp'd <LOOP-START>for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { if((adapted_[ndx] > 0) || ((adapted_[ndx] < 0) && (ghost_flag == 1))) { //if this element does not belong on this processor don't involve!!! if(h[ndx] > GEOFLOW_TINY) { double VxVy[2]; double evalue; /* calculate hmax */ if(hmax < h[ndx]) hmax = h[ndx]; gmfggetcoef_C(h[ndx], hVx[ndx], hVy[ndx], dh_dx[ndx], dhVx_dx[ndx], dh_dy[ndx], dhVy_dy[ndx], matprops_ptr->bedfrict[material_[ndx]], int_frict, kactxy_[0][ndx], kactxy_[1][ndx], tiny, scale_.epsilon); elements_[ndx].calc_stop_crit(matprops_ptr, this); if((stoppedflags_[ndx] < 0) || (stoppedflags_[ndx] > 2)) printf("get_coef_and_eigen stopped flag=%d\n", stoppedflags_[ndx]); //must use hVx/h and hVy/h rather than eval_velocity (L'Hopital's //rule speed if it is smaller) because underestimating speed (which //results in over estimating the timestep) is fatal to stability... VxVy[0] = hVx[ndx] / h[ndx]; VxVy[1] = hVy[ndx] / h[ndx]; //eigen_(EmTemp->eval_state_vars(u_vec_alt), eigen_C(h[ndx], eigenvxymax_[0][ndx],eigenvxymax_[1][ndx], evalue, tiny, kactxy_[0][ndx], gravity_[2][ndx], VxVy); // *********************************************************** // !!!!!!!!!!!!!!!!!!!!!check dx & dy!!!!!!!!!!!!!!!!!!!!!!!! // *********************************************************** if(evalue > 1000000000.) { double maxcurve = (dabs(curvature_[0][ndx]) > dabs(curvature_[1][ndx]) ? curvature_[0][ndx] : curvature_[1][ndx]); printf(" eigenvalue is %e for procd %d momentums are %e %e for pile height %e curvature=%e (x,y)=(%e,%e)\n", evalue, myid, hVx[ndx], hVy[ndx], h[ndx], maxcurve, coord_[0][ndx], coord_[1][ndx]); assert(0); } min_dx_dy_evalue = min( min(dx_[0][ndx], dx_[1][ndx]) / evalue, min_dx_dy_evalue); } else { stoppedflags_[ndx]=2; } } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) reduction(min:min_dx_dy_evalue) reduction(max:hmax)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/get_coef_and_eigen.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) reduction(min:min_dx_dy_evalue) reduction(max:hmax)
100
dt[2] = c_dmin1(dttemp, dttemp2); } //end of section that SHOULD ____NOT___ be openmp'd <LOOP-START>for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { if((adapted_[ndx] > 0) || ((adapted_[ndx] < 0) && (ghost_flag == 1))) { //if this element does not belong on this processor don't involve!!! if(h[ndx] > GEOFLOW_TINY) { double VxVy[2]; double evalue; /* calculate hmax */ if(hmax < h[ndx]) hmax = h[ndx]; gmfggetcoef_VS(kactxy_[0][ndx], kactxy_[1][ndx], scale_.epsilon); elements_[ndx].calc_stop_crit(matprops_ptr, this); if((stoppedflags_[ndx] < 0) || (stoppedflags_[ndx] > 2)) printf("get_coef_and_eigen stopped flag=%d\n", stoppedflags_[ndx]); //must use hVx/h and hVy/h rather than eval_velocity (L'Hopital's //rule speed if it is smaller) because underestimating speed (which //results in over estimating the timestep) is fatal to stability... VxVy[0] = hVx[ndx] / h[ndx]; VxVy[1] = hVy[ndx] / h[ndx]; //eigen_(EmTemp->eval_state_vars(u_vec_alt), eigen_VS(h[ndx], eigenvxymax_[0][ndx],eigenvxymax_[1][ndx], evalue, tiny, kactxy_[0][ndx], gravity_[2][ndx], VxVy); // *********************************************************** // !!!!!!!!!!!!!!!!!!!!!check dx & dy!!!!!!!!!!!!!!!!!!!!!!!! // *********************************************************** if(evalue > 1000000000.) { double maxcurve = (dabs(curvature_[0][ndx]) > dabs(curvature_[1][ndx]) ? curvature_[0][ndx] : curvature_[1][ndx]); printf(" eigenvalue is %e for procd %d momentums are %e %e for pile height %e curvature=%e (x,y)=(%e,%e)\n", evalue, myid, hVx[ndx], hVy[ndx], h[ndx], maxcurve, coord_[0][ndx], coord_[1][ndx]); assert(0); } min_dx_dy_evalue = min( min(dx_[0][ndx], dx_[1][ndx]) / evalue, min_dx_dy_evalue); } else { stoppedflags_[ndx]=2; } } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) reduction(min:min_dx_dy_evalue) reduction(max:hmax)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/get_coef_and_eigen.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) reduction(min:min_dx_dy_evalue) reduction(max:hmax)
100
dt[2] = c_dmin1(dttemp, dttemp2); } //end of section that SHOULD ____NOT___ be openmp'd <LOOP-START>for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { if((adapted_[ndx] > 0) || ((adapted_[ndx] < 0) && (ghost_flag == 1))) { //if this element does not belong on this processor don't involve!!! if(h[ndx] > GEOFLOW_TINY) { double VxVy[2]; double evalue; /* calculate hmax */ if(hmax < h[ndx]) hmax = h[ndx]; gmfggetcoef_PF(kactxy_[0][ndx], kactxy_[1][ndx], scale_.epsilon); elements_[ndx].calc_stop_crit(matprops_ptr, this); if((stoppedflags_[ndx] < 0) || (stoppedflags_[ndx] > 2)) printf("get_coef_and_eigen stopped flag=%d\n", stoppedflags_[ndx]); //must use hVx/h and hVy/h rather than eval_velocity (L'Hopital's //rule speed if it is smaller) because underestimating speed (which //results in over estimating the timestep) is fatal to stability... VxVy[0] = hVx[ndx] / h[ndx]; VxVy[1] = hVy[ndx] / h[ndx]; //eigen_(EmTemp->eval_state_vars(u_vec_alt), eigen_PF(h[ndx], eigenvxymax_[0][ndx],eigenvxymax_[1][ndx], evalue, tiny, kactxy_[0][ndx], gravity_[2][ndx], VxVy); // *********************************************************** // !!!!!!!!!!!!!!!!!!!!!check dx & dy!!!!!!!!!!!!!!!!!!!!!!!! // *********************************************************** if(evalue > 1000000000.) { double maxcurve = (dabs(curvature_[0][ndx]) > dabs(curvature_[1][ndx]) ? curvature_[0][ndx] : curvature_[1][ndx]); printf(" eigenvalue is %e for procd %d momentums are %e %e for pile height %e curvature=%e (x,y)=(%e,%e)\n", evalue, myid, hVx[ndx], hVy[ndx], h[ndx], maxcurve, coord_[0][ndx], coord_[1][ndx]); assert(0); } min_dx_dy_evalue = min( min(dx_[0][ndx], dx_[1][ndx]) / evalue, min_dx_dy_evalue); } else { stoppedflags_[ndx]=2; } } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) reduction(min:min_dx_dy_evalue) reduction(max:hmax)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/geoflow/get_coef_and_eigen.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) reduction(min:min_dx_dy_evalue) reduction(max:hmax)
100
2] = c_dmin1(dttemp, dttemp2); } //end of section that SHOULD ____NOT___ be openmp'd <LOOP-START>for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { if((adapted_[ndx] > 0) || ((adapted_[ndx] < 0) && (ghost_flag == 1))) { //if this element does not belong on this processor don't involve!!! if(h[ndx] > GEOFLOW_TINY) { double Vsolid[2], Vfluid[2]; double evalue; /* calculate hmax */ if(hmax < h[ndx]) hmax = h[ndx]; gmfggetcoef2ph(h_liq[ndx],hVx_sol[ndx],hVy_sol[ndx], dh_liq_dx[ndx],dhVx_sol_dx[ndx], dh_liq_dy[ndx],dhVy_sol_dy[ndx], matprops_ptr->bedfrict[material_[ndx]], int_frict, kactxy_[0][ndx], kactxy_[1][ndx], tiny, scale_.epsilon); elements_[ndx].calc_stop_crit(matprops_ptr, this); if((stoppedflags_[ndx] < 0) || (stoppedflags_[ndx] > 2)) printf("get_coef_and_eigen stopped flag=%d\n", stoppedflags_[ndx]); //must use hVx/h and hVy/h rather than eval_velocity (L'Hopital's //rule speed if it is smaller) because underestimating speed (which //results in over estimating the timestep) is fatal to stability... Vsolid[0] = hVx_sol[ndx] / h_liq[ndx]; Vsolid[1] = hVy_sol[ndx] / h_liq[ndx]; Vfluid[0] = hVx_liq[ndx] / h[ndx]; Vfluid[1] = hVy_liq[ndx] / h[ndx]; //eigen_(EmTemp->eval_state_vars(u_vec_alt), eigen2ph(h[ndx], h_liq[ndx], eigenvxymax_[0][ndx], eigenvxymax_[1][ndx], evalue, tiny, kactxy_[0][ndx], gravity_[2][ndx], Vsolid, Vfluid, matprops2_ptr->flow_type); // *********************************************************** // !!!!!!!!!!!!!!!!!!!!!check dx & dy!!!!!!!!!!!!!!!!!!!!!!!! // *********************************************************** if(evalue > 1000000000.) { double maxcurve = (dabs(curvature_[0][ndx]) > dabs(curvature_[1][ndx]) ? curvature_[0][ndx] : curvature_[1][ndx]); fprintf(stderr, "eigenvalue is %e for procd %d momentums are:\n \ solid :(%e, %e) \n \ fluid :(%e, %e) \n \ for pile height %e curvature=%e (x,y)=(%e,%e)\n", evalue, myid, hVx_sol[ndx],hVy_sol[ndx], hVx_liq[ndx],hVy_liq[ndx], h[ndx], maxcurve, coord_[0][ndx], coord_[1][ndx]); assert(0); } min_dx_dy_evalue = min( min(dx_[0][ndx], dx_[1][ndx]) / evalue, min_dx_dy_evalue); } else { elements_[ndx].calc_stop_crit(matprops2_ptr, this); // ensure decent values of kactxy } } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK) reduction(min:min_dx_dy_evalue) reduction(max:hmax)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/datstr/hashtab2.C
#pragma omp parallel for schedule(guided,TITAN2D_DINAMIC_CHUNK)
100
NodeHashTable::removeNodes(const ti_ndx_t *nodes_to_delete, const ti_ndx_t Nnodes_to_delete) { <LOOP-START>for(int i=0;i<Nnodes_to_delete;++i) { ti_ndx_t ndx=nodes_to_delete[i]; if(status_[ndx]<0)continue;/*was already deleted*/ ASSERT2(status_[ndx]>=0); SFC_Key keyi=key_[ndx]; int entry = hash(keyi); IF_OMP(omp_set_lock(&(bucket_lock[entry]))); if(status_[ndx]>=0)/*nodes_to_delete might contain duplicates which might be removed while waiting for lock*/ { ASSERT2(ti_ndx_not_negative(lookup_ndx(key_[ndx]))); int entry_size = bucket[entry].key.size(); ti_ndx_t bucket_entry_ndx=bucket[entry].lookup_local_ndx(keyi); if(ti_ndx_not_negative(bucket_entry_ndx)) { //delete bucket[entry].key.erase(bucket[entry].key.begin() + bucket_entry_ndx); bucket[entry].ndx.erase(bucket[entry].ndx.begin() + bucket_entry_ndx); } //set status status_[ndx]=CS_Removed; } IF_OMP(omp_unset_lock(&(bucket_lock[entry]))); }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(guided,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/datstr/hashtab2.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
ragma omp section connection_id_.resize(new_size); } } //set values <LOOP-START>for(int i=0;i<N;++i) { const int iElm=create_node_ielm[i]; const int which=create_node_iwhich[i]; const ti_ndx_t ndx=ndx_start+i; SFC_Key keyi=new_node_key[iElm][which]; key_[ndx]=keyi; status_[ndx]=CS_Added; elenode_[ndx].ndx(ndx); for(int j=0;j<DIMENSION;++j) coord_[j][ndx]=new_node_coord[iElm][which][j]; new_node_ndx[iElm][which]=ndx; new_node_isnew[iElm][which]=true; }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/datstr/hashtab2.C
#pragma omp parallel for schedule(guided,TITAN2D_DINAMIC_CHUNK)
100
dx[iElm][which]=ndx; new_node_isnew[iElm][which]=true; } //place to hash table <LOOP-START>for(int i=0;i<N;++i) { const int iElm=create_node_ielm[i]; const int which=create_node_iwhich[i]; SFC_Key keyi=new_node_key[iElm][which]; int entry = hash(keyi); IF_OMP(omp_set_lock(&(bucket_lock[entry]))); int entry_size = bucket[entry].key.size(); //get space ti_ndx_t ndx=ndx_start+i; //place to hash table if(entry_size>0) { //this place is already occupied //find proper place to insert it int j; SFC_Key *keyArr = &(bucket[entry].key[0]); for(j=0;j<entry_size&&keyi>keyArr[j];++j){} bucket[entry].key.insert(bucket[entry].key.begin() + j, keyi); bucket[entry].ndx.insert(bucket[entry].ndx.begin() + j, ndx); } else { //will be first member of the bucket entry bucket[entry].key.push_back(keyi); bucket[entry].ndx.push_back(ndx); } IF_OMP(omp_unset_lock(&(bucket_lock[entry]))); }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(guided,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/datstr/hashtab2.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
ize(); ti_ndx_t new_size=size()+numElemToRefine*4; resize(new_size); //set values <LOOP-START>for(int iElm=0;iElm<numElemToRefine;++iElm) { for(int which=0;which<4;++which) { const ti_ndx_t ndx=ndx_start+iElm*4+which; SFC_Key keyi=new_node_key[iElm][which]; key_[ndx]=keyi; status_[ndx]=CS_Added; elenode_[ndx].ndx(ndx); new_sons_ndx[iElm][which]=ndx; } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/datstr/hashtab2.C
#pragma omp parallel for schedule(guided,TITAN2D_DINAMIC_CHUNK)
100
dx(ndx); new_sons_ndx[iElm][which]=ndx; } } //place to hash table <LOOP-START>for(int iElm=0;iElm<numElemToRefine;++iElm) { for(int which=0;which<4;++which) { SFC_Key keyi=new_node_key[iElm][which]; int entry = hash(keyi); IF_OMP(omp_set_lock(&(bucket_lock[entry]))); int entry_size = bucket[entry].key.size(); //get space ti_ndx_t ndx=ndx_start+iElm*4+which; //place to hash table if(entry_size>0) { //this place is already occupied //find proper place to insert it int j; SFC_Key *keyArr = &(bucket[entry].key[0]); for(j=0;j<entry_size&&keyi>keyArr[j];++j){} bucket[entry].key.insert(bucket[entry].key.begin() + j, keyi); bucket[entry].ndx.insert(bucket[entry].ndx.begin() + j, ndx); } else { //will be first member of the bucket entry bucket[entry].key.push_back(keyi); bucket[entry].ndx.push_back(ndx); } IF_OMP(omp_unset_lock(&(bucket_lock[entry]))); } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(guided,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/datstr/hashtab2.C
#pragma omp parallel for schedule(guided,TITAN2D_DINAMIC_CHUNK)
100
Table::removeElements(const ti_ndx_t *elements_to_delete, const ti_ndx_t Nelements_to_delete) { <LOOP-START>for(int i=0;i<Nelements_to_delete;++i) { ti_ndx_t ndx=elements_to_delete[i]; ASSERT2(status_[ndx]>=0); SFC_Key keyi=key_[ndx]; int entry = hash(keyi); IF_OMP(omp_set_lock(&(bucket_lock[entry]))); ASSERT2(ti_ndx_not_negative(lookup_ndx(key_[ndx]))); int entry_size = bucket[entry].key.size(); ti_ndx_t bucket_entry_ndx=bucket[entry].lookup_local_ndx(keyi); if(ti_ndx_not_negative(bucket_entry_ndx)) { //set status status_[bucket[entry].ndx[bucket_entry_ndx]]=CS_Removed; //delete bucket[entry].key.erase(bucket[entry].key.begin() + bucket_entry_ndx); bucket[entry].ndx.erase(bucket[entry].ndx.begin() + bucket_entry_ndx); } IF_OMP(omp_unset_lock(&(bucket_lock[entry]))); }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(guided,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/datstr/elements_properties.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
ptr) { assert(ElemTable->all_elenodes_are_permanent); double gamma=matprops_ptr->gamma; <LOOP-START>for(ti_ndx_t ndx = 0; ndx < elements_.size(); ndx++) { if(adapted_[ndx] > 0)//if this element does not belong on this processor don't involve!!! { get_slopes(ndx,gamma); } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/main/properties.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
ic_pressure_by_elm); TI_ASSUME_ALIGNED(m_cum_kinergy_by_elm); if(numprocs>1) { <LOOP-START>for(ti_ndx_t ndx = 0; ndx < N; ndx++) { if(adapted_[ndx] <= 0)continue;//if this element does not belong on this processor don't involve!!! //update the record of maximum pileheight in the area covered by this element double ke = 0.0; double dp = 0.0; if (h[ndx] > 1.0E-04){ ke = 0.5 * (hVx[ndx] * hVx[ndx] + hVy[ndx] * hVy[ndx]) / h[ndx]; dp = ke / h[ndx]; } m_cum_kinergy_by_elm[ndx] += ke; m_pileheight_by_elm[ndx] = max(m_pileheight_by_elm[ndx], h[ndx]); m_max_dynamic_pressure_by_elm[ndx] = max(m_max_dynamic_pressure_by_elm[ndx],dp); m_max_kinergy_by_elm[ndx] = max(m_max_kinergy_by_elm[ndx],ke); }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/main/properties.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
max_kinergy_by_elm[ndx] = max(m_max_kinergy_by_elm[ndx],ke); } } else { <LOOP-START>for(ti_ndx_t ndx = 0; ndx < N; ndx++) { //update the record of maximum pileheight in the area covered by this element double ke = 0.0; double dp = 0.0; if (h[ndx] > 1.0E-04){ ke = 0.5 * (hVx[ndx] * hVx[ndx] + hVy[ndx] * hVy[ndx]) / h[ndx]; dp = ke / h[ndx]; } m_cum_kinergy_by_elm[ndx] += ke; m_pileheight_by_elm[ndx] = max(m_pileheight_by_elm[ndx], h[ndx]); m_max_dynamic_pressure_by_elm[ndx] = max(m_max_dynamic_pressure_by_elm[ndx],dp); m_max_kinergy_by_elm[ndx] = max(m_max_kinergy_by_elm[ndx],ke); }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/main/properties.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
I_ASSUME_ALIGNED(m_max_dynamic_pressure_by_elm); TI_ASSUME_ALIGNED(m_cum_kinergy_by_elm); <LOOP-START>for(ti_ndx_t ndx = 0; ndx < N; ndx++) { if(adapted_[ndx] <= 0)continue;//if this element does not belong on this processor don't involve!!! //@TODO check ke for two phases double ke = 0.0; double dp = 0.0; if (h[ndx] > 1.0E-04){ ke = 0.5 * (hVx_sol[ndx] * hVx_sol[ndx] + hVy_sol[ndx] * hVy_sol[ndx] + hVx_liq[ndx] * hVx_liq[ndx] + hVy_liq[ndx] * hVy_liq[ndx]) / h[ndx]; dp = ke / h[ndx]; } m_cum_kinergy_by_elm[ndx] += ke; if(h[ndx] > m_pileheight_by_elm[ndx]) m_pileheight_by_elm[ndx] = h[ndx]; if(ke > m_max_kinergy_by_elm[ndx]) m_max_kinergy_by_elm[ndx] = ke; if(dp > m_max_dynamic_pressure_by_elm[ndx]) m_max_dynamic_pressure_by_elm[ndx] = dp; }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/adapt/refine2.C
#pragma omp parallel for schedule(static)
100
D_RESTART(HAdapt_refineElements_init,pt_start); //find position of corners, sides and bubbles <LOOP-START>for(int iElm=0;iElm<numElemToRefine;++iElm) { ti_ndx_t ndx=ElemToRefine[iElm]; for(int i = 0; i < 8; i++) //-- corners and sides { node_ndx_ref[iElm][i] = ElemTable->node_key_ndx_[i][ndx]; ASSERT2(ElemTable->node_key_ndx_[i][ndx]==NodeTable->lookup_ndx(ElemTable->node_key_[i][ndx])); ASSERT2(ti_ndx_not_negative(node_ndx_ref[iElm][i])); } //-- bubble node_ndx_ref[iElm][8] = ElemTable->node_bubble_ndx_[ndx]; ASSERT2(ElemTable->node_bubble_ndx_[ndx]==NodeTable->lookup_ndx(ElemTable->key_[ndx])); ASSERT2(ti_ndx_not_negative(node_ndx_ref[iElm][8])); }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(static)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/adapt/refine2.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
s(); PROFILING3_STOPADD_RESTART(HAdapt_refineElements_int_nodes_alloc,pt_start); //SIDE 0 <LOOP-START>for(int iElm=0;iElm<numElemToRefine;++iElm) { ti_ndx_t ndx=ElemToRefine[iElm]; //@todo replace which with macro or enum //@todo reuse indexes for nodes and elements int which; ti_ndx_t n1_ndx, n2_ndx, n3_ndx, n4_ndx; ti_ndx_t *ndxNodeTemp=&(node_ndx_ref[iElm][0]); SFC_Key *NewNodeKey=&(new_node_key[iElm][0]); ti_ndx_t *NewNodeNdx=&(new_node_ndx[iElm][0]); int i; ti_ndx_t neigh_elm_ndx; int RefinedNeigh = 0; int info; int other_proc = 0; int boundary; //SIDE 0 if(ElemTable->neigh_proc_[0][ndx] == -1) boundary = 1; else boundary = 0; if(boundary == 1 || ElemTable->neigh_gen_[0][ndx] <= ElemTable->generation_[ndx]) { //i.e. boundary of the computational domain or neighbor generation same or smaller then this one RefinedNeigh = 0; info = S_S_CON; if(ElemTable->neigh_proc_[0][ndx] != myid) { other_proc = 1; info = -1; } else other_proc = 0; which = 4; //---Fourth new node--- check_create_new_node2(iElm, which, info, RefinedNeigh, boundary); //---Fourth old node--- if(RefinedNeigh || boundary) NodeTable->info_[ndxNodeTemp[4]]=CORNER; else if(other_proc) NodeTable->info_[ndxNodeTemp[4]]=-1; else NodeTable->info_[ndxNodeTemp[4]]=S_C_CON; //---Fifth new node--- which = 5; //n2 = (Node*) NodeTable->lookup(EmTemp->node_key(1)); check_create_new_node2(iElm, which, info, RefinedNeigh, boundary); } else { //i.e. not boundary of the computational domain and neighbor generation higher then this one // //Keith Added this if if((ElemTable->neigh_proc_[0][ndx] != myid) || ((ElemTable->neigh_proc_[4][ndx] != myid) && (ElemTable->neigh_proc_[4][ndx] != -2))) other_proc = 1; else other_proc = 0; // fourth new node neigh_elm_ndx = ElemTable->neighbor_ndx_[0][ndx]; ASSERT2(neigh_elm_ndx == ElemTable->lookup_ndx(ElemTable->neighbors_[0][ndx])); n1_ndx = NewNodeNdx[4]; ASSERT2(NewNodeNdx[4] == NodeTable->lookup_ndx(NewNodeKey[4])); if(ElemTable->refined_[neigh_elm_ndx] == 0 || ElemTable->refined_[neigh_elm_ndx] == GHOST) NodeTable->info_[n1_ndx]=SIDE; else NodeTable->info_[n1_ndx]=S_C_CON; //fourth old node NodeTable->info_[ndxNodeTemp[4]]=CORNER; if(other_proc) //ERROR: other_proc is never set, we never checked to see if the more refined neighbor was on another processor NodeTable->info_[ndxNodeTemp[4]]=-1; // fifth new node neigh_elm_ndx = ElemTable->neighbor_ndx_[4][ndx]; ASSERT2(neigh_elm_ndx == ElemTable->lookup_ndx(ElemTable->neighbors_[4][ndx])); n1_ndx = NewNodeNdx[5]; ASSERT2(NewNodeNdx[5] == NodeTable->lookup_ndx(NewNodeKey[5])); if(ElemTable->refined_[neigh_elm_ndx] == 0 || ElemTable->refined_[neigh_elm_ndx] == GHOST) NodeTable->info_[n1_ndx]=SIDE; else NodeTable->info_[n1_ndx]=S_C_CON; } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/adapt/refine2.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
} } PROFILING3_STOPADD_RESTART(HAdapt_refineElements_side0_init,pt_start); //SIDE1 <LOOP-START>for(int iElm=0;iElm<numElemToRefine;++iElm) { ti_ndx_t ndx=ElemToRefine[iElm]; //@todo replace which with macro or enum //@todo reuse indexes for nodes and elements int which; ti_ndx_t n1_ndx, n2_ndx, n3_ndx, n4_ndx; ti_ndx_t *ndxNodeTemp=&(node_ndx_ref[iElm][0]); SFC_Key *NewNodeKey=&(new_node_key[iElm][0]); ti_ndx_t *NewNodeNdx=&(new_node_ndx[iElm][0]); int i; ti_ndx_t neigh_elm_ndx; int RefinedNeigh = 0; int info; int other_proc = 0; int boundary; //+++++++++++++++++++++++++++SIDE1 if(ElemTable->neigh_proc_[1][ndx] == -1) boundary = 1; else boundary = 0; if(boundary == 1 || ElemTable->neigh_gen_[1][ndx] <= ElemTable->generation_[ndx]) { RefinedNeigh = 0; info = S_S_CON; if(ElemTable->neigh_gen_[1][ndx] != myid) // && *(EmTemp->get_neigh_proc()+1)>0) { other_proc = 1; info = -1; } else other_proc = 0; //---Eight new node--- which = 8; check_create_new_node2(iElm, which, info, RefinedNeigh, boundary); //---Fifth old node--- if(RefinedNeigh || boundary) NodeTable->info_[ndxNodeTemp[5]]=CORNER; else if(other_proc) NodeTable->info_[ndxNodeTemp[5]]=info; else NodeTable->info_[ndxNodeTemp[5]]=S_C_CON; //---Thirteenth new node--- which = 13; check_create_new_node2(iElm, which, info, RefinedNeigh, boundary); //check_create_new_node(which, 2, 5, ndxNodeTemp, NewNodeKey, NewNodeNdx, info, RefinedNeigh, boundary); } else { //Keith Added this if if((ElemTable->neigh_proc_[1][ndx] != myid) || ((ElemTable->neigh_proc_[5][ndx] != myid) && (ElemTable->neigh_proc_[5][ndx] != -2))) other_proc = 1; else other_proc = 0; // eighth new node neigh_elm_ndx = ElemTable->neighbor_ndx_[1][ndx]; ASSERT2(neigh_elm_ndx == ElemTable->lookup_ndx(ElemTable->neighbors_[1][ndx])); n1_ndx =NewNodeNdx[8]; ASSERT2(NewNodeNdx[8] == NodeTable->lookup_ndx(NewNodeKey[8])); if(ElemTable->refined_[neigh_elm_ndx] == 0 || ElemTable->refined_[neigh_elm_ndx] == GHOST) NodeTable->info_[n1_ndx]=SIDE; else NodeTable->info_[n1_ndx]=S_C_CON; // fifth old node NodeTable->info_[ndxNodeTemp[5]]=CORNER; if(other_proc) //ERROR: other_proc is never set, we never checked to see if the more refined neighbor was on another processor NodeTable->info_[ndxNodeTemp[5]]=-1; // thirteenth new node neigh_elm_ndx = ElemTable->neighbor_ndx_[5][ndx]; ASSERT2(neigh_elm_ndx == ElemTable->lookup_ndx(ElemTable->neighbors_[5][ndx])); n1_ndx = NewNodeNdx[13]; ASSERT2(NewNodeNdx[13] == NodeTable->lookup_ndx(NewNodeKey[13])); if(ElemTable->refined_[neigh_elm_ndx] == 0 || ElemTable->refined_[neigh_elm_ndx] == GHOST) NodeTable->info_[n1_ndx]=SIDE; else NodeTable->info_[n1_ndx]=S_C_CON; } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/adapt/refine2.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
} } PROFILING3_STOPADD_RESTART(HAdapt_refineElements_side1_init,pt_start); //SIDE2 <LOOP-START>for(int iElm=0;iElm<numElemToRefine;++iElm) { ti_ndx_t ndx=ElemToRefine[iElm]; //@todo replace which with macro or enum //@todo reuse indexes for nodes and elements int which; ti_ndx_t n1_ndx, n2_ndx, n3_ndx, n4_ndx; ti_ndx_t *ndxNodeTemp=&(node_ndx_ref[iElm][0]); SFC_Key *NewNodeKey=&(new_node_key[iElm][0]); ti_ndx_t *NewNodeNdx=&(new_node_ndx[iElm][0]); int i; ti_ndx_t neigh_elm_ndx; int RefinedNeigh = 0; int info; int other_proc = 0; int boundary; //+++++++++++++++++++++++++++SIDE2 if(ElemTable->neigh_proc_[2][ndx] == -1) boundary = 1; else boundary = 0; if(boundary == 1 || ElemTable->neigh_gen_[2][ndx] <= ElemTable->generation_[ndx]) { info = S_S_CON; if(ElemTable->neigh_gen_[2][ndx] != myid) // && *(EmTemp->get_neigh_proc()+2)>0) { other_proc = 1; info = -1; } else other_proc = 0; RefinedNeigh = 0; //---Fourteenth new node--- which = 14; check_create_new_node2(iElm, which, info, RefinedNeigh, boundary); //---Sixth old node--- if(RefinedNeigh || boundary) NodeTable->info_[ndxNodeTemp[6]]=CORNER; else if(other_proc) NodeTable->info_[ndxNodeTemp[6]]=info; else NodeTable->info_[ndxNodeTemp[6]]=S_C_CON; //---Fifteenth new node--- which = 15; check_create_new_node2(iElm, which, info, RefinedNeigh, boundary); } else { //Keith Added this if if((ElemTable->neigh_proc_[2][ndx] != myid) || ((ElemTable->neigh_proc_[6][ndx] != myid) && (ElemTable->neigh_proc_[6][ndx] != -2))) other_proc = 1; else other_proc = 0; // fourteenth new node neigh_elm_ndx = ElemTable->neighbor_ndx_[6][ndx]; ASSERT2(neigh_elm_ndx == ElemTable->lookup_ndx(ElemTable->neighbors_[6][ndx])); n1_ndx = NewNodeNdx[14]; ASSERT2(NewNodeNdx[14] == NodeTable->lookup_ndx(NewNodeKey[14])); if(ElemTable->refined_[neigh_elm_ndx] == 0 || ElemTable->refined_[neigh_elm_ndx] == GHOST) NodeTable->info_[n1_ndx]=SIDE; else NodeTable->info_[n1_ndx]=S_C_CON; // sixth old node NodeTable->info_[ndxNodeTemp[6]]=CORNER; if(other_proc) //ERROR: other_proc is never set, we never checked to see if the more refined neighbor was on another processor NodeTable->info_[ndxNodeTemp[6]]=-1; // fifteenth new node neigh_elm_ndx = ElemTable->neighbor_ndx_[2][ndx]; ASSERT2(neigh_elm_ndx == ElemTable->lookup_ndx(ElemTable->neighbors_[2][ndx])); n1_ndx = NewNodeNdx[15]; ASSERT2(NewNodeNdx[15] == NodeTable->lookup_ndx(NewNodeKey[15])); if(ElemTable->refined_[neigh_elm_ndx] == 0 || ElemTable->refined_[neigh_elm_ndx] == GHOST) NodeTable->info_[n1_ndx]=SIDE; else NodeTable->info_[n1_ndx]=S_C_CON; } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/adapt/refine2.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
} PROFILING3_STOPADD_RESTART(HAdapt_refineElements_side2_init,pt_start); //SIDE 3 <LOOP-START>for(int iElm=0;iElm<numElemToRefine;++iElm) { ti_ndx_t ndx=ElemToRefine[iElm]; //@todo replace which with macro or enum //@todo reuse indexes for nodes and elements int which; ti_ndx_t n1_ndx, n2_ndx, n3_ndx, n4_ndx; ti_ndx_t *ndxNodeTemp=&(node_ndx_ref[iElm][0]); SFC_Key *NewNodeKey=&(new_node_key[iElm][0]); ti_ndx_t *NewNodeNdx=&(new_node_ndx[iElm][0]); int i; ti_ndx_t neigh_elm_ndx; int RefinedNeigh = 0; int info; int other_proc = 0; int boundary; //+++++++++++++++++++++++++++SIDE 3 if(ElemTable->neigh_proc_[3][ndx] == -1) boundary = 1; else boundary = 0; if(boundary == 1 || ElemTable->neigh_gen_[3][ndx] <= ElemTable->generation_[ndx]) { info = S_S_CON; if(ElemTable->neigh_gen_[3][ndx] != myid) //&& *(EmTemp->get_neigh_proc()+3)>0) { other_proc = 1; info = -1; } else other_proc = 0; RefinedNeigh = 0; //---Sixth new node---- which = 6; check_create_new_node2(iElm, which, info, RefinedNeigh, boundary); //check_create_new_node(which, 0, 7, ndxNodeTemp, NewNodeKey, NewNodeNdx, info, RefinedNeigh, boundary); //---Seventh old node--- if(RefinedNeigh || boundary) NodeTable->info_[ndxNodeTemp[7]]=CORNER; else if(other_proc) NodeTable->info_[ndxNodeTemp[7]]=-1; else NodeTable->info_[ndxNodeTemp[7]]=S_C_CON; //---Eleventh new node--- which = 11; check_create_new_node2(iElm, which, info, RefinedNeigh, boundary); //n1 = (Node*) NodeTable->lookup(EmTemp->node_key(7)); //n2 = (Node*) NodeTable->lookup(EmTemp->node_key(3)); //check_create_new_node(which, 3, 7, ndxNodeTemp, NewNodeKey, NewNodeNdx, info, RefinedNeigh, boundary); } else { //Keith Added this if if((ElemTable->neigh_proc_[3][ndx] != myid) || ((ElemTable->neigh_proc_[7][ndx] != myid) && (ElemTable->neigh_proc_[7][ndx] != -2))) other_proc = 1; else other_proc = 0; // sixth new node neigh_elm_ndx = ElemTable->neighbor_ndx_[7][ndx]; ASSERT2(neigh_elm_ndx == ElemTable->lookup_ndx(ElemTable->neighbors_[7][ndx])); n1_ndx = NewNodeNdx[6]; ASSERT2(NewNodeNdx[6] == NodeTable->lookup_ndx(NewNodeKey[6])); if(ElemTable->refined_[neigh_elm_ndx] == 0 || ElemTable->refined_[neigh_elm_ndx] == GHOST) NodeTable->info_[n1_ndx]=SIDE; else NodeTable->info_[n1_ndx]=S_C_CON; // seventh old node NodeTable->info_[ndxNodeTemp[7]]=CORNER; if(other_proc) //ERROR: other_proc is never set, we never checked to see if the more refined neighbor was on another processor NodeTable->info_[ndxNodeTemp[7]]=-1; // eleventh new node neigh_elm_ndx = ElemTable->neighbor_ndx_[3][ndx]; ASSERT2(neigh_elm_ndx == ElemTable->lookup_ndx(ElemTable->neighbors_[3][ndx])); n1_ndx = NewNodeNdx[11]; ASSERT2(NewNodeNdx[11] == NodeTable->lookup_ndx(NewNodeKey[11])); if(ElemTable->refined_[neigh_elm_ndx] == 0 || ElemTable->refined_[neigh_elm_ndx] == GHOST) NodeTable->info_[n1_ndx]=SIDE; else NodeTable->info_[n1_ndx]=S_C_CON; } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/adapt/refine2.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
=S_C_CON; } } PROFILING3_STOPADD_RESTART(HAdapt_refineElements_side3_init,pt_start); <LOOP-START>for(int iElm=0;iElm<numElemToRefine;++iElm) { ti_ndx_t ndx=ElemToRefine[iElm]; int which; //changing the old bubble NodeTable->info_[ElemTable->node_bubble_ndx_[iElm]]=CORNER; //++++++++++++++++INTERNAL SIDE NODES 7, 8OLD, 12, 9, 10 //---Seventh new node--- which=7; NodeTable->elenode_[new_node_ndx[iElm][which]].init(new_node_key[iElm][which], &(new_node_coord[iElm][which][0]), SIDE, -3, matprops_ptr); //---Twelwth new node--- which=12; NodeTable->elenode_[new_node_ndx[iElm][which]].init(new_node_key[iElm][which], &(new_node_coord[iElm][which][0]), SIDE, -3, matprops_ptr); //---Ninth new node--- which=9; NodeTable->elenode_[new_node_ndx[iElm][which]].init(new_node_key[iElm][which], &(new_node_coord[iElm][which][0]), SIDE, -3, matprops_ptr); //---Tenth new node--- which=10; NodeTable->elenode_[new_node_ndx[iElm][which]].init(new_node_key[iElm][which], &(new_node_coord[iElm][which][0]), SIDE, -3, matprops_ptr); //+++++++++++++++++++THE NEW BUBBLES 0, 1, 2, 3 //---0th new node--- which=0; NodeTable->elenode_[new_node_ndx[iElm][which]].init(new_node_key[iElm][which], &(new_node_coord[iElm][which][0]), BUBBLE, -3, matprops_ptr); //---1st new node--- which=1; NodeTable->elenode_[new_node_ndx[iElm][which]].init(new_node_key[iElm][which], &(new_node_coord[iElm][which][0]), BUBBLE, -3, matprops_ptr); //---2nd new node--- which=2; NodeTable->elenode_[new_node_ndx[iElm][which]].init(new_node_key[iElm][which], &(new_node_coord[iElm][which][0]), BUBBLE, -3, matprops_ptr); //---3rd new node--- which=3; NodeTable->elenode_[new_node_ndx[iElm][which]].init(new_node_key[iElm][which], &(new_node_coord[iElm][which][0]), BUBBLE, -3, matprops_ptr); }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/adapt/refine2.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
,new_node_isnew); PROFILING3_STOPADD_RESTART(HAdapt_refineElements_new_elm_aloc,pt_start); <LOOP-START>for(int iElm=0;iElm<numElemToRefine;++iElm) { ti_ndx_t ndx=ElemToRefine[iElm]; //@todo replace which with macro or enum //@todo reuse indexes for nodes and elements int which; ti_ndx_t n1_ndx, n2_ndx, n3_ndx, n4_ndx; SFC_Key *NewNodeKey=&(new_node_key[iElm][0]); ti_ndx_t *NewNodeNdx=&(new_node_ndx[iElm][0]); int i; ti_ndx_t neigh_elm_ndx; int RefinedNeigh = 0; int info; int other_proc = 0; int boundary; ti_ndx_t *ndxSons=&(new_sons_ndx[iElm][0]); SFC_Key nodes[9]; ti_ndx_t nodes_ndx[9]; SFC_Key neigh[8]; ti_ndx_t neigh_ndx[8]; int neigh_proc[8]; int generation = ElemTable->generation_[ndx] + 1; int neigh_gen[4]; int material = ElemTable->material_[ndx]; double coord[DIMENSION]; //---0th new element--- ti_ndx_t ndxQuad9P; //the nodes nodes[0] = ElemTable->node_key_[0][ndx]; nodes[1] = ElemTable->node_key_[4][ndx]; nodes[2] = ElemTable->key_[ndx]; nodes[3] = ElemTable->node_key_[7][ndx]; nodes[4] = NewNodeKey[4]; nodes[5] = NewNodeKey[7]; nodes[6] = NewNodeKey[9]; nodes[7] = NewNodeKey[6]; nodes[8] = NewNodeKey[0]; nodes_ndx[0] = ElemTable->node_key_ndx_[0][ndx]; nodes_ndx[1] = ElemTable->node_key_ndx_[4][ndx]; nodes_ndx[2] = ElemTable->node_bubble_ndx_[ndx]; nodes_ndx[3] = ElemTable->node_key_ndx_[7][ndx]; nodes_ndx[4] = NewNodeNdx[4]; nodes_ndx[5] = NewNodeNdx[7]; nodes_ndx[6] = NewNodeNdx[9]; nodes_ndx[7] = NewNodeNdx[6]; nodes_ndx[8] = NewNodeNdx[0]; n1_ndx = nodes_ndx[8]; for(i = 0; i < DIMENSION; i++) coord[i] = NodeTable->coord_[i][n1_ndx]; //neighbors neigh[0] = neigh[4] = ElemTable->neighbors_[0][ndx]; //Why is this ok if not ok for 3 down neigh[1] = neigh[5] = NewNodeKey[1]; neigh[2] = neigh[6] = NewNodeKey[3]; if(ElemTable->neigh_proc_[7][ndx]!= -2) neigh[3] = neigh[7] = ElemTable->neighbors_[7][ndx]; //This should be okay no matter what else neigh[3] = neigh[7] = ElemTable->neighbors_[3][ndx]; //This is only ok if neigh_proc==-2 neigh_ndx[0] = neigh_ndx[4] = ElemTable->neighbor_ndx_[0][ndx]; //Why is this ok if not ok for 3 down neigh_ndx[1] = neigh_ndx[5] = ndxSons[1]; neigh_ndx[2] = neigh_ndx[6] = ndxSons[3]; if(ElemTable->neigh_proc_[7][ndx]!= -2) neigh_ndx[3] = neigh_ndx[7] = ElemTable->neighbor_ndx_[7][ndx]; //This should be okay no matter what else neigh_ndx[3] = neigh_ndx[7] = ElemTable->neighbor_ndx_[3][ndx]; //This is only ok if neigh_proc==-2 //process of the neighbors neigh_proc[0] = ElemTable->neigh_proc_[0][ndx]; neigh_proc[1] = myid; neigh_proc[2] = myid; if(ElemTable->neigh_proc_[7][ndx] != -2) neigh_proc[3] = ElemTable->neigh_proc_[7][ndx]; //depending if the neighboring element is already refined else neigh_proc[3] = ElemTable->neigh_proc_[3][ndx]; neigh_proc[4] = neigh_proc[5] = neigh_proc[6] = neigh_proc[7] = -2; neigh_gen[0] = ElemTable->neigh_gen_[0][ndx]; neigh_gen[1] = generation; neigh_gen[2] = generation; neigh_gen[3] = ElemTable->neigh_gen_[3][ndx]; double err = ElemTable->el_error_[0][ndx] * .5; //added by jp oct11 double sol = ElemTable->el_solution_[0][ndx] * .5; //added by jp oct11 // son 0 can use elm_loc int iwetnodefather = ElemTable->iwetnode_[ndx]; double Awetfather = ElemTable->Awet_[ndx]; double dpson[2]; dpson[0] = ElemTable->drypoint_[0][ndx] * 2 + 0.5; dpson[1] = ElemTable->drypoint_[1][ndx] * 2 + 0.5; int elm_loc[2], my_elm_loc[2]; elm_loc[0] = 2 * ElemTable->elm_loc_[0][ndx]; elm_loc[1] = 2 * ElemTable->elm_loc_[1][ndx]; //init new element ndxQuad9P = ndxSons[0]; ElemTable->elenode_[ndxQuad9P].init(nodes, nodes_ndx, neigh, neigh_ndx, neigh_proc, generation, elm_loc, NULL, neigh_gen, material, ndx, coord, ElemTable, NodeTable, myid, matprops_ptr, iwetnodefather, Awetfather, dpson); ElemTable->which_son_[ndxQuad9P]=0; //--by jp, 0 means son 0 ElemTable->elenode_[ndxQuad9P].putel_sq(sol, err); //added by jp oct11 //---1st new element--- //the nodes nodes[0] = ElemTable->node_key_[4][ndx]; nodes[1] = ElemTable->node_key_[1][ndx]; nodes[2] = ElemTable->node_key_[5][ndx]; nodes[3] = ElemTable->key_[ndx]; nodes[4] = NewNodeKey[5]; nodes[5] = NewNodeKey[8]; nodes[6] = NewNodeKey[10]; nodes[7] = NewNodeKey[7]; nodes[8] = NewNodeKey[1]; nodes_ndx[0] = ElemTable->node_key_ndx_[4][ndx]; nodes_ndx[1] = ElemTable->node_key_ndx_[1][ndx]; nodes_ndx[2] = ElemTable->node_key_ndx_[5][ndx]; nodes_ndx[3] = ElemTable->node_bubble_ndx_[ndx]; nodes_ndx[4] = NewNodeNdx[5]; nodes_ndx[5] = NewNodeNdx[8]; nodes_ndx[6] = NewNodeNdx[10]; nodes_ndx[7] = NewNodeNdx[7]; nodes_ndx[8] = NewNodeNdx[1]; n1_ndx = nodes_ndx[8]; for(i = 0; i < DIMENSION; i++) coord[i] = NodeTable->coord_[i][n1_ndx]; //neighbors if(ElemTable->neigh_proc_[4][ndx] != -2) neigh[0] = neigh[4] = ElemTable->neighbors_[4][ndx]; //this should be ok now matter what else neigh[0] = neigh[4] = ElemTable->neighbors_[0][ndx]; //this is only ok if neigh_proc==-2 neigh[1] = neigh[5] = ElemTable->neighbors_[1][ndx]; neigh[2] = neigh[6] = NewNodeKey[2]; neigh[3] = neigh[7] = NewNodeKey[0]; if(ElemTable->neigh_proc_[4][ndx] != -2) neigh_ndx[0] = neigh_ndx[4] = ElemTable->neighbor_ndx_[4][ndx]; //this should be ok now matter what else neigh_ndx[0] = neigh_ndx[4] = ElemTable->neighbor_ndx_[0][ndx]; //this is only ok if neigh_proc==-2 neigh_ndx[1] = neigh_ndx[5] = ElemTable->neighbor_ndx_[1][ndx]; neigh_ndx[2] = neigh_ndx[6] = ndxSons[2]; neigh_ndx[3] = neigh_ndx[7] = ndxSons[0]; //process of the neighbors neigh_proc[0] = (ElemTable->neigh_proc_[4][ndx] != -2) ? ElemTable->neigh_proc_[4][ndx] : ElemTable->neigh_proc_[0][ndx]; neigh_proc[1] = ElemTable->neigh_proc_[1][ndx]; neigh_proc[2] = myid; neigh_proc[3] = myid; neigh_proc[4] = neigh_proc[5] = neigh_proc[6] = neigh_proc[7] = -2; neigh_gen[0] = ElemTable->neigh_gen_[0][ndx]; neigh_gen[1] = ElemTable->neigh_gen_[1][ndx]; neigh_gen[2] = generation; neigh_gen[3] = generation; my_elm_loc[0] = elm_loc[0] + 1; my_elm_loc[1] = elm_loc[1]; dpson[0] = ElemTable->drypoint_[0][ndx] * 2 - 0.5; dpson[1] = ElemTable->drypoint_[1][ndx] * 2 + 0.5; //init new element ndxQuad9P = ndxSons[1]; ElemTable->elenode_[ndxQuad9P].init(nodes, nodes_ndx, neigh, neigh_ndx, neigh_proc, generation, my_elm_loc, NULL, neigh_gen, material, ndx, coord, ElemTable, NodeTable, myid, matprops_ptr, iwetnodefather, Awetfather, dpson); ElemTable->which_son_[ndxQuad9P]=1; //--by jp ElemTable->elenode_[ndxQuad9P].putel_sq(sol, err); //added by jp oct11 //---2nd new element--- //the nodes nodes[0] = ElemTable->key_[ndx]; nodes[1] = ElemTable->node_key_[5][ndx]; nodes[2] = ElemTable->node_key_[2][ndx]; nodes[3] = ElemTable->node_key_[6][ndx]; nodes[4] = NewNodeKey[10]; nodes[5] = NewNodeKey[13]; nodes[6] = NewNodeKey[15]; nodes[7] = NewNodeKey[12]; nodes[8] = NewNodeKey[2]; nodes_ndx[0] = ElemTable->node_bubble_ndx_[ndx]; nodes_ndx[1] = ElemTable->node_key_ndx_[5][ndx]; nodes_ndx[2] = ElemTable->node_key_ndx_[2][ndx]; nodes_ndx[3] = ElemTable->node_key_ndx_[6][ndx]; nodes_ndx[4] = NewNodeNdx[10]; nodes_ndx[5] = NewNodeNdx[13]; nodes_ndx[6] = NewNodeNdx[15]; nodes_ndx[7] = NewNodeNdx[12]; nodes_ndx[8] = NewNodeNdx[2]; n1_ndx = nodes_ndx[8]; for(i = 0; i < DIMENSION; i++) coord[i] = NodeTable->coord_[i][n1_ndx]; //neighbors neigh[0] = neigh[4] = NewNodeKey[1]; if(ElemTable->neigh_proc_[5][ndx] != -2) neigh[1] = neigh[5] = ElemTable->neighbors_[5][ndx]; //This should be ok no matter what else neigh[1] = neigh[5] = ElemTable->neighbors_[1][ndx]; //this is only ok is neigh_proc==-2 neigh[2] = neigh[6] = ElemTable->neighbors_[2][ndx]; neigh[3] = neigh[7] = NewNodeKey[3]; neigh_ndx[0] = neigh_ndx[4] = ndxSons[1]; if(ElemTable->neigh_proc_[5][ndx] != -2) neigh_ndx[1] = neigh_ndx[5] = ElemTable->neighbor_ndx_[5][ndx]; //This should be ok no matter what else neigh_ndx[1] = neigh_ndx[5] = ElemTable->neighbor_ndx_[1][ndx]; //this is only ok is neigh_proc==-2 neigh_ndx[2] = neigh_ndx[6] = ElemTable->neighbor_ndx_[2][ndx]; neigh_ndx[3] = neigh_ndx[7] = ndxSons[3]; //process of the neighbors neigh_proc[0] = myid; neigh_proc[1] = (ElemTable->neigh_proc_[5][ndx] != -2) ? ElemTable->neigh_proc_[5][ndx] : ElemTable->neigh_proc_[1][ndx]; neigh_proc[2] = ElemTable->neigh_proc_[2][ndx]; neigh_proc[3] = myid; neigh_proc[4] = neigh_proc[5] = neigh_proc[6] = neigh_proc[7] = -2; neigh_gen[0] = generation; neigh_gen[1] = ElemTable->neigh_gen_[1][ndx]; neigh_gen[2] = ElemTable->neigh_gen_[2][ndx]; neigh_gen[3] = generation; my_elm_loc[0] = elm_loc[0] + 1; my_elm_loc[1] = elm_loc[1] + 1; dpson[0] = ElemTable->drypoint_[0][ndx] * 2 - 0.5; dpson[1] = ElemTable->drypoint_[1][ndx] * 2 - 0.5; //init new element ndxQuad9P = ndxSons[2]; ElemTable->elenode_[ndxQuad9P].init(nodes, nodes_ndx, neigh, neigh_ndx, neigh_proc, generation, my_elm_loc, NULL, neigh_gen, material, ndx, coord, ElemTable, NodeTable, myid, matprops_ptr, iwetnodefather, Awetfather, dpson); ElemTable->which_son_[ndxQuad9P]=2; //--by jp ElemTable->elenode_[ndxQuad9P].putel_sq(sol, err); //added by jp oct11 //---3rd new element--- //the nodes nodes[0] = ElemTable->node_key_[7][ndx]; nodes[1] = ElemTable->key_[ndx]; nodes[2] = ElemTable->node_key_[6][ndx]; nodes[3] = ElemTable->node_key_[3][ndx]; nodes[4] = NewNodeKey[9]; nodes[5] = NewNodeKey[12]; nodes[6] = NewNodeKey[14]; nodes[7] = NewNodeKey[11]; nodes[8] = NewNodeKey[3]; nodes_ndx[0] = ElemTable->node_key_ndx_[7][ndx]; nodes_ndx[1] = ElemTable->node_bubble_ndx_[ndx]; nodes_ndx[2] = ElemTable->node_key_ndx_[6][ndx]; nodes_ndx[3] = ElemTable->node_key_ndx_[3][ndx]; nodes_ndx[4] = NewNodeNdx[9]; nodes_ndx[5] = NewNodeNdx[12]; nodes_ndx[6] = NewNodeNdx[14]; nodes_ndx[7] = NewNodeNdx[11]; nodes_ndx[8] = NewNodeNdx[3]; n1_ndx = nodes_ndx[8]; for(i = 0; i < DIMENSION; i++) coord[i] = NodeTable->coord_[i][n1_ndx]; //neighbors neigh[0] = neigh[4] = NewNodeKey[0]; neigh[1] = neigh[5] = NewNodeKey[2]; if(ElemTable->neigh_proc_[6][ndx] != -2) neigh[2] = neigh[6] = ElemTable->neighbors_[6][ndx]; else neigh[2] = neigh[6] = ElemTable->neighbors_[2][ndx]; neigh[3] = neigh[7] = ElemTable->neighbors_[3][ndx]; neigh_ndx[0] = neigh_ndx[4] = ndxSons[0]; neigh_ndx[1] = neigh_ndx[5] = ndxSons[2]; if(ElemTable->neigh_proc_[6][ndx] != -2) neigh_ndx[2] = neigh_ndx[6] = ElemTable->neighbor_ndx_[6][ndx]; else neigh_ndx[2] = neigh_ndx[6] = ElemTable->neighbor_ndx_[2][ndx]; neigh_ndx[3] = neigh_ndx[7] = ElemTable->neighbor_ndx_[3][ndx]; //process of the neighbors neigh_proc[0] = myid; neigh_proc[1] = myid; neigh_proc[2] = (ElemTable->neigh_proc_[6][ndx] != -2) ? ElemTable->neigh_proc_[6][ndx] : ElemTable->neigh_proc_[2][ndx]; neigh_proc[3] = ElemTable->neigh_proc_[3][ndx]; neigh_proc[4] = neigh_proc[5] = neigh_proc[6] = neigh_proc[7] = -2; neigh_gen[0] = generation; neigh_gen[1] = generation; neigh_gen[2] = ElemTable->neigh_gen_[2][ndx]; neigh_gen[3] = ElemTable->neigh_gen_[3][ndx]; my_elm_loc[0] = elm_loc[0]; my_elm_loc[1] = elm_loc[1] + 1; dpson[0] = ElemTable->drypoint_[0][ndx] * 2 + 0.5; dpson[1] = ElemTable->drypoint_[1][ndx] * 2 - 0.5; //init new element ndxQuad9P = ndxSons[3]; ElemTable->elenode_[ndxQuad9P].init(nodes, nodes_ndx, neigh, neigh_ndx, neigh_proc, generation, my_elm_loc, NULL, neigh_gen, material, ndx, coord, ElemTable, NodeTable, myid, matprops_ptr, iwetnodefather, Awetfather, dpson); ElemTable->which_son_[ndxQuad9P]=3; //--by jp ElemTable->elenode_[ndxQuad9P].putel_sq(sol, err); //added by jp oct11 //---CHANGING THE FATHER--- for(i = 0; i < 4; i++) { ElemTable->son_[i][ndx]=NewNodeKey[i]; ElemTable->son_ndx_[i][ndx]=ndxSons[i]; } // putting in brother info for(i = 0; i < 4; i++) { ElemTable->elenode_[ndxSons[i]].set_brothers(NewNodeKey); for(int j = 0; j < 4; j++) { ElemTable->brothers_ndx_[j][ndxSons[i]]=ndxSons[j]; } } adapted[ndx]=OLDFATHER; refined[ndx]=1; }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/adapt/hadpt.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
n the innermost buffer layer as the BUFFER layer //@ElementsSingleLoopNoStatusCheck <LOOP-START>for(ti_ndx_t ndx=0;ndx<ElemTable->size();++ndx) { if(status[ndx] >=0 && ((ElemProp->if_first_buffer_boundary(ndx, GEOFLOW_TINY) > 0) || (ElemProp->if_first_buffer_boundary(ndx, REFINE_THRESHOLD1) > 0) || (ElemProp->if_first_buffer_boundary(ndx, REFINE_THRESHOLD2) > 0) || (ElemProp->if_first_buffer_boundary(ndx, REFINE_THRESHOLD) > 0))) { adapted[ndx]=BUFFER; } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/adapt/hadpt.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
PROFILING3_STOPADD_RESTART(HAdapt_adapt_htflush2,pt_start); TIMING3_START(t_start3); <LOOP-START>for(ti_ndx_t ndx=0;ndx<ElemTable->size();++ndx) { if(status[ndx]>=0) { EmTemp = &(elements[ndx]); switch (adapted[ndx]) { case NEWBUFFER: printf("Suspicious element has adapted flag=%d\n aborting", adapted[ndx]); assert(0); break; case BUFFER: case NEWSON: case NEWFATHER: case NOTRECADAPTED: //it's an active (non ghost) element ElemProp->calc_d_gravity(ndx); ElemProp->calc_wet_dry_orient(ndx); break; case TOBEDELETED: //there should be no more elements to delete at this point printf("Should be already deleted aborting", adapted[ndx]); assert(0); break; case -NOTRECADAPTED: case -NEWFATHER: case -NEWSON: case -BUFFER: //it's a ghost element, keep these so I don't have to move data again. break; case OLDFATHER: case OLDSON: printf("Suspicious element has adapted flag=%d\n aborting", adapted[ndx]); assert(0); break; default: //I don't know what kind of Element this is. cout<<"FUBAR element type in H_adapt()!!! key={"<<ElemTable->key_[ndx]<<"} adapted="<<adapted[ndx]; cout <<"\naborting.\n"; assert(0); break; } } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/TITAN2D/titan2d/src/adapt/updatenei.C
#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)
100
on from other processors */ /*************************************************************/ <LOOP-START>for(int iElm=0;iElm<allRefinement.size();++iElm) { Element* EmFather; Element* EmSon[4]; ti_ndx_t EmSonNdx[4]; Element* EmNeighNew[4]; ti_ndx_t EmNeighNewNdx[4]; Element* EmNeighOld[2]; ti_ndx_t EmNeighOldNdx[2]; Node* NdTemp; ti_ndx_t NdTempNdx; int iside, ineigh, ineighp4, isonA, isonB; int ineighme, ineighmep4, ineighson, inewcase, inode; ti_ndx_t ifather=allRefinement[iElm]; EmFather = &(ElemTable->elenode_[ifather]); //Hello I'm the OLDFATHER ASSERT2(ElemTable->adapted_[ifather]==OLDFATHER); //sanity check NdTempNdx = ElemTable->node_bubble_ndx_[ifather]; ASSERT2(NdTempNdx==NodeTable->lookup_ndx(ElemTable->key_[ifather])); NodeTable->info_[NdTempNdx]=CORNER; //These are my sons, I'm going to introduce them to my neighbors for(isonA = 0; isonA < 4; isonA++) { EmSonNdx[isonA] = ElemTable->son_ndx_[isonA][ifather]; EmSon[isonA]=&(ElemTable->elenode_[EmSonNdx[isonA]]); ASSERT2(EmSonNdx[isonA] == ElemTable->lookup_ndx(ElemTable->son_[isonA][ifather])); if(ElemTable->node_bubble_ndx_[EmSonNdx[isonA]]!=NodeTable->lookup_ndx(ElemTable->key_[EmSonNdx[isonA]])) { printf("%d %d\n",ElemTable->node_bubble_ndx_[EmSonNdx[isonA]],NodeTable->lookup_ndx(ElemTable->key_[EmSonNdx[isonA]])); } ASSERT2(ElemTable->node_bubble_ndx_[EmSonNdx[isonA]]==NodeTable->lookup_ndx(ElemTable->key_[EmSonNdx[isonA]])); NodeTable->info_[ElemTable->node_bubble_ndx_[EmSonNdx[isonA]]]=BUBBLE; ASSERT2(ElemTable->node_key_ndx_[(isonA + 1) % 4 + 4][EmSonNdx[isonA]] ==\ NodeTable->lookup_ndx(ElemTable->node_key_[(isonA + 1) % 4 + 4][EmSonNdx[isonA]])); NodeTable->info_[ElemTable->node_key_ndx_[(isonA + 1) % 4 + 4][EmSonNdx[isonA]]]=SIDE; } //visit my neighbors on each side for(iside = 0; iside < 4; iside++) { ineigh = iside; ineighp4 = ineigh + 4; isonA = ineigh; isonB = (ineighp4 + 1) % 4; if(EmFather->neigh_proc(ineigh) == -1) { //handle map boundary special EmSon[isonA]->set_neighbor(ineigh, sfc_key_zero); EmSon[isonA]->set_neighbor(ineighp4, sfc_key_zero); EmSon[isonB]->set_neighbor(ineigh, sfc_key_zero); EmSon[isonB]->set_neighbor(ineighp4, sfc_key_zero); EmSon[isonA]->neighbor_ndx(ineigh, ti_ndx_doesnt_exist); EmSon[isonA]->neighbor_ndx(ineighp4, ti_ndx_doesnt_exist); EmSon[isonB]->neighbor_ndx(ineigh, ti_ndx_doesnt_exist); EmSon[isonB]->neighbor_ndx(ineighp4, ti_ndx_doesnt_exist); EmSon[isonA]->get_neigh_gen(ineigh, 0); EmSon[isonA]->get_neigh_gen(ineighp4, 0); EmSon[isonB]->get_neigh_gen(ineigh, 0); EmSon[isonB]->get_neigh_gen(ineighp4, 0); EmSon[isonA]->set_neigh_proc(ineigh, -1); EmSon[isonB]->set_neigh_proc(ineigh, -1); EmSon[isonA]->set_neigh_proc(ineighp4, -2); EmSon[isonB]->set_neigh_proc(ineighp4, -2); //if(Curr_El) if(IfNeighProcChange(El_Table,NodeTable,myid,Curr_El,EmFather)) assert(0); } else if((EmFather->neigh_proc(ineigh) == myid) && ((EmFather->neigh_proc(ineighp4) == myid) || (EmFather->neigh_proc(ineighp4) == -2))) { //case where one neighbor on this side is on my proc while the other //is on another proc has already been handled up above, when packing //the information to send to the other proc. //knock knock, Hello Neighbors ASSERT2(ElemTable->neighbor_ndx_[ineigh][ifather]==ElemTable->lookup_ndx(EmFather->neighbor(ineigh))); EmNeighOldNdx[0] = ElemTable->neighbor_ndx_[ineigh][ifather]; EmNeighOld[0] = &(ElemTable->elenode_[EmNeighOldNdx[0]]); ASSERT2(ElemTable->neighbor_ndx_[ineighp4][ifather]==ElemTable->lookup_ndx(EmFather->neighbor(ineighp4))); EmNeighOldNdx[1] = ElemTable->neighbor_ndx_[ineighp4][ifather]; EmNeighOld[1] = &(ElemTable->elenode_[EmNeighOldNdx[1]]); EmNeighNew[0] = EmNeighNew[1] = EmNeighNew[2] = EmNeighNew[3] = NULL; EmNeighNewNdx[0] = EmNeighNewNdx[1] = EmNeighNewNdx[2] = EmNeighNewNdx[3] = ti_ndx_unknown; for(ineighme = 0; ineighme < 8; ineighme++) { if(EmFather->key()==EmNeighOld[1]->neighbor(ineighme)) break; } if(!(ineighme < 8)) { cout<<"FUBAR 0 detected in refine_neigh_update\nEmFather={"<<EmFather->key()<<"}\n"; cout<<"EmNeighOld[0]={"<<EmNeighOld[0]->key()<<"} ineigh="<<ineigh<<" isonA="<<isonA<<" isonB="<<isonB<<"\n"; cout<<"aborting!!"<<endl; assert(ineighme < 8); } //There are 5 cases I need to worry about about //A: my old neighbor is one generation older than me, only // possible if we've both been refined //B: my old neighbor is of my generation and hasn't been refined //C: my old neighbor is of my generation and has been refined //D: my old neighbor is one generation younger than me and hasn't // been refined //E: my old neighbor is one generation younger than me and has // been refined // //I'm going to compress this into one of 3 cases I need to handle //0: case A: same as case E but from the other side, only need // to do once so don't do anything this time //1: my new neighbor is my generation //2: my new neighbor is one generation younger than me //3: my new neighbor is two generations younger than me //this switch loop compresses cases switch (EmNeighOld[0]->generation() - EmFather->generation()) { case -1: //this is a case A inewcase = 0; assert(EmNeighOld[0]->adapted_flag()==OLDFATHER); ineighme = ineighmep4 = -1; //for sanity check break; case 0: assert(ineighme < 4); ineighmep4 = ineighme + 4; if(EmNeighOld[0]->adapted_flag() == OLDFATHER) { //this is a case C inewcase = 2; EmNeighNewNdx[0] = EmNeighOld[0]->son_ndx((ineighme + 1) % 4); EmNeighNew[0]=&(ElemTable->elenode_[EmNeighNewNdx[0]]); ASSERT2(EmNeighNewNdx[0] == ElemTable->lookup_ndx(EmNeighOld[0]->son((ineighme + 1) % 4))); EmNeighNewNdx[1] = EmNeighOld[0]->son_ndx(ineighme); EmNeighNew[1] = &(ElemTable->elenode_[EmNeighNewNdx[1]]); EmNeighNew[2] = EmNeighNew[3] = NULL; EmNeighNewNdx[2] = EmNeighNewNdx[3] = ti_ndx_unknown; } else { //this is a case B if(EmNeighOld[0]->adapted_flag() > TOBEDELETED) { inewcase = 1; EmNeighNew[0] = EmNeighOld[0]; EmNeighNewNdx[0] = EmNeighOldNdx[0]; EmNeighNew[1] = EmNeighNew[2] = EmNeighNew[3] = NULL; EmNeighNewNdx[1] = EmNeighNewNdx[2] = EmNeighNewNdx[3] = ti_ndx_unknown; } else inewcase = 0; } break; case 1: assert(ineighme < 4); ineighmep4 = ineighme + 4; if((EmNeighOld[0]->adapted_flag() == OLDFATHER) || (EmNeighOld[1]->adapted_flag() == OLDFATHER)) { //this is a case E inewcase = 3; if(EmNeighOld[0]->adapted_flag() == OLDFATHER) { EmNeighNewNdx[0] = EmNeighOld[0]->son_ndx((ineighme + 1) % 4); EmNeighNew[0]=&(ElemTable->elenode_[EmNeighNewNdx[0]]); ASSERT2(EmNeighNewNdx[0] == ElemTable->lookup_ndx(EmNeighOld[0]->son((ineighme + 1) % 4))); EmNeighNewNdx[1] = EmNeighOld[0]->son_ndx(ineighme); EmNeighNew[1] = &(ElemTable->elenode_[EmNeighNewNdx[1]]); ASSERT2(EmNeighNewNdx[1] == ElemTable->lookup_ndx(EmNeighOld[0]->son(ineighme))); } else { EmNeighNew[1] = EmNeighNew[0] = EmNeighOld[0]; EmNeighNewNdx[1] = EmNeighNewNdx[0] = EmNeighOldNdx[0]; } if(EmNeighOld[1]->adapted_flag() == OLDFATHER) { EmNeighNewNdx[2] = EmNeighOld[1]->son_ndx((ineighme + 1) % 4); EmNeighNew[2] = &(ElemTable->elenode_[EmNeighNewNdx[2]]); ASSERT2(EmNeighNewNdx[2] == ElemTable->lookup_ndx(EmNeighOld[1]->son((ineighme + 1) % 4))); EmNeighNewNdx[3] = EmNeighOld[1]->son_ndx(ineighme); EmNeighNew[3] = &(ElemTable->elenode_[EmNeighNewNdx[3]]); ASSERT2(EmNeighNewNdx[3] == ElemTable->lookup_ndx(EmNeighOld[1]->son(ineighme))); } else { EmNeighNew[3] = EmNeighNew[2] = EmNeighOld[1]; EmNeighNewNdx[3] = EmNeighNewNdx[2] = EmNeighOldNdx[1]; } } else { //this is a case D inewcase = 2; EmNeighNew[0] = EmNeighOld[0]; EmNeighNew[1] = EmNeighOld[1]; EmNeighNew[2] = EmNeighNew[3] = NULL; EmNeighNewNdx[0] = EmNeighOldNdx[0]; EmNeighNewNdx[1] = EmNeighOldNdx[1]; EmNeighNewNdx[2] = EmNeighNewNdx[3] = ti_ndx_unknown; } break; default: inewcase = -1; printf("FUBAR 1 detected in refine_neigh_update! aborting.\n"); assert(0); break; } //switch based on difference in generation between me and my old neighbor, this is used to reduce the number of cases from 5 to 3 (based on new neighbor generation) //sanity check assert((ineigh >= 0) && (ineigh < 4)); assert(ineighp4 == ineigh + 4); if(inewcase) { assert((ineighme >= 0) && (ineighme < 4)); assert(ineighmep4 == ineighme + 4); } //now only deal with the new cases, and yes I know that I //am resetting neighbor information in ghost cells but //not neighbor information of the original cells on other //processors, I'm going to fix that in a minute switch (inewcase) { case 0: //case A break; case 1: //case B //new neighbor generation is my (the OLDFATHER) generation EmNeighNew[0]->set_neighbor(ineighme, EmSon[isonB]->key()); EmNeighNew[0]->set_neighbor(ineighmep4, EmSon[isonA]->key()); EmSon[isonA]->set_neighbor(ineigh, EmNeighNew[0]->key()); EmSon[isonA]->set_neighbor(ineighp4, EmNeighNew[0]->key()); EmSon[isonB]->set_neighbor(ineigh, EmNeighNew[0]->key()); EmSon[isonB]->set_neighbor(ineighp4, EmNeighNew[0]->key()); EmNeighNew[0]->neighbor_ndx(ineighme, EmSonNdx[isonB]); EmNeighNew[0]->neighbor_ndx(ineighmep4, EmSonNdx[isonA]); EmSon[isonA]->neighbor_ndx(ineigh, EmNeighNewNdx[0]); EmSon[isonA]->neighbor_ndx(ineighp4, EmNeighNewNdx[0]); EmSon[isonB]->neighbor_ndx(ineigh, EmNeighNewNdx[0]); EmSon[isonB]->neighbor_ndx(ineighp4, EmNeighNewNdx[0]); EmNeighNew[0]->get_neigh_gen(ineighme, EmSon[isonA]->generation()); EmNeighNew[0]->get_neigh_gen(ineighmep4, EmSon[isonA]->generation()); EmSon[isonA]->get_neigh_gen(ineigh, EmNeighNew[0]->generation()); EmSon[isonA]->get_neigh_gen(ineighp4, EmNeighNew[0]->generation()); EmSon[isonB]->get_neigh_gen(ineigh, EmNeighNew[0]->generation()); EmSon[isonB]->get_neigh_gen(ineighp4, EmNeighNew[0]->generation()); EmSon[isonA]->set_neigh_proc(ineighp4, -2); EmSon[isonB]->set_neigh_proc(ineighp4, -2); EmNeighNew[0]->set_neigh_proc(ineighme, EmFather->myprocess()); EmNeighNew[0]->set_neigh_proc(ineighmep4, EmFather->myprocess()); //update the nodes on this side //The new difference in generation tells me the OLDFATHER's //2 corner nodes on this side are actually CORNER's and not //S_C_CON's inode = ineigh; ASSERT2(node_key_ndx[inode][ifather] == NodeTable->lookup_ndx(node_key[inode][ifather])); node_info[node_key_ndx[inode][ifather]]=CORNER; inode = ineighp4; ASSERT2(node_key_ndx[inode][EmSonNdx[isonA]]==NodeTable->lookup_ndx(node_key[inode][EmSonNdx[isonA]])); node_info[node_key_ndx[inode][EmSonNdx[isonA]]]=S_S_CON; ASSERT2(node_key_ndx[inode][ifather] == NodeTable->lookup_ndx(node_key[inode][ifather])); node_info[node_key_ndx[inode][ifather]]=S_C_CON; ASSERT2(node_key_ndx[inode][EmSonNdx[isonB]]==NodeTable->lookup_ndx(node_key[inode][EmSonNdx[isonB]])); node_info[node_key_ndx[inode][EmSonNdx[isonB]]]=S_S_CON; inode = (ineigh + 1) % 4; ASSERT2(node_key_ndx[inode][ifather] == NodeTable->lookup_ndx(node_key[inode][ifather])); node_info[node_key_ndx[inode][ifather]]=CORNER; break; case 2: //cases C & D //new neighbor generation is my son's generation EmNeighNew[0]->set_neighbor(ineighme, EmSon[isonA]->key()); EmNeighNew[0]->set_neighbor(ineighmep4, EmSon[isonA]->key()); EmNeighNew[1]->set_neighbor(ineighme, EmSon[isonB]->key()); EmNeighNew[1]->set_neighbor(ineighmep4, EmSon[isonB]->key()); EmSon[isonA]->set_neighbor(ineigh, EmNeighNew[0]->key()); EmSon[isonA]->set_neighbor(ineighp4, EmNeighNew[0]->key()); EmSon[isonB]->set_neighbor(ineigh, EmNeighNew[1]->key()); EmSon[isonB]->set_neighbor(ineighp4, EmNeighNew[1]->key()); EmNeighNew[0]->neighbor_ndx(ineighme, EmSonNdx[isonA]); EmNeighNew[0]->neighbor_ndx(ineighmep4, EmSonNdx[isonA]); EmNeighNew[1]->neighbor_ndx(ineighme, EmSonNdx[isonB]); EmNeighNew[1]->neighbor_ndx(ineighmep4, EmSonNdx[isonB]); EmSon[isonA]->neighbor_ndx(ineigh, EmNeighNewNdx[0]); EmSon[isonA]->neighbor_ndx(ineighp4, EmNeighNewNdx[0]); EmSon[isonB]->neighbor_ndx(ineigh, EmNeighNewNdx[1]); EmSon[isonB]->neighbor_ndx(ineighp4, EmNeighNewNdx[1]); EmNeighNew[0]->get_neigh_gen(ineighme, EmSon[isonA]->generation()); EmNeighNew[0]->get_neigh_gen(ineighmep4, EmSon[isonA]->generation()); EmNeighNew[1]->get_neigh_gen(ineighme, EmSon[isonA]->generation()); EmNeighNew[1]->get_neigh_gen(ineighmep4, EmSon[isonA]->generation()); EmNeighNew[0]->set_neigh_proc(ineighmep4, -2); EmNeighNew[1]->set_neigh_proc(ineighmep4, -2); EmSon[isonA]->set_neigh_proc(ineighp4, -2); EmSon[isonB]->set_neigh_proc(ineighp4, -2); EmSon[isonA]->get_neigh_gen(ineigh, EmNeighNew[0]->generation()); EmSon[isonA]->get_neigh_gen(ineighp4, EmNeighNew[0]->generation()); EmSon[isonB]->get_neigh_gen(ineigh, EmNeighNew[0]->generation()); EmSon[isonB]->get_neigh_gen(ineighp4, EmNeighNew[0]->generation()); EmSon[isonA]->set_neigh_proc(ineigh, EmNeighNew[0]->myprocess()); EmSon[isonB]->set_neigh_proc(ineigh, EmNeighNew[1]->myprocess()); EmNeighNew[0]->set_neigh_proc(ineighme, EmFather->myprocess()); EmNeighNew[1]->set_neigh_proc(ineighme, EmFather->myprocess()); //update the nodes on this side //don't update my corner nodes because they could be S_C_CON's //if they should be S_C_CON's and I reset them to CORNERs I //will no longer conserve mass/volume in a dramatically //observable fashion if(EmSon[isonA]->neigh_gen((ineigh + 3) % 4) == EmSon[isonA]->generation()) { //neighbor before (tested here) and after this (the ineigh) //corner (i.e. the ineigh neighbor) are the same generation //as me, therefor this (the ineigh) node is a CORNER and not //an S_C_CON node inode = ineigh; ASSERT2(node_key_ndx[inode][ifather] == NodeTable->lookup_ndx(node_key[inode][ifather])); node_info[node_key_ndx[inode][ifather]]=CORNER; } inode = ineigh + 4; ASSERT2(node_key_ndx[inode][EmSonNdx[isonA]]==NodeTable->lookup_ndx(node_key[inode][EmSonNdx[isonA]])); node_info[node_key_ndx[inode][EmSonNdx[isonA]]]=SIDE; ASSERT2(node_key_ndx[inode][ifather] == NodeTable->lookup_ndx(node_key[inode][ifather])); node_info[node_key_ndx[inode][ifather]]=CORNER; ASSERT2(node_key_ndx[inode][EmSonNdx[isonB]]==NodeTable->lookup_ndx(node_key[inode][EmSonNdx[isonB]])); node_info[node_key_ndx[inode][EmSonNdx[isonB]]]=SIDE; if(EmSon[isonB]->neigh_gen((ineigh + 1) % 4) == EmSon[isonB]->generation()) { //neighbor before (i.e. the ineigh neighbor) and after //(tested here) this (the (ineigh+1)%4) corner are the //the same generation as me, therefore this (the //(ineigh+1)%4) node is a CORNER and not an S_C_CON node inode = (ineigh + 1) % 4; ASSERT2(node_key_ndx[inode][ifather] == NodeTable->lookup_ndx(node_key[inode][ifather])); node_info[node_key_ndx[inode][ifather]]=CORNER; } break; case 3: //case E //update the nodes on this side inode = ineigh; //father corner node ASSERT2(node_key_ndx[inode][ifather] == NodeTable->lookup_ndx(node_key[inode][ifather])); node_info[node_key_ndx[inode][ifather]]=CORNER; inode = ineighp4; //father edge node ASSERT2(node_key_ndx[inode][ifather] == NodeTable->lookup_ndx(node_key[inode][ifather])); node_info[node_key_ndx[inode][ifather]]=CORNER; inode = (ineigh + 1) % 4; //father corner node ASSERT2(node_key_ndx[inode][ifather] == NodeTable->lookup_ndx(node_key[inode][ifather])); node_info[node_key_ndx[inode][ifather]]=CORNER; EmNeighNew[0]->set_neighbor(ineighme, EmSon[isonA]->key()); EmNeighNew[0]->set_neighbor(ineighmep4, EmSon[isonA]->key()); EmNeighNew[1]->set_neighbor(ineighme, EmSon[isonA]->key()); EmNeighNew[1]->set_neighbor(ineighmep4, EmSon[isonA]->key()); EmNeighNew[2]->set_neighbor(ineighme, EmSon[isonB]->key()); EmNeighNew[2]->set_neighbor(ineighmep4, EmSon[isonB]->key()); EmNeighNew[3]->set_neighbor(ineighme, EmSon[isonB]->key()); EmNeighNew[3]->set_neighbor(ineighmep4, EmSon[isonB]->key()); EmSon[isonA]->set_neighbor(ineigh, EmNeighNew[0]->key()); EmSon[isonA]->set_neighbor(ineighp4, EmNeighNew[1]->key()); EmSon[isonB]->set_neighbor(ineigh, EmNeighNew[2]->key()); EmSon[isonB]->set_neighbor(ineighp4, EmNeighNew[3]->key()); EmNeighNew[0]->neighbor_ndx(ineighme, EmSonNdx[isonA]); EmNeighNew[0]->neighbor_ndx(ineighmep4, EmSonNdx[isonA]); EmNeighNew[1]->neighbor_ndx(ineighme, EmSonNdx[isonA]); EmNeighNew[1]->neighbor_ndx(ineighmep4, EmSonNdx[isonA]); EmNeighNew[2]->neighbor_ndx(ineighme, EmSonNdx[isonB]); EmNeighNew[2]->neighbor_ndx(ineighmep4, EmSonNdx[isonB]); EmNeighNew[3]->neighbor_ndx(ineighme, EmSonNdx[isonB]); EmNeighNew[3]->neighbor_ndx(ineighmep4, EmSonNdx[isonB]); EmSon[isonA]->neighbor_ndx(ineigh, EmNeighNewNdx[0]); EmSon[isonA]->neighbor_ndx(ineighp4, EmNeighNewNdx[1]); EmSon[isonB]->neighbor_ndx(ineigh, EmNeighNewNdx[2]); EmSon[isonB]->neighbor_ndx(ineighp4, EmNeighNewNdx[3]); //if(Curr_El) if(IfNeighProcChange(El_Table,NodeTable,myid,Curr_El,EmFather)) assert(0); EmNeighNew[0]->get_neigh_gen(ineighme, EmSon[isonA]->generation()); EmNeighNew[0]->get_neigh_gen(ineighmep4, EmSon[isonA]->generation()); EmNeighNew[1]->get_neigh_gen(ineighme, EmSon[isonA]->generation()); EmNeighNew[1]->get_neigh_gen(ineighmep4, EmSon[isonA]->generation()); EmNeighNew[2]->get_neigh_gen(ineighme, EmSon[isonA]->generation()); EmNeighNew[2]->get_neigh_gen(ineighmep4, EmSon[isonA]->generation()); EmNeighNew[3]->get_neigh_gen(ineighme, EmSon[isonA]->generation()); EmNeighNew[3]->get_neigh_gen(ineighmep4, EmSon[isonA]->generation()); EmSon[isonA]->get_neigh_gen(ineigh, EmNeighNew[0]->generation()); EmSon[isonA]->get_neigh_gen(ineighp4, EmNeighNew[0]->generation()); EmSon[isonB]->get_neigh_gen(ineigh, EmNeighNew[2]->generation()); EmSon[isonB]->get_neigh_gen(ineighp4, EmNeighNew[2]->generation()); EmNeighNew[0]->set_neigh_proc(ineighmep4, -2); EmNeighNew[1]->set_neigh_proc(ineighmep4, -2); EmNeighNew[2]->set_neigh_proc(ineighmep4, -2); EmNeighNew[3]->set_neigh_proc(ineighmep4, -2); //if(Curr_El) if(IfNeighProcChange(El_Table,NodeTable,myid,Curr_El,EmFather)) assert(0); EmSon[isonA]->set_neigh_proc(ineigh, EmFather->neigh_proc(ineigh)); //if(Curr_El) if(IfNeighProcChange(El_Table,NodeTable,myid,Curr_El,EmFather)) assert(0); EmSon[isonB]->set_neigh_proc(ineigh, EmFather->neigh_proc(ineighp4)); //if(Curr_El) if(IfNeighProcChange(El_Table,NodeTable,myid,Curr_El,EmFather)) assert(0); inode = ineighp4; //sonA edge node ASSERT2(node_key_ndx[inode][EmSonNdx[isonA]]==NodeTable->lookup_ndx(node_key[inode][EmSonNdx[isonA]])); if(EmSon[isonA]->neighbor(ineigh)==EmSon[isonA]->neighbor(ineighp4)) { EmSon[isonA]->set_neigh_proc(ineighp4, -2); node_info[node_key_ndx[inode][EmSonNdx[isonA]]]=SIDE; } else { EmSon[isonA]->set_neigh_proc(ineighp4, EmSon[isonA]->neigh_proc(ineigh)); node_info[node_key_ndx[inode][EmSonNdx[isonA]]]=S_C_CON; inode = ineighmep4; ASSERT2(node_key_ndx[inode][EmNeighNewNdx[0]] == NodeTable->lookup_ndx(node_key[inode][EmNeighNewNdx[0]])); node_info[node_key_ndx[inode][EmNeighNewNdx[0]]]=S_S_CON; ASSERT2(node_key_ndx[inode][EmNeighNewNdx[1]] == NodeTable->lookup_ndx(node_key[inode][EmNeighNewNdx[1]])); node_info[node_key_ndx[inode][EmNeighNewNdx[1]]]=S_S_CON; } inode = ineighp4; //sonB edge node ASSERT2(node_key_ndx[inode][EmSonNdx[isonB]]==NodeTable->lookup_ndx(node_key[inode][EmSonNdx[isonB]])); if(EmSon[isonB]->neighbor(ineigh)==EmSon[isonB]->neighbor(ineighp4)) { EmSon[isonB]->set_neigh_proc(ineighp4, -2); node_info[node_key_ndx[inode][EmSonNdx[isonB]]]=SIDE; } else { EmSon[isonB]->set_neigh_proc(ineighp4, EmSon[isonB]->neigh_proc(ineigh)); node_info[node_key_ndx[inode][EmSonNdx[isonB]]]=S_C_CON; inode = ineighmep4; ASSERT2(node_key_ndx[inode][EmNeighNewNdx[2]] == NodeTable->lookup_ndx(node_key[inode][EmNeighNewNdx[2]])); node_info[node_key_ndx[inode][EmNeighNewNdx[2]]]=S_S_CON; ASSERT2(node_key_ndx[inode][EmNeighNewNdx[3]] == NodeTable->lookup_ndx(node_key[inode][EmNeighNewNdx[3]])); node_info[node_key_ndx[inode][EmNeighNewNdx[3]]]=S_S_CON; } break; default: printf("FUBAR 2 detected in refine_neigh_update! aborting.\n"); assert(0); break; } //switch(inewcase), case based on generation of my new neighbor } //else: not a map boundary } //iside loop }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(dynamic,TITAN2D_DINAMIC_CHUNK)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try20/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
n euclidean_distance[id1 * n + id2]; } static INLINE void calcEuclideanDistanceAndStoreInArray() { <LOOP-START>for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { euclidean_distance[i * n + j] = euclidean_distance[j * n + i] = (i == j) ? 0 : calc_distance(i, j); } }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try20/pivot.c
#pragma omp parallel for schedule(static, 200) num_threads(thread_count)
100
******************************************* int len = c_n_m(n, m); // set omp thread number <LOOP-START>for (int i = 0; i < len; i++) { int tid = omp_get_thread_num(); int *values = object[i].values; for (int __m__ = 0; __m__ < m; __m__++) { int pivot_id = values[__m__]; int _d2 = pivot_id * n; for (int __n__ = 0; __n__ < n; __n__++) { cache_eu_dist[tid][__m__ * n + __n__] = euclidean_distance[_d2 + __n__]; } } for (int __i__ = 0; __i__ < n; __i__++) { int bound = __i__ + 1; for (int __j__ = bound; __j__ < n; __j__++) { object[i].cost += calcOneChebyshevDistance(__i__, __j__, tid); } } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(static, 200) num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try9/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
nDistanceAndStoreInArray() { // when adding this pragma, the program can be really fast! // <LOOP-START>for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { euclidean_distance[i * n + j] = get_distance(i, j); } // printf("calcEuclideanDistanceAndStoreInArray: %d\n", i); }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try9/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
tf("c_n_m = %d, each_thread_works = %d\n", c_n_m(n, m), each_thread_works); <LOOP-START>for (int __thread__ = 0; __thread__ < thread_count; __thread__++) { struct timeval start1, end1; gettimeofday(&start1, NULL); // ********************************************************* int base_index = __thread__ * each_thread_works; int end_index = base_index + each_thread_works; if (end_index > c_n_m(n, m)) { end_index = c_n_m(n, m); } for (int i = base_index; i < end_index; i++) { united_calc_and_add(object[i].values, &object[i].cost); } gettimeofday(&end1, NULL); printf("thread %d finished, time = %lf ms\n", __thread__, (end1.tv_sec - start1.tv_sec) * 1000 + (end1.tv_usec - start1.tv_usec) / 1000.0); // ********************************************************* }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try6/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
nDistanceAndStoreInArray() { // when adding this pragma, the program can be really fast! // <LOOP-START>for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { euclidean_distance[i * n + j] = get_distance(i, j); } // printf("calcEuclideanDistanceAndStoreInArray: %d\n", i); }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try6/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
bination)); com->values = (int *)malloc(sizeof(int) * m); com->cost = 0; // <LOOP-START>for (int i = 0; i < c_n_m(n, m); i++) { com = next_combination(com); // CRITICAL SECTION if (com == NULL) { break; } int *values = com->values; // struct timeval start, end; // gettimeofday(&start, NULL); calcAllChebyshevDistanceAndStoreInArray(chebyshev_matrix, values); // cost about 1 ms // gettimeofday(&end, NULL); // printf("calcAllChebyshevDistanceAndStoreInArray() time: %ld // ms\n", // (end.tv_sec - start.tv_sec) * 1000 + // (end.tv_usec - start.tv_usec) / 1000); float res = add_all_entries_of_matrix(chebyshev_matrix); // float res = 0; com->cost = res; // store the combination in object array // object had been fully allocated in the beginning. store_in_object(com); // CRITICAL SECTION if (res_index % 1000 == 0) { printf("combination %d finished, i = %d \n\n", res_index, i); } }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try7/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
nDistanceAndStoreInArray() { // when adding this pragma, the program can be really fast! // <LOOP-START>for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { euclidean_distance[i * n + j] = get_distance(i, j); } // printf("calcEuclideanDistanceAndStoreInArray: %d\n", i); }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try7/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
omp_lock_t LOCK_1, LOCK_2; omp_init_lock(&LOCK_1); omp_init_lock(&LOCK_2); <LOOP-START>for (int __thread__ = 0; __thread__ < thread_count; __thread__++) { // ********************************************************* // int chebyshev_matrix_set = 0; double **chebyshev_matrix = (double **)malloc(sizeof(double *) * n); for (int j = 0; j < n; j++) { chebyshev_matrix[j] = (double *)malloc(sizeof(double) * n); }; combination *com = (combination *)malloc(sizeof(combination)); com->values = (int *)malloc(sizeof(int) * m); com->cost = 0; for (int i = 0; i < each_thread_works; i++) { // lock1 omp_set_lock(&LOCK_1); com = next_combination(com); // CRITICAL SECTION omp_unset_lock(&LOCK_1); if (com == NULL) { printf("thread %d finished, breaking...\n", __thread__); break; } int *values = com->values; // struct timeval start, end; // gettimeofday(&start, NULL); calcAllChebyshevDistanceAndStoreInArray( chebyshev_matrix, values); // cost about 1 ms // gettimeofday(&end, NULL); // printf("calcAllChebyshevDistanceAndStoreInArray() time: %ld // ms\n", // (end.tv_sec - start.tv_sec) * 1000 + // (end.tv_usec - start.tv_usec) / 1000); double res = add_all_entries_of_matrix(chebyshev_matrix); // double res = 0; com->cost = res; // store the combination in object array // object had been fully allocated in the beginning. // lock2 omp_set_lock(&LOCK_2); store_in_object(com); // CRITICAL SECTION omp_unset_lock(&LOCK_2); if (res_index % 1000 == 0) { printf("combination %d finished, i = %d, thread = %d \n\n", res_index, i, __thread__); } } if (!com == NULL) { free(com->values); free(com); } for (int j = 0; j < n; j++) { free(chebyshev_matrix[j]); } free(chebyshev_matrix); // ********************************************************* }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try16/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
2) static INLINE double calc_distance(int id1, int id2) { double sum = 0; // 更改5,没作用 // <LOOP-START>for (int i = 0; i < dim; i++) { double diff = get_point_coordinate_of_id_and_dimension(id1, i) - get_point_coordinate_of_id_and_dimension(id2, i); sum += diff * diff; }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try16/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
id2]; } // 计算每对顶点的欧几里得距离并存储在数组中 static INLINE void calcEuclideanDistanceAndStoreInArray() { // <LOOP-START>// 更改3: 加入collapse(2) #pragma omp parallel for num_threads(thread_count) for (int i = 0; i < n; i++) { // 更改4,大概优化100ms for (int j = i; j < n; j++) { // if (i == j) { // euclidean_distance[i * n + j] = 0; // } else { // euclidean_distance[i * n + j] = calc_distance(i, j); // } // *更改1:更换为三目运算符 // euclidean_distance[i * n + j] = (i == j) ? 0 : calc_distance(i, j); // 更改4: d(i,j) = d(j,i) euclidean_distance[i * n + j] = euclidean_distance[j * n + i] = (i == j) ? 0 : calc_distance(i, j); } // printf("calcEuclideanDistanceAndStoreInArray: %d\n", i); }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try16/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
InArray() { // #pragma omp parallel for num_threads(thread_count) // 更改3: 加入collapse(2) <LOOP-START>for (int i = 0; i < n; i++) { // 更改4,大概优化100ms for (int j = i; j < n; j++) { // if (i == j) { // euclidean_distance[i * n + j] = 0; // } else { // euclidean_distance[i * n + j] = calc_distance(i, j); // } // *更改1:更换为三目运算符 // euclidean_distance[i * n + j] = (i == j) ? 0 : calc_distance(i, j); // 更改4: d(i,j) = d(j,i) euclidean_distance[i * n + j] = euclidean_distance[j * n + i] = (i == j) ? 0 : calc_distance(i, j); } // printf("calcEuclideanDistanceAndStoreInArray: %d\n", i); }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try16/pivot.c
#pragma omp parallel for ?
100
bject object = (combination *)malloc(sizeof(combination) * c_n_m(n, m)); // *更改,可以加 <LOOP-START>// #pragma omp parallel for (变慢了) for (int i = 0; i < c_n_m(n, m); i++) { object[i].values = (int *)malloc(sizeof(int) * m); object[i].cost = 0; }<LOOP-END> <OMP-START>#pragma omp parallel for ?<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try16/pivot.c
#pragma omp parallel for (变慢了)
100
malloc(sizeof(combination) * c_n_m(n, m)); // *更改,可以加 #pragma omp parallel for ? // <LOOP-START>for (int i = 0; i < c_n_m(n, m); i++) { object[i].values = (int *)malloc(sizeof(int) * m); object[i].cost = 0; }<LOOP-END> <OMP-START>#pragma omp parallel for (变慢了)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try16/pivot.c
#pragma omp parallel for schedule(static,200) num_threads(thread_count)
100
en = c_n_m(n, m); // set omp thread number // Q: 怎么确定的schedule(static,200)? <LOOP-START>// #pragma omp parallel for schedule(guided) num_threads(thread_count) for (int i = 0; i < len; i++) { int tid = omp_get_thread_num(); int d1 = tid * m * n; int *values = object[i].values; // 计算cube中d1层的矩阵 for (int __m__ = 0; __m__ < m; __m__++) { int d2 = d1 + __m__ * n; int pivot_id = values[__m__]; int _d2 = pivot_id * n; for (int __n__ = 0; __n__ < n; __n__++) { cache_eu_dist[d2 + __n__] = euclidean_distance[_d2 + __n__]; } } // 计算每两点之间的切比雪夫距离 for (int __i__ = 0; __i__ < n; __i__++) { for (int __j__ = __i__ + 1; __j__ < n; __j__++) { object[i].cost += calcOneChebyshevDistance(__i__, __j__, tid); } } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(static,200) num_threads(thread_count) <OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try16/pivot.c
#pragma omp parallel for schedule(guided) num_threads(thread_count)
100
c,200)? #pragma omp parallel for schedule(static,200) num_threads(thread_count) // <LOOP-START>for (int i = 0; i < len; i++) { int tid = omp_get_thread_num(); int d1 = tid * m * n; int *values = object[i].values; // 计算cube中d1层的矩阵 for (int __m__ = 0; __m__ < m; __m__++) { int d2 = d1 + __m__ * n; int pivot_id = values[__m__]; int _d2 = pivot_id * n; for (int __n__ = 0; __n__ < n; __n__++) { cache_eu_dist[d2 + __n__] = euclidean_distance[_d2 + __n__]; } } // 计算每两点之间的切比雪夫距离 for (int __i__ = 0; __i__ < n; __i__++) { for (int __j__ = __i__ + 1; __j__ < n; __j__++) { object[i].cost += calcOneChebyshevDistance(__i__, __j__, tid); } } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(guided) num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try18/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
n euclidean_distance[id1 * n + id2]; } static INLINE void calcEuclideanDistanceAndStoreInArray() { <LOOP-START>for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) { euclidean_distance[i * n + j] = 0; } else { euclidean_distance[i * n + j] = calc_distance(i, j); } } // printf("calcEuclideanDistanceAndStoreInArray: %d\n", i); }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try18/pivot.c
#pragma omp parallel for schedule(static, 200) num_threads(thread_count)
100
******************************************* int len = c_n_m(n, m); // set omp thread number <LOOP-START>for (int i = 0; i < len; i++) { int tid = omp_get_thread_num(); int *values = object[i].values; for (int __m__ = 0; __m__ < m; __m__++) { int pivot_id = values[__m__]; int _d2 = pivot_id * n; for (int __n__ = 0; __n__ < n; __n__++) { cache_eu_dist[tid][__m__ * n + __n__] = euclidean_distance[_d2 + __n__]; } } for (int __i__ = 0; __i__ < n; __i__++) { int bound = __i__ + 1; for (int __j__ = bound; __j__ < n; __j__++) { object[i].cost += calcOneChebyshevDistance(__i__, __j__, tid); } } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(static, 200) num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try5/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
nDistanceAndStoreInArray() { // when adding this pragma, the program can be really fast! // <LOOP-START>for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { euclidean_distance[i * n + j] = get_distance(i, j); } // printf("calcEuclideanDistanceAndStoreInArray: %d\n", i); }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try5/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
j++) { chebyshev_matrix[j] = (float *)malloc(sizeof(float) * n); }; // <LOOP-START>for (int i = 0; i < c_n_m(n, m); i++) { combination *com = next_combination(); // very quick if (com == NULL) { break; } int *values = com->values; // struct timeval start, end; // gettimeofday(&start, NULL); calcAllChebyshevDistanceAndStoreInArray(chebyshev_matrix, values); // very slow!! // gettimeofday(&end, NULL); // printf("calcAllChebyshevDistanceAndStoreInArray() time: %ld ms\n", // (end.tv_sec - start.tv_sec) * 1000 + // (end.tv_usec - start.tv_usec) / 1000); float res = add_all_entries_of_matrix(chebyshev_matrix); // float res = 0; com->cost = res; // store the combination in object array // object had been fully allocated in the beginning. store_in_object(com); free(com->values); free(com); if (res_index % 1000 == 0) { printf("combination %d finished, i = %d \n\n", res_index, i); } }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try10/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
printf("c_n_m = %d, each_thread_works = %d\n", c_n_m(n, m), each_thread_works); <LOOP-START>for (int __thread__ = 0; __thread__ < thread_count; __thread__++) { struct timeval start1, end1; gettimeofday(&start1, NULL); // ********************************************************* int base_index = __thread__ * each_thread_works; int end_index = base_index + each_thread_works; if (end_index > c_n_m(n, m)) { end_index = c_n_m(n, m); } for (int i = base_index; i < end_index; i++) { for (int j = 0; j < m; j++) { small_cache[__thread__][j] = object[i].values[j] * n; } for (int __i__ = 0; __i__ < n; __i__++) { for (int __j__ = 0; __j__ < n; __j__++) { if (__i__ > __j__) { object[i].cost += calcOneChebyshevDistance( __i__, __j__, object[i].values, __thread__); } } } } gettimeofday(&end1, NULL); printf("thread %d finished, time = %lf ms\n", __thread__, (end1.tv_sec - start1.tv_sec) * 1000 + (end1.tv_usec - start1.tv_usec) / 1000.0); // ********************************************************* }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try3/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
alcEuclideanDistanceAndStoreInArray() { // when adding this pragma, the program can be really fast! <LOOP-START>for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { euclidean_distance[i * n + j] = get_distance(i, j); } // printf("calcEuclideanDistanceAndStoreInArray: %d\n", i); }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try19/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
return euclidean_distance[id1][id2]; } static INLINE void calcEuclideanDistanceAndStoreInArray() { <LOOP-START>for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) { euclidean_distance[i][j] = 0; } else { euclidean_distance[i][j] = calc_distance(i, j); } } // printf("calcEuclideanDistanceAndStoreInArray: %d\n", i); }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try19/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
******************************************* int len = c_n_m(n, m); // set omp thread number <LOOP-START>for (int i = 0; i < len; i++) { int tid = omp_get_thread_num(); int *values = object[i].values; for (int __m__ = 0; __m__ < m; __m__++) { int pivot_id = values[__m__]; cache_eu_dist[tid][__m__] = euclidean_distance[pivot_id]; } for (int __i__ = 0; __i__ < n; __i__++) { int bound = __i__ + 1; for (int __j__ = bound; __j__ < n; __j__++) { object[i].cost += calcOneChebyshevDistance(__i__, __j__, tid); } } }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try14/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
clidean_distance[id1 * n + id2]; } static INLINE void calcEuclideanDistanceAndStoreInArray() { <LOOP-START>for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) { euclidean_distance[i * n + j] = 0; } else { euclidean_distance[i * n + j] = calc_distance(i, j); } } // printf("calcEuclideanDistanceAndStoreInArray: %d\n", i); }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try14/pivot.c
#pragma omp parallel for schedule(static, 200) num_threads(thread_count)
100
******************************************* int len = c_n_m(n, m); // set omp thread number <LOOP-START>for (int i = 0; i < len; i++) { int tid = omp_get_thread_num(); int d1 = tid * m * n; int *values = object[i].values; for (int __m__ = 0; __m__ < m; __m__++) { int d2 = d1 + __m__ * n; int pivot_id = values[__m__]; int _d2 = pivot_id * n; for (int __n__ = 0; __n__ < n; __n__++) { cache_eu_dist[d2 + __n__] = euclidean_distance[_d2 + __n__]; } } for (int __i__ = 0; __i__ < n; __i__++) { int bound = __i__ + 1; for (int __j__ = bound; __j__ < n; __j__++) { object[i].cost += calcOneChebyshevDistance(__i__, __j__, tid); } } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(static, 200) num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try11/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
printf("c_n_m = %d, each_thread_works = %d\n", c_n_m(n, m), each_thread_works); <LOOP-START>for (int __thread__ = 0; __thread__ < thread_count; __thread__++) { struct timeval start1, end1; gettimeofday(&start1, NULL); // ********************************************************* int base_index = __thread__ * each_thread_works; int end_index = base_index + each_thread_works; if (end_index > c_n_m(n, m)) { end_index = c_n_m(n, m); } for (int i = base_index; i < end_index; i++) { for (int __i__ = 0; __i__ < n; __i__++) { // 500 times for (int __j__ = 0; __j__ < n; __j__++) { // 500 * 500 times if (__i__ > __j__) { object[i].cost += calcOneChebyshevDistance( __i__, __j__, object[i].values); } } } } gettimeofday(&end1, NULL); printf("thread %d finished, time = %lf ms\n", __thread__, (end1.tv_sec - start1.tv_sec) * 1000 + (end1.tv_usec - start1.tv_usec) / 1000.0); // ********************************************************* }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try15-big-change-using-avx2/pivot.c
#pragma omp parallel for
100
*********************************** int len = c_n_m(n, m); // set omp thread number <LOOP-START>for (int i = 0; i < len; i++) { // printf("HERE\n"); int tid = omp_get_thread_num(); int d1 = tid * m * n; int *values = object[i].values; for (int __m__ = 0; __m__ < m; __m__++) { int d2 = d1 + __m__ * n; int pivot_id = values[__m__]; int _d2 = pivot_id * n; for (int __n__ = 0; __n__ < n; __n__++) { cache_eu_dist[d2 + __n__] = euclidean_distance[_d2 + __n__]; } } // init the small cache int d2 = tid * m; for (int __n__ = 0; __n__ < n; __n__++) { for (int col = 0; col < block_num; col++) { __m256d _max = _mm256_set1_pd(0.0); for (int __m__ = 0; __m__ < m; __m__++) { int d3 = d1 + __m__ * n; small_cache[d2 + __m__] = cache_eu_dist[d3 + __n__]; // construct __m256d every 4 elements of cache_eu_dist // __m256d _cache_eu_dist = // _mm256_loadu_pd(&cache_eu_dist[d3 + col * 4]); block_cache[d2 + __m__] = _mm256_andnot_pd( _mm256_set1_pd(-0.0), _mm256_sub_pd(_mm256_loadu_pd(&cache_eu_dist[d3 + col * 4]), _mm256_set1_pd(small_cache[d2 + __m__]))); // for each index from 0 to 3, find the max value of // each column if (__m__ == 0) { _max = block_cache[d2 + __m__]; } else { _max = _mm256_max_pd(_max, block_cache[d2 + __m__]); } } object[i].cost += hsum_double_avx(_max); } } }<LOOP-END> <OMP-START>#pragma omp parallel for <OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try17/pivot.c
#pragma omp parallel for num_threads(thread_count)
100
clidean_distance[id1 * n + id2]; } static INLINE void calcEuclideanDistanceAndStoreInArray() { <LOOP-START>for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) { euclidean_distance[i * n + j] = 0; } else { euclidean_distance[i * n + j] = calc_distance(i, j); } } // printf("calcEuclideanDistanceAndStoreInArray: %d\n", i); }<LOOP-END> <OMP-START>#pragma omp parallel for num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try17/pivot.c
#pragma omp parallel for schedule(static, 200) num_threads(thread_count)
100
******************************************* int len = c_n_m(n, m); // set omp thread number <LOOP-START>for (int i = 0; i < len; i++) { int tid_ = omp_get_thread_num(); short unsigned int tid = (short unsigned int)tid_; int d1 = tid * m * n; short unsigned int *values = object[i].values; for (int __m__ = 0; __m__ < m; __m__++) { int d2 = d1 + __m__ * n; int pivot_id = values[__m__]; int _d2 = pivot_id * n; for (int __n__ = 0; __n__ < n; __n__++) { cache_eu_dist[d2 + __n__] = euclidean_distance[_d2 + __n__]; } } for (short unsigned int __i__ = 0; __i__ < n; __i__++) { short unsigned int bound = __i__ + 1; for (short unsigned int __j__ = bound; __j__ < n; __j__++) { object[i].cost += calcOneChebyshevDistance(__i__, __j__, tid); } } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(static, 200) num_threads(thread_count)<OMP-END>
/ascldap/users/netienn/Research/HPC-Coder/data/ClonedRepos/void-echo/SDU-Parallel-Lab/LAB/try13/pivot.c
#pragma omp parallel for schedule(static, 100) num_threads(thread_count)
100
******************************************* int len = c_n_m(n, m); // set omp thread number <LOOP-START>for (int i = 0; i < len; i++) { for (int __i__ = 0; __i__ < n; __i__++) { int bound = __i__ + 1; for (int __j__ = bound; __j__ < n; __j__++) { object[i].cost += calcOneChebyshevDistance( __i__, __j__, object[i].values); } } }<LOOP-END> <OMP-START>#pragma omp parallel for schedule(static, 100) num_threads(thread_count)<OMP-END>