3

I have gcc version 5.4.0 20160609. I try to parallize this loop below, but it doesn't want to work proprely. I tried to used examples from the internet, but wasn't helpful. How should it look like?

void Text::readText(){
    std::cout<<"start reading"<<std::endl;
    omp_set_num_threads(2);

    #pragma omp parallel
    {
      std::list<std::string>::iterator it;

     #pragma omp for
      for (it = listOfWordsFromText.begin(); it!=listOfWordsFromText.end(); it++)
      {
        std::cout << *it << " thread: "<<omp_get_thread_num()<< std::endl; 
      }
}
}

Text.cpp:41:3: error: invalid controlling predicate for (it = listOfWordsFromText.begin(); it!=listOfWordsFromText.end(); it++)

EDIT: I can use OpenMP 4.5(i think so), version 2.0 is not up-to-date

Xalion
  • 623
  • 9
  • 27
  • 3
    Possible duplicate of [How do I parallelize a for loop through a C++ std::list using OpenMP?](https://stackoverflow.com/questions/8691459/how-do-i-parallelize-a-for-loop-through-a-c-stdlist-using-openmp) – 1201ProgramAlarm Jan 03 '18 at 20:22

0 Answers0