[GAP Forum] Re: Speed of GAP

Bulutoglu Dursun A Civ AFIT/ENC Dursun.Bulutoglu at afit.edu
Sun Feb 20 17:28:11 GMT 2005


	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?
	Dursun.

Dear GAP Forum,

Dursun Bulutoglu asked:



> 	I was wondering how GAP compares to C in terms of speed.
> 	Is GAP slower processing through large loops? 
> Is there a programming style in GAP that can improve the speed at
which
> jobs are done? For example in some high level programming languages
> avoiding loops as much as possible is recommended to boost speed.
> Is GAP much slower when the data it processes through is large?
> I have a GAP code running for a week now and it still has not
finished.
> I have a feeling that it would have run much faster with C.   

There is no really simple answer to this question, it depends very much
on what
you are doing. Code in which most the time is spent doing simple
arithmetic,
array accesses, data structure manipulation, and so on is perhaps 3 to
10 times
slower in GAP than C, due mainly to the additional overheads from the
memory
management and the interpreter, but this is extremely variable. Code of
this
kind can benefit significantly from compilation using the "gac" GAP to C
compiler (see section 3.7 of the reference manual). As soon as you do
something
which calls upon the slightly higher level capabilities of the GAP
kernel,
such as vector arithmetic, the overhead of using GAP drops away
dramatically.

The overhead of simple loops such as 

for i in [1..10000] do .... od

is very small. Special code in the interpreter detects this case and
essentially performs the equivalent C loop. On the other hand it will be
quite
a lot faster to do

w := u+ v;

than 

for i in [1..Length(u)] do w[i] := u[i]+ v[i]; od;

since the former will use a kernel routine to do all the additions
instead of
interpreting each one separately. Without seeing your code it is
difficult to
say more.

	Steve Linton



-- 
Steve Linton	School of Computer Science  &
      Centre for Interdisciplinary Research in Computational Algebra
	     University of St Andrews 	 Tel   +44 (1334) 463269
http://www.dcs.st-and.ac.uk/~sal	 Fax   +44 (1334) 463278   

_______________________________________________
Forum mailing list
Forum at mail.gap-system.org
http://mail.gap-system.org/mailman/listinfo/forum




More information about the Forum mailing list