Genetic Placement: Genie Algorithm Way Sern Shong ECE556 Final Project Fall 2004 Introduction Overview One of the principle problems in VLSI chip design is the layout problem. The layout problem is complex and therefore divided into different areas: chip planning, partitioning, placement, and routing. We are given a set of modules, and a set of signals. The objective is to assign each module to a slot, and achieving the minimum wire length possible between modules that are connected by each net. Being an important CAD issue, the placement problem has received a lot of attention and there are various different approaches to the problem, such as partitioning, quadratic assignment, force-directed, resistive network, and simulated annealing. Genetic Algorithms Genetic algorithms operate on strings of data in which each string represents a solution, in a way that resembles the workings of natural evolution. By defining a population, these algorithms maintain a number of solutions which it will operate upon in the future. Eventually, solutions with a high cost would be replaced by solutions with lower cost. The technique to generate new solutions is to choose parents from the population that would then pass their genes (attributes/elements) to its offspring. This process is called the crossover. After the crossover, a new population must be generated using the old population and the new offspring. This selection process is to select the genes that survive for the next generation. Another process with happens after this is known as the mutation process. Mutation processes happen to produce new genetic variation, so that diversity is maintained. Once some numbers of offspring have been generated through crossover and mutation, the combined population of parents and offspring are evaluated. The algorithm continues iteratively usually until no improvements are detected for a long time. In the long run, the better (lower cost) solutions tend to stay in the population and the worse (higher cost) solutions tend to die off.
Genie Specification Genie is one of the earliest placement algorithms based on the genetic approach, for the assignment of modules to locations on chip. The algorithm implements a directed-evolution methodology to formulate its solutions from the solution space. Firstly, the scoring function must be determined in order to evaluate which solutions are better than the others. The scoring function used in this program was to calculate the total estimated wirelength using the semiperimeter method. The distance for a single net is calculated by taking the area that is enveloped by modules connected to that net. Such a function encourages short interconnections with even horizontal and vertical channel capacities. The initial population is constructed by using a combination of two methods. Cohoon and Paris found that the best results are achieved by generating an initial population using 25% random placements and 75% using a method that places modules in a row-major fashion. There are several versions of the crossover method which were stated in the research paper. Only the method that produced the best results was recreated in this project. It involves choosing a passing and target parent. The offspring is then made by first copying the target parent s assignment of modules into the offspring. Then an area in the passing parent is selected to be copied over into the offspring. Before doing this, the offspring must first move the cells that occupy that area into different locations. This process is shown below: The mutation function randomly selects a solution from the population and acts to introduce a new combination into the solution space. A net in the solution is randomly selected and the cells which are furthest away from each other but attached to the net are brought closer. This process reduces the wirelength of that respective net.
Data Structure The input file contains list of nets and modules, with the maximum row width in the top line. The input information is stored in an array of net and cell structures. Each net structure stores its weight, number of cells connected, and connected cell ids. Each cell structure stores its position, number of ports, port positions, and nets connected. Each solution (population element) consists of an array of pointers to cells structures. Pseudocode The Genie algorithm repetitively runs the crossover, selection, and mutation operations in a main while loop. The main operation of the program is as follows: 1. Parse input file and create net and cell structs 2. P <- determine initial population 3. For 25% of population Select passing and target parents Perform crossover to generate offspring 4. Apply selector to old population and offspring to create new population 5. Apply mutation to a number of solutions in new population 6. Repeat from step 3 until no improvement in score for 10000 iterations Compilation/Execution The g++ compiler was used to compile all source codes and generate the executable file. The entire project was done in a Unix environment using Sun-Blade 2000 machines. The code is in the ANSI-C++ programming language. Compiled code size is dependant on the capabilities of optimizing compilers and is also highly platform-dependant. The specific command used to compile was: g++ geniefinal.c o genie which creates an executable file named genie. The program is then run with these parameters: genie <inputfile> <outputfile>
Structure and Organization The entire program consists of one file for simplicity and convenience. All the main data (net and cell) structures are declared first and the important functions next, such as the cost, crossover, mutation, and selection functions. The main function follows shortly which include the main while loop which repetitively calls the important functions. Comments are included in detail for every function that is implemented and throughout the entire program. In the main function, the variables are initialized in the beginning and any memory used is deleted from the heap at the end. Discussion Results The results of the genie algorithm were compared against those of a previous implementation of the TimberWolf placement algorithm. This implementation of TimberWolf is a variation of the TimberWolf 3.2 algorithm. The genie algorithm was constrained as the TimberWolf algorithm in terms of its inputs. The modules were all fixed-width and height with no space in between modules. The entire code consists of slightly over 800 lines. The code size is as follows: Sourcecode(genieFinal.C) = 24148 bytes Binary (genie*) = 34088 bytes Performance On average, the Genie algorithm outperforms the TimberWolf algorithm by about 63%. In general, the Genie algorithm acts upon past solutions, which enables it to more rapidly converge to a better solution in the early stages. TimberWolf was not as efficient as it only selects one solution at a time, but shows better performance in later stages. Cost TimberWolf Genie 10-cell input file 1 721 468 (input_10_1.txt) 10-cell input file 2 873 479 (input_10_2.txt) 50-cell input file 3 64879 39863 (input_50_1.txt) 50-cell input file 4 (input_50_2.txt) 67209 42394
Run Time TimberWolf (s) Genie (s) 10-cell input file 1 0.220 0.354 (input_10_1.txt) 10-cell input file 2 0.240 0.398 (input_10_2.txt) 50-cell input file 3 0.476 2.03 (input_50_1.txt) 50-cell input file 4 (input_50_2.txt) 0.508 2.31 TimberWolf performs a lot faster than the Genie algorithm. This is due to the genie algorithm acting upon a set of solutions compared to the TimberWolf algorithm generating only one solution every iteration. Improvements An effective method to improve performance of the genie algorithm is to ensure that diversity is maintained through varying the solutions at every point in execution. This allows for the solution space to explore more solutions with less time. Achieving a greater diversity can be done using the following improvements: 1) Initial populations should be generated using a combination of techniques. For example, cells that are connected to the same net should be placed as near as possible to each other. Having a good initial population would lead to needing less time to converge upon good solutions and exploring more options within those genes. 2) Wise choices of parents should be made for crossover using probabilistic choice functions. Such examples would include selecting parents which have a lower than average cost. Doing this would lead to better offspring solutions. 3) Selecting the next generation population can also be done using such probabilistic choice functions. Higher scoring solutions should be chosen not all the time as it might lead to an early convergence and local optima. Smartly applying the mutation process to certain solutions would generate more diversity and create better solutions.
References COHOON, J. P., AND PARIS, W. D. 1986. Genetic placement. In Proceedings of the IEEE International Conference on Computer-Aided Design. DUNLOP, A. E., AND KERNIGHAN, B. W. 1985. A procedure for placement of standard cell VLSI circuits. IEEE Trans. Computer-Aided Design CAD-4. Appendix Example crossover:
Example mutation process: