On 13 Dec 2015 13:41:37 GMT
r...@zedat.fu-berlin.de (Stefan Ram) wrote:
> I have a vector filled with about 16000 unsigned ints,
> which seem to have 4 bytes each here.
>
> /* at file scope, after »using NUMBER = unsigned int;«: */
>
> ::std::vector<NUMBER> collection;
>
> I have an »inner loop«, where no new entries are added to
> the vector and the result of collection.data() is accessed
> as an array. It searches through subsets of the array, and
> therefore the accesses might be somewhat irregular (for the
> prefetcher). I wondered whether that array still fits in some
> cache.
>
> Now, I looked at the program with a stack monitor. It shows
> always (whenever probed) something like this, under Windows:
>
> ntoskrnl.exe!KeWaitForMultipleObjects
> ntoskrnl.exe!KeAcquireSpinLockAtDpcLevel
> ntoskrnl.exe!KeWaitForSingleObject
> ntoskrnl.exe!_misaligned_access
> ntoskrnl.exe!_misaligned_access
> ntoskrnl.exe!_misaligned_access
> SlowProgram.exe
> SlowProgram.exe
> SlowProgram.exe
> SlowProgram.exe
> SlowProgram.exe
> kernel32.dll!BaseThreadInitThunk
> ntdll.dll!RtlUserThreadStart
>
> What's this? My program spends most of its time to »wait
> for multiple objects«??
It's a Windows thing.
>
> I do not call »_misaligned_access« directly in my SlowProgram!
>
> Is this the processor causing an interrupt due to misaligned
> data very often?
Nope. You get align exceptions on x86 only if loading SSE vectors.
>
> I used to believe that C++ would align my vector of ints so
> that this doesn't happen.
Try with custom allocator and see.