bytedeco / javacpp-presets

The missing Java distribution of native C++ libraries
Other
2.65k stars 736 forks source link

Missing MKL Lapack functions #1388

Closed blueberry closed 1 year ago

blueberry commented 1 year ago

JavaCPP presets 1.5.9 are missing MKL LAPACK norm operations: slansb, dlansb, slangb, dlangb, slantb, dlantb (maybe others too, I'll report if I encounter such cases).

These are standard LAPACK functions, and are listed in both LAPACK and MKL documentation, such as:

https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-fortran/2023-0/langb.html

I couldn't find them listed in JavaCPP MKL preset source, so I'm not sure whether they are missing for a specific reason, or is it purely by chance. BTW, I used them in my C code, they are in MKL headers, and they work as expected in MKL...

saudet commented 1 year ago

The mkl_lapack.h file is huge and it didn't used to be possible to compile the generated code. I tried again in commit ccfa8af, but the build machines still don't have enough memory. As we can see from the Windows build log though, a whole lot of symbols don't actually exist, so we need to find a way to prune them. But if the only functions you're interested in are the ones you mention above, you could copy the declarations for those only and paste them in this class: https://github.com/bytedeco/javacpp-presets/blob/master/mkl/src/main/java/org/bytedeco/mkl/presets/mkl_rt.java

If this sounds good, please open a pull request to that effect!

blueberry commented 1 year ago

Yes, I only need these functions for now, and i might stumble upon a few others, but I will havea an explicit list. I will add them to that file. By copying the declarations, you mean that I should only add their names to the list at line 64?

saudet commented 1 year ago

No, I mean something like in commit 5bc74d828cd.

blueberry commented 1 year ago

OK, I'll do the port I'm currently on, keep track of missing functions, and then I'll try to add them to javacpp presets by hand (or cry for help if there's something I can't follow).

saudet commented 1 year ago

I was able to get rid of all non-existent symbols by skipping all functions whose names end with an underscore, and I've managed to make it compile under Linux machines from GitHub Actions as well in commit b80d5a2, so could you give that a try and let me know if this works for you?

blueberry commented 1 year ago

Sure! Should I expect this commit to be available in maven snapshots repository (I expect that would be in a couple of hours or sooner?) or I must clone javacpp repository and build it myself?

saudet commented 1 year ago

Please give it a try with the snapshots: http://bytedeco.org/builds/

blueberry commented 1 year ago

Thanks! I've updated my project to 1.5.10-SNAPSHOT, but these functions are still missing from the current snapshot. However, I've noticed that the timestamp on these snapshots is org/bytedeco/mkl-platform/2023.1-1.5.10-SNAPSHOT/mkl-platform-2023.1-1.5.10-20230718.130143-27.pom which i suppose stands for 13:01:43, that is BEFORE the last commit. Do you perhaps know when the snapshots get updated? Should it be in a few hours, or I better wait until tomorow?

BTW, here's the list of available XlanXX operations available in the snapshot that is currently available (the GB, SB, and TB versions are still missing).

Click on a completion to select it.
In this buffer, type RET to select the completion near point.

Possible completions are:
org.bytedeco.mkl.global.mkl_rt/LAPACKE_slange <sm>  org.bytedeco.mkl.global.mkl_rt/LAPACKE_slange_work <sm>
org.bytedeco.mkl.global.mkl_rt/LAPACKE_slansy <sm>  org.bytedeco.mkl.global.mkl_rt/LAPACKE_slansy_work <sm>
org.bytedeco.mkl.global.mkl_rt/LAPACKE_slantr <sm>  org.bytedeco.mkl.global.mkl_rt/LAPACKE_slantr_work <sm>
blueberry commented 1 year ago

Whoops, now I see that your commit was 7 hours ago, so it's probably included in the snapshot. But no, these functions are still missing.

saudet commented 1 year ago

I see them perfectly fine in this file: https://raw.githubusercontent.com/bytedeco/javacpp-presets/mkl/mkl/src/gen/java/org/bytedeco/mkl/global/mkl_rt.java Why do you say they are missing? I can't fix what isn't broken!

blueberry commented 1 year ago

Sorry for missing that. It turns out that I expected these files to have the =LAPACKE_= prefix, like their cousins =LAPACKE_slange= etc, while they have been generated without that prefix.

Now I see that the un-prefixed versions are not available in http://bytedeco.org/javacpp-presets/mkl/apidocs/ that's why I didn't try to look them under these names. After a bit more looking, it seems that un-prefixed functions are "raw", while =LAPACK_xxxxx= are more Java-friendly with their primitive arguments. I'm puzzled why the generator hasn't produced =LAPACK_slangb= etc. but I don't mind it if it works.

The code that I had that uses these functions now had to be adapted to this "raw" way of calling. I'll do this tomorrow and report the results!

Thank you.

blueberry commented 1 year ago

It works! (At least the cases that I tried so far). Thank you.

saudet commented 1 year ago

I don't see any LAPACK_slansb, etc functions in MKL. It's possible they got removed in newer versions. Please verify with Intel!

blueberry commented 1 year ago

Yes. It turns out it's their mess. But, anyway, as far as JavaCPP is concerned, this now works as expected (well).