[Yt-svn] yt: Switching the order of bin_id creation and field table integ...

hg at spacepope.org hg at spacepope.org
Mon Jul 19 22:36:18 PDT 2010


hg Repository: yt
details:   yt/rev/5bfed664cf16
changeset: 1879:5bfed664cf16
user:      Matthew Turk <matthewturk at gmail.com>
date:
Mon Jul 19 22:36:08 2010 -0700
description:
Switching the order of bin_id creation and field table integration early
termination for tiny speedup

diffstat:

 yt/_amr_utils/VolumeIntegrator.pyx |   2 +-
 yt/amr_utils.c                     |  58 ++++++++++++++--------------
 2 files changed, 30 insertions(+), 30 deletions(-)

diffs (114 lines):

diff -r 8c4c5f4ea326 -r 5bfed664cf16 yt/_amr_utils/VolumeIntegrator.pyx
--- a/yt/_amr_utils/VolumeIntegrator.pyx	Wed Jul 07 21:15:54 2010 -0700
+++ b/yt/_amr_utils/VolumeIntegrator.pyx	Mon Jul 19 22:36:08 2010 -0700
@@ -106,9 +106,9 @@
     cdef np.float64_t bv, dy, dd, tf
     cdef int bin_id
     if fit.pass_through == 1: return dvs[fit.field_id]
+    if dvs[fit.field_id] > fit.bounds[1] or dvs[fit.field_id] < fit.bounds[0]: return 0.0
     bin_id = <int> ((dvs[fit.field_id] - fit.bounds[0]) * fit.idbin)
     dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0
-    if bin_id > fit.nbins - 2 or bin_id < 0: return 0.0
     bv = fit.values[bin_id]
     dy = fit.values[bin_id + 1] - bv
     if fit.weight_field_id != -1:
diff -r 8c4c5f4ea326 -r 5bfed664cf16 yt/amr_utils.c
--- a/yt/amr_utils.c	Wed Jul 07 21:15:54 2010 -0700
+++ b/yt/amr_utils.c	Mon Jul 19 22:36:08 2010 -0700
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.12.1 on Thu Jun 24 08:40:25 2010 */
+/* Generated by Cython 0.12.1 on Mon Jul 19 22:35:35 2010 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
@@ -12939,8 +12939,8 @@
  *     cdef np.float64_t bv, dy, dd, tf
  *     cdef int bin_id
  *     if fit.pass_through == 1: return dvs[fit.field_id]             # <<<<<<<<<<<<<<
+ *     if dvs[fit.field_id] > fit.bounds[1] or dvs[fit.field_id] < fit.bounds[0]: return 0.0
  *     bin_id = <int> ((dvs[fit.field_id] - fit.bounds[0]) * fit.idbin)
- *     dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0
  */
   __pyx_t_1 = (__pyx_v_fit->pass_through == 1);
   if (__pyx_t_1) {
@@ -12953,45 +12953,45 @@
   /* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":109
  *     cdef int bin_id
  *     if fit.pass_through == 1: return dvs[fit.field_id]
+ *     if dvs[fit.field_id] > fit.bounds[1] or dvs[fit.field_id] < fit.bounds[0]: return 0.0             # <<<<<<<<<<<<<<
+ *     bin_id = <int> ((dvs[fit.field_id] - fit.bounds[0]) * fit.idbin)
+ *     dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0
+ */
+  __pyx_t_1 = ((__pyx_v_dvs[__pyx_v_fit->field_id]) > (__pyx_v_fit->bounds[1]));
+  if (!__pyx_t_1) {
+    __pyx_t_2 = ((__pyx_v_dvs[__pyx_v_fit->field_id]) < (__pyx_v_fit->bounds[0]));
+    __pyx_t_3 = __pyx_t_2;
+  } else {
+    __pyx_t_3 = __pyx_t_1;
+  }
+  if (__pyx_t_3) {
+    __pyx_r = 0.0;
+    goto __pyx_L0;
+    goto __pyx_L4;
+  }
+  __pyx_L4:;
+
+  /* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":110
+ *     if fit.pass_through == 1: return dvs[fit.field_id]
+ *     if dvs[fit.field_id] > fit.bounds[1] or dvs[fit.field_id] < fit.bounds[0]: return 0.0
  *     bin_id = <int> ((dvs[fit.field_id] - fit.bounds[0]) * fit.idbin)             # <<<<<<<<<<<<<<
  *     dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0
- *     if bin_id > fit.nbins - 2 or bin_id < 0: return 0.0
+ *     bv = fit.values[bin_id]
  */
   __pyx_v_bin_id = ((int)(((__pyx_v_dvs[__pyx_v_fit->field_id]) - (__pyx_v_fit->bounds[0])) * __pyx_v_fit->idbin));
 
-  /* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":110
- *     if fit.pass_through == 1: return dvs[fit.field_id]
+  /* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":111
+ *     if dvs[fit.field_id] > fit.bounds[1] or dvs[fit.field_id] < fit.bounds[0]: return 0.0
  *     bin_id = <int> ((dvs[fit.field_id] - fit.bounds[0]) * fit.idbin)
  *     dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0             # <<<<<<<<<<<<<<
- *     if bin_id > fit.nbins - 2 or bin_id < 0: return 0.0
  *     bv = fit.values[bin_id]
+ *     dy = fit.values[bin_id + 1] - bv
  */
   __pyx_v_dd = ((__pyx_v_dvs[__pyx_v_fit->field_id]) - ((__pyx_v_fit->bounds[0]) + (__pyx_v_bin_id * __pyx_v_fit->dbin)));
 
-  /* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":111
+  /* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":112
  *     bin_id = <int> ((dvs[fit.field_id] - fit.bounds[0]) * fit.idbin)
  *     dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0
- *     if bin_id > fit.nbins - 2 or bin_id < 0: return 0.0             # <<<<<<<<<<<<<<
- *     bv = fit.values[bin_id]
- *     dy = fit.values[bin_id + 1] - bv
- */
-  __pyx_t_1 = (__pyx_v_bin_id > (__pyx_v_fit->nbins - 2));
-  if (!__pyx_t_1) {
-    __pyx_t_2 = (__pyx_v_bin_id < 0);
-    __pyx_t_3 = __pyx_t_2;
-  } else {
-    __pyx_t_3 = __pyx_t_1;
-  }
-  if (__pyx_t_3) {
-    __pyx_r = 0.0;
-    goto __pyx_L0;
-    goto __pyx_L4;
-  }
-  __pyx_L4:;
-
-  /* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":112
- *     dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0
- *     if bin_id > fit.nbins - 2 or bin_id < 0: return 0.0
  *     bv = fit.values[bin_id]             # <<<<<<<<<<<<<<
  *     dy = fit.values[bin_id + 1] - bv
  *     if fit.weight_field_id != -1:
@@ -12999,7 +12999,7 @@
   __pyx_v_bv = (__pyx_v_fit->values[__pyx_v_bin_id]);
 
   /* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":113
- *     if bin_id > fit.nbins - 2 or bin_id < 0: return 0.0
+ *     dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0
  *     bv = fit.values[bin_id]
  *     dy = fit.values[bin_id + 1] - bv             # <<<<<<<<<<<<<<
  *     if fit.weight_field_id != -1:



More information about the yt-svn mailing list