注册 登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

随机过程

http://superware.blog.163.com

 
 
 

日志

 
 

Interfacing to PETSc and Trilinos  

2012-04-18 14:51:49|  分类: Linux |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

About PETSc, Trilinos, and the deal.II interfaces

deal.II can interface to the PETSc and Trilinos software libraries. Both of these libraries provide lots of functions for linear algebra, among other things, for example implementations of a variety of linear solvers, as well as various different sparse and dense matrix and vector formats. Trilinos also has many subpackages that deal with problems that go far beyond linear algebra, for example nonlinear solvers, automatic differentiation packages, uncertainty propagation engines, etc. Of particular interest to deal.II is their ability to provide this functionality both on sequential and parallel (using MPI) computers. PETSc is written in C; Trilinos is written in C++ and can be considered to be a more modern version of PETSc though both packages are under continuing development at their respective national laboratories.

deal.II has wrapper classes to the linear algebra parts of both packages that provide almost the same interfaces as the built-in deal.II linear algebra classes. We use these interfaces for parallel computations based on MPI since the native deal.II linear algebra classes lack this ability.

Configuring the interfaces to PETSc and Trilinos

The use of PETSc and Trilinos is optional. To use the wrapper classes, you first have to install these packages and point deal.II's ./configure to the installation directories. This happens in similar ways for the two packages:

PETSc

PETSc usually requires you to set the environment variables PETSC_DIR and PETSC_ARCH to a path to PETSc and denoting the architecture for which PETSc is compiled. If these environment variables are set, then deal.II will pick them up during configuration, and store them. It will then also recognize that PETSc shall be used, and enable the wrapper classes.

Alternatively, the --with-petsc=DIR and --with-petsc-arch=ARCH switches to ./configure can be used to override the values of PETSC_DIR and PETSC_ARCH or if these environment variables are not set at all. If you do have a PETSc installation and have set the PETSC_DIR and PETSC_ARCH environment variables but do not wish deal.II to be configured for PETSc use, you should specify --with-petsc=no as a flag during configuration.

Note that in order to use PETSc with deal.II with the current release version of deal.II you will need to have at least PETSc version 2.3.0 installed, earlier releases are no longer supported. There is no correlation between deal.II version numbers and PETSc version numbers. deal.II version 7.0 has been tested up to PETSc release 3.1.0-p8, and newer version up to at least PETSc release 3.2.

There is an additional caveat: PETSc appears not to co-operate well when using threads and some programs crash when deal.II is compiled in its usual mode supporting multithreading. If you see this sort of behavior, we recommend to try disabling multithreading upon configuration of deal.II using the --disable-threads switch to ./configure.

Installing both PETSc and deal.II together can be a bit of a challenge. A good summary of the relevant steps can be found on the Frequently Asked Questions page.

Trilinos

As above, set the TRILINOS_DIR environment variable to the path to an existing Trilinos installation, or use the --with-trilinos=/path/to/trilinos switch of the deal.II ./configure script. It should point to the path of which the include and lib directories are subdirs. The Trilinos installation needs to provide the same kind of libraries that deal.II is configured for, i.e. if you want deal.II to use shared libraries, then Trilinos needs to use shared libraries as well.

deal.II and its tutorial programs use several of the Trilinos sub-packages.

Trilinos starting with version 10.0

Note: Trilinos versions 10.6.x, 10.8.0, and 10.8.1 are not compatible with deal.II. They contain subtle bugs related to (parallel) matrices and vectors. We recommend staying with 10.4.2 for the time being.

Due to the entirely different build system, deal.II does no longer support Trilinos versions prior to 10.0. Starting with this version, Trilinos uses cmake to configure and build. This is a bit cumbersome because you first have to install a version of cmake that is at least a cmake 2.8 prerelease, and then enter the following slightly longish set of commands:

cd trilinos-10.4.2
mkdir build
cd build

cmake -D Trilinos_ENABLE_OPTIONAL_PACKAGES:BOOL=ON \
-D Trilinos_ENABLE_Sacado:BOOL=ON \
-D Trilinos_ENABLE_Stratimikos:BOOL=ON \
-D CMAKE_BUILD_TYPE:STRING=RELEASE \
-D CMAKE_CXX_FLAGS:STRING="-g -O3" \
-D CMAKE_C_FLAGS:STRING="-g -O3" \
-D CMAKE_FORTRAN_FLAGS:STRING="-g -O5" \
-D Trilinos_EXTRA_LINK_FLAGS:STRING="-lgfortran" \
-D CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE \
-D Trilinos_VERBOSE_CONFIGURE:BOOL=FALSE \
-D TPL_ENABLE_MPI:BOOL=OFF \
-D CMAKE_INSTALL_PREFIX:PATH=/w/bangerth/share/x86_64/trilinos-10.4.2 \
-D BUILD_SHARED_LIBS:BOOL=ON `pwd`/..

make
make install
Again, the path into which you want to install Trilinos in the second to last line of the cmake command needs to be adjusted. Obviously, if you want to use Trilinos with MPI on parallel machines, you also need to flip the value of the TPL_ENABLE_MPI flag above. Finally, if your computer has more than one processor core, you may want to add the -jN flag to the calls to make where N is the number of compile jobs you want to run in parallel.

Trilinos sometimes searches for other libraries but can't find them if they are not in the usual directories or have other names. A common example are BLAS or LAPACK. In a case like this, you may have to specifically pass the directories and/or library names under which they can be found to cmake. For example, this may mean to add the following flags to the call above:

      -D BLAS_LIBRARY_NAMES:STRING=goto \
-D BLAS_LIBRARY_DIRS:STRING=/apps/GotoBLAS/lib64 \
-D LAPACK_LIBRARY_NAMES:STRING=lapack \
-D LAPACK_LIBRARY_DIRS:STRING=/apps/lapack-3.2.1/lib64

If the deal configuration complains about

configure: error: *** Your Trilinos installation is not compatible with the C++ standard selected for this compiler. See the deal.II FAQ page for a solution. ***
you have encountered a bug in Trilinos. As a workaround, include/Sacado_cmath.hpp has to be edited (see the FAQ entry for details).

Configuring for installed Trilinos packages

The above scheme works if Trilinos is installed in its own directory and header and library files are in subdirectories of the directory given to --with-trilinos. This scheme doesn't work, however, if Trilinos has been installed as a regular package on a system, for example into the /usr or /opt directories.

In that case, paths to include and library files may be specified separately using the --with-trilinos-include and --with-trilinos-libs switches to ./configure. Alternatively, this information can also be passed to the configuration script by setting the environment variables TRILINOS_INCDIR, TRILINOS_LIBDIR.

Dealing with other Trilinos packages

In the commands configuring Trilinos shown above, we have assumed a particular subset of Trilinos libraries that deal.II interfaces with. However, Trilinos has many more packages that deal.II doesn't use, and you can add many more -D Trilinos_ENABLE_XXX:BOOL=ON flags for package XXX. Most of the time, no harm is done by doing so, but there are cases where some of the packages deal.II does interact with also interacts with package XXX if the latter was enabled in Trilinos. One example is that Trilinos' ML package (which we use) uses Trilinos' Zoltan package if Zoltan is enable, but not if Zoltan is not enabled. That means that the libml.so library may or may not depend on a libzoltan.so library.

Unfortunately, Trilinos' configuration framework does not record this in libml.so, and it is also something that is difficult for the deal.II configuration framework to find out after the fact. Consequently, deal.II's Makefiles rely on the fact that only the Trilinos packages listed above were enabled. If that isn't the case, you may get linker warnings. The only way to solve this problem is to add the additional Trilinos libraries at the appropriate place in the list of DEAL_II_TRILINOS_LIBS libraries in common/Make.global_options by hand.

  评论这张
 
阅读(59)| 评论(0)
推荐

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018