Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Dynamic vs Static Data

Name: Anonymous 2014-04-27 6:01

Suppose we have

#define SIZE 1024*1024*512
uint8_t dataS[SIZE];
uint8_t *dataD;
/* ... */
dataD = malloc(SIZE);


then
1. how much faster is dataS[index] over dataD[index]?
2. Will CPU's cache amend the indirection?
3. should we strive to make everything global?
4. How global variables affect multi-threading?

Name: Anonymous 2014-04-27 6:16

>>1

if one keeps dataD pointer in register, then dataD[index] will be faster than the dataS[index] access, because loading 8-byte immediate address is an expensive operation cache-wise (x86 cacheline is 64-bytes). x86 also offers more addressing modes for register base than for an immediate base.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List