A Visual Studio 2022 project and a Java application project are presented. The VS2022 project generates a DLL file that is called by the Java application via JNA in Windows 11 environment. CUDA and CULA are involved.
This Java application is used in:
Denoising NMR time-domain signal by singular-value decomposition accelerated
by graphics processing units,
Pascal P. Man, Christian Bonhomme, and Florence Babonneau
Solid State Nucl. Magn. Reson. 61-62, 28-34 (2014).
Abstract
*** Outline ***
- CULA installation
- svdComplexDevice1 DLL project in MS Visual Studio 2022
- Java environment installation
- svdComplexDevice1X64 Java application project in Eclipse IDE
- References
CULA installation
Install CULA Dense R15
for Windows (Universal).
Its folder location is C:\Program Files\CULA\R15.
svdComplexDevice1 DLL project in MS Visual Studio 2022
- In Visual Studio 2022 panel, select Create a new Project.
- In Create a new project panel, select Dynamic-Link Library (DLL)
Click Next button. - In Configure a new project panel, provid the name of the project:
svdComplexDevice1
Click Create button. - The Visual Studio editor appears with a dllmain.cpp file.
Four files are generated: dllmain.cpp, pch.cpp, pch.h, and framework.h - Right click the folder of Source Files in Solution Explorer
for adding a new item.
Select Add then New Item...
Add New Item panel appears.
Select C++ File (.cpp).
Provid the Name: svdComplexDevice1.cpp
Click Add button. - An empty svdComplexDevice1.cpp file is created.
Open svdComplexDevice1.cpp.
Copy and paste its content into the empty source file svdComplexDevice1.cpp. - Right click the folder of Header Files in Solution Explorer
for adding a new item...
Select Add then New Item.
Add New Item panel appears.
Select Header File (.h).
Provid the Name: svdComplexDevice1.h
Click Add button. - An empty svdComplexDevice1.h file is created.
Open svdComplexDevice1.h.
Copy and paste its content into the empty Header File svdComplexDevice1.h. - Right click the file svdComplexDevice1.cpp in Solution Explorer.
Select Properties.
The Item Type is C/C++ compiler. Close the panel. - Right click the file svdComplexDevice1.h in Solution Explorer. Select Properties.
The Item Type is C/C++ header. Close the panel. - Right click the project svdComplexDevice1 in
Solution Explorer. Select Properties, then VC++ Directories.
Add C:\Program Files\CULA\R15\bin64; in Executable Directories.
Add C:\Program Files\CULA\R15\include;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5\include; in Include Directories.
Add C:\Program Files\CULA\R15\lib64;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5\lib\x64; in Library Directories.
- Select Linker then Input.
Add cula_core.lib;cula_lapack.lib;cudart.lib; in Additional Dependencies.
Click Appliquer button then OK button. - Select Build menu then Build Solution.
The file svdComplexDevice1.dll with 71 kbit size is generated in the folder C:\Users\pm\source\repos\svdComplexDevice1\x64\Debug.
Java environment installation
- Install Eclipse IDE 2024-09 R Packages for Windows with Eclipse
Installer 2024-09 R: eclipse-inst-jre-win64.exe.
Select Eclipse IDE for Java Developers.
- Install Oracle
JDK Development Kit 21.0.5 for 64-bit Windows: jdk-21_windows-x64_bin.exe
Interface Observer and class Observable are depreciated since Java version 9. - Download two Java Native Access executable files: jna-5.15.0.jar and jna-platform-5.15.0.jar.
- The four CULA DLL files, cula_lapack.dll, cula_core.dll, cublas64_42_6.dll, and cudart64_42_6.dll, are located at C:\Program Files\CULA\R15\bin64.
- My Java application folder location is C:\Users\pm\eclipse-workspace.
svdComplexDevice1X64 Java application project in Eclipse IDE
- Open Eclipse IDE 2024-09.
- Select Window menu then Preferences.
Click Java then Installed JREs.
Click Add button. Select Standard VM then click Next > button.
Click Directory.. button. Select JRE folder or JDK folder. Click Finish button.
Tick jdk-21 (default)
Click Apply button. - Click Compiler.
Choose 21 for Compiler compliance level.
Click Apply and Close button.
These settings will be effective for new projects. - Select Create a Java project in Eclipse IDE.
Provid the project name: svdComplexDeviceX64
Click Finish button. - The project folder appears in Package Explorer.
- The file .classpath in the project folder located at
C:\Users\pm\eclipse-workspace\svdComplexDevice1X64 is filled.
- Open the project folder.
Transfer seven files into the project folder: svdComplexDevice1.dll, cula_lapack.dll, cula_core.dll, cudart64_42_6.dll, cublas64_42_6.dll, jna-platform-5.5.jar, and jna-5.5.0.jar.
- Right click the project name in Project Explorer then select Refresh.
The seven files appear in Package Explorer. - Right click the source folder src in Project Explorer.
Select New then Package. Provid the package name: nmrsvd
Click Finish button. - Right click the package folder nmrsvd in Project Explorer.
Select New then class. Provid the class name: fidsvd
Click Finish button. - Similarly, generate four Java classes: Frame1, Graph, ListGentle,
and SVDMVCModelGPU
- Copy and paste fidsvd.java, Frame1.java, Graph.java, ListGentle.java, and SVDMVCModelGPU.java into the five newly generated java files, respectively.
- Right click the project folder svdComplexDevice1X64 in Project Explorer.
Select Properties, Java Build Path, Library.
- Select Classpath to activate Add buttons.
Click Add JARs... button.
Click the project folder in JAR Selection panel.
Select the two jar files.
Click OK button.
- Click Apply and Close button.
- A new folder, Referenced Libraries containing the two jna files, is added to the project in Package Explorer.
- The file .classpath in the project folder located at
C:\Users\pm\eclipse-workspace\svdComplexDevice1X64 is filled.
Two lines concerning with jna files are added. - Select Run menu then Run Configuration...
Click Java Application then New_configuration.
Click Run button. - Save and Launch panel appears.
Click OK button. - The Java application panel appears.
References
- Creating a jar File in Eclipse
- Creating an executable Jar file
- Tutoriel pour exécuter du code natif en Java : JNI VS JNA
- YouTube: How to setup Eclipse for C/C++ developers in Windows 8.1
- How to install Eclipse CDT 8.2 and get started
- Eclipse CDT (C/C++ Development Tooling)
- Add .dll to java.library.path in Eclipse/PyDev Jython projec
- Tutoriel pour exécuter du code natif à partir de Java avec JNA, en 5 minutes
- How to change Eclipse Java version for compiler and JRE
- How to change Java Version in an Eclipse project
- Tout savoir sur Eclipse
- Setting up the code for development and compilation
- Eclipse managed build
- [Learning] CUDA C/C++ (Part 1) - Visual Studio project setup (Visual Studio 2017 15.5 version) from Win32 empty project
- CULA programmer’s guide, release R15 (CUDA 4.2) (PDF file)
- CULA reference manual, release R15 (CUDA 4.2) (PDF file)
- CUDA C++ programming guide (PDF file)
- CUDA quick start guide (PDF file)
- CUDA sample (PDF file)
- Learning CUDA (PDF file) from FREE eBook created from Stack Overflow contributors
- JavaBeans
- Nvidia: CUDA toolkit documentation 12.6 update 3
References cusolver
- Nvidia Developer: CUDA libraries documentation
- Stackoverflow: Singular values calculation only with CUDA
- CUDA: cuSOLVER API Reference v12.6
- Nvidia: CUSOLVER library DU-06709-001_v10.1 | April 2019
- Nvidia: Cusolver SVD for general complex matrix
- Nvidia: cusolverDnSgesvd svd of matrix with m<n
- Nvidia: [cusolverDn] Fail to compute the singular values only in Cuda 7.0
- Nvidia Developer zone, CUDA Toolkit v10.1.168: G. Examples of Singular Value Decomposition
- Nvidia cuQuantum : Define SVD decomposition
- github: CUDALibrarySamples/cuSOLVER/Xgesvd/cusolver_Xgesvd_example.cu
- github: cuSOLVER Singular Value Decomposition example
- github: cuSOLVER library - APIs examples
- OGeek 极客中国: cuda - Cusolver SVD does not give correct U and VT outputs for complex inputs
- Blue Waters: cuSolver
- Andrzej Chrzęszczyk and Jacob Anders: Matrix computations on the GPU, CUBLAS, CUSOLVER and MAGMA by example
- DP3: Complex.h