RTC Toolkit  2.0.0
gpuLib.hpp
Go to the documentation of this file.
1 
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 
24 class GpuLib {
25 public:
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 
43 protected:
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 
51 private:
52  int m_gpu;
53  int current_sample;
54  float m_alpha;
55  float m_beta;
56 
57  cublasHandle_t handle;
58 
59  // input_vector
60  int m_slopes;
61  int m_modes;
62 
63  // slopes vector
64  float* m_slopes_vector;
65  float* m_slopes_vector_d;
66 
67  // avg_array_vector
68  float* m_avg_slopes;
69  float* m_avg_slopes_d;
70 
71  // matrix
72  float* m_slopes_to_modes_matrix;
73  float* m_slopes_to_modes_matrix_d;
74 
75  // output vector
76  float* m_modes_vector;
77  float* m_modes_vector_d;
78 };
79 
80 #endif // EXAMPLEGPULIB_H
GpuLib::Compute
void Compute()
GpuLib::CublasGetStatusString
std::string CublasGetStatusString(cublasStatus_t error)
GpuLib::PrintCudaError
void PrintCudaError(cudaError_t error)
GpuLib::SetMatrix
void SetMatrix(float *mat, bool flip=true)
GpuLib::SetGPU
void SetGPU()
rtctkExampleDataTaskGenFitsData.mat
mat
Definition: rtctkExampleDataTaskGenFitsData.py:12
GpuLib::NewSample
void NewSample(const float *sample, int callback_count)
GpuLib::GpuLib
GpuLib(int input_length, int output_length, int gpu)
GpuLib::GetResults
std::vector< float > GetResults(bool download=false)
GpuLib::~GpuLib
~GpuLib()
GpuLib::GetAvgSlopes
std::vector< float > GetAvgSlopes()
GpuLib::ResetAvgSlopes
void ResetAvgSlopes()
GpuLib::InitReaderThread
void InitReaderThread()
GpuLib
Definition: gpuLib.hpp:24
GpuLib::PrintCublasStatus
void PrintCublasStatus(cublasStatus_t status)
GpuLib::GetMatrix
std::vector< float > GetMatrix()