Compiling Dynamic Languages

Total Page:16

File Type:pdf, Size:1020Kb

Compiling Dynamic Languages Compiling Dynamic Languages Anders Schlichtkrull, Rasmus T. Tjalk-Bøggild Kongens Lyngby 2013 Compute-B.Sc.-2013-15 Technical University of Denmark Department of Applied Mathematics and Computer Science Matematiktorvet, Building 303 B, DK-2800 Kongens Lyngby, Denmark Phone +45 45253031 [email protected] http://www.compute.dtu.dk/ Compute-B.Sc.-2013-15 Abstract The purpose of this thesis is to examine if ahead-of-time compilation is a viable solution for executing programs written in Dynamic Languages when compared to interpretation and just-in-time compilation, and to find out how such a solu- tion can be made. We achieve this by first describing and classifying Dynamic Languages in terms of their type systems and programming concepts. Specifically we will show how the Dynamic Languages differ from Statically Typed Languages. We then build an ahead-of-time compiler, called the project compiler, for a sub- set of JavaScript. The subset is large enough to constitute a Dynamic Language and large enough to run an industry standard benchmark. The ahead-of-time compiler can also do optimizations. Furthermore, we benchmark this compiler implementation and compare it to the benchmark results for two contemporary JavaScript implementations: Rhino which is a JavaScript interpreter and com- piler, and V8 which is a JavaScript just-in-time compiler. We also profile the implementation to measure the effect of the implemented optimizations. Based on these results we find that the performance of the project compiler is better than that of the interpreter, but the performance is worse than that of the two other compilers. The performance of the project compiler is influenced negatively by its implementation of JavaScript values in memory. We also find that the implemented optimizations give significant performance benefits for simple examples, but do not improve the performance significantly when running more complex benchmarks. We conclude that ahead-of-time compilation is a viable alternative to interpre- ii tation of dynamic languages, but based on the collected results we are unable to make any generalizations with regards to ahead-of-time compilation compared to just-in-time compilation. Contribution of work We have both contributed equal amounts of work to the project. Acknowledgements We would like to thank our supervisors Christian W. Probst and Sven Karlsson for the chance to work on this project as well for their valuable input and feedback. We would also like to thank our families for their understanding and support throughout the project period. iv Contents Abstract i Acknowledgements iii 1 Introduction 1 2 Preliminaries and theory background 3 2.1 Dictionary . .3 2.2 Overview of Dynamic Languages . .6 2.2.1 Included languages . .6 2.2.2 JavaScript . .6 2.2.3 Python . .7 2.2.4 Ruby . .8 2.2.5 Perl . .8 2.2.6 PHP . .9 2.3 Common characteristics for Dynamic Languages . .9 2.4 A typical Compiler Design . 10 2.5 Special requirements for Dynamic Languages . 12 2.5.1 Delayed type checking . 12 2.5.2 Type coercion . 12 2.5.3 Closures . 12 2.5.4 Build-in data structures . 13 2.5.5 Garbage Collection . 13 2.5.6 Context . 13 2.6 Related works . 14 3 Analysis of the problem 17 3.1 Choice of output language . 17 3.2 Representing nested functions . 18 vi CONTENTS 3.3 Representing values and variables . 20 3.4 Representing objects . 21 3.5 Meta programming issues . 22 3.6 Garbage Collection . 23 3.7 Possible optimizations . 24 4 Implementation work 25 4.1 Compiler structure . 25 4.1.1 Phases included in the project compiler . 26 4.1.2 Lexing and parsing . 26 4.1.3 Context handling . 29 4.1.4 Intermediate code generation . 34 4.1.5 Translating TAC to IR . 40 4.1.6 Output code generation . 40 4.1.7 Build native executable . 40 4.1.8 Environments and values . 40 4.1.9 Operators . 44 4.1.10 Garbage Collector . 45 4.2 Implementation of optimizations . 46 4.3 Limitations of our implementation . 55 4.3.1 Lex and Parse level . 56 4.3.2 IR generation level . 56 4.4 Verification of the compiler . 64 4.5 Description of the tool . 65 5 Testing and performance analysis 67 5.1 Benchmark Design . 67 5.1.1 Comparison to contemporary implementations . 68 5.1.2 Measure the effect of optimizations . 68 5.2 Benchmark setup . 68 5.2.1 Chosen Benchmarks . 68 5.2.2 Benchmarking against contemporary implementations . 71 5.2.3 Measurements . 72 5.2.4 Profiling the optimizations we have made . 73 5.2.5 Machine . 73 5.2.6 Limitations of the benchmark setup . 74 5.3 Benchmark results . 77 5.3.1 Profiling the project compiler . 77 5.3.2 Results of optimizations . 82 5.3.3 Performance comparison between the project compiler and NodeJs . 83 5.3.4 Performance comparison between the project compiler and RingoJs . 89 5.3.5 Compile timings . 92 CONTENTS vii 5.4 The project compiler performance bottlenecks . 95 5.4.1 Object properties . 96 5.4.2 Garbage collection . 97 5.4.3 Run-time support . 99 6 Discussion 101 6.1 Compiler Implementation . 101 6.1.1 Compiler design . 102 6.2 Just-in-time compilation vs Ahead-of-time compilation in Dy- namic Languages . 102 6.2.1 Improving the project implementation . 103 6.2.2 Testing just-in-time vs ahead-of-time compilation models 104 7 Conclusions 105 7.1 Future work . 106 7.1.1 Performance improvements . 106 7.1.2 Compile timings . 107 A Appendix A - Benefits of Dynamic Languages 109 A.1 Primary arguments for the benefits of Dynamic Languages . 109 A.2 Examples of problems suitable for Dynamic Languages . 111 A.3 Context . 113 B Appendix B - Run-time Data 115 C Appendix C - Memory usage Data 125 D Appendix D - Compile time data 129 E Appendix E - Profiling data 131 F Appendix F - NodeJs data 141 F.1 NodeJs optimization flag scores . 141 F.2 NodeJs Garbage Collection data for DeltaBlue . 143 F.3 NodeJs profiling data for the DeltaBlue benchmark . 143 F.4 NodeJs assembly output . 148 G Appendix G - RingoJs compiler output 153 Bibliography 159 viii CONTENTS Chapter 1 Introduction Dynamic languages, and in particular JavaScript, are among the most widely used programming languages [Wel13] [Sof13] [Git13]. The dynamic languages have many features considered beneficial to the programmer such as a type system that does not impose restrictions on the types at compile time, easy access to data structures and concepts such as meta programming, higher-order functions and object oriented programming. Furthermore, the languages are used in many different contexts including web services, game scripting and rapid prototyping [OZPSG10]. Classically, dynamic languages have been interpreted, that is, evaluated at run- time by an interpreter program. In recent years, dynamic languages have also been complied, that is, translated to another language such as native code before being executed. In particular, the compilation model for translating the pro- gram to native machine code, known as just-in-time compilation has been used. In this model the compilation for a section of the program is performed just before it is used. This allows for faster start-up times than compiling the entire program ahead of time when a compiled version of the program is not available. These approaches especially make sense for executing JavaScript when used for client side web-programming, where it is important that the execution can start immediately. However, Dynamic languages, including Javascript, are also used on servers, 2 Introduction where the same code is run many times. For this purpose it would make sense to do the translation to native code only once, so that the run-time is only used on the actual execution of the program code. This technique is called ahead-of-time compilation. The purpose of the project is to build an ahead-of-time compiler for the dy- namic programming language JavaScript and measure the performance of this compiler against contemporary implementations. Specifically, the project will examine if ahead-of-time compilation is a viable solution when compared to both interpretation and just-in-time compilation. To do this, an overview of the major contemporary dynamic languages is given first. The languages are introduced with a specific focus on how they differ from statically typed languages as well as the special requirements that the dynamic languages have during compilation and run-time. JavaScript is then placed in this framework to describe how it fits among the dynamic languages. With JavaScript as the base, the major moving parts of a compiler is then analysed with a focus on how specific dynamic aspects of the language are translated. The actual implementation of these aspects in the project compiler is then de- scribed as well as how the optimization of the code is performed. Finally, the project compiler is benchmarked. Firstly, to measure the perfor- mance against contemporary implementations (both a JavaScript interpreter, a JavaScript ahead-of-time compiler and a JavaScript just-in-time compiler). Secondly, to measure the effect of the optimizations implemented. Based on these benchmarks we will evaluate the viability of the compiler when compared to contemporary JavaScript implementations. Chapter 2 Preliminaries and theory background This chapter will provide the theoretical background needed to understand the report. The central terms of the report will be defined in a dictionary. Fur- thermore it will give an overview of the subject of Dynamic Languages and compiling. 2.1 Dictionary The purpose of the dictionary is to establish unambiguous definitions of the central terms in this paper, to avoid the confusion sometimes associated with some of the terms.
Recommended publications
  • Metaheuristics1
    METAHEURISTICS1 Kenneth Sörensen University of Antwerp, Belgium Fred Glover University of Colorado and OptTek Systems, Inc., USA 1 Definition A metaheuristic is a high-level problem-independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic optimization algorithms (Sörensen and Glover, To appear). Notable examples of metaheuristics include genetic/evolutionary algorithms, tabu search, simulated annealing, and ant colony optimization, although many more exist. A problem-specific implementation of a heuristic optimization algorithm according to the guidelines expressed in a metaheuristic framework is also referred to as a metaheuristic. The term was coined by Glover (1986) and combines the Greek prefix meta- (metá, beyond in the sense of high-level) with heuristic (from the Greek heuriskein or euriskein, to search). Metaheuristic algorithms, i.e., optimization methods designed according to the strategies laid out in a metaheuristic framework, are — as the name suggests — always heuristic in nature. This fact distinguishes them from exact methods, that do come with a proof that the optimal solution will be found in a finite (although often prohibitively large) amount of time. Metaheuristics are therefore developed specifically to find a solution that is “good enough” in a computing time that is “small enough”. As a result, they are not subject to combinatorial explosion – the phenomenon where the computing time required to find the optimal solution of NP- hard problems increases as an exponential function of the problem size. Metaheuristics have been demonstrated by the scientific community to be a viable, and often superior, alternative to more traditional (exact) methods of mixed- integer optimization such as branch and bound and dynamic programming.
    [Show full text]
  • Lecture 4 Dynamic Programming
    1/17 Lecture 4 Dynamic Programming Last update: Jan 19, 2021 References: Algorithms, Jeff Erickson, Chapter 3. Algorithms, Gopal Pandurangan, Chapter 6. Dynamic Programming 2/17 Backtracking is incredible powerful in solving all kinds of hard prob- lems, but it can often be very slow; usually exponential. Example: Fibonacci numbers is defined as recurrence: 0 if n = 0 Fn =8 1 if n = 1 > Fn 1 + Fn 2 otherwise < ¡ ¡ > A direct translation in:to recursive program to compute Fibonacci number is RecFib(n): if n=0 return 0 if n=1 return 1 return RecFib(n-1) + RecFib(n-2) Fibonacci Number 3/17 The recursive program has horrible time complexity. How bad? Let's try to compute. Denote T(n) as the time complexity of computing RecFib(n). Based on the recursion, we have the recurrence: T(n) = T(n 1) + T(n 2) + 1; T(0) = T(1) = 1 ¡ ¡ Solving this recurrence, we get p5 + 1 T(n) = O(n); = 1.618 2 So the RecFib(n) program runs at exponential time complexity. RecFib Recursion Tree 4/17 Intuitively, why RecFib() runs exponentially slow. Problem: redun- dant computation! How about memorize the intermediate computa- tion result to avoid recomputation? Fib: Memoization 5/17 To optimize the performance of RecFib, we can memorize the inter- mediate Fn into some kind of cache, and look it up when we need it again. MemFib(n): if n = 0 n = 1 retujrjn n if F[n] is undefined F[n] MemFib(n-1)+MemFib(n-2) retur n F[n] How much does it improve upon RecFib()? Assuming accessing F[n] takes constant time, then at most n additions will be performed (we never recompute).
    [Show full text]
  • Chapter 1 Introduction to Computers, Programs, and Java
    Chapter 1 Introduction to Computers, Programs, and Java 1.1 Introduction • The central theme of this book is to learn how to solve problems by writing a program . • This book teaches you how to create programs by using the Java programming languages . • Java is the Internet program language • Why Java? The answer is that Java enables user to deploy applications on the Internet for servers , desktop computers , and small hand-held devices . 1.2 What is a Computer? • A computer is an electronic device that stores and processes data. • A computer includes both hardware and software. o Hardware is the physical aspect of the computer that can be seen. o Software is the invisible instructions that control the hardware and make it work. • Computer programming consists of writing instructions for computers to perform. • A computer consists of the following hardware components o CPU (Central Processing Unit) o Memory (Main memory) o Storage Devices (hard disk, floppy disk, CDs) o Input/Output devices (monitor, printer, keyboard, mouse) o Communication devices (Modem, NIC (Network Interface Card)). Bus Storage Communication Input Output Memory CPU Devices Devices Devices Devices e.g., Disk, CD, e.g., Modem, e.g., Keyboard, e.g., Monitor, and Tape and NIC Mouse Printer FIGURE 1.1 A computer consists of a CPU, memory, Hard disk, floppy disk, monitor, printer, and communication devices. CMPS161 Class Notes (Chap 01) Page 1 / 15 Kuo-pao Yang 1.2.1 Central Processing Unit (CPU) • The central processing unit (CPU) is the brain of a computer. • It retrieves instructions from memory and executes them.
    [Show full text]
  • Dynamic Programming Via Static Incrementalization 1 Introduction
    Dynamic Programming via Static Incrementalization Yanhong A. Liu and Scott D. Stoller Abstract Dynamic programming is an imp ortant algorithm design technique. It is used for solving problems whose solutions involve recursively solving subproblems that share subsubproblems. While a straightforward recursive program solves common subsubproblems rep eatedly and of- ten takes exp onential time, a dynamic programming algorithm solves every subsubproblem just once, saves the result, reuses it when the subsubproblem is encountered again, and takes p oly- nomial time. This pap er describ es a systematic metho d for transforming programs written as straightforward recursions into programs that use dynamic programming. The metho d extends the original program to cache all p ossibly computed values, incrementalizes the extended pro- gram with resp ect to an input increment to use and maintain all cached results, prunes out cached results that are not used in the incremental computation, and uses the resulting in- cremental program to form an optimized new program. Incrementalization statically exploits semantics of b oth control structures and data structures and maintains as invariants equalities characterizing cached results. The principle underlying incrementalization is general for achiev- ing drastic program sp eedups. Compared with previous metho ds that p erform memoization or tabulation, the metho d based on incrementalization is more powerful and systematic. It has b een implemented and applied to numerous problems and succeeded on all of them. 1 Intro duction Dynamic programming is an imp ortant technique for designing ecient algorithms [2, 44 , 13 ]. It is used for problems whose solutions involve recursively solving subproblems that overlap.
    [Show full text]
  • Automatic Code Generation Using Dynamic Programming Techniques
    ! Automatic Code Generation using Dynamic Programming Techniques MASTERARBEIT zur Erlangung des akademischen Grades Diplom-Ingenieur im Masterstudium INFORMATIK Eingereicht von: Igor Böhm, 0155477 Angefertigt am: Institut für System Software Betreuung: o.Univ.-Prof.Dipl.-Ing. Dr. Dr.h.c. Hanspeter Mössenböck Linz, Oktober 2007 Abstract Building compiler back ends from declarative specifications that map tree structured intermediate representations onto target machine code is the topic of this thesis. Although many tools and approaches have been devised to tackle the problem of automated code generation, there is still room for improvement. In this context we present Hburg, an implementation of a code generator generator that emits compiler back ends from concise tree pattern specifications written in our code generator description language. The language features attribute grammar style specifications and allows for great flexibility with respect to the placement of semantic actions. Our main contribution is to show that these language features can be integrated into automatically generated code generators that perform optimal instruction selection based on tree pattern matching combined with dynamic program- ming. In order to substantiate claims about the usefulness of our language we provide two complete examples that demonstrate how to specify code generators for Risc and Cisc architectures. Kurzfassung Diese Diplomarbeit beschreibt Hburg, ein Werkzeug das aus einer Spezi- fikation des abstrakten Syntaxbaums eines Programms und der Spezifika- tion der gewuns¨ chten Zielmaschine automatisch einen Codegenerator fur¨ diese Maschine erzeugt. Abbildungen zwischen abstrakten Syntaxb¨aumen und einer Zielmaschine werden durch Baummuster definiert. Fur¨ diesen Zweck haben wir eine deklarative Beschreibungssprache entwickelt, die es erm¨oglicht den Baummustern Attribute beizugeben, wodurch diese gleich- sam parametrisiert werden k¨onnen.
    [Show full text]
  • Language Translators
    Student Notes Theory LANGUAGE TRANSLATORS A. HIGH AND LOW LEVEL LANGUAGES Programming languages Low – Level Languages High-Level Languages Example: Assembly Language Example: Pascal, Basic, Java Characteristics of LOW Level Languages: They are machine oriented : an assembly language program written for one machine will not work on any other type of machine unless they happen to use the same processor chip. Each assembly language statement generally translates into one machine code instruction, therefore the program becomes long and time-consuming to create. Example: 10100101 01110001 LDA &71 01101001 00000001 ADD #&01 10000101 01110001 STA &71 Characteristics of HIGH Level Languages: They are not machine oriented: in theory they are portable , meaning that a program written for one machine will run on any other machine for which the appropriate compiler or interpreter is available. They are problem oriented: most high level languages have structures and facilities appropriate to a particular use or type of problem. For example, FORTRAN was developed for use in solving mathematical problems. Some languages, such as PASCAL were developed as general-purpose languages. Statements in high-level languages usually resemble English sentences or mathematical expressions and these languages tend to be easier to learn and understand than assembly language. Each statement in a high level language will be translated into several machine code instructions. Example: number:= number + 1; 10100101 01110001 01101001 00000001 10000101 01110001 B. GENERATIONS OF PROGRAMMING LANGUAGES 4th generation 4GLs 3rd generation High Level Languages 2nd generation Low-level Languages 1st generation Machine Code Page 1 of 5 K Aquilina Student Notes Theory 1. MACHINE LANGUAGE – 1ST GENERATION In the early days of computer programming all programs had to be written in machine code.
    [Show full text]
  • 1 Introduction 2 Dijkstra's Algorithm
    15-451/651: Design & Analysis of Algorithms September 3, 2019 Lecture #3: Dynamic Programming II last changed: August 30, 2019 In this lecture we continue our discussion of dynamic programming, focusing on using it for a variety of path-finding problems in graphs. Topics in this lecture include: • The Bellman-Ford algorithm for single-source (or single-sink) shortest paths. • Matrix-product algorithms for all-pairs shortest paths. • Algorithms for all-pairs shortest paths, including Floyd-Warshall and Johnson. • Dynamic programming for the Travelling Salesperson Problem (TSP). 1 Introduction As a reminder of basic terminology: a graph is a set of nodes or vertices, with edges between some of the nodes. We will use V to denote the set of vertices and E to denote the set of edges. If there is an edge between two vertices, we call them neighbors. The degree of a vertex is the number of neighbors it has. Unless otherwise specified, we will not allow self-loops or multi-edges (multiple edges between the same pair of nodes). As is standard with discussing graphs, we will use n = jV j, and m = jEj, and we will let V = f1; : : : ; ng. The above describes an undirected graph. In a directed graph, each edge now has a direction (and as we said earlier, we will sometimes call the edges in a directed graph arcs). For each node, we can now talk about out-neighbors (and out-degree) and in-neighbors (and in-degree). In a directed graph you may have both an edge from u to v and an edge from v to u.
    [Show full text]
  • Language and Compiler Support for Dynamic Code Generation by Massimiliano A
    Language and Compiler Support for Dynamic Code Generation by Massimiliano A. Poletto S.B., Massachusetts Institute of Technology (1995) M.Eng., Massachusetts Institute of Technology (1995) Submitted to the Department of Electrical Engineering and Computer Science in partial fulfillment of the requirements for the degree of Doctor of Philosophy at the MASSACHUSETTS INSTITUTE OF TECHNOLOGY September 1999 © Massachusetts Institute of Technology 1999. All rights reserved. A u th or ............................................................................ Department of Electrical Engineering and Computer Science June 23, 1999 Certified by...............,. ...*V .,., . .* N . .. .*. *.* . -. *.... M. Frans Kaashoek Associate Pro essor of Electrical Engineering and Computer Science Thesis Supervisor A ccepted by ................ ..... ............ ............................. Arthur C. Smith Chairman, Departmental CommitteA on Graduate Students me 2 Language and Compiler Support for Dynamic Code Generation by Massimiliano A. Poletto Submitted to the Department of Electrical Engineering and Computer Science on June 23, 1999, in partial fulfillment of the requirements for the degree of Doctor of Philosophy Abstract Dynamic code generation, also called run-time code generation or dynamic compilation, is the cre- ation of executable code for an application while that application is running. Dynamic compilation can significantly improve the performance of software by giving the compiler access to run-time infor- mation that is not available to a traditional static compiler. A well-designed programming interface to dynamic compilation can also simplify the creation of important classes of computer programs. Until recently, however, no system combined efficient dynamic generation of high-performance code with a powerful and portable language interface. This thesis describes a system that meets these requirements, and discusses several applications of dynamic compilation.
    [Show full text]
  • Bellman-Ford Algorithm
    The many cases offinding shortest paths Dynamic programming Bellman-Ford algorithm We’ve already seen how to calculate the shortest path in an Tyler Moore unweighted graph (BFS traversal) We’ll now study how to compute the shortest path in different CSE 3353, SMU, Dallas, TX circumstances for weighted graphs Lecture 18 1 Single-source shortest path on a weighted DAG 2 Single-source shortest path on a weighted graph with nonnegative weights (Dijkstra’s algorithm) 3 Single-source shortest path on a weighted graph including negative weights (Bellman-Ford algorithm) Some slides created by or adapted from Dr. Kevin Wayne. For more information see http://www.cs.princeton.edu/~wayne/kleinberg-tardos. Some code reused from Python Algorithms by Magnus Lie Hetland. 2 / 13 �������������� Shortest path problem. Given a digraph ����������, with arbitrary edge 6. DYNAMIC PROGRAMMING II weights or costs ���, find cheapest path from node � to node �. ‣ sequence alignment ‣ Hirschberg's algorithm ‣ Bellman-Ford 1 -3 3 5 ‣ distance vector protocols 4 12 �������� 0 -5 ‣ negative cycles in a digraph 8 7 7 2 9 9 -1 1 11 ����������� 5 5 -3 13 4 10 6 ������������� ���������������������������������� 22 3 / 13 4 / 13 �������������������������������� ��������������� Dijkstra. Can fail if negative edge weights. Def. A negative cycle is a directed cycle such that the sum of its edge weights is negative. s 2 u 1 3 v -8 w 5 -3 -3 Reweighting. Adding a constant to every edge weight can fail. 4 -4 u 5 5 2 2 ���������������������� c(W) = ce < 0 t s e W 6 6 �∈ 3 3 0 v -3 w 23 24 5 / 13 6 / 13 ���������������������������������� ���������������������������������� Lemma 1.
    [Show full text]
  • Notes on Dynamic Programming Algorithms & Data Structures 1
    Notes on Dynamic Programming Algorithms & Data Structures Dr Mary Cryan These notes are to accompany lectures 10 and 11 of ADS. 1 Introduction The technique of Dynamic Programming (DP) could be described “recursion turned upside-down”. However, it is not usually used as an alternative to recursion. Rather, dynamic programming is used (if possible) for cases when a recurrence for an algorithmic problem will not run in polynomial-time if it is implemented recursively. So in fact Dynamic Programming is a more- powerful technique than basic Divide-and-Conquer. Designing, Analysing and Implementing a dynamic programming algorithm is (like Divide- and-Conquer) highly problem specific. However, there are particular features shared by most dynamic programming algorithms, and we describe them below on page 2 (dp1(a), dp1(b), dp2, dp3). It will be helpful to carry along an introductory example-problem to illustrate these fea- tures. The introductory problem will be the problem of computing the nth Fibonacci number, where F(n) is defined as follows: F0 = 0; F1 = 1; Fn = Fn-1 + Fn-2 (for n ≥ 2). Since Fibonacci numbers are defined recursively, the definition suggests a very natural recursive algorithm to compute F(n): Algorithm REC-FIB(n) 1. if n = 0 then 2. return 0 3. else if n = 1 then 4. return 1 5. else 6. return REC-FIB(n - 1) + REC-FIB(n - 2) First note that were we to implement REC-FIB, we would not be able to use the Master Theo- rem to analyse its running-time. The recurrence for the running-time TREC-FIB(n) that we would get would be TREC-FIB(n) = TREC-FIB(n - 1) + TREC-FIB(n - 2) + Θ(1); (1) where the Θ(1) comes from the fact that, at most, we have to do enough work to add two values together (on line 6).
    [Show full text]
  • Parallel Technique for the Metaheuristic Algorithms Using Devoted Local Search and Manipulating the Solutions Space
    applied sciences Article Parallel Technique for the Metaheuristic Algorithms Using Devoted Local Search and Manipulating the Solutions Space Dawid Połap 1,* ID , Karolina K˛esik 1, Marcin Wo´zniak 1 ID and Robertas Damaševiˇcius 2 ID 1 Institute of Mathematics, Silesian University of Technology, Kaszubska 23, 44-100 Gliwice, Poland; [email protected] (K.K.); [email protected] (M.W.) 2 Department of Software Engineering, Kaunas University of Technology, Studentu 50, LT-51368, Kaunas, Lithuania; [email protected] * Correspondence: [email protected] Received: 16 December 2017; Accepted: 13 February 2018 ; Published: 16 February 2018 Abstract: The increasing exploration of alternative methods for solving optimization problems causes that parallelization and modification of the existing algorithms are necessary. Obtaining the right solution using the meta-heuristic algorithm may require long operating time or a large number of iterations or individuals in a population. The higher the number, the longer the operation time. In order to minimize not only the time, but also the value of the parameters we suggest three proposition to increase the efficiency of classical methods. The first one is to use the method of searching through the neighborhood in order to minimize the solution space exploration. Moreover, task distribution between threads and CPU cores can affect the speed of the algorithm and therefore make it work more efficiently. The second proposition involves manipulating the solutions space to minimize the number of calculations. In addition, the third proposition is the combination of the previous two. All propositions has been described, tested and analyzed due to the use of various test functions.
    [Show full text]
  • Complete Code Generation from UML State Machine
    Complete Code Generation from UML State Machine Van Cam Pham, Ansgar Radermacher, Sebastien´ Gerard´ and Shuai Li CEA, LIST, Laboratory of Model Driven Engineering for Embedded Systems, P.C. 174, Gif-sur-Yvette, 91191, France Keywords: UML State Machine, Code Generation, Semantics-conformance, Efficiency, Events, C++. Abstract: An event-driven architecture is a useful way to design and implement complex systems. The UML State Machine and its visualizations are a powerful means to the modeling of the logical behavior of such an archi- tecture. In Model Driven Engineering, executable code can be automatically generated from state machines. However, existing generation approaches and tools from UML State Machines are still limited to simple cases, especially when considering concurrency and pseudo states such as history, junction, and event types. This paper provides a pattern and tool for complete and efficient code generation approach from UML State Ma- chine. It extends IF-ELSE-SWITCH constructions of programming languages with concurrency support. The code generated with our approach has been executed with a set of state-machine examples that are part of a test-suite described in the recent OMG standard Precise Semantics Of State Machine. The traced execution results comply with the standard and are a good hint that the execution is semantically correct. The generated code is also efficient: it supports multi-thread-based concurrency, and the (static and dynamic) efficiency of generated code is improved compared to considered approaches. 1 INTRODUCTION Completeness: Existing tools and approaches mainly focus on the sequential aspect while the concurrency The UML State Machine (USM) (Specification and of state machines is limitedly supported.
    [Show full text]