Answer the question
In order to leave comments, you need to log in
What is the best way to parallelize the search for a substring in a string?
Task: To parallelize the search for a substring in a string.
If you use a trivial algorithm (apply a pattern to all places in the string), then you can parallelize it by distributing the intervals over the streams (for example, 1 stream - apply to 1..4 positions, 2 stream - 5..8 positions, etc.). What other substring search algorithms can also be parallelized? (I do not want to use the trivial method)
Development tools: C, POSIX Threads.
Answer the question
In order to leave comments, you need to log in
yes IMHO any. the smaller the amount of text for the search, the better (after all, you hardly want to parallelize this for a 16 character string)
Look, calculate the optimal number of threads on Windows = the number of cores.
Analyze search speed in strings of different lengths. It may be that it will be faster than with parallelization.
And based on this, depending on the length, parallelize the lines or do not parallelize them. It depends on what will be faster, because it also takes time to select a stream.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question