8000 Merge pull request #4 from pavanky/master · wcork/arrayfire-java@72814d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 72814d8

Browse files
committed
Merge pull request arrayfire#4 from pavanky/master
Changes to make the wrapper compatible with ArrayFire 3.x
2 parents c068c9f + 7d3d436 commit 72814d8

21 files changed

+1373
-1644
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ AF_JAVA_JAR = $(AF_JAVA_PATH)/ArrayFire.jar
1616
AF_JAVA_MANIFEST= $(AF_JAVA_PATH)/Manifest.txt
1717
AF_JAVA_COM = $(shell ls com/arrayfire/*.java)
1818
AF_JAVA_CLASSES = $(patsubst %.java, %.class, $(AF_JAVA_COM))
19+
AF_JNI_SRC = $(shell ls $(AF_JAVA_PATH)/src/*.cpp)
1920

2021
ifeq ($(findstring opencl, $(MAKECMDGOALS)), opencl)
2122
AF=afopencl
@@ -44,8 +45,8 @@ $(AF_JAVA_LIB): $(AF_JAVA_LIB_EXT)
4445
cp $(AF_JAVA_LIB_EXT) $(AF_JAVA_LIB)
4546
cp $(AF_LIB_PATH)/lib$(AF).so $(AF_JAVA_PATH)/$(LIB)
4647

47-
$(AF_JAVA_LIB_EXT): $(AF_JAVA_PATH)/src/java_wrapper.cpp
48-
gcc -shared -fPIC $< $(AF_CFLAGS) -L$(AF_LIB_PATH) -l$(AF) -o $@
48+
$(AF_JAVA_LIB_EXT): $(AF_JNI_SRC)
49+
gcc -shared -fPIC $(AF_JNI_SRC) $(AF_CFLAGS) -L$(AF_LIB_PATH) -l$(AF) -o $@
4950

5051
clean:
5152
rm -f lib/*.so $(AF_JAVA_JAR)

README.md

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,30 @@ This repository contains the files required to use ArrayFire from Java.
66
Prerequisites
77
---------------
88

9-
- The latest version of ArrayFire. You can [download here](http://www.arrayfire.com/docs/installation.htm)
10-
- All the pre-requisites for ArrayFire still apply.
9+
- The latest version of ArrayFire. You can get ArrayFire using one of the following:
10+
- [Download binary installers](http://www.arrayfire.com/download)
11+
- [Build from source](https://github.com/arrayfire/arrayfire)
1112

1213
- The latest version of `JAVA SDK`. Make sure there is an environmental variable `JAVA_HOME` pointing to the root directory of java sdk installation.
1314

1415
- make
15-
- `GNU Make` on `Linux`
16-
- `nmake` on `Windows`
16+
- `GNU Make` on Linux
1717

1818
- C++ compiler
19-
- `gcc/g++` on Linux
20-
- `Visual Studio 2012` for `Windows`.
19+
- `gcc` or `clang` on Linux
2120

22-
- OSX support coming soon.
21+
- OSX and Windows support coming soon
2322

2423
Contents
2524
---------------
2625

2726
- `src/`: Contains the source files for the ArrayFire Java wrapper
28-
- `java_wrapper.cpp` The JNI wrapper file
29-
- `java_wrapper.h` The JNI API definitions
27+
- `*.cpp` The JNI wrapper files
28+
- `jni_helper.h` The JNI API helper functions
3029

31-
- `com/`: Contains the Java source files implementing `Array` and `Image` classes
30+
- `com/`: Contains the Java source files implementing algorithms
3231

33-
- `lib/`, `lib64/`: The location where the JNI library is stored
32+
- `lib/`: The location where the JNI library is stored
3433

3534
- `examples`: contains a few examples demonstrating the usage
3635

@@ -52,23 +51,6 @@ After you the necessary pre-requisites, edit the following paramets
5251
- `make cuda run ` to use build and run examples using CUDA
5352
- `make opencl run` to use build and run examples using OpenCL
5453

55-
56-
### Windows
57-
58-
- To build the JNI Wrapper for ArrayFire
59-
- Verify if the following macros are correctly defined in the file `Makefile.Windows`.
60-
- Ensure that `VC_ROOT` points to Visual-C (VC) installation path.
61-
- Ensure that `WINSDK_X64` points to Windows SDK X64 library path.
62-
- Launch `Developer command prompt for Visual Studio 2012`.
63-
- `cd <Repository root>`.
64-
- `nmake /F Makefile.Windows af_java` to build wrapper dll using CUDA.
65-
- OpenCL support coming soon.
66-
67-
- To build and run the examples
68-
- `nmake /F Makefile.Windows examples` to build all examples.
69-
- `nmake /F Makefile.Windows` to build and run all examples.
70-
71-
7254
Documentation
7355
---------------
7456
- TODO
@@ -77,4 +59,3 @@ License
7759
---------------
7860

7961
- Please check the LICENSE file in the root directory
80-

com/arrayfire/Algorithm.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.arrayfire;
2+
3+
public class Algorithm extends Array {
4+
5+
// Scalar return operations
6+
private native static double sumAll(long a);
7+
private native static double maxAll(long a);
8+
private native static double minAll(long a);
9+
10+
private native static long sum(long a, int dim);
11+
private native static long max(long a, int dim);
12+
private native static long min(long a, int dim);
13+
14+
// Scalar return operations
15+
public static double sumAll(Array a) throws Exception { return sumAll(a.ref); }
16+
public static double maxAll(Array a) throws Exception { return maxAll(a.ref); }
17+
public static double minAll(Array a) throws Exception { return minAll(a.ref); }
18+
19+
public static void sum(Array res, Array a, int dim) throws Exception {
20+
long ref = sum(a.ref, dim);
21+
res.set(ref);
22+
}
23+
24+
public static void max(Array res, Array a, int dim) throws Exception {
25+
long ref = max(a.ref, dim);
26+
res.set(ref);
27+
}
28+
29+
public static void min(Array res, Array a, int dim) throws Exception {
30+
long ref = min(a.ref, dim);
31+
res.set(ref);
32+
}
33+
34+
public static void sum(Array res, Array a) throws Exception {
35+
sum(res, a, 0);
36+
}
37+
38+
public static void max(Array res, Array a) throws Exception {
39+
max(res, a, 0);
40+
}
41+
42+
public static void min(Array res, Array a) throws Exception {
43+
min(res, a, 0);
44+
}
45+
}

0 commit comments

Comments
 (0)
0