Practical application of graph coloring

Lecture



The coloring of graphs is practically applied (the formulation of the problem of different colorings will not be discussed here) for:

Scheduling

  • timetables for educational institutions (review - [1] );
  • schedules in sports (review - [2] );
  • planning meetings, meetings, interviews;
  • transportation schedules, including air transport [3] ;
  • schedules for utilities [4] ;
  • and others.

Probably, any particular type of coloring will be used in scheduling.

Register allocation in microprocessors

See also: Register allocation

A significant role in the speed of programs on the computer is played by the microprocessor accessing data. Namely, the processor can refer (we list the devices in decreasing order of speed and increase in volume) to:

  • processor registers
  • cache,
  • operational memory,
  • other devices.

Next, consider the optimization programs associated with the distribution of data in these devices.

Standard Haitin Approach [edit]

The first [5] important works that laid the foundations for applying the graph coloring method in register allocation were [6] , [7] - the subsequent ones did not add anything revolutionary, their attention was focused on speeding up the algorithm, decreasing memory, new heuristics by definition the cost of pumping registers (we introduce the definition below) and the choice of registers for pumping; A review of these methods can be found in [8] .

Next, consider the method proposed in [7] .

Register allocation of a microprocessor is usually done at compile time.

A certain internal code ( IL , intermediate language , internal language ) is applied to the distribution procedure, which is designed for a virtual machine with an unlimited number of registers - we will call them virtual registers.

At the output, the procedures for accessing virtual registers are transferred either to real processor registers or, if the first one cannot be done due to the fact that all registers are already occupied, to real-time memory calls by introducing an additional code. This code is called the pumping code (English spillcode ), and the process itself - the pumping ( spilling ). Note that when accessing RAM, real registers are also sometimes used (for those processor commands that cannot take an address in memory as an argument).

For example, the number of general-purpose registers in most of the Intel processors corresponding to the architecture:

  • IA-32 - 8 pcs.,
  • Intel 64 [www 1] - 16 pcs.

(However, not even all of them can be used in our procedure of register allocation, since they can already be occupied - but these are already subtle implementation issues.) The RAM can store a very large number of “pumped out” “registers” - restrictions on its size We will not consider.

Before performing the distribution procedure itself, you should do:

  • Optimization of calls to virtual registers.
  • Determining whether a variable is currently "significant" for each program location. A “meaningful” variable is when the reading of the value currently written in it is performed later in the program.

The register allocation algorithm itself consists of the following steps:

  • Building a graph - let's call it a graph of incompatibilities (eng. Interfernce graph , conflict graph ). The vertices of this graph are registers. The vertices are adjacent if the corresponding variables are “significant” at the same time (differently: one of the variables is defined when the other is already “significant”).
  • “Gluing” of variables ( subsumption , variable propagation ): if before copying one variable to another, the 2nd is not “significant” yet, and the 1st is not “significant” after copying - we can omit the unnecessary move operation and pull (“glue ") The corresponding nodes of the graph.
  • And, finally, the most interesting stage for us: finding the n-coloring of the graph, where n is the number of the above-mentioned real variables. The solution to this problem coloring is the optimal allocation of registers. We will color it like this:
  1. For vertices with degree less than n, assign color if possible.
  2. For unpainted vertices (either their degree is not less than n, or - the colors are over) - we “pump out” the variables; delete these vertices from the graph. Correspondingly, the degree of their neighboring peaks decreases - and it makes sense to do step 1 again. (Do not forget that when pumping out it is also possible to introduce a new variable - it must be added to the graph.)

Practice shows that the algorithm converges fairly quickly.

The coloring of the graph is used in many well-known compilers, for example:

  • In GCC version 4.4, a new register allocator [www 2] - Eng. integrated register allocator , which uses the so-called coloring "Haitin-Briggs."
  • The “Haitin-Briggs” coloring book is also used in (at least its earlier versions) compiler from Intel for the IA-64 architecture. [www 1] [9]

Accounting for command-level concurrency [edit]

Processors capable of simultaneously and independently executing several instructions are becoming more widely used; they are said to be supported by teamwork parallelism ( Instruction-level parallelism , ILP ). Let's call them ILP processors. The class of ILP processors includes, among other things, processors with a very long command word - VLIW ( Very Large Instruction Word , among which are, in particular, many models of digital signal processing processors (DEPC). The most well-known commercially successful implementation of the concept of parallelism at the level of individual instructions is a family of microprocessors from Itanium by Intel. Also worth noting is the E2K architecture developed by the Russian company MCST.

For real-world use of high-performance ILP processors, high-level language compilers are needed that are capable of generating efficient code; including the optimization of the allocation of registers. The introduction of ILP requires a serious reworking of the Haitin method in terms of constructing an incompatibility graph; [5] proposed a modified version.

Distribution of executable code by cache [edit]

An algorithm was also proposed for the distribution of frequently used areas of code in the cache [10] - so-called. English cache line coloring .

The incompatibility graph here is: vertices are some “blocks” of code (for example, you can take procedures), edges exist when another is called from one “block”. As you can see, we concentrate on the so-called. first-generation cache conflicts - between the “block” and its caller / callee. But it is worth noting that the coloring problem is not solved by general-purpose algorithms, but by a special heuristic, which, moreover, gives a solution that satisfies certain additional conditions.

The advantage of this method is that it takes into account cache sizes, cache lines, code “blocks”, and cache associativity. The method is successfully combined with other optimizations and inline-functions [10] [11] . It should be noted that it can be implemented by the optimizer - but not by the optimizer of the compiler, but by the optimizer of the linker.

Frequency allocation

(Eng. Spectrum management , Eng. frequency allocation )

A good work classifying such problems and systematically setting out their solutions is [12] .

The term “frequency allocation” unites different types of tasks, which often have different goals and models. These tasks include:

  • Layout of distribution models (licensing, regulation) of radio frequencies maximizing the use of the entire radio spectrum.
  • Taking into account the fact that it is necessary to allocate the bands for mobile, terrestrial (English point-to-point ) and satellite communications, radio and television broadcasts.
  • Algorithms that dynamically distribute the frequencies of one particular network between users. The cellular communication is of particular interest here, in the field of which a very large amount of research has been done.

The common thing between tasks is that they all produce an optimal distribution of a limited set of radio spectrum resources among users, the number of which is constantly growing in modern conditions.

Two main areas of optimization here:

  • maximizing channel capacity while maintaining a certain minimum level of interference (interference);
  • minimization of interference to achieve a fixed bandwidth.

In the course of considering suitable models, in [12] , problems arise not much more complicated than T-coloring (English T-coloring ) of a multigraph, list T-coloring (English set T-coloring ).

As an example of work on a real cellular network, the results of which were further applied by the operator in their practical activities - [13] (Conducted by the operator E-Plus ((eng.) En: E-Plus) - the 3rd largest in Germany (2010 )).

Parallelization of numerical methods

To summarize, we will present the problem as follows: objects are certain calculations between which it is necessary to divide the computing resources (processors, computers ...) that can work in parallel with each other. Some calculations can be performed in parallel to each other, some - no. Accordingly, the vertex coloring of the incompatibility graph of the calculations is the desired distribution.

Let us give the following examples of numerical methods that can be parallelized in this way:

Cholesky decomposition for the conjugate gradient method with predestination [edit]

See also: en: Conjugate gradient method # The preconditioned conjugate gradient method

[14] This method is one of the best iterative methods for solving systems of linear algebraic equations (SLAE) with large, sparse, symmetric, positively defined matrices.

Gauss – Seidel method as applied to sparse matrices [edit]

The same iterative method for solving SLAU.

This, in turn, is good, for example, for calculating power distribution grids: such networks can be represented by graphs whose vertices are consumers and sources of electricity, and the edges are power lines; further, a SLAE is constructed, in the matrix of which the diagonal elements correspond to the nodes of the aforementioned graph, and non-zero non-diagonal elements correspond to edges. [15]

Also, the method can be so-called. smoother (English iterative smoother ) for multigrid finite element problem solving methods. (English multigrid methods of finite element problems ). Optimization of the Gauss – Seidel method used in smoothing using the so-called English sparse tiling for such a case of its use is considered in [16] .

Methods using adaptive refined grids [edit]

(English Adaptive mesh refinement )

[17] They, in turn, are useful in solving partial differential equations (DPEs). The clarification principle here is this: in places where the greatest local error is expected — where the solution changes most rapidly, the grid density is chosen to be greater.

Coordinate relaxation method [edit]

(eng. method of coordinate relaxation )

[18] It is successfully used in finding the extremal eigenvalues ​​of very large sparse symmetric matrices. Sometimes so large that it is more practical to generate them on the fly than to store them in memory. Such problems often arise in quantum mechanics.

Predefinition by incomplete LU decomposition [edit]

( Preconditioning by ILU, Incomplete LU-factorization )

To solve the slau using the Krylov subspaces. [nineteen]

Derivative Computation

Calculation of matrices of derivatives (Jacobians and Hessians) in the case when they are sparse, can be seriously accelerated by coloring the graphs. There is a project "Graph Coloring for Computer Derivatives", site - [www 3] . The site contains publications on the topic, as well as - a software package, in which the project participants have drawn up their achievements. For an introduction to the subject, you can see one of the presentations related to the project - [20] .

For a simple case when the “compaction” of a derivative is limited to a decrease in the number of columns, we give an algorithm:

Input : function from vector - Practical application of graph coloring

Output : derivative Practical application of graph coloring - Jacobian or Hessian

1. Investigate the structure of the sparseness of the derivative Practical application of graph coloring (we will not calculate the derivative itself).

2. Make a matrix Practical application of graph coloring reduce the number of columns Practical application of graph coloring - English seed matrix ; make up so that Practical application of graph coloring was the smallest.

3. Calculate the compacted values Practical application of graph coloring ; we will not calculate by this formula, but in a different way. Here it is clear that reduced before Practical application of graph coloring - number of columns Practical application of graph coloring

4. And now, restore the values Practical application of graph coloring by Practical application of graph coloring (can be some direct methods, it is possible - by solving equations).

Coloring graph here - in the calculation Practical application of graph coloring . In simple cases, it is necessary to calculate the usual vertex (born distance-1 ); distance-2 coloring (which, including reduced to square -distance distance-1 coloring); in more complex, small additional restrictions are required:

  • star coloring ( star coloring ) - vertex distance-1 , but with an additional restriction: for any path from 4 vertices at least 3 colors are used;
  • acyclic coloring ( acyclic coloring ) - vertex distance-1 + each cycle uses at least 3 colors.

Within the framework of the above project, calculations were carried out for technical production problems:

  • the process of chromatographic separation (from the field of chemistry, chemical technology) by means of English technology. Simulated Moving Bed ;
  • solution of the problem of optimal energy flow ( optimal power flow ) (electric power industry).

Digital watermarks

Digital watermarking technology (English digital watermarking ) allows along with data (whether it be media files, executable files, and others) to transmit some hidden message ("watermark", Watermark ). Such a hidden message can be used in copyright protection to identify the owner of the data.

This is important, for example, to determine the source of their distribution in an illegal manner. Or to confirm the rights to the data, for example - software systems on a chip ( system-on-chip ).

The message can be encoded including in the column. One of these techniques was proposed by Qu and Potkonjak (therefore, it is sometimes called the QP algorithm) in [21] .

It consists of this: let's say we have a graph G, the coloring of which is used in the program - moreover, it is used in such a way that it is permissible to change the contents of the graph with a slight increase in its chromatic number. What is important, one of such examples is the incompatibility graph of the register of the processor, which was mentioned above, which means that we will be able to encode the message in a software product using the distribution of registers.

You can extract it by comparing the resulting graph with the original one; there are also ways to ascertain whether a message was encoded in the graph without using the original one — the extraction is described in more detail, for example, in [22] .

The development and refinement of the thoughts of Qu and Potkonjak , attempts to improve the algorithm occur in [23] , [24] , [22] .

Note that in [23] , [24] there are references to the SandMark software package, in which algorithms of this kind are executed; available for download at [www 4] .

Other applications

  • The classical map coloring problem: tops - countries; edges - common borders. Such a graph corresponding to the map is planar, which means, by the 4-color theorem, always χ ≤ 4.
  • Calculation of networks OKS-7 (some generalization of telephone networks); namely, multigraph coloring with some restrictions is needed when routing packets with regard to uniform load [25] . In general, PFUR, including the author [25] who worked there, took an active part in the calculation of the Russian long-distance network OKS-7 [26] - which means the reliability of the source.
  • Cluster analysis (separation of objects into so-called clusters; within a cluster, objects have similar properties and / or clusters have distinct differences) [27] .
  • Solution sudoku: 9 digits sudoku - 9 colors. The vertices of the incompatibility graph are the cells of the table. Ribs between Practical application of graph coloring and Practical application of graph coloring hold if and only if:
    • Practical application of graph coloring , or,
    • Practical application of graph coloring , or,
    • Practical application of graph coloring and Practical application of graph coloring .
  • Designing devices where the wires connected in one node must have different colors for the convenience of distinguishing.
created: 2015-01-07
updated: 2021-12-09
132722



Rating 9 of 10. count vote: 2
Are you satisfied?:



Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Discrete Math. Set theory. Graph theory. Combinatorics.

Terms: Discrete Math. Set theory. Graph theory. Combinatorics.