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.
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!
Thats really very, very true.
Global variables are not worth all the trouble and won't help that much in performance terms.
>>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.