Mpich2 + Windows environment DIY

Source: Internet
Author: User

Now it is necessary to use this plug-in, not only in the cluster environment, the current CPU multi-core is quite common, you will ask if using mpich2 will improve efficiency?

Okay, I also want to know, from a built-in PI computing program in mpich2 (the point-setting method), how can I check whether the CPU efficiency is improved on my Intel Core (TM) 2 Duo CPU.

 

Okay, first find the mpich2 package, Google a mpich2, the first one is, huh, it indicates a very trendy http://www.mcs.anl.gov/research/projects/mpich2/

News & events

MPICH2-1.3.1 released (Nov. 17th, 2010)
A new release of mpich2, 1.3.1, is now available to download. this is primarily a bug-fix release. A few new features have also been added including complete support for the Ftb MPI events, improvements to RMA operations, and ability to modify collective algorithm selection thresholds using environment variables.

 

Well, it's the latest stable version. I found a Win32 version to download.

Installation:

First, open the attachment, find the command prompt icon, right click, and select Run as Administrator (Be sure to run as administrator ).

Run the msiexec command to uninstall or install the mpich2 package.

For example, The mpich2-1.2.1p1-win-ia32.msi file is placed under the root directory of the E disk

Msiexec/I E:/mpich2-1.2.1p1-win-ia32.msi so that you can complete the administrator permissions under the mpich2 installation, execute the installation process, only the default (PATH also do not change, so worry a lot) next step ,, ..

 

The Process Manager Service for mpich2 applications (smpd.exe) appears in the Windows Task Manager (in win7, you may need to select to display all user processes to see it ).

 

Next, open the example folder in the mpich2 package and find the ICPI. C program, as shown below (you can also copy the following program to save it ):

/*-Mode: C; C-Basic-offset: 4 ;-*-*/
/*
* (C) 2001 by Argonne National Laboratory.
* See copyright in top-level directory.
*/

/* This is an interactive version of CPI */
# Include <MPI. h>
# Include <stdio. h>
# Include <math. h>
# Pragma comment (Lib, "MPI. lib ")
Double F (double );

Double F (double)
{
Return (4.0/(1.0 + A * ));
}

Int main (INT argc, char * argv [])
{
Int done = 0, N, myid, numprocs, I;
Double pi25dt = 3.141592653589793238462643;
Double mypi, PI, H, sum, X;
Double startwtime = 0.0, endwtime;
Int namelen;
Char processor_name [mpi_max_processor_name];

Mpi_init (& argc, & argv );
Mpi_comm_size (mpi_comm_world, & numprocs );
Mpi_comm_rank (mpi_comm_world, & myid );
Mpi_get_processor_name (processor_name, & namelen );


Fprintf (stdout, "process % d of % d is on % s/n ",
Myid, numprocs, processor_name );
Fflush (stdout );

While (! Done ){
If (myid = 0 ){
Fprintf (stdout, "Enter the number of intervals: (0 quits )");
Fflush (stdout );
If (scanf ("% d", & N )! = 1 ){
Fprintf (stdout, "No number entered; quitting/N ");
N = 0;
}
Startwtime = mpi_wtime ();
}
Mpi_bcast (& N, 1, mpi_int, 0, mpi_comm_world );
If (n = 0)
Done = 1;
Else {
H = 1.0/(double) N;
Sums = 0.0;
For (I = myid + 1; I <= N; I + = numprocs ){
X = H * (double) I-0.5 );
Sum + = f (x );
}
Mypi = H * sum;
Mpi_reduce (& mypi, & Pi, 1, mpi_double, mpi_sum, 0, mpi_comm_world );

If (myid = 0 ){
Printf ("Pi is approximately %. 16f, error is %. 16f/N ",
Pi, FABS (Pi-pi25dt ));
Endwtime = mpi_wtime ();
Printf ("wall clock time = % F/N", endwtime-startwtime );
Fflush (stdout );
}
}
}
Mpi_finalize ();
Return 0;
}

Compilation (the essence is to use the cl.exe compilation of vsseries (it is obvious that the assembler can be compiled cross). Therefore, you can use the common vs ide compiling environment. Of course, you must include the mpich2 package, I have extracted some of the following for VC ++ 6.0, or I can ):

@ Echo off
Set include = D:/program files/mpich2/include; D:/vcpack/mfc/include
Set Lib = D:/program files/mpich2/LIB; D:/vcpack/mfc/lib
Set Path = D:/program files/mpich2/bin; D:/vcpack/bin; % PATH %

 

Echo --------------- ======= by goldenspider 2010-11-27 ======= -------------------
Echo on

CL/C/O2 pi. c

Link/libpath: "D:/program files/mpich2/lib" Pi. obj mpi. Lib

Del *. OBJ

Pause

Mpiexec-N 2 pi.exe

 

Save it as a bat file and run it.

It should be noted that the first time the program runs, the program will ask you to output the user name and password (that is, use the user name and password for power-on (prompt, very understandable ))

Mpiexec-N 2 pi.exe can be run on multiple cores. If pi.exe is opened directly, only one process is available. It is recommended that you do not use commands with more than the number of cores.

For example, if mpiexec-N 2 pi.exe is used for dual-core, mpiexec-N 4 pi.exe is better, while mpiexec-N 8 pi.exe is not necessarily efficient.

 

The running effect is as follows:

The dual-process concurrency is as follows (Be sure to run it under the administrator privilege ):

 

 

Directly double-click pi.exe, and a single process is run, as shown below:

 

 

 

It can be seen that the same program runs in dual-process mode, reducing the number of times !!!!, Good, huh ..........

 

 

 

 

 

 

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.