Compare strings with SSE4 wrappers

I need to quickly compare two lines on a machine with SSE4 support. How to do this without writing assembler inserts?

Some wrappers, such as long long bitmask = strcmp(char* a, char* b) , will be ideal.

+6
source share
3 answers

Instead of using the built-in build, you should use the built-in Intel SSE features.

To compare strings, you will need the built-in functions of SSE4.2:

The documentation is here: http://software.intel.com/sites/products/documentation/doclib/stdxe/2013/composerxe/compiler/cpp-mac/GUID-6E9CFDF2-5DF6-42A4-B429-0E2CD441342E.htm

+9
source

Here is a good article on using SSE 4.2 to speed up string operations: http://www.strchr.com/strcmp_and_strlen_using_sse_4.2

0
source

Use Agner Fog asmlib. http://www.agner.org/optimize/#asmlib

He already had a problem writing code in the assembly for you, including SSE4.2 instructions. Use its A_strcmp function (or the case-insensitive version of A_stricmp ).

It would be interesting how a method using intrinsics compares in performance.

0
source

Source: https://habr.com/ru/post/915615/


All Articles