[GAP Forum] Fwd: Speed of GAP

John McDermott jjm at dcs.st-and.ac.uk
Tue Mar 1 09:51:47 GMT 2005



Begin forwarded message:

> From: Alexander Hulpke <hulpke at math.colostate.edu>
> Date: 28 February 2005 17:27:25 GMT
> To: gap-forum at gap-system.org
> Subject: Re: Speed of GAP
>
> Dear GAP Forum,
>
> D. Bulutoglu asked:
>
>> 	I was wondering, if I compiled my GAP code using GAC is there a
>> guarantee that it will run as fast as the C version of my code?
>
> There is no guarantee as you are comparing very different things.
> (In particular it is often possible to improve runtime at the cost of
> modularity or portability.)
>
> Not knowing your application also makes guessing hard, but here are 
> some
> rules of thumb:
>
> If you can write everything you need in C (which in particular means 
> that
> you have no need for the functionality provided by GAP beyond the basic
> programming language, or that you are willing to recode all of this on 
> your
> own in C) good C code is likely faster. In examples I have observed C 
> being
> faster by a factor of between 10 and 1000 than pure GAP code. (As soon 
> as
> notable time is spent in GAP kernel routines, such as matrix
> multiplication or permutation multiplication the factor drops down to 
> under
> 10.)
>
> Using the `gac' compiler will reduce this factor (again only 
> considering
> code that does not use GAP kernel routines) to around 3 to 100.
>
> On the other hand coding in GAP is (at least for me) easily a similar 
> factor
> faster than coding in C.
>
> If you need GAP functionality and you *must* have the speed of C your 
> best
> bet is likely to have `gac' produce C code and then to hand 
> optimize/rewrite
> this code.
>
> Finally I'd like to strongly second the opinion expressed already that
> algorithmic improvements are likey to get you much further as any
> programming tricks will ever do.
>
> All the best,
>
>     Alexander Hulpke
>
> -- Colorado State University, Department of Mathematics,
> Weber Building, 1874 Campus Delivery, Fort Collins, CO 80523-1874, USA
> email: hulpke at math.colostate.edu, Phone: ++1-970-4914288
> http://www.math.colostate.edu/~hulpke
>
>
--
John McDermott
Computing Officer & Purchase Officer
School of Computer Science
University of St Andrews
North Haugh, St Andrews, Fife
KY16 9SX

tel +44 1334 463252
mob +44 7941 507531




More information about the Forum mailing list