Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

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

Christian_G_1
Beginner
714 Views


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
Valued Contributor III
714 Views

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

0 Kudos
Christian_G_1
Beginner
714 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.

0 Kudos
RafSchietekat
Valued Contributor III
714 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.

0 Kudos
Christian_G_1
Beginner
714 Views


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

 

0 Kudos
Christian_G_1
Beginner
714 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)

0 Kudos
RafSchietekat
Valued Contributor III
714 Views

Maybe it disapproves of your spelling...

0 Kudos
Reply