Skip to content

CEEMDAN‐GPU Documentation

Electrical Brain Imaging Lab edited this page Dec 4, 2023 · 19 revisions

Introduction

The GPU version of the Improved CEEMDAN algorithm was developed primarily for execution from MATLAB scripts to speed up the otherwise very long MATLAB runs. However, our implementation is also usable from the command line or within a C/C++ program via function calls. Information for all these use cases are given below.

Installation and compiling instructions

HW/SW requirements

Using our program assumes that you have an (i) NVIDIA GPU card in your computer (Pascal or newer architecture family; Compute Capability 6.0 or up) and (ii) the CUDA SDK (10.2 or later) installed. We have tested this implementation on Pascal (CC 6.1), Volta (CC 7.0) and Ampere (CC 8.0) architectures using CUDA versions 10.2 and 11. If you are using MATLAB, it is likely that CUDA is already installed (for details, see the next section).

Compiling in MATLAB

Our implementation is using the MEXCUDA functionality of MATLAB that allows calling precompiled GPU code directly from a MATLBA script. You need to have the the Parallel Computing Toolbox installed in MATLAB to use this feature. Check with the gpuDevice MATLAB command whether the CUDA toolkit is installed (and if so, which version) and the details of your GPU card. Support for different GPU cards can be checked at the following two links:

Go to the MatlabMEXCUDA folder and open the launch.m script. Check lines 2-3 for CUDA-related parameters.

In Line 2, change the path to match the location of the folders storing the CUDA toolkit binaries.

setenv("MW_NVCC_PATH","C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\bin")

In Line 3, change the CUDA architecture version -- currently compute_80 and sm_80 -- to match your card, as well as the CUDA library path (-LC:...).

mexcuda 'NVCCFLAGS=-gencode=arch=compute_80,code=sm_80' '-LC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\lib\x64' -lcublas -lcusparse -lcurand iceemdanCUDA_MexFun.cu cudaICEEMDAN.cu statistics.cu

This is all to set, the rest will be taken care of by MATLAB.

Compiling in standalone mode

If you want to use our implementation without MATLAB, as a command line executable or as a module embedded into another C/C++ program, follow the next steps. The CEEMDAN‐GPU implementation can be found in the source files cudaICEEMDAN.cu and statistics.cu. These files must be compiled with your C/C++ program using the standard NVIDIA compiler. Assuming your program is in the file main.cu, the command for compiling is

nvcc -arch=sm_70 -Xcompiler -fopenmp -lcublas -lcusparse -lcurand ./main.cu ./cudaICEEMDAN.cu ./statistics.cu -o ceemdan_main

Notes: this command compiles to Volta architecture (CC 7.0). Should you have a different Compute Capability card, change the -arch=sm_XX option accordingly, e.g. sm_80 for Ampere cards. The implementation uses the cuBLAS, cuSPARSE and cuRAND libraries and relies on OpenMP internally, hence the options -Xcompiler -fopenmp -lcublas -lcusparse -lcurand.

Compiling on Linux requires the presence of the gcc/g++ compilers. On Windows systems, we recommend using the Visual Studio or Visual Studio Code environment. For the two sample programs we created pre-compiled binary versions that should execute from the command line without problems. See below under 'Usage instructions' for details of this.

Create a CUDA project, place the file from this project into the source directory and add them to the VS project. After setting the necessary project configuration parameters, the project can be built.

TODO

Usage instructions

Executing from MATLAB

The [launch.m] script illustrates how to use our code from MATLAB. This script first creates a synthetic signal, stores it in the variable inputSignal, calls the CUDA mex function iceemdanCUDA_MexFun and finally return the IMFs in variable modes. Then the script continues with loading a sample data file into inputSignal, running CEEMDAN again and storing the final results in modes. loads a data file and stores it in the variable inputSignal. You can use this script as a template for developing your own CEEMDAN scripts.

Running the sample CUDA programs

We have provided two sample C program files that demonstrate how to use the implementation. You can use these as standalone programs. The program sample_synthetic_signal.cu creates and uses synthetic signals, while the file sample_binary_file.cu demonstrates how to read in a binary input data file, process the data on the GPU and save the results in an output file. Input file can be generated by MATLAB or any program that can save the signal data as raw binary file.

Compile the sample program as before, after setting the -arch option to the required Compute Capability version:

nvcc -arch=sm_70 -Xcompiler -fopenmp -lcublas -lcusparse -lcurand ./sample_synthetic_signal.cu ./cudaICEEMDAN.cu ./statistics.cu -o CUDA_ICEEMDAN_SYNTH

nvcc -arch=sm_70 -Xcompiler -fopenmp -lcublas -lcusparse -lcurand ./sample_binary_file.cu ./cudaICEEMDAN.cu ./statistics.cu -o CUDA_ICEEMDAN_FILE

Precompiled sample programs

to do