Help with concurrent_hash_map / parallel_for

Help with concurrent_hash_map / parallel_for

I am a noobie concerning threading, so I thought that I would start with Threading Building Blocks for my application. I 'think' I am creating things appropriately, but I am getting compilier errors (on VS 2005 - Error C2784). I am able to create the map and populate it, but I don't think I am doing the parallel iteration correctly. For instance, I 'think' I am setting the blocked_range correctly, but I am probably wrong. I have the O'Reilly book, but there isn't a concise example of what I am attempting to do, which is to basically iterate the hash map and call a method on the type T.

typedef concurrent_hash_map CollectionOfFoos;
typedef concurrent_hash_map::const_iterator FoosIterator;

struct UpdateFoos
{
float DeltaT;

UpdateFoos(float elapsed_time) : DeltaT(elapsed_time) {};

void operator()(blocked_range& range) const
{
for (FoosIterator iter = range.begin(); iter != range.end(); ++iter)
{
iter->second->update(DeltaT);
}
}
};

CollectionOfFoos Foos;
...
// populate foos - not having problem with this.
...

void updateElapsedTime(float delta_t)
{
parallel_for(blocked_range(Foos.begin(), Foos.end(), 10000), UpdateFoos(delta_t));
}

Again, I 'think' I am doing this correctly, but considering the compiler error I am obviously not. I left out StringHashCompare, but it is basically the same as the examples except for the usemy data type.

I appreciate any help, thanks!

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Quoting - scasey67
I am a noobie concerning threading, so I thought that I would start with Threading Building Blocks for my application. I 'think' I am creating things appropriately, but I am getting compilier errors (on VS 2005 - Error C2784). I am able to create the map and populate it, but I don't think I am doing the parallel iteration correctly. For instance, I 'think' I am setting the blocked_range correctly, but I am probably wrong. I have the O'Reilly book, but there isn't a concise example of what I am attempting to do, which is to basically iterate the hash map and call a method on the type T.

typedef concurrent_hash_map CollectionOfFoos;
typedef concurrent_hash_map::const_iterator FoosIterator;

struct UpdateFoos
{
float DeltaT;

UpdateFoos(float elapsed_time) : DeltaT(elapsed_time) {};

void operator()(blocked_range& range) const
{
for (FoosIterator iter = range.begin(); iter != range.end(); ++iter)
{
iter->second->update(DeltaT);
}
}
};

CollectionOfFoos Foos;
...
// populate foos - not having problem with this.
...

void updateElapsedTime(float delta_t)
{
parallel_for(blocked_range(Foos.begin(), Foos.end(), 10000), UpdateFoos(delta_t));
}

Again, I 'think' I am doing this correctly, but considering the compiler error I am obviously not. I left out StringHashCompare, but it is basically the same as the examples except for the usemy data type.

I appreciate any help, thanks!

After reading through a bunch of posts I had come across this:
http://software.intel.com/en-us/forums/showpost.php?p=51548

I had used the search function, but the thread abovedidn't come up for me.

Question answered.

Leave a Comment

Please sign in to add a comment. Not a member? Join today