workspace_gpu = gpuarray.zeros(lwork, dtype=A.dtype) info = gpuarray.zeros(batchSize, dtype=np.int32) # Compute: solver.cusolverDnCheevjBatched(handle, 'CUSOLVER_EIG_MODE_VECTOR', 'u', n, x_gpu.gpudata, n, w_gpu.gpudata, workspace_gpu.gpudata, lwork, info.gpudata, params, batchSize) # Print info tmp = info.get() if any(tmp): print "the following job did not converge:", np.nonzero(tmp)[0] else: print "all jobs converged" # Destroy handle solver.cusolverDnDestroySyevjInfo(params) solver.cusolverDnDestroy(handle) Q = x_gpu.get() W = w_gpu.get() print 'maximum error in A * Q - Q * Lambda is:' for i in range(batchSize): q = Q[i * n:(i + 1) * n, :].T.copy() x = A[i * n:(i + 1) * n, :].copy() w = W[i, :].copy() print '{}th matrix'.format(i), np.abs( np.dot(x, q) - np.dot(q, np.diag(w))).max()
lwork = solver.cusolverDnDsyevjBatched_bufferSize(handle, 'CUSOLVER_EIG_MODE_VECTOR', 'u', n, x_gpu.gpudata, n, w_gpu.gpudata, params, batchSize) workspace_gpu = gpuarray.zeros(lwork, dtype = A.dtype) info = gpuarray.zeros(batchSize, dtype = np.int32) # Compute: solver.cusolverDnDsyevjBatched(handle, 'CUSOLVER_EIG_MODE_VECTOR', 'u', n, x_gpu.gpudata, n, w_gpu.gpudata, workspace_gpu.gpudata, lwork, info.gpudata, params, batchSize) # print info tmp = info.get() if any(tmp): print("the following job did not converge: %r" % np.nonzero(tmp)[0]) # Destroy handle solver.cusolverDnDestroySyevjInfo(params) solver.cusolverDnDestroy(handle) Q = x_gpu.get() W = w_gpu.get() print('maximum error in A * Q - Q * Lambda is:') for i in range(batchSize): q = Q[i*n:(i+1)*n,:].T.copy() x = A[i*n:(i+1)*n,:].copy() w = W[i, :].copy() print('{}th matrix %r'.format(i) % np.abs(np.dot(x, q) - np.dot(q, np.diag(w))).max())