
Tutorial
This is a step-by-step tutorial on how to build our first STLMPI application. To explore the full functionality of STLMPI, please refer to the STLMPI developer's guide.
Step 1. Check your system
Before building our first application, please check its prerequisite software have been properly installed.
? STLMPI is installed. We assume the installation path is /home/someone/stl-mpi/install/
? GNU Compiler Collection (GCC) packages are installed, and the GNU C++ compiler (g++) is available
? MPICH2 is installed under the default installation path, so that the header files and shared objects can be accessed
Step 2. Prepare the program
We can simply go to the directory 'sample'. We will use the program 'sendrecv.cpp' as the example.
Step 3. Compile the program
We can compile the program with the command
g++ -o sendrecv -I/home/someone/stl-mpi/install/include -L/home/someone/stl-mpi/install/lib sendrecv.cpp -lstlmpi
Here, the -I flag tells the compiler where to find the required header files. The -L flag tells the compiler where to find the shared objects for linking. The -l flag tells the compiler which library to link with.
Step 4. Run the program
We first start the mpd process.
mpdboot -n 1
Then, we can set the correct path for the library and execute the program.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/someone/stl-mpi/install/lib
mpiexec -n 2 ./sendrecv
Done! You can see an output like this.
Rank 1 received 0
Rank 0 received 1
Have fun with STLMPI!
Beijing Mandarin Chinese Translation Service Company has translated many technical documents in the field of Function of all the characteristics of STLMPI.
华译网北京翻译公司翻译过大量有关STLMPI的全部特性功能文件资料。
指南
该指南按步骤给出了创建第一个STLMPI应用程序的过程。要了解STLMPI的全部特性功能,请参阅STLMPI开发人员指南。
步骤一 检查你的系统
创建第一个应用程序之前,请检查下述软件是否正确安装。
? 安装STLMPI。我们假定安装路径为/home/someone/stlmpi/install/
? 安装GNU编译器集合(GNU Compiler Collection, GCC),并确保GNU C++ 编译器(g++)能正常使用
? 在默认安装路径下安装MPICH2,以确保访问头文件和共享对象。
步骤2 准备程序
进入‘sample’目录。我们将使用‘sendrecv.cpp’作为例子程序。
步骤3 编译该程序
在命令行编译该程序
g++ -o sendrecv -I/home/someone/stl-mpi/install/include -L/home/someone/stl-mpi/install/lib sendrecv.cpp -lstlmpi
这里,-I参数告诉编译器在哪里可以找到需要的头文件。-L参数告诉编译器在哪里可以找到用于连接的共享对象。-l参数告诉编译器连接到哪个库。
步骤4 运行该程序
首先启动mpd进程。
mpdboot -n 1
然后,设置库文件的路径并执行该程序。
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/someone/stl-mpi/install/lib
mpiexec -n 2 ./sendrecv
完成后,你将看到如下输出。
Rank 1 received 0
Rank 0 received 1
祝您愉快地使用STLMPI!