Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

unresolved symbols compiling PARDISO

ringlery
Beginner
263 Views
Greetings,
I downloaded the unsymmetric, real PARDISO example file in c from pardiso-project.org to see if I could get that to work properly. I'm trying to compile it on a dual 3.0 GHz quad core machine running OSX 10.5 and using the em64t libraries. I compile using the following:

icpc real.cpp -L$MKLPATH/Libraries/em64t -I$MKLPATH/Headers -lmkl_solver_lp64 $MKLPATH/Libraries/em64t/libmkl_intel_lp64.a $MKLPATH/Libraries/em64t/libmkl_intel_thread.a $MKLPATH/Libraries/em64t/libmkl_core.a $MKLPATH/Libraries/em64t/libmkl_intel_lp64.a $MKLPATH/Libraries/em64t/libmkl_intel_thread.a $MKLPATH/Libraries/em64t/libmkl_core.a -lguide -lpthread

This comes, more or less, directly out of the Intel PARDISO documentation. The results are

real.cpp(110): (col. 5) remark: LOOP WAS VECTORIZED.
real.cpp(113): (col. 5) remark: LOOP WAS VECTORIZED.
real.cpp(158): (col. 5) remark: LOOP WAS VECTORIZED.
real.cpp(181): (col. 5) remark: LOOP WAS VECTORIZED.
real.cpp(184): (col. 5) remark: LOOP WAS VECTORIZED.
Undefined symbols:
"__Z8pardiso_PvPiS0_S0_S0_S0_PdS0_S0_S0_S0_S0_S0_S1_S1_S0_", referenced from:
_main in icc7s5WXT.o
_main in icc7s5WXT.o
_main in icc7s5WXT.o
_main in icc7s5WXT.o
ld: symbol(s) not found

The MKL path is included in my DYLD_LIBRARY_PATH. Any suggestions would be appreciated.
0 Kudos
2 Replies
TimP
Honored Contributor III
263 Views
When you perform a static link by repeating the libraries, you may require 3 passes, probably with libmkl_intel_thread last in each group of 3. Is this method preferred for OSX, over the begin-group .. end-group method (which may require icpc 10.1.012 or newer)? Do you use extern "C" or equivalent header files for the MKL function names?
0 Kudos
ringlery
Beginner
263 Views
Ok, I had forgotten the extern "C" and now the code links properly. Now the problem is that I get a segmentation fault whenever the PARDISO routine is called. Below is the slightly modified sample file that I'm using:

/* -------------------------------------------------------------------- */
/* Example program to show the use of the "PARDISO" routine */
/* on for unsymmetric linear systems */
/* -------------------------------------------------------------------- */
/* This program can be downloaded from the following site: */
/* http://www.pardiso-project.org */
/* */
/* (C) Olaf Schenk, Department of Computer Science, */
/* University of Basel, Switzerland. */
/* Email: olaf.schenk@unibas.ch */
/* -------------------------------------------------------------------- */

#include
#include
#include


/* Change this, if your Fortran compiler does not append underscores. */
/* e.g. the AIX compiler: #define F77_FUNC(func) func */

/*#ifdef AIX
#define F77_FUNC(func) func
#else
#define F77_FUNC(func) func ## _
#endif*/
#define PARDISO pardiso_
extern "C" {int PARDISO
(void *, int *, int *, int *, int *, int *,
double *, int *, int *, int *, int *, int *,
int *, double *, double *, int *);}


int main( void )
{
/* Matrix data. */
int n = 8;
int ia[ 9] = { 0, 4, 7, 9, 11, 12, 15, 17, 20 };
int ja[20] = { 0, 2, 5, 6,
1, 2, 4,
2, 7,
3, 6,
1,
2, 5, 7,
1, 6,
2, 6, 7 };
double a[20] = { 7.0, 1.0, 2.0, 7.0,
-4.0, 8.0, 2.0,
1.0, 5.0,
7.0, 9.0,
-4.0,
7.0, 3.0, 8.0,
1.0, 11.0,
-3.0, 2.0, 5.0 };

int nnz = ia;
int mtype = 11; /* Real unsymmetric matrix */

/* RHS and solution vectors. */
double b[8], x[8];
int nrhs = 1; /* Number of right hand sides. */

/* Internal solver memory pointer pt, */
/* 32-bit: int pt[64]; 64-bit: long int pt[64] */
/* or void *pt[64] should be OK on both architectures */
void *pt[64];

/* Pardiso control parameters. */
int iparm[64];
int maxfct, mnum, phase, error, msglvl;

/* Number of processors. */
int num_procs;

/* Auxiliary variables. */
char *var;
int i;

double ddum; /* Double dummy */
int idum; /* Integer dummy. */

/* -------------------------------------------------------------------- */
/* .. Setup Pardiso control parameters und initialize the solvers */
/* internal adress pointers. This is only necessary for the FIRST */
/* call of the PARDISO solver. */
/* ---------------------------------------------------------------------*/


/* Numbers of processors, value of OMP_NUM_THREADS */
var = getenv("OMP_NUM_THREADS");
if(var != NULL)
sscanf( var, "%d", &num_procs );
else {
printf("Set environment OMP_NUM_THREADS to 1");
exit(1);
}
iparm[2] = num_procs;


maxfct = 1; /* Maximum number of numerical factorizations. */
mnum = 1; /* Which factorization to use. */

msglvl = 1; /* Print statistical information */
error = 0; /* Initialize error flag */


/* -------------------------------------------------------------------- */
/* .. Convert matrix from 0-based C-notation to Fortran 1-based */
/* notation. */
/* -------------------------------------------------------------------- */
for (i = 0; i ia += 1;
}
for (i = 0; i ja += 1;
}

/* -------------------------------------------------------------------- */
/* .. Reordering and Symbolic Factorization. This step also allocates */
/* all memory that is necessary for the factorization. */
/* -------------------------------------------------------------------- */
phase = 11;

PARDISO (pt, &maxfct, &mnum, &mtype, &phase,
&n, a, ia, ja, &idum, &nrhs,
iparm, &msglvl, &ddum, &ddum, &error);

if (error != 0) {
printf(" ERROR during symbolic factorization: %d", error);
exit(1);
}
printf(" Reordering completed ... ");
printf(" Number of nonzeros in factors = %d", iparm[17]);
printf(" Number of factorization MFLOPS = %d", iparm[18]);

/* -------------------------------------------------------------------- */
/* .. Numerical factorization. */
/* -------------------------------------------------------------------- */
phase = 22;

PARDISO (pt, &maxfct, &mnum, &mtype, &phase,
&n, a, ia, ja, &idum, &nrhs,
iparm, &msglvl, &ddum, &ddum, &error);

if (error != 0) {
printf(" ERROR during numerical factorization: %d", error);
exit(2);
}
printf(" Factorization completed ... ");

/* -------------------------------------------------------------------- */
/* .. Back substitution and iterative refinement. */
/* --------------------------------------------------------- ----------- */
phase = 33;

iparm[7] = 1; /* Max numbers of iterative refinement steps. */

/* Set right hand side to one. */
for (i = 0; i b = 1;
}

PARDISO (pt, &maxfct, &mnum, &mtype, &phase,
&n, a, ia, ja, &idum, &nrhs,
iparm, &msglvl, b, x, &error);

if (error != 0) {
printf(" ERROR during solution: %d", error);
exit(3);
}

printf(" Solve completed ... ");
printf(" The solution of the system is: ");
for (i = 0; i printf(" x [%d] = % f", i, x );
}
printf (" ");

/* -------------------------------------------------------------------- */
/* .. Convert matrix back to 0-based C-notation. */
/* -------------------------------------------------------------------- */
for (i = 0; i ia -= 1;
}
for (i = 0; i ja -= 1;
}

/* -------------------------------------------------------------------- */
/* .. Termination and release of memory. */
/* -------------------------------------------------------------------- */
phase = -1; /* Release internal memory. */

PARDISO (pt, &maxfct, &mnum, &mtype, &phase,
&n, &ddum, ia, ja, &idum, &nrhs,
iparm, &msglvl, &ddum, &ddum, &error);

return 0;
}
0 Kudos
Reply