• Save
A mathematical model and a heuristic memory allocation problem
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

A mathematical model and a heuristic memory allocation problem

  • 915 views
Uploaded on

Effective memory management in embedded systems reduce running time and power consumption. Memory allocation is complicated by limited capacity and number of memory banks, as well as potential......

Effective memory management in embedded systems reduce running time and power consumption. Memory allocation is complicated by limited capacity and number of memory banks, as well as potential runtime conflicts. We approached the optimization of memory allocation problem through exact solution using ILP and Tabu Search heauristic method. Inputs from DIMACs instances were tested and the results show significant performance difference between the two approaches

More in: Education , Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
915
On Slideshare
915
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. 1 Memory Allocation Problem Using Tabu Search Metaheuristics and ILP Enkhjin Bayarsaikhan, Farnoosh Farokhmanesh, Diego Montero CANO (Master CANS - FIB) UPC Barcelona, Spain Abstract Effective memory management in embedded systems reduce running time and power consumption. Memory allocation is complicated by limited capacity and number of memory banks, as well as potential runtime conflicts. We approached the optimization of memory allocation problem through exact solution using ILP and Tabu Search heauristics method. Inputs from DIMACs instances[1] were tested and the results show significant performance difference between the two approaches. I. I NTRODUCTION Memory management optimization is closely related to minimizing the power consumption in embeddedsystems. Given a limited number of memory cache available, in a data and computationally intensiveperformance, it is critical to ensure the maximum amount of data available in memory, and minimumtime spent loading and offloading data from external storage. In the era where desktop computers arebeing replaced by laptops, smart-phones and tablet computers, reducing power consumption at runtime inembedded systems is important. In this paper, we tackle the optimization of memory management problemusing Integer Linear Programming (ILP) in CPLEX, and Tabu Search (TS) metaheairustics technique. Themain purpose of this paper is analyse the performance comparison of ILP and TS in the optimization ofrealistic memory management problem. Memory allocation with limited number of memory banks is similar to a classic combinatorial optimiza-tion problem called k-weighted graph coloring [2]. Furthermore, one of the suggested metaheuristics forsolving the graph coloring problem is TS. Therefore, we’ve used a version of TS called tabucol to find theheuristical optimization of the given memory allocation problem. The input data were publicly availableDIMACs instances that are enriched with multiple constraints and costs to match the inputs presented in[3]. From the experimentations using these instances in both ILP and TS, the observed difference wasthat ILP performed excellent in smaller datasets with small number of conflicts, whereas TS performedsignificantly better for larger instances. The structure of this paper is as follows, Section II contains a detailed discussion of background andrelated works, Section III discusses the experimental setup, Section IV discusses the ILP implementation,Section V covers the metaheuristics implementation, Section VI contains the output comparison andSection VII with critical discussions, and finally the paper concludes with project review and suggestionsfrom our group. II. BACKGROUND AND R ELATED WORKS The topic of this project was presented in [3], which introduces solving memory allocation problem inembedded systems using exact approach and multiple metaheuristic methods. Due to the correspondencein class contents and scope, we chose to implement Tabu search heuristic method in our project, andcompared its execution and performance against the integer solution. The following sections introduce thememory allocation problem in more detail, how it is solved using the graph coloring approach, and theheuristics method we chose to implement.
  • 2. 2A. Memory Allocation in Embedded Systems The relationship between memory management and power consumption of electronic systems is in-troduced in [4], where the authors observed that during a heavy computation period, inefficient memorymanagement demands higher power consumption by the embedded system. Another way to minimize thepower consumption of computer system is to minimize the runtime of any application, which also meansminimizing the time it takes for loading operations and accessing to memory. Therefore, optimizing thememory management in embedded systems reduces power consumption of the system, and enhances theproduct usage. To solve the aforementioned memory management problem, several assumptions must be made. The firstassumption is that, absence of an operating system. Since each operating systems have different memorymanagement methods, the focus of this paper is to optimize the memory management of applicationswritten in lower level language, such as C code. Therefore the problem, on which this project focuses,is minimizing the total time accessing the data structures and loading them to appropriate registers toperform the operations listed in C code. Also, in addition to the limited capacity internal memory banks, the presence of an external memory withunlimited capacity is assumed. The data structures take time to be accessed from internal memory banks,and a parameter p times longer to be accessed from the external memory. When two data structures arecalled in a same operation, they must be accessed simultaneously if they are located in different memorybanks. If they are located in a same memory bank, they must be accessed sequentially, hence creating aconflict in the optimization. As mentioned in [3], there are four different conflict statuses between suchtwo data structures: • two data structures could be mapped to different memory banks, thus creating no conflicts. • two data structures could be located in same internal memory bank, and need to be accessed sequentially. In this case, there would be a conflict cost, d. • one of the data structures, ak , could be mapped to an external memory bank, while the other data structure, bk , is mapped to an internal memory bank. The conflict arises when both data structures are accesses simultaneously, and ak would be mapped with extra cost factor, p. Thus, the total cost in this case would be pd. • two data structures could be both mapped to external memory, hence the cost would be 2pd. Conflicts costs, as well as the access times from internal memory and external memory, are analogousto power consumption. With these realistic assumptions, the power consumption of an embedded systemcould be now optimized via the memory allocation problem.B. Graph Coloring Problem using Tabu Search Memory allocation with constraint on the number of memory banks is equivalent to k-weighted graphcoloring problem [2]. K-weighted graph coloring problem consists of coloring the vertices of a graph withundirected edges, with k number of colors, such that the number of edges with vertices of same colorwould be minimized. In comparison to memory allocation problem, the data structures are represented bynodes or vertices, the memory banks are represented by colors. The conflicts are represented by edges. Thedifference between graph coloring problem and the given memory allocation problem is the capacity ofmemory banks, the access times of data structures, and cost of conflicts. Therefore, it is safe to assume thatk-weighted graph coloring problem is a simpler version of memory allocation problem with constraintsin number of memory banks. Tabu search procedure, suggested by [5] to solve graph coloring problem, is described as movingiteratively towards the optimum value of a function, employing a special feature, to avoid being trappedin a local optima. The special feature is called a Tabu List, which contains a certain number of moves thathave been covered before, thus they are forbidden as the name suggests. The idea is to generate an initialfeasible solution, S, and generate a set of neighbourhoods, N(S), of feasible solutions. From N(S), thecurrent best neighbour, S*, is chosen in one iteration. The trick here is to choose S* that does not belong
  • 3. 3to values in the Tabu List. For the graph coloring problem, the initial solution is generated randomly. Theimplementation of tabu search metaheuristic in more detail in Section V. III. E XPERIMENTAL S ETUP The given problem was solved using two techniques: by using Integer Linear Programming (ILP) ,and by implementing Tabu Search metaheuristic. The use of these two methods in memory managementproblem was discussed in [3]. The ILP was implemented in CPLEX optimization software, acquiredthrough the academic license from IBM. The execution of each problem instances were done in the UPClab computers in Building B5. The Tabu search metaheuristic was implemented in C code, in one of ourgroup members’ personal computer, running Ubuntu OS. The metaheurisctic implementation is based onthe TabuCol[5] approach implementation taken from [6]. Furthermore, the input data were chosen from DIMACs graph coloring instances, as mentioned in [3],that are publicly availbale at [1]. The original DIMACs instances contain number of edges and nodesfor a graph coloring problem, and are analogous to number of conflicts and number of data structures,respectively. These instances were enriched with randomly generated values for the number of memorybanks, the p factor for loading from the external memory, the access times of data structures, as well asthe conflict costs. The data structure sizes and memory bank capacities were set to be constant for allinstances, as they are in [3]. IV. ILP I MPLEMENTATION The ILP model used for memory allocation problem was presented in [3], and it was implemented usingthe IBM CPLEX optimizer. This section focuses on the interpretation of the ILP model, and discussionabout CPLEX performance in optimizing the ILP.A. ILP Model The sets and parameters in ILP model are as follows: • There are n number of data structures, indexed i. • There are m number of memory banks, indexed j. The external memory is indicated as m+1. • There are o number of conflicts, indexed k. • The capacity of memory bank j is denoted by cj . • The size of each data structure i is denoted by si . • The access cost of data structure i is denoted by ei . • The cost of conflict k is denoted as dk . The variables in ILP model are as follows: • A binary matrix X of size (n×m), with elements xi ,j . Each element, xi ,j , is either 1 when data structure i is mapped to memory bank j, or 0 when otherwise. 1, if data structure i is mapped to memory bank j ∀i ∈ {1, . . . , n}, ∀j ∈ {1, . . . , m + 1} xi,j = 0, otherwise • A vector Y with nonnegative variables yk associated with conflicting relationships between two data structures. The variable yk takes on a value of 0, when there are no conflicts between two data structures, 1 when both data structures are mapped to a same internal memory, p when one is mapped to internal and the other is mapped to an external memory, and 2p when both data structures are mapped to external memories. In short, the value of yk could be 0, 1, p, or 2p.The purpose of memory allocation problem is to minizie the power consumption by efficiently managingthe memory, as discussed earlier. Thus, it is analogous to minimizing the cost associated with any conflicts,and cost of access time of each data structures in internal and in external memory banks. This objectiveof our problem, modeled in equation (1), is to minimize the total cost of conflicts, the cost to accesseach data structures in all internal memory, and the cost to access data structures allocated in the external
  • 4. 4memory. The equation (2) enforces that each data structure is mapped to a single memory bank, or theexternal memory. The equation (3) enforces that the total size of data structures mapped to a memorybank j does not exceed its capacity. The inequalities (4) to (7) ensures the appropriate values of variableyk for conflict k. Inequality (4) declares that when two data structures, ak and bk , are mapped to a sameinternal memory bank j, the value of variable yk is not zero. Inequalities (5) and (6) prevents the value ofvariable yk from being less than p when one data structure is mapped to internal and the other is mappedto external memory. Similarly, the inequality (7) ensures the appropriate value of yk for the last conflictcase. The expressions in (8) and (9) ensure the binary nature of xi ,j , and nonnegative nature of yk . o n m n Min yk dk + (ei xi,j ) + p (ei xi,m+1 ) (1) k=1 i=1 j=1 i=1 m+1 xi,j = 1, ∀i ∈ {1, . . . , n} (2) j=1 n xi,j si ≤ cj , ∀j ∈ {1, . . . , m} (3) i=1 xak ,j + xbk ,j ≤ 1 + yk , ∀j ∈ {1, . . . , m}, ∀k ∈ {1, . . . , o} (4) 1 xak ,j + xbk ,m+1 ≤ 1 + yk , ∀j ∈ {1, . . . , m}, ∀k ∈ {1, . . . , o} (5) p 1 xak ,m+1 + xbk ,j ≤ 1 + yk , ∀j ∈ {1, . . . , m}, ∀k ∈ {1, . . . , o} (6) p 1 xak ,m+1 + xbk ,m+1 ≤ 1 + yk , ∀k ∈ {1, . . . , o} (7) 2p xi,j ∈ {0, 1}, ∀(i, j) ∈ {1, . . . , n} × {1, . . . , m} (8) yk ≥ 0, ∀k ∈ {1, . . . , o} (9)B. Optimization using CPLEX The optimization process in CPLEX could be described as minimizing the gap between generatedobjective function projection and current solution projection. In other words, the optimum solution ofan ILP problem is found when this gap reaches to zero, and current solution projection intersects theobjective function projection. CPLEX optimizer utilizes the Branch&Cut technique, such as described inthe course lectures, to reduce the feasible solution pool into smaller sections, and finds integer valuesfrom the reduced sections. The current minimum integer solution is called the incumbent value. The results of our CPLEX implementation is presented in the columns 7 and 8 of Table 1. The boldedtexts indicate the guaranteed optimum solutions obtained by CPLEX and unbolded texts indicate incumbentvalues obtained for the specified time frame. The magnitude of each input instances could be describedby the n,m,o values, and the problem instances could classified by the number of constraints and variablesgenerated by the ILP. It is noticeable that ILP optimizer performs well for smaller problem instances.The optimum values were guaranteed and execution time fell under 1 second. In larger problem instancesILP failed to ensure the optimization of the current incumbent. The execution time was in the range ofhundreds of seconds, and the change in execution time between smaller and larger instances is significant.
  • 5. 5 TABLE I C OMPARISON OF P ERFORMANCE AND E XECUTION T IME B ETWEEN ILP AND TS V. M ETAHEURISTICS I MPLEMENTATION - TABU S EARCH In this section, we describe the implementation of the Metaheuristic used for addressing this problem.Besides, we briefly describe the TabuCol algorithm which was used to solve the problem.Our metaheuristic works in two phases. The first one is looking for a Random Initial Solution, then theTabu Search is executed based on the initial solution.A. Random Initial Solution Algorithm 1 presents the procedure to find an initial feasible solution taking into account the capacityconstrains of the memory banks. The algorithm’s inputs are a graph G = (V, E) and a number of bankmemories (colors). The outputs are a feasible solution X ∗ and the cost of that solution f ∗ .Algorithm 1 Random Initial SolutionRequire: Graph G(V,E), k ←number of colors Initialization: Capacity used: uj ← 0, ∀j ∈ {1, . . . , m + 1} Allocation: x∗ ← 0, ∀i ∈ {1, . . . , n}, ∀j ∈ {1, . . . , m + 1} i,j f∗ ← 0 Assignment: for i = 1 → n do repeat Generate j at random in {1 . . . , m + 1} until uj + sj ≤ cj x∗ ← 1 i,j uj ← uj + si Compute gi,j , the cost generated from allocation the data i to memory bank j f ∗ ← f ∗ + gi,j end for return [X ∗ , f ∗ ]B. Tabu Search TS - TabuCol Tabu search is a metaheuristic that relies on a single local search procedure: it iteratively moves fromthe current solution to another one in its neighborhood. Generally, local search procedures stop when alocal optimum is found, then it becomes necessary to escape from the local optimum to explore otherregions of the search space. Besides, the local search is repeated a max number of iterations.
  • 6. 6 We introduce tabu search in Algorithm 2 which is based on TabuCol, an algorithm for graph coloringintroduced in [5]. The algorithm takes an initial solution X as input and looks for a X’s neighbor bestsolution until the cost of the new solution is better than the previous. However, if there is no a bettersolution, the algorithm iterates a fixed number of iterations which are controlled by the parameter maxIter.Algorithm 3 defines the how to find the neighbor’s solutions of solution X. A pair (i, j) means that datastructure i is in memory bank j. A move is a trio (i, h, j), this means that data structure i, which iscurrently in memory bank h is going to be moved to memory bank j. As a consequence, if the move(i, h, j) is performed, then the pair (i, h) is appended to the tabu list T. Thus, the tabu list contains thepairs that have been performed in the recent past and those movements remain in T a certain period(number of iterations).Algorithm 2 TabuCol Memory AllocationRequire: Graph G(V,E), k ←number of colors, Initial Solution X Initialization: Initiate T (TabuList) iter←0 f ∗ ← f (X) while iter ≤ maxIter and f (X) > 0 do generate neighbours Xi of X with move X → Xi ∈ T or f (Xi ) < f ∗ / Let X be the best neighbour generated Update tabu list T (introduce move X → X ) X←X f ∗ ← f (X ) iter ← iter + 1 end while return [X ∗ , f ∗ ]Algorithm 3 Finding a NeighborhoodRequire: Solution X Find non tabu min cost move (i, h, j), such that h = j and uj + si ≤ cj Check move on Tabulist T if move is not in T: Build the new solution X as follows then X ←X xj,h ← 0 xi,j ← 1 uj ← ui + sj uh ← uh − sj end if return [X , (i, h, j)] VI. O UTPUT C OMPARISON The graphs illustrated in Figure 1 shows the solution comparison of ILP and TS for smaller instances,and the execution time differences. The red columns represent results from TS, and blue columns representCPLEX. For the first four cases, although TS was able to provide the optimum values, its execution timewas longer than CPLEX. In the instance of queen6 6, the TS metaheauristics took much longer time thanCPLEX and provided a poor solution.
  • 7. 7Fig. 1. Comparison of Tabu Search and ILP for Smaller InstancesFig. 2. Comparison of Execution Time by Tabu Search and ILP Figure 2 shows the execution time comparison of TS and ILP, as the number of variables in a probleminstance increases. The blue columns represent the exact time in seconds that TS was able to providefeasible solution. The red columns represent the time in seconds that ILP was run, during which allinstances were able to find incumbent feasible solutions. It is easy to observe that although CPLEX showedbetter performance in smaller problem instances, TS performed significantly better in larger probleminstances.Fig. 3. Comparison of Solutions Obtained by Tabu Search and ILP The graphs illustrated in Figure 3 show the solution comparison obtained by both ILP and TS, as thenumber of variables in problem instances increase. The red columns in first graph represent the incumbentvalues from CPLEX. The second graph in Figure 3 shows the percent differences between solutions fromTS and ILP. For larger instances, the solutions provided by TS is within 20% range of those provided
  • 8. 8by ILP. In smaller instances, TS was able to perform as well as ILP, with one exception. This exceptioncase may be due to the fact that TS highly depends on the initial solution, as mentioned in Section V. VII. D ISCUSSIONS There are certain issues that must be taken into consideration when comparing the performances of TSmetaheauristic and ILP optimization. Firstly, it must be noted that the input data are DIMACs instancesenriched with random values, such as size and access times of data structures, memory capacities, andconflict costs. Real life input data may result in different execution times, and better feasible solutionpools. Secondly, the implemented metaheauristic is solely Tabu Search method. The resulting optimumvalues highly depend on the initial solution, hence in Figure 3 we were able to observe 60% differencein optimum values acquired from ILP and TS. It was mentioned during our presentation to increase thenumber of initial solutions for each TS run to improve the results from the metaheuristic. Also, it iscommon to implement TS with other metaheauristics to improve its performance. VIII. C ONCLUSIONS Optimum memory management in embedded systems is related to shorter runtimes of applications andreduced power consumption. The memory allocation problem is equivalent to k-weighted graph coloringproblem, which is a classic combinatorial optimization problem known to be solved by Tabu Searchheauristics technique, among other metaheauristics. In this paper, we approached the memory allocationproblem with exact optimization using ILP, and with Tabu Search metaheuristic method. Enriched graphcoloring instances from DIMACs were chosen to be executed by the two methods, and the output resultswere compared. The performance comparison showed that ILP performs well for smaller instances, whileperforming much worse as the magnitude of problem instances grew. In contrast, Tabu Search metaheuristicperformed consistently as the problem size scales up. R EFERENCES[1] “Graph coloring instances.” http://mat.gsia.cmu.edu/COLOR/instances.html.[2] M. Soto, “Optimization methods for the memory allocation problems in embedded systems,” 2011.[3] A. R. M. Soto and M. Sevaux, “A mathematical model and a metaheuristic approach for a memory allocation problem,” Springer Science and Business Media, 2011.[4] L. N. S. Wuytack, F. Catthoor and H. Man, “Power exploration for data dominated video applications,” in International Symposium on Low Power Electronics and Design, pp. 359–364, 1996.[5] A. Hertz and D. de Werra, “Using tabu search techniques for graph coloring,” Springer-Verlag Computing, no. 39, pp. 345–351, 1987.[6] M. Pagliari, “Heuristic tools: Tabucol, SA, variable neighborhood Search(VNS).” http://www.adaptivebox.net/CILib/code/gcpcodes link. html.