Open SalmanMaths opened 1 year ago
It's difficult to tell what went wrong. You will need to do some debugging, for example, by printing out some info at various places of the source code.
The problem occurred to me at the position/function ( LU factorization of A): / ------------------------------------------------------------ Compute the LU factorization of A. The following routine will create nprocs threads. ------------------------------------------------------------/ pdgstrf(&superlumt_options, &AC, perm_r, &L, &U, &Gstat, &info);
It is must, to use the dreadhb(&m, &n, &nnz, &a, &asub, &xa)? instead of it, I use the following (it works in SuperLU):
// Initialize matrix A. m = n = f.size();//f.size is the number of rows of the matrix nnz = _sk.size(); if ( !(a = doubleMalloc(nnz)) ) SUPERLU_ABORT("Malloc fails for a[]."); if ( !(asub = intMalloc(nnz)) ) SUPERLU_ABORT("Malloc fails for asub[]."); if ( !(xa = intMalloc(n+1)) ) SUPERLU_ABORT("Malloc fails for xa[]."); dCompRow_to_CompCol(m, n, nnz, const_cast<double>(_sk.data()), const_cast<int_t>(_ik.data()), const_cast<int_t>(_id.data()), &a, &asub, &xa); / Set up the sparse matrix data structure for A. */ dCreate_CompCol_Matrix(&A, m, n, nnz, a, asub, xa, SLU_NC, SLU_D, SLU_GE);
I don't see anything wrong in your matrix setup routine. I suggest you go into the SuperLU source code, do some printing at various places, see whether your input matrix is correct. In SRC/pdutil.c, therre are a number of printing functions, such as: dPrint_CompCol_Matrix(), etc.
fp.txt I did this and printed the CCS matrix in the attached file.
Dear Sherry Li, Thank you so much for your support. I think my problem is from the not correct reading of matrix structure. Now I am going to save my matrix in a .hb file then I will call from dreadhb() function. So I hope it will work.
But I need your help to define the .hb file correctly. I defined it below but it is not working. Please help me in this (Particularly in the first two lines: fprintf(fp,"CompCol matrix %s\n", what); //fprintf(fp,"Stype %d, Dtype %d, Mtype %d\n", A->Stype,A->Dtype,A->Mtype); n = A->ncol; Astore = (NCformat ) A->Store; dp = (double ) Astore->nzval; fprintf(fp,"RUA"); fprintf(fp," %d %d %d ", A->nrow,A->ncol,Astore->nnz);//nrow, ncol, a, asub, xa, fprintf(fp,"0\n");):
`template
// Create matrix A in the format expected by SuperLU.
dCreate_CompCol_Matrix(&A1, m, n1, nnz, a, asub, xa, SLU_NC, SLU_D, SLU_GE);
A = &A1;
fp = fopen("./SRC/fp.hb","w");
fprintf(fp,"CompCol matrix %s\n", what);
//fprintf(fp,"Stype %d, Dtype %d, Mtype %d\n", A->Stype,A->Dtype,A->Mtype);
n = A->ncol;
Astore = (NCformat *) A->Store;
dp = (double *) Astore->nzval;
fprintf(fp,"RUA");
fprintf(fp," %d %d %d ", A->nrow,A->ncol,Astore->nnz);//nrow, ncol, a, asub, xa,
fprintf(fp,"0\n");
//fprintf(fp,"\nxa: ");//
for (i = 0; i <= n; ++i){
fprintf(fp,"%d ", Astore->colptr[i]);
}
fprintf(fp,"\n");
//fprintf(fp,"\nasub: ");//
for (i = 0; i < Astore->colptr[n]; ++i){
fprintf(fp,"%d ", Astore->rowind[i]);
}
fprintf(fp,"\n");
//fprintf(fp,"\na: ");//
for (i = 0; i < Astore->colptr[n]; ++i){
fprintf(fp,"%f ", dp[i]);
}
fprintf(fp,"\n");
fclose(fp);
return;
}`
fp.hb.zip Dear Sherry Li,
I am using the matrix in the attachment but give me the Segmentation fault (core dumped) at dreadhb(). What is wrong in the matrix or it is the code problem?
I am using the SuperLU_MT and the code from pdrepeat.c (https://github.com/xiaoyeli/superlu_mt/blob/master/EXAMPLE/pdrepeat.c). In this code the function dreadhb(&m, &n, &nnz, &a, &asub, &xa); is used. My matrix format is CRS and transform it into CCS by dCompRow_to_CompCol(m, n, nnz, const_cast<double>(_sk.data()), const_cast<int_t>(_ik.data()), const_cast<int_t*>(_id.data()), &a, &asub, &xa); And then use the dCreate_CompCol_Matrix(&A, m, n, nnz, a, asub, xa, SLU_NC, SLU_D, SLU_GE); to create the Supermatrix A.
When I run the code, it gives me the following error:
** On entry to sp_ienv, parameter number 1 had an illegal value Storage for L subscripts exceeded; Current column 0; Need at least 72; You may set it by the 8-th parameter in routine sp_ienv(). Memory allocation failed at line 222 in file pmemory.c
Any suggestions about this to handle the error?