mirror of
https://gitlab.com/scemama/irpf90.git
synced 2024-09-02 01:33:42 +02:00
Improved parallelization
Version:1.1.53
This commit is contained in:
parent
0da7952476
commit
5a69a56036
13
src/util.py
13
src/util.py
@ -24,7 +24,7 @@
|
||||
# 31062 Toulouse Cedex 4
|
||||
# scemama@irsamc.ups-tlse.fr
|
||||
|
||||
NTHREADS=3
|
||||
NTHREADS=16
|
||||
|
||||
def strip(x):
|
||||
return x.strip()
|
||||
@ -130,7 +130,7 @@ def put_info(text,filename):
|
||||
import cPickle as pickle
|
||||
import os, sys
|
||||
def parallel_loop(f,source):
|
||||
pidlist = {}
|
||||
pidlist = range(NTHREADS)
|
||||
|
||||
src = [ [] for i in xrange(NTHREADS) ]
|
||||
index = 0
|
||||
@ -145,20 +145,19 @@ def parallel_loop(f,source):
|
||||
if fork == 0:
|
||||
break
|
||||
else:
|
||||
import time
|
||||
time.sleep(1)
|
||||
pidlist[i] = fork
|
||||
pidlist[thread_id] = fork
|
||||
thread_id = 0
|
||||
|
||||
print "fork : ", fork, thread_id
|
||||
for filename, text in src[thread_id]:
|
||||
result = f(filename,text)
|
||||
file = open('%s.pickle'%filename,'w')
|
||||
pickle.dump(result,file,-1)
|
||||
file.close()
|
||||
|
||||
if fork == 0:
|
||||
sys.exit(0)
|
||||
|
||||
for i in xrange(NTHREADS):
|
||||
for i in xrange(1,NTHREADS):
|
||||
os.waitpid(pidlist[i],0)
|
||||
|
||||
result = []
|
||||
|
@ -1 +1 @@
|
||||
version = "1.1.52"
|
||||
version = "1.1.53"
|
||||
|
Loading…
Reference in New Issue
Block a user