aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhaas <rhaas@8e189c6b-2ab8-4400-aa02-70a9cfce18b9>2014-03-13 03:01:48 +0000
committerrhaas <rhaas@8e189c6b-2ab8-4400-aa02-70a9cfce18b9>2014-03-13 03:01:48 +0000
commit50c3d797f21890b12a7bc487c70297e20180f2ce (patch)
tree53d66a9c7280c8f735f9be24cca4be095dc02863
parent3f6090970ad845ed1b783f8efee4a61b8f2f97cd (diff)
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@tapir.caltech.edu> git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinEOS/EOS_Omni/trunk@99 8e189c6b-2ab8-4400-aa02-70a9cfce18b9
-rw-r--r--src/nuc_eos_cxx/nuc_eos_dpdrhoe_dpderho.cc7
-rw-r--r--src/nuc_eos_cxx/nuc_eos_full.cc20
-rw-r--r--src/nuc_eos_cxx/nuc_eos_press.cc20
-rw-r--r--src/nuc_eos_cxx/nuc_eos_press_cs2.cc22
-rw-r--r--src/nuc_eos_cxx/nuc_eos_short.cc30
5 files changed, 59 insertions, 40 deletions
diff --git a/src/nuc_eos_cxx/nuc_eos_dpdrhoe_dpderho.cc b/src/nuc_eos_cxx/nuc_eos_dpdrhoe_dpderho.cc
index 332638d..ace3670 100644
--- a/src/nuc_eos_cxx/nuc_eos_dpdrhoe_dpderho.cc
+++ b/src/nuc_eos_cxx/nuc_eos_dpdrhoe_dpderho.cc
@@ -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 @@ void CCTK_FNAME(nuc_eos_m_kt0_dpdrhoe_dpderho)(const int *restrict n,
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 @@ void CCTK_FNAME(nuc_eos_m_kt0_dpdrhoe_dpderho)(const int *restrict n,
// 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;
diff --git a/src/nuc_eos_cxx/nuc_eos_full.cc b/src/nuc_eos_cxx/nuc_eos_full.cc
index 56b6ae0..d1f511d 100644
--- a/src/nuc_eos_cxx/nuc_eos_full.cc
+++ b/src/nuc_eos_cxx/nuc_eos_full.cc
@@ -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 @@ void CCTK_FNAME(nuc_eos_m_kt1_full)(const int *restrict n,
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 @@ void CCTK_FNAME(nuc_eos_m_kt1_full)(const int *restrict n,
}
}
- 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 @@ void CCTK_FNAME(nuc_eos_m_kt1_full)(const int *restrict n,
}
}
- 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 @@ void CCTK_FNAME(nuc_eos_m_kt1_full)(const int *restrict n,
}
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 @@ void CCTK_FNAME(nuc_eos_m_kt0_full)(const int *restrict n,
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 @@ void CCTK_FNAME(nuc_eos_m_kt0_full)(const int *restrict n,
// 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 @@ void CCTK_FNAME(nuc_eos_m_kt0_full)(const int *restrict n,
}
}
- 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]);
diff --git a/src/nuc_eos_cxx/nuc_eos_press.cc b/src/nuc_eos_cxx/nuc_eos_press.cc
index 215adf8..13b0558 100644
--- a/src/nuc_eos_cxx/nuc_eos_press.cc
+++ b/src/nuc_eos_cxx/nuc_eos_press.cc
@@ -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 @@ void CCTK_FNAME(nuc_eos_m_kt1_press_eps)(const int *restrict n,
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 @@ void CCTK_FNAME(nuc_eos_m_kt1_press_eps)(const int *restrict n,
}
}
- 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 @@ void CCTK_FNAME(nuc_eos_m_kt1_press_eps)(const int *restrict 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]);
eps[i] = exp(eps[i]) - energy_shift;
}
@@ -59,7 +61,7 @@ void CCTK_FNAME(nuc_eos_m_kt1_press_eps)(const int *restrict n,
}
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 @@ void CCTK_FNAME(nuc_eos_m_kt0_press)(const int *restrict n,
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 @@ void CCTK_FNAME(nuc_eos_m_kt0_press)(const int *restrict n,
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 @@ void CCTK_FNAME(nuc_eos_m_kt0_press)(const int *restrict n,
} // 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]);
}
diff --git a/src/nuc_eos_cxx/nuc_eos_press_cs2.cc b/src/nuc_eos_cxx/nuc_eos_press_cs2.cc
index 5a47ba2..08ab8c2 100644
--- a/src/nuc_eos_cxx/nuc_eos_press_cs2.cc
+++ b/src/nuc_eos_cxx/nuc_eos_press_cs2.cc
@@ -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 @@ void CCTK_FNAME(nuc_eos_m_kt1_press_eps_cs2)(const int *restrict n,
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 @@ void CCTK_FNAME(nuc_eos_m_kt1_press_eps_cs2)(const int *restrict n,
}
}
- 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 @@ void CCTK_FNAME(nuc_eos_m_kt1_press_eps_cs2)(const int *restrict 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]);
eps[i] = exp(eps[i]) - energy_shift;
#if HAVEGR
@@ -66,7 +68,7 @@ void CCTK_FNAME(nuc_eos_m_kt1_press_eps_cs2)(const int *restrict n,
}
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 @@ void CCTK_FNAME(nuc_eos_m_kt0_press_cs2)(const int *restrict n,
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 @@ void CCTK_FNAME(nuc_eos_m_kt0_press_cs2)(const int *restrict n,
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 @@ void CCTK_FNAME(nuc_eos_m_kt0_press_cs2)(const int *restrict 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]);
#if HAVEGR
cs2[i] = cs2[i] / (1.0 + eps[i] + prs[i]/rho[i]);
diff --git a/src/nuc_eos_cxx/nuc_eos_short.cc b/src/nuc_eos_cxx/nuc_eos_short.cc
index fbdf5d0..06e66d8 100644
--- a/src/nuc_eos_cxx/nuc_eos_short.cc
+++ b/src/nuc_eos_cxx/nuc_eos_short.cc
@@ -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 @@ void CCTK_FNAME(nuc_eos_m_kt1_short)(const int *restrict n,
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 @@ void CCTK_FNAME(nuc_eos_m_kt1_short)(const int *restrict n,
}
}
- 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 @@ void CCTK_FNAME(nuc_eos_m_kt1_short)(const int *restrict n,
}
}
- 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 @@ void CCTK_FNAME(nuc_eos_m_kt1_short)(const int *restrict n,
}
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 @@ extern "C"
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 @@ extern "C"
// 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 @@ extern "C"
}
}
- 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"
}
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 @@ extern "C"
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 @@ extern "C"
// 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 @@ extern "C"
}
}
- 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