Difference between revisions of "PageRank"

From CSE231 Wiki
Jump to navigation Jump to search
(Created page with "Page Rank studio will someday replace the Iterative_Averaging studio.")
 
 
Line 1: Line 1:
 
Page Rank studio will someday replace the [[Iterative_Averaging]] studio.
 
Page Rank studio will someday replace the [[Iterative_Averaging]] studio.
 +
==PageRank==
 +
 +
<math>PR(u) = \sum_{v \in B_u} \frac{PR(v)}{L(v)}</math>
 +
 +
===parallel===
 +
<nowiki>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);
 +
          });
 +
});
 +
}</nowiki>
 +
 +
===parallel phased===
 +
<nowiki>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();
 +
});
 +
</nowiki>

Latest revision as of 12:10, 14 April 2019

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();
});