more binary_c style function macros that I missed previously

parent ef94b7d8
......@@ -107,7 +107,7 @@ typedef unsigned int rinterpolate_Boolean_t;
/*
* Use memcmp to compare cache lines?
* The alternative is !FEQUAL, which is usually a bit faster.
* The alternative is !Fequal, which is usually a bit faster.
* Your mileage may vary.
*/
#define RINTERPOLATE_CACHE_USE_MEMCMP
......
......@@ -41,7 +41,7 @@ rinterpolate_counter_t rinterpolate_add_new_table(
table->d = d;
table->l = l;
table->line_length = n + d;
table->hypertable_length = POWER2_INT(n);
table->hypertable_length = Intger_power_of_two(n);
#ifdef RINTERPOLATE_CACHE
table->cache_length = cache_length;
#endif
......
......@@ -65,7 +65,7 @@ rinterpolate_Boolean_t rinterpolate_check_cache(
Rinterpolate_print("start of for loop\n");
for(m=0; m<table->n; m++)
{
if(!FEQUAL(x[m],cacheline[m]))
if(!Fequal(x[m],cacheline[m]))
{
match = FALSE;
break;
......
......@@ -21,34 +21,34 @@
#endif
/* fast bit-shift equivalent to pow(2,A) but for integers */
#define POWER2_INT(A) (1<<(A))
#define Intger_power_of_two(A) (1<<(A))
/* macros to define less and more than operations */
#define LESS_THAN(A,B) ((A)<(B))
#define MORE_THAN(A,B) ((A)>(B))
#define MAX(A,B) ({ \
#define Less_than(A,B) ((A)<(B))
#define More_than(A,B) ((A)>(B))
#define Max(A,B) ({ \
const Autotype(A) _a = (A); \
const Autotype(B) _b = (B); \
MORE_THAN(_a,_b) ? _a : _b; \
More_than(_a,_b) ? _a : _b; \
})
#define MIN(A,B) ({ \
#define Min(A,B) ({ \
const Autotype(A) _a = (A); \
const Autotype(B) _b = (B); \
LESS_THAN(_a,_b) ? _a : _b; \
Less_than(_a,_b) ? _a : _b; \
})
#define FORCE_RANGE(A,B,X) ({ \
#define Force_range(A,B,X) ({ \
const Autotype(A) _a = (A); \
const Autotype(B) _b = (B); \
const Autotype(X) _x = (X); \
(unlikely(LESS_THAN(_x,_a))) ? _a : \
(unlikely(MORE_THAN(_x,_b)) ? _b : _x); \
(unlikely(Less_than(_x,_a))) ? _a : \
(unlikely(More_than(_x,_b)) ? _b : _x); \
})
#ifndef IS_ZERO
#define IS_ZERO(A) (fabs((A))<TINY)
#ifndef Is_zero
#define Is_zero(A) (fabs((A))<TINY)
#endif
#ifndef FEQUAL
#define FEQUAL(A,B) (IS_ZERO((A)-(B)))
#ifndef Fequal
#define Fequal(A,B) (Is_zero((A)-(B)))
#endif
#ifdef RINTERPOLATE_DEBUG
......
......@@ -58,7 +58,7 @@
//else b = c; // if(LESS_OR_EQUAL(v,u)) // obviously!
}
a=MIN(a,b);
a=Min(a,b);
b=a+1;
//printf("QUADRATIC %d %d\n",a,b);
#endif
......@@ -77,7 +77,7 @@
while(c)
{
b = a|c;
w = MIN(b,N);
w = Min(b,N);
#ifdef RINTERPOLATE_POINT_ARITHMETIC_J_LOOP
if(b < N && v >= *(tj+b*i)) a=b;
#else
......
......@@ -41,17 +41,17 @@ void rinterpolate_search_table(
#endif
#ifdef RINTERPOLATE_POINTER_ARITHMETIC_J_LOOP
#ifdef RINTERPOLATE_PRESEARCH
const rinterpolate_float_t v = FORCE_RANGE(*tpre,*(tpre+b-1),*(x+j));
const rinterpolate_float_t v = Force_range(*tpre,*(tpre+b-1),*(x+j));
#else
const rinterpolate_float_t * tj = table->data + j;
const rinterpolate_float_t v = MAX(*tj,MIN(*(tj+g),*(x+j)));
const rinterpolate_float_t v = Max(*tj,Min(*(tj+g),*(x+j)));
#endif
const rinterpolate_counter_t k = *(table->steps+j);
#else
#ifdef RINTERPOLATE_PRESEARCH
const rinterpolate_float_t v = MAX(tpre[0],MIN(tpre[b-1],x[j]));
const rinterpolate_float_t v = Max(tpre[0],Min(tpre[b-1],x[j]));
#else
const rinterpolate_float_t v = MAX(table->data[j],MIN(table->data[g+j],x[j]));
const rinterpolate_float_t v = Max(table->data[j],Min(table->data[g+j],x[j]));
#endif
const rinterpolate_counter_t k = table->steps[j];
#endif
......@@ -180,7 +180,7 @@ void rinterpolate_search_table(
#endif
}
const rinterpolate_counter_t c = POWER2_INT(table->n-1-j);
const rinterpolate_counter_t c = Intger_power_of_two(table->n-1-j);
a *= k;
b *= k;
//rinterpolate_counter_t tmp;
......
......@@ -169,11 +169,11 @@ int main (int argc,
* the exact functions and the interpolated functions.
*/
rinterpolate_float_t diffmax = 0.0;
#define DIFF(X,Y) (fabs(X-Y)/MIN(fabs(X),fabs(Y)))
#define DIFF(X,Y) (fabs(X-Y)/Min(fabs(X),fabs(Y)))
#define MAXDIFF \
MAX(MAX(diffmax, \
Max(Max(diffmax, \
DIFF(r[0],rr[0])), \
MAX(DIFF(r[1],rr[1]), \
Max(DIFF(r[1],rr[1]), \
DIFF(r[2],rr[2])));
if(status==0)
......@@ -237,7 +237,7 @@ int main (int argc,
printf("%7s cache : %8.3f, maxdiff = %6.4f %%\n","With",t_cache,100.0*diffmax);
printf("Cache speed up : %5.3f %%\n",
100.0*((rinterpolate_float_t)t_nocache - (rinterpolate_float_t)t_cache)/
MIN((rinterpolate_float_t)t_cache,(rinterpolate_float_t)t_nocache));
Min((rinterpolate_float_t)t_cache,(rinterpolate_float_t)t_nocache));
Report("Fixed cache",t_cache);
}
......@@ -298,7 +298,7 @@ int main (int argc,
printf("%7s cache : %8.3f, maxdiff = %6.4f %%\n","With",t_cache,100.0*diffmax);
printf("Cache speed up : %6.4f %%\n",
100.0*((rinterpolate_float_t)t_nocache - (rinterpolate_float_t)t_cache)/
MIN((rinterpolate_float_t)t_cache,(rinterpolate_float_t)t_nocache));
Min((rinterpolate_float_t)t_cache,(rinterpolate_float_t)t_nocache));
}
......@@ -349,7 +349,7 @@ int main (int argc,
printf("%7s cache_length %2d : %8.3f, maxdiff = %6.4f %%\n","With",ncache,t_cache,100.0*diffmax);
printf(" Cache speed up : %5.3f %%\n",
100.0*((rinterpolate_float_t)t_nocache - (rinterpolate_float_t)t_cache)/
MIN((rinterpolate_float_t)t_cache,(rinterpolate_float_t)t_nocache));
Min((rinterpolate_float_t)t_cache,(rinterpolate_float_t)t_nocache));
char c[100];
sprintf(c,"Spun %d",ncache);
Report(c,t_cache);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment