@ Override public void start ( final VortexThreadPool vortexThreadPool ) { final List < Matrix < Double > > leftSplits = generateMatrixSplits ( numRows , numColumns , divideFactor ) ; final Matrix < Double > right = generateIdentityMatrix ( numColumns ) ; // Measure job finish time starting from here.. final double start = System . currentTimeMillis ( ) ; // Define callback that is invoked when Tasklets finish. final CountDownLatch latch = new CountDownLatch ( divideFactor ) ; final FutureCallback < MatMulOutput > callback = new FutureCallback < MatMulOutput > ( ) { @ Override public void onSuccess ( final MatMulOutput output ) { final int index = output . getIndex ( ) ; final Matrix < Double > result = output . getResult ( ) ; // Compare the result from the original matrix. if ( result . equals ( leftSplits . get ( index ) ) ) { latch . countDown ( ) ; } else { throw new RuntimeException ( index + " th result is not correct." ) ; } } @ Override public void onFailure ( final Throwable t ) { throw new RuntimeException ( t ) ; } } ; // Submit Tasklets and register callback. final MatMulFunction matMulFunction = new MatMulFunction ( ) ; for ( int i = 0 ; i < divideFactor ; i ++ ) { vortexThreadPool . submit ( matMulFunction , new MatMulInput ( i , leftSplits . get ( i ) , right ) , callback ) ; } try { // Wait until all Tasklets finish. latch . await ( ) ; LOG . log ( Level . INFO , "Job Finish Time: " + ( System . currentTimeMillis ( ) - start ) ) ; } catch ( final InterruptedException e ) { throw new RuntimeException ( e ) ; } }
Perform a simple vector multiplication on Vortex .