GCC and Memory Organization
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
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]>
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
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
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]>