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!
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.
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.
(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)