Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
112 Views

segment error on mkl_sparse_?_ev when the matrix has degenerate eigenvalues

Hi everyone,

I am trying to calculate eigenvalues of some real symmetric sparse matrices. What I notice is that the program crashes occasionally. I found a minimum working example:

#include <stdio.h>
#include <mkl.h>
#include <mkl_spblas.h>
#include <mkl_solvers_ee.h>

int main()
{
	int i;
    MKL_INT pm[128];
    mkl_sparse_ee_init(pm);
    // feastinit(pm);  // Using FEAST is fine
    char ls_which = 'L';
    sparse_matrix_t mat_handle;

    double vals[] = {3, 1, 1, 5, 1, 5, 5};
    MKL_INT cols[] = {0, 1, 3, 1, 2, 2, 3};
    MKL_INT rows[] =  {0, 3, 5, 6, 7};

    double vals2[] = {3, 1, 1, 1, 5, 5, 5};
    MKL_INT cols2[] = {0, 1, 2, 3, 1, 2, 3};
    MKL_INT rows2[] =  {0, 4, 5, 6, 7};

    MKL_INT ret_k;
    double ret_E[4], ret_X[4*4], ret_res[4];
    struct matrix_descr descs = {.type = SPARSE_MATRIX_TYPE_SYMMETRIC,
                               .mode = SPARSE_FILL_MODE_UPPER,
                               .diag = SPARSE_DIAG_NON_UNIT
    };
    int csize = 4;
    sparse_status_t spflag = mkl_sparse_d_create_csr(&mat_handle, SPARSE_INDEX_BASE_ZERO, csize, csize,
                           rows, rows+1, cols, vals);
    printf("create_csr return: %d\n", (int)spflag );
    spflag = mkl_sparse_d_ev(&ls_which, pm, mat_handle, descs, csize, &ret_k, ret_E, ret_X, ret_res);
    printf("sparse_ev return: %d\n", (int)spflag );
    for(i=0; i<4; ++i)
    {
    	printf("%f ", ret_E);
    }
    printf("\n");
    spflag = mkl_sparse_d_create_csr(&mat_handle, SPARSE_INDEX_BASE_ZERO, csize, csize,
                           rows2, rows2+1, cols2, vals2);
printf("create_csr return: %d\n", (int)spflag );
    spflag = mkl_sparse_d_ev(&ls_which, pm, mat_handle, descs, csize, &ret_k, ret_E, ret_X, ret_res); // *Crash* here
    printf("sparse_ev return: %d\n", (int)spflag );
    for(i=0; i<4; ++i)
    {
    	printf("%f ", ret_E);
    }

    printf("\n");
}

The first matrix is 

[3, 1, 0, 1;
1, 5, 1, 0;
0, 1, 5, 0;
1, 0, 0, 5

The second matrix is 

[3, 1, 1, 1;
1, 5, 0, 0;
1, 0, 5, 0;
1, 0, 0, 5

which has two degenerated eigenvalue 5. I am wondering what happens.

Also attach the simple Makefile:

INTEL_ROOT = /opt/intel/compilers_and_libraries/mac
MKLROOT = $(INTEL_ROOT)/mkl
FLAGS =   -L${MKLROOT}/lib -Wl,-rpath,${MKLROOT}/lib -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl
mkl_test: test.c
	icc -o mkl_test test.c -I$(MKLROOT)/include $(FLAGS) 
2 Replies
Highlighted
Beginner
112 Views

Did you solve this problem? if not, why don't you try to change the type to General matrix? 

I am now suffering from symmetric diagonalization using mkl_sparse_d_ev function. In my case, if I use the general format (even though the matrix is still symmetric), the function works perfectly.

0 Kudos
Highlighted
Novice
105 Views

I have a positive semi-definite matrix with two zero-eigenvalues. I'm trying to find its smallest, non-zero eigenvalue. I seem to be having the same trouble when I use SPARSE_MATRIX_TYPE_SYMMETRIC. This is the backtrace:

 

#0  0x00007ffff591c0e7 in mkl_sparse_d_transpose_matrix_i4 () from /opt/intel/mkl/lib/intel64/libmkl_intel_thread.so
#1  0x00007ffff597eda2 in mkl_sparse_d_transposeMatrix_i4 () from /opt/intel/mkl/lib/intel64/libmkl_intel_thread.so
#2  0x00007ffff593eaba in mkl_sparse_d_add_i4 () from /opt/intel/mkl/lib/intel64/libmkl_intel_thread.so
#3  0x00007ffff597b06b in create_gen_from_sym () from /opt/intel/mkl/lib/intel64/libmkl_intel_thread.so
#4  0x00007ffff597c730 in mkl_sparse_d_optimize_csr_mv_i4 () from /opt/intel/mkl/lib/intel64/libmkl_intel_thread.so
#5  0x00007fffef3e575b in mkl_sparse_optimize_i4_avx2 () from /opt/intel/mkl/lib/intel64/libmkl_avx2.so
#6  0x00007ffff68e7fe1 in mkl_sparse_d_ev_i4 () from /opt/intel/mkl/lib/intel64/libmkl_intel_thread.so

 

EDIT: Never-mind; I have made a trivial mistake. It works for me with either setting, and the SYMMETRIC option is slightly faster.

 

0 Kudos