RTC Toolkit 4.0.2
Loading...
Searching...
No Matches
gpuLib.hpp
Go to the documentation of this file.
1
13#ifndef EXAMPLEGPULIB_H
14#define EXAMPLEGPULIB_H
15
16#include <cassert>
17#include <string>
18#include <vector>
19
20#include "cublas_v2.h"
21#include "cuda_runtime.h"
22
23#include "rtctk/exampleDataTask/CumulativeAverage_cuda.cuh"
24
25class GpuLib {
26public:
27 GpuLib(int input_length, int output_length, int gpu);
29
30 void SetMatrix(float* mat, bool flip = true);
31 std::vector<float> GetMatrix();
32
34
35 std::vector<float> GetAvgSlopes();
36
37 std::vector<float> GetResults(bool download = false);
38
39 void NewSample(const float* sample, int callback_count);
40 void Compute();
41
43
44protected:
45 // sets the required GPU
46 void SetGPU();
47
48 void PrintCudaError(cudaError_t error);
49 std::string CublasGetStatusString(cublasStatus_t error);
50 void PrintCublasStatus(cublasStatus_t status);
51
52private:
53 int m_gpu;
54 int current_sample;
55 float m_alpha;
56 float m_beta;
57
58 cublasHandle_t handle;
59
60 // input_vector
61 int m_slopes;
62 int m_modes;
63
64 // slopes vector
65 float* m_slopes_vector;
66 float* m_slopes_vector_d;
67
68 // avg_array_vector
69 float* m_avg_slopes;
70 float* m_avg_slopes_d;
71
72 // matrix
73 float* m_slopes_to_modes_matrix;
74 float* m_slopes_to_modes_matrix_d;
75
76 // output vector
77 float* m_modes_vector;
78 float* m_modes_vector_d;
79};
80
81#endif // EXAMPLEGPULIB_H
Definition: gpuLib.hpp:25
std::string CublasGetStatusString(cublasStatus_t error)
void SetMatrix(float *mat, bool flip=true)
void InitReaderThread()
void ResetAvgSlopes()
void SetGPU()
void Compute()
std::vector< float > GetResults(bool download=false)
std::vector< float > GetMatrix()
void NewSample(const float *sample, int callback_count)
std::vector< float > GetAvgSlopes()
void PrintCublasStatus(cublasStatus_t status)
GpuLib(int input_length, int output_length, int gpu)
void PrintCudaError(cudaError_t error)