-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcuda_solver.cuh
64 lines (51 loc) · 1.54 KB
/
cuda_solver.cuh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef CUDA_SOLVER_H
#define CUDA_SOLVER_H
#include <assert.h>
#include <stdio.h>
#include "cusolverDn.h"
#include "cuda_pyramid.cuh"
#include "defines.hpp"
#include "enums.hpp"
#include "kernels.cuh"
class cudaSolver {
int numberOfParameters = 0;
int bufferSize = 0;
cudaPyramid &cudaPyramidManager;
cusolverDnHandle_t handle = nullptr;
cudaStream_t stream = nullptr;
float *buffer = nullptr;
int *info = nullptr;
float *d_mat = nullptr;
float *d_vec = nullptr;
public:
cudaSolver(cudaPyramid &cudaPyramidManager_)
: cudaPyramidManager(cudaPyramidManager_) {
cudaError err;
// Create cuSolver handle and other cuSolver mem space
err = cudaMalloc(&info, sizeof(int));
if (err != cudaSuccess) {
printf("Failed to allocate cuSolver info (error code %s)!\n",
cudaGetErrorString(err));
exit(EXIT_FAILURE);
}
err = cudaMemset(info, 0, sizeof(int));
if (err != cudaSuccess) {
printf("Failed to set cuSolver info to 0 (error code %s)!\n",
cudaGetErrorString(err));
exit(EXIT_FAILURE);
}
cusolverStatus_t cu_err = cusolverDnCreate(&handle);
if (cu_err != CUSOLVER_STATUS_SUCCESS) {
printf("Failed to create cuSolver handle!\n");
exit(EXIT_FAILURE);
}
#if DEBUG_SOLVER_CUDA
printf("cudaSolver::cudaSolver\n");
#endif
}
~cudaSolver();
errorEnum setCuSolver(int iSector, int numberOfModelParameters_,
cudaStream_t correlationStream);
errorEnum callCusolver(int iSector, float *chi);
};
#endif // CUDA_SOLVER_H