Skip to content

Commit

Permalink
Det() returns zero for the sigular matrix
Browse files Browse the repository at this point in the history
According to cuSOLVER's document, returned `devInfo` greater than zero
means U[devInfo - 1, devInfo - 1] (zero-indexed) is zero, which implies
the determinant is zero.
  • Loading branch information
IvanaGyro committed Dec 4, 2024
1 parent dd72877 commit eb67ff2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/backend/linalg_internal_gpu/cuDet_internal.cu
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ namespace cytnx {

int info;
checkCudaErrors(cudaMemcpy(&info, devInfo, sizeof(int), cudaMemcpyDeviceToHost));
cytnx_error_msg(info != 0, "[ERROR] cusolverDnZgetrf fail with info= %d\n", info);
cytnx_error_msg(info < 0, "[ERROR] cusolverDnZgetrf fail with info= %d\n", info);
// TODO: info > 0 means U[info - 1, info - 1] is zero, which implies the determinant is
// zero. The steps below can be skipped.

// since we do unify mem, direct access element is possible:
od[0] = 1;
Expand Down Expand Up @@ -79,7 +81,9 @@ namespace cytnx {

int info;
checkCudaErrors(cudaMemcpy(&info, devInfo, sizeof(int), cudaMemcpyDeviceToHost));
cytnx_error_msg(info != 0, "[ERROR] cusolverDnCgetrf fail with info= %d\n", info);
cytnx_error_msg(info < 0, "[ERROR] cusolverDnCgetrf fail with info= %d\n", info);
// TODO: info > 0 means U[info - 1, info - 1] is zero, which implies the determinant is
// zero. The steps below can be skipped.

// since we do unify mem, direct access element is possible:
od[0] = 1;
Expand Down Expand Up @@ -124,7 +128,9 @@ namespace cytnx {

int info;
checkCudaErrors(cudaMemcpy(&info, devInfo, sizeof(int), cudaMemcpyDeviceToHost));
cytnx_error_msg(info != 0, "[ERROR] cusolverDnDgetrf fail with info= %d\n", info);
cytnx_error_msg(info < 0, "[ERROR] cusolverDnDgetrf fail with info= %d\n", info);
// TODO: info > 0 means U[info - 1, info - 1] is zero, which implies the determinant is
// zero. The steps below can be skipped.

// since we do unify mem, direct access element is possible:
od[0] = 1;
Expand Down Expand Up @@ -169,7 +175,9 @@ namespace cytnx {

int info;
checkCudaErrors(cudaMemcpy(&info, devInfo, sizeof(int), cudaMemcpyDeviceToHost));
cytnx_error_msg(info != 0, "[ERROR] cusolverDnSgetrf fail with info= %d\n", info);
cytnx_error_msg(info < 0, "[ERROR] cusolverDnSgetrf fail with info= %d\n", info);
// TODO: info > 0 means U[info - 1, info - 1] is zero, which implies the determinant is
// zero. The steps below can be skipped.

// since we do unify mem, direct access element is possible:
od[0] = 1;
Expand Down

0 comments on commit eb67ff2

Please sign in to comment.