Re: Unicode (UCS2) string length using SSE2
Posted: Tue Aug 19, 2014 5:26 am
Thanks everyone again for testing
It's nice to see there's so much room for speed improvement using SSE2 instructions compared to the default implementation.
It probably is possible in a similar way to also create faster unicode versions of procedures like Mid or FindString.
Even with non aligned strings, it should perform similar to the first version.
Normally when memory is allocated, it always is allocated on a DWord (4 byte) boundary which of course is also a Word boundary.
So I presume all PB strings with the .s type will be aligned. Maybe Fred can confirm this.
The thing is that PB supports non aligned structures. The code below is an example where the fixed length string is not aligned on a Word boundary.

It's nice to see there's so much room for speed improvement using SSE2 instructions compared to the default implementation.
It probably is possible in a similar way to also create faster unicode versions of procedures like Mid or FindString.
If you want to use this, I recommend using the second version since in almost every case it is faster compared to my first attempt.Tenaja wrote:Is there a way to force (or ensure) string alignment on the Word boundaries? Fred?
Even with non aligned strings, it should perform similar to the first version.
Normally when memory is allocated, it always is allocated on a DWord (4 byte) boundary which of course is also a Word boundary.
So I presume all PB strings with the .s type will be aligned. Maybe Fred can confirm this.
The thing is that PB supports non aligned structures. The code below is an example where the fixed length string is not aligned on a Word boundary.
Code: Select all
Structure MyStruct
a.a
s.s{20}
EndStructure
Debug @A.MyStruct\s