Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How would I parallize a nested For loop in java?  RSS feed

 
Terry Coughlan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I would like some help on dividing up this problem into smaller tasks that can be processed at the same time (parallel)

for (numbers){

for(each number){
128 **This is ok**
}
for(each n, n){
128 x 128 **This is ok**
}
for(each n, n, n){
128 x 128 x 128 **Needs to be parallized from here**
}
for(each n, n, n, n){
128 x 128 x 128 x 128
}
}

I was thinking of trying to implement forkjoin or mapReduce but I'm a complete newbie and I don't know how to get started on this. Any help would be appreciated...

Thanks in advance

T
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry, I don't understand what you wrote. It doesn't make any sense. Can you show with real code or explain in English rather than whatever markup you used?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not much information to go on here as far as how compute intensive the computations are... but anyway:

If you think of your loop(s) as "job" generators, suppose you create a custom object for each job and add it to queue of jobs. One or more Threads can take a job from the queue and run it, disposing of the finished job somehow.


Bill
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!