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

Parallelized move_variables in parsed_text

Version:1.1.49
This commit is contained in:
Anthony Scemama 2010-10-02 19:58:19 +02:00
parent 772327fe56
commit 86f281f5ab
4 changed files with 21 additions and 19 deletions

View File

@ -243,8 +243,7 @@ parsed_text = result
######################################################################
def move_variables():
main_result = []
for filename, text in parsed_text:
def func(filename, text):
result = []
# 1st pass
varlist = []
@ -328,9 +327,9 @@ def move_variables():
assert old_varlist == []
varlist = []
result.append( (vars,line) )
return result
main_result.append( (filename, result) )
return main_result
return parallel_loop(func,parsed_text)
parsed_text = move_variables()
######################################################################

View File

@ -548,7 +548,7 @@ def irp_simple_statements(text):
i = line.i
f = line.filename
result = [ Begin_provider(i,line.text, (f,varname)),
Declaration(i," character*(%d) :: irp_here = '%s'"%(length,varname), line.filename) ]
Declaration(i," character*(%d) :: irp_here = '%s'"%(length,varname), f) ]
if command_line.do_assert or command_line.do_debug:
result += [
Simple_line(i," call irp_enter(irp_here)", f),
@ -829,7 +829,8 @@ def create_preprocessed_text(filename):
return result
######################################################################
preprocessed_text = parallel_loop( create_preprocessed_text, irpf90_files )
preprocessed_text = parallel_loop( lambda x,y: create_preprocessed_text(x), \
map(lambda x: (x,None), irpf90_files ) )
######################################################################
def debug():

View File

@ -128,10 +128,10 @@ def put_info(text,filename):
import cPickle as pickle
import os, sys
def fork_and_pickle(f,filename):
def fork_and_pickle(f,filename,text):
fork = os.fork()
if fork == 0:
result = f(filename)
result = f(filename,text)
file = open('%s.pickle'%filename,'w')
pickle.dump(result,file,-1)
file.close()
@ -139,22 +139,24 @@ def fork_and_pickle(f,filename):
else:
return fork
def parallel_loop(f,files):
def parallel_loop(f,source):
pidlist = {}
for filename in files:
pidlist[filename] = fork_and_pickle( f, filename )
for filename, text in source:
pidlist[filename] = fork_and_pickle( f, filename, text )
result = []
for filename in files:
os.waitpid(pidlist[filename],0)
file = open('%s.pickle'%filename,'r')
data = pickle.load(file)
file.close()
os.remove('%s.pickle'%filename)
result.append( (filename, data) )
for filename,text in source:
os.waitpid(pidlist[filename],0)
file = open('%s.pickle'%filename,'r')
data = pickle.load(file)
file.close()
os.remove('%s.pickle'%filename)
result.append( (filename, data) )
return result
if __name__ == '__main__':
print "10",dimsize("10") #-> "10"
print "0:10",dimsize("0:10") # -> "11"

View File

@ -1 +1 @@
version = "1.1.48"
version = "1.1.49"