coin-or / Ipopt

COIN-OR Interior Point Optimizer IPOPT
https://coin-or.github.io/Ipopt
Other
1.43k stars 284 forks source link

Pardiso Loader issue with Intel MKL's Pardiso #253

Closed svigerske closed 5 years ago

svigerske commented 5 years ago

Issue created by migration from Trac.

Original creator: FabiF1

Original creation time: 2015-01-04 16:37:43

Assignee: ipopt-team

Version: 3.11

Dear all,

I am using Ipopt 3.11.9 from sources on a Windows machine. I am building it together with the linear solver Pardiso coming from the Intel MKL 11.2 update 1.

I may have found a bug in the Pardiso loader that would cause exceptions whenever Ipopt tries to invoke it. I am proposing a fix hereafter which has enabled me to successfully use MKL's Pardiso to solve optimization problems.

The main issue comes from the fact that in the Pardiso loader C-code, the argument IPARM comes after SOLVER. A bit of digging into the MKL reference documentation led me to believe that their version expects IPARM to come before SOLVER. Another minor issue appeared with an uninitialized pointer *E. Hereafter details of my fix.

PardisoLoader.c line 42-46 modified to become:

typedef void (*pardisoinit_new_t)(void* PT, const ipfint* MTYPE,
                              ipfint* IPARM,
                              const ipfint * SOLVER,
                              double* DPARM,
                              ipfint* E);

PardisoLoader.c line 62-67 modified to become:

void wrap_old_pardisoinit(void* PT, const ipfint* MTYPE, ipfint* IPARM, const ipfint* SOLVER, double* DPARM, ipfint* E) {
   if (func_pardisoinit == NULL)
      LSL_lateParadisoLibLoad();
   func_pardisoinit(PT, MTYPE, IPARM);
   // *E = 0; // Fab Hack as uninitialized pointer
}

PardisoLoader.c line 88-97 modified to become:

void F77_FUNC(pardisoinit,PARDISOINIT)(void* PT, const ipfint* MTYPE,
                      ipfint* IPARM,
                      const ipfint* SOLVER,
                      double* DPARM,
                      ipfint* E) {
   if (func_new_pardisoinit == NULL)
      LSL_lateParadisoLibLoad();
   assert(func_new_pardisoinit != NULL);
   func_new_pardisoinit(PT, MTYPE, IPARM, SOLVER, DPARM, E);
}

IpPardisoSolverInterface.cpp lines 69-73 modified to become:

 void PARDISOINIT_FUNC(void* PT, const ipfint* MTYPE,
                        ipfint* IPARM,
                        const ipfint* SOLVER,
                        double* DPARM,
                        ipfint* ERROR);

IpPardisoSolverInterface.cpp line 407 modified to become:

    PARDISOINIT_FUNC(PT_, &MTYPE_, IPARM_, &SOLVER, DPARM_, &ERROR);

Modifying IpPardisoSolverInterface.cpp and PardisoLoader.c has been enough to be able to run Ipopt, nonetheless, as I haven't tried all the possible Pardiso options, more might be needed.

Feel free to let me know, shall any of my modifications be incorrect.

Best regards, and Happy New Year 2015. Fab.

svigerske commented 5 years ago

Comment by @svigerske created at 2015-01-05 09:16:22

If you build Ipopt together with the MKL Pardiso, I don't understand why it then uses the PardisoLoader to load a Pardiso library dynamically at runtime.

From the changes you describe, I have the impression that there is some misunderstanding between IpPardisoSolverInterface and the PardisoLoader about which Pardiso interface version to use (pre-4.0/MKL or post-4.0). IpPardisoSolverInterface seems to assume an old interface, which I think can only happening when building against Pardiso, not just loading it dynamically. The PardisoLoader assumes to be called by IpPardisoSolverInterface via the new Pardiso interface routines, which then leads to the mismatch you see.

You might want to check your configure run and which preprocessor definitions are active (HAVE_PARDISO, HAVE_PARDISO_OLDINTERFACE, HAVE_PARDISO_MKL). You should have at least the first and last defined. However, Ipopt 3.11.x's configure doesn't support MKL Pardiso, so they need to be set by hand.

svigerske commented 5 years ago

Comment by @svigerske created at 2015-01-05 09:16:22

Changing assignee from ipopt-team to @svigerske.

svigerske commented 5 years ago

Comment by @svigerske created at 2015-01-05 09:16:22

Changing status from new to assigned.

svigerske commented 5 years ago

Comment by @tkelman created at 2015-01-18 08:20:31

I thought we added some auto-detection in https://projects.coin-or.org/Ipopt/ticket/216 ?

svigerske commented 5 years ago

Comment by @svigerske created at 2015-01-18 08:26:21

Replying to [comment:2 kelman]:

I thought we added some auto-detection in https://projects.coin-or.org/Ipopt/ticket/216 ?

That isn't enabled in the 3.11 buildsystem, as it would automatically change the default solver for users that use MKL and, e.g., Mumps.

svigerske commented 5 years ago

Comment by @svigerske created at 2015-02-08 02:33:41

No response from submitter, so closing ticket.

svigerske commented 5 years ago

Comment by @svigerske created at 2015-02-08 02:33:41

Resolution: invalid