9 Replies Latest reply: Apr 6, 2006 12:00 AM by DrClap RSS

    Parallelism and Threads

    843853
      With the advent of multi-core CPUs with potentially hundreds or thousands of cores introduced over the next 10 years, I don't feel we currently have the software technology to take advantage of this hardware.

      Whilst the Java thread model is quite reasonable for simple multi-threaded designs, it is impossible (or difficult) to use it for detailed processes where multi-core/multi-SPE processors could provide benefits. Such examples are divide and conquer algorithms or highly parallel graphics algorithms.

      For example, we could have a "fork" loop which spawns a thread for each instance of the loop variables (int this case i=0..numPixels) if the contents of the loop are known to be mutually exclusive. Load-balancing and end-of-loop joining would be automatically performed.

           fork(int i=0;i<numPixels;i++)
           {
                drawPixel(i);
           }


      We seriously require language extensions along the lines of "Clik" (or JCilk) and possibly more.

      The question is... when is this going to happen???!!!
        • 1. Re: Parallelism and Threads
          843853
          I should note - the suggested "fork" loop (or similar) would transparently take advantage of available cores so if, for example, you had 16 cores then only 16 instances of the internal code would be executed at one time. This is difficult to emulate in the current Thread model.
          • 2. Re: Parallelism and Threads
            843853
            I should note - the suggested "fork" loop (or
            similar) would transparently take advantage of
            available cores so if, for example, you had 16 cores
            then only 16 instances of the internal code would be
            executed at one time. This is difficult to emulate in
            the current Thread model.
            Now that you mention this, I think it has merit but I doubt that it will be part of the Java language syntax. Perhaps one of the contenders for a 'next generation' langauge might benefit from some sort of syntax based thread handling.

            But for Java, a class could be written (if it is not already) that implements functional-style methods with the kind of functionality you are proposing.
            • 3. Re: Parallelism and Threads
              843853
              It could be written, but not in one line, like my amazing "fork" loop!
              I feel we need a next generation language soon...
              • 4. Re: Parallelism and Threads
                843853
                Although I should point out that this has already been (unofficially) implemented in the "JCilk" project which could possibly merit a merge into the official Java implementation.
                • 5. Re: Parallelism and Threads
                  843853
                  It could be written, but not in one line, like my
                  amazing "fork" loop!
                  Yours? Amazing?
                  I feel we need a next generation language soon...
                  There are Java based next-gen languages now/ See nice and scala.
                  • 6. Re: Parallelism and Threads
                    843853
                    Currently, these constructs are where they belong: research languages. There's still a long way to go before things like this should be put into a... uh what would you call it?... err, "pragmatically practical" (just made that up) language like Java.
                    • 7. Re: Parallelism and Threads
                      DrClap
                      Yeah, that would be like making COBOL object-oriented. Well, okay, they did do that but it took them 40 years to get there.
                      • 8. Re: Parallelism and Threads
                        843853
                        Yours? Amazing?
                        Have you ever seen a "fork loop" before? - "fork", yes - but not the amazing "fork loop"! Anyway, it doesn't matter...!

                        Thanks for pointing out Nice and Scala. I had a quick look at Nice and it looks like a vast improvement over Java - I think I'll have a play around with it. I was quite surprised, it even includes "Optional types" which I suggested should be added to Java in my other thread Syntax of new and null and with virtually the same syntax - nice.

                        Cheers.
                        • 9. Re: Parallelism and Threads
                          843853
                          Yours? Amazing?
                          Have you ever seen a "fork loop" before? - "fork",
                          yes - but not the amazing "fork loop"! Anyway, it
                          doesn't matter...!
                          I thought you said it came from that research paper. In any event it's a clever name but not terribly intuitive. I like it though.