1 Star 0 Fork 0

兜兜圈圈 / geographer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
LGPL-3.0

@file @mainpage User guide

Geographer

Geographer is a mesh partitioner for large-scale simulation meshes in distributed memory. It partitions meshes in two steps: First with a fast geometric method, then with multi-level local refinement.

It is implemented in C++ and uses the LAMA framework for distributed graph datastructures.

Requirements

The following software is needed to compile and use Geographer:

  • A sufficiently modern compiler, for example g++ >= 4.9 or icpc >=17.0. LLVM / Clang is currently not supported.
  • MPI
  • OpenMP
  • CMake (>= 3.0.2)
  • The numerical library Lama (>= 3.0.0)
  • For Lama, an implementation of the BLAS linear algebra standard

On a recent Ubuntu (>= 16.04), most of the dependencies can be installed with the following command:

sudo apt install cmake g++ git libatlas-base-dev mpi-default-dev

Installation

Libraries

Compile and install the Lama library. If its dependencies are installed, this can be done with the following commands:

git clone https://github.com/kit-parco/lama.git
mkdir lama/build && cd lama/build && cmake ../scai && cd ../..
cd lama/build && make && sudo make install && cd ../..

If root access is not available or not preferred, you can pass the argument -DCMAKE_INSTALL_PREFIX=<path>to cmake to specify an alternative install location.

Note that on newer versions of GCC (>= 8), several type conversions trigger warnings which are interpreted as errors. As a workaround, give -DADDITIONAL_WARNING_FLAGS="" as an argument to cmake.

The KaDIS library for distributed sorting is included as a submodule in this repository. If it is not yet cloned when starting the build process, cmake will download it automatically. Should this fail, do it manually by calling git submodule update --init --recursive. When compiling Geographer, KaDIS is automatically compiled as a CMake subproject.

Compilation

Use CMake to configure the project and make to build it, followed by make install:

mkdir build && cd build && cmake .. && make && sudo make install

If you have installed Lama in a non-standard location, add -DSCAI_DIR=<path/to/lama> where <path/to/lama> is your Lama installation directory. To install Geographer in an alternative location, pass the argument -DCMAKE_INSTALL_PREFIX=<path> to cmake. After successful compilation, the library libgeographer and the standalone executable GeographerStandalone are installed into the installation target. If the Google Test library was found, the unit tests can be found in the executable GeographerTest.

Mac OS

On Mac OS, the default compiler is LLVM, which is not supported by the Lama library on which we depend. One possibility to install the Gnu Compiler Collection GCC is with the homebrew package manager. You need to specify the compiler explicitly when calling CMake; as on Mac OS the command g++ is often an alias for clang, you might need to set the full path, for example as -DCMAKE_CXX_Compiler=/usr/local/bin/g++-7 -DCMAKE_C_COMPILER=/usr/local/bin/gcc-7.

Usage as Standalone Executable

Geographer can be used as a library or called from the command line. When using it from the command line, it expects to read an input graph from a file. By default, it is assumed that the input graph is in the METIS format and that coordinate files describe one point position per line. If no coordinate file is given, it is assumed that the coordinates are in foo.metis.xyz for an input file foo.metis. For an input graph embedded in 2 dimensions, a graph file input.graph and a coordinate file input.graph.xyz, call the program like this:

./GeographerStandalone --graphFile input.graph  --numBlocks 8 --dimensions 2 --outFile output.part

This will partition the graph into 8 blocks and write the result to output.part.

Parallelization

Geographer can run in parallel using MPI. An example call with 8 processes :

mpirun -np 8 GeographerStandalone --graphFile input.graph  --numBlocks 8 --dimensions 2 --outFile  output.part

The number of blocks can be different from the number of processes, but this will disable the local refinement. If the number of blocks is not given, it is set to the number of processes. Thus, the last command could also be phrased like this:

mpirun -np 8 GeographerStandalone --graphFile input.graph --dimensions 2 --outFile output.part

Other parameters

Geographer supports other parameters and input formats as well. For a full list call ./GeographerStandalone --help. For example, to partition a graph formatted as METIS and coordinates given in the ADCIRC format into 512 blocks with a maximum imbalance of 0.01 according to the second node weight, use:

mpirun -np 8 GeographerStandalone --graphFile fesom_core2.graph --coordFile node2d_core2.out --coordFormat ADCIRC --epsilon 0.01 --dimensions 2 --numBlocks 512

Usage as Library

The methods that should be called by end users are the member functions of the ParcoRepart class. They mostly accept and return Lama data structures. The functions are templated to accept different types for indices and values, instantiated with the same types used in the compilation of the used Lama library.

An example is this:

static DenseVector<IndexType> partitionGraph(CSRSparseMatrix<ValueType> &input,
	std::vector<DenseVector<ValueType>> &coordinates,
	struct Settings settings)

This function takes the input graph as an adjacency matrix in the CSRSparseMatrix format. The edge weights are interpreted as communication volumes. The coordinates are accepted in a vector of DenseVector, one DenseVector for each dimension. The settings struct contains relevant options, for example the target number of blocks. The result is returned as a DenseVector with one entry for each vertex, specifying its block ID in the partition. If the number of blocks is equal to the number of processes, the input data structures are redistributed to reflect the new partition.

Node Weights

Node weights can also be given as an optional parameter. We accept multiple weights per node, for a graph with n nodes and k weights for each node, nodeWeights should be a vector of k DenseVectors with n entries each.

static DenseVector<IndexType> partitionGraph(CSRSparseMatrix<ValueType> &input,
	std::vector<DenseVector<ValueType>> &coordinates,
	std::vector<DenseVector<ValueType>> &nodeWeights,
	struct Settings settings)

Metis Compatibility Interface

For those who are used to the common Metis library for graph partitioning, we offer an interface with a similar format:

static std::vector<IndexType> partitionGraph(
	IndexType *vtxDist, IndexType *xadj, IndexType *adjncy, IndexType localM,
	IndexType *vwgt, IndexType ndims, ValueType *xyz,
	Settings  settings, Metrics& metrics)

The Metrics struct keeps track of how long each of the partitioning substeps took, as well as other performance metrics. It can be constructed with a settings object.

Settings settings;
settings.numBlocks = 8 //example, setting the target number of blocks to 8.
Metrics metrics(settings);

Mapping

The performance of a distributed application depends not only on balancing the computational load and reducing the amount of necessary communication, but also on a good match between the partitioned blocks and the available computing resources. This holds especially for heterogenuous environments with for example a mix of GPUs and CPUs.

If you know the topology of your computing system, you can pass a representation of it as the commTree argument to the partitionGraph method.

static DenseVector<IndexType> partitionGraph(
	CSRSparseMatrix<ValueType> &input,
	std::vector<DenseVector<ValueType>> &coordinates,
	std::vector<DenseVector<ValueType>> &nodeWeights,
	DenseVector<IndexType>& previous,
	CommTree<IndexType,ValueType> commTree,
	struct Settings settings,
	struct Metrics& metrics)

TODO: Describe how to construct a comm tree. This is also not optimal now.

Partitioning Methods

The partitioning works in two phases: In the geometric phase, the input points are partitioned to yield a convex partition, but without considering the graph-based metrics. In the following graph phase, if the number of blocks equals the number of processes, use the multi-level heuristic with distributed local refinement to improve the solution with respect to graph-theoretical metrics such as the cut and communication volume.

The choice of method in the geometric phase is governed by the parameter initialPartition in the Settings struct or the --initialPartition argument of the standalone executable. Several methods are available:

Space Filling Curves

Sort and redistribute points along a Hilbert curve in two or three dimensions. Fast, but with suboptimal quality. Does not support node weights. Selected by setting the initialPartition member of settings to ITI::Tool::geoSFC or passing "--initialPartition geoSFC" to the standalone executable.

K-Means

First use space-filling curves for an initial partition, then improve it using distributed k-means. Repeatedly adjust influence values to achieve the desired balance. Output partitions are convex or nearly convex. This is the default, represented by ITI::Tool::geoKmeans or "--initialPartition geoKMeans".

Hierarchical K-Means

For more than a few thousand blocks, k-means sometimes takes long to converge to a balanced solution. A faster alternative is to first partition into a smaller number of blocks and then proceed hierarchically, partitioning each block further until the desired number of blocks is reached. To use this method, select ITI::Tool::geoHierKM or "--initialPartition geoHierKM". You also need to pass the number of divisions on each level in the hierLevels argument. The final number of blocks is the product of the divisions on all levels, the following snippet sets 4 levels of 100 blocks in total:

ITI::Settings settings;
settings.numBlocks = 100;
settings.initialPartition = ITI::Tool::geoHierKM;
settings.hierLevels = std::vector<int>({5, 2, 5, 2});

MultiSection

Analogous to recursive bisection, MultiSection repeatedly divides the initial point set along a set of straight lines. It is selected with ITI::Tool::geoMS or "--initialPartition geoMS". When using this method, you also need to pass the number of cuts in each dimension with the cutsPerDim parameter. The final number of blocks is product of the number of cuts in each dimension. The following snipped sets 100 blocks in total in two dimensions:

ITI::Settings settings;
settings.numBlocks = 100;
settings.dimensions = 2;
settings.initialPartition = ITI::Tool::geoMS;
settings.hierLevels = std::vector<int>({10, 10});

The number of dimensions must match the number of dimensions in the input. TODO: give credit to original authors

Multilevel Local Refinement

The graph refinement phase uses the Fiduccia-Mattheyses method to improve the geometric partition. It is only available if the number of blocks matches the number of processes. It can be disabled by setting settings.noRefinement to False or with the --noRefinement flag when using the standalone executable.

GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

简介

暂无描述 展开 收起
LGPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/xichaoqiang/geographer.git
git@gitee.com:xichaoqiang/geographer.git
xichaoqiang
geographer
geographer
master

搜索帮助