Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inadequate top level API for java #2

Closed
PavelSosin-320 opened this issue Oct 29, 2019 · 6 comments
Closed

Inadequate top level API for java #2

PavelSosin-320 opened this issue Oct 29, 2019 · 6 comments

Comments

@PavelSosin-320
Copy link

Blas is essentially matrix arithmetics, i.e. set of functions receiving several value arguments - matrix, vectors, etc.and returning one value - matrix. This is well known pattern provided by Java 9 in the form of functional programming. Every function is Callable class receiving own parameters object and supplying value to consumer for further processing:
matrix1 = new Matrix()
matrix1.set();
matrix2 = new Matrix();
matrix2.set();
MutrixMultiplicationParams params = new MutrixMultiplicationParams(matrix1, matrix2, opt);
params -> Callable {
invoke CUDA and get matrix3
supplyAsynch( matrix3); complete();
}.thenAccept(result) {
result -> next Callable...
Matrix finalResult= (Matrix)get();

@jcuda
Copy link
Owner

jcuda commented Oct 29, 2019

That's right.

@PavelSosin-320
Copy link
Author

PavelSosin-320 commented Nov 6, 2019 via email

@jcuda
Copy link
Owner

jcuda commented Nov 7, 2019

Yeah, the "complete solution". People have been trying that. There are literally dozens of Java Matrix libraries out there. They all have different focuses and priorities. They range from something like https://math.nist.gov/javanumerics/jama/doc/ to things like http://ejml.org/javadoc/ , and in terms of complexity and versatility, the Apache Commons Math4 solution is somewhere in the lower end.

As a starter: So you want only double matrices, and no float matrices? That's not gonna work. You want only 2D matrices, and no n-D matrices? Why? There is a SparseMatrix, but where are the implementations?

The closest what I have seen to be a Universal Java Matrix Package is the Universal Java Matrix Package from https://ujmp.org/ . They really went the extra mile in terms of abstraction and engineering. Unfortunately, the JavaDocs are not available any more, but you may have a look at the code at https://github.com/ujmp/universal-java-matrix-package/tree/master/ujmp-core/src/main/java/org/ujmp/core/doublematrix


For something that is supposed to be built on top of CUDA, there are dozens of further questions: What sparse storage do the sparse matrices use? DOK, LIL, COO, CSR, CRS, Yal, CSC or CCS? Are there methods for converting between these formats? How to differentiate between Host- and Device matrices? There as to be a release-method to free the GPU memory. What use are the matrices when there are no implementations of the common matrix operations that internally delegate to CUBLAS or CUSPARSE?

I created the https://github.com/jcuda/jcuda-matrix-utils a while ago (but note the disclaimer in the README). The sample at https://github.com/jcuda/jcuda-matrix-utils/blob/master/JCudaMatrixUtils/src/test/java/org/jcuda/matrix/samples/JCusparseSampleDgemm.java shows how these classes may be used to perform a DGEMM using sparse matrices with JCusparse. That's only one example. One could invest endless amounts of time here.

@jcuda jcuda closed this as completed Nov 8, 2019
@PavelSosin-320
Copy link
Author

PavelSosin-320 commented Nov 10, 2019 via email

@PavelSosin-320
Copy link
Author

PavelSosin-320 commented Nov 12, 2019 via email

@jcuda
Copy link
Owner

jcuda commented Nov 12, 2019

I already linked to JavaCPP in jcuda/jcuda#25 (comment) (but already thought that you wouldn't really read my attempts to give proper answers to the issues that you opened here recently).

Yes, JavaCPP has CUDA presets: https://github.com/bytedeco/javacpp-presets/tree/master/cuda

Download it. Use it. It's ideal for you.

(The fact that JCuda exists is due to the fact that I started JCuda >10 years ago, and JavaCPP wasn't available back then. Now, I'm maintaining JCuda, because I know that people are using it, and I consider it as a form of "responsibility")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants