Boost logo

Boost Users :

Subject: [Boost-users] Private unordered map in openMP
From: MeMooMeM (mbelgin_at_[hidden])
Date: 2009-08-21 18:09:35


Hi everyone,

I am trying to assign one private unordered map per thread. As you know, I
cannot declare a new array inside the parallel section and make it private.
So I declared a map:

typedef boost::unordered_map<int, int> Map_t;
...
Map_t localMap;

and passed it to the parallel section as private (please see
http://www.nabble.com/file/p25088091/doesnotwork.cc doesnotwork.cc )

#pragma omp parallel default(shared) private(iam, i, localMap)
{
  ...
}

I got the following error:

openmptry.cc: In function ‘int main(int, char**)’:
openmptry.cc:0: internal compiler error: in lower_stmt, at gimple-low.c:282
Please submit a full bug report,
...
...

I can solve this problem by declaring a map pointer, creating local copies
using 'new' and changing

"++(*localMap)[iam]" to "++localMap[iam]"
"localMap->begin()" to "localMap.begin()"

etc... (please see http://www.nabble.com/file/p25088091/works.cc works.cc )
 
But these changes will require lots of editing in the code. So, is there a
way to use the map directly?

Thanks so much in advance!

PS: desired output for these test codes is (in arbitrary order):

2: 2 -> 1
7: 7 -> 1
5: 5 -> 1
6: 6 -> 1
4: 4 -> 1
1: 1 -> 1
3: 3 -> 1
0: 0 -> 1

 

-- 
View this message in context: http://www.nabble.com/Private-unordered-map-in-openMP-tp25088091p25088091.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net