The Great and Terrible implementation of MPI-2
DeinoMPI is an implementation of the MPI-2 standard for Microsoft Windows originally derived from the MPICH2 distribution from Argonne National Laboratory.
System requirements:
Windows 2000/XP/Server/Vista/7
.NET Framework 2.0
Download DeinoMPI.msi and run it on each machine in your cluster. The installation process is identical on all machines and you must be an administrator to install Deino MPI on a machine. In addition to the software libraries and tools a process manager is installed as a Windows service. This action requires administrator privileges. Once the package is installed on the machines all users can use DeinoMPI even if they don’t have administrator privileges.
Note on Windows Vista/7:
Currently on a Windows Vista or Windows 7 machine the installer cannot start the Deino Process Manger service because the installer runs commands with limited privileges even when the user has Administrator privileges. So this means that you have to go to the Services management console after installing DeinoMPI and start the DeinoMPI Process Manager service on each node before Deino MPI jobs can be run (or you can reboot the machines and the service will start automatically). The management console can be started by right-clicking Computer from the Start menu and selecting “manage”. Navigate to the DeinoPM service, right-click and select Start.
After you install the software on all the machines each user will need to create a Credential store. This store will be used to securely launch jobs. Mpiexec will not run a job without a Credential Store and the GUI tool will prompt the user to create a store the first time it is run. Users can use the DeinoMPIwin tool to create a Credential store or they can use the command line tool, create_credential_store.exe, to create the store.
By default all users have access to all machines where DeinoMPI is installed and can launch jobs on any machines where they have user accounts. If you want to restrict user access to machines you can use the manage_public_keys.exe command line tool. Have an administrator run the following two commands on each machine that you want restricted access to:
1) manage_public_keys.exe /auto_keys false
2) manage_public_keys.exe /clear_all
At this point no users will have access to the machines. Then the administrator can add users one by one using the public key from each user’s Credential store. Have each user export their public key from their Credential store using the GUI tool or the manage_public_keys.exe command line tool. The command line would be something like this:
manage_public_keys.exe /export mypubkey.txt
Then send this file to or point the administrator to this file. The administrator can add access to the user using the following command:
manage_public_keys.exe /import mypubkey.txt
This command is local to a machine and must be executed by a user with administrator privileges on the machine. Since the command is local it must be executed on each machine in the cluster that you want the user to have access to. Once the user’s public key has been imported on one or more machines in the cluster then the user can use mpiexec or the GUI tool to launch jobs on those machines.
The following tools are installed:
All communication used during process startup and management is encrypted. The public and private keys in each user’s Credential store are used to establish secure connections between machines in the cluster. The keys are used to encrypt a session key which is then used to encrypt and decrypt session data. The private keys currently are 2048 bit and the session encryption uses the Rijndael (AES) algorithm.
The following sub-directories are created in the location you choose to install DeinoMPI: bin, include, lib, examples and java. The bin directory contains the executable files mpiexec.exe and DeinoPM.exe and Jumpshot.jar and the command line tools. The include directory contains the header files required to compile MPI applications. The lib directory contains the libraries required to link MPI applications. The examples directory contains pre-compiled example applications and source code for each. Read the examples.pdf file for a description of all the examples. The java directory contains the manual for the Jumpshot log viewing application. The dlls used to implement DeinoMPI are installed in the Windows system directory. Two assemblies used are installed in the GAC (Global Assembly Cache), DeinoMPI.dll and DeinoLP.dll.
Compile your MPI applications using the following information. Set your include path to include the DeinoMPI\include directory. Set your library path to include the DeinoMPI\lib directory. Link your C applications with mpi.lib from the lib directory. Link C++ applications with the cxx.lib and mpi.lib libraries. Link Fortran applications with DeinoFMPI.lib.
There are several versions of the Fortran link libraries to support common name mangling and calling conventions used by various Fortran compilers. The following libraries contain the specified formats:
· DeinoFMPI.lib – MPI_INIT and mpi_init_. All capital external names and all lower case external names with a trailing underscore. Functions use the C calling convention. There is a Unicode version of this library also – DeinoFMPIu.lib. The Intel compiler uses this format as of the 8.x series. The Portland Group compiler uses the lower case format.
· DeinoFMPIs.lib – MPI_INIT@4. All capital external names. Functions use the stdcall calling convention. Visual Fortran 6.x uses this format.
· DeinoFMPIg.lib – mpi_init__. All lower case external names with two trailing underscores. Functions use the C calling convention. g77 uses this format.
For examples using specific compilers see the companion DeinoMPI compilers document.
You can use the graphical DeinoMPIwin.exe or mpiexec.exe from the command line to start MPI jobs.
This multi-purpose tool can be used to start MPI jobs, manage the user’s Credential Store, search the local network for machines with DeinoMPI installed, verify the mpiexec inputs to diagnose common job problems, and view the DeinoMPI web page for information such as help pages on all the MPI functions.
The main page is used to start and interact with MPI jobs.
The mpiexec tab contains the following sections:
The Credential Store tab is used to manage the current user’s Credential Store.
If you do not have a Credential Store created then select the “enable create store options” check box and more options will be available. These options are hidden by the check box because they are usually only needed once by the current user the first time DeinoMPI is run.
Click the “enable create store options” check box to enable the creation fields
Select your choice from the three sections and then click Create Credential Store
The three sections are
Recommendations:
If you want the highest security option it is recommended that you select a password, the Windows ProtectData API and save the store to a removable USB thumb drive. Click the green High Security label to automatically select these settings.
If you want high security and convenience it is recommended that you select no password, the Windows ProtectData API and save the store to the Windows Registry. Click the yellow Secure and Convenient label to automatically select these settings.
Once you have created a Credential store you can use the rest of the fields in the Credential store tab to manage the store. You can add and remove user names and passwords from the store using the Add and Remove buttons.
If your store is password protected then you will need to enter the password into the password box and click login before you will have access to the store.
You can change the location of your Credential store using the location section. This is useful if you have created multiple stores. For example you may want to switch between a store saved to the Windows Registry and another store saved on a USB thumb drive.
The Keys section shows the hash of the public key in your store. You can export the public key to a file by clicking the export button. This file can then be imported into the PublicKey store on other machines in your cluster. This is required if you select the option to deny unknown public keys when connecting to machines in your cluster. The default behavior is to automatically distribute public keys when connecting to machines for the first time. If you disable the automatic option then you will need to import the public key of each user that is allowed to run jobs on a machine. Public keys can be imported into the local PublicKey store on each machine by an administrator using the manage_public_keys.exe command line tool.
You can also change the public and private keys in your store. Since this is an uncommon option it is protected by two clicks. First select the enable create check box to enable the button to create new keys. Then click the Create New Keys button and the keys will be replaced in your store with new ones. This option is provided in case your keys are compromised for some reason. You may also have security requirements that require you to change the keys at certain intervals. How you decide to manage your keys and Credential stores is up to you.
The cluster tab is used to view the machines on your local network and see what version of DeinoMPI you have installed.
The cluster tab contains the following items:
The Verify Job tab is a diagnostic tool to check to make sure the information provided in the Mpiexec tab describes a valid job that will run on your cluster. It does not run the job but it parses all the information, contacts the hosts and verifies that the job will be able to run. It can find the following problems with a job:
When you click the Verify button the information in the Mpiexec tab is parsed as if the job were to be run and then the hosts are contacted and information is collected. The results for each process in the job are provided in a list with the last entry used to display all the information for all processes. The processes are color coded to quickly ascertain the results. Green processes will run without any problems. Red processes will not run due to one of the problems mentioned in the above bulleted list. Yellow processes will probably run but have warnings. For example if a working directory does not exist on a host a warning will be displayed but the process will still run. If a delay loaded dll dependency is detected in the executable and that dll is not found on a host then a warning is displayed because the process may fail at runtime. This is a warning and not an error because many applications have libraries that load dlls based on the capabilities of the system they run on and do not fail when a dll is missing.
There are some problems that can cause a job to fail when run that the Verify Job tab is not able to check. If the process explicitly loads a dll by name using the LoadLibrary function call and this dll does not exist this error will not be detected. If the application tries to open a file that does not exist on a host this error will not be detected. If there is a fault in the application that causes it to crash or if the architecture doesn’t match these errors will not be detected. There may be other run-time errors that can occur that this tool does not detect. It is provided as a tool to diagnose the most common errors that can be detected without running the job.
If the “Use directory staging” check box from the Mpiexec tab is selected a warning is displayed under the Verify button. If directory staging is selected then there may be files required by the job that will be copied out to the nodes before the job starts. The verify command does not copy any files so it may display errors even though the job may run just fine after the directories are copied to the nodes.
The last tab is the web tab and it shows the web page for DeinoMPI. You must be connected to the internet to view this tab.
This command line tool can be used to start MPI jobs.
mpiexec -n <maxprocs> [options] executable [args ...]
mpiexec [options] executable [args ...] : [options] exe [args] : ...
mpiexec -configfile <configfile>
mpiexec -n 4 cpi
mpiexec -n 1 -host foo master : -n 8 worker
-n <maxprocs>
-wdir <working directory>
-configfile <filename> -
each line contains a complete set of mpiexec options including the executable and arguments
-host <hostname>
-path <search path for executable, ; separated>
-n x
-np x
Launch x processes.
-localonly x
-n x -localonly
Launch x processes on the local machine.
-machinefile filename
Use a file to list the names of machines to launch on. Each line in the file should contain one host name. Lines beginning with # are ignored. If you want multiple processes to be deposited on a single host you can add a colon and a number to the host name like this: hostA:4
-host hostname
-hosts n host1 host2 ... hostn
-hosts n host1 m1 host2 m2 ... hostn mn
Launch on the specified hosts.
In the second version the number of processes = m1 + m2 + ... + mn.
Example: mpiexec –hosts 3 hostA hostB 2 hostC myapp.exe
The example would produce 4 processes, 1 on hostA, 2 on hostB and 1 on hostC.
-map drive:\\host\share
Map a drive on all the nodes. This mapping will be removed when the processes exit. Example: mpiexec –map z:\\myserver\myhome –n 4 z:\myapp.exe
-dir drive:\my\working\directory
-wdir drive:\my\working\directory
Launch processes in the specified directory. –wdir and –dir are synonyms.
Example: mpiexec –dir c:\temp –n 4 myapp.exe
-env var val
Set environment variable before launching the processes.
Example: mpiexec –env VERBOSE 1 –n 4 myapp.exe
-logon
Prompt for user account and password.
-pwdfile filename
Read the account and password from the file specified. Put the account on the first line and the password on the second.
-user <user name>
Select the username to be used from the Credential store. With this option you can specify different users for different hosts. This is useful if you have different user accounts and passwords for different machines. The user name must match an account saved in the current user’s Credential store. If you have the same user name on different machines but different passwords you will have to specify the machine name in the user account name like this: hostA\userA and hostB\userA.
Example: mpiexec –user joe –host Foo –n 2 myapp.exe : -user john –host Bar –n 3 myapp.exe
-exitcodes
Print the process exit codes when each process exits.
-noprompt
Prevent mpiexec from prompting for user credentials.
-priority class[:level]
Set the process startup priority class and optionally level.
class = 0,1,2,3,4 = idle, below, normal, above, high
level = 0,1,2,3,4,5 = idle, lowest, below, normal, above, highest
The default is -priority 2:3.
-localroot
Launch the root process directly from mpiexec if the host is local. (This allows the root process to create windows and be debugged.)
-path search_path
Search path for executable. Separate paths with the ; character.
Example: mpiexec –path c:\bin;c:\temp –n 4 myapp.exe
-timeout seconds
Specify a timeout for the job in seconds. If the job takes longer than the specified number of seconds mpiexec will kill the processes.
Example: mpiexec –timeout 180 –n 4 myapp.exe
-set_hosts hostA hostB:N hostC ...
Set the default hosts and optionally the number of processes per host. If you want to specify the number of processes to be deposited on a host put a colon at the end of the host name and then put the number, like this: foo.host.com:2. This is useful for multi-CPU machines where you want processes deposited on hosts one per CPU.
-set_myhosts hostA hostB:N hostC …
Set the default hosts for the current user only. Use the same format as the –set_hosts option.
-log
Use the MPE logging library to log the MPI job. A clog2 file is produced after the job finishes which can be converted and viewed using Jumpshot (requires Java to be installed on the host).
-validate
Validate that the job can run without actually starting the job. Add this flag along with all the rest of the mpiexec command line. The hosts are contacted to determine if the job can run but executables are not started.
Example: mpiexec –validate –n 4 cpi.exe
-stage path
Specify the source directory you want to copy out to all the nodes before the job is started.
Example: -stage c:\data\myjob or -stage \\myserver\myshare\data
-stage_dest path
Specify the destination directory where you want the staged directory to be copied to. If this option is not specified then the source directory is used as the destination.
Example: mpiexec -stage \\myserver\myshare\data -stage_dest c:\temp\data ...
-stage_recursive
Specify this flag to indicate that you want the source directory to be copied and all of its sub-directories also.
-stage_wildcards pattern
Specify a wild-card pattern to limit which files are copied out to the worker nodes when staging a directory. Only files that match this pattern will be copied.
Example: mpiexec -stage_wildcards *.txt -stage c:\temp\data …
-stage_nopull
Specify this flag to indicate that you do not want any modified files copied back to the source directory after the job has finished. The default behavior is for new or modified files in the staging destination directory to be copied back to the source directory after the job has completed. This flag overrides that option.
-version [hostname]
Print the version of DeinoMPI installed on the specified machine. If no host is specified then print the version installed on the local machine.
Debugging parallel applications is hard but there are a few options provided by DeinoMPI that can help.
1) This simplest and sometimes most effective way to debug MPI applications is to add printf statements to your code. Whenever you add a printf statement, make sure to add a call to fflush(stdout); after the printf statement or statements. It is important to do so because the output of applications is buffered by default and must be flushed if you want to see the output immediately. This is true for stderr also because unlike on UNIX systems stderr is buffered on Windows machines.
2) The DeinoMPIwin.exe GUI tool has a Show Messages button that can provide useful information.
First, the Show Messages button will display the current state of the internal MPI message queues. This can be useful if your application hangs and you are not sure why. You can click the Show Messages button and see what messages are in the internal message queues for each process. Two message types can show up. There can be posted messages where a process is expecting a message but has not received it yet. And there can be messages that have been received and buffered but not matched yet. Note: some messages may not correspond directly to user code MPI calls since the implementation uses internal messages to implement the collective, file and win MPI functions. But it is easy to understand these messages because they are marked with type information.
Second, the Show Messages button will display the MPI function call history for each process if you have specified the DeinoMPI_USE_CALL_HISTORY environment variable. With this option turned on each MPI function call is logged to an internal ring buffer. When you click the Show Messages button the last N calls will be printed out for each process. The default is to save 32 calls per process but this can be reduced using the environment variable, DeinoMPI_CALL_HISTORY_SIZE. Set this value to a number between 1 and 32 to limit the depth of MPI calls per process saved.
3) Jumpshot is a java tool that can be used to profile applications. It is limited in its debugging ability though because applications must run to completion in order to generate log files. The primary goal of Jumpshot is to view the runtime patterns of an MPI application and then analyze these patterns to see if changes can be made to the code to optimize the application. Jumpshot has very well developed tool options for this kind of work. See the Jumpshot manual for information.
There are at least two ways you can use a debugger to step through your parallel processes. These methods have been tested using the Visual Studio debugger but may also work with other debuggers.
1) Use a debugger to attach to the running processes. If your application has a natural wait state then you can simply attach the debugger when the processes are idle. Otherwise you can add code to the beginning of your application to cause it to wait. For example: you could create a local variable, set it to true and add a while (local_variable) { Sleep(100); } statement. When you start the application using mpiexec.exe all the processes will be stuck in this infinite loop. Use the debugger to attach to the processes and set the local_variable value to false. Then you will be able to step through the process. You could also make this Sleep block depend on a command line parameter so that you can attach to a specific process instead of all of the processes. Depending on the user privileges you may get Access Denied errors when trying to attach to processes started by mpiexec.exe because the processes are started by the DeinoPM service. If this is the case you can use the –localonly flag to start the processes: “mpiexec.exe -localonly …”. This will start the processes directly from the current user’s environment.
2) A second method is to start each process by hand. You will set up the environment for each process and start the debugger for each process. In order to debug processes directly without attaching to running processes you will need to set up the environment variables for each process. You can set the environment variables, start the debugger and then step through the process. When you start a job this way the dynamic process functions like MPI_Comm_spawn will not be available. The smallest set of variables required to be set are: PMI_ROOT_HOST, PMI_ROOT_PORT, PMI_ROOT_LOCAL, PMI_RANK, PMI_SIZE, PMI_KVS, PMI_WDLL_NAME. Here is a batch file that can be run to set the variables for each process:
· if "%1" == "" goto HELP
· if "%2" == "" goto HELP
· set PMI_ROOT_HOST=%COMPUTERNAME%
· set PMI_ROOT_PORT=9222
· set PMI_ROOT_LOCAL=1
· set PMI_RANK=%1
· set PMI_SIZE=%2
· set PMI_KVS=deinompi
· set PMI_WDLL_NAME=none
· goto DONE
· :HELP
· REM usage: setmpi2 rank size
· :DONE
Save this text as setmpi2.bat and then use it as follows. Bring up a command prompt for each process in the job. Let’s assume you are starting a two process job. Bring up two command prompts and execute the following in the first one: “setmpi2.bat 0 2”. Then execute this in the second one: “setmpi2.bat 1 2”. The first prompt will be rank 0 in a job of size 2. The second prompt will be rank 1 of size 2. Then from the each command prompt execute: “devenv.exe myapp.exe”. Substitute the name of your application for myapp.exe. Devenv.exe is probably located at C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe. At this point you will have two debuggers open. Now you can step through each process independently using the two debugger windows. There is one requirement to stepping through the processes. You must step over MPI_Init in the root process, process 0, first before calling MPI_Init from the other processes. Also you can restart the processes from within the debuggers but you have to restart all of them and make sure process 0 calls MPI_Init first.
The setmpi2.bat script assumes that the job will run on a single host. If you want to run on multiple machines you will need to change the PMI_ROOT_HOST environment variable to be the name of the host where process 0 is started. For example: on the second host you could execute “setmpi2.bat 1 2” and then “set PMI_ROOT_HOST=first_host_name”.
The following command line tools are provided to support DeinoMPI. create_credential_store.exe and manage_credentials.exe provide command line options equivalent to those found in the GUI DeinoMPIwin.exe tool. manage_public_keys.exe is an administrative tool that provides additional functionality not replicated in the GUI tool.
This tool creates a Credential store for the current user. It can be run in interactive mode, with a response file, or use defaults.
Run create_credential_store.exe with no parameters and it will prompt you for the information necessary to create a store.
Run create_credential_store.exe with a filename as the first parameter and it will use the data in the specified file to create a credential store. The response file has three lines in it.
1) The first line is the password. Leave this line blank if you don’t want the store password protected.
2) The second line specifies which type of encryption to use. Specify ‘protect’, ‘symmetric’, or ‘none’.
3) The third line contains the path to the location where you want the store saved or the keyword ‘registry’ to save it in the current user’s registry hive.
Example response file:
foobar
protect
C:\me\mydata
Run create_credential_store.exe –default to create a credential store with the default settings. The defaults are no password, protect, and registry.
This tool manages user credentials stored in the current user’s Credential store. Run it with no parameters and it will output a usage message briefly explaining the options.
This tool manages the Credential store public keys for the current user and the current machine. Some options to this tool require administrator privileges to execute. Run it with no parameters and it will output a usage message briefly explaining the options.
User level options:
Administrator level options:
Send bug reports and other correspondence to support@deino.net