Skip to content

Commit e5943a3

Browse files
committed
debug setupSparseThreadLocalMem
1 parent c086be7 commit e5943a3

File tree

2 files changed

+28
-33
lines changed

2 files changed

+28
-33
lines changed

src/main/java/org/apache/sysds/runtime/codegen/LibSpoofPrimitives.java

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,7 +2195,7 @@ public static SparseRowVector vectMultWrite(int len, double bval, double[] a, in
21952195
return vectMultWrite(len, a, bval, aix, ai, alen);
21962196
}
21972197

2198-
//version with branching
2198+
//old version with branching (not used)
21992199
public static SparseRowVector vectMultWriteB(int len, double[] a, double[] b, int[] aix, int[] bix, int ai, int bi, int alen, int blen) {
22002200
SparseRowVector c = allocSparseVector(Math.min(alen, blen));
22012201
if( a == null || b == null ) return c;
@@ -2279,7 +2279,7 @@ public static SparseRowVector vectDivWrite(int len, double bval, double[] a, int
22792279
return c;
22802280
}
22812281

2282-
//version with branching
2282+
//old version with branching (not used)
22832283
public static SparseRowVector vectDivWriteB(int len, double[] a, double[] b, int[] aix, int[] bix, int ai, int bi, int alen, int blen) {
22842284
SparseRowVector c = allocSparseVector(alen);
22852285
int aItr = ai;
@@ -3318,31 +3318,6 @@ public static SparseRowVector vectSignWrite(int len, double[] a, int[] aix, int
33183318
return c;
33193319
}
33203320

3321-
//todo MatrixMult, pow2 and mult2 drafts
3322-
// public static SparseRowVector vectMatrixMult(int len, double[] a, double[] b, int[] aix, int[] bix, int ai, int bi, int alen, int blen) {
3323-
// //note: assumption b is already transposed for efficient dot products
3324-
// int m2clen = b.length / len;
3325-
// SparseRowVector c = allocSparseVector(m2clen);
3326-
// for(int i = 0; i < m2clen; i++) {
3327-
// c.set(bix[i], LibMatrixMult.dotProduct(a, aix, ai, alen, b, bix, bi, blen));
3328-
// }
3329-
// return c;
3330-
// }
3331-
//
3332-
// public static SparseRowVector vectPow2Write(int len, double[] a, int[] aix, int ai, int alen) {
3333-
// SparseRowVector c = allocSparseVector(len);
3334-
// for(int j = 0; j < ai+alen; j++)
3335-
// c.set(aix[j], a[j] * a[j]);
3336-
// return c;
3337-
// }
3338-
//
3339-
// public static SparseRowVector vectMult2Write(int len, double[] a, int[] aix, int ai, int alen) {
3340-
// SparseRowVector c = allocSparseVector(len);
3341-
// for(int j = 0; j < ai+alen; j++)
3342-
// c.set(aix[j], a[j] + a[j]);
3343-
// return c;
3344-
// }
3345-
33463321
//complex builtin functions that are not directly generated
33473322
//(included here in order to reduce the number of imports)
33483323

src/main/java/org/apache/sysds/runtime/codegen/SpoofRowwise.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public MatrixBlock execute(ArrayList<MatrixBlock> inputs, ArrayList<ScalarObject
189189
//setup thread-local memory if necessary
190190
if( allocTmp &&_reqVectMem > 0 )
191191
if(inputs.get(0).isInSparseFormat() && DMLScript.SPARSE_INTERMEDIATE) {
192-
LibSpoofPrimitives.setupSparseThreadLocalMemory(_reqVectMem, n/2, n2);
192+
LibSpoofPrimitives.setupSparseThreadLocalMemory(_reqVectMem, n, n2);
193193
LibSpoofPrimitives.setupThreadLocalMemory(_reqVectMem, n, n2);
194194
} else {
195195
LibSpoofPrimitives.setupThreadLocalMemory(_reqVectMem, n, n2);
@@ -442,7 +442,12 @@ public DenseBlock call() {
442442

443443
//allocate vector intermediates and partial output
444444
if( _reqVectMem > 0 )
445-
LibSpoofPrimitives.setupThreadLocalMemory(_reqVectMem, _clen, _clen2);
445+
if(_a.isInSparseFormat() && DMLScript.SPARSE_INTERMEDIATE) {
446+
LibSpoofPrimitives.setupSparseThreadLocalMemory(_reqVectMem, _clen, _clen2);
447+
LibSpoofPrimitives.setupThreadLocalMemory(_reqVectMem, _clen, _clen2);
448+
} else {
449+
LibSpoofPrimitives.setupThreadLocalMemory(_reqVectMem, _clen, _clen2);
450+
}
446451
DenseBlock c = DenseBlockFactory.createDenseBlock(1, _outLen);
447452

448453
if( !_a.isInSparseFormat() )
@@ -451,7 +456,12 @@ public DenseBlock call() {
451456
executeSparse(_a.getSparseBlock(), _b, _scalars, c, _clen, _rl, _ru, 0);
452457

453458
if( _reqVectMem > 0 )
454-
LibSpoofPrimitives.cleanupThreadLocalMemory();
459+
if(_a.isInSparseFormat() && DMLScript.SPARSE_INTERMEDIATE) {
460+
LibSpoofPrimitives.cleanupSparseThreadLocalMemory();
461+
LibSpoofPrimitives.cleanupThreadLocalMemory();
462+
} else {
463+
LibSpoofPrimitives.cleanupThreadLocalMemory();
464+
}
455465
return c;
456466
}
457467
}
@@ -485,15 +495,25 @@ protected ParExecTask( MatrixBlock a, SideInput[] b, MatrixBlock c, double[] sca
485495
public Long call() {
486496
//allocate vector intermediates
487497
if( _reqVectMem > 0 )
488-
LibSpoofPrimitives.setupThreadLocalMemory(_reqVectMem, _clen, _clen2);
498+
if(_a.isInSparseFormat() && DMLScript.SPARSE_INTERMEDIATE) {
499+
LibSpoofPrimitives.setupSparseThreadLocalMemory(_reqVectMem, _clen, _clen2);
500+
LibSpoofPrimitives.setupThreadLocalMemory(_reqVectMem, _clen, _clen2);
501+
} else {
502+
LibSpoofPrimitives.setupThreadLocalMemory(_reqVectMem, _clen, _clen2);
503+
}
489504

490505
if( !_a.isInSparseFormat() )
491506
executeDense(_a.getDenseBlock(), _b, _scalars, _c.getDenseBlock(), _clen, _rl, _ru, 0);
492507
else
493508
executeSparse(_a.getSparseBlock(), _b, _scalars, _c.getDenseBlock(), _clen, _rl, _ru, 0);
494-
509+
495510
if( _reqVectMem > 0 )
496-
LibSpoofPrimitives.cleanupThreadLocalMemory();
511+
if(_a.isInSparseFormat() && DMLScript.SPARSE_INTERMEDIATE) {
512+
LibSpoofPrimitives.cleanupSparseThreadLocalMemory();
513+
LibSpoofPrimitives.cleanupThreadLocalMemory();
514+
} else {
515+
LibSpoofPrimitives.cleanupThreadLocalMemory();
516+
}
497517

498518
//maintain nnz for row partition
499519
return _c.recomputeNonZeros(_rl, _ru-1, 0, _c.getNumColumns()-1);

0 commit comments

Comments
 (0)