- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The point is that Find function just returns the first match position in a text, e.g:
pos: 0123456789abcdef0
pattern to search: urfi
As far as I know (*1), processors with SSE4.2 technology have 16-byte registers and they can work in parallel in the pattern matching process, as shown below:
<-- 16 bytes -->
Text: Surfing n Turfin
result: 0100000000010000
That is, Find function returns just first position but actually the processor knows all matched positions in 16-byte length.
So, I think it could be more efficient if there would be any function that would return all matched positions.
My questions are the next:
- Does anyone know if there is any function that works on that way?
- If not (and maybe is outside the scope of this forum), how could I create my own function to achieve that goal? Is there any Intel tool to create custom functions? Would either FASM or NASM be a good option?
http://softwarecommunity.intel.com/userfiles/en-us/d9156103.pdf
http://www.strchr.com/strcmp_and_strlen_using_sse_4.2
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is a description of an algorithm for a "Hash" like approach for finding all Sub-strings in a String:
For example,
Input String ( IS ) : "000123000123000123000"
Search Sub-string ( SS ): "123"
0. If len(SS) > len(IS) there are no Sub-strings and go to 11
1. Allocate an Array for Positions of 1st characters of all Found Sub-strings ( APFS )
( Estimated length is: ( len(IS) / len(SS) ) + some number of guard bytes )
2. Calculate a Hash for the Search Sub-string "123" ( HSS ): HSS = '1'+'2'+'3' = 49+50+51 = 150
3. Calculate a Hash for a Current Sub-string ( HCS ): HCS = '0'+'0'+'0' = 48+48+48 = 144
4. Compare HSS and HCS
5. If equal, save in APFS a position of the 1st character of the found Sub-string in the IS and advance for len(SS) characters
6. End of the Input String ( IS )? If Yes, go to step 9. If Not, continue processing
7. Calculate a Hash for a new Current Sub-string: HCS = HCS - < CS[0] > + < IS[next-char] > = 144-'0'+'1'= 144-48+49 = 145
8. Go to step 4
9. Do all the rest processing with found Sub-strings ( use APFS )
10. Release memory of APFS
11. Done
Notes:
- This is almost a Classic or a Book like approach
- Could be implemented with SSE
- Could be done in parallel for very long input strings
- Since this is your College Project I can't provide the source codes for the algorithm, but
I could help you with a review, tune-ups, etc. You could switch to aprivate posting if you wish.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page