Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Christian_G_1
Beginner
19 Views

TBB Android for loop accessing storage of same class vectors <std::float>


Hello everyone,

Me and a friend try to make and android app. Unfortunately the performance in a 3 staged for-loop constelation is very low. However, the forloops are mathematically not linked i.e. the i-th step in the outer for loop does not need to know what the i+1-th step's results are. However, in  this loop the same global class variable will be used which is a long 50k long vector of 3D points.

1. Question: Is it at all possible to parallelize when the loop needs the same variables in each step?
2. If it is possible, how much will the performance be degraded ( I guess sometimes the access to the points will not continously be granted since sometimes another thread might access the storage of these points?).

I do not find any information to this so you can also give me a link where I can find this.

Thanks for your help guys!


Best,
BootTooth
 

0 Kudos
6 Replies
RafSchietekat
Black Belt
19 Views

You only need to worry if the shared data is being modified by any of the threads?

Christian_G_1
Beginner
19 Views


Thanks!

The thing is that I can not set these data vector of 50k points to static/const/final because these are points to be displayed by OpenGL and sometimes I change/update them. But in the parallel loop I dont. Anway, thanks.

RafSchietekat
Black Belt
19 Views

You don't have to declare the data as const, only actions matter.

Since you have enough potential parallelism in the outer loop, only use parallel_for at that level, and normal sequential loops in the inner loops. To diagnose the problem, perhaps try simple_partitioner with various grainsize values.

(Added) Just in case: you also don't need a mutex.

Christian_G_1
Beginner
19 Views


Thx, yeah I saw not also that there are nice graphics in the Tutorial of Intel® Threading Building Blocks. Best

 

Christian_G_1
Beginner
19 Views

(Btw I have another question and posted it recently as a new post but it is not shown and its status is "DRAFT" whereas this post's status is "PUBLISHED". Whys that? Sry to write it here)

RafSchietekat
Black Belt
19 Views

Maybe it disapproves of your spelling...