• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How would I parallize a nested For loop in java?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic