[
https://issues.apache.org/jira/browse/HAMA-524?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13420400#comment-13420400
]
Edward J. Yoon commented on HAMA-524:
-------------------------------------
Mikalai, I looked at your new code but still strange to me.
Here's my row-wise access style simple code.
{code}
// Row-wise access style
public static class RowWiseAccess
extends
BSP<IntWritable, ArrayWritable, IntWritable, IntWritable, BytesWritable> {
private IntWritable[] columnVector = new IntWritable[4];
/*
* Let's assume
*
* matrix A x
* 1
* 3 -2 0 4 2
* 1 5 -1 2 x 3
* 0 4 3 1 4
*
* @see org.apache.hama.bsp.BSP#bsp(org.apache.hama.bsp.BSPPeer)
*/
@Override
public void bsp(
BSPPeer<IntWritable, ArrayWritable, IntWritable, IntWritable,
BytesWritable> peer)
throws IOException, SyncException, InterruptedException {
KeyValuePair<IntWritable, ArrayWritable> row = null;
// Read n-th row of matrix A
while ((row = peer.readNext()) != null) {
int key = row.getKey().get();
int sum = 0;
IntWritable[] rowVector = (IntWritable[]) row.getValue().get();
// calculation of the scalar product of two vectors and n - 1 summation
operations.
for(int i = 0; i < 4; i++) {
sum += rowVector[i].get() * columnVector[i].get();
}
// So, complexity is O(n).
peer.write(new IntWritable(key), new IntWritable(sum));
}
}
@Override
public void setup(
BSPPeer<IntWritable, ArrayWritable, IntWritable, IntWritable,
BytesWritable> peer)
throws IOException, SyncException, InterruptedException {
for (int i = 1; i < 5; i++) {
columnVector[i - 1] = new IntWritable(i);
}
}
}
{code}
Then, As I mentioned you before, BSP framework automatically partitions the
input data and executes each BSP task on that split.
{code}
Matrix A x
Task1
---------------------------
3 -2 0 4 1
1 5 -1 2 2
x 3
Task2 4
---------------------------
0 4 3 1
{code}
Can you understand this?
> [GSoC 2012] Sparse Matrix-Vector multiplication (SpMV) on Hama
> --------------------------------------------------------------
>
> Key: HAMA-524
> URL: https://issues.apache.org/jira/browse/HAMA-524
> Project: Hama
> Issue Type: New Feature
> Components: bsp core, examples, math
> Reporter: Edward J. Yoon
> Assignee: Mikalai Parafeniuk
> Labels: gsoc, gsoc2012, newbie
>
> Implement Efficient and Fast SpMV algorithm which can be widely used in
> scientiļ¬c computing, financial modeling, information retrieval, and others,
> using Hama Bulk Synchronous Parallel framework.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira