Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenMP share file handler
    text
    copied!<p>I've got a loop, which I parallelize using OpenMP. In this loop, I read a triangle from a file, and perform some operations on this data. These operations are independent from each triangle to another, so I thought this would be easy to parallelize, as long as I kept the actual reading of files in a critical section.</p> <ul> <li>Order in which triangles are read is not important</li> <li>Some triangles are read and get discarded pretty quickly, some need some more algorithmic work (bbox construction, ...)</li> <li>I'm doing binary I/O</li> <li>Using C++ ifstream *tri_data*</li> <li>I'm testing this on an SSD</li> </ul> <p>ReadTriangle calls file.read() and reads 12 floats from an ifstream.</p> <pre><code>#pragma omp parallel for shared (tri_data) for(int i = 0; i &lt; ntriangles ; i++) { vec3 v0,v1,v2,normal; #pragma omp critical { readTriangle(tri_data,v0,v1,v2,normal); } (working with the triangle here) } </code></pre> <p>Now, the behaviour I'm observing is that with OpenMP enabled, the whole process is slower. I've added some timers to my code to track time spent in the I/O method, and time spent in the loop itself.</p> <p>Without OpenMP: </p> <pre><code>Total IO IN time : 41.836 s. Total algorithm time : 15.495 s. </code></pre> <p>With OpenMP: </p> <pre><code>Total IO IN time : 48.959 s. Total algorithm time : 44.61 s. </code></pre> <p>My guess is, since the reading is in a critical section, the threads are just waiting for eachother to finish using the file handler, resulting in a longer waiting time.</p> <p>Any pointers on how to resolve this? My program would really benefit from the possibility to process read triangles with multiple processes. I've tried toying with thread scheduling and related stuff, but that doesn't seem to help a lot in this instance.</p> <p>Since I'm working on an out-of-core algorithm, introducing a buffer to hold a multitude of triangles is not really an option.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload