Skip to content

Commit

Permalink
Merge pull request #266 from BconstantMMK/dev
Browse files Browse the repository at this point in the history
Converter: fix deadlock when reading from file in parallel
  • Loading branch information
vincentcasseau authored Jan 29, 2025
2 parents 6d95b6d + dee7327 commit 5bc0297
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Cassiopee/Converter/Converter/Mpi4py.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from mpi4py import MPI
import numpy
import os

COMM_WORLD = MPI.COMM_WORLD
KCOMM = COMM_WORLD
Expand Down Expand Up @@ -441,6 +442,9 @@ def gatherZones(zones, root=0):
def convertFile2SkeletonTree(fileName, format=None, maxFloatSize=5,
maxDepth=-1, links=None):
"""Read a file and return a skeleton tree."""
exists = os.path.exists(fileName)
if not exists: raise IOError("convertFile2SkeletonTree: file %s not found."%fileName)

if rank == 0: t = Distributed.convertFile2SkeletonTree(fileName, format, maxFloatSize, maxDepth, None, links)
else: t = None
t = KCOMM.bcast(t)
Expand All @@ -456,6 +460,9 @@ def convertFile2SkeletonTree(fileName, format=None, maxFloatSize=5,
#==============================================================================
def convertFile2PyTree(fileName, format=None, proc=None):
"""Read a file and return a full tree or partial tree."""
exists = os.path.exists(fileName)
if not exists: raise IOError("convertFile2PyTree: file %s not found."%fileName)

if proc is None: # load full tree on all procs
if rank == 0: t = C.convertFile2PyTree(fileName, format)
else: t = None
Expand Down

0 comments on commit 5bc0297

Please sign in to comment.