Author: hjz
Date: 2010-09-21 03:32:03 -0400 (Tue, 21 Sep 2010)
New Revision: 3351
Modified:
trunk/osprey/libopenmp/omp_lock.c
trunk/osprey/wgen/wgen_decl.cxx
trunk/osprey/wgen/wgen_omp_directives.cxx
trunk/osprey/wgen/wgen_omp_directives.h
Log:
Fix the data race bug of __ompc_critical() in osprey/libopenmp/omp_lock.c.
Approved by: Tianwei
BTW, revert a minor portion of my previous checkin (rev 3345). Some code in
that checkin is to fix the bug of local variable defined inside OpenMP
paralllel region, but I find that bug has been already fixed in rev 3211 in
open64-booster branch, and that change has been merged into trunk in rev 3314.
Modified: trunk/osprey/libopenmp/omp_lock.c
===================================================================
--- trunk/osprey/libopenmp/omp_lock.c 2010-09-21 06:58:23 UTC (rev 3350)
+++ trunk/osprey/libopenmp/omp_lock.c 2010-09-21 07:32:03 UTC (rev 3351)
@@ -197,10 +197,11 @@
__ompc_lock_spinlock(&_ompc_thread_lock);
if ((ompc_lock_t*)*lck == NULL){
// put the shared data aligned with cache line
- *lck = aligned_malloc(sizeof(ompc_lock_t), CACHE_LINE_SIZE);
- Is_True(*lck!=NULL,
+ volatile ompc_lock_t* new_lock = aligned_malloc(sizeof(ompc_lock_t),
CACHE_LINE_SIZE);
+ Is_True(new_lock!=NULL,
("Cannot allocate lock memory for critical"));
- __ompc_init_lock (*lck);
+ __ompc_init_lock (new_lock);
+ *lck = new_lock;
}
__ompc_unlock_spinlock(&_ompc_thread_lock);
}
Modified: trunk/osprey/wgen/wgen_decl.cxx
===================================================================
--- trunk/osprey/wgen/wgen_decl.cxx 2010-09-21 06:58:23 UTC (rev 3350)
+++ trunk/osprey/wgen/wgen_decl.cxx 2010-09-21 07:32:03 UTC (rev 3351)
@@ -708,7 +708,6 @@
Init_Deferred_Function_Stack();
}
*/
- ST *var_st;
switch (gs_tree_code(decl)) {
case GS_CONST_DECL:
@@ -887,9 +886,7 @@
expanded_decl(decl) = TRUE;
#endif
- var_st = Get_ST(decl);
- if (!gs_tree_static(decl) && !gs_decl_external(decl))
- WGEN_register_local_variable(var_st);
+ (void) Get_ST(decl);
if (gs_decl_initial(decl) && !gs_decl_external(decl)) {
gs_t init = gs_decl_initial(decl);
gs_code_t code = gs_tree_code(init);
Modified: trunk/osprey/wgen/wgen_omp_directives.cxx
===================================================================
--- trunk/osprey/wgen/wgen_omp_directives.cxx 2010-09-21 06:58:23 UTC (rev
3350)
+++ trunk/osprey/wgen/wgen_omp_directives.cxx 2010-09-21 07:32:03 UTC (rev
3351)
@@ -87,8 +87,6 @@
// vector for storing DO-loop side-effects, to be emitted before the loop.
std::vector<WN *> doloop_side_effects;
-static std::stack<WN *> omp_construct_stack;
-
BOOL Trace_Omp = FALSE;
// Put in per-file OpenMP specific initializations here.
@@ -842,7 +840,6 @@
/* create a region on current block */
WN * region = WGEN_region(REGION_KIND_MP);
- omp_construct_stack.push(region);
WN *wn;
@@ -895,7 +892,6 @@
WGEN_maybe_do_eh_cleanups ();
}
- omp_construct_stack.pop();
WGEN_Stmt_Pop (wgen_stmk_scope);
WGEN_CS_pop (wgen_omp_parallel);
};
@@ -1259,7 +1255,6 @@
/* create a region on current block */
WN * region = WGEN_region(REGION_KIND_MP);
- omp_construct_stack.push(region);
WN *wn;
@@ -1303,7 +1298,6 @@
{
WN *wn = WGEN_Stmt_Top ();
//WGEN_check_parallel_for (wn);
- omp_construct_stack.pop();
WGEN_Stmt_Pop (wgen_stmk_scope);
WGEN_CS_pop(wgen_omp_parallel_for);
}
@@ -1318,7 +1312,6 @@
/* create a region on current block */
WN * region = WGEN_region(REGION_KIND_MP);
- omp_construct_stack.push(region);
WN *wn;
@@ -1364,7 +1357,6 @@
{
WN *wn = WGEN_Stmt_Top ();
// WGEN_check_parallel_sections (wn);
- omp_construct_stack.pop();
WGEN_Stmt_Pop (wgen_stmk_scope);
WGEN_CS_pop(wgen_omp_parallel_sections);
@@ -1827,13 +1819,3 @@
WGEN_Stmt_Pop (wgen_stmk_for_cond);
}
-void WGEN_register_local_variable(ST * st)
-{
- if (omp_construct_stack.empty())
- return;
- WN * last_region = omp_construct_stack.top();
- WN * pragmas = WN_region_pragmas(last_region);
- WN * private_pragma = WN_CreatePragma(WN_PRAGMA_LOCAL, st, 0, 0);
- WN_set_pragma_omp(private_pragma);
- WN_INSERT_BlockLast(pragmas, private_pragma);
-}
Modified: trunk/osprey/wgen/wgen_omp_directives.h
===================================================================
--- trunk/osprey/wgen/wgen_omp_directives.h 2010-09-21 06:58:23 UTC (rev
3350)
+++ trunk/osprey/wgen/wgen_omp_directives.h 2010-09-21 07:32:03 UTC (rev
3351)
@@ -99,8 +99,6 @@
extern void WGEN_expand_end_do_loop (void);
-extern void WGEN_register_local_variable(ST * st);
-
extern BOOL Trace_Omp;
#endif
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Open64-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/open64-devel