Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
3 Views

Is enumerable thread specific the right choice here?

Hi,

I've got a vector with id's of particles objects [from a preexistent class Particle, that has a private attribute called next_event. It stores the id of the next particle that is scheduled to collide]. What I want is to simulate the effects of the collisions of these particles locally and, when finished, check if there are any inconsistencies between them and update the global state.

I was planning to simulate each particle collision in a task, saving the results in, for example, tbb::enumerable_thread_specific> and using continuation-passing style, where the continuation would do the check_and_save job.

So, my question is if it is possible to rejoin the local data of each task into a new vector in the continuation. Or should it be done in a global process outside a task?

Sorry if you don't understand a thing, I tried to explain it as clear as I could (also sorry about my english).

Thanks.
0 Kudos
5 Replies
Highlighted
3 Views

Have you considered creating a shared vector of thread_specific vectors, where each thread uses TLS to remember its own thread_specific vector.

Jim Dempsey

0 Kudos
Highlighted
Beginner
3 Views

I don't clearly get it...
Each thread has ETS vector, which is stored in the global shared vector. Is that it?

Thanks!
0 Kudos
Highlighted
3 Views

Yes, or they can have an allocated standard template library vector (since it is not shared other than for collation).

Jim
0 Kudos
Highlighted
Beginner
3 Views

Ok!! I'll give it a try!

Thanks Jim!!
0 Kudos
Highlighted
3 Views

Have you considered creating a shared vector of thread_specific vectors, where each thread uses TLS to remember its own thread_specific vector.

This is what class enumerable_thread_specific< vector >does, basically; it is a shared container of thread-local instances.
0 Kudos