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