10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-12-22 04:13:33 +01:00

Improved parallelization

Version:1.1.53
This commit is contained in:
Anthony Scemama 2010-10-02 21:46:32 +02:00
parent 0da7952476
commit 5a69a56036
2 changed files with 7 additions and 8 deletions

View File

@ -24,7 +24,7 @@
# 31062 Toulouse Cedex 4 # 31062 Toulouse Cedex 4
# scemama@irsamc.ups-tlse.fr # scemama@irsamc.ups-tlse.fr
NTHREADS=3 NTHREADS=16
def strip(x): def strip(x):
return x.strip() return x.strip()
@ -130,7 +130,7 @@ def put_info(text,filename):
import cPickle as pickle import cPickle as pickle
import os, sys import os, sys
def parallel_loop(f,source): def parallel_loop(f,source):
pidlist = {} pidlist = range(NTHREADS)
src = [ [] for i in xrange(NTHREADS) ] src = [ [] for i in xrange(NTHREADS) ]
index = 0 index = 0
@ -145,20 +145,19 @@ def parallel_loop(f,source):
if fork == 0: if fork == 0:
break break
else: else:
import time pidlist[thread_id] = fork
time.sleep(1)
pidlist[i] = fork
thread_id = 0 thread_id = 0
print "fork : ", fork, thread_id
for filename, text in src[thread_id]: for filename, text in src[thread_id]:
result = f(filename,text) 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()
if fork == 0:
sys.exit(0) sys.exit(0)
for i in xrange(NTHREADS): for i in xrange(1,NTHREADS):
os.waitpid(pidlist[i],0) os.waitpid(pidlist[i],0)
result = [] result = []

View File

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