COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
test_cusolver Namespace Reference

Functions

def test_float_syevd ()
 
def test_double_syevd ()
 

Variables

int m = 1024
 
int n = 1024
 
 min_mn = min(m, n)
 
int dec = 3
 
int prec = 10**(-dec)
 
 c = ch.context.get_instance()
 

Function Documentation

◆ test_double_syevd()

def test_cusolver.test_double_syevd ( )

Definition at line 181 of file test_cusolver.py.

181 def test_double_syevd():
182 
183  d_mat = ch.obj_double(c, np.random.randn(m, m))
184  d_U = ch.obj_double(c, np.random.randn(m, m))
185  d_EV = ch.obj_double(c, np.random.randn(m))
186  d_EV2 = ch.obj_double(c, np.random.randn(m))
187 
188  d_res = d_mat.gemm(d_mat, op_a='n', op_b='t')
189 
190  ch.syevd_double(d_res, d_EV, d_U)
191 
192  U = np.array(d_U)
193  Mat = np.array(d_res)
194  EV = np.diag(d_EV)
195 
196  npt.assert_almost_equal(np.dot(np.dot(U, EV), U.T), Mat, decimal=2 * dec - 1)
197 
198  err = np.amax(np.abs(Mat - np.dot(np.dot(U, EV), U.T)))
199 
200  print("")
201 
202  print("out of place, compute U")
203  print(err)
204 
205  npt.assert_almost_equal(err, 0., decimal=dec)
206 
207  d_res = d_mat.gemm(d_mat, op_a='n', op_b='t')
208  ch.syevd_double(d_res, d_EV2, computeU=False)
209 
210  err = np.amax(np.abs(np.array(d_EV) - np.array(d_EV2)))
211 
212  print("in place, U not computed")
213  print(err)
214  npt.assert_almost_equal(np.array(d_EV), np.array(d_EV2), decimal=2 * dec - 2)

◆ test_float_syevd()

def test_cusolver.test_float_syevd ( )

Definition at line 145 of file test_cusolver.py.

145 def test_float_syevd():
146 
147  d_mat = ch.obj_float(c, np.random.randn(m, m))
148  d_U = ch.obj_float(c, np.random.randn(m, m))
149  d_EV = ch.obj_float(c, np.random.randn(m))
150  d_EV2 = ch.obj_float(c, np.random.randn(m))
151 
152  d_res = d_mat.gemm(d_mat, op_a='n', op_b='t')
153 
154  ch.syevd_float(d_res, d_EV, d_U)
155 
156  U = np.array(d_U)
157  Mat = np.array(d_res)
158  EV = np.diag(d_EV)
159 
160  npt.assert_almost_equal(np.dot(np.dot(U, EV), U.T), Mat, decimal=dec - 1)
161 
162  err = np.amax(np.abs(Mat - np.dot(np.dot(U, EV), U.T)))
163 
164  print("")
165 
166  print("out of place, compute U")
167  print(err)
168 
169  npt.assert_almost_equal(err, 0., decimal=dec)
170 
171  d_res = d_mat.gemm(d_mat, op_a='n', op_b='t')
172  ch.syevd_float(d_res, d_EV2, computeU=False)
173 
174  err = np.amax(np.abs(np.array(d_EV) - np.array(d_EV2)))
175 
176  print("in place, U not computed")
177  print(err)
178  npt.assert_almost_equal(np.array(d_EV), np.array(d_EV2), decimal=dec - 2)
179 
180 

Variable Documentation

◆ c

test_cusolver.c = ch.context.get_instance()

Definition at line 13 of file test_cusolver.py.

◆ dec

int test_cusolver.dec = 3

Definition at line 10 of file test_cusolver.py.

◆ m

int test_cusolver.m = 1024

Definition at line 6 of file test_cusolver.py.

◆ min_mn

test_cusolver.min_mn = min(m, n)

Definition at line 8 of file test_cusolver.py.

◆ n

int test_cusolver.n = 1024

Definition at line 7 of file test_cusolver.py.

◆ prec

int test_cusolver.prec = 10**(-dec)

Definition at line 11 of file test_cusolver.py.