I want to choose the integer on which calculations will perform fastest.I thought that PtrInt would always be the best choice.So, as a start, I wrote this:Code: Pascal [Select][+][-]type // fastest integer, but at least 32-bit: IntFast32 = {$if SizeOf(Pointer) <= 4}Int32{$else}PtrInt{$endif}; UIntFast32 = {$if SizeOf(Pointer) <= 4}UInt32{$else}PtrUInt{$endif}; // fastest, at least 16-bit: IntFast16 = {$if SizeOf(Pointer) <= 2}Int16{$else}IntFast32{$endif}; UIntFast16 = {$if SizeOf(Pointer) <= 2}UInt16{$else}UIntFast32{$endif}; However, I am not sure any more, as I read somewhere that on 64-bit CPU's, 32-bit integer is still the fastest.
I want to choose the integer on which calculations will perform fastest.
The fasted integer type is the native type for the CPU. That's all there is to it.
Please note that your check for the size of Pointer in the 16-bit case is not entirely correct as the size depends on the selected memory model (on i8086 obviously) and thus you might have a pointer type of size 4 on a 16-bit system (e.g. in Huge memory model). Thus your IntFast16 would be IntFast32 there which would not be the fastest type.
8 bit integer needs 4 times less cache space then 32 bit integer.
Quote from: Thaddy on August 09, 2019, 09:12:12 amThe fasted integer type is the native type for the CPU. That's all there is to it.No.If we talking about performance then the fastest integer is the smallest.8 bit integer needs 4 times less cache space then 32 bit integer.And L1 cache is ~80 times faster then memory.
I put 50$, that you can't write a faster code of processing buffer of integers than mine.I mean two buffers of the same amount of elements but one contain 8 bit int and another 32 bit integers.(arch x86)
Quote from: LemonParty on August 10, 2019, 12:06:58 pmI put 50$, that you can't write a faster code of processing buffer of integers than mine.I mean two buffers of the same amount of elements but one contain 8 bit int and another 32 bit integers.(arch x86)The code already is avx2 ?
The code already is avx2 ?