Skip to contentSkip to conversation

GCC and Memory Organization

DISCUSSION William N. Zanatta 2 participants 5 messages Apr 9, 2002 – Apr 11, 2002

lore
Share & tools
lore
#0 lore raw

Hello brothers,

I have a question on memory organization...
In my Computer Architeture classes, I've learned something like that
there are two ways to organize data in memory.
The first one puts it in a linear mode like:

     +---------------+
12k  | z | z |   |   |
     |---------------|
8k   | y | y | z | z |
     |---------------|
4k   | x | x | x | y |
     +---------------+

And the second way is a non-linear, a block mode like:

     +---------------+
12k  | z | z | z | z |
     |---------------|
8k   | y | y | y |   |
     |---------------|
4k   | x | x |   |   |
     +---------------+

The second way should be faster than the first one for memory
management, right?! That a kindda obviuos as it wouldn't be necessary to scan all the block to find the next entry. Also it can be expensive since the 4k block is allocated for only 2k of real data.

My question is, how does GCC works with this? Does it have any switch
for optimizing (or not) the code?? What's the default action???

Thank you, keep it hard!

William Zanatta

#1 lore raw
Quoted 23 lines · William N. Zanatta

I have a question on memory organization...
In my Computer Architeture classes, I've learned something like that
there are two ways to organize data in memory.
The first one puts it in a linear mode like:

      +---------------+
12k  | z | z |   |   |
      |---------------|
8k   | y | y | z | z |
      |---------------|
4k   | x | x | x | y |
      +---------------+

And the second way is a non-linear, a block mode like:

      +---------------+
12k  | z | z | z | z |
      |---------------|
8k   | y | y | y |   |
      |---------------|
4k   | x | x |   |   |
      +---------------+
Quoted 7 lines

The second way should be faster than the first one for memory
management, right?! That a kindda obviuos as it wouldn't be necessary to scan all the block to find the next entry. Also it can be expensive since the 4k block is allocated for only 2k of real data.

My question is, how does GCC works with this? Does it have any switch
for optimizing (or not) the code?? What's the default action???

This isn't a compiler issue. The different layouts would require different source code. The former corresponds to a one-dimensional array, while the latter corresponds to a two-dimensional array.

Signature · 1 line
Glynn Clements <[email protected]>
#2 lore raw
Quoted 4 lines · Glynn Clements

This isn't a compiler issue. The different layouts would require different source code. The former corresponds to a one-dimensional array, while the latter corresponds to a two-dimensional array.

Do you know any document on the web where I can study more about this issue?

William

#3 lore raw
In reply to Glynn Clements
Quoted 5 lines

This isn't a compiler issue. The different layouts would require different source code. The former corresponds to a one-dimensional array, while the latter corresponds to a two-dimensional array.

I guess I found something. Looks like I'm talking about the concepts of segmentation and paging. Is that right? In the following site there's a interesting map for understanding the concepts of VM.

http://cne.gmu.edu/modules/vm/index.html

Thank you again,

William

#4 lore raw
Quoted 7 lines · William N. Zanatta
Quoted 4 lines

This isn't a compiler issue. The different layouts would require different source code. The former corresponds to a one-dimensional array, while the latter corresponds to a two-dimensional array.

I guess I found something. Looks like I'm talking about the concepts of segmentation and paging. Is that right?

Maybe, but segmentation and paging are only really relevant if you're designing a CPU or an OS kernel. A program just sees a flat address space.

Signature · 1 line
Glynn Clements <[email protected]>