There is my question:
I have many files (more than 1000) of the same size (several Mb). I have to read them and extract some information. This step of the information extraction requires some time, so I can use (at least I hope so) this time to read another file. What I try to do is:
#pragma omp parallel for
for (int i=0; i<FilesCount; i++)
{
myData Data;
#pragma omp critical
{
Data.ReadDataFromFile (FileNames[i]);
}
//Operate with the Data and extract some information
}
It doesn't work as I expect. I also tried to use:
#pragma omp ordered
and the result is the same - only one thread is used.
Other OpenMP
stuff works fine. Maybe the problem is that I use fstream
for the reading?
What is the problem with it and how to do that correctly?