I'm writing a program that reads huge file (3x280 GB) and does a fitting procedure to the data in the file. It's pretty convenient to parallelise such a program, where this is easily done with OpenMP.
The thing I don't understand is how private variables are taken in OpenMP. As we all know, fstream's obejcts are a non-copyable, and intiuitively, that prevented me from using it as a private object. So the reader of the file was shared.
I got some problem later, and I thought of trying have fstreams as private, ... and guess what? it worked!!! How could this be possible?! if the object is non-copyable, how could OpenMP use different copies of the same object for each kernel?
This is how my program looks like:
fstream dataReaderX(Dirs[0].c_str(), ios::in | ios::binary);
fstream dataReaderY(Dirs[1].c_str(), ios::in | ios::binary);
fstream dataReaderZ(Dirs[2].c_str(), ios::in | ios::binary);
#pragma omp parallel num_threads(cpus_num) shared(...) private(...,dataReaderX,dataReaderY,dataReaderZ)
{
...
}
Thank you.