Skip to content

Commit

Permalink
shzeros return shared memory array only if nprocs>1
Browse files Browse the repository at this point in the history
  • Loading branch information
Gertjan van Zwieten committed Oct 24, 2016
1 parent 15c2145 commit e6f7e4b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nutils/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,11 @@ def shzeros( shape, dtype=float ):
dtype = numpy.int8
else:
raise Exception( 'invalid dtype: %r' % dtype )
buf = multiprocessing.RawArray( typecode, int(size) )
return numpy.frombuffer( buf, dtype ).reshape( shape )
if core.getprop( 'nprocs', 1 ) == 1:
return numpy.zeros( shape=shape, dtype=dtype )
else:
buf = multiprocessing.RawArray( typecode, int(size) )
return numpy.frombuffer( buf, dtype ).reshape( shape )

def pariter( iterable ):
'iterate parallel'
Expand Down

0 comments on commit e6f7e4b

Please sign in to comment.