- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bryan,
I also referred you to other books at Intel Press and the technical optimization center. Did you look there already?
Aart Bik
http://www.aartbik.com/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Bryan,
Vectorization can onlyspeedup repetitive operations (typically detected in loops, but occasionally also detected in straight-line code). Just judging from the description of your application, I agree that this is probably not the right optimization for you.
I can recommend The Software Optimization Cookbook from Intel Press and The Intel Architecture Optimization Reference Manual from the IntelTechnicalDocumentationCenter. These books do not explicitly give many C++ programming guidelines, but together give you very good insights on how to optimize for IA32.
Aart Bik
http://www.aartbik.com/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The only reason that local variables in the struct are faster is because of the way the cache system works. When you are executing code and accessing data very close to each other, the cache system doesn't have to reach far away to grab the data you are looking for, increasing the rate at which your code executes. Global Variables are stored next to each other in system memory. Your structs may or may not be next to eachother based on when you allocate memory for them in your program. If the data you are looking for is in your struct and not off 100 MB somewhere else in a global variable then it can all be stored in cache and executed very efficiently. Someone tell meI'm wrong. And in general, global variables are messy when editing your source code and functions. Why reach up 200 lines of code to remember what you called a variable. Your functions shouldn't be depending so much on global variables. Even use a static variable inside your structs just to get away from them!
Ryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thats really very, very true.
Global variables are not worth all the trouble and won't help that much in performance terms.
lg Clemens
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>I have tested all of them using clock function. It shows that global variables and member variable inside struct are the same speed, but member variables and member functions inside classes are slower than global variables and global functions. <<
Another thought... member variables require two memory accesses. One for the object and another for the variable offset.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page