[Yt-svn] yt-commit r1360 - in trunk/yt: extensions lagos
skillman at wrangler.dreamhost.com
skillman at wrangler.dreamhost.com
Fri Jul 3 14:45:14 PDT 2009
Author: skillman
Date: Fri Jul 3 14:45:13 2009
New Revision: 1360
URL: http://yt.spacepope.org/changeset/1360
Log:
Fixed bug in parallel halo profiling/projecting that caused
mpi-barrier to hang on last halo. This required the addition of a
hierarchy function "_reset_save_data(round_robin=False(default)/True)"
that upon calling will reset the save_data function. This function is
now called from the makeProjection routine in the HaloProfiler. If
someone has a more elegant fix to this, suggestions are welcome.
--SWS 7/3/09
Modified:
trunk/yt/extensions/HaloProfiler.py
trunk/yt/lagos/HierarchyType.py
Modified: trunk/yt/extensions/HaloProfiler.py
==============================================================================
--- trunk/yt/extensions/HaloProfiler.py (original)
+++ trunk/yt/extensions/HaloProfiler.py Fri Jul 3 14:45:13 2009
@@ -96,6 +96,9 @@
def makeProfiles(self):
"Make radial profiles for all halos on the list."
+ def _finalize_parallel(self):
+ self.virialQuantities = self._mpi_catlist(self.virialQuantities)
+ self.virialQuantities.sort(key = lambda a:a['id'])
# Get halo(s).
if self.halos is 'single':
@@ -120,20 +123,20 @@
for q,halo in enumerate(self._get_objs('hopHalos', round_robin=True)):
filename = "%s/Halo_%04d_profile.dat" % (outputDir,halo['id'])
-
+
# Read profile from file if it already exists.
# If not, profile will be None.
profile = self._ReadProfile(filename)
-
+
# Make profile if necessary.
newProfile = profile is None
if profile is None:
-
+
r_min = 2*self.pf.h.get_smallest_dx() * self.pf['mpc']
if (halo['r_max'] / r_min < PROFILE_RADIUS_THRESHOLD):
mylog.error("Skipping halo with r_max / r_min = %f." % (halo['r_max']/r_min))
continue
-
+
sphere = self.pf.h.sphere(halo['center'],halo['r_max']/self.pf.units['mpc'])
if len(sphere._grids) == 0: continue
@@ -150,7 +153,7 @@
sphere.set_field_parameter('bulk_velocity',[max_grid['x-velocity'][max_cell],
max_grid['y-velocity'][max_cell],
max_grid['z-velocity'][max_cell]])
-
+
profile = lagos.BinnedProfile1D(sphere,self.haloProfilerParameters['n_bins'],"RadiusMpc",
r_min,halo['r_max'],
log_space=True, lazy_reader=False)
@@ -163,7 +166,7 @@
virial = self._CalculateVirialQuantities(profile)
virial['center'] = halo['center']
virial['id'] = halo['id']
-
+
if (virial['TotalMassMsun'] >= self.haloProfilerParameters['VirialMassCutoff']):
self.virialQuantities.append(virial)
if newProfile:
@@ -180,10 +183,6 @@
self._WriteVirialQuantities()
- def _finalize_parallel(self):
- self.virialQuantities = self._mpi_catlist(self.virialQuantities)
- self.virialQuantities.sort(key = lambda a:a['id'])
-
@lagos.parallel_root_only
def __check_directory(self, outputDir):
if (os.path.exists(outputDir)):
@@ -195,8 +194,8 @@
def makeProjections(self,save_images=True,save_cube=True,**kwargs):
"Make projections of all halos using specified fields."
-
# Get virial quantities.
+ self.pf.hierarchy._reset_save_data(round_robin=True)
self._LoadVirialData()
# Set resolution for fixed resolution output.
@@ -253,7 +252,7 @@
for field in self.projectionFields.keys():
pc.add_projection(field,w,weight_field=self.projectionFields[field],source=region,lazy_reader=False,**kwargs)
-
+
# Set x and y limits, shift image if it overlaps domain boundary.
if need_per:
pw = self.haloProfilerParameters['ProjectionWidth']/self.pf.units['mpc']
@@ -288,9 +287,7 @@
pc.save("%s/Halo_%04d" % (outputDir,halo['id']))
pc.clear_plots()
-
del region
-
del pc
@lagos.parallel_root_only
Modified: trunk/yt/lagos/HierarchyType.py
==============================================================================
--- trunk/yt/lagos/HierarchyType.py (original)
+++ trunk/yt/lagos/HierarchyType.py Fri Jul 3 14:45:13 2009
@@ -180,6 +180,12 @@
del self._data_file
self._data_file = h5py.File(self.__data_filename, self._data_mode)
+ def _reset_save_data(self,round_robin=False):
+ if round_robin:
+ self.save_data = self._save_data
+ else:
+ self.save_data = parallel_splitter(self._save_data, self._reload_data_file)
+
save_data = parallel_splitter(_save_data, _reload_data_file)
def save_object(self, obj, name):
More information about the yt-svn
mailing list