What is the best solution if I just want to parallelize the loop only and sequential saving to file using openmp. I have a file with a large volume of information I would like to split into equal chunks (16 bytes each) , encrypted using openmp (multithreading programming in C++). After completion of encryption process these chunks store in a single file, but the same sequence of the original.
i_count=meta->subchunk2_size-meta->subchunk2_size%16;// TO GET THE EXACT LENTH MODE 16
// Get the number of processors in this system
int iCPU = omp_get_num_procs();
// Now set the number of threads
omp_set_num_threads(iCPU);
#pragma omp parallel for ordered
for( i=0;i<i_count;i+=16)
{
fread(Store,sizeof(char),16,Rfile);// read
ENCRYPT();
#pragma omp ordered
fwrite(Store,sizeof(char),16,Wfile) // write
}
The program it supposed works parallel but the saving to file work sequential, but the implementation of the program shows it work in sequential order.