-
Notifications
You must be signed in to change notification settings - Fork 744
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add presets for OpenBLAS/MKL (issue #112)
- Loading branch information
Showing
11 changed files
with
46,877 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Copyright (c) 2011-2014, The OpenBLAS Project | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in | ||
the documentation and/or other materials provided with the | ||
distribution. | ||
3. Neither the name of the OpenBLAS project nor the names of | ||
its contributors may be used to endorse or promote products | ||
derived from this software without specific prior written | ||
permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
diff -ruN OpenBLAS-0.2.18/common.h OpenBLAS-0.2.18-android/common.h | ||
--- OpenBLAS-0.2.18/common.h 2016-04-13 04:29:19.000000000 +0900 | ||
+++ OpenBLAS-0.2.18-android/common.h 2016-08-24 14:04:13.057535318 +0900 | ||
@@ -100,9 +100,9 @@ | ||
#ifdef OS_ANDROID | ||
#define NO_SYSV_IPC | ||
//Android NDK only supports complex.h since Android 5.0 | ||
-#if __ANDROID_API__ < 21 | ||
+//#if __ANDROID_API__ < 21 | ||
#define FORCE_OPENBLAS_COMPLEX_STRUCT | ||
-#endif | ||
+//#endif | ||
#endif | ||
|
||
#ifdef OS_WINDOWS | ||
diff -ruN OpenBLAS-0.2.18/exports/Makefile OpenBLAS-0.2.18-android/exports/Makefile | ||
--- OpenBLAS-0.2.18/exports/Makefile 2016-04-13 04:29:19.000000000 +0900 | ||
+++ OpenBLAS-0.2.18-android/exports/Makefile 2016-08-24 12:24:58.661889197 +0900 | ||
@@ -118,7 +118,7 @@ | ||
dllinit.$(SUFFIX) : dllinit.c | ||
$(CC) $(CFLAGS) -c -o $(@F) -s $< | ||
|
||
-ifeq ($(OSNAME), $(filter $(OSNAME),Linux SunOS)) | ||
+ifeq ($(OSNAME), $(filter $(OSNAME),Android Linux SunOS)) | ||
|
||
so : ../$(LIBSONAME) | ||
|
||
@@ -132,13 +132,13 @@ | ||
ifneq ($(C_COMPILER), LSB) | ||
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \ | ||
-Wl,--whole-archive $< -Wl,--no-whole-archive \ | ||
- -Wl,-soname,$(LIBPREFIX).so.$(MAJOR_VERSION) $(EXTRALIB) | ||
+ -Wl,-soname,$(LIBPREFIX).so $(EXTRALIB) | ||
$(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK. | ||
else | ||
#for LSB | ||
env LSBCC_SHAREDLIBS=gfortran $(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \ | ||
-Wl,--whole-archive $< -Wl,--no-whole-archive \ | ||
- -Wl,-soname,$(LIBPREFIX).so.$(MAJOR_VERSION) $(EXTRALIB) | ||
+ -Wl,-soname,$(LIBPREFIX).so $(EXTRALIB) | ||
$(FC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK. | ||
endif | ||
rm -f linktest | ||
diff -ruN OpenBLAS-0.2.18/kernel/arm/zdot.c OpenBLAS-0.2.18-android/kernel/arm/zdot.c | ||
--- OpenBLAS-0.2.18/kernel/arm/zdot.c 2016-04-13 04:29:19.000000000 +0900 | ||
+++ OpenBLAS-0.2.18-android/kernel/arm/zdot.c 2016-08-24 14:23:19.671303569 +0900 | ||
@@ -36,12 +36,12 @@ | ||
|
||
#include "common.h" | ||
|
||
-#ifndef _MSC_VER | ||
-#include <complex.h> | ||
-FLOAT _Complex CNAME(BLASLONG n, FLOAT *x, BLASLONG inc_x, FLOAT *y, BLASLONG inc_y) | ||
-#else | ||
+//#ifndef _MSC_VER | ||
+//#include <complex.h> | ||
+//FLOAT _Complex CNAME(BLASLONG n, FLOAT *x, BLASLONG inc_x, FLOAT *y, BLASLONG inc_y) | ||
+//#else | ||
OPENBLAS_COMPLEX_FLOAT CNAME(BLASLONG n, FLOAT *x, BLASLONG inc_x, FLOAT *y, BLASLONG inc_y) | ||
-#endif | ||
+//#endif | ||
{ | ||
BLASLONG i=0; | ||
BLASLONG ix=0,iy=0; | ||
diff -ruN OpenBLAS-0.2.18/lapack-netlib/LAPACKE/include/lapacke_config.h OpenBLAS-0.2.18-android/lapack-netlib/LAPACKE/include/lapacke_config.h | ||
--- OpenBLAS-0.2.18/lapack-netlib/LAPACKE/include/lapacke_config.h 2016-08-24 14:05:16.424908207 +0900 | ||
+++ OpenBLAS-0.2.18-android/lapack-netlib/LAPACKE/include/lapacke_config.h 2016-08-24 14:05:46.816566659 +0900 | ||
@@ -36,9 +36,9 @@ | ||
|
||
// For Android prior to API 21 (no <complex> include) | ||
#if defined(__ANDROID__) | ||
-#if __ANDROID_API__ < 21 | ||
+//#if __ANDROID_API__ < 21 | ||
#define LAPACK_COMPLEX_STRUCTURE | ||
-#endif | ||
+//#endif | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
diff -ruN OpenBLAS-0.2.18/Makefile OpenBLAS-0.2.18-android/Makefile | ||
--- OpenBLAS-0.2.18/Makefile 2016-04-13 04:29:19.000000000 +0900 | ||
+++ OpenBLAS-0.2.18-android/Makefile 2016-08-24 12:24:19.678027696 +0900 | ||
@@ -81,7 +81,7 @@ | ||
|
||
shared : | ||
ifndef NO_SHARED | ||
-ifeq ($(OSNAME), $(filter $(OSNAME),Linux SunOS)) | ||
+ifeq ($(OSNAME), $(filter $(OSNAME),Android Linux SunOS)) | ||
@$(MAKE) -C exports so | ||
@ln -fs $(LIBSONAME) $(LIBPREFIX).so | ||
@ln -fs $(LIBSONAME) $(LIBPREFIX).so.$(MAJOR_VERSION) | ||
diff -ruN OpenBLAS-0.2.18/Makefile.install OpenBLAS-0.2.18-android/Makefile.install | ||
--- OpenBLAS-0.2.18/Makefile.install 2016-04-13 04:29:19.000000000 +0900 | ||
+++ OpenBLAS-0.2.18-android/Makefile.install 2016-08-24 12:24:29.226238701 +0900 | ||
@@ -64,7 +64,7 @@ | ||
#for install shared library | ||
ifndef NO_SHARED | ||
@echo Copying the shared library to $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) | ||
-ifeq ($(OSNAME), $(filter $(OSNAME),Linux SunOS)) | ||
+ifeq ($(OSNAME), $(filter $(OSNAME),Android Linux SunOS)) | ||
@install -pm755 $(LIBSONAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) | ||
@cd $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) ; \ | ||
ln -fs $(LIBSONAME) $(LIBPREFIX).so ; \ | ||
@@ -101,7 +101,7 @@ | ||
|
||
ifndef NO_SHARED | ||
#ifeq logical or | ||
-ifeq ($(OSNAME), $(filter $(OSNAME),Linux FreeBSD NetBSD)) | ||
+ifeq ($(OSNAME), $(filter $(OSNAME),Android Linux FreeBSD NetBSD)) | ||
@echo "SET(OpenBLAS_LIBRARIES ${OPENBLAS_LIBRARY_DIR}/$(LIBPREFIX).so)" >> $(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG) | ||
endif | ||
ifeq ($(OSNAME), $(filter $(OSNAME),WINNT CYGWIN_NT)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
JavaCPP Presets for OpenBLAS | ||
============================ | ||
|
||
Introduction | ||
------------ | ||
This directory contains the JavaCPP Presets module for: | ||
|
||
* OpenBLAS 0.2.18 http://www.openblas.net/ | ||
|
||
Please refer to the parent README.md file for more detailed information about the JavaCPP Presets. | ||
|
||
|
||
Documentation | ||
------------- | ||
Java API documentation is available here: | ||
|
||
* http://bytedeco.org/javacpp-presets/openblas/apidocs/ | ||
|
||
∗ The JNI bindings actually link with [Intel MKL](https://software.intel.com/intel-mkl) instead if found on the "java.library.path". | ||
|
||
|
||
Sample Usage | ||
------------ | ||
Here is a simple example of LAPACK ported to Java from this C source file: | ||
|
||
* https://github.com/bitfusionio/OpenBLAS/blob/master/lapack-netlib/lapacke/example/example_DGELS_rowmajor.c | ||
|
||
We can use [Maven 3](http://maven.apache.org/) to download and install automatically all the class files as well as the native binaries. To run this sample code, after creating the `pom.xml` and `src/main/java/ExampleDGELSrowmajor.java` source files below, simply execute on the command line: | ||
```bash | ||
$ mvn compile exec:java | ||
``` | ||
|
||
### The `pom.xml` build file | ||
```xml | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.bytedeco.javacpp-presets.openblas</groupId> | ||
<artifactId>openblas</artifactId> | ||
<version>1.2</version> | ||
<properties> | ||
<exec.mainClass>ExampleDGELSrowmajor</exec.mainClass> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.bytedeco.javacpp-presets</groupId> | ||
<artifactId>openblas</artifactId> | ||
<version>0.2.18-1.2</version> | ||
</dependency> | ||
</dependencies> | ||
</project> | ||
``` | ||
|
||
### The `src/main/java/ExampleDGELSrowmajor.java` source file | ||
```java | ||
/* | ||
LAPACKE Example : Calling DGELS using row-major order | ||
===================================================== | ||
The program computes the solution to the system of linear | ||
equations with a square matrix A and multiple | ||
right-hand sides B, where A is the coefficient matrix | ||
and b is the right-hand side matrix: | ||
Description | ||
=========== | ||
In this example, we wish solve the least squares problem min_x || B - Ax || | ||
for two right-hand sides using the LAPACK routine DGELS. For input we will | ||
use the 5-by-3 matrix | ||
( 1 1 1 ) | ||
( 2 3 4 ) | ||
A = ( 3 5 2 ) | ||
( 4 2 5 ) | ||
( 5 4 3 ) | ||
and the 5-by-2 matrix | ||
( -10 -3 ) | ||
( 12 14 ) | ||
B = ( 14 12 ) | ||
( 16 16 ) | ||
( 18 16 ) | ||
We will first store the input matrix as a static C two-dimensional array, | ||
which is stored in row-major order, and let LAPACKE handle the work space | ||
array allocation. The LAPACK base name for this function is gels, and we | ||
will use double precision (d), so the LAPACKE function name is LAPACKE_dgels. | ||
thus lda=3 and ldb=2. The output for each right hand side is stored in b as | ||
consecutive vectors of length 3. The correct answer for this problem is | ||
the 3-by-2 matrix | ||
( 2 1 ) | ||
( 1 1 ) | ||
( 1 2 ) | ||
A complete C program for this example is given below. Note that when the arrays | ||
are passed to the LAPACK routine, they must be dereferenced, since LAPACK is | ||
expecting arrays of type double *, not double **. | ||
LAPACKE Interface | ||
================= | ||
LAPACKE_dgels (row-major, high-level) Example Program Results | ||
-- LAPACKE Example routine (version 3.5.0) -- | ||
-- LAPACK is a software package provided by Univ. of Tennessee, -- | ||
-- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- | ||
February 2012 | ||
*/ | ||
/* Calling DGELS using row-major order */ | ||
|
||
/* Includes */ | ||
import static org.bytedeco.javacpp.openblas.*; | ||
|
||
public class ExampleDGELSrowmajor { | ||
/* Auxiliary routine: printing a matrix */ | ||
static void print_matrix_rowmajor(String desc, int m, int n, double[] mat, int ldm) { | ||
int i, j; | ||
System.out.printf("\n %s\n", desc); | ||
|
||
for (i = 0; i < m; i++) { | ||
for (j = 0; j < n; j++) System.out.printf(" %6.2f", mat[i*ldm+j]); | ||
System.out.printf("\n"); | ||
} | ||
} | ||
|
||
|
||
/* Auxiliary routine: printing a matrix */ | ||
static void print_matrix_colmajor(String desc, int m, int n, double[] mat, int ldm) { | ||
int i, j; | ||
System.out.printf("\n %s\n", desc); | ||
|
||
for (i = 0; i < m; i++) { | ||
for (j = 0; j < n; j++) System.out.printf(" %6.2f", mat[i+j*ldm]); | ||
System.out.printf("\n"); | ||
} | ||
} | ||
|
||
/* Auxiliary routine: printing a vector of integers */ | ||
static void print_vector(String desc, int n, int[] vec) { | ||
int j; | ||
System.out.printf("\n %s\n", desc); | ||
for (j = 0; j < n; j++) System.out.printf(" %6i", vec[j]); | ||
System.out.printf("\n"); | ||
} | ||
|
||
/* Main program */ | ||
public static void main(String[] args) { | ||
/* Locals */ | ||
double[] A = {1, 1, 1, 2, 3, 4, 3, 5, 2, 4, 2, 5, 5, 4, 3}; | ||
double[] b = {-10, -3, 12, 14, 14, 12, 16, 16, 18, 16}; | ||
int info, m, n, lda, ldb, nrhs; | ||
int i, j; | ||
|
||
/* Initialization */ | ||
m = 5; | ||
n = 3; | ||
nrhs = 2; | ||
lda = 3; | ||
ldb = 2; | ||
|
||
/* Print Entry Matrix */ | ||
print_matrix_rowmajor("Entry Matrix A", m, n, A, lda); | ||
/* Print Right Rand Side */ | ||
print_matrix_rowmajor("Right Hand Side b", n, nrhs, b, ldb); | ||
System.out.println(); | ||
|
||
/* Executable statements */ | ||
System.out.println("LAPACKE_dgels (row-major, high-level) Example Program Results"); | ||
/* Solve least squares problem*/ | ||
info = LAPACKE_dgels(LAPACK_ROW_MAJOR, (byte)'N', m, n, nrhs, A, lda, b, ldb); | ||
|
||
/* Print Solution */ | ||
print_matrix_rowmajor("Solution", n, nrhs, b, ldb); | ||
System.out.println(); | ||
System.exit(0); | ||
} | ||
} /* End of LAPACKE_dgels Example */ | ||
``` |
Oops, something went wrong.