You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@systemds.apache.org by GitBox <gi...@apache.org> on 2021/05/12 20:49:34 UTC

[GitHub] [systemds] ilovemesomeramen commented on a change in pull request #1261: [SYSTEMDS-2972] Initial Multi-Threaded transformencode

ilovemesomeramen commented on a change in pull request #1261:
URL: https://github.com/apache/systemds/pull/1261#discussion_r631388487



##########
File path: src/main/java/org/apache/sysds/runtime/matrix/data/MatrixBlock.java
##########
@@ -643,7 +643,36 @@ public void quickSetValue(int r, int c, double v)
 				nonZeros--;
 		}
 	}
-	
+
+	/*
+		Thread save set.
+		Blocks need to be allocated and in case of MCSR sparse all rows that are going to be accessed need to be allocated
+		aswell.
+	 */
+	public void quickSetValueThreadSafe(int r, int c, double v){
+		if(sparse){
+			if(!(sparseBlock instanceof SparseBlockMCSR))
+				throw new RuntimeException("Only MCSR Blocks are supported for Multithreaded sparse set.");
+			synchronized (sparseBlock.get(r)){
+				sparseBlock.set(r,c,v);
+			}
+		}else{
+			denseBlock.set(r,c,v);
+		}

Review comment:
       Since denseblocks are just a collection of arrays and at the moment of writing to the block there should be nothing that is reading we can write concurrently without any need of synchronization, on the other hand the sparse blocks are only row independent so we need to sync over rows.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org