help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] -DHAVE_INLINE syntax error


From: Nicola Botta
Subject: [Help-gsl] -DHAVE_INLINE syntax error
Date: Sun, 06 Jun 2004 08:42:12 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624

dear GSL developers and users,


I am using gsl vectors to prototype renumbering of triangulations
for minimizing cache misses in PDE solvers (if interested, please
visit http://www.pik-potsdam.de/~botta/projects/projects.html).

For measuring the impact of renumbering algorithms on cache hits
I have to time the access to vector elements. This should take place
through plain C pointer arithmetic & dereferencing i.e. bypassing
calls to range checking functions. I therefore need to enable inlining
and disable range checking.

Compiling the example included below with debugging options

gcc -Wall -ansi -pedantic -g -DDEBUG  -I. -I../.. -c inlining.c
Linking inlining:
gcc  -o inlining inlining.o -lgsl -lgslcblas -lm
$ inlining
20000000 set/get, average = 1.000069e+07, elapsed time = 2.864324e+00 [sec]
$

or with optimization options and with -UGSL_RANGE_CHECK

$ make -f inlining.mk
gcc -Wall -ansi -pedantic -UDEBUG -DNDEBUG -O3 -mcpu=i686 -funroll-loops
-fcaller-saves -fstrength-reduce -frerun-cse-after-loop -ffast-math -fforce-mem
-UGSL_RANGE_CHECK -I. -I../.. -c inlining.c
Linking inlining:
gcc  -o inlining inlining.o -lgsl -lgslcblas -lm
$ inlining
20000000 set/get, average = 1.000069e+07, elapsed time = 2.378855e+00 [sec]
$

makes no significant difference in execution time. Compilation
with -DHAVE_INLINE fails:

$ make -f inlining.mk
gcc -Wall -ansi -pedantic -UDEBUG -DNDEBUG -O3 -mcpu=i686 -funroll-loops
-fcaller-saves -fstrength-reduce -frerun-cse-after-loop -ffast-math -fforce-mem
-DHAVE_INLINE -UGSL_RANGE_CHECK -I. -I../.. -c inlining.c
In file included from inlining.c:37:
/usr/local/include/gsl/gsl_vector_int.h:168: syntax error before `int'
/usr/local/include/gsl/gsl_vector_int.h:181: syntax error before `void'
/usr/local/include/gsl/gsl_vector_int.h:194: syntax error before `int'
/usr/local/include/gsl/gsl_vector_int.h:207: syntax error before `const'
In file included from inlining.c:38:
/usr/local/include/gsl/gsl_rng.h:156: syntax error before `unsigned'
/usr/local/include/gsl/gsl_rng.h:158: syntax error before `unsigned'
/usr/local/include/gsl/gsl_rng.h:164: syntax error before `double'
/usr/local/include/gsl/gsl_rng.h:166: syntax error before `double'
/usr/local/include/gsl/gsl_rng.h:172: syntax error before `double'
/usr/local/include/gsl/gsl_rng.h:174: syntax error before `double'
/usr/local/include/gsl/gsl_rng.h:187: syntax error before `unsigned'
/usr/local/include/gsl/gsl_rng.h:189: syntax error before `unsigned'
make: *** [inlining.o] Error 1
$

Do you have any idea how to fix the problem ? Notice that direct
access to the vector data (line 68 of the example below) leads to
significantly shorter execution times:

$ make -f inlining.mk
gcc -Wall -ansi -pedantic -UDEBUG -DNDEBUG -O3 -mcpu=i686 -funroll-loops -fcaller-saves -fstrength-reduce -frerun-cse-after-loop -ffast-math -fforce-mem -UGSL_RANGE_CHECK -I. -I../.. -c inlining.c
Linking inlining:
gcc  -o inlining inlining.o -lgsl -lgslcblas -lm
$ inlining
20000000 set/get, average = 1.000069e+07, elapsed time = 9.820210e-01 [sec]
$

This suggests that the crucial point for avoiding function calls upon
element access is the HAVE_INLINE flag which unfortunatly leads
to syntax errors.


best regards,
Nicola



   37    #include <gsl/gsl_vector_int.h>
   38    #include <gsl/gsl_rng.h>
   39    #include <sys/time.h>
40 41 42 /*------------------------------------------------------------------------------
   43      main
44 ------------------------------------------------------------------------------*/
   45    int main(int argc, char **argv) {
46 47 int size, i;
   48      gsl_vector_int *v;
   49      gsl_rng *rng;
   50      double average;
   51      struct timeval tv;
   52      double t0s, t0ms, t1s, t1ms, elapsed;
53 54 size = 20000000; 55 56 v = gsl_vector_int_alloc(size);
   57      rng = gsl_rng_alloc(gsl_rng_taus);
   58      for(i = 0; i < size; i++)
   59        gsl_vector_int_set(v, i, (int)gsl_rng_uniform_int(rng, size));
60 61 average = 0.0;
   62      /* start of timed section */
   63      gettimeofday(&tv, (struct timezone *) 0);
   64      t0s = tv.tv_sec;
   65      t0ms = tv.tv_usec;
   66      for(i = 0; i < size; i++)
   67        average += gsl_vector_int_get(v, i);
   68    /*      average += v->data[i]; */
   69      gettimeofday(&tv, (struct timezone *) 0);
   70      /* end of timed section */
   71      average /= size;
   72      t1s = tv.tv_sec;
   73      t1ms = tv.tv_usec;
   74      elapsed = t1s - t0s;
   75      elapsed += 1e-6 * (t1ms - t0ms);
76 77 printf("%d set/get, average = %e, elapsed time = %e [sec]\n", size, average, elapsed); 78 79 gsl_rng_free(rng);
   80      gsl_vector_int_free(v);
81 82 return 0; 83 84 }




--
Nicola Botta, Data & Computation
Potsdam Institute for Climate Impact Research (PIK)
Telegrafenberg C4, Postfach 60 12 03, D-14412 Potsdam
tel: ++49 (0)331 288 2657 mailto:address@hidden







reply via email to

[Prev in Thread] Current Thread [Next in Thread]