MPI Parallel Environment setup under Windows Visual Studio 2012

Source: Internet
Author: User
Tags windows visual



because the course homework needs to write a parallel computing program, ready to write the MPI program, the full name of MPI is the message passing interface, the standard messaging interface, which can be used for parallel computing. The implementation of MPI is generally based on Mpich. The following describes how to build an MPI environment in Visual Studio 2012 under Windows 8 system to write an MPI program.





Installing the MPI Implementation Library





Mpich on the internet is given under Windows. You can see the link to Microsoft's official website, according to my version download and install the HPC Pack SDK. However, finding information on the Internet is all about MPICH2, so it is downloaded and installed, and is configured according to the content of the blog. As a result of this I wrote the Hello World program to run successfully, but the previous installation of two times this process has brought me a lot of trouble behind the work.


implementation of the first MPI program Create a new console program in Visual Studio 2012, configuring the Include and LIB paths for MPI. Open the application properties->VC directory to make the changes.




Add code:




 
#include "stdafx.h"
#include "mpi.h"
#include <stdio.h>
#include <math.h>
#pragma comment (lib, "msmpi.lib")

int _tmain(int argc, char* argv[])
{
	int myid, numprocs;
	int namelen;

	char processor_name[MPI_MAX_PROCESSOR_NAME];

	MPI_Init(&argc, &argv);
	MPI_Comm_rank(MPI_COMM_WORLD, &myid);
	MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
	MPI_Get_processor_name(processor_name, &namelen);

	fprintf(stderr, "Hello World! Process %d of %d on %s\n", myid, numprocs, processor_name);

	MPI_Finalize();
	return 0;
}
run to get:






Indicates that the program is running correctly. But from the program run to see only a process, not see the so-called parallel operation AH. Don't worry. The next section provides an introduction.


MPI Parallel Operations


Use the console command to invoke the Helloworld.exe program above to get the results of the parallel operation. Enter the command:



Mpiexec-n 4 Helloworld.exe



As a result, the following problem occurs:



Error:unable to read the CMD header on the PMI context, Error =-1



Daniel on StackOverflow that the problem was caused by the installation of two versions of MPI in the system, namely C:\Program Files\mpich2\bin and c:\program Files\ Microsoft HPC Pack 2012\bin.



Based on the above method, I uninstalled HPC Pack 2012 (because it was used all over the Mpich, so I uninstalled the Microsoft offer), rerun the command above, and there was a problem:



Please specify a authentication passphrase for SMPD:



The workaround provided on StackOverflow is to register using Wmpiregister , which is provided in reference 1, but still does not resolve the issue. Again uninstall and reinstall Mpich this time, direct prompt no mpiexec command. I guess Mpich is provided by a third-party library, and HPC Pack 2012 is Microsoft's own stuff, so you need to do some environmental configuration when using Mpich, and HPC Pack 2012 does not, so you uninstall the Mpich and install PC Pack 2012. This time to run the Mpiexec command unexpectedly succeeded! Get run 10 times results as follows:





As can be seen from the above results, the order of the system to invoke different threads is randomly determined by the system, and the end time of the thread cannot be determined.



A little thought: programming is not only a technical life is a physical activity, many times encountered a problem need to constantly go to Google to find solutions, but we usually encounter most of the problems are a lot of people have met, this process requires that we do not rush, careful to find the previous solution.


References:




    1. windows XP configuration mpich:http:// blog.csdn.net/morewindows/article/details/6823436
    2. error =-1 solution to the problem: http://stackoverflow.com/ Questions/10977026/mpi-runtime-errorunable-to-read-the-cmd-header-on-the-pmi-context-error-1
    3. authentication Problem Resolution:/HTTP STACKOVERFLOW.COM/QUESTIONS/13926882/PLEASE-SPECIFY-AN-AUTHENTICATION-PASSPHRASE-FOR-SMPD
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.