-
Notifications
You must be signed in to change notification settings - Fork 0
/
initLibs.cu
90 lines (53 loc) · 1.78 KB
/
initLibs.cu
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
65
66
67
68
69
70
/*
initLibs.cu
Initialize libraries to use.
Nicolas Sawaya
2013
*/
bool initCula() {
culaStatus culaStat;
culaStat = culaInitialize();
if(culaStat!=culaNoError) {
cout << "CULA failed to initialize. " << endl;;
cout << "culaGetStatusString(culaStat) = " << culaGetStatusString(culaStat);
cout << endl;
cout << "culaGetErrorInfo() = " << culaGetErrorInfo();
//Apparently above returns error integer equivalent to LAPACK error
cout << ". Aborting." << endl;
return false;
}
return true;
}
bool initCusparse(cusparseHandle_t *cusparseHandle) {
cusparseStatus_t csStatus;
csStatus = cusparseCreate(cusparseHandle);
if (csStatus != CUSPARSE_STATUS_SUCCESS) {
cout << "Error from cusparseCreate(). csStatus = ";
cout << cusparseGetErrorString(csStatus) << endl;
return false;
}
//Set pointer mode to device
cusparseSetPointerMode(*cusparseHandle, CUSPARSE_POINTER_MODE_DEVICE);
return true;
}
bool initCublas(cublasHandle_t *cublasHandle) {
cublasStatus_t cbStatus;
//cublasHandle = 0;
cbStatus = cublasCreate(cublasHandle);
if (cbStatus != CUBLAS_STATUS_SUCCESS) {
cout << "Error from cublasCreate(). cbStatus = ";
cout << cublasGetErrorString(cbStatus) << endl;
return false;
}
//Set pointer mode to device
cbStatus = cublasSetPointerMode(*cublasHandle, CUBLAS_POINTER_MODE_DEVICE);
return true;
}
bool initCufft(cufftHandle *cufftPlan, int arrlength) {
//cufftPlan1d(plan, nx, cuffttype, batch)
if( cufftPlan1d(cufftPlan, arrlength, CUFFT_Z2Z, 1) != CUFFT_SUCCESS ) {
cout << "ERROR in initCufft with cufftPlan1d(). Aborting." << endl;
return false;
}
return true;
}