With the proliferation of multi-core possessors, having a way to use
all the CPU's is necessary. The academic/scientific communities have enjoyed vector processors for
decades. They have multi-tasked their needs with FORTRAN and specialized
languages almost from the beginning.
The general application development community can also participate in this most
difficult endeavor with the Java language.
Fork-Join
What is Fork-Join? Think of a fork in the road where each path eventually comes back
together - joins.
Fork-Join breaks your application into several parts for parallel
processing and joins the results at the end.
Let’s say we have an array of one thousand numbers. We need to do a
procedure on each of these numbers and add the total.
for (int i = 0; i <
1000; i++) {
total += array[i].doProcedure();
} |
If the procedure takes one second to complete, then it is going to take
one thousand seconds (over 16 ½
minutes) to complete this task.
Fork-Join could
- fork the large array into ten arrays of one hundred elements each,
- processes each array on a separate CPU and
- join the results when finished.
That would take one hundred seconds (just over 1
½ minutes)-- one tenth of the original time.
The more CPU's available, the faster the result.
One of the additions to the java.util.concurrent packages coming in
Java 7 is an API for Fork-Join style parallel decomposition. This
API makes it feasible to dynamically break large arrays into segments for
processing on separate CPU's.
What if you don't have an array? What if you have an application that
could benefit from processing different parts in parallel? Welcome to Tymeac.
Tymeac
Tymeac uses Fork-Join as part of a distributed computing system, not an
API.
A difference between Tymeac and the Fork-Join API mentioned
above is that Tymeac cannot dynamically separate your application into
parts. You need to pre-define the parts to Tymeac. Tymeac can fork your
application. When each part finishes, Tymeac joins the result
together.
You can process a large array in Tymeac by breaking it into parts. If
you have four CPU's available, you can have four Queues that each work on
one quarter of the array. The difference is that Tymeac is static. You
must plan in advance for whatever environment you may need.
Would you like to see it work and compare it to the new Fork-Join
package? We provide a demonstration for early
adapters.
On the other hand, Tymeac is not restricted to any single use. If you
have an application that uses different databases
and it would benefit from parallel decomposition, than Tymeac is your
choice.