|
ReMAS
1.5
Real-time Musical Accompaniment System
|
Header file for using ReMAS with Nvidia GPUs. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <float.h>#include <cuda_runtime.h>#include <cufft.h>#include <cublas_v2.h>#include "../common/defines.h"Go to the source code of this file.
Functions | |
| void | BlocksAndThreads (int *, int *, int *, const int, const int) |
| BlocksAndThreads calculates the suitable number of blocks and threads, and the needed shared memory. More... | |
| int | HaveCompatibleGPU (int &) |
| HaveCompatibleGPU checks if the system has an appropiate GPU for ReMAS. More... | |
| bool | IsPow2 (unsigned int) |
| IsPow2 decides if a number is power of 2. More... | |
| unsigned int | NextPow2 (unsigned int) |
| NextPow2 returns the next power of 2 of a given number. More... | |
| int | FFTGPU (MyType *, MyType *, MyFFTGPUType *) |
| FFTGPU computes FFT. More... | |
| void | InitSxD (MyType *, MyType *, const MyType *__restrict__, const int *__restrict__, const int, const int) |
| int | AllocAuxiGPU (MyType **, short **, short **, MyType **, MyType **, const int, const int, const int) |
| AllocAuxiGPU memory reservation for norms, frame, v_cfreq and v_dxState vectors. More... | |
| int | AllocDataGPU (MyType **, int **, int **, int **, int **, int **, int *, const int, const int, DTWfiles) |
| AllocDataGPU Allocates memory and initializes some structures reading info from files. More... | |
| int | AllocDTWGPU (MyType **, MyType **, MyType **, const int, const int, const int) |
| AllocDTWGPU Allocates memory for DTW vectors and auxiliar structures. More... | |
| int | AllocFFTGPU (MyFFTGPUType *, MyType **, MyType **, MyType **, int *, int *, const int, DTWfiles) |
| AllocFFTGPU Allocates "Unified" GPU memory for FFT vector and reads some fft information from files. More... | |
| int | AllocS_fkGPU (MyType **, MyType **, MyType **, const MyType, const int, const int, DTWfiles) |
| AllocS_fkGPU Allocates memory for S_fk vector, read its data from file and initializes other auxiliar vectors. More... | |
| int | OneImin (MyType *, int *, MyType *, const int, const int) |
| This function launches cuda kernels to find one minimun and its position. More... | |
| int | FirstImin (MyType *, int *, MyType *, const int, const int) |
| This function launches cuda kernels to find the first minimun and its position. More... | |
| int | LastImin (MyType *, int *, MyType *, const int, const int) |
| This function launches cuda kernels to find the last minimun and its position. More... | |
| int | ReadWavGPU1st (short *, short *, FILE *) |
| ReadWavGPU1st reads first audio (frame) from WAV file when NVIDIA GPU is used. More... | |
| int | ReadWavGPU (short *, short *, FILE *) |
| ReadFileGPU reads current audio (frame) from WAV file when NVIDIA GPU is used. More... | |
| __global__ void | kernel_ApplyWindow (MyType *__restrict__, const short *__restrict__, const MyType *__restrict__, const int, const int) |
| __global__ void | kernel_InitDTW (MyType *__restrict__, const int, const int) |
| __global__ void | kernel_CompNorB0 (MyType *__restrict__, const MyType, const int) |
| __global__ void | kernel_CompNorB1 (MyType *__restrict__, const MyType *__restrict__, const int, const int) |
| __global__ void | kernel_CompNorBG (MyType *__restrict__, MyType *__restrict__, const MyType *__restrict__, const int, const MyType, const int) |
| __global__ void | kernel_PowToReal (MyType *__restrict__, const MyType *__restrict__, const MyType, const int) |
| __global__ void | kernel_Cfreq (MyType *__restrict__, const MyType *__restrict__) |
| __global__ void | kernel_Modul (MyType *__restrict__, const MyType *__restrict__, const int) |
| __global__ void | kernel_Reduction (MyType *__restrict__, const int) |
| __global__ void | kernel_InitSxD (MyType *__restrict__, MyType *__restrict__, const MyType *__restrict__, const int *__restrict__, const int, const bool, const int) |
| __global__ void | kernel_Sum (MyType *__restrict__, const MyType *__restrict__, const int, const bool, const int) |
| __global__ void | kernel_Vnorm (MyType *__restrict__) |
| __global__ void | kernel_UpdateSxD (MyType *__restrict__, const MyType, const MyType *__restrict__, const int) |
| __global__ void | kernel_DTW (const MyType *__restrict__, MyType *__restrict__, MyType *__restrict__, int *__restrict__, const int, const int, const int) |
| __global__ void | kernel_CompDisB0 (MyType *__restrict__, const MyType *__restrict__, const MyType *__restrict__, const MyType *__restrict__, const int, const int) |
| __global__ void | kernel_CompDisB1 (MyType *__restrict__, const MyType *__restrict__, const MyType *__restrict__, const MyType *__restrict__, const int, const int) |
| __global__ void | kernel_CompDisBG (MyType *__restrict__, const MyType *__restrict__, const MyType *__restrict__, const MyType *__restrict__, const MyType *__restrict__, const MyType *__restrict__, const MyType, const int, const int) |
| __global__ void | kernel_Shift (short *__restrict__, const int, const int) |
| __global__ void | kernel_OneImin (MyType *__restrict__, int *__restrict__, const MyType *__restrict__, const int, const bool, const int) |
| __global__ void | kernel_FirstImin (MyType *__restrict__, int *__restrict__, const MyType *__restrict__, const int, const bool, const int) |
| __global__ void | kernel_LastImin (MyType *__restrict__, int *__restrict__, const MyType *__restrict__, const int, const bool, const int) |
| __global__ void | kernel_OneIminLast (MyType *__restrict__, int *__restrict__, const MyType *__restrict__, const int *__restrict__, const int, const bool, const int) |
| __global__ void | kernel_FirstIminLast (MyType *__restrict__, int *__restrict__, const MyType *__restrict__, const int *__restrict__, const int, const bool, const int) |
| __global__ void | kernel_LastIminLast (MyType *__restrict__, int *__restrict__, const MyType *__restrict__, const int *__restrict__, const int, const bool, const int) |
Header file for using ReMAS with Nvidia GPUs.
Definition in file GPUFunctions.h.
| int AllocAuxiGPU | ( | MyType ** | norms, |
| short ** | GPUframe, | ||
| short ** | CPUframe, | ||
| MyType ** | v_cfreq, | ||
| MyType ** | v_dxState, | ||
| const int | nbases, | ||
| const int | tamframe, | ||
| const int | nmidi | ||
| ) |
AllocAuxiGPU memory reservation for norms, frame, v_cfreq and v_dxState vectors.
| norms | (out) Norms vector |
| GPUframe | (out) Vector for frames in GPU memory |
| CPUframe | (out) Vector for frames in CPU memory |
| v_cfreq | (out) v_cfreq vector |
| v_dxState | (out) v_dxState vector |
| nbases | (in) Number of bases/combinations, sizeof norms and v_dxState |
| tamframe | (in) Size of frames in samples |
| nmidi | (in) Number of midi notes, v_cfreq size |
Definition at line 259 of file GPUFunctions.cu.
| int AllocDataGPU | ( | MyType ** | v_hanning, |
| int ** | states_time_i, | ||
| int ** | states_time_e, | ||
| int ** | states_seq, | ||
| int ** | states_corr, | ||
| int ** | I_SxD, | ||
| int * | DTWSize, | ||
| const int | tamtrama, | ||
| const int | nstates, | ||
| DTWfiles | NameFiles | ||
| ) |
AllocDataGPU Allocates memory and initializes some structures reading info from files.
| v_hanning | (out) v_hanning vector |
| states_time_i | (out) states_time_i vector, contains the start-time of each state in frames |
| states_time_e | (out) states_time_e vector, contains the end-time of each state in frames |
| states_seq | (out) states_seq vector, contains the base/combination that is performed in each state |
| states_corr | (out) states_corr vector |
| I_SxD | (out) I_SxD vector |
| DTWSize | (in) Size of DTW vectors |
| tamtrama | (in) Size of frames in samples |
| nstates | (in) Number of states |
| NameFiles | (in) Struct with the file names |
Definition at line 148 of file GPUFunctions.cu.
| int AllocDTWGPU | ( | MyType ** | pV, |
| MyType ** | v_SxD, | ||
| MyType ** | sdata, | ||
| const int | maxGrid, | ||
| const int | DTWSize, | ||
| const int | DTWSizePlusPad | ||
| ) |
AllocDTWGPU Allocates memory for DTW vectors and auxiliar structures.
| pV | (out) DTW pV vector |
| v_SxD | (out) v_SxD vector |
| sdata | (out) sdata vector, auxiliar |
| maxGrid | (in) maxGridSize supported by GPU |
| DTWSize | (in) Size of DTW vectors |
| DTWSizePlusPad | (in) Size of DTW vectors plus padding |
Definition at line 232 of file GPUFunctions.cu.
| int AllocFFTGPU | ( | MyFFTGPUType * | plan, |
| MyType ** | X_fft, | ||
| MyType ** | Out_fft, | ||
| MyType ** | Mod_fft, | ||
| int * | kmin_fft, | ||
| int * | kmax_fft, | ||
| const int | nfft, | ||
| DTWfiles | NameFiles | ||
| ) |
AllocFFTGPU Allocates "Unified" GPU memory for FFT vector and reads some fft information from files.
| plan | (out) FFT scheduler |
| X_fft | (out) X_fft vector |
| Out_fft | (out) Out_fft vector |
| Mod_fft | (out) Mod_fft vector |
| kmin_fft | (out) Where kmin_fft is stored |
| kmax_fft | (out) Where kmax_fft is stored |
| nfft | (in) As is to be, Mod_fft and Out_fft size |
| NameFiles | (in) Struct with the file names |
Definition at line 197 of file GPUFunctions.cu.
| int AllocS_fkGPU | ( | MyType ** | s_fk, |
| MyType ** | tauxi, | ||
| MyType ** | ts_fk, | ||
| const MyType | BETA, | ||
| const int | nmidi, | ||
| const int | nbases, | ||
| DTWfiles | NameFiles | ||
| ) |
AllocS_fkGPU Allocates memory for S_fk vector, read its data from file and initializes other auxiliar vectors.
| s_fk | (out) s_fk vector |
| tauxi | (out) Auxiliar vector tauxi |
| ts_fk | (out) Auxiliar vector ts_fk |
| BETA | (in) BETA value |
| nmidi | (in) Number of midi notes |
| nbases | (in) Number of bases/combinations |
| NameFiles | (in) Struct with the file names |
Definition at line 117 of file GPUFunctions.cu.
| void BlocksAndThreads | ( | int * | blocks, |
| int * | threads, | ||
| int * | sharedsize, | ||
| const int | maxGrid, | ||
| const int | size | ||
| ) |
BlocksAndThreads calculates the suitable number of blocks and threads, and the needed shared memory.
| blocks | (out) Number of blocks |
| threads | (out) Number of threads |
| sharedsize | (out) Size of shared memory |
| maxGrid | (in) maxGridSize supported by GPU |
| size | (in) Size of the vectors |
Definition at line 283 of file GPUFunctions.cu.
| int FFTGPU | ( | MyType * | X_fft, |
| MyType * | Out_fft, | ||
| MyFFTGPUType * | plan | ||
| ) |
FFTGPU computes FFT.
| X_fft | (inout) X_fft vector |
| Out_fft | (inout) Out_fft vector |
| plan | (out) FFT scheduler |
Definition at line 307 of file GPUFunctions.cu.
| int FirstImin | ( | MyType * | odata, |
| int * | opos, | ||
| MyType * | idata, | ||
| const int | maxGrid, | ||
| const int | size | ||
| ) |
This function launches cuda kernels to find the first minimun and its position.
| odata | (inout) Intermedial data vector |
| opos | (inout) Intermedial positions vector |
| idata | (in) Input data vector |
| maxGrid | (in) maxGridSize supported by GPU |
| size | (in) Size of the vector |
Definition at line 394 of file GPUFunctions.cu.
| int HaveCompatibleGPU | ( | int & | maxGrid | ) |
HaveCompatibleGPU checks if the system has an appropiate GPU for ReMAS.
| maxGrid | (out) MaxGrid stores the GPU maxGridSize property |
Definition at line 75 of file GPUFunctions.cu.
|
inline |
IsPow2 decides if a number is power of 2.
| x | (in) The number |
Definition at line 66 of file GPUFunctions.cu.
| int LastImin | ( | MyType * | odata, |
| int * | opos, | ||
| MyType * | idata, | ||
| const int | maxGrid, | ||
| const int | size | ||
| ) |
This function launches cuda kernels to find the last minimun and its position.
| odata | (inout) Intermedial data vector |
| opos | (inout) Intermedial positions vector |
| idata | (in) Input data vector |
| maxGrid | (in) maxGridSize supported by GPU |
| size | (in) Size of the vector |
Definition at line 426 of file GPUFunctions.cu.
| unsigned int NextPow2 | ( | unsigned int | x | ) |
NextPow2 returns the next power of 2 of a given number.
| x | (in) The number |
Definition at line 47 of file GPUFunctions.cu.
| int OneImin | ( | MyType * | odata, |
| int * | opos, | ||
| MyType * | idata, | ||
| const int | maxGrid, | ||
| const int | size | ||
| ) |
This function launches cuda kernels to find one minimun and its position.
| odata | (inout) Intermedial data vector |
| opos | (inout) Intermedial positions vector |
| idata | (in) Input data vector |
| maxGrid | (in) maxGridSize supported by GPU |
| size | (in) Size of the vector |
Definition at line 362 of file GPUFunctions.cu.
| int ReadWavGPU | ( | short * | GPUframe, |
| short * | CPUframe, | ||
| FILE * | fp | ||
| ) |
ReadFileGPU reads current audio (frame) from WAV file when NVIDIA GPU is used.
| GPUframe | (out) Vector to store the current frame whitin NVIDIA GPU |
| CPUframe | (—) Vector to store the current frame whitin ARM |
| fp | (in) ID of file with the information |
Definition at line 473 of file GPUFunctions.cu.
| int ReadWavGPU1st | ( | short * | GPUframe, |
| short * | CPUframe, | ||
| FILE * | fp | ||
| ) |
ReadWavGPU1st reads first audio (frame) from WAV file when NVIDIA GPU is used.
| GPUframe | (out) Vector to store the first frame within NVIDIA GPU |
| CPUframe | (—) Vector to store the first frame within ARM |
| fp | (in) ID of file with the information |
Definition at line 456 of file GPUFunctions.cu.
1.8.13