ReMAS  1.5
Real-time Musical Accompaniment System
Functions
GPUFunctions.cu File Reference

File with code of ReMAS functions for Nvidia GPUs. More...

#include "GPUFunctions.h"
#include "../common/FileFunctions.h"

Go to the source code of this file.

Functions

unsigned int NextPow2 (unsigned int x)
 NextPow2 returns the next power of 2 of a given number. More...
 
bool IsPow2 (unsigned int x)
 IsPow2 decides if a number is power of 2. More...
 
int HaveCompatibleGPU (int &maxGrid)
 HaveCompatibleGPU checks if the system has an appropiate GPU for ReMAS. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int FFTGPU (MyType *X_fft, MyType *Out_fft, MyFFTGPUType *plan)
 FFTGPU computes FFT. More...
 
void InitSxD (MyType *odata, MyType *v_SxD, const MyType *__restrict__ v_dxState, const int *__restrict__ I_SxD, const int maxGrid, const int size)
 InitSxD launches the cuda kernel that sets up the vector SxD when "Unified" GPU memory is used. More...
 
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. More...
 
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. More...
 
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. More...
 
int ReadWavGPU1st (short *GPUframe, short *CPUframe, FILE *fp)
 ReadWavGPU1st reads first audio (frame) from WAV file when NVIDIA GPU is used. More...
 
int ReadWavGPU (short *GPUframe, short *CPUframe, FILE *fp)
 ReadFileGPU reads current audio (frame) from WAV file when NVIDIA GPU is used. More...
 

Detailed Description

File with code of ReMAS functions for Nvidia GPUs.

Author
Information Retrieval and Parallel Computing Group, University of Oviedo, Spain
Interdisciplinary Computation and Communication Group, Universitat Politecnica de Valencia, Spain
Signal Processing and Telecommunication Systems Research Group, University of Jaen, Spain.
Contact: remas.nosp@m.pack.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Date
February 13, 2017

Definition in file GPUFunctions.cu.

Function Documentation

◆ AllocAuxiGPU()

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.

Parameters
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
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 259 of file GPUFunctions.cu.

◆ AllocDataGPU()

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.

Parameters
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
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 148 of file GPUFunctions.cu.

◆ AllocDTWGPU()

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.

Parameters
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
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 232 of file GPUFunctions.cu.

◆ AllocFFTGPU()

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.

Parameters
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
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 197 of file GPUFunctions.cu.

◆ AllocS_fkGPU()

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.

Parameters
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
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 117 of file GPUFunctions.cu.

◆ BlocksAndThreads()

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.

Parameters
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
Returns
: Nothing, it is void

Definition at line 283 of file GPUFunctions.cu.

◆ FFTGPU()

int FFTGPU ( MyType *  X_fft,
MyType *  Out_fft,
MyFFTGPUType *  plan 
)

FFTGPU computes FFT.

Parameters
X_fft(inout) X_fft vector
Out_fft(inout) Out_fft vector
plan(out) FFT scheduler
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 307 of file GPUFunctions.cu.

◆ FirstImin()

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.

Parameters
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
Returns
: The pos of "a" minimum

Definition at line 394 of file GPUFunctions.cu.

◆ HaveCompatibleGPU()

int HaveCompatibleGPU ( int &  maxGrid)

HaveCompatibleGPU checks if the system has an appropiate GPU for ReMAS.

Parameters
maxGrid(out) MaxGrid stores the GPU maxGridSize property
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 75 of file GPUFunctions.cu.

◆ InitSxD()

void InitSxD ( MyType *  odata,
MyType *  v_SxD,
const MyType *__restrict__  v_dxState,
const int *__restrict__  I_SxD,
const int  maxGrid,
const int  size 
)

InitSxD launches the cuda kernel that sets up the vector SxD when "Unified" GPU memory is used.

Parameters
odata(inout) Intermedial data vector
v_SxD(out) v_SxD vector
v_dxState(out) v_dxState vector
I_SxD(out) I_SxD vector
maxGrid(in) maxGridSize supported by GPU
size(in) Size of the vector
Returns
: none, it is void

Definition at line 330 of file GPUFunctions.cu.

◆ IsPow2()

bool IsPow2 ( unsigned int  x)
inline

IsPow2 decides if a number is power of 2.

Parameters
x(in) The number
Returns
: True is the number is power of 2, 0 otherwise false

Definition at line 66 of file GPUFunctions.cu.

◆ LastImin()

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.

Parameters
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
Returns
: The pos of "a" minimum

Definition at line 426 of file GPUFunctions.cu.

◆ NextPow2()

unsigned int NextPow2 ( unsigned int  x)

NextPow2 returns the next power of 2 of a given number.

Parameters
x(in) The number
Returns
: Next power of 2 of a number

Definition at line 47 of file GPUFunctions.cu.

◆ OneImin()

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.

Parameters
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
Returns
: The pos of "a" minimum

Definition at line 362 of file GPUFunctions.cu.

◆ ReadWavGPU()

ReadWavGPU ( short *  GPUframe,
short *  CPUframe,
FILE *  fp 
)

ReadFileGPU reads current audio (frame) from WAV file when NVIDIA GPU is used.

Parameters
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
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 473 of file GPUFunctions.cu.

◆ ReadWavGPU1st()

ReadWavGPU1st ( short *  GPUframe,
short *  CPUframe,
FILE *  fp 
)

ReadWavGPU1st reads first audio (frame) from WAV file when NVIDIA GPU is used.

Parameters
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
Returns
: 0 if all is OK, otherwise a code error (see defines.h)

Definition at line 456 of file GPUFunctions.cu.