PageRank

From CSE231 Wiki
Jump to navigation Jump to search

Page Rank studio will someday replace the Iterative_Averaging studio.

PageRank

parallel

for (int iteration : new IntegerRange(0, iterationCount)) {
	forall(slices, (slice) -> {
		PageRank[] arrayPrev = ((iteration & 1) == 0) ? a : b;
		PageRank[] arrayNext = ((iteration & 1) == 0) ? b : a;
		slice.forEachIndex((index) -> {
                 	arrayNext[index] = calculateNextRank(index, arrayPrev);
          	});
	});
}

parallel phased

Phaser phaser = new Phaser();
phaser.bulkRegister(slices.size());
forall(slices, (slice) -> {
	for (int iteration : new IntegerRange(0, iterationCount)) {
		PageRank[] arrayPrev = ((iteration & 1) == 0) ? a : b;
		PageRank[] arrayNext = ((iteration & 1) == 0) ? b : a;
		slice.forEachIndex((index) -> {
                 	arrayNext[index] = calculateNextRank(index, arrayPrev);
          	});
		phaser.arriveAndAwaitAdvance();
	}
	// note: arriveAndDeregister not required for this application
	phaser.arriveAndDeregister();
});