inmost_partitioner.h 3.46 KB
Newer Older
Kirill Terekhov's avatar
Fixes  
Kirill Terekhov committed
1

Kirill Terekhov's avatar
Kirill Terekhov committed
2 3 4 5 6
#ifndef INMOST_PARTITIONER_H_INCLUDED
#define INMOST_PARTITIONER_H_INCLUDED
#include "inmost.h"

#if defined(USE_PARTITIONER) && !defined(USE_MESH)
7
#warning "USE_PARTITIONER require USE_MESH"
Kirill Terekhov's avatar
Kirill Terekhov committed
8 9 10 11 12 13 14 15
#undef USE_PARTITIONER
#endif


#if defined(USE_PARTITIONER)

namespace INMOST
{
16
	/// Main class to modify or improve the mesh distribution for better load balancing.
Kirill Terekhov's avatar
Kirill Terekhov committed
17 18 19
	class Partitioner
	{
	public:
20 21 22 23 24 25 26 27 28 29 30 31
		/// Type of the Partitioner can be currently used in this version of INMOST.
		/// @see Zoltan: Parallel Partitioning, Load Balancing and Data-Management Services. http://www.cs.sandia.gov/Zoltan/
		/// @see ParMETIS: Parallel Graph Partitioning and Fill-reducing Matrix Ordering. http://glaros.dtc.umn.edu/gkhome/metis/parmetis/overview
		enum Type
		{
			Zoltan_Parmetis, ///< Parmetis partitioner with the Zoltan package interface.
			Zoltan_Scotch,   ///< Scotch partitioner with the Zoltan package interface.
			Zoltan_PHG,      ///< Zoltan topology-based method using Partitioning of HyperGraph.
			Zoltan_RCB,      ///< Zoltan geometry-based method using Recursive Coordinate Bisection.
			Zoltan_RIB,      ///< Zoltan geometry-based method using Recursive Inertial Bisection.
			Zoltan_HSFC,     ///< Zoltan geometry-based method using Hilbert Space-Filling Curve partitioning.
			Parmetis,        ///< Parmetis partitioner with the original interface.
32 33
			INNER_RCM,       ///< Internal serial only partitioner based on the Reverse Cuthill–McKee algorithm ordering.
			INNER_KMEANS     ///< Internal parallel paritioner based on K-means clustering.
34 35 36 37 38 39 40
		};
		enum Action
		{
			Partition,       ///< Partition "from scratch", not taking into account the current mesh distribution.
			Repartition,     ///< Repartition the existing partition but try to stay close to the current mesh distribution.
			Refine           ///< Refine the current partition assuming only small changes of mesh distribution.
		};
Kirill Terekhov's avatar
Kirill Terekhov committed
41 42 43 44 45 46 47
	private:
		enum Type pt;
		enum Action pa;
		void * pzz;
		Tag weight_tag;
		Mesh * m;
	public:
48 49 50 51 52 53
		/// Initialize the use of partitioner.
		/// @param argc The number of arguments transmitted to the function main.
		/// @param argv The pointer to arguments transmitted to the function main.
		/// The shortest call to this function with the default solver parameters is the following: Initialize(NULL,NULL);
		/// @see Partitioner::SetMethod
		/// @see Partitioner::Finalize
Kirill Terekhov's avatar
Kirill Terekhov committed
54
		static void Initialize(int * argc, char *** argv);
55 56
		/// Finalize the use of partitioner.
		/// @see Partitioner::Initialize
Kirill Terekhov's avatar
Kirill Terekhov committed
57
		static void Finalize();
58
		/// The default constructor of the partitioner for the specified mesh.
Kirill Terekhov's avatar
Kirill Terekhov committed
59 60 61 62
		Partitioner(Mesh * m);
		Partitioner(const Partitioner & other);
		Partitioner & operator =(Partitioner const & other);
		~Partitioner();
63 64
		/// Evaluate the earlier specified partitioner.
		/// @see Partitioner::SetMethod
Kirill Terekhov's avatar
Kirill Terekhov committed
65
		void Evaluate();
66 67 68 69
		/// Set the partitioner method to be used.
		/// @param t The concrete Type of the partitioner from the selected package.
		/// @param a The partitioner Action, the default is Repartition.
		/// @see Partitioner::Evaluate
Kirill Terekhov's avatar
Kirill Terekhov committed
70
		void SetMethod(enum Type t, enum Action a = Repartition);
71
		/// Compute the specific weights for the selected partitioner.
Kirill Terekhov's avatar
Kirill Terekhov committed
72
		void SetWeight(Tag weight);
73
		/// Reset the computed weights for the partitioner.
Kirill Terekhov's avatar
Kirill Terekhov committed
74 75
		void ResetWeight();
		
76
		/// Get the Mesh pointer for the current partitioner.
Kirill Terekhov's avatar
Kirill Terekhov committed
77
		Mesh * GetMesh();
78
		/// Get the Tag of the computed weights for the current partitioner.
Kirill Terekhov's avatar
Kirill Terekhov committed
79 80 81 82 83 84 85
		Tag GetWeight();
	};
}
#endif //USE_PARTITIONER


#endif //INMOST_PARTITIONER_H_INCLUDED