Results 1 to 11 of 11

Thread: Qprocess and mpi not finishing

  1. #1
    Join Date
    Mar 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qprocess and mpi not finishing

    I know this may be more of an mpi question but i'm wondering if this type of behaviour has been seen anywhere else. mpiexec.exe launches several child processes and monitors them. Once the child processes all finish, normal behaviour for mpiexec is to finish and exit.

    If i use a QProcess to start mpiexec.exe in attached mode (QProcess->start()), mpiexec.exe will never finish and stays in my task manager evern after all of it's child processes have completed and exited properly. The QProcess state goes into Qprocess::Running and stays there. The Qprocess emits the started and stateChanged signals (and all of the read signals) but never emits the finished signal.

    So essentially everything goes properly except that mpiexec.exe will not actually 'finish' and close.

    If i launch mpiexec.exe in detached mode (QProcess->startDetached()) or if i run mpiexec from the command line it will finish and exit properly.

    Does anyone have any ideas on this? I need to monitor when the process finishes (either by the finsihed slot or peridically calling state) so i need to use the attached start() mode.

    EDIT: I should mention that starting, stopping, reading from, writing to, and everything else to do with QProcesses works for me as long as i'm not launching mpiexec.exe. Any other 'normal' executable works fine. I know this is MPI related but i was hoping someone has seen this behaviour and has an idea.

    Using Windows. QT 4.3
    Last edited by Spifffers; 19th March 2009 at 16:16.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qprocess and mpi not finishing

    I would say this is caused by mpiexec. Maybe it detects it is a slave to other process and waits for you to send it some signal.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qprocess and mpi not finishing

    I think MPI's signal handling is hijacking QProcess signal handling so that QProcess loses its connection to the system. Check MPI's document about the signal handling and see if you can find something there.

  4. #4
    Join Date
    Mar 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qprocess and mpi not finishing

    Thanks for the opinions.

    Sounds more like QT signals are somehow hijacking the mpi functionality. Since qt is still monitoring the process. IF i manually kill mpiexec, the QProcess does send the finished() signal.

    mpiexec must monitor how many other things are 'connected' to it and only exit once all of them disconnect. Usually only it's own children are connected. Since the QProcesses maintains a connection, it always thinks it needs to stay alive and therefore never exits. Darn.

    I'll look into MPI documentation.

  5. #5
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qprocess and mpi not finishing

    Quote Originally Posted by Spifffers View Post
    Thanks for the opinions.

    Sounds more like QT signals are somehow hijacking the mpi functionality. Since qt is still monitoring the process. IF i manually kill mpiexec, the QProcess does send the finished() signal.

    mpiexec must monitor how many other things are 'connected' to it and only exit once all of them disconnect. Usually only it's own children are connected. Since the QProcesses maintains a connection, it always thinks it needs to stay alive and therefore never exits. Darn.

    I'll look into MPI documentation.
    When there are two processes in the program trying to handle same signals, you won't know how they would interfere with one another.

    But how can QProcess submit a job to a different node? I thought QProcess can only launch a program in the local node... If your MPI requires more CPUS or ranks than your machine has, it would fail, I think...

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qprocess and mpi not finishing

    Quote Originally Posted by Spifffers View Post
    Sounds more like QT signals are somehow hijacking the mpi functionality.
    This is very unlikely. A parent process can't intercept its child's signals. Especially that QProcess is cross-platform so it is very unlikely it uses unix signals at all.

    IF i manually kill mpiexec, the QProcess does send the finished() signal.
    This also suggests mpiexec just doesn't want to die on its own. If Qt hijacked its signals, it would also have hijacked the one you had sent.

    Since the QProcesses maintains a connection, it always thinks it needs to stay alive and therefore never exits.
    No, because if that was true, mpiexec would never die when ran from a terminal as the shell maintains a similar connection to its file descriptors as Qt does. It's the parent process that creates descriptors for its child before calling execve() or equivalent and it usually "attaches" those descriptors to itself. mpiexec must be detecting it's not the owner of its own process group and doesn't terminate. It probably sends some signal to the group leader, at least that could be the case on Unix. I don't know how processes are groupped in Windows.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7

    Default Re: Qprocess and mpi not finishing

    Currently I'm facing the same problem with mpiexec, did you found a solution for this problem then?

  8. #8
    Join Date
    Jan 2014
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Qprocess and mpi not finishing

    Exactly the same problem : still no solution (6 years after !)

    Working with Qt 4.8, Windows

  9. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qprocess and mpi not finishing

    Rather than post "Me too!" Perhaps you could put some effort in to write a small, self-contained example that demonstrates the problem. The problem almost certainly has nothing to do with Qt but you never know what the process of distilling and sharing the problem might show you.

    You could also capture any standard output/error output from mpiexec, which I am sure could be useful in conjunction with other MPI log.

    BTW: Mar 2009 to Jan 2014 is a long way short of 6 years.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  10. #10
    Join Date
    Jan 2014
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Qprocess and mpi not finishing

    Ok i was a bit frustrated ... and you are right 2009 to 2014 is a bit less than 6 years !

    The solution i found is to use the command "system" rather than qprocess

    My first idea was to use QProcess like this :
    QProcess process;
    process.setWorkingDirectory( "xxxx" );
    process.setProcessChannelMode(QProcess::MergedChan nels);
    process.setStandardOutputFile("logfile");
    process.start(commandProcess,argumentsProcess);
    process.waitForFinished(-1);

    But as i mentionned, the qprocess never sends a finish signal (why, this is the question and that's maybe mpiexec problem ??)

    Solution i did is (using command system) :
    QString command = commandProcess+" "+argumentsProcess.join(" ")+ " > "+logProcessFilePath;
    command = QDir::toNativeSeparators(command);
    command.replace(":\\",":\\\\");
    int returnCode = system(command.toStdString().c_str());

  11. #11
    Join Date
    Apr 2016
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Qprocess and mpi not finishing

    I am sorry to post in a very old thread, but I figured that it might help others looking for an answer in a search engine...

    I just had the very same problem, which might be due to this bug, at least according to my research.
    According to that message, OpenMPI is catching the SIGCHLD signal, which is necessary for QProcess "finished" signal to work correctly (and thus for QProcess::waitForFinished()).

    The message says that this was changed in OpenMPI series 1.6 and 1.7.
    As of today, the latest Ubuntu 15.10 ships with OpenMPI 1.6.5, which apparently is still affected by this (mis-)behaviour.

    Upgrading to a later OpenMPI version should therefore fix the problem.
    I did this by installing OpenMPI 1.10.2 from source, which is very easily done by following these instructions, and I can confirm that the problem is solved.

    Hope this helps...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.