You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/02/26 14:42:25 UTC

[GitHub] [spark] srowen commented on a change in pull request #27546: [SPARK-30773][ML]Support NativeBlas for level-1 routines

srowen commented on a change in pull request #27546: [SPARK-30773][ML]Support NativeBlas for level-1 routines
URL: https://github.com/apache/spark/pull/27546#discussion_r384513855
 
 

 ##########
 File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
 ##########
 @@ -27,15 +27,35 @@ private[spark] object BLAS extends Serializable {
 
   @transient private var _f2jBLAS: NetlibBLAS = _
   @transient private var _nativeBLAS: NetlibBLAS = _
+  @transient private val vectorSizeThreshold: Int = 256
 
-  // For level-1 routines, we use Java implementation.
+  // For level-3 routines, we use the native BLAS.
+  // if native BLAS is not properly configured in system, will automatically fallback to f2jBLAS
+  private[ml] def nativeBLAS: NetlibBLAS = {
+    if (_nativeBLAS == null) {
+      _nativeBLAS = NativeBLAS
+    }
+    _nativeBLAS
+  }
+
+  // For level-1 functions scal(double, SparseVector) and dspmv, use f2jBLAS for better performance.
   private[ml] def f2jBLAS: NetlibBLAS = {
     if (_f2jBLAS == null) {
       _f2jBLAS = new F2jBLAS
     }
     _f2jBLAS
   }
 
+  // For level-1 functions axpy(), dot() and scal(double, DenseVector), use nativeBLAS when
+  // vector size >= 256, otherwise use f2jBLAS instead
+  private[ml] def getBLAS(vectorSize: Int): NetlibBLAS = {
+    if (vectorSize < vectorSizeThreshold) {
+      return f2jBLAS
 
 Review comment:
   You can omit "return"

----------------------------------------------------------------
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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org