-
Notifications
You must be signed in to change notification settings - Fork 4
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
Comments
That's right. |
It looks like this page contains complete solution except Cuda binding
https://github.com/apache/commons-math/tree/master/src/main/java/org/apache/commons/math4/linear😃
<https://github.com/apache/commons-math/tree/master/src/main/java/org/apache/commons/math4/linear>
…On Tue, Oct 29, 2019 at 2:19 PM Marco Hutter ***@***.***> wrote:
That's right.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2?email_source=notifications&email_token=AM7YVKFXCFSB77KHPNZNLLDQRAS4JA5CNFSM4JGHRL7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECQI2GA#issuecomment-547392792>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AM7YVKD2SX64RXWCE5B75ODQRAS4JANCNFSM4JGHRL7A>
.
|
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 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 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. |
It looks OK for me too simply because I came from another than mathematics
background () physics and core software development ) and can't say what is
better from my own experiance. My point is
1. There is no Native pointers in Java because java and JNI provides own
organic solution - mapping Java Object to everything. Any Java object
provide hashCode which is used in all JavaCollection and Map
implementations. JNI native code can create Java objects in half dozen ways
and return it to Java caller. Once such object is created it can be mapped
using Std::Map container to everything, including opaque or typed pointers.
Created object can expose convenient for user's choice buffer, writer and
reader API's implemented in native code.
Anyway, Java doesn't know how to cast primitive types but if array is
passed as parameter its type can be recognized as "[float", "[int]", "[[
double'", etc.
Also assumption that Java reference and pointer are the same things is
wrong because reference is internal java thing with own Boxing object -
java.ref.Reference. Its implementation is totally hidden from Java
developer eyes to keep Java platform independent.
P.S. cpointers[] pointers has no sense - this is simply collection of
objects.Java spec only says that 2 dimensional array is collection of rows
without promising continue storage. To ensure the 2D array continue storage
it has to be packed into simple primitive typed array, for example, by
matrix writer._
…On Fri, Nov 8, 2019 at 4:34 PM Marco Hutter ***@***.***> wrote:
Closed #2 <#2>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2?email_source=notifications&email_token=AM7YVKBOL33XZCO2CWMA52DQSV2F3A5CNFSM4JGHRL7KYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOUXSCX4A#event-2783194096>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AM7YVKAMQJKK7NPYK4SJKPTQSV2F3ANCNFSM4JGHRL7A>
.
|
Hi Marco,
When I compare different approaches for Java binding with frameworks
implemented in C or C++ including NVidia CUDA API, I found the roof project
which concentrates all efforts: https://github.com/bytedeco/javacpp-presets .
It looks like it would be better resource investment to extend this
collection of frameworks than spawn yet another project.
Could you look and say which features are missed in this project collection?
…On Sun, Nov 10, 2019 at 12:37 PM Pavel Sosin ***@***.***> wrote:
It looks OK for me too simply because I came from another than mathematics
background () physics and core software development ) and can't say what is
better from my own experiance. My point is
1. There is no Native pointers in Java because java and JNI provides own
organic solution - mapping Java Object to everything. Any Java object
provide hashCode which is used in all JavaCollection and Map
implementations. JNI native code can create Java objects in half dozen
ways and return it to Java caller. Once such object is created it can be
mapped using Std::Map container to everything, including opaque or typed
pointers. Created object can expose convenient for user's choice buffer,
writer and reader API's implemented in native code.
Anyway, Java doesn't know how to cast primitive types but if array is
passed as parameter its type can be recognized as "[float", "[int]", "[[
double'", etc.
Also assumption that Java reference and pointer are the same things is
wrong because reference is internal java thing with own Boxing object -
java.ref.Reference. Its implementation is totally hidden from Java
developer eyes to keep Java platform independent.
P.S. cpointers[] pointers has no sense - this is simply collection of
objects.Java spec only says that 2 dimensional array is collection of rows
without promising continue storage. To ensure the 2D array continue storage
it has to be packed into simple primitive typed array, for example, by
matrix writer._
On Fri, Nov 8, 2019 at 4:34 PM Marco Hutter ***@***.***>
wrote:
> Closed #2 <#2>.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#2?email_source=notifications&email_token=AM7YVKBOL33XZCO2CWMA52DQSV2F3A5CNFSM4JGHRL7KYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOUXSCX4A#event-2783194096>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AM7YVKAMQJKK7NPYK4SJKPTQSV2F3ANCNFSM4JGHRL7A>
> .
>
|
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") |
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();
The text was updated successfully, but these errors were encountered: