forked from michael-lehn/FLENS
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_cusolver.cu
76 lines (47 loc) · 1.57 KB
/
test_cusolver.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
71
72
73
74
75
76
// $ nvcc -std=c++11 -ccbin=g++-4.7 -I. -o test_cusolver test_cusolver.cu -lcublas -lcusolver
#include <iostream>
#include <complex>
#include <thrust/device_malloc_allocator.h>
#define WITH_CUBLAS
#define WITH_CUSOLVER
#define CXXBLAS_DEBUG
#define CXXLAPACK_DEBUG
#define ALWAYS_USE_CXXLAPACK
#include "flens/flens.cxx"
using namespace flens;
using namespace std;
template <typename T>
using CPUArray = Array<T>;
template <typename T>
using CPUFull = FullStorage<T,ColMajor>;
template <typename T, typename I = IndexOptions<> >
using GPUArray = Array<T,I,thrust::device_malloc_allocator<T> >;
template <typename T, typename I = IndexOptions<> >
using GPUFull = FullStorage<T,ColMajor,I,thrust::device_malloc_allocator<T> >;
int main() {
//using T = std::complex<double>;
using T = double;
int N = 10000;
typedef DenseVector<GPUArray<T> > Vector;
typedef GeMatrix<GPUFull<T> > Matrix;
typedef typename Vector::IndexType IndexType;
cxxlapack::CusolverEnv::init(); // XXX: revisit
std::cout << cxxlapack::CudaEnv::getInfo() << std::endl;
GeMatrix<CPUFull<T> > A_(N,N);
A_ = 1;
A_.diag(0) = 2;
Matrix A = A_;
DenseVector<GPUArray<IndexType> > ipiv;
DenseVector<GPUArray<T> > B(N);
B = 1;
//cout << "A = " << A << endl;
//cout << "B = " << B << endl;
//flens::lapack::trf(A, ipiv);
//flens::lapack::trs(NoTrans, A, ipiv, B);
flens::lapack::sv(A, ipiv, B);
//cout << "A = " << A << endl;
//cout << "ipiv = " << ipiv << endl;
//cout << "B = " << B << endl;
cxxlapack::CusolverEnv::release(); // XXX: revisit
return 0;
}