none
Window Messaging with MPI RRS feed

  • Question

  • Hi, all.

    I have an MFC program that involves dialog interfaces, with dialog windows started with DoModal() command. Now I am going to run it in a cluster, with 2 PCs, both installed with HPC manager under Windows Server 2008 R2.

    During program running, I need to enter into deep dialog levels, such that corresponding variables related to the dialog inside can be modified. My target is to modify that variable at both PCs with dialog control of 1 PC. With HPC_ATTACHTOSESSION set to true, I am able to see the enter information into the fields of the dialog of the first PC, and press buttons of the first PC to change the variable value of the program in the first PC.

    At the same time, although the dialog interface of the 2nd PC is not displaying, I still need the program of the 2nd PC to enter to run the code of the dialog class. What I am thinking is that, when I press a button on the dialog of the first PC, a window message (just like ::PostMessage command in MFC program) is sent into the second PC to trigger the  something like 'ONCOMMAND' instruction, such that the key handling routine of the 2nd PC is being run.

    In MPI messaging, MPI_Send and MPI_Recv only sends data between the 2 PCs. Is it possible for us to use MPI commands to pass window messages between different threads?

    Thanks.

    Regards, Simon


    Wednesday, March 23, 2016 6:13 AM

Answers

  • Hi Simon,

    Yes it should be possible to use MPI commands to pass information between the processes. You need to use mpiexec to launch the program so that the processes would get launched properly.

    However, can you describe what your program is trying to accomplish? If your program needs frequent communication it is definitely a good case for using MPI. If you are only needing to pass some initial values to other instances of the program it might make sense to have multiple tasks and use task dependency to handle the capture and parsing of the required value, and then provide the value to the actual program.

    Anh

    • Marked as answer by Simon Tong Tuesday, March 29, 2016 7:36 AM
    Monday, March 28, 2016 6:09 PM
  • Simon,

    There are several ways to approach this:

    1) One option is to run a program A that captures the user input then generate a job with two tasks. Since you know the user input you can pass the user input through either the task command line, or you can pass it through task environment variables. After the two tasks finish you can parse the output and provide the results to the user?

    2) Another option would be to use MPI as you intended to and make sure that only rank 0 is asking for user input, and then rank 0 would send the input to rank 1. The program would look something like this. Let me know if you have questions about this

    int rank;

    MPI_Init( &argc, &argv );

    MPI_Comm_rank( MPI_COMM_WORLD, &rank );

    if( rank == 0 )

    {

         // Code to popup dialog and capture user input

        CollectUserInput();

        MPI_Send( send input to rank_1 );

    }

    else if ( rank == 1)

    {

        MPI_Recv (receive input from rank 0);

    }

        // Now each rank does its own part of the calculation;
        DoIt();

    if( rank == 0 )

    {

       // Receive result from rank 1

       MPI_Recv(...);

        // Now that I've received result from other ranks, process it and give result back to user

        ProcessAndDisplayResult();

    }

    else if ( rank == 1 )

    {

        // Send result to rank 0

        MPI_Send(...)

    }

    MPI_Finalize();

    • Marked as answer by Simon Tong Wednesday, March 30, 2016 5:30 AM
    Tuesday, March 29, 2016 11:28 PM

All replies

  • Hi Simon,

    Yes it should be possible to use MPI commands to pass information between the processes. You need to use mpiexec to launch the program so that the processes would get launched properly.

    However, can you describe what your program is trying to accomplish? If your program needs frequent communication it is definitely a good case for using MPI. If you are only needing to pass some initial values to other instances of the program it might make sense to have multiple tasks and use task dependency to handle the capture and parsing of the required value, and then provide the value to the actual program.

    Anh

    • Marked as answer by Simon Tong Tuesday, March 29, 2016 7:36 AM
    Monday, March 28, 2016 6:09 PM
  • Hi, Anh.

    My original program is an MFC application, that uses dialogs and contains some fields for user to enter values. After the program received the user input values in the dialog fields, it will do calculation based on values received in dialog field and then display calculated results.

    Original application uses a single computer. Now I would like to increase the processing speed and use 2 computers (HEADNODE and NODE01) together to do the calculation, with each computer doing a part of the calculation. As the application itself is complicated, I want to maintain its original dialog structure such that

    1) Only one computer will be used for displaying the dialog, receiving user input in dialog and display calculated results. To achieve this, When I use HPC Manager to run the program, I set the environmental variable HPC_ATTACHTOSESSION to True in the HEADNODE computer such the the dialog of the first computer will be displayed for user input.

    2) Both computer will run the same program and the program contains some dialog opening command like DoModal(), the dialog of the 2nd computer won't be displayed. I would like to program of the 2nd computer, also need to run DoModal() and then run the codes of the Dialog class. 

    3) At the moment, when user enter values in the Dialog of the 1st computer, according to the way that Windows operates, the 1st computer will receive window message and run commands like OnMessage() to process variable change. In order to make the 2nd computer to run the OnMessage() command at the same time, the 1st computer need to send a message to the 2nd computer, such that the 2nd computer program receive the window message and process the change

    My question is, how to use MPI message for the 1st computer to trigger the 2nd computer to receive a window message?

    Thanks.

    Regards, Simon 


    • Edited by Simon Tong Tuesday, March 29, 2016 7:12 AM
    Tuesday, March 29, 2016 7:10 AM
  • Hi, Anh,

    On the other hand, seems to me that your suggestion is 

    1) Run the dialog interface with one task at one computer.

    2) Trigger two computers to do the calculation together (the second task) after finishing entering the data in dialog. 

    Here, two programs will be involved with different number of cores being run. Not quite sure what tools should I use to accomplish this, could you inform me links and documentation about that?

    Thanks.

    Regards, Simon

    Tuesday, March 29, 2016 7:23 AM
  • Hi, Anh,

    About task dependency, I can see that within the New Job window, there's a button called 'Dependency', in which, I think that I can enter different task in order, with each task being run with different number of cores and PC.

    In this way, to trigger the running of the 2nd task, my first task program must end. 

    I would need, however, to trigger the 2nd task with a dialog button at the 1st task.

    Seems to me that I can't divide the job into two task such that using the dependency list seems not adequate to fulfill my task. 

    May need to use the MPI method I'm thinking before or some other methods.  

    Appreciate much of your help to look at this and suggest.

    Thanks.

    Regards, Simon

    Tuesday, March 29, 2016 8:03 AM
  • Simon,

    There are several ways to approach this:

    1) One option is to run a program A that captures the user input then generate a job with two tasks. Since you know the user input you can pass the user input through either the task command line, or you can pass it through task environment variables. After the two tasks finish you can parse the output and provide the results to the user?

    2) Another option would be to use MPI as you intended to and make sure that only rank 0 is asking for user input, and then rank 0 would send the input to rank 1. The program would look something like this. Let me know if you have questions about this

    int rank;

    MPI_Init( &argc, &argv );

    MPI_Comm_rank( MPI_COMM_WORLD, &rank );

    if( rank == 0 )

    {

         // Code to popup dialog and capture user input

        CollectUserInput();

        MPI_Send( send input to rank_1 );

    }

    else if ( rank == 1)

    {

        MPI_Recv (receive input from rank 0);

    }

        // Now each rank does its own part of the calculation;
        DoIt();

    if( rank == 0 )

    {

       // Receive result from rank 1

       MPI_Recv(...);

        // Now that I've received result from other ranks, process it and give result back to user

        ProcessAndDisplayResult();

    }

    else if ( rank == 1 )

    {

        // Send result to rank 0

        MPI_Send(...)

    }

    MPI_Finalize();

    • Marked as answer by Simon Tong Wednesday, March 30, 2016 5:30 AM
    Tuesday, March 29, 2016 11:28 PM