[Commits] [svn:einsteintoolkit] EOS_Omni/trunk/src/nuc_eos_cxx/ (Rev. 99)

rhaas at tapir.caltech.edu rhaas at tapir.caltech.edu
Wed Mar 12 22:01:49 CDT 2014


User: rhaas
Date: 2014/03/12 10:01 PM

Modified:
 /trunk/src/nuc_eos_cxx/
  nuc_eos_dpdrhoe_dpderho.cc, nuc_eos_full.cc, nuc_eos_press.cc, nuc_eos_press_cs2.cc, nuc_eos_short.cc

Log:
 EOS_Omni: use explicit temporary for loop upper bound
 
 not sure if restrict is propagated to called routines or if the compiler
 must assume that all pointed to variables change when a function is
 called.
 
 From: Roland Haas <rhaas at tapir.caltech.edu>

File Changes:

Directory: /trunk/src/nuc_eos_cxx/
==================================

File [modified]: nuc_eos_dpdrhoe_dpderho.cc
Delta lines: +4 -3
===================================================================
--- trunk/src/nuc_eos_cxx/nuc_eos_dpdrhoe_dpderho.cc	2014-03-13 03:01:46 UTC (rev 98)
+++ trunk/src/nuc_eos_cxx/nuc_eos_dpdrhoe_dpderho.cc	2014-03-13 03:01:48 UTC (rev 99)
@@ -7,7 +7,7 @@
 namespace nuc_eos {
 
 extern "C"
-void CCTK_FNAME(nuc_eos_m_kt0_dpdrhoe_dpderho)(const int *restrict n,
+void CCTK_FNAME(nuc_eos_m_kt0_dpdrhoe_dpderho)(const int *restrict n_in,
 				     const double *restrict rho, 
 				     double *restrict temp,
 				     const double *restrict ye,
@@ -18,12 +18,13 @@
 				     int *restrict keyerr,
 				     int *restrict anyerr)
 {
+  const int n = *n_in;
 
   using namespace nuc_eos;
 
   *anyerr = 0;
 
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     
     // check if we are fine
     // Note that this code now requires that the
@@ -39,7 +40,7 @@
   // a fatal error anyway. No point in doing any further EOS calculations.
   if(*anyerr) return;
 
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     const double lr = log(rho[i]);
     const double lt = log(MIN(MAX(temp[i],eos_tempmin),eos_tempmax));
     double ltout;

File [modified]: nuc_eos_full.cc
Delta lines: +12 -8
===================================================================
--- trunk/src/nuc_eos_cxx/nuc_eos_full.cc	2014-03-13 03:01:46 UTC (rev 98)
+++ trunk/src/nuc_eos_cxx/nuc_eos_full.cc	2014-03-13 03:01:48 UTC (rev 99)
@@ -6,7 +6,7 @@
 
 namespace nuc_eos {
 extern "C"
-void CCTK_FNAME(nuc_eos_m_kt1_full)(const int *restrict n,
+void CCTK_FNAME(nuc_eos_m_kt1_full)(const int *restrict n_in,
 			  const double *restrict rho, 
 			  const double *restrict temp,
 			  const double *restrict ye,
@@ -33,8 +33,10 @@
 
   using namespace nuc_eos;
 
+  const int n = *n_in;
+
   *anyerr = 0;
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     // check if we are fine
     keyerr[i] = checkbounds(rho[i], temp[i], ye[i]);
     if(keyerr[i] != 0) {
@@ -43,7 +45,7 @@
     }
   }
 
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
   
     int idx[8];
     double delx,dely,delz;
@@ -138,7 +140,7 @@
     }
   }
   
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     prs[i] = exp(prs[i]);
     eps[i] = exp(eps[i]) - energy_shift;
 #if HAVEGR
@@ -150,7 +152,7 @@
 }
 
 extern "C"
-void CCTK_FNAME(nuc_eos_m_kt0_full)(const int *restrict n,
+void CCTK_FNAME(nuc_eos_m_kt0_full)(const int *restrict n_in,
 			  const double *restrict rho, 
 			  double *restrict temp,
 			  const double *restrict ye,
@@ -178,9 +180,11 @@
 
   using namespace nuc_eos;
 
+  const int n = *n_in;
+
   *anyerr = 0;
 
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     
     // check if we are fine
     // Note that this code now requires that the
@@ -196,7 +200,7 @@
   // a fatal error anyway. No point in doing any further EOS calculations.
   if(*anyerr) return;
 
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     const double lr = log(rho[i]);
     const double lt = log(MIN(MAX(temp[i],eos_tempmin),eos_tempmax));
     double ltout;
@@ -306,7 +310,7 @@
     }
   }
 
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     prs[i] = exp(prs[i]);
 #if HAVEGR
     cs2[i] = cs2[i] / (1.0 + eps[i] + prs[i]/rho[i]);

File [modified]: nuc_eos_press.cc
Delta lines: +12 -8
===================================================================
--- trunk/src/nuc_eos_cxx/nuc_eos_press.cc	2014-03-13 03:01:46 UTC (rev 98)
+++ trunk/src/nuc_eos_cxx/nuc_eos_press.cc	2014-03-13 03:01:48 UTC (rev 99)
@@ -7,7 +7,7 @@
 namespace nuc_eos {
 
 extern "C"
-void CCTK_FNAME(nuc_eos_m_kt1_press_eps)(const int *restrict n,
+void CCTK_FNAME(nuc_eos_m_kt1_press_eps)(const int *restrict n_in,
 			     const double *restrict rho, 
 			     const double *restrict temp,
 			     const double *restrict ye,
@@ -19,8 +19,10 @@
 
   using namespace nuc_eos;
 
+  const int n = *n_in;
+
   *anyerr = 0;
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     // check if we are fine
     keyerr[i] = checkbounds(rho[i], temp[i], ye[i]);
     if(keyerr[i] != 0) {
@@ -29,7 +31,7 @@
     }
   }
 
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     int idx[8];
     double delx,dely,delz;
     const double xrho = log(rho[i]);
@@ -49,7 +51,7 @@
   } 
 
   // now get rid of ln:
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     prs[i] = exp(prs[i]);
     eps[i] = exp(eps[i]) - energy_shift;
   }
@@ -59,7 +61,7 @@
 }
 
 extern "C"
-void CCTK_FNAME(nuc_eos_m_kt0_press)(const int *restrict n,
+void CCTK_FNAME(nuc_eos_m_kt0_press)(const int *restrict n_in,
 			 const double *restrict rho, 
 			 double *restrict temp,
 			 const double *restrict ye,
@@ -72,9 +74,11 @@
 
   using namespace nuc_eos;
 
+  const int n = *n_in;
+
   *anyerr = 0;
 
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     // check if we are fine
     // Note that this code now requires that the
     // temperature guess be within the table bounds
@@ -90,7 +94,7 @@
   if(*anyerr) return;
 
   // first must find the temperature
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     const double lr = log(rho[i]);
     const double lt = log(MIN(MAX(temp[i],eos_tempmin),eos_tempmax));
     double ltout;
@@ -148,7 +152,7 @@
   } // loop i<n
 
   // now get rid of ln:
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     prs[i] = exp(prs[i]);
   }
 

File [modified]: nuc_eos_press_cs2.cc
Delta lines: +13 -9
===================================================================
--- trunk/src/nuc_eos_cxx/nuc_eos_press_cs2.cc	2014-03-13 03:01:46 UTC (rev 98)
+++ trunk/src/nuc_eos_cxx/nuc_eos_press_cs2.cc	2014-03-13 03:01:48 UTC (rev 99)
@@ -7,7 +7,7 @@
 namespace nuc_eos {
 
 extern "C"
-void CCTK_FNAME(nuc_eos_m_kt1_press_eps_cs2)(const int *restrict n,
+void CCTK_FNAME(nuc_eos_m_kt1_press_eps_cs2)(const int *restrict n_in,
 			     const double *restrict rho, 
 			     const double *restrict temp,
 			     const double *restrict ye,
@@ -20,8 +20,10 @@
 
   using namespace nuc_eos;
 
+  const int n = *n_in;
+
   *anyerr = 0;
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     // check if we are fine
     keyerr[i] = checkbounds(rho[i], temp[i], ye[i]);
     if(keyerr[i] != 0) {
@@ -30,7 +32,7 @@
     }
   }
   
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     int idx[8];
     double delx,dely,delz;
     const double xrho = log(rho[i]);
@@ -53,7 +55,7 @@
   } 
 
   // now get rid of ln:
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     prs[i] = exp(prs[i]);
     eps[i] = exp(eps[i]) - energy_shift;
 #if HAVEGR
@@ -66,7 +68,7 @@
 }
 
 extern "C"
-void CCTK_FNAME(nuc_eos_m_kt0_press_cs2)(const int *restrict n,
+void CCTK_FNAME(nuc_eos_m_kt0_press_cs2)(const int *restrict n_in,
 			 const double *restrict rho, 
 			 double *restrict temp,
 			 const double *restrict ye,
@@ -80,14 +82,16 @@
 
   using namespace nuc_eos;
 
+  const int n = *n_in;
+
   *anyerr = 0;
 
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     
     // check if we are fine
     // Note that this code now requires that the
     // temperature guess be within the table bounds
-    keyerr[i] = checkbounds_kt0_noTcheck(rho[i], ye[i]);;
+    keyerr[i] = checkbounds_kt0_noTcheck(rho[i], ye[i]);
     if(keyerr[i] != 0) {
       *anyerr = 1;
     }
@@ -99,7 +103,7 @@
   if(*anyerr) return;
 
   // first must find the temperature
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     const double lr = log(rho[i]);
     const double lt = log(MIN(MAX(temp[i],eos_tempmin),eos_tempmax));
     double ltout;
@@ -164,7 +168,7 @@
   }
 
   // now get rid of ln:
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     prs[i] = exp(prs[i]);
 #if HAVEGR
     cs2[i] = cs2[i] / (1.0 + eps[i] + prs[i]/rho[i]);

File [modified]: nuc_eos_short.cc
Delta lines: +18 -12
===================================================================
--- trunk/src/nuc_eos_cxx/nuc_eos_short.cc	2014-03-13 03:01:46 UTC (rev 98)
+++ trunk/src/nuc_eos_cxx/nuc_eos_short.cc	2014-03-13 03:01:48 UTC (rev 99)
@@ -7,7 +7,7 @@
 namespace nuc_eos {
 
 extern "C"
-void CCTK_FNAME(nuc_eos_m_kt1_short)(const int *restrict n,
+void CCTK_FNAME(nuc_eos_m_kt1_short)(const int *restrict n_in,
 			   const double *restrict rho, 
 			   const double *restrict temp,
 			   const double *restrict ye,
@@ -25,8 +25,10 @@
 
   using namespace nuc_eos;
 
+  const int n = *n_in;
+
   *anyerr = 0;
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     // check if we are fine
     keyerr[i] = checkbounds(rho[i], temp[i], ye[i]);
     if(keyerr[i] != 0) {
@@ -35,7 +37,7 @@
     }
   }
 
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
   
     int idx[8];
     double delx,dely,delz;
@@ -84,7 +86,7 @@
     }
   }
   
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     prs[i] = exp(prs[i]);
     eps[i] = exp(eps[i]) - energy_shift;
 #if HAVEGR
@@ -96,7 +98,7 @@
 }
 
 extern "C"
-  void CCTK_FNAME(nuc_eos_m_kt0_short)(const int *restrict n,
+  void CCTK_FNAME(nuc_eos_m_kt0_short)(const int *restrict n_in,
 			   const double *restrict rho, 
 			   double *restrict temp,
 			   const double *restrict ye,
@@ -115,9 +117,11 @@
 
   using namespace nuc_eos;
 
+  const int n = *n_in;
+
   *anyerr = 0;
 
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     
     // check if we are fine
     // Note that this code now requires that the
@@ -133,7 +137,7 @@
   // a fatal error anyway. No point in doing any further EOS calculations.
   if(*anyerr) return;
 
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     const double lr = log(rho[i]);
     const double lt = log(MIN(MAX(temp[i],eos_tempmin),eos_tempmax));
     double ltout;
@@ -198,7 +202,7 @@
     }
   }
 
-  for(int i=0;i<*n;i++) {
+  for(int i=0;i<n;i++) {
     prs[i] = exp(prs[i]);
 #if HAVEGR
     cs2[i] = cs2[i] / (1.0 + eps[i] + prs[i]/rho[i]);
@@ -209,7 +213,7 @@
 }
 
 extern "C"
-  void CCTK_FNAME(nuc_eos_m_kt2_short)(const int *restrict n,
+  void CCTK_FNAME(nuc_eos_m_kt2_short)(const int *restrict n_in,
 			   const double *restrict rho, 
 			   double *restrict temp,
 			   const double *restrict ye,
@@ -228,9 +232,11 @@
 
     using namespace nuc_eos;
 
+    const int n = *n_in;
+
     *anyerr = 0;
 
-    for(int i=0;i<*n;i++) {
+    for(int i=0;i<n;i++) {
       // check if we are fine
       // Note that this code now requires that the
       // temperature guess be within the table bounds
@@ -245,7 +251,7 @@
     // a fatal error anyway. No point in doing any further EOS calculations.
     if(*anyerr) return;
 
-    for(int i=0;i<*n;i++) {
+    for(int i=0;i<n;i++) {
       const double lr = log(rho[i]);
       const double lt = log(MIN(MAX(temp[i],eos_tempmin),eos_tempmax));
       double ltout;
@@ -295,7 +301,7 @@
       }
     }
 
-    for(int i=0;i<*n;i++) {
+    for(int i=0;i<n;i++) {
       prs[i] = exp(prs[i]);
       eps[i] = exp(eps[i]) - energy_shift;
 #if HAVEGR



More information about the Commits mailing list