[yt-svn] commit/yt: MatthewTurk: Moving num_threads into a config option.
Bitbucket
commits-noreply at bitbucket.org
Tue Jul 3 12:14:47 PDT 2012
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/changeset/90869269c7ff/
changeset: 90869269c7ff
branch: yt
user: MatthewTurk
date: 2012-07-03 20:29:00
summary: Moving num_threads into a config option.
affected #: 3 files
diff -r 6290d758f7490d79d1531e64ed346f37deb5f70a -r 90869269c7ff63182c0c7fbb9137b3ee43198bd9 yt/config.py
--- a/yt/config.py
+++ b/yt/config.py
@@ -36,6 +36,7 @@
suppressstreamlogging = 'False',
loglevel = '20',
inline = 'False',
+ numthreads = '-1',
__withinreason = 'False',
__parallel = 'False',
__global_parallel_rank = '0',
diff -r 6290d758f7490d79d1531e64ed346f37deb5f70a -r 90869269c7ff63182c0c7fbb9137b3ee43198bd9 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -553,3 +553,12 @@
yield fn
p.disable()
p.dump_stats(fn)
+
+def get_num_threads():
+ from .config import ytcfg
+ nt = ytcfg.getint("yt","numthreads")
+ if nt < 0:
+ return os.environ.get("OMP_NUM_THREADS", 0)
+ return nt
+
+
diff -r 6290d758f7490d79d1531e64ed346f37deb5f70a -r 90869269c7ff63182c0c7fbb9137b3ee43198bd9 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -349,7 +349,7 @@
return self.volume.initialize_source()
def snapshot(self, fn = None, clip_ratio = None, double_check = False,
- num_threads = 0):
+ num_threads = None):
r"""Ray-cast the camera.
This method instructs the camera to take a snapshot -- i.e., call the ray
@@ -376,6 +376,8 @@
image : array
An (N,M,3) array of the final returned values, in float64 form.
"""
+ if num_threads is None:
+ num_threads=get_num_threads()
image = self.new_image()
args = self.get_sampler_args(image)
@@ -753,7 +755,7 @@
return image
def snapshot(self, fn = None, clip_ratio = None, double_check = False,
- num_threads = 0, clim = None):
+ num_threads = None, clim = None):
r"""Ray-cast the camera.
This method instructs the camera to take a snapshot -- i.e., call the ray
@@ -773,6 +775,8 @@
image : array
An (N,M,3) array of the final returned values, in float64 form.
"""
+ if num_threads is None:
+ num_threads=get_num_threads()
image = self.new_image()
args = self.get_sampler_args(image)
@@ -1610,7 +1614,10 @@
write_image(im, fn)
def snapshot(self, fn = None, clip_ratio = None, double_check = False,
- num_threads = 0):
+ num_threads = None):
+
+ if num_threads is None:
+ num_threads=get_num_threads()
fields = [self.field]
resolution = self.resolution
@@ -1633,7 +1640,7 @@
data_object_registry["projection_camera"] = ProjectionCamera
def off_axis_projection(pf, center, normal_vector, width, resolution,
- field, weight = None, num_threads = 0,
+ field, weight = None,
volume = None, no_ghost = False, interpolated = False):
r"""Project through a parameter file, off-axis, and return the image plane.
@@ -1695,7 +1702,7 @@
projcam = ProjectionCamera(center, normal_vector, width, resolution,
field, weight=weight, pf=pf, volume=volume,
no_ghost=no_ghost, interpolated=interpolated)
- image = projcam.snapshot(num_threads=num_threads)
+ image = projcam.snapshot()
if weight is not None:
pf.field_info.pop("temp_weightfield")
del projcam
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list