Skip to content

Commit 17b797f

Browse files
authored
Add JNI-based BLAS, LAPACK, and ARPACK implementations (#1)
* v2-SNAPSHOT * Add JNI-based wrapper for BLAS * Print which implementation is currently running for benchmark Since java or native can mean more things, let's just log it out. * Add JDK17 profile, just in case. * Try JNIBLAS before ForeignLinkerBLAS The former is faster because it doesn't require to copy memory from the heap to native memory * Use Fortran symbols directly Still without using any external library. * Remove leftover debug comments * Rename dev.ludovic.netlib.blas.VectorizedBLAS to dev.ludovic.netlib.blas.VectorBLAS This aligns with dev.ludovic.netlib.blas.ForeignLinkerBLAS * fixup! Rename dev.ludovic.netlib.blas.VectorizedBLAS to dev.ludovic.netlib.blas.VectorBLAS * Remove com.github.fommil from BLAS fully and WIP for LAPACK * Make sure critical JNI regions don't contain unecessary JNI calls * Do better error handling + Load org.netlib.util.*W types * Base implementation for LAPACK + Implement calls used by Spark I still need to come up with proper testing. * Add native implementation for benchmarking JDK 8 and 11 It's now supported with JNIBLAS, JNILAPACK, and (upcoming) JNIARPACK. * Allow manual trigger of the workflow * Relax the compiler warnings for now * Fix installed dependencies * Implement some more BLAS calls in JNIBLAS * Fix bound condition check It triggered the "Vector API breaks JNI". Turns out testing just got better and uncovered a bug. * Add code coverage information * Add scaffolding for JNIARPACK * Make sure license is consistent across all files * There might be cases where we want to make a release on a SNAPSHOT tag * Add scaffolding for all ARPACK, BLAS, and LAPACK routines * Fix surefire:test jacoco wouldn't setup the argLine variable. Just set it to "" * Add missing libarpack2-dev dependency on CI * Cache M2 repository to speed up CI * Relax caching across JDK versions * Implement all BLAS routines for JNIBLAS * Add generator for JNI * Compiler complains that __ret may be uninitialized It's because it doesn't know Throw never returns * Generate function for NotImplemented + Reduce whitespace noise * Remove -Wno-unused-function and -Wno-unused-parameter warnings * Generate the totality of jni.c for BLAS, ARPACK, and LAPACK It makes it much much easier to manager * Add null and index checks for double/float arrays * Cache more often * Use full name of library for dev.ludovic.netlib.{blas,lapack,arpack}.nativeLib * Skip unimplemented tests * Wrap calls to Objects.requireNonNull for consistency with checkIndex * Add {BLAS,LAPACK,ARPACK}.getInstance helpers * Rename _*_offset parameters to offset* * Remove unused test resources and methods
1 parent 12c0570 commit 17b797f

File tree

849 files changed

+65822
-6272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

849 files changed

+65822
-6272
lines changed

.github/workflows/build-and-test.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@ jobs:
2020
jdk: [8, 11, 16]
2121
steps:
2222
- uses: actions/checkout@v2
23+
- name: Cache M2 local repository
24+
uses: actions/cache@v2
25+
with:
26+
path: ~/.m2/repository
27+
key: m2
2328
- name: Install dependencies
2429
run: |
2530
sudo apt-get -y update
26-
sudo apt-get -y install libopenblas-dev gcc-aarch64-linux-gnu gcc-x86-64-linux-gnu
31+
sudo apt-get -y install libopenblas-dev libarpack2-dev gcc-aarch64-linux-gnu gcc-x86-64-linux-gnu
2732
# Build with JDK 16
2833
- name: Set up JDK 16
2934
uses: actions/setup-java@v1

.github/workflows/release.yml

+16-15
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
push:
66
tags:
77
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
8-
- '!v*-SNAPSHOT' # But not v*-SNAPSHOT, i.e. v2-SNAPSHOT
98
workflow_dispatch:
109

1110
name: Release
@@ -21,10 +20,15 @@ jobs:
2120
jdk: [8, 11, 16]
2221
steps:
2322
- uses: actions/checkout@v2
23+
- name: Cache M2 local repository
24+
uses: actions/cache@v2
25+
with:
26+
path: ~/.m2/repository
27+
key: m2
2428
- name: Install dependencies
2529
run: |
2630
sudo apt-get -y update
27-
sudo apt-get -y install libopenblas-dev gcc-aarch64-linux-gnu gcc-x86-64-linux-gnu
31+
sudo apt-get -y install libopenblas-dev libarpack2-dev gcc-aarch64-linux-gnu gcc-x86-64-linux-gnu
2832
# Build with JDK 16
2933
- name: Set up JDK 16
3034
uses: actions/setup-java@v1
@@ -49,6 +53,15 @@ jobs:
4953
release_upload_url: ${{ steps.create_release.outputs.upload_url }}
5054
steps:
5155
- uses: actions/checkout@v2
56+
- name: Cache M2 local repository
57+
uses: actions/cache@v2
58+
with:
59+
path: ~/.m2/repository
60+
key: m2
61+
- name: Install dependencies
62+
run: |
63+
sudo apt-get -y update
64+
sudo apt-get -y install gcc-aarch64-linux-gnu gcc-x86-64-linux-gnu
5265
- name: Set up JDK 16
5366
uses: actions/setup-java@v1
5467
with: # running setup-java again overwrites the settings.xml
@@ -85,7 +98,7 @@ jobs:
8598
strategy:
8699
matrix:
87100
jdk: [8, 11, 16]
88-
implementation: ["f2j", "java"]
101+
implementation: ["f2j", "java", "native"]
89102
filter: ["dev.ludovic.netlib.benchmarks.blas.l1", "dev.ludovic.netlib.benchmarks.blas.l2", "dev.ludovic.netlib.benchmarks.blas.l3"]
90103
include:
91104
- jdk: 16
@@ -100,18 +113,6 @@ jobs:
100113
implementation: "java"
101114
filter: "dev.ludovic.netlib.benchmarks.blas.l3"
102115
jvmArgs: "--add-modules=jdk.incubator.vector"
103-
- jdk: 16
104-
implementation: "native"
105-
filter: "dev.ludovic.netlib.benchmarks.blas.l1"
106-
jvmArgs: "--add-modules=jdk.incubator.foreign -Dforeign.restricted=permit"
107-
- jdk: 16
108-
implementation: "native"
109-
filter: "dev.ludovic.netlib.benchmarks.blas.l2"
110-
jvmArgs: "--add-modules=jdk.incubator.foreign -Dforeign.restricted=permit"
111-
- jdk: 16
112-
implementation: "native"
113-
filter: "dev.ludovic.netlib.benchmarks.blas.l3"
114-
jvmArgs: "--add-modules=jdk.incubator.foreign -Dforeign.restricted=permit"
115116
steps:
116117
- name: Set up JDK ${{ matrix.jdk }}
117118
uses: actions/setup-java@v1

arpack/pom.xml

+13-6
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,24 @@ information or have any questions.
3030
<parent>
3131
<groupId>dev.ludovic.netlib</groupId>
3232
<artifactId>parent</artifactId>
33-
<version>1.3.2</version>
33+
<version>2-SNAPSHOT</version>
3434
<relativePath>../pom.xml</relativePath>
3535
</parent>
3636

3737
<groupId>dev.ludovic.netlib</groupId>
3838
<artifactId>arpack</artifactId>
39-
<version>1.3.2</version>
39+
<version>2-SNAPSHOT</version>
4040
<packaging>jar</packaging>
4141

4242
<properties>
4343
<junit.version>5.5.2</junit.version>
44-
<netlib.java.version>1.1.2</netlib.java.version>
4544
</properties>
4645

4746
<dependencies>
4847
<dependency>
49-
<groupId>com.github.fommil.netlib</groupId>
50-
<artifactId>core</artifactId>
51-
<version>${netlib.java.version}</version>
48+
<groupId>net.sourceforge.f2j</groupId>
49+
<artifactId>arpack_combined_all</artifactId>
50+
<version>0.1</version>
5251
</dependency>
5352

5453
<dependency>
@@ -64,4 +63,12 @@ information or have any questions.
6463
<scope>test</scope>
6564
</dependency>
6665
</dependencies>
66+
67+
<build>
68+
<plugins>
69+
<plugin>
70+
<artifactId>maven-antrun-plugin</artifactId>
71+
</plugin>
72+
</plugins>
73+
</build>
6774
</project>

arpack/src/main/java/dev/ludovic/netlib/ARPACK.java

+12
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,20 @@
2525

2626
package dev.ludovic.netlib;
2727

28+
import java.util.logging.Level;
29+
import java.util.logging.Logger;
30+
2831
public interface ARPACK {
2932

33+
public static ARPACK getInstance() {
34+
try {
35+
return dev.ludovic.netlib.NativeARPACK.getInstance();
36+
} catch (Throwable t) {
37+
Logger.getLogger(ARPACK.class.getName()).warning("Failed to load implementation from:dev.ludovic.netlib.NativeARPACK");
38+
}
39+
return dev.ludovic.netlib.JavaARPACK.getInstance();
40+
}
41+
3042
public void dmout(int lout, int m, int n, double[] a, int lda, int idigit, String ifmt);
3143
public void dmout(int lout, int m, int n, double[] a, int offseta, int lda, int idigit, String ifmt);
3244
public void smout(int lout, int m, int n, float[] a, int lda, int idigit, String ifmt);

arpack/src/main/java/dev/ludovic/netlib/JavaARPACK.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
public interface JavaARPACK extends ARPACK {
2929

3030
public static JavaARPACK getInstance() {
31-
return dev.ludovic.netlib.arpack.NetlibF2jARPACK.getInstance();
31+
return dev.ludovic.netlib.arpack.F2jARPACK.getInstance();
3232
}
3333
}

arpack/src/main/java/dev/ludovic/netlib/NativeARPACK.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public interface NativeARPACK extends ARPACK {
3232

3333
public static NativeARPACK getInstance() {
3434
try {
35-
return dev.ludovic.netlib.arpack.NetlibNativeARPACK.getInstance();
35+
return dev.ludovic.netlib.arpack.JNIARPACK.getInstance();
3636
} catch (Throwable t) {
37-
Logger.getLogger(NativeARPACK.class.getName()).warning("Failed to load implementation from:dev.ludovic.netlib.arpack.NetlibNativeARPACK");
37+
Logger.getLogger(NativeARPACK.class.getName()).warning("Failed to load implementation from:dev.ludovic.netlib.arpack.JNIARPACK");
3838
}
3939
throw new RuntimeException("Unable to load native implementation");
4040
}

0 commit comments

Comments
 (0)