- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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), sizeof(I[0]), 1, In ); for (i = 0; i < nz; i++) fread ( &(val), sizeof(val[0]), 1, In ); for (i = 0; i < nz; i++) fread ( &(J), sizeof(J[0]), 1, In ); for (i = 0; i < n; i++) fread ( &(RHS), 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; rhs = RHS; } for (i = 0; i < nz; i++) { columns = J; values = val; } 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); 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!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- check if you fill the input matrix be the right way in accordance with CSR. DSS interface dosn't provide Matrix Checker functionality. see Pardiso ipatm(27).
- how did you link the example? please check with MKL Linker Adviser how to do that. Here is the link to LA: http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your quick response!
To link the example I do the following steps:
export MKLROOT=/opt/intel/mkl export MKLPATH=$MKLROOT/lib/intel64 export MKLINCLUDE=$MKLROOT/include source $MKLROOT/bin/mklvars.sh intel 64
Then according to my specification:
g++ pardiso_sym_c.c -o pardiso -L$MKLPATH -I$MKLINCLUDE -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm -ldl
It gives:
/opt/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `logf' /opt/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `atan2' /opt/intel/mkl/lib/intel64/libmkl_intel_thread.so: undefined reference to `sin' /opt/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `fabs' /opt/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `exp' /opt/intel/mkl/lib/intel64/libmkl_intel_thread.so: undefined reference to `cos' /opt/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `sqrt' /opt/intel/mkl/lib/intel64/libmkl_intel_lp64.so: undefined reference to `log' /opt/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `pow' /opt/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `log10' /opt/intel/mkl/lib/intel64/libmkl_intel_thread.so: undefined reference to `floor' /opt/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `ceil' /opt/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `expf'
Link advisor aslo suggests this option:
-DMKL_ILP64 -m64 -I$(MKLROOT)/include
But it doesn't solve the problem.
Is it possible to use iparm(27) in this program? Or should I compile pardiso_sym_c.c first and try my system there?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does the reported
source $MKLROOT/bin/mklvars.sh intel 64
contain just a typographical error, the real command being
source $MKLROOT/bin/mklvars.sh intel64
?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, but it's really just a misprint in my post, of course I used
source
$MKLROOT/bin/mklvars.sh intel64
This is strange: usually errors concerning 'logf', 'sin', 'cos', etc appear when -lm is missed. So this problem remains unsolved, but the error which occured during reordering was fixed: I didn't pass the last element to rowIndex, and now it works until dss_solve_real. Here memory crashes:

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page