Hi!
I'm taking my first steps at MKL and after installation and linking libraries (I have Ubuntu 12.04, 64-bit) I tried to modify the direct solver dss_sym_c.c so that I could solve my sparse symmetric system which is stored in a binary file (1 based index). I changed CSR system but after that an unclassifiable error uccured at the "reorder step" of the program. What can be the reason of it?
Here's the code:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include "mkl_dss.h"
#include "mkl_types.h"
MKL_INT
main ()
{
MKL_INT i;
_MKL_DSS_HANDLE_t handle;
_INTEGER_t error;
_CHARACTER_t statIn[] = "determinant";
_DOUBLE_PRECISION_t statOut[5];
MKL_INT opt = MKL_DSS_DEFAULTS;
MKL_INT sym = MKL_DSS_SYMMETRIC;
MKL_INT type = MKL_DSS_POSITIVE_DEFINITE;
MKL_INT nRows;
MKL_INT nCols;
MKL_INT nNonZeros;
MKL_INT nRhs;
_INTEGER_t *rowIndex;
_INTEGER_t *columns;
_DOUBLE_PRECISION_t *values;
_DOUBLE_PRECISION_t *rhs;
_DOUBLE_PRECISION_t *solValues;
FILE *In;
MKL_INT n, nz;
MKL_INT *I = NULL, *J = NULL;
_DOUBLE_PRECISION_t *val = NULL, *sol = NULL, *RHS = NULL;
if ( ( In = fopen ("matr_rhs_binary", "rb" ) ) == NULL ) {
fprintf (stderr, "Error opening file\n");
return (-1);
}
fread ( &n, sizeof(MKL_INT), 1, In );
printf ("n = %d\n", n);
fread ( &nz, sizeof(MKL_INT), 1, In );
printf ("nz = %d\n", nz);
I = (MKL_INT *) malloc ( sizeof (I[0]) * (n + 1)); // csr row pointers for matrix A
J = (MKL_INT *) malloc ( sizeof (J[0]) * nz); // csr column indices for matrix A
val = (_DOUBLE_PRECISION_t *) malloc ( sizeof (val[0]) * nz); // csr values for matrix A
sol = (_DOUBLE_PRECISION_t *) malloc ( sizeof (sol[0]) * n);
RHS = (_DOUBLE_PRECISION_t *) malloc ( sizeof (RHS[0]) * n);
for (i = 0; i < n + 1; i++)
fread ( &(I[i]), sizeof(I[0]), 1, In );
for (i = 0; i < nz; i++)
fread ( &(val[i]), sizeof(val[0]), 1, In );
for (i = 0; i < nz; i++)
fread ( &(J[i]), sizeof(J[0]), 1, In );
for (i = 0; i < n; i++)
fread ( &(RHS[i]), sizeof(RHS[0]), 1, In);
fclose (In);
nRows = n;
nCols = n;
nNonZeros = nz;
nRhs = n;
rowIndex = (_INTEGER_t *) malloc ( sizeof (rowIndex[0]) * (nRows + 1) );
columns = (_INTEGER_t *) malloc ( sizeof (columns[0]) * nNonZeros );
values = (_DOUBLE_PRECISION_t *) malloc ( sizeof (values[0]) * nNonZeros );
rhs = (_DOUBLE_PRECISION_t *) malloc ( sizeof (rhs[0]) * nCols );
solValues = (_DOUBLE_PRECISION_t *) malloc ( sizeof (solValues[0]) * nCols );
for (i = 0; i < n; i++) {
rowIndex[i] = I[i];
rhs[i] = RHS[i];
}
for (i = 0; i < nz; i++) {
columns[i] = J[i];
values[i] = val[i];
}
error = dss_create (handle, opt);
if (error != MKL_DSS_SUCCESS)
goto printError;
error = dss_define_structure (handle, sym, rowIndex, nRows, nCols,
columns, nNonZeros);
if (error != MKL_DSS_SUCCESS)
goto printError;
error = dss_reorder (handle, opt, 0);
if (error != MKL_DSS_SUCCESS)
goto printError;
error = dss_factor_real (handle, type, values);
if (error != MKL_DSS_SUCCESS)
goto printError;
error = dss_solve_real (handle, opt, rhs, nRhs, solValues);
if (error != MKL_DSS_SUCCESS)
goto printError;
printf ("check\n");
if (nRows < nNonZeros)
{
error = dss_statistics (handle, opt, statIn, statOut);
if (error != MKL_DSS_SUCCESS)
goto printError;
printf (" determinant power is %g \n", statOut[0]);
printf (" determinant base is %g \n", statOut[1]);
printf (" Determinant is %g \n", (pow (10.0, statOut[0])) * statOut[1]);
}
error = dss_delete (handle, opt);
if (error != MKL_DSS_SUCCESS)
goto printError;
printf (" Solution array: ");
for (i = 0; i < nCols; i++)
printf (" %g", solValues[i]);
printf ("\n");
exit (0);
printError:
printf ("Solver returned error code %d\n", error);
exit (1);
}
And another question: When I compile pardiso_sym_c.c, several errors occur: undefined references to functions like atan2, sin, cos, log10, etc though I compile with an -lm option. Is it because of:
/usr/bin/ld: skipping incompatible /opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/ia32/libmkl_intel_thread.so when searching for -lmkl_intel_thread
/usr/bin/ld: skipping incompatible /opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/ia32/libmkl_intel_thread.a when searching for -lmkl_intel_thread
/usr/bin/ld: skipping incompatible /opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/ia32/libmkl_core.so when searching for -lmkl_core
/usr/bin/ld: skipping incompatible /opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/ia32/libmkl_core.a when searching for -lmkl_core
How can I fix it?
Thanks! Any help is appreciated!