NVIDIA Interview Question
Software Engineer / DevelopersPadding causes accessing of the memory which is aligned on the word boundary of the underlying processor.
This has following benefits:
a.Performance increases as the number of instruction cycles required are reduced due to alignment since CPU always performs read/write on its word size.
b.CPU can operate on the aligned word boundary atomically, meaning without any interruptions.
c.On processors which don't support unaligned access, it would result in it crash (but most of the compilers take care of the padding to meet the alignment requirements)
Padding is done to fast access the memory.Let us take ex of structure padding.
- Piyush August 08, 2009In it , structure members are aligned to be based on the memory pointer size.
If word size is 4 bytes then data should be read at the offset of multiple of 4.