MPI program example under the VC.NET platform

xiaoxiao2021-03-06  43

Write an MPI example program, under the VC.NET platform.

Several first: in engineering properties 1. Additional included in the catalog, include the MPICH SDK's include path, such as "E: / Program Files / MPICH / SDK / INCLUDE" 2. Add the library of MPICH SDK in the attached library, such as " E: / Program Files / MPICH / SDK / LIB "3. Debug | Command plus mpirun.exe, mainly for the convenience of running, don't forget to add" -np 4 $ (targetPath) "on the command parameter 4. The environment variable of my computer properties increases the execution path of MPICH BIN, such as "E: / Progra ~ 1 / MPICH / MPD / BIN"

Built an empty console program, configure it above, you can use the following code segment.

#include #include #include #include #pragma Comment (lib, "mpichd.lib") int Main (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 (); if (MyID == 0) {Printf (" / NPRESS A KEY AND EXIT./N); Getch ();} return 0;

These are the lectures of Chi Xue Bin, Mozu, etc., such as the next day.

It feels good.

转载请注明原文地址:https://www.9cbs.com/read-55867.html

New Post(0)