[Top][All Lists]

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

Stack speed access

From: j8fx
Subject: Stack speed access
Date: Wed, 15 Nov 2000 01:41:05 GMT

Hi all:

My name is Alan and I have a question that I need some help from all
great minds in this forum.

The question are as follow:


Platform 1 = Pentium 600 ,Win NT 4.0 + SP4 , Visual C++ 6.0
Platform 2 = Pentium 600, Suse Linux 6.4 , GCC compiler 2.95.2 with
optimize flag '-O2' set.

I have programmed the following code for a small test and run it on two
different platform as stated above.


        unsigned long bigArray1[500];
        unsigned long bigArray2[500];
        unsigned long bigArray3[500];
        unsigned long bigArray4[500];
        unsigned long bigArray5[500];
        unsigned long bigArray6[500];
        unsigned long bigArray7[500];
        unsigned long bigArray8[500];
        unsigned long i;

        for (i=0;i<500;i++) {
                bigArray2[i] = bigArray1[i] + i;
                bigArray3[i] = bigArray2[i] + bigArray1[i];
                bigArray4[i] = bigArray3[i] + bigArray2[i];
                bigArray5[i] = bigArray4[i] + bigArray3[i];
                bigArray6[i] = bigArray5[i] + bigArray4[i];
                bigArray7[i] = bigArray6[i] + bigArray5[i];
                bigArray8[i] = bigArray7[i] + bigArray6[i];

The results is as follow:
MS Visual C++ =  ~900ms
Linux with GCC = ~2000ms

We then change the declaration of these arrays to "static" and rerun
the test, the result are as follow:

MS Visual C++ =  ~900ms
Linux with GCC = ~950ms

We have isolated the problem to be "access speed to locally defined
automatic arrays" i.e. stack access speed. Our arrays are typically 1
KB in size and we use lots of them in our functions. As shown above, we
ran some timing tests for simple manipulation of arrays cells and found
that arrays defined as "automatic" ran significantly slower than arrays
defined as "static". This has caused our program to crawl in certain
instances when arrays are constantly being pushed and popped from the
stack. Is there a way to configure Linux to be more efficient in this
regard, or possibly we have missed something in GCC?

Any help would be much appreciated here. Thank you for your time.


Sent via Deja.com http://www.deja.com/
Before you buy.

reply via email to

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