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/12/16 17:24:13 UTC
[GitHub] [spark] luhenry opened a new pull request #30810: [ML] Add a vectorized BLAS implementation
luhenry opened a new pull request #30810:
URL: https://github.com/apache/spark/pull/30810
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
This patch introduces a VectorizedBLAS class which implements such hardware-accelerated BLAS operations. This feature is hidden behind the "vectorized" profile that you can enable by passing "-Pvectorized" to sbt or maven.
The Vector API has been introduced in JDK 16. Following discussion on the mailing list, this API is introduced transparently and needs to be enabled explicitely.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
Whenever a native BLAS implementation isn't available on the system, Spark automatically falls back onto a Java implementation. With the recent release of the Vector API in the OpenJDK [1], we can use hardware acceleration for such operations.
This change was also discussed on the mailing list. [2]
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
It introduces a build-time profile called `vectorized`. You can pass it to sbt and mvn with `-Pvectorized`. There is no change to the end-user of Spark and it should only impact Spark developpers. It is also disabled by default.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
-->
It passes `build/sbt mllib-local/test` with and without `-Pvectorized` with JDK 16. This patch also introduces benchmarks for BLAS.
/cc @srowen @xkrogen
[1] https://openjdk.java.net/jeps/338
[2] https://mail-archives.apache.org/mod_mbox/spark-dev/202012.mbox/%3cDM5PR2101MB11106162BB3AF32AD29C6C79B0C69@DM5PR2101MB1110.namprd21.prod.outlook.com%3e
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-749797644
@srowen I've created a JIRA and linked it in the title of this PR. I've also updated various uses of `com.github.fommil.netlib.BLAS` to go through `org.apache.spark.ml.linalg.BLAS.nativeBLAS` instead. This doesn't change anything except in the case where the VectorizedBLAS is available but there isn't any OpenBLAS or MLK installed. Then, instead of falling back to f2j, it falls back to vector then f2j.
The only direct uses of `com.github.fommil.netlib.BLAS` left are either in mllib/mllib-local or in graphx. It would be worth changing the use in graphx as it already depends on ml, but `org.apache.spark.ml.linalg.BLAS` is `private[spark]` which makes it inaccessible (scala compiler is complaining).
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-746676925
Can one of the admins verify this patch?
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-832774216
> However, it is strange that you're not providing benchmarks against machine-optimised MKL (or otherwise) backends as described in http://fommil.com/scalax14/#/
You can find the comparison to machine-optimised MKL and OpenBLAS in https://github.com/apache/spark/pull/32415. There, the `javaBLAS` on JDK 16 is using the Vector API. You can see the performance is equivalent or better on most level-1 and level-2 operations but still lacks on level-3 operations (there is a write-up why at https://mail.openjdk.java.net/pipermail/panama-dev/2021-January/011930.html).
> The f2j backend is just the fallback and could be replaced in the most part (e.g. dgemm) with 10 lines of java code.
Yep, agreed. That's what I did for some operations in `javaBLAS`. I get some decent speedups over f2j for some of the operations and even matching the native implementations in some cases.
> Lots of benchmarks over at https://github.com/fommil/matrix-toolkits-java as another consumer of netlib-java that address your comments about "memory copying" (which is incorrect).
I'll definitely look into these higher-level benchmarks, thanks for the pointer!
And you're right, my comment about memory copying was based on the wrong assumption that JNI doesn't support passing java heap memory to native libraries without copying. By using [`Get/ReleasePrimitiveArrayCritical`](https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#GetPrimitiveArrayCritical_ReleasePrimitiveArrayCritical), you can do just that. That is however something that is not possible with the [Foreign Linker API](https://openjdk.java.net/jeps/412) without using a`MemorySegment` backed by native memory, and which would be very invasive for Spark (and not compatible with Java 8 nor 11).
A future avenue of improvement will be to support Sparse Matrix/Vector operations in `dev.ludovic.netlib` directly so that we can take advantage of native libraries that do provide such routines, or fall back to a hand-optimized pure-java fallback.
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry edited a comment on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry edited a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-823660970
> > Late LGTM.
> > BTW, I am not familiar with the new vector api, is it possible to apply it in BLAS for sparse vec/mat?
>
> This vector API provides access to hardware acceleration. So as long as you can express the sparse vec/matrix operations with hardware vectors, you should be able to use the Vector API. However, from my cursory glance at the implementation I’m BLAS.Scala, using hardware acceleration doesn’t seem trivial.
@zhengruifeng I looked further into that today and what might be looking interesting is Intel MKL support for level-2 and level-3 operations on sparse vectors/matrices (https://software.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/blas-and-sparse-blas-routines/inspector-executor-sparse-blas-routines.html). I'll research what's applicable to Spark, and how we could surface it. Feel free to reach out if you want to discuss it offline.
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry edited a comment on pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry edited a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-748687656
I updated the PR to depend on the package `dev.ludovic.vectorizedblas-blas` instead as it makes it a lot easier for me to go and evolve the algorithms independently of Spark, and for the integration to the build system. Let me know if that compromise of good for you.
As for the latest results, it's looking much better:
```
[info] f2jBLAS = com.github.fommil.netlib.F2jBLAS
[info] vectorBLAS = dev.ludovic.blas.VectorizedBLAS
[info]
[info] daxpy: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 45 45 1 223.7 4.5 1.0X
[info] vector 26 26 3 389.4 2.6 1.7X
[info]
[info] sdot: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 53 53 1 190.4 5.3 1.0X
[info] vector 16 17 1 607.4 1.6 3.2X
[info]
[info] ddot: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 73 73 1 137.3 7.3 1.0X
[info] vector 35 36 3 282.8 3.5 2.1X
[info]
[info] dscal: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 36 36 1 279.5 3.6 1.0X
[info] vector 21 21 0 481.4 2.1 1.7X
[info]
[info] dgemv[T]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 35 36 0 0.0 35458.6 1.0X
[info] vector 23 23 0 0.0 23415.6 1.5X
[info]
[info] dgemm[T,N]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 275 276 1 0.4 2753.6 1.0X
[info] vector 149 166 169 0.7 1488.5 1.8X
```
For much more detailed performance numbers on x86 (w/ AVX-2), I'm currently running a JMH benchmark covering more cases. I'll link to it as soon as it finishes (by tomorrow morning CET).
EDIT: I've added the results of the JMH benchmark suite at https://github.com/luhenry/vectorizedblas/releases/tag/v0.1.7
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-819138255
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41893/
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-815339615
**[Test build #137033 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137033/testReport)** for PR 30810 at commit [`521cba2`](https://github.com/apache/spark/commit/521cba2c9c4b0ca2ece7bd05adf5a477b914c1e0).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-819113258
> This also changes in a few cases where native vs Java BLAS is invoked, but I think it's probably a good rationalization of those calls.
I couldn't find such a case. Changes from `blas` to `BLAS.nativeBLAS` should lead to using native libraries just the same. It's only in the case that the native library is _not_ available, then it will try to fallback to VectorizedBLAS instead of F2jBLAS.
> If you have a moment, you might also do one last check through the source for other occurrences of BLAS that may have arisen after you began the change. @zhengruifeng has been applying BLAS in more places.
I couldn't find any other occurrence.
Thank you again :)
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] kiszk commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
kiszk commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r545614820
##########
File path: mllib-local/src/vectorized/java/org/apache/spark/ml/linalg/VectorizedBLAS.java
##########
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.ml.linalg;
+
+import com.github.fommil.netlib.F2jBLAS;
+import jdk.incubator.vector.DoubleVector;
+import jdk.incubator.vector.FloatVector;
+import jdk.incubator.vector.VectorOperators;
+import jdk.incubator.vector.VectorSpecies;
+
+public class VectorizedBLAS extends F2jBLAS {
+
+ private final static VectorSpecies<Float> FMAX = FloatVector.SPECIES_MAX;
+ private final static VectorSpecies<Double> DMAX = DoubleVector.SPECIES_MAX;
+
+ // y += alpha * x
+ @Override
+ public void daxpy(int n, double alpha, double[] x, int incx, double[] y, int incy) {
+ if (incx == 1 && incy == 1 && n <= x.length && n <= y.length) {
+ if (alpha != 0.) {
+ int i = 0;
+ for (; i < DMAX.loopBound(n); i += DMAX.length()) {
+ DoubleVector vx = DoubleVector.fromArray(DMAX, x, i);
+ DoubleVector vy = DoubleVector.fromArray(DMAX, y, i);
+ vx.lanewise(VectorOperators.MUL, alpha).add(vy)
+ .intoArray(y, i);
+ }
+ for (; i < n; i += 1) {
+ y[i] += alpha * x[i];
+ }
+ }
+ } else {
+ super.daxpy(n, alpha, x, incx, y, incy);
+ }
+ }
+
+ // sum(x * y)
+ @Override
+ public float sdot(int n, float[] x, int incx, float[] y, int incy) {
+ if (incx == 1 && incy == 1) {
+ float sum = 0.0f;
+ int i = 0;
+ for (; i < FMAX.loopBound(n); i += FMAX.length()) {
+ FloatVector vx = FloatVector.fromArray(FMAX, x, i);
+ FloatVector vy = FloatVector.fromArray(FMAX, y, i);
+ sum += vx.mul(vy).reduceLanes(VectorOperators.ADD);
+ }
+ for (; i < n; i += 1) {
+ sum += x[i] * y[i];
+ }
+ return sum;
+ } else {
+ return super.sdot(n, x, incx, y, incy);
+ }
+ }
+
+ // sum(x * y)
+ @Override
+ public double ddot(int n, double[] x, int incx, double[] y, int incy) {
+ if (incx == 1 && incy == 1) {
+ double sum = 0.;
+ int i = 0;
+ for (; i < DMAX.loopBound(n); i += DMAX.length()) {
+ DoubleVector vx = DoubleVector.fromArray(DMAX, x, i);
+ DoubleVector vy = DoubleVector.fromArray(DMAX, y, i);
+ sum += vx.mul(vy).reduceLanes(VectorOperators.ADD);
+ }
+ for (; i < n; i += 1) {
+ sum += x[i] * y[i];
+ }
+ return sum;
+ } else {
+ return super.ddot(n, x, incx, y, incy);
+ }
+ }
+
+ // x = alpha * x
+ @Override
+ public void dscal(int n, double alpha, double[] x, int incx) {
+ if (incx == 1) {
+ if (alpha != 1.) {
Review comment:
Can we move this line before line 95?
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-823318572
> Late LGTM.
> BTW, I am not familiar with the new vector api, is it possible to apply it in BLAS for sparse vec/mat?
This vector API provides access to hardware acceleration. So as long as you can express the sparse vec/matrix operations with hardware vectors, you should be able to use the Vector API. However, from my cursory glance at the implementation I’m BLAS.Scala, using hardware acceleration doesn’t seem trivial.
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r545049557
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -18,28 +18,46 @@
package org.apache.spark.ml.linalg
import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
-import com.github.fommil.netlib.BLAS.{getInstance => NativeBLAS}
+import scala.util.Try
+
+import org.apache.spark.util.Utils
/**
* BLAS routines for MLlib's vectors and matrices.
*/
private[spark] object BLAS extends Serializable {
- @transient private var _f2jBLAS: NetlibBLAS = _
+ @transient private var _javaBLAS: NetlibBLAS = _
@transient private var _nativeBLAS: NetlibBLAS = _
private val nativeL1Threshold: Int = 256
Review comment:
From the results of the benchmarks (see https://github.com/apache/spark/pull/30810#issuecomment-747405702), the value is likely to be a bit bigger when using vectorized implementation and we will keep something similar for some operations (`dscal`, `dspr`, `dsyr`, `sdot`).
I'll look at why is the native implementation so much faster for simple operations like `dscal` and `sdot` (especially when `ddot` is equivalent to native), and what we can apply to the vectorized version.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-749806525
@luhenry . Could you copy and paste your benchmark result into the PR description? That will be a commit log.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-801944250
Hi, as JDK 16 has been released, I’ll follow up on this in the upcoming days to check if it’s still building and passing the test suite, and fix any possible regressions.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] fommil commented on a change in pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
fommil commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r626332421
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -18,28 +18,51 @@
package org.apache.spark.ml.linalg
import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
-import com.github.fommil.netlib.BLAS.{getInstance => NativeBLAS}
/**
* BLAS routines for MLlib's vectors and matrices.
*/
private[spark] object BLAS extends Serializable {
- @transient private var _f2jBLAS: NetlibBLAS = _
+ @transient private var _javaBLAS: NetlibBLAS = _
@transient private var _nativeBLAS: NetlibBLAS = _
private val nativeL1Threshold: Int = 256
Review comment:
netlib-java does not copy memory when using native backend, it uses memory pinning (which has its own problems). Please provide benchmarks to show any degradation.
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-818075807
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/137222/
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r547427103
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -267,7 +282,7 @@ private[spark] object BLAS extends Serializable {
x: DenseVector,
beta: Double,
y: DenseVector): Unit = {
- f2jBLAS.dspmv("U", n, alpha, A.values, x.values, 1, beta, y.values, 1)
+ javaBLAS.dspmv("U", n, alpha, A.values, x.values, 1, beta, y.values, 1)
Review comment:
OK that's fine if we're fairly confident that this is a win for this use case. I don't even know if there was a strong reason for it or whether it's still valid.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-819169692
**[Test build #137313 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137313/testReport)** for PR 30810 at commit [`10595df`](https://github.com/apache/spark/commit/10595df8cd6ad01c6a9ae5cde49a9974ae58b667).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds the following public classes _(experimental)_:
* `class SQLProcessor(object):`
* `case class KnownFloatingPointNormalized(child: Expression) extends TaggingExpression `
* `trait BaseGroupingSets extends Expression with CodegenFallback `
* `case class Cube(`
* `case class Acos(child: Expression) extends UnaryMathExpression(math.acos, \"ACOS\") `
* `case class Asin(child: Expression) extends UnaryMathExpression(math.asin, \"ASIN\") `
* `case class Atan(child: Expression) extends UnaryMathExpression(math.atan, \"ATAN\") `
* `case class Cbrt(child: Expression) extends UnaryMathExpression(math.cbrt, \"CBRT\") `
* `case class Cos(child: Expression) extends UnaryMathExpression(math.cos, \"COS\") `
* `case class Cosh(child: Expression) extends UnaryMathExpression(math.cosh, \"COSH\") `
* `case class Log10(child: Expression) extends UnaryLogExpression(StrictMath.log10, \"LOG10\") `
* `case class Signum(child: Expression) extends UnaryMathExpression(math.signum, \"SIGNUM\") `
* `case class Sin(child: Expression) extends UnaryMathExpression(math.sin, \"SIN\") `
* `case class Sinh(child: Expression) extends UnaryMathExpression(math.sinh, \"SINH\") `
* `case class Sqrt(child: Expression) extends UnaryMathExpression(math.sqrt, \"SQRT\") `
* `case class Tan(child: Expression) extends UnaryMathExpression(math.tan, \"TAN\") `
* `case class Tanh(child: Expression) extends UnaryMathExpression(math.tanh, \"TANH\") `
* `case class DeleteAction(condition: Option[Expression]) extends MergeAction `
* `case class UpdateStarAction(condition: Option[Expression]) extends MergeAction `
* `case class InsertStarAction(condition: Option[Expression]) extends MergeAction `
* `case class RefreshTable(child: LogicalPlan) extends UnaryCommand `
* `case class CommentOnNamespace(child: LogicalPlan, comment: String) extends UnaryCommand `
* `case class CommentOnTable(child: LogicalPlan, comment: String) extends UnaryCommand `
* `case class RefreshFunction(child: LogicalPlan) extends UnaryCommand `
* `case class DescribeFunction(child: LogicalPlan, isExtended: Boolean) extends UnaryCommand `
* `case class RecoverPartitions(child: LogicalPlan) extends UnaryCommand `
* `case class RuleId(id: Int) `
* `abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product with TreePatternBits `
* `trait TreePatternBits `
* `case class SetCommand(kv: Option[(String, Option[String])])`
* `case class ResetCommand(config: Option[String]) extends LeafRunnableCommand with IgnoreCachedData `
* `case class AddJarCommand(path: String) extends LeafRunnableCommand `
* `case class AddFileCommand(path: String) extends LeafRunnableCommand `
* `case class AddArchiveCommand(path: String) extends LeafRunnableCommand `
* `case class ListFilesCommand(files: Seq[String] = Seq.empty[String]) extends LeafRunnableCommand `
* `case class ListJarsCommand(jars: Seq[String] = Seq.empty[String]) extends LeafRunnableCommand `
* `case class ListArchivesCommand(archives: Seq[String] = Seq.empty[String])`
* `abstract class DescribeCommandBase extends LeafRunnableCommand `
* `case class WriteToDataSourceV2(`
* `case class LocalLimitExec(limit: Int, child: SparkPlan) extends BaseLimitExec `
* `case class WriteToMicroBatchDataSource(`
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] kiszk commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
kiszk commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r544868623
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -18,28 +18,46 @@
package org.apache.spark.ml.linalg
import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
-import com.github.fommil.netlib.BLAS.{getInstance => NativeBLAS}
+import scala.util.Try
+
+import org.apache.spark.util.Utils
/**
* BLAS routines for MLlib's vectors and matrices.
*/
private[spark] object BLAS extends Serializable {
- @transient private var _f2jBLAS: NetlibBLAS = _
+ @transient private var _javaBLAS: NetlibBLAS = _
@transient private var _nativeBLAS: NetlibBLAS = _
private val nativeL1Threshold: Int = 256
Review comment:
Will we need to change this value depending on which javaBLAS is selected? vectorized version or F2JBLAS.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-819658225
Merged to master
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-819136230
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on a change in pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r612463403
##########
File path: project/SparkBuild.scala
##########
@@ -291,6 +291,12 @@ object SparkBuild extends PomBuild {
publishLocal in SbtCompile := publishTask(publishLocalConfiguration in SbtCompile).value,
publishLocal := Seq(publishLocal in MavenCompile, publishLocal in SbtCompile).dependOn.value,
+ javaOptions ++= {
Review comment:
Apologies @luhenry there's a merge conflict around here. If you can resolve it I will merge.
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-818075807
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/137222/
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-748687656
I updated the PR to depend on the package `dev.ludovic.vectorizedblas-blas` instead as it makes it a lot easier for me to go and evolve the algorithms independently of Spark, and for the integration to the build system. Let me know if that compromise of good for you.
As for the latest results, it's looking much better:
```
[info] f2jBLAS = com.github.fommil.netlib.F2jBLAS
[info] vectorBLAS = dev.ludovic.blas.VectorizedBLAS
[info]
[info] daxpy: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 45 45 1 223.7 4.5 1.0X
[info] vector 26 26 3 389.4 2.6 1.7X
[info]
[info] Unknown processor
[info] sdot: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 53 53 1 190.4 5.3 1.0X
[info] vector 16 17 1 607.4 1.6 3.2X
[info]
[info] Unknown processor
[info] ddot: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 73 73 1 137.3 7.3 1.0X
[info] vector 35 36 3 282.8 3.5 2.1X
[info]
[info] dscal: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 36 36 1 279.5 3.6 1.0X
[info] vector 21 21 0 481.4 2.1 1.7X
[info]
[info] dgemv[T]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 35 36 0 0.0 35458.6 1.0X
[info] vector 23 23 0 0.0 23415.6 1.5X
[info]
[info] dgemm[T,N]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 275 276 1 0.4 2753.6 1.0X
[info] vector 149 166 169 0.7 1488.5 1.8X
```
For much more detailed performance numbers on x86 (w/ AVX-2), I'm currently running a JMH benchmark covering more cases. I'll link to it as soon as it finishes (by tomorrow morning CET).
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r547313267
##########
File path: mllib-local/pom.xml
##########
@@ -68,6 +68,13 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.spark</groupId>
+ <artifactId>spark-core_${scala.binary.version}</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
Review comment:
This should be fine if it's test only.
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -18,28 +18,51 @@
package org.apache.spark.ml.linalg
import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
-import com.github.fommil.netlib.BLAS.{getInstance => NativeBLAS}
/**
* BLAS routines for MLlib's vectors and matrices.
*/
private[spark] object BLAS extends Serializable {
- @transient private var _f2jBLAS: NetlibBLAS = _
+ @transient private var _javaBLAS: NetlibBLAS = _
@transient private var _nativeBLAS: NetlibBLAS = _
private val nativeL1Threshold: Int = 256
- // For level-1 function dspmv, use f2jBLAS for better performance.
- private[ml] def f2jBLAS: NetlibBLAS = {
- if (_f2jBLAS == null) {
- _f2jBLAS = new F2jBLAS
+ // For level-1 function dspmv, use javaBLAS for better performance.
+ private[ml] def javaBLAS: NetlibBLAS = {
+ if (_javaBLAS == null) {
+ _javaBLAS =
+ try {
+ // scalastyle:off classforname
+ Class.forName("org.apache.spark.ml.linalg.VectorizedBLAS", true,
+ Option(Thread.currentThread().getContextClassLoader)
Review comment:
Nit: the indentation through line 41 seems too far in / uneven
##########
File path: .github/workflows/build_and_test.yml
##########
@@ -394,6 +394,31 @@ jobs:
./build/mvn $MAVEN_CLI_OPTS -DskipTests -Pyarn -Pmesos -Pkubernetes -Phive -Phive-thriftserver -Phadoop-cloud -Djava.version=11 install
rm -rf ~/.m2/repository/org/apache/spark
+ java-17:
Review comment:
@dongjoon-hyun does this look correct?
I think we're not quite on to even testing vs Java 14 yet, though informally it seems to work fine already.
We may not need to set this up yet, as I imagine anyone wanting to enable this is building from scratch anyway (we won't publish releases requiring 17 for a long time!)
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -267,7 +282,7 @@ private[spark] object BLAS extends Serializable {
x: DenseVector,
beta: Double,
y: DenseVector): Unit = {
- f2jBLAS.dspmv("U", n, alpha, A.values, x.values, 1, beta, y.values, 1)
+ javaBLAS.dspmv("U", n, alpha, A.values, x.values, 1, beta, y.values, 1)
Review comment:
It looks like the intent here was to never try a vectorized implementation. That might or might not be wrong, but same point - I think we want to keep the separate native vs non-native options above, keep them separate
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -18,28 +18,51 @@
package org.apache.spark.ml.linalg
import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
-import com.github.fommil.netlib.BLAS.{getInstance => NativeBLAS}
/**
* BLAS routines for MLlib's vectors and matrices.
*/
private[spark] object BLAS extends Serializable {
- @transient private var _f2jBLAS: NetlibBLAS = _
+ @transient private var _javaBLAS: NetlibBLAS = _
@transient private var _nativeBLAS: NetlibBLAS = _
private val nativeL1Threshold: Int = 256
- // For level-1 function dspmv, use f2jBLAS for better performance.
- private[ml] def f2jBLAS: NetlibBLAS = {
- if (_f2jBLAS == null) {
- _f2jBLAS = new F2jBLAS
+ // For level-1 function dspmv, use javaBLAS for better performance.
+ private[ml] def javaBLAS: NetlibBLAS = {
+ if (_javaBLAS == null) {
+ _javaBLAS =
+ try {
+ // scalastyle:off classforname
+ Class.forName("org.apache.spark.ml.linalg.VectorizedBLAS", true,
+ Option(Thread.currentThread().getContextClassLoader)
+ .getOrElse(getClass.getClassLoader))
+ .newInstance()
+ .asInstanceOf[NetlibBLAS]
+ // scalastyle:on classforname
+ } catch {
+ case _: Throwable => new F2jBLAS
+ }
+ }
+ _javaBLAS
+ }
+
+ // For level-3 routines, we use the native BLAS.
+ private[ml] def nativeBLAS: NetlibBLAS = {
+ if (_nativeBLAS == null) {
+ _nativeBLAS =
+ if (NetlibBLAS.getInstance.isInstanceOf[F2jBLAS]) {
+ javaBLAS
+ } else {
+ NetlibBLAS.getInstance
+ }
}
- _f2jBLAS
+ _nativeBLAS
}
private[ml] def getBLAS(vectorSize: Int): NetlibBLAS = {
if (vectorSize < nativeL1Threshold) {
- f2jBLAS
+ javaBLAS
Review comment:
I think we might need to readjust the logic around here. This is meant to avoid calling into native code for very small operations, where it probably isn't a win. I think f2jBLAS should stay, and the nativeBLAS implementation should vary based on availability of the JVM or Netlib implementation?
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-819138255
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41893/
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-815296026
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41611/
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-817992412
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41802/
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-819177712
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/137313/
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on a change in pull request #30810: [ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r544486626
##########
File path: mllib-local/pom.xml
##########
@@ -56,6 +56,11 @@
<groupId>org.apache.spark</groupId>
<artifactId>spark-tags_${scala.binary.version}</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.spark</groupId>
+ <artifactId>spark-core_${scala.binary.version}</artifactId>
Review comment:
We won't be able to include this dependency - mllib-local needs to be independent of core.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-819118534
**[Test build #137313 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137313/testReport)** for PR 30810 at commit [`10595df`](https://github.com/apache/spark/commit/10595df8cd6ad01c6a9ae5cde49a9974ae58b667).
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-754037826
We can just hold the PR until Java 16 at least. It will just stay open (we can stop it from auto-closing).
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on a change in pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r609662949
##########
File path: mllib-local/pom.xml
##########
@@ -81,6 +88,34 @@
</dependency>
</dependencies>
</profile>
+ <profile>
+ <id>vectorized</id>
+ <properties>
+ <extra.source.dir>src/vectorized/java</extra.source.dir>
Review comment:
Let me do the rename.
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-749451215
The latest BLASBenchmark results with 0.1.9:
```
[info] daxpy: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 37 37 0 271.5 3.7 1.0X
[info] vector 24 25 4 416.1 2.4 1.5X
[info]
[info] ddot: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 70 70 0 143.2 7.0 1.0X
[info] vector 35 35 2 288.7 3.5 2.0X
[info]
[info] sdot: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 50 51 1 199.8 5.0 1.0X
[info] vector 15 15 0 648.7 1.5 3.2X
[info]
[info] dscal: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 34 34 0 295.6 3.4 1.0X
[info] vector 19 19 0 531.2 1.9 1.8X
[info]
[info] sscal: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 25 25 1 399.0 2.5 1.0X
[info] vector 8 9 1 1177.3 0.8 3.0X
[info]
[info] dgemv[N]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 27 27 0 0.0 26651.5 1.0X
[info] vector 21 21 0 0.0 20646.3 1.3X
[info]
[info] dgemv[T]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 36 36 0 0.0 35501.4 1.0X
[info] vector 22 22 0 0.0 21930.3 1.6X
[info]
[info] sgemv[N]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 20 20 0 0.0 20283.3 1.0X
[info] vector 9 9 0 0.1 8657.7 2.3X
[info]
[info] sgemv[T]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 30 30 0 0.0 29845.8 1.0X
[info] vector 10 10 1 0.1 9695.4 3.1X
[info]
[info] dgemm[N,N]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 182 182 0 0.5 1820.0 1.0X
[info] vector 160 160 1 0.6 1597.6 1.1X
[info]
[info] dgemm[N,T]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 211 211 1 0.5 2106.2 1.0X
[info] vector 156 157 0 0.6 1564.4 1.3X
[info]
[info] dgemm[T,N]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 276 276 0 0.4 2757.8 1.0X
[info] vector 137 137 0 0.7 1365.1 2.0X
```
I'll now run a LogisticRegression benchmark that should benefit from these accelerated operations. I'll also later run a MultilayerPerceptronClassifier benchmark which should equally benefit from accelerated dgemm operations.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] zhengruifeng edited a comment on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
zhengruifeng edited a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-819959813
Late LGTM.
BTW, I am not familiar with the new vector api, is it possible to apply it in BLAS for sparse vec/mat?
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-817992412
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/41802/
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-817910611
**[Test build #137222 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137222/testReport)** for PR 30810 at commit [`d93b274`](https://github.com/apache/spark/commit/d93b27410b8223605f4891eae3f675914c8d0346).
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-749698745
Go ahead and make a JIRA for this and put it in the title in place of WIP
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] zhengruifeng edited a comment on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
zhengruifeng edited a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-752369531
I have one stupid question:
`VectorBLAS` in https://gist.github.com/luhenry/6b24ac146a110143ad31736caf7250e6#file-f2j-vs-vector-log was implemented in scala, now you switch to java, does this change speedup VectorBLAS?
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r547426492
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -18,28 +18,51 @@
package org.apache.spark.ml.linalg
import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
-import com.github.fommil.netlib.BLAS.{getInstance => NativeBLAS}
/**
* BLAS routines for MLlib's vectors and matrices.
*/
private[spark] object BLAS extends Serializable {
- @transient private var _f2jBLAS: NetlibBLAS = _
+ @transient private var _javaBLAS: NetlibBLAS = _
@transient private var _nativeBLAS: NetlibBLAS = _
private val nativeL1Threshold: Int = 256
- // For level-1 function dspmv, use f2jBLAS for better performance.
- private[ml] def f2jBLAS: NetlibBLAS = {
- if (_f2jBLAS == null) {
- _f2jBLAS = new F2jBLAS
+ // For level-1 function dspmv, use javaBLAS for better performance.
+ private[ml] def javaBLAS: NetlibBLAS = {
+ if (_javaBLAS == null) {
+ _javaBLAS =
+ try {
+ // scalastyle:off classforname
+ Class.forName("org.apache.spark.ml.linalg.VectorizedBLAS", true,
+ Option(Thread.currentThread().getContextClassLoader)
+ .getOrElse(getClass.getClassLoader))
+ .newInstance()
+ .asInstanceOf[NetlibBLAS]
+ // scalastyle:on classforname
+ } catch {
+ case _: Throwable => new F2jBLAS
+ }
+ }
+ _javaBLAS
+ }
+
+ // For level-3 routines, we use the native BLAS.
+ private[ml] def nativeBLAS: NetlibBLAS = {
+ if (_nativeBLAS == null) {
+ _nativeBLAS =
+ if (NetlibBLAS.getInstance.isInstanceOf[F2jBLAS]) {
+ javaBLAS
+ } else {
+ NetlibBLAS.getInstance
+ }
}
- _f2jBLAS
+ _nativeBLAS
}
private[ml] def getBLAS(vectorSize: Int): NetlibBLAS = {
if (vectorSize < nativeL1Threshold) {
- f2jBLAS
+ javaBLAS
Review comment:
OK I get that. If the Vector API is available, then, no real reason to use the plain Java implementation ever. This makes sense to me. You can still use Netlib + BLAS by providing it if desired.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-749452983
@srowen as I'm getting some encouraging numbers and CI is passing (since https://github.com/apache/spark/pull/30810/commits/d4b737cdca52a113ac39121117c4fe3655205850), what do you want to see to get this PR merged? Are you happy with the approach of depending on this external package? Are you looking for more benchmark numbers?
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on a change in pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r551320681
##########
File path: mllib-local/src/test/scala/org/apache/spark/ml/linalg/BLASBenchmark.scala
##########
@@ -0,0 +1,502 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.ml.linalg
+
+import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
+
+import org.apache.spark.benchmark.{Benchmark, BenchmarkBase}
+
+/**
+ * Serialization benchmark for BLAS.
+ * To run this benchmark:
+ * {{{
+ * 1. without sbt: bin/spark-submit --class <this class> <spark mllib test jar>
+ * 2. build/sbt "mllib/test:runMain <this class>"
+ * 3. generate result: SPARK_GENERATE_BENCHMARK_FILES=1 build/sbt "mllib/test:runMain <this class>"
+ * Results will be written to "benchmarks/BLASBenchmark-results.txt".
+ * }}}
+ */
+object BLASBenchmark extends BenchmarkBase {
+
+ override def runBenchmarkSuite(mainArgs: Array[String]): Unit = {
+
+ val iters = 1e2.toInt
+ val rnd = new scala.util.Random(0)
+
+ val f2jBLAS = new F2jBLAS
+ val nativeBLAS = NetlibBLAS.getInstance
+ val vectorBLAS =
+ try {
+ // scalastyle:off classforname
+ Class.forName("org.apache.spark.ml.linalg.VectorizedBLAS", true,
+ Option(Thread.currentThread().getContextClassLoader)
+ .getOrElse(getClass.getClassLoader))
+ .newInstance()
+ .asInstanceOf[NetlibBLAS]
+ // scalastyle:on classforname
+ } catch {
+ case _: Throwable => new F2jBLAS
+ }
Review comment:
It's indeed not necessarily helpful to run the benchmark if there is no `VectorizedBLAS` nor `NetblibRefBLAS`/`NetlibSystemBLAS`. However, AFAICT, this benchmark is only run manually and we can then assume that whoever is running it is trying to compare two implementations. If you feel strongly about not running the benchmark if only `F2jBLAS` implementation is available, let me know and I'll modify it to do so.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on pull request #30810: [ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-746687567
This will eventually need a JIRA, but I'm going to mark it WIP for now
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r544536426
##########
File path: mllib-local/pom.xml
##########
@@ -56,6 +56,11 @@
<groupId>org.apache.spark</groupId>
<artifactId>spark-tags_${scala.binary.version}</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.spark</groupId>
+ <artifactId>spark-core_${scala.binary.version}</artifactId>
Review comment:
I know, but we won't be able to allow that dependency. You can 'inline' Utils.classForName, and eventually we won't need the benchmark (or maybe the test-scope dependency is OK). For experiments now it's fine.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r547392950
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -18,28 +18,51 @@
package org.apache.spark.ml.linalg
import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
-import com.github.fommil.netlib.BLAS.{getInstance => NativeBLAS}
/**
* BLAS routines for MLlib's vectors and matrices.
*/
private[spark] object BLAS extends Serializable {
- @transient private var _f2jBLAS: NetlibBLAS = _
+ @transient private var _javaBLAS: NetlibBLAS = _
@transient private var _nativeBLAS: NetlibBLAS = _
private val nativeL1Threshold: Int = 256
- // For level-1 function dspmv, use f2jBLAS for better performance.
- private[ml] def f2jBLAS: NetlibBLAS = {
- if (_f2jBLAS == null) {
- _f2jBLAS = new F2jBLAS
+ // For level-1 function dspmv, use javaBLAS for better performance.
+ private[ml] def javaBLAS: NetlibBLAS = {
+ if (_javaBLAS == null) {
+ _javaBLAS =
+ try {
+ // scalastyle:off classforname
+ Class.forName("org.apache.spark.ml.linalg.VectorizedBLAS", true,
+ Option(Thread.currentThread().getContextClassLoader)
+ .getOrElse(getClass.getClassLoader))
+ .newInstance()
+ .asInstanceOf[NetlibBLAS]
+ // scalastyle:on classforname
+ } catch {
+ case _: Throwable => new F2jBLAS
+ }
+ }
+ _javaBLAS
+ }
+
+ // For level-3 routines, we use the native BLAS.
+ private[ml] def nativeBLAS: NetlibBLAS = {
+ if (_nativeBLAS == null) {
+ _nativeBLAS =
+ if (NetlibBLAS.getInstance.isInstanceOf[F2jBLAS]) {
+ javaBLAS
+ } else {
+ NetlibBLAS.getInstance
+ }
}
- _f2jBLAS
+ _nativeBLAS
}
private[ml] def getBLAS(vectorSize: Int): NetlibBLAS = {
if (vectorSize < nativeL1Threshold) {
- f2jBLAS
+ javaBLAS
Review comment:
I would argue for the vector implementation to "replace" the f2j one when possible instead of the native one for three reasons. First, the vector implementation is faster than f2j in all cases. Second, the vector implementation doesn't suffer from the overhead of switching between java and native that native has (these are all compiler intrinsic and is completely transparent to the user of the Vector API). And third, because the vector implementation doesn't depend on any other external dependency (other than a recent enough JDK that is used to run the whole of Spark) similarly to f2j.
The current fallback chain is as follows:
- for `javaBLAS`: 1. vector, 2. f2j
- for `nativeBLAS`: 1. native, 2. vector, 3. f2j
That guarantees to get access to the fastest implementation available given the set of options enabled (compiled with `-Pvectorized`, compiled with JDK16+, ran with JDK16+, installed OpenBLAS or MLK).
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r545559034
##########
File path: mllib-local/src/test/scala/org/apache/spark/ml/linalg/BLASBenchmark.scala
##########
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.ml.linalg
+
+import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
+import scala.util.Try
+
+import org.apache.spark.benchmark.{Benchmark, BenchmarkBase}
+import org.apache.spark.util.Utils
+
+/**
+ * Serialization benchmark for BLAS.
+ * To run this benchmark:
+ * {{{
+ * 1. without sbt: bin/spark-submit --class <this class> <spark mllib test jar>
+ * 2. build/sbt "mllib/test:runMain <this class>"
+ * 3. generate result: SPARK_GENERATE_BENCHMARK_FILES=1 build/sbt "mllib/test:runMain <this class>"
+ * Results will be written to "benchmarks/UDTSerializationBenchmark-results.txt".
Review comment:
`UDTSerializationBenchmark` -> `BLASBemnchmark`?
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-755053647
Thank you, @luhenry and @srowen .
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-817974532
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on a change in pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r551319230
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -18,28 +18,51 @@
package org.apache.spark.ml.linalg
import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
-import com.github.fommil.netlib.BLAS.{getInstance => NativeBLAS}
/**
* BLAS routines for MLlib's vectors and matrices.
*/
private[spark] object BLAS extends Serializable {
- @transient private var _f2jBLAS: NetlibBLAS = _
+ @transient private var _javaBLAS: NetlibBLAS = _
@transient private var _nativeBLAS: NetlibBLAS = _
private val nativeL1Threshold: Int = 256
- // For level-1 function dspmv, use f2jBLAS for better performance.
- private[ml] def f2jBLAS: NetlibBLAS = {
- if (_f2jBLAS == null) {
- _f2jBLAS = new F2jBLAS
+ // For level-1 function dspmv, use javaBLAS for better performance.
+ private[ml] def javaBLAS: NetlibBLAS = {
+ if (_javaBLAS == null) {
+ _javaBLAS =
+ try {
+ // scalastyle:off classforname
+ Class.forName("org.apache.spark.ml.linalg.VectorizedBLAS", true,
+ Option(Thread.currentThread().getContextClassLoader)
+ .getOrElse(getClass.getClassLoader))
+ .newInstance()
+ .asInstanceOf[NetlibBLAS]
+ // scalastyle:on classforname
+ } catch {
+ case _: Throwable => new F2jBLAS
+ }
+ }
+ _javaBLAS
+ }
+
+ // For level-3 routines, we use the native BLAS.
+ private[ml] def nativeBLAS: NetlibBLAS = {
+ if (_nativeBLAS == null) {
+ _nativeBLAS =
+ if (NetlibBLAS.getInstance.isInstanceOf[F2jBLAS]) {
+ javaBLAS
+ } else {
+ NetlibBLAS.getInstance
Review comment:
`NetlibBLAS.getInstance` already caches the creation of the NetlibBLAS object. Calling it twice then doesn't lead to the creation of two objects.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-815268073
**[Test build #137033 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137033/testReport)** for PR 30810 at commit [`521cba2`](https://github.com/apache/spark/commit/521cba2c9c4b0ca2ece7bd05adf5a477b914c1e0).
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r544498951
##########
File path: mllib-local/pom.xml
##########
@@ -56,6 +56,11 @@
<groupId>org.apache.spark</groupId>
<artifactId>spark-tags_${scala.binary.version}</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.spark</groupId>
+ <artifactId>spark-core_${scala.binary.version}</artifactId>
Review comment:
That is needed for two bits:
- `Utils.classForName`: a scalastyle rule indicated I should do that. I can always disable the rule locally and use `Class.forName` directly.
- `Benchmark` and `BenchmarkBase`: I followed how `org.apache.spark.mllib.linalg.UDTSerializationBenchmark` does it. Since that is only for testing, is it an issue, or could that stay as-is?
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] zhengruifeng commented on a change in pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
zhengruifeng commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r613713375
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -18,28 +18,51 @@
package org.apache.spark.ml.linalg
import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
-import com.github.fommil.netlib.BLAS.{getInstance => NativeBLAS}
/**
* BLAS routines for MLlib's vectors and matrices.
*/
private[spark] object BLAS extends Serializable {
- @transient private var _f2jBLAS: NetlibBLAS = _
+ @transient private var _javaBLAS: NetlibBLAS = _
@transient private var _nativeBLAS: NetlibBLAS = _
private val nativeL1Threshold: Int = 256
Review comment:
according to the performance test, I think we can increase `nativeL1Threshold` to 512?
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] zhengruifeng commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
zhengruifeng commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-819959813
Late LGTM.
BTW, I am not familiar with the java api, is it possible to apply it in BLAS for sparse vec/mat?
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] kiszk commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
kiszk commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-821003025
@luhenry Could you please update the description using `-Pjvm-vectorized` instead of `-Pvectorized`?
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r546452297
##########
File path: mllib-local/src/vectorized/java/org/apache/spark/ml/linalg/VectorizedBLAS.java
##########
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.ml.linalg;
+
+import com.github.fommil.netlib.F2jBLAS;
+import jdk.incubator.vector.DoubleVector;
+import jdk.incubator.vector.FloatVector;
+import jdk.incubator.vector.VectorOperators;
+import jdk.incubator.vector.VectorSpecies;
+
+public class VectorizedBLAS extends F2jBLAS {
+
+ private final static VectorSpecies<Float> FMAX = FloatVector.SPECIES_MAX;
+ private final static VectorSpecies<Double> DMAX = DoubleVector.SPECIES_MAX;
+
+ // y += alpha * x
+ @Override
+ public void daxpy(int n, double alpha, double[] x, int incx, double[] y, int incy) {
+ if (incx == 1 && incy == 1 && n <= x.length && n <= y.length) {
+ if (alpha != 0.) {
+ int i = 0;
+ for (; i < DMAX.loopBound(n); i += DMAX.length()) {
+ DoubleVector vx = DoubleVector.fromArray(DMAX, x, i);
+ DoubleVector vy = DoubleVector.fromArray(DMAX, y, i);
+ vx.lanewise(VectorOperators.MUL, alpha).add(vy)
+ .intoArray(y, i);
+ }
+ for (; i < n; i += 1) {
+ y[i] += alpha * x[i];
+ }
+ }
+ } else {
+ super.daxpy(n, alpha, x, incx, y, incy);
+ }
+ }
+
+ // sum(x * y)
+ @Override
+ public float sdot(int n, float[] x, int incx, float[] y, int incy) {
+ if (incx == 1 && incy == 1) {
+ float sum = 0.0f;
+ int i = 0;
+ for (; i < FMAX.loopBound(n); i += FMAX.length()) {
+ FloatVector vx = FloatVector.fromArray(FMAX, x, i);
+ FloatVector vy = FloatVector.fromArray(FMAX, y, i);
+ sum += vx.mul(vy).reduceLanes(VectorOperators.ADD);
+ }
+ for (; i < n; i += 1) {
+ sum += x[i] * y[i];
+ }
+ return sum;
+ } else {
+ return super.sdot(n, x, incx, y, incy);
+ }
+ }
+
+ // sum(x * y)
+ @Override
+ public double ddot(int n, double[] x, int incx, double[] y, int incy) {
+ if (incx == 1 && incy == 1) {
+ double sum = 0.;
+ int i = 0;
+ for (; i < DMAX.loopBound(n); i += DMAX.length()) {
+ DoubleVector vx = DoubleVector.fromArray(DMAX, x, i);
+ DoubleVector vy = DoubleVector.fromArray(DMAX, y, i);
+ sum += vx.mul(vy).reduceLanes(VectorOperators.ADD);
+ }
+ for (; i < n; i += 1) {
+ sum += x[i] * y[i];
+ }
+ return sum;
+ } else {
+ return super.ddot(n, x, incx, y, incy);
+ }
+ }
+
+ // x = alpha * x
+ @Override
+ public void dscal(int n, double alpha, double[] x, int incx) {
+ if (incx == 1) {
+ if (alpha != 1.) {
Review comment:
I am concerned that doing that could change the implicit API around errors if a value passed to the method is invalid. On that note, I should likely add checks for the values of `x` (like `x != null && n <= x.length`).
##########
File path: mllib-local/src/vectorized/java/org/apache/spark/ml/linalg/VectorizedBLAS.java
##########
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.ml.linalg;
+
+import com.github.fommil.netlib.F2jBLAS;
+import jdk.incubator.vector.DoubleVector;
+import jdk.incubator.vector.FloatVector;
+import jdk.incubator.vector.VectorOperators;
+import jdk.incubator.vector.VectorSpecies;
+
+public class VectorizedBLAS extends F2jBLAS {
+
+ private final static VectorSpecies<Float> FMAX = FloatVector.SPECIES_MAX;
+ private final static VectorSpecies<Double> DMAX = DoubleVector.SPECIES_MAX;
+
+ // y += alpha * x
+ @Override
+ public void daxpy(int n, double alpha, double[] x, int incx, double[] y, int incy) {
+ if (incx == 1 && incy == 1 && n <= x.length && n <= y.length) {
+ if (alpha != 0.) {
Review comment:
Same as https://github.com/apache/spark/pull/30810#discussion_r546452297
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on a change in pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r609559096
##########
File path: project/SparkBuild.scala
##########
@@ -291,6 +291,12 @@ object SparkBuild extends PomBuild {
publishLocal in SbtCompile := publishTask(publishLocalConfiguration in SbtCompile).value,
publishLocal := Seq(publishLocal in MavenCompile, publishLocal in SbtCompile).dependOn.value,
+ javaOptions ++= {
+ val versionParts = System.getProperty("java.version").split("[+.\\-]+", 3)
+ var major = versionParts(0).toInt
+ if (major >= 16) Seq("--add-modules=jdk.incubator.vector") else Seq.empty
Review comment:
Yes, they would have to. It's one of the failsafe to make sure users don't end up using the feature "by accident". That will be the case until the Vector API becomes stable (gets out of incubation) and doesn't need this flag anymore.
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-819177712
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/137313/
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on a change in pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r609144837
##########
File path: project/SparkBuild.scala
##########
@@ -291,6 +291,12 @@ object SparkBuild extends PomBuild {
publishLocal in SbtCompile := publishTask(publishLocalConfiguration in SbtCompile).value,
publishLocal := Seq(publishLocal in MavenCompile, publishLocal in SbtCompile).dependOn.value,
+ javaOptions ++= {
+ val versionParts = System.getProperty("java.version").split("[+.\\-]+", 3)
+ var major = versionParts(0).toInt
+ if (major >= 16) Seq("--add-modules=jdk.incubator.vector") else Seq.empty
Review comment:
Would a Spark cluster have to launch its JVMs with this flag to make it work? that's OK if so, we might just add a note in the docs about it.
##########
File path: mllib-local/pom.xml
##########
@@ -81,6 +88,34 @@
</dependency>
</dependencies>
</profile>
+ <profile>
+ <id>vectorized</id>
+ <properties>
+ <extra.source.dir>src/vectorized/java</extra.source.dir>
Review comment:
Just some nits now: I wonder if we should call this profile something more like `jvm-vectorized` to be more specific? but it doesn't matter much
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-823660970
> > Late LGTM.
> > BTW, I am not familiar with the new vector api, is it possible to apply it in BLAS for sparse vec/mat?
>
> This vector API provides access to hardware acceleration. So as long as you can express the sparse vec/matrix operations with hardware vectors, you should be able to use the Vector API. However, from my cursory glance at the implementation I’m BLAS.Scala, using hardware acceleration doesn’t seem trivial.
@zhengruifeng I looked further into that today and what might be looking interesting is Intel MKL support for level-2 and level-3 operations on sparse vectors/matrices (https://software.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/blas-and-sparse-blas-routines/inspector-executor-sparse-blas-routines.html). I'll look into that further and see what's applicable to Spark, and how we could surface it. Feel free to reach out if you want to discuss it offline.
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] kiszk commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
kiszk commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-815914749
Any update on the performance number in the description by using the official release of JDK16?
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-815981031
> Any update on the performance number in the description by using the official release of JDK16?
```
[info] OpenJDK 64-Bit Server VM 16+36 on Linux 5.8.0-48-generic
[info] Intel(R) Xeon(R) E-2276G CPU @ 3.80GHz
```
```
[info] Running benchmark: daxpy
[info] daxpy: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 9 9 0 1109.2 0.9 1.0X
[info] vector 7 8 0 1359.4 0.7 1.2X
[info]
[info] Running benchmark: ddot
[info] ddot: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 11 11 0 924.5 1.1 1.0X
[info] vector 6 6 0 1757.9 0.6 1.9X
[info]
[info] Running benchmark: sdot
[info] sdot: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 9 10 0 1061.2 0.9 1.0X
[info] vector 3 3 0 3775.5 0.3 3.6X
[info]
[info] Running benchmark: dscal
[info] dscal: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 5 6 1 1855.5 0.5 1.0X
[info] vector 4 21 32 2380.3 0.4 1.3X
[info]
[info] Running benchmark: dspmv[U]
[info] dspmv[U]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 61 63 2 0.2 6135.3 1.0X
[info] vector 24 25 2 0.4 2427.7 2.5X
[info]
[info] Running benchmark: dspr[U]
[info] dspr[U]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 32 34 2 0.3 3181.0 1.0X
[info] vector 25 26 1 0.4 2532.1 1.3X
[info]
[info] Running benchmark: dsyr[U]
[info] dsyr[U]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 33 33 1 0.3 3279.5 1.0X
[info] vector 26 27 1 0.4 2627.4 1.2X
[info]
[info] Running benchmark: dgemv[N]
[info] dgemv[N]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 6 6 0 0.2 5695.1 1.0X
[info] vector 4 4 0 0.3 3711.8 1.5X
[info]
[info] Running benchmark: dgemv[T]
[info] dgemv[T]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 9 9 0 0.1 8909.8 1.0X
[info] vector 4 4 0 0.3 3711.8 2.4X
[info]
[info] Running benchmark: sgemv[N]
[info] sgemv[N]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 4 4 0 0.2 4330.9 1.0X
[info] vector 2 2 0 0.6 1801.9 2.4X
[info]
[info] Running benchmark: sgemv[T]
[info] sgemv[T]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 8 9 0 0.1 8415.5 1.0X
[info] vector 2 2 0 0.6 1683.8 5.0X
[info]
[info] Running benchmark: dgemm[N,N]
[info] dgemm[N,N]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 49 51 2 2.0 489.0 1.0X
[info] vector 30 33 5 3.4 296.8 1.6X
[info]
[info] Running benchmark: dgemm[N,T]
[info] dgemm[N,T]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 55 57 2 1.8 551.4 1.0X
[info] vector 29 30 1 3.4 291.8 1.9X
[info]
[info] Running benchmark: dgemm[T,N]
[info] dgemm[T,N]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 81 84 4 1.2 807.4 1.0X
[info] vector 20 21 2 5.1 198.0 4.1X
```
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-815296026
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] zhengruifeng commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
zhengruifeng commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-752369531
I have stupid questions: `VectorBLAS` in https://gist.github.com/luhenry/6b24ac146a110143ad31736caf7250e6#file-f2j-vs-vector-log was implemented in scala, now you switch to java, does this change speedup VectorBLAS?
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-747405702
I've run some benchmarks overnight comparing the implementation of the native, f2j, and vectorized implementations. You can find the results at https://gist.github.com/luhenry/2cda93cb40f3edef76cb499c896608a9
Some things I noted which are noteworthy or which I need to investigate further:
1. for `daxpy` and `ddot`, the vectorized version is equivalent or faster than the native implementation
2. for `dscal`, `dspr`, `dsyr`, and `sdot`, the vectorized version is faster than native on small vectors/matrices but slower on large ones; that is something I need to investigate in the Vector API implementation itself
3. for `dgemm` and `dgemv`, the performance is at best equivalent to f2j and native; I'm focusing on that now since `dgemm` is a major component of neural net training and logistical regressions; the problem is with my naive implementation of the algorithms and not necessarily with the Vector API itself.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry edited a comment on pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry edited a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-748687656
I updated the PR to depend on the package `dev.ludovic.vectorizedblas-blas` instead as it makes it a lot easier for me to go and evolve the algorithms independently of Spark, and for the integration to the build system. Let me know if that compromise of good for you.
As for the latest results, it's looking much better:
```
[info] f2jBLAS = com.github.fommil.netlib.F2jBLAS
[info] vectorBLAS = dev.ludovic.blas.VectorizedBLAS
[info]
[info] daxpy: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 45 45 1 223.7 4.5 1.0X
[info] vector 26 26 3 389.4 2.6 1.7X
[info]
[info] Unknown processor
[info] sdot: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 53 53 1 190.4 5.3 1.0X
[info] vector 16 17 1 607.4 1.6 3.2X
[info]
[info] Unknown processor
[info] ddot: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 73 73 1 137.3 7.3 1.0X
[info] vector 35 36 3 282.8 3.5 2.1X
[info]
[info] dscal: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 36 36 1 279.5 3.6 1.0X
[info] vector 21 21 0 481.4 2.1 1.7X
[info]
[info] dgemv[T]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 35 36 0 0.0 35458.6 1.0X
[info] vector 23 23 0 0.0 23415.6 1.5X
[info]
[info] dgemm[T,N]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 275 276 1 0.4 2753.6 1.0X
[info] vector 149 166 169 0.7 1488.5 1.8X
```
For much more detailed performance numbers on x86 (w/ AVX-2), I'm currently running a JMH benchmark covering more cases. I'll link to it as soon as it finishes (by tomorrow morning CET).
EDIT: I've added the results of the JMH benchmark testsuite at https://github.com/luhenry/vectorizedblas/releases/tag/v0.1.7
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-819115609
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] fommil commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
fommil commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-832481967
the f2j backend in spark is provided via netlib-java which can swap to using machine optimised binaries if they are present. There are reasons not to use netlib-java (and I no longer recommend it, preferring direct handcoded access to machine optimised libblas) so it's good to see alternatives being proposed. However, it is strange that you're not providing benchmarks against machine-optimised MKL (or otherwise) backends as described in http://fommil.com/scalax14/#/ The f2j backend is just the fallback and could be replaced in the most part (e.g. dgemm) with 10 lines of java code.
Lots of benchmarks over at https://github.com/fommil/matrix-toolkits-java as another consumer of netlib-java that address your comments about "memory copying" (which is incorrect).
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r547395790
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -267,7 +282,7 @@ private[spark] object BLAS extends Serializable {
x: DenseVector,
beta: Double,
y: DenseVector): Unit = {
- f2jBLAS.dspmv("U", n, alpha, A.values, x.values, 1, beta, y.values, 1)
+ javaBLAS.dspmv("U", n, alpha, A.values, x.values, 1, beta, y.values, 1)
Review comment:
The advantage of f2j over native is the absence of the overhead of switching between java and native. This overhead is particularly costly when the size of the inputs is small or whether the f2j implementation is just "good enough". The vector implementation is much faster than f2j on both small and large inputs (see https://github.com/luhenry/vectorizedblas/releases/tag/v0.1.11 -> jmh-results.csv for detailed numbers). It would then be wasteful not to take advantage of it when it's available.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #30810: [ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-746676925
Can one of the admins verify this patch?
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] kiszk commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
kiszk commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r545614692
##########
File path: mllib-local/src/vectorized/java/org/apache/spark/ml/linalg/VectorizedBLAS.java
##########
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.ml.linalg;
+
+import com.github.fommil.netlib.F2jBLAS;
+import jdk.incubator.vector.DoubleVector;
+import jdk.incubator.vector.FloatVector;
+import jdk.incubator.vector.VectorOperators;
+import jdk.incubator.vector.VectorSpecies;
+
+public class VectorizedBLAS extends F2jBLAS {
+
+ private final static VectorSpecies<Float> FMAX = FloatVector.SPECIES_MAX;
+ private final static VectorSpecies<Double> DMAX = DoubleVector.SPECIES_MAX;
+
+ // y += alpha * x
+ @Override
+ public void daxpy(int n, double alpha, double[] x, int incx, double[] y, int incy) {
+ if (incx == 1 && incy == 1 && n <= x.length && n <= y.length) {
+ if (alpha != 0.) {
Review comment:
Can we move this line before line 34?
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-749670059
Some more numbers. I ran a variant of https://github.com/apache/spark/blob/master/examples/src/main/scala/org/apache/spark/examples/ml/MultilayerPerceptronClassifierExample.scala to get some numbers comparing the f2j and vector implementations. Of 10 runs, the average training times are:
- vector: 81s
- f2j: 112.3s
This is with the same dataset, same test, simply passing `--add-modules=jdk.incubator.vector` or not to the JVM.
The JDK version used is build `16-ea+24`, and Spark has been compiled with `JAVA_HOME=/usr/lib/jvm/jdk-16+24 build/sbt package -Pvectorized -Djava.version=16`.
You can find the output at https://gist.github.com/luhenry/5b54ca0bb3e64a99c2f8796826fd373f
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r547393614
##########
File path: .github/workflows/build_and_test.yml
##########
@@ -394,6 +394,31 @@ jobs:
./build/mvn $MAVEN_CLI_OPTS -DskipTests -Pyarn -Pmesos -Pkubernetes -Phive -Phive-thriftserver -Phadoop-cloud -Djava.version=11 install
rm -rf ~/.m2/repository/org/apache/spark
+ java-17:
Review comment:
Happy to remove it if you don't think it has a place in this PR. I added it simply to get some tests ran on Spark's CI with Java 17, but not in the optic of pushing Spark to test more extensively on the latest version of the JDK.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r545558852
##########
File path: mllib-local/src/test/scala/org/apache/spark/ml/linalg/BLASBenchmark.scala
##########
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.ml.linalg
+
+import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
+import scala.util.Try
+
+import org.apache.spark.benchmark.{Benchmark, BenchmarkBase}
+import org.apache.spark.util.Utils
+
+/**
+ * Serialization benchmark for BLAS.
+ * To run this benchmark:
+ * {{{
+ * 1. without sbt: bin/spark-submit --class <this class> <spark mllib test jar>
+ * 2. build/sbt "mllib/test:runMain <this class>"
+ * 3. generate result: SPARK_GENERATE_BENCHMARK_FILES=1 build/sbt "mllib/test:runMain <this class>"
+ * Results will be written to "benchmarks/UDTSerializationBenchmark-results.txt".
+ * }}}
+ */
+object BLASBenchmark extends BenchmarkBase {
Review comment:
Thank you for providing this.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a change in pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r548210592
##########
File path: mllib-local/src/test/scala/org/apache/spark/ml/linalg/BLASBenchmark.scala
##########
@@ -0,0 +1,502 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.ml.linalg
+
+import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
+
+import org.apache.spark.benchmark.{Benchmark, BenchmarkBase}
+
+/**
+ * Serialization benchmark for BLAS.
+ * To run this benchmark:
+ * {{{
+ * 1. without sbt: bin/spark-submit --class <this class> <spark mllib test jar>
+ * 2. build/sbt "mllib/test:runMain <this class>"
+ * 3. generate result: SPARK_GENERATE_BENCHMARK_FILES=1 build/sbt "mllib/test:runMain <this class>"
+ * Results will be written to "benchmarks/BLASBenchmark-results.txt".
+ * }}}
+ */
+object BLASBenchmark extends BenchmarkBase {
+
+ override def runBenchmarkSuite(mainArgs: Array[String]): Unit = {
+
+ val iters = 1e2.toInt
+ val rnd = new scala.util.Random(0)
+
+ val f2jBLAS = new F2jBLAS
+ val nativeBLAS = NetlibBLAS.getInstance
+ val vectorBLAS =
+ try {
+ // scalastyle:off classforname
+ Class.forName("org.apache.spark.ml.linalg.VectorizedBLAS", true,
+ Option(Thread.currentThread().getContextClassLoader)
+ .getOrElse(getClass.getClassLoader))
+ .newInstance()
+ .asInstanceOf[NetlibBLAS]
+ // scalastyle:on classforname
+ } catch {
+ case _: Throwable => new F2jBLAS
+ }
Review comment:
Hmm, for this benchmark, do we want to fallback to `F2jBLAS`? I think we want to benchmark `VectorizedBLAS` actually.
I saw this benchmark doesn't add cases of native BLAS and vectorized BLAS if they aren't available, but if so, is it useful to run the benchmark?
##########
File path: mllib-local/src/test/scala/org/apache/spark/ml/linalg/BLASBenchmark.scala
##########
@@ -0,0 +1,502 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.ml.linalg
+
+import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
+
+import org.apache.spark.benchmark.{Benchmark, BenchmarkBase}
+
+/**
+ * Serialization benchmark for BLAS.
+ * To run this benchmark:
+ * {{{
+ * 1. without sbt: bin/spark-submit --class <this class> <spark mllib test jar>
+ * 2. build/sbt "mllib/test:runMain <this class>"
Review comment:
mllib-local?
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a change in pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r548206324
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -18,28 +18,51 @@
package org.apache.spark.ml.linalg
import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
-import com.github.fommil.netlib.BLAS.{getInstance => NativeBLAS}
/**
* BLAS routines for MLlib's vectors and matrices.
*/
private[spark] object BLAS extends Serializable {
- @transient private var _f2jBLAS: NetlibBLAS = _
+ @transient private var _javaBLAS: NetlibBLAS = _
@transient private var _nativeBLAS: NetlibBLAS = _
private val nativeL1Threshold: Int = 256
- // For level-1 function dspmv, use f2jBLAS for better performance.
- private[ml] def f2jBLAS: NetlibBLAS = {
- if (_f2jBLAS == null) {
- _f2jBLAS = new F2jBLAS
+ // For level-1 function dspmv, use javaBLAS for better performance.
+ private[ml] def javaBLAS: NetlibBLAS = {
+ if (_javaBLAS == null) {
+ _javaBLAS =
+ try {
+ // scalastyle:off classforname
+ Class.forName("org.apache.spark.ml.linalg.VectorizedBLAS", true,
+ Option(Thread.currentThread().getContextClassLoader)
+ .getOrElse(getClass.getClassLoader))
+ .newInstance()
+ .asInstanceOf[NetlibBLAS]
+ // scalastyle:on classforname
+ } catch {
+ case _: Throwable => new F2jBLAS
+ }
+ }
+ _javaBLAS
+ }
+
+ // For level-3 routines, we use the native BLAS.
+ private[ml] def nativeBLAS: NetlibBLAS = {
+ if (_nativeBLAS == null) {
+ _nativeBLAS =
+ if (NetlibBLAS.getInstance.isInstanceOf[F2jBLAS]) {
+ javaBLAS
+ } else {
+ NetlibBLAS.getInstance
Review comment:
`NetlibBLAS.getInstance` will be called twice for `else` condition. Will it do some initialization twice? Maybe calling `NetlibBLAS.getInstance` before `if...else`?
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-815352263
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/137033/
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-819118534
**[Test build #137313 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137313/testReport)** for PR 30810 at commit [`10595df`](https://github.com/apache/spark/commit/10595df8cd6ad01c6a9ae5cde49a9974ae58b667).
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] fommil edited a comment on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
fommil edited a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-832481967
the f2j backend in spark is provided via netlib-java which can swap to using machine optimised binaries if they are present. There are reasons not to use netlib-java (and I no longer recommend it, preferring direct handcoded access to machine optimised libblas) so it's good to see alternatives being proposed.
However, it is strange that you're not providing benchmarks against machine-optimised MKL (or otherwise) backends as described in http://fommil.com/scalax14/#/ The f2j backend is just the fallback and could be replaced in the most part (e.g. dgemm) with 10 lines of java code.
Lots of benchmarks over at https://github.com/fommil/matrix-toolkits-java as another consumer of netlib-java that address your comments about "memory copying" (which is incorrect).
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-817896133
Jenkins test this please
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen closed pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen closed pull request #30810:
URL: https://github.com/apache/spark/pull/30810
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-818071541
**[Test build #137222 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137222/testReport)** for PR 30810 at commit [`d93b274`](https://github.com/apache/spark/commit/d93b27410b8223605f4891eae3f675914c8d0346).
* This patch passes all tests.
* This patch **does not merge cleanly**.
* This patch adds the following public classes _(experimental)_:
* `public class VectorizedBLAS extends F2jBLAS `
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on a change in pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r616738347
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -18,28 +18,51 @@
package org.apache.spark.ml.linalg
import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
-import com.github.fommil.netlib.BLAS.{getInstance => NativeBLAS}
/**
* BLAS routines for MLlib's vectors and matrices.
*/
private[spark] object BLAS extends Serializable {
- @transient private var _f2jBLAS: NetlibBLAS = _
+ @transient private var _javaBLAS: NetlibBLAS = _
@transient private var _nativeBLAS: NetlibBLAS = _
private val nativeL1Threshold: Int = 256
Review comment:
I would go even as far as using nativeBLAS exclusively for level-3 operations, and never for level-1 and level-2. The cost of copying the data from managed memory to native memory (necessary to pass the array to native code) is too great relative to the small speed up of native for the level-1 and level-2 routines.
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] fommil commented on a change in pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
fommil commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r626335537
##########
File path: mllib-local/src/main/scala/org/apache/spark/ml/linalg/BLAS.scala
##########
@@ -18,28 +18,51 @@
package org.apache.spark.ml.linalg
import com.github.fommil.netlib.{BLAS => NetlibBLAS, F2jBLAS}
-import com.github.fommil.netlib.BLAS.{getInstance => NativeBLAS}
/**
* BLAS routines for MLlib's vectors and matrices.
*/
private[spark] object BLAS extends Serializable {
- @transient private var _f2jBLAS: NetlibBLAS = _
+ @transient private var _javaBLAS: NetlibBLAS = _
@transient private var _nativeBLAS: NetlibBLAS = _
private val nativeL1Threshold: Int = 256
Review comment:
"small speed up of native for the level-1 and level-2 routines." I think you need to do some more analysis on this. Native can be 10x faster than JVM for reasonable sized matrices. However, as shown in https://github.com/fommil/matrix-toolkits-java the EJML and common-math project are faster for matrices of 10x10 or smaller. If you want to heavily optimise for those usecases, then swap to using EJML which is heavily optimised for that usecase (not just "something on the JVM")
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-815253955
Jenkins retest this please
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-815203637
@dongjoon-hyun @srowen @viirya @kiszk I've updated the PR by merging the latest master. Let me know if there is anything else before it's ready to merge.
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry edited a comment on pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry edited a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-748687656
I updated the PR to depend on the package `dev.ludovic.vectorizedblas-blas` instead as it makes it a lot easier for me to go and evolve the algorithms independently of Spark, and for the integration to the build system. Let me know if that compromise of good for you.
As for the latest results, it's looking much better:
```
[info] f2jBLAS = com.github.fommil.netlib.F2jBLAS
[info] vectorBLAS = dev.ludovic.blas.VectorizedBLAS
[info]
[info] daxpy: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 45 45 1 223.7 4.5 1.0X
[info] vector 26 26 3 389.4 2.6 1.7X
[info]
[info] Unknown processor
[info] sdot: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 53 53 1 190.4 5.3 1.0X
[info] vector 16 17 1 607.4 1.6 3.2X
[info]
[info] Unknown processor
[info] ddot: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 73 73 1 137.3 7.3 1.0X
[info] vector 35 36 3 282.8 3.5 2.1X
[info]
[info] dscal: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 36 36 1 279.5 3.6 1.0X
[info] vector 21 21 0 481.4 2.1 1.7X
[info]
[info] dgemv[T]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 35 36 0 0.0 35458.6 1.0X
[info] vector 23 23 0 0.0 23415.6 1.5X
[info]
[info] dgemm[T,N]: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
[info] ------------------------------------------------------------------------------------------------------------------------
[info] f2j 275 276 1 0.4 2753.6 1.0X
[info] vector 149 166 169 0.7 1488.5 1.8X
```
For much more detailed performance numbers on x86 (w/ AVX-2), I'm currently running a JMH benchmark covering more cases. I'll link to it as soon as it finishes (by tomorrow morning CET).
EDIT: I've added the results of the JMH benchmark suite at https://github.com/luhenry/vectorizedblas/releases/tag/v0.1.7
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] zhengruifeng commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
zhengruifeng commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-819164280
@srowen It is OK, I will wait for this PR and then adjust my one.
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-753980219
> This looks fascinating. However, can we hold on this PR until Java 16 become available as GA? I guess Java 16 will be released on next March 2021.
I can definitely wait for Java 16 to be released as GA to merge this PR. What should I do with this PR until then?
> I converted this issue as a subtask of [SPARK-33772](https://issues.apache.org/jira/browse/SPARK-33772) (Build and Run Spark on Java 17) because Apache Spark officially will support Java 17 LTS (including this nice feature) eventually.
Thank you. Over the holidays break, I was also thinking how we could use the [Foreign Linker API](https://openjdk.java.net/jeps/389) to accelerate calls to OpenBLAS and MKL over JNI. That could be an experiment for support with Java 17 as well.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-753980958
>
>
> I have one stupid question:
> `VectorBLAS` in https://gist.github.com/luhenry/6b24ac146a110143ad31736caf7250e6#file-f2j-vs-vector-log was implemented in scala, now you switch to java, does this change speedup VectorBLAS?
The results at https://github.com/apache/spark/pull/30810#issuecomment-749451215 are more up-to-date and run with the Java version of `VectorizedBLAS`. https://gist.github.com/luhenry/6b24ac146a110143ad31736caf7250e6#file-f2j-vs-vector-log is by now obsolete.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] luhenry commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
luhenry commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r546452130
##########
File path: project/SparkBuild.scala
##########
@@ -415,6 +415,11 @@ object SparkBuild extends PomBuild {
outputStrategy in run := Some (StdoutOutput),
javaOptions += "-Xmx2g",
+ javaOptions += {
+ val versionParts = System.getProperty("java.version").split("[+.\\-]+", 3)
+ var major = versionParts(0).toInt
+ if (major >= 16) "--add-modules=jdk.incubator.vector" else ""
Review comment:
No, it doesn't yet and it's unlikely to happen before Project Valhalla (inline/value types) is going to land into JDK mainline.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-817910611
**[Test build #137222 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137222/testReport)** for PR 30810 at commit [`d93b274`](https://github.com/apache/spark/commit/d93b27410b8223605f4891eae3f675914c8d0346).
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r545559673
##########
File path: project/SparkBuild.scala
##########
@@ -415,6 +415,11 @@ object SparkBuild extends PomBuild {
outputStrategy in run := Some (StdoutOutput),
javaOptions += "-Xmx2g",
+ javaOptions += {
+ val versionParts = System.getProperty("java.version").split("[+.\\-]+", 3)
+ var major = versionParts(0).toInt
+ if (major >= 16) "--add-modules=jdk.incubator.vector" else ""
Review comment:
Do you think `Java 17 (LTS)` has this an official module (not `incubator`)?
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on a change in pull request #30810: [WIP][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
srowen commented on a change in pull request #30810:
URL: https://github.com/apache/spark/pull/30810#discussion_r547428965
##########
File path: .github/workflows/build_and_test.yml
##########
@@ -394,6 +394,31 @@ jobs:
./build/mvn $MAVEN_CLI_OPTS -DskipTests -Pyarn -Pmesos -Pkubernetes -Phive -Phive-thriftserver -Phadoop-cloud -Djava.version=11 install
rm -rf ~/.m2/repository/org/apache/spark
+ java-17:
Review comment:
I think we can remove it ... just because I'm not sure it'll even pass although it's very close from some manual testing. We'll probably add Java 14 as a profile soon, which is all but the same for test purposes as 17 (w.r.t Spark) and eventually yes Java 17. I don't feel strongly about it
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-815268073
**[Test build #137033 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137033/testReport)** for PR 30810 at commit [`521cba2`](https://github.com/apache/spark/commit/521cba2c9c4b0ca2ece7bd05adf5a477b914c1e0).
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #30810: [SPARK-33882][ML] Add a vectorized BLAS implementation
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30810:
URL: https://github.com/apache/spark/pull/30810#issuecomment-815290230
Kubernetes integration test unable to build dist.
exiting with code: 1
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/41611/
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org