mirror of
https://gitlab.com/scemama/irpf90.git
synced 2024-11-09 07:33:43 +01:00
Parallelized move_variables in parsed_text
Version:1.1.49
This commit is contained in:
parent
772327fe56
commit
86f281f5ab
@ -243,8 +243,7 @@ parsed_text = result
|
|||||||
######################################################################
|
######################################################################
|
||||||
def move_variables():
|
def move_variables():
|
||||||
|
|
||||||
main_result = []
|
def func(filename, text):
|
||||||
for filename, text in parsed_text:
|
|
||||||
result = []
|
result = []
|
||||||
# 1st pass
|
# 1st pass
|
||||||
varlist = []
|
varlist = []
|
||||||
@ -328,9 +327,9 @@ def move_variables():
|
|||||||
assert old_varlist == []
|
assert old_varlist == []
|
||||||
varlist = []
|
varlist = []
|
||||||
result.append( (vars,line) )
|
result.append( (vars,line) )
|
||||||
|
return result
|
||||||
|
|
||||||
main_result.append( (filename, result) )
|
return parallel_loop(func,parsed_text)
|
||||||
return main_result
|
|
||||||
|
|
||||||
parsed_text = move_variables()
|
parsed_text = move_variables()
|
||||||
######################################################################
|
######################################################################
|
||||||
|
@ -548,7 +548,7 @@ def irp_simple_statements(text):
|
|||||||
i = line.i
|
i = line.i
|
||||||
f = line.filename
|
f = line.filename
|
||||||
result = [ Begin_provider(i,line.text, (f,varname)),
|
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:
|
if command_line.do_assert or command_line.do_debug:
|
||||||
result += [
|
result += [
|
||||||
Simple_line(i," call irp_enter(irp_here)", f),
|
Simple_line(i," call irp_enter(irp_here)", f),
|
||||||
@ -829,7 +829,8 @@ def create_preprocessed_text(filename):
|
|||||||
return result
|
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():
|
def debug():
|
||||||
|
26
src/util.py
26
src/util.py
@ -128,10 +128,10 @@ def put_info(text,filename):
|
|||||||
|
|
||||||
import cPickle as pickle
|
import cPickle as pickle
|
||||||
import os, sys
|
import os, sys
|
||||||
def fork_and_pickle(f,filename):
|
def fork_and_pickle(f,filename,text):
|
||||||
fork = os.fork()
|
fork = os.fork()
|
||||||
if fork == 0:
|
if fork == 0:
|
||||||
result = f(filename)
|
result = f(filename,text)
|
||||||
file = open('%s.pickle'%filename,'w')
|
file = open('%s.pickle'%filename,'w')
|
||||||
pickle.dump(result,file,-1)
|
pickle.dump(result,file,-1)
|
||||||
file.close()
|
file.close()
|
||||||
@ -139,22 +139,24 @@ def fork_and_pickle(f,filename):
|
|||||||
else:
|
else:
|
||||||
return fork
|
return fork
|
||||||
|
|
||||||
def parallel_loop(f,files):
|
def parallel_loop(f,source):
|
||||||
pidlist = {}
|
pidlist = {}
|
||||||
for filename in files:
|
for filename, text in source:
|
||||||
pidlist[filename] = fork_and_pickle( f, filename )
|
pidlist[filename] = fork_and_pickle( f, filename, text )
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
for filename in files:
|
for filename,text in source:
|
||||||
os.waitpid(pidlist[filename],0)
|
os.waitpid(pidlist[filename],0)
|
||||||
file = open('%s.pickle'%filename,'r')
|
file = open('%s.pickle'%filename,'r')
|
||||||
data = pickle.load(file)
|
data = pickle.load(file)
|
||||||
file.close()
|
file.close()
|
||||||
os.remove('%s.pickle'%filename)
|
os.remove('%s.pickle'%filename)
|
||||||
result.append( (filename, data) )
|
result.append( (filename, data) )
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print "10",dimsize("10") #-> "10"
|
print "10",dimsize("10") #-> "10"
|
||||||
print "0:10",dimsize("0:10") # -> "11"
|
print "0:10",dimsize("0:10") # -> "11"
|
||||||
|
@ -1 +1 @@
|
|||||||
version = "1.1.48"
|
version = "1.1.49"
|
||||||
|
Loading…
Reference in New Issue
Block a user