Linux上编译计算Palabos案例指南

Linux上编译计算Palabos

Palabos用户文档
Palabos主页
Palabos旧版2.0

原始文档

The most recent version of Palabos can be downloaded at the address www.palabos.org. It is now shown how to compile and run the software under Linux or other Unix-like environment. The library is exempt from external dependencies: all you need is a working compiler environment, including a modern C++ compiler (for example the free GCC compiler), the command make, and a reasonably recent version of the Python interpreter. To get started, download the tarball of the most recent version of Palabos, for example plb-v1.1r0.tgz, and move it to the directory in which you wish the code to reside (we will refer to this directory under the name of $(PALABOS)). In the following, the code is staying at this location, as there is currently no explicit installation process. Instead, compiled libraries are deposited in the directory $(PALABOS)/lib/. Unpack the code, using for example the command tar xvfz plb-v1.1r0.tgz.
The library Palabos makes use of an on-demand compilation process. The code is compiled the first time it is used by an end-user application, and then automatically re-used in future, until a new compilation is needed due to a modification of the code or compilation options. To see how this works, change into the directory of one of the example programs, such as $(PALABOS)/examples/showCases/cylinder2D/. Type make to compile both the Palabos library and the example program under standard conditions with the GCC compiler, and execute the program with the command ./cavity2D. The program simulates the 2D flow around a cylinder; if the software ImageMagick is installed on your system, the program saves GIF images in the tmp/ subdirectory, representing the velocity field at selected time steps.
To use a different compiler, compile for parallel execution, or modify other compilation options, edit the file Makefile in the local directory. The following options are particularly often modified:
debug Turn on this flag to compile in debug mode. The resulting executable is a bit slower but easier to analyze in search for bugs. The recommended default behavior is to turn on debug mode.
MPIparallel Turn on this flag to compile for parallel execution.
serialCXX Specify the compiler to use for serial programs.
parallelCXX Specify the compiler to use for parallel programs.
optimFlags Specify the compiler options to use when the flag optimize is true.
compileFlags Specify additional compiler options, which are for example specific to your hardware environment. Typical options are -DPLB_BGP or -DPLB_MAC_OS_X when compiling on a BlueGene or on a Mac respectively.
If MPI is installed on your system (and if you have several cores or processors available), you can try to compile the code in parallel and execute it, say with two threads, through a command of the type mpirun -np 2 ./cavity2d. Note that the execution time of the example program is dominated by output operations. To observe a significant speed improvement in the parallel program, the output operations need first to be commented in the source code.

文档翻译

最新版本的Palabos可以通过网址www.palabos.org下载。现在演示如何在Linux或其他类unix环境下编译和运行软件。该库不受外部依赖:您所需要的只是一个工作的编译器环境,包括一个现代的c++编译器(例如免费的GCC编译器)、make命令和一个相当新的Python解释器。首先,下载Palabos的最新版本的压缩包,例如plb-v1.1r0。并将其移动到您希望代码驻留的目录(我们将以$(PALABOS)的名称引用此目录)。在下面的代码中,代码将保留在这个位置,因为目前没有显式的安装过程。相反,编译后的库存储在$(PALABOS)/lib/目录中。使用命令tar xvfz plb-v1.1r0.tgz解压缩代码。
库Palabos使用按需编译过程。代码在最终用户应用程序第一次使用时进行编译,然后在将来自动重新使用,直到由于修改代码或编译选项而需要重新编译为止。要查看这是如何工作的,请切换到其中一个示例程序的目录,如$(PALABOS)/examples/showCases/cylinder2d /。使用GCC编译器在标准条件下编译Palabos库和示例程序,并使用命令./cavity2D执行程序。该程序模拟了圆柱周围的二维流动;如果您的系统上安装了ImageMagick软件,该程序将GIF图像保存在tmp/子目录中,表示所选时间步长的速度字段。
若要使用不同的编译器、为并行执行进行编译或修改其他编译选项,请在本地目录中编辑文件Makefile。特别经常修改下列选择:
debug 在调试模式下打开此标志以进行编译。生成的可执行文件稍微慢一些,但是更容易分析,以查找bug。推荐的默认行为是打开调试模式。
MPIparallel 打开这个标志来编译并行执行。
serialCXX 指定用于串行程序的编译器。
parallelCXX 指定用于并行程序的编译器。
optimFlags 指定标记优化为真时使用的编译器选项。
compileFlags 指定额外的编译器选项,例如,这些选项特定于您的硬件环境。在BlueGene或Mac上编译时,典型的选项是-DPLB_BGP或-DPLB_MAC_OS_X。
如果MPI安装在您的系统上(如果您有多个可用的内核或处理器),那么您可以尝试并行地编译代码,并通过mpirun -np 2 ./cavity2d类型的命令执行它,比如使用两个线程。注意,示例程序的执行时间由输出操作决定。要观察并行程序中显著的速度改进,首先需要在源代码中注释输出操作。

解释说明

makefile文件修改:

# Name of source files in current directory to compile and link with Palabos
projectFiles = cavity2d.cpp

一般只需要改这一条,Makefile文件大致相同,这条是修改编译所需源代码文件的名称,你写好的程序放在examples/showcases/下新建的文件夹中,其他的都不需要改,只需要改这个文件名,按照你自己的程序文件名来写,使用make,即可以编译成可执行文件,再使用 ./文件名 运行文件。
如果没有办法编译,请查看是否安装了gcc,需要安装python,版本低于3.0,高版本编译无法通过,没有办法使用mpi,请自行编译安装openmpi

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值