I am trying to write my first program, using Open MP. I must search in a text using different number of threads. In order to find matches I must divide my text so that if i am searching for example the word "book" in the text "I like to read a book" thread 1 takes "I like " and searchs, thread 2 takes "to read " and thread 3 take "a book". No one thread takes a part of the word. How can I do this according to my code?
Here is my C++ code:
vector <unsigned int> bitmask; vector <unsigned long> hits ; int length = T.length; unsigned int D=0; unsigned int i,pos; #pragma omp parallel for private(pos,i),shared (length,bitmask,D), firstprivate(hits) for (i=0;i<T.length();++i){ pos = istword (T[i],P,length); D = (((D<<1)|1) & bitmask [pos]); #pragma omp critical if(D & (1 << length - 1)){ hits.push_back(i-length+2); } }
Thank you!