10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-12-21 11:53:32 +01:00

Parallel bug corrected

Version:1.1.54
This commit is contained in:
Anthony Scemama 2010-10-02 23:04:30 +02:00
parent 5a69a56036
commit 06ba51a253
4 changed files with 50 additions and 26 deletions

View File

@ -89,6 +89,36 @@ def check_touch(line,vars,main_vars):
message = "\n".join([message]+map(lambda x: "- %s"%(x,),all_others)) message = "\n".join([message]+map(lambda x: "- %s"%(x,),all_others))
error.fail(line,message) error.fail(line,message)
################################################################################
def update_variables():
for filename,text in preprocessed_text:
for line in filter(lambda x: type(x) in [ Touch, SoftTouch ], text):
vars = line.text_lower.split()
if len(vars) < 2:
error.fail(line,"Syntax error")
for v in vars[1:]:
if v not in variables:
error.fail(line,"Variable %s unknown"%(v,))
variables[v]._is_touched = True
for line in filter(lambda x: isinstance(x,Free),text):
vars = line.text_lower.split()
if len(vars) < 2:
error.fail(line,"Syntax error")
for v in vars[1:]:
if v not in variables:
error.fail(line,"Variable %s unknown"%(v,))
variables[v].is_freed = True
for line in filter(lambda x: isinstance(x,Irp_read),text):
variables[line.filename]._is_read = True
for line in filter(lambda x: isinstance(x,Irp_write),text):
variables[line.filename]._is_written = True
################################################################################
def get_parsed_text(): def get_parsed_text():
def func(filename, text): def func(filename, text):
varlist = [] varlist = []
@ -138,11 +168,7 @@ def get_parsed_text():
append( ([],Provide_all(line.i,"",line.filename)) ) append( ([],Provide_all(line.i,"",line.filename)) )
elif isinstance(line,Free): elif isinstance(line,Free):
vars = line.text_lower.split() vars = line.text_lower.split()
if len(vars) < 2:
error.fail(line,"Syntax error")
vars = vars[1:] vars = vars[1:]
for v in vars:
variables[v].is_freed = True
append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) ) append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
use = map(lambda x: " use %s"%(variables[x].fmodule),vars) use = map(lambda x: " use %s"%(variables[x].fmodule),vars)
for var in vars: for var in vars:
@ -151,28 +177,22 @@ def get_parsed_text():
result += map(lambda x: ([],Simple_line(line.i,x,line.filename)), result += map(lambda x: ([],Simple_line(line.i,x,line.filename)),
variables[var].free) variables[var].free)
elif isinstance(line,Irp_read): elif isinstance(line,Irp_read):
variables[line.filename]._is_read = True
append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) ) append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
elif isinstance(line,Irp_write): elif isinstance(line,Irp_write):
variables[line.filename]._is_written = True
append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) ) append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
elif isinstance(line,Touch): elif isinstance(line,Touch):
vars = line.text_lower.split() vars = line.text_lower.split()
if len(vars) < 2: if len(vars) < 2:
error.fail(line,"Syntax error") error.fail(line,"Syntax error")
vars = vars[1:] vars = vars[1:]
for v in vars:
if v not in variables:
error.fail(line,"Variable %s unknown"%(v,))
variables[v]._is_touched = True
def fun(x): def fun(x):
main = variables[x].same_as main = variables[x].same_as
return main return main
main_vars = make_single( map(fun, vars) ) main_vars = make_single( map(fun, vars) )
check_touch(line,vars,main_vars) check_touch(line,vars,main_vars)
txt = " ".join(vars) txt = " ".join(vars)
result += [ (vars,Simple_line(line.i,"!",line.filename)), append ( (vars,Simple_line(line.i,"!",line.filename)) )
([],Simple_line(line.i,"! >>> TOUCH %s"%(txt,),line.filename)) ] append ( ([],Simple_line(line.i,"! >>> TOUCH %s"%(txt,),line.filename)) )
def fun(x): def fun(x):
if x not in variables: if x not in variables:
error.fail(line,"Variable %s unknown"%(x,)) error.fail(line,"Variable %s unknown"%(x,))
@ -185,9 +205,9 @@ def get_parsed_text():
return ([],Simple_line(line.i," %s_is_built = .True."%(x,),line.filename)) return ([],Simple_line(line.i," %s_is_built = .True."%(x,),line.filename))
result += map( fun, main_vars[:-1] ) result += map( fun, main_vars[:-1] )
if isinstance(line,SoftTouch): if isinstance(line,SoftTouch):
result += [ ([],Simple_line(line.i,"! <<< END TOUCH (Soft)",line.filename)) ] append ( ([],Simple_line(line.i,"! <<< END TOUCH (Soft)",line.filename)) )
else: else:
result += [ ([],Provide_all(line.i,"! <<< END TOUCH",line.filename)) ] append ( ([],Provide_all(line.i,"! <<< END TOUCH",line.filename)) )
elif type(line) in [ Begin_provider, Cont_provider ]: elif type(line) in [ Begin_provider, Cont_provider ]:
if isinstance(line,Begin_provider): if isinstance(line,Begin_provider):
varlist = [] varlist = []
@ -205,19 +225,19 @@ def get_parsed_text():
else: else:
l = find_variables_in_line(line) l = find_variables_in_line(line)
l = filter(lambda x: x not in varlist, l) l = filter(lambda x: x not in varlist, l)
result.append( (l,line) ) append( (l,line) )
return result return result
#main_result = [] main_result = []
#for filename,text in preprocessed_text: for filename,text in preprocessed_text:
# main_result.append( (filename, func(filename,text)) ) main_result.append( (filename, func(filename,text)) )
#return main_result return main_result
return parallel_loop(func,preprocessed_text) #return parallel_loop(func,preprocessed_text)
update_variables()
parsed_text = get_parsed_text() parsed_text = get_parsed_text()
###################################################################### ######################################################################
def move_to_top(text,t): def move_to_top(text,t):

View File

@ -830,7 +830,7 @@ def create_preprocessed_text(filename):
###################################################################### ######################################################################
preprocessed_text = parallel_loop( lambda x,y: create_preprocessed_text(x), \ preprocessed_text = parallel_loop( lambda x,y: create_preprocessed_text(x), \
map(lambda x: (x,None), irpf90_files ) ) map(lambda x: (x,None), irpf90_files ) )
###################################################################### ######################################################################
def debug(): def debug():

View File

@ -24,7 +24,8 @@
# 31062 Toulouse Cedex 4 # 31062 Toulouse Cedex 4
# scemama@irsamc.ups-tlse.fr # scemama@irsamc.ups-tlse.fr
NTHREADS=16 import os
NTHREADS=int(os.getenv('OMP_NUM_THREADS',4))
def strip(x): def strip(x):
return x.strip() return x.strip()
@ -135,11 +136,13 @@ def parallel_loop(f,source):
src = [ [] for i in xrange(NTHREADS) ] src = [ [] for i in xrange(NTHREADS) ]
index = 0 index = 0
for i in source: for i in source:
index = index+1 index += 1
if index == NTHREADS: if index == NTHREADS:
index = 0 index = 0
src[index].append(i) src[index].append(i)
thread_id = 0
fork = 1
for thread_id in xrange(1,NTHREADS): for thread_id in xrange(1,NTHREADS):
fork = os.fork() fork = os.fork()
if fork == 0: if fork == 0:
@ -158,7 +161,8 @@ def parallel_loop(f,source):
sys.exit(0) sys.exit(0)
for i in xrange(1,NTHREADS): for i in xrange(1,NTHREADS):
os.waitpid(pidlist[i],0) if os.waitpid(pidlist[i],0)[1] != 0:
sys.exit(0)
result = [] result = []
for filename,text in source: for filename,text in source:

View File

@ -1 +1 @@
version = "1.1.53" version = "1.1.54"