Skip to content

Commit

Permalink
[SYSTEMDS-3172] Cleanup new MCSC sparse block, new tests
Browse files Browse the repository at this point in the history
Closes #2049.
  • Loading branch information
ReneEnjilian authored and mboehm7 committed Jul 14, 2024
1 parent f81b76d commit e6eebb9
Show file tree
Hide file tree
Showing 16 changed files with 776 additions and 459 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/apache/sysds/runtime/data/SparseBlockCOO.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,15 @@ public int size(int r) {
public long size(int rl, int ru) {
return pos(ru) - pos(rl);
}

@Override
public long size(int rl, int ru, int cl, int cu) {
long nnz = 0;
for(int i=rl; i<ru; i++)
if( !isEmpty(i) ) {
for(int i = rl; i < ru; i++)
if(!isEmpty(i)) {
int start = internPosFIndexGTE(i, cl);
int end = internPosFIndexGTE(i, cu);
nnz += (start!=-1) ? (end-start) : 0;
int end = internPosFIndexLTE(i, cu - 1);
nnz += (start != -1 && end != -1) ? (end - start + 1) : 0;
}
return nnz;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,11 @@ public long size(int rl, int ru) {
@Override
public long size(int rl, int ru, int cl, int cu) {
long nnz = 0;
for(int i=rl; i<ru; i++)
if( !isEmpty(i) ) {
for(int i = rl; i < ru; i++)
if(!isEmpty(i)) {
int start = internPosFIndexGTE(i, cl);
int end = internPosFIndexGTE(i, cu);
nnz += (start!=-1) ? (end-start) : 0;
int end = internPosFIndexLTE(i, cu - 1);
nnz += (start != -1 && end != -1) ? (end - start + 1) : 0;
}
return nnz;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ public static SparseBlock createSparseBlock(SparseBlock.Type type, SparseRow row
return ret;
}

public static SparseBlock copySparseBlock( SparseBlock.Type type, SparseBlock sblock, boolean forceCopy )
public static SparseBlock copySparseBlock(SparseBlock.Type type, SparseBlock sblock, boolean forceCopy) {
//Call this method in case 'type' is row format
return copySparseBlock(type, sblock, forceCopy, 1000); // Default clen value
}

public static SparseBlock copySparseBlock( SparseBlock.Type type, SparseBlock sblock, boolean forceCopy , int clen)
{
//sanity check for empty inputs
if( sblock == null )
Expand All @@ -65,7 +70,7 @@ public static SparseBlock copySparseBlock( SparseBlock.Type type, SparseBlock sb
case CSR: return new SparseBlockCSR(sblock);
case COO: return new SparseBlockCOO(sblock);
case DCSR: return new SparseBlockDCSR(sblock);
case MCSC: return new SparseBlockMCSC(sblock);
case MCSC: return new SparseBlockMCSC(sblock, clen);
default:
throw new RuntimeException("Unexpected sparse block type: "+type.toString());
}
Expand Down
Loading

0 comments on commit e6eebb9

Please sign in to comment.