Skip to content

Commit dee9876

Browse files
authored
Merge pull request #73 from BconstantMMK/dev
Fast/FastS: bug fix for openMP
2 parents 7de6547 + a1aaa4c commit dee9876

File tree

5 files changed

+60
-54
lines changed

5 files changed

+60
-54
lines changed

Fast/Fast/Fast/gsdr3.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,11 @@ E_Int rank =0;
242242

243243
// calcul metric si maillage deformable
244244
//
245-
#include "../FastS/FastS/Metric/cp_metric.cpp"
245+
#include "FastS/Metric/cp_metric.cpp"
246246
}
247247

248+
// init verrou omp
249+
#include "FastS/Compute/verrou_lhs_init.cpp"
248250
//---------------------------------------------------------------------
249251
// -----Boucle sur num.les domaines de la configuration
250252
// ---------------------------------------------------------------------

Fast/FastS/FastS/Compute/bcs.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@
4040
if(nd>=0){ correct_coins_(nd, param_int[nd], ipt_inddm_omp , iptro_CL[nd]); }
4141
}//autorisation
4242

43-
44-
//Reinitialisation verrou omp
45-
//
46-
E_Int l = ntask*mx_synchro*Nbre_thread_actif + (ithread_loc-1)*mx_synchro;
47-
for (E_Int i = 0; i < mx_synchro ; i++) { ipt_lok[ l + i ] = 0; }
43+
//Reinitialisation verrou omp rhs
44+
E_Int l = ntask*mx_synchro*Nbre_thread_actif + (ithread_loc-1)*mx_synchro;
45+
for (E_Int i = 0; i < mx_synchro ; i++) { ipt_lok[ l + i ] = 0; }
4846

4947
}//loop zone

Fast/FastS/FastS/Compute/gsdr3.cpp

+34-34
Original file line numberDiff line numberDiff line change
@@ -232,38 +232,39 @@ if(nitcfg==1){param_real[0][TEMPS] = 0.0;}
232232
E_Int* ipt_ind_dm_omp_thread = ipt_ind_dm_socket + 6;
233233

234234
E_Int* ipt_nidom_loc, nb_subzone;
235-
/****************************************************
235+
/****************************************************
236236
-----Boucle sous-iteration
237-
****************************************************/
238-
E_Int nbtask = ipt_omp[nitcfg-1];
239-
E_Int ptiter = ipt_omp[nssiter+ nitcfg-1];
240-
241-
if( nitcfg == 1)
242-
{
243-
//mise a jour metric et vent ale zone cart et 3dhom(3dfull et 2d a la volee)
244-
for (E_Int ntask = 0; ntask < nbtask; ntask++)
245-
{
246-
E_Int pttask = ptiter + ntask*(6+Nbre_thread_actif*7);
247-
E_Int nd = ipt_omp[ pttask ];
248-
if(param_int[nd][LALE]==1) //maillage indeformable
249-
{
250-
mjr_ale_3dhomocart_(nd, param_int[nd] , param_real[nd] ,
251-
socket , Nbre_socket , ithread_sock , thread_parsock,
252-
ipt_ind_dm_socket , ipt_topology_socket,
253-
iptx[nd] , ipty[nd] , iptz[nd] ,
254-
ipti[nd] , iptj[nd] , iptk[nd] ,
255-
ipti0[nd] , iptj0[nd] , iptk0[nd] , iptvol[nd] ,
256-
iptventi[nd] , iptventj[nd] , iptventk[nd] );
257-
//modifier mjr_ale_3dhomocart_ pour faire sauter barrier
258-
#pragma omp barrier
259-
}
260-
}//zone
261-
262-
263-
// calcul metric si maillage deformable
264-
//
265-
#include "FastS/Metric/cp_metric.cpp"
237+
****************************************************/
238+
E_Int nbtask = ipt_omp[nitcfg-1];
239+
E_Int ptiter = ipt_omp[nssiter+ nitcfg-1];
240+
241+
if( nitcfg == 1)
242+
{
243+
//mise a jour metric et vent ale zone cart et 3dhom(3dfull et 2d a la volee)
244+
for (E_Int ntask = 0; ntask < nbtask; ntask++)
245+
{
246+
E_Int pttask = ptiter + ntask*(6+Nbre_thread_actif*7);
247+
E_Int nd = ipt_omp[ pttask ];
248+
if(param_int[nd][LALE]==1) //maillage indeformable
249+
{
250+
mjr_ale_3dhomocart_(nd, param_int[nd] , param_real[nd] ,
251+
socket , Nbre_socket , ithread_sock , thread_parsock,
252+
ipt_ind_dm_socket , ipt_topology_socket,
253+
iptx[nd] , ipty[nd] , iptz[nd] ,
254+
ipti[nd] , iptj[nd] , iptk[nd] ,
255+
ipti0[nd] , iptj0[nd] , iptk0[nd] , iptvol[nd] ,
256+
iptventi[nd] , iptventj[nd] , iptventk[nd] );
257+
//modifier mjr_ale_3dhomocart_ pour faire sauter barrier
258+
#pragma omp barrier
266259
}
260+
}//zone
261+
262+
// calcul metric si maillage deformable
263+
#include "FastS/Metric/cp_metric.cpp"
264+
}
265+
266+
// init verrou omp
267+
#include "FastS/Compute/verrou_lhs_init.cpp"
267268

268269

269270
//---------------------------------------------------------------------
@@ -298,9 +299,9 @@ if(nitcfg==1){param_real[0][TEMPS] = 0.0;}
298299
#include "FastS/Compute/cp_debitIBM.cpp"
299300
#endif
300301

301-
#if defined __GNUC__ && defined _OPENMP
302-
#pragma omp barrier
303-
#endif
302+
//#if defined __GNUC__ && defined _OPENMP
303+
//#pragma omp barrier
304+
//#endif
304305

305306
//
306307
//timer pour omp "dynamique"
@@ -319,7 +320,6 @@ if(nitcfg==1){param_real[0][TEMPS] = 0.0;}
319320
#include "FastS/Compute/Linear_solver/lhs.cpp"
320321
}
321322

322-
323323
// LUSGS
324324
else
325325
{

Fast/FastS/FastS/Compute/rhs.cpp

+4-14
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
//printf("topo %d %d %d %d %d \n",ipt_topo_omp[0], ipt_topo_omp[1], ipt_topo_omp[2], Nbre_thread_actif_loc, nd );
2020
//printf("shif %d %d %d \n", shift_zone,shift_coe, shift_wig );
2121

22-
//Init verrou rhs pour chaque sous zone et chaque thread actif: init val to zero
23-
E_Int type = 4;
24-
E_Int* verrou_lhs_thread= verrou_lhs + ntask*Nbre_thread_actif + ithread_loc -1;
25-
verrou_c_( verrou_lhs_thread, type);
26-
verrou_lhs_thread = verrou_lhs + (nbtask + ntask)*Nbre_thread_actif + ithread_loc -1; //pour calcul residu avant LU
27-
verrou_c_( verrou_lhs_thread, type );
28-
2922
// Revoir cet adressage si scater et socket>1 et ou nidom >1
3023
E_Int* ipt_lok_thread = ipt_lok + ntask*mx_synchro*Nbre_thread_actif;
3124

@@ -58,19 +51,16 @@
5851
iptdrodm + shift_zone , iptcoe + shift_coe , iptdelta[nd] , iptro_res[nd] , iptsrc[nd] );
5952

6053
//Flush Rhs
61-
E_Int size = param_int[nd][NEQ]*param_int[nd][NDIMDX];
54+
//E_Int size = param_int[nd][NEQ]*param_int[nd][NDIMDX];
6255
//flush_real_( size , iptdrodm + shift_zone);
6356
if(nitcfg==1)
6457
{
65-
size = param_int[nd][NEQ_COE]*param_int[nd][NDIMDX];
58+
E_Int size = param_int[nd][NEQ_COE]*param_int[nd][NDIMDX];
6659
flush_real_( size , iptcoe + shift_coe);
6760
}
68-
//size = param_int[nd][NDIMDX];
69-
//flush_real_( size , iptmut[nd]);
70-
//#pragma omp flush
7161
//Go verrou rhs pour chaque sous zone et chaque thread actif: valeur mise a un
72-
type = 1;
73-
verrou_lhs_thread= verrou_lhs + ntask*Nbre_thread_actif + ithread_loc -1;
62+
E_Int type = 1;
63+
E_Int* verrou_lhs_thread= verrou_lhs + ntask*Nbre_thread_actif + ithread_loc -1;
7464
verrou_c_( verrou_lhs_thread, type );
7565

7666
if(ithread_loc==1 && lexit_lu==0 && nitcfg*nitrun >15 and (nitcfg < 3 or nitcfg == nssiter-1) ){ timer_omp[cpu_perzone]+=1; } //nbre echantillon
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
for (E_Int ntask = 0; ntask < nbtask; ntask++)
2+
{
3+
E_Int pttask = ptiter + ntask*(6+Nbre_thread_actif*7);
4+
ithread_loc = ipt_omp[ pttask + 2 + ithread -1 ] +1 ;
5+
6+
if (ithread_loc == -1) {continue;}
7+
8+
E_Int type = 4;
9+
////Init verrou rhs pour chaque sous zone et chaque thread actif: init val to zero
10+
E_Int* verrou_lhs_thread = verrou_lhs + ntask*Nbre_thread_actif + ithread_loc -1;
11+
verrou_c_( verrou_lhs_thread, type);
12+
13+
//Reinitialisation verrou omp pour calcul residu avant lhs
14+
verrou_lhs_thread = verrou_lhs + (nbtask + ntask)*Nbre_thread_actif + ithread_loc -1;
15+
verrou_c_( verrou_lhs_thread, type );
16+
}

0 commit comments

Comments
 (0)