Optimization Tools for C and C ++

What tools for Windows and Linux systems can be used to identify alignment problems, cache misses, and other parameters related to the code generated by Visual C ++ and GCC? Can I use these tools to determine the alignment of structures so that I can avoid filling with the compiler?

+5
source share
2 answers

To identify cache misses, you need a processor-level profiler, for example, oprofileor vtune, or a dynamic toolkit, for example, valgrindwith cachegrind.

To look for alignment problems in structures, there is a tool called paholefor object files with debugging information DWARF.

+3
source

If you want to avoid filling in data structures, you can use __attribute__((__packed__))for gcc or for Microsoft studio studio #pragma(pack(push,1))before declaring your structure #pragma(pop)after declaring your structure. You can also specify a command-line option for Microsoft Visual Studio compiler / Zp 1 to pack in one byte http://msdn.microsoft.com/en-us/library/xh3e3fd0(v=vs.80).aspx or using gcc -falign-function = 8 for packaging at 1 byte boundaries. Your code base will be smaller, but it can have serious negative consequences for your performance ...

+1

All Articles