0 Replies - 1180 Views - Last Post: 08 December 2012 - 03:36 PM Rate Topic: -----

#1 Scarlet69  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-December 12

Open MP

Posted 08 December 2012 - 03:36 PM

Hi, all!
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!

Is This A Good Question/Topic? 0
  • +

Page 1 of 1