I'm a little new to OpenMP, but I have experience with parallel processing in general. I have worked with boost::threadsbefore and now I am testing openmp.
The problem is that I don’t know how to handle access to shared data, because I really don’t know what openmp does internally with shared data objects inside parallel loops.
What I'm doing right now (while this works): I read files from disk to memory using mmap. I get a pointer to char after part of the memory card.
OpenMP can now use this pointer inside an OpenMP loop to loop and share data between threads. Now I can search for regular expression matches within the matched and shared file with multiple threads by checking each line for a (fairly long) list of regular expressions.
I made this list (a vector containing a regular expression) closed inside the openmp loop, so each thread has its own copy of this list.
This is where the problem arises:
To dramatically increase the performance of my application, I need to be able to remove (regex-) elements from this vector when they match the string.
Now all other active threads should also remove this item from their list.
So, I made this list a shared data object inside the openmp loop, but now I get segmentation errors at runtime when I try to write (vector.erase (item #)) to the list.
With boost :: threads, I would just use a mutex to lock this object while writing / reading.
openmp, , , , openmp, .