Bringing Next Generation C++ to Gpus

Total Page:16

File Type:pdf, Size:1020Kb

Bringing Next Generation C++ to Gpus Bringing Next Generation C++ to GPUs Michael Haidl1, Michel Steuwer2, Lars Klein1 and Sergei Gorlatch1 1University of Muenster, Germany 2University of Edinburgh, UK The Problem: Dot Product std::vector<int> a(N), b(N), tmp(N); std::transform(a.begin(), a.end(), b.begin(), tmp.begin(), std::multiplies<int>()); auto result = std::accumulate(tmp.begin(), tmp.end(), 0, std::plus<int>()); • The STL is the C++ programmers swiss knife • STL containers, iterators and algorithms introduce a high-level of abstraction • Since C++17 it is also parallel 1 The Problem: Dot Product std::vector<int> a(N), b(N), tmp(N); std::transform(a.begin(), a.end(), b.begin(), tmp.begin(), std::multiplies<int>()); auto result = std::accumulate(tmp.begin(), tmp.end(), 0, std::plus<int>()); f1.hpp f2.hpp template<typename T> template<typename T> auto mult(const std::vector<T>& a auto sum(const std::vector<T>& a){ const std::vector<T>& b){ return std::accumulate(a.begin(), std::vector<T> tmp(a.size()); a.end(), T(), std::plus<T>()); std::transform(a.begin(), a.end(), } b.begin(), tmp.begin(), std::multiplies<T>()); return tmp; } 1 The Problem: Dot Product std::vector<int> a(N), b(N); auto result = sum(mult(a, b)); f1.hpp f2.hpp template<typename T> template<typename T> auto mult(const std::vector<T>& a auto sum(const std::vector<T>& a){ const std::vector<T>& b){ return std::accumulate(a.begin(), std::vector<T> tmp(a.size()); a.end(), T(), std::plus<T>()); std::transform(a.begin(), a.end(), } b.begin(), tmp.begin(), std::multiplies<T>()); return tmp; } 1 f1.hpp f2.hpp The Problem: Dot Product std::vector<int> a(N), b(N); auto result = sum(mult(a, b)); 40 Performance: 20 template<typename T> template<typename T> auto mult(const std::vector<T>& a auto sum(const std::vector<T>& a){ • vectors of size 25600000 Runtime (ms) const std::vector<T>& b){ return std::accumulate(a.begin(), std::vector<T> tmp(a.size()); a.end(), T(), std::plus<T>()); • Clang/LLVM std::transform(a.begin(), 5.0.0svn -O3 optimizeda.end(), } b.begin(), tmp.begin(), 0 std::multiplies<T>()); transform/accumulatetransform/accumulate*inner_product return tmp; } * LLVM patched with extended D17386 (loop fusion) 1 The Problem: Dot Product on GPUs thrust::device_vector<int> a(N), b(N), tmp(N); thrust::transform(a.begin(), a.end(), b.begin(), tmp.begin(), thrust::multiplies<int>()); auto result = thrust::reduce(tmp.begin(), tmp.end(), 0, thrust::plus<int>()); • Highly tuned STL-like library for GPU programming • Thrust offers containers, iterators and algorithms • Based on CUDA 2 The Problem: Dot Product on GPUs thrust::device_vector<int> a(N), b(N), tmp(N); thrust::transform(a.begin(), a.end(), b.begin(), tmp.begin(), thrust::multiplies<int>()); auto result = thrust::reduce(tmp.begin(), tmp.end(), 0, thrust::plus<int>()); • Highly tuned STL-like library for GPU programming • Thrust offers containers, iterators and algorithms • Based on CUDA 30 20 Same Experiment: 10 • nvcc -O3 (from CUDA 8.0) Runtime (ms) 0 transform/reduce inner_product 2 The Next Generation: Ranges for the STL • range-v3 prototype implementation by E. Niebler • Proposed as N4560 for the C++ Standard std::vector<int> a(N), b(N); auto mult = [](auto tpl){ return get<0>(tpl)* get<1>(tpl); }; auto result = accumulate(view::transform(view::zip(a, b), mult), 0); 3 The Next Generation: Ranges for the STL std::vector<int> a(N), b(N); auto mult = [](auto tpl){ return get<0>(tpl)* get<1>(tpl); }; auto result = accumulate(view::transform(view::zip(a, b), mult), 0); 40 Performance? 20 • Clang/LLVM 5.0.0svn -O3 optimized Runtime (ms) 0 transform/accumulateinner_product 3 The Next Generation: Ranges for the STL std::vector<int> a(N), b(N); auto mult = [](auto tpl){ return get<0>(tpl)* get<1>(tpl); }; auto result = accumulate(view::transform(view::zip(a, b), mult), 0); • Views describe lazy, non-mutating operations on ranges • Evaluation happens inside an algorithm (e.g., accumulate) • Fusion is guaranteed by the implementation 3 Ranges for GPUs • Extended range-v3 with GPU-enabled container and algorithms • Original code of range-v3 remains unmodified std::vector<int> a(N), b(N); auto mult = [](auto tpl){ return get<0>(tpl)* get<1>(tpl); }; auto ga = gpu::copy(a); auto gb = gpu::copy(b); auto result = gpu::reduce(view::transform(view::zip(ga, gb), mult), 0); 4 Programming Accelerators with C++ (PACXX) Offline Stage Executable PACXX PACXX Runtime Offline Compiler Online Stage Clang Frontend LLVM-based LLVM Onlineonline Compiler compiler IR LLVM libc++ OpenCL CUDA LLVM IR to SPIR NVPTX Backend Backend SPIR PTX #include <algorithm> #include <vector> #include <iostream> template< class ForwardIt, class T > void fill(ForwardIt first, ForwardIt last, C++const T& value) { OpenCL Runtime CUDA Runtime for (; first != last; ++first) { *first = value; } AMD GPU Intel MIC Nvidia GPU } • Based entirely on LLVM / Clang • Supports C++14 for GPU Programming • Just-In-Time Compilation of LLVM IR for target accelerators 5 Multi-Stage Programming template <typename InRng, typename T, typename Fun> auto reduce(InRng&& in, T init, Fun&& fun){ // 1. preparation of kernel call ... // 2. create GPU kernel auto kernel = pacxx::kernel( [fun](auto&& in, auto&& out, int size, auto init){ // 2a. stage elements per thread auto ept = stage([&]{ return size / get_block_size(0); }); // 2b. start reduction computation auto sum = init; for (int x = 0; x < ept; ++x){ sum = fun(sum, *(in + gid)); gid += glbSize;} // 2c. perform reduction in shared memory ... // 2d. write result back if (lid = 0) *(out + bid) = shared[0]; }, blocks, threads); // 3. execute kernel kernel(in, out, distance(in), init); // 4. finish reduction on the CPU return std::accumulate(out, init, fun); } 6 MSP Integration into PACXX Executable PACXX Runtime PACXX MSP MSP Engine Offline Compiler IR Clang Frontend LLVM-based KERNEL online compiler IR LLVM libc++ OpenCL CUDA LLVM IR to SPIR NVPTX Backend Backend SPIR PTX #include <algorithm> #include <vector> #include <iostream> template< class ForwardIt, class T > void fill(ForwardIt first, ForwardIt last, C++const T& value) { OpenCL Runtime CUDA Runtime for (; first != last; ++first) { *first = value; } AMD GPU Intel MIC Nvidia GPU } • MSP Engine JIT compiles the MSP IR, • evaluates stage prior to a kernel launch, and • replaces the calls to stage in the kernel’s IR with the results. • Enables more optimizations (e.g., loop-unrolling) in the online stage. 7 Performance Impact of MSP gpu::reduce on Nvidia K20c 1.4 Dot 1.35 Sum Dot +MS Sum +MS 1.3 1.25 1.2 1.15 Speedup 1.1 1.05 1 0.95 0.9 215 217 219 221 223 225 Input Size Up to 35% better performance compared to non-MSP version 8 Just-In-Time Compilation Overhead Comparing MSP in PACXX with Nvidia’s nvrtc library 450 CUDA 7.5 CUDA 8.0 RC 400 PACXX 350 300 250 200 150 Compilation Time (ms) 100 50 0 Dot Sum 10 to 20 times faster because front-end actions are performed. 9 Benchmarks range-v3 + PACXX vs. Nvidia’s Thrust 2 82:32% Thrust 73:31% PACXX 1:5 33:6% 8:37% 1:61% −3:13% 1 −7:38% Speedup 0:5 vadd saxpy sum dot Monte CarloMandelbrotVoronoi • Evaluated on a Nvidia K20c GPU • 11 different input sizes • 1000 runs for each benchmark Competitive performance with a composable GPU programming API 10 Going Native: Work in Progress Executable PACXX Runtime PACXX MSP MSP Engine Offline Compiler IR Clang Frontend LLVM-based KERNEL online compiler IR WFV LLVM libc++ OpenCL LLVM IR [1] CUDA NVPTX Backend to SPIR MCJIT Backend SPIR PTX #include <algorithm> #include <vector> #include <iostream> template< class ForwardIt, class T > void fill(ForwardIt first, ForwardIt last, C++const T& value) { OpenCL Runtime CUDA Runtime for (; first != last; ++first) { *first = value; } AMD GPU Intel MIC CPUs: Intel / AMD / IBM ... Nvidia GPU } • PACXX is extended by a native CPU backend • The Kernel IR is modified to be runnable on a CPU • Kernels are vectorized by the Whole Function Vectorizer (WFV) [1] • MCJIT compiles the kernels and TBB executes them in parallel. 11 [1] Karrenberg, Ralf, and Sebastian Hack. ”Whole-Function Vectorization.” @ CGO’11, pp. 141–150 Benchmarks range-v3 + PACXX vs. OpenCL on x86_64 2 OpenCL (Intel) 1:5 PACXX −1:45% −13:94% −12:64% 1 −20:02% −36:48% Speedup 0:5 0 vadd saxpy sum dot Mandelbrot • Running on 2x Intel Xeon E5-2620 CPUs • Intel’s auto-vectorizer optimizes the OpenCL C code 12 Benchmarks range-v3 + PACXX vs. OpenCL on x86_64 3 OpenCL (AMD) 153:82% PACXX 2 58:12% 58:45% Speedup 1 vadd saxpy sum dot Mandelbrot • Running on 2x Intel Xeon E5-2620 CPUs • AMD OpenCL SDK has no auto-vectorizer • Barriers are very expensive in AMD’s OpenCL implementation (speedup up to 126x for sum) 13 Benchmarks range-v3 + PACXX vs. OpenMP on IBM Power8 2 OpenMP (IBM) PACXX 1:5 35:09% 17:97% 0:45% 1 Speedup −20:05% −42:95% 0:5 vadd saxpy sum dot Mandelbrot • Running on a PowerNV 8247-42L with 4x IBM Power8e CPUs • No OpenCL implementation from IBM available • #prama omp parallel for simd parallelized loops • Compiled with XL C++ 13.1.5 14 Questions? 14.
Recommended publications
  • The LLVM Instruction Set and Compilation Strategy
    The LLVM Instruction Set and Compilation Strategy Chris Lattner Vikram Adve University of Illinois at Urbana-Champaign lattner,vadve ¡ @cs.uiuc.edu Abstract This document introduces the LLVM compiler infrastructure and instruction set, a simple approach that enables sophisticated code transformations at link time, runtime, and in the field. It is a pragmatic approach to compilation, interfering with programmers and tools as little as possible, while still retaining extensive high-level information from source-level compilers for later stages of an application’s lifetime. We describe the LLVM instruction set, the design of the LLVM system, and some of its key components. 1 Introduction Modern programming languages and software practices aim to support more reliable, flexible, and powerful software applications, increase programmer productivity, and provide higher level semantic information to the compiler. Un- fortunately, traditional approaches to compilation either fail to extract sufficient performance from the program (by not using interprocedural analysis or profile information) or interfere with the build process substantially (by requiring build scripts to be modified for either profiling or interprocedural optimization). Furthermore, they do not support optimization either at runtime or after an application has been installed at an end-user’s site, when the most relevant information about actual usage patterns would be available. The LLVM Compilation Strategy is designed to enable effective multi-stage optimization (at compile-time, link-time, runtime, and offline) and more effective profile-driven optimization, and to do so without changes to the traditional build process or programmer intervention. LLVM (Low Level Virtual Machine) is a compilation strategy that uses a low-level virtual instruction set with rich type information as a common code representation for all phases of compilation.
    [Show full text]
  • What Is LLVM? and a Status Update
    What is LLVM? And a Status Update. Approved for public release Hal Finkel Leadership Computing Facility Argonne National Laboratory Clang, LLVM, etc. ✔ LLVM is a liberally-licensed(*) infrastructure for creating compilers, other toolchain components, and JIT compilation engines. ✔ Clang is a modern C++ frontend for LLVM ✔ LLVM and Clang will play significant roles in exascale computing systems! (*) Now under the Apache 2 license with the LLVM Exception LLVM/Clang is both a research platform and a production-quality compiler. 2 A role in exascale? Current/Future HPC vendors are already involved (plus many others)... Apple + Google Intel (Many millions invested annually) + many others (Qualcomm, Sony, Microsoft, Facebook, Ericcson, etc.) ARM LLVM IBM Cray NVIDIA (and PGI) Academia, Labs, etc. AMD 3 What is LLVM: LLVM is a multi-architecture infrastructure for constructing compilers and other toolchain components. LLVM is not a “low-level virtual machine”! LLVM IR Architecture-independent simplification Architecture-aware optimization (e.g. vectorization) Assembly printing, binary generation, or JIT execution Backends (Type legalization, instruction selection, register allocation, etc.) 4 What is Clang: LLVM IR Clang is a C++ frontend for LLVM... Code generation Parsing and C++ Source semantic analysis (C++14, C11, etc.) Static analysis ● For basic compilation, Clang works just like gcc – using clang instead of gcc, or clang++ instead of g++, in your makefile will likely “just work.” ● Clang has a scalable LTO, check out: https://clang.llvm.org/docs/ThinLTO.html 5 The core LLVM compiler-infrastructure components are one of the subprojects in the LLVM project. These components are also referred to as “LLVM.” 6 What About Flang? ● Started as a collaboration between DOE and NVIDIA/PGI.
    [Show full text]
  • CUDA Flux: a Lightweight Instruction Profiler for CUDA Applications
    CUDA Flux: A Lightweight Instruction Profiler for CUDA Applications Lorenz Braun Holger Froning¨ Institute of Computer Engineering Institute of Computer Engineering Heidelberg University Heidelberg University Heidelberg, Germany Heidelberg, Germany [email protected] [email protected] Abstract—GPUs are powerful, massively parallel processors, hardware, it lacks verbosity when it comes to analyzing the which require a vast amount of thread parallelism to keep their different types of instructions executed. This problem is aggra- thousands of execution units busy, and to tolerate latency when vated by the recently frequent introduction of new instructions, accessing its high-throughput memory system. Understanding the behavior of massively threaded GPU programs can be for instance floating point operations with reduced precision difficult, even though recent GPUs provide an abundance of or special function operations including Tensor Cores for ma- hardware performance counters, which collect statistics about chine learning. Similarly, information on the use of vectorized certain events. Profiling tools that assist the user in such analysis operations is often lost. Characterizing workloads on PTX for their GPUs, like NVIDIA’s nvprof and cupti, are state-of- level is desirable as PTX allows us to determine the exact types the-art. However, instrumentation based on reading hardware performance counters can be slow, in particular when the number of the instructions a kernel executes. On the contrary, nvprof of metrics is large. Furthermore, the results can be inaccurate as metrics are based on a lower-level representation called SASS. instructions are grouped to match the available set of hardware Still, even if there was an exact mapping, some information on counters.
    [Show full text]
  • Implementing Continuation Based Language in LLVM and Clang
    Implementing Continuation based language in LLVM and Clang Kaito TOKUMORI Shinji KONO University of the Ryukyus University of the Ryukyus Email: [email protected] Email: [email protected] Abstract—The programming paradigm which use data seg- 1 __code f(Allocate allocate){ 2 allocate.size = 0; ments and code segments are proposed. This paradigm uses 3 goto g(allocate); Continuation based C (CbC), which a slight modified C language. 4 } 5 Code segments are units of calculation and Data segments are 6 // data segment definition sets of typed data. We use these segments as units of computation 7 // (generated automatically) 8 union Data { and meta computation. In this paper we show the implementation 9 struct Allocate { of CbC on LLVM and Clang 3.7. 10 long size; 11 } allocate; 12 }; I. A PRACTICAL CONTINUATION BASED LANGUAGE TABLE I The proposed units of programming are named code seg- CBCEXAMPLE ments and data segments. Code segments are units of calcu- lation which have no state. Data segments are sets of typed data. Code segments are connected to data segments by a meta data segment called a context. After the execution of a code have input data segments and output data segments. Data segment and its context, the next code segment (continuation) segments have two kind of dependency with code segments. is executed. First, Code segments access the contents of data segments Continuation based C (CbC) [1], hereafter referred to as using field names. So data segments should have the named CbC, is a slight modified C which supports code segments.
    [Show full text]
  • Code Transformation and Analysis Using Clang and LLVM Static and Dynamic Analysis
    Code transformation and analysis using Clang and LLVM Static and Dynamic Analysis Hal Finkel1 and G´abor Horv´ath2 Computer Science Summer School 2017 1 Argonne National Laboratory 2 Ericsson and E¨otv¨osLor´adUniversity Table of contents 1. Introduction 2. Static Analysis with Clang 3. Instrumentation and More 1 Introduction Space of Techniques During this set of lectures we'll cover a space of techniques for the analysis and transformation of code using LLVM. Each of these techniques have overlapping areas of applicability: Static Analysis LLVM Instrumentation Source Transformation 2 Space of Techniques When to use source-to-source transformation: • When you need to use the instrumented code with multiple compilers. • When you intend for the instrumentation to become a permanent part of the code base. You'll end up being concerned with the textual formatting of the instrumentation if humans also need to maintain or enhance this same code. 3 Space of Techniques When to use Clang's static analysis: • When the analysis can be performed on an AST representation. • When you'd like to maintain a strong connection to the original source code. • When false negatives are acceptable (i.e. it is okay if you miss problems). https://clang-analyzer.llvm.org/ 4 Space of Techniques When to use IR instrumentation: • When the necessary conditions can be (or can only be) detected at runtime (often in conjunction with a specialized runtime library). • When you require stronger coverage guarantees than static analysis. • When you'd like to reduce the cost of the instrumentation by running optimizations before the instrumentation is inserted, after the instrumentation is inserted, or both.
    [Show full text]
  • Sham: a DSL for Fast Dsls
    Sham: A DSL for Fast DSLs Rajan Waliaa, Chung-chieh Shana, and Sam Tobin-Hochstadta a Indiana University, Bloomington, United States Abstract Domain-specific languages (DSLs) are touted as both easy to embed in programs and easy to optimize. Yet these goals are often in tension. Embedded or internal DSLs fit naturally with a host language, while inheriting the host’s performance characteristics. External DSLs can use external optimizers and languages but sit apart from the host. We present Sham, a toolkit designed to enable internal DSLs with high performance. Sham provides a domain-specific language (embedded in Racket) for implementing other high-performance DSLs, with transparent compilation to assembly code at runtime. Sham is well suited as both a compilation target for other embedded DSLs and for transparently replacing DSL support code with faster versions. Sham provides seamless inter-operation with its host language without requiring any additional effort from its users. Sham also provides a framework for defining language syntax which implements Sham’s own language interface as well. We validate Sham’s design on a series of case studies, ranging from Krishnamurthi’s classic automata DSL to a sound synthesis DSL and a probabilistic programming language. All of these are existing DSLs where we replaced the backend using Sham, resulting in major performance gains. We present an example-driven description of how Sham can smoothly enhance an existing DSL into a high-performance one. When compared to existing approaches for implementing high-performance DSLs, Sham’s design aims for both simplicity and programmer control. This makes it easier to port our techniques to other languages and frameworks, or borrow Sham’s innovations “à la carte” without adopting the whole approach.
    [Show full text]
  • Introduction to LLVM (Low Level Virtual Machine)
    Introduction to LLVM (Low Level Virtual Machine) Fons Rademakers CERN What is the LLVM Project? • Collection of compiler technology components ■ Not a traditional “Virtual Machine” ■ Language independent optimizer and code generator ■ LLVM-GCC front-end ■ Clang front-end ■ Just-In-Time compiler • Open source project with many contributors ■ Industry, research groups, individuals ■ See http://llvm.org/Users.html • Everything is Open Source, and BSD Licensed! (except GCC) • For more see: http://llvm.org/ 2 LLVM as an Open-Source Project • Abridged project history ■ Dec. 2000: Started as a research project at University of Illinois ■ Oct. 2003: Open Source LLVM 1.0 release ■ June 2005: Apple hires project lead Chris Lattner ■ June 2008: LLVM GCC 4.2 ships in Apple Xcode 3.1 ■ Feb. 2009: LLVM 2.5 3 Why New Compilers? • Existing Open Source C Compilers have Stagnated! • How? ■ Based on decades old code generation technology ■ No modern techniques like cross-file optimization and JIT codegen ■ Aging code bases: difficult to learn, hard to change substantially ■ Can’t be reused in other applications ■ Keep getting slower with every release 4 LLVM Vision and Approach • Build a set of modular compiler components: ■ Reduces the time & cost to construct a particular compiler ■ Components are shared across different compilers ■ Allows choice of the right component for the job ■ Focus on compile and execution times ■ All components written in C++, ported to many platforms 5 First Product - LLVM-GCC 4.2 • C, C++, Objective C, Objective C++, Ada and Fortran • Same GCC command line options • Supports almost all GCC language features and extensions • Supports many targets, including X86, X86-64, PowerPC, etc.
    [Show full text]
  • Polymorphisation: Improving Rust Compilation Times Through
    Polymorphisation: Improving Rust compilation times through intelligent monomorphisation David Wood (2198230W) April 15, 2020 MSci Software Engineering with Work Placement (40 Credits) ABSTRACT In addition, Rust's compilation model is different from Rust is a new systems programming language, designed to other programming languages. In C++, the compilation unit is a single file, whereas Rust's compilation unit is a provide memory safety while maintaining high performance. 1 One of the major priorities for the Rust compiler team is crate . While compilation times of entire C++ and entire to improve compilation times, which is regularly requested Rust projects are generally comparable, modification of a by users of the language. Rust's high compilation times are single C++ file requires far less recompilation than modifi- a result of many expensive compile-time analyses, a com- cation of a single Rust file. In recent years, implementation pilation model with large compilation units (thus requiring of incremental compilation into rustc has improved recom- incremental compilation techniques), use of LLVM to gen- pilation times after small modifications to code. erate machine code, and the language's monomorphisation Rust generates machine code using LLVM, a collection of strategy. This paper presents a code size optimisation, im- modular and reusable compiler and toolchain technologies. plemented in rustc, to reduce compilation times by intelli- At LLVM's core is a language-independent optimiser, and gently reducing monomorphisation through \polymorphisa- code-generation support for multiple processors. Languages tion" - identifying where functions could remain polymor- including Rust, Swift, Julia and C/C++ have compilers us- phic and producing fewer monomorphisations.
    [Show full text]
  • Formalizing the LLVM Intermediate Representation for Verified Program Transformations
    University of Pennsylvania ScholarlyCommons Departmental Papers (CIS) Department of Computer & Information Science 2012 Formalizing the LLVM Intermediate Representation for Verified Program Transformations Jianzhou Zhao University of Pennsylvania Santosh Nagarakatte University of Pennsylvania, [email protected] Milo Martin University of Pennsylvania, [email protected] Stephan A. Zdancewic University of Pennsylvania, [email protected] Follow this and additional works at: https://repository.upenn.edu/cis_papers Part of the Computer Sciences Commons Recommended Citation Jianzhou Zhao, Santosh Nagarakatte, Milo Martin, and Stephan A. Zdancewic, "Formalizing the LLVM Intermediate Representation for Verified Program Transformations", . January 2012. Jianzhou Zhao, Santosh Nagarakatte, Milo M. K. Martin, and Steve Zdancewic. Formalizing the LLVM Intermediate Representation for Verified Program Transformations. In Proc. of the ACM Symposium on Principles of Programming Languages (POPL), 2012 doi>10.1145/2103656.2103709 © ACM, 2012. This is the author's version of the work. It is posted here by permission of ACM for your personal use. Not for redistribution. The definitive version was published in Proc. of the ACM Symposium on Principles of Programming Languages, { (2012)} http://doi.acm.org/doi>10.1145/2103656.2103709" Email [email protected] This paper is posted at ScholarlyCommons. https://repository.upenn.edu/cis_papers/560 For more information, please contact [email protected]. Formalizing the LLVM Intermediate Representation for Verified Program Transformations Abstract This paper presents Vellvm (verified LLVM), a framework for reasoning about programs expressed in LLVM's intermediate representation and transformations that operate on it. Vellvm provides a mechanized formal semantics of LLVM's intermediate representation, its type system, and properties of its SSA form.
    [Show full text]
  • “Which Targets Does Clang Support?”
    “Which targets does Clang support?” EuroLLVM 2014: Lightening Talk Jonathan Roelofs [email protected] mentor.com/embedded Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. “Which targets does Clang support?” “Some stuff doesn’t seem to be documented at ALL…. what are the valid inputs to the ‘- arch’ … option? … This really is frustrating.” – Tim Hill [1] 2 “Which targets does Clang support?” “I read the man page … but I haven't been able to find a list of what ‘-march’ options are available…. Could someone point me to a list of supported options?” – Tim Nackos [2] 3 “Which targets does Clang support?” “I think the best way to get the answer is reading the source” – a’Q [3] 4 “Which targets does Clang support?” Clearly we need a better answer! 5 Prior Work 6 Prior Work $> clang –target <foo> --print-multi-libs (Based on patches I submitted earlier this spring) 7 Universal Driver “Clang is inherently a cross compiler…. However, actually cross compiling in practice involves much more than just generating the right assembly” – Daniel Dunbar [4] 8 Proposed Solution Target Triple: <arch><sub>-<vendor>-<sys>-<abi> --print-supported-archs --print-supported-vendors --print-supported-systems --print-supported-abis --print-multi-libs --print-available-targets 9 Proposed Solution: Examples $> clang --print-supported-archs x86 ... $> clang -march x86 --print-supported-systems auroraux darwin macosx ... $> clang -march x86 --print-available-systems linux 10 Proposed Solution: Examples $> clang --print-supported-targets x86-linux-gnu ppc-apple-darwin arm-none-eabi $> clang --print-available-targets x86-linux-gnu $> clang –target ppc-apple-darwin foo.c Sorry, but the toolchain for: ppc-apple-darwin has not been installed.
    [Show full text]
  • Llvmlinux: the Linux Kernel with Dragon Wings
    LLVMLinux: The Linux Kernel with Dragon Wings Presented by: Behan Webster (LLVMLinux project lead) Presentation Date: 2013.10.24 LLVMLinux Project What is Clang/LLVM? LLVMLinux Project LLVM is a Toolchain Toolkit A modular set of libraries for building tools Compiler, linker Source code analysis tools Meta data extraction from code Code refactoring tools Tight integration with IDEs LLVMLinux Project LLVM Toolchain Suite Clang (C/C++/Objective-C compiler) Compiler-rt (highly tuned low level operations) LLD and MC Linker (Linkers) Static Analyzer (checkers) LLDB (debugger) And more... LLVMLinux Project Why Would I Want to Use Clang/LLVM to Compile the Linux Kernel? LLVMLinux Project Fast Compiles Clang compiles code faster and use less memory than other toolchains Timed ImageMagick Compilation v6.8.1-10 Time To Compile Seconds, Less Is Better OpenBenchmarking.org GCC 4.7.2 58.05 SE +/- 0.07 GCC 4.8.0 59.67 SE +/- 0.12 LLVM Clang 3.2 25.03 SE +/- 0.11 LLVM Clang 3.3 SVN 24.79 SE +/- 0.10 13 26 39 52 65 Powered By Phoronix Test Suite 4.4.1 http://www.phoronix.com/scan.php?page=article&item=llvm_33svn_competes&num=1 LLVMLinux Project Fast Moving Project In just a few years Clang has reached and in some cases surpassed what other toolchains can do LAMMPS Molecular Dynamics Simulator v1.0 Test: Rhodopsin Protein Loop Time, Less Is Better OpenBenchmarking.org GCC 4.7.2 49.36 SE +/- 0.18 GCC 4.8.0 48.46 SE +/- 0.14 LLVM Clang 3.2 49.71 SE +/- 0.07 LLVM Clang 3.3 SVN 41.36 SE +/- 0.09 11 22 33 44 55 Powered By Phoronix Test Suite 4.4.1 1.
    [Show full text]
  • Vmkit: a Substrate for Managed Runtime Environments
    VMKit: a Substrate for Managed Runtime Environments Nicolas Geoffray Gael¨ Thomas Julia Lawall Universite´ Pierre et Marie Curie Universite´ Pierre et Marie Curie University of Copenhagen LIP6/INRIA/Regal LIP6/INRIA/Regal Universitetsparken 1 Paris, France Paris, France Copenhagen, Denmark nicolas.geoff[email protected] [email protected] [email protected] Gilles Muller Bertil Folliot Universite´ Pierre et Marie Curie Universite´ Pierre et Marie Curie LIP6/INRIA/Regal LIP6/INRIA/Regal Paris, France Paris, France [email protected] [email protected] Abstract 1. Introduction Managed Runtime Environments (MREs), such as the JVM and Managed runtime environments, such as the Java Virtual Machine the CLI, form an attractive environment for program execution, by (JVM) [28] or the Common Language Infrastructure (CLI) [20],1 providing portability and safety, via the use of a bytecode language are becoming the norm for executing programs in environments and automatic memory management, as well as good performance, ranging from web servers to desktops and even embedded systems. via just-in-time (JIT) compilation. Nevertheless, developing a fully An MRE executes an intermediate representation of an applica- featured MRE, including e.g. a garbage collector and JIT compiler, tion, which is portable, compact and, most important of all, can be is a herculean task. As a result, new languages cannot easily take checked to enforce safety. An MRE can in principle support many advantage of the benefits of MREs, and it is difficult to experiment languages; for example, the CLI supports languages ranging from with extensions of existing MRE based languages. the imperative language C# to the functional language F#, and the This paper describes and evaluates VMKit, a first attempt to scripting language IronPython.
    [Show full text]