.NET Native deep dive Andrew Pardoe

Slides:



Advertisements
Similar presentations
By Sam Nasr September 28, 2004 Understanding MSIL.
Advertisements

Using.NET Platform Note: Most of the material of these slides have been taken & extended from Nakov’s excellent overview for.NET framework, MSDN and wikipedia.
Streaming SIMD Extension (SSE)
8. Code Generation. Generate executable code for a target machine that is a faithful representation of the semantics of the source code Depends not only.
SIMD Single instruction on multiple data – This form of parallel processing has existed since the 1960s – The idea is rather than executing array operations.
Copyright © 2005 Elsevier Imperative languages Group languages as –imperative von Neumann(Fortran, Pascal, Basic, C) object-oriented(Smalltalk, Eiffel,
Computer Organization CS224 Fall 2012 Lesson 12. Synchronization  Two processors or threads sharing an area of memory l P1 writes, then P2 reads l Data.
.NET IL Obfuscation Presented by: Sarath Chandra Dorbala.
.NET Technology.
Modern Compiler Internal Representations Silvius Rus 1/23/2002.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
Data Structure and Algorithm 1 Yingcai Xiao. You Me The Course (
1-1 Embedded Software Development Tools and Processes Hardware & Software Hardware – Host development system Software – Compilers, simulators etc. Target.
Programming A Historic Perspective on Code Reuse Yingcai Xiao.
© 2007 IBM Corporation IBM Software Group September 26, 2007 Tactics for Minimal Interference from Class Loading in Real-Time Java™ The 5th International.
Introducing the Common Language Runtime for.NET. The Common Language Runtime The Common Language Runtime (CLR) The Common Language Runtime (CLR) –Execution.
.NET’s CLR How does it really work? 7/2/20151Bhavani Sankar Ikkurthi CS 795 Presentation.
Build /17/2017 © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION.
Accelerating Machine Learning Applications on Graphics Processors Narayanan Sundaram and Bryan Catanzaro Presented by Narayanan Sundaram.
COP4020 Programming Languages
“Our role is more important than ever before” “We are required to innovate and deliver much faster” “I need a cross-platform mobile development strategy”
Language Systems Chapter FourModern Programming Languages 1.
CIS NET Applications1 Chapter 2 –.NET Component- Oriented Programming Essentials.
Introduction to .NET Framework
ICOM 5995: Performance Instrumentation and Visualization for High Performance Computer Systems Lecture 7 October 16, 2002 Nayda G. Santiago.
Java Virtual Machine Java Virtual Machine A Java Virtual Machine (JVM) is a set of computer software programs and data structures that use.
+ A Short Java RMI Tutorial Usman Saleem
Introduction to the Java Virtual Machine 井民全. JVM (Java Virtual Machine) the environment in which the java programs execute The specification define an.
Core.NET Next gen JIT (“RyuJIT”) SIMD Runtime Compilers.NET Compiler Platform (“Roslyn”) Languages innovation Windows Desktop Azure and Windows Server.
Windows Camp #wincamp Windows Camp Игорь Сычев Premier Field Engineer, Microsoft Что нового/полезного принесла VS2015 для разработчиков приложений.
1 Introduction to JVM Based on material produced by Bill Venners.
CS266 Software Reverse Engineering (SRE) Reversing and Patching Java Bytecode Teodoro (Ted) Cipresso,
CSC 230: C and Software Tools Rudra Dutta Computer Science Department Course Introduction.
Introduction to VB.Net. What is.NET? A brand of Microsoft technologies A platform for creating distributed Web applications A combination of new and updated.
1.NET FRAMEWORK CE-105 Spring 2007 Engr. Faisal ur Rehman.
Languages and IDE (Integrated Development Environment)
tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3.
Module 3: Using Microsoft.NET- Based Languages. Overview Overview of the.NET-Based Languages Comparison of the.NET-Based Languages.
Dynamo: A Transparent Dynamic Optimization System Bala, Dueterwald, and Banerjia projects/Dynamo.
LANGUAGE SYSTEMS Chapter Four Modern Programming Languages 1.
Intro to dot Net Dr. John Abraham UTPA CSCI 3327.
Slide Advanced Programming 2004, based on LY Stefanus's slides Native Methods.
By: Cheryl Mok & Sarah Tan. Java is partially interpreted. 1. Programmer writes a program in textual form 2. Runs the compiler, which converts the textual.
Getting Started With Java September 22, Java Bytecode  Bytecode : is a highly optimized set of instructions designed to be executed by the Java.
Common Language Runtime Introduction  The common language runtime is one of the most essential component of the.Net Framework.  It acts.
64-bit JIT + SIMD Garbage Collector Runtime components Compilers.NET Compiler Platform (Roslyn) Languages innovation.NET Framework 4.6.NET Core.
Design of A Custom Vector Operation API Exploiting SIMD Intrinsics within Java Presented by John-Marc Desmarais Authors: Jonathan Parri, John-Marc Desmarais,
Module 4: Deployment and Versioning. Overview Introduction to Application Deployment Application Deployment Scenarios Related Topics and Tools.
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
1 HPJAVA I.K.UJJWAL 07M11A1217 Dept. of Information Technology B.S.I.T.
Distributed programming in Java Faculty:Nguyen Ngoc Tu Session 5 - RMI.
Lab Activities 1, 2. Some of the Lab Server Specifications CPU: 2 Quad(4) Core Intel Xeon 5400 processors CPU Speed: 2.5 GHz Cache : Each 2 cores share.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Сергей Лутай REFACTORING converts single-tier code into distributed RETARGETING converts MSIL code into code for other virtual.
© Copyright Khronos Group, Page 1 Real-Time Shallow Water Simulation with OpenCL for CPUs Arnon Peleg, Adam Lake software, Intel OpenCL WG, The.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
.NET Framework.
.NET Native & CoreRT.
Language Translation Compilation vs. interpretation.
ECE 498AL Lectures 8: Bank Conflicts and Sample PTX code
CE-105 Spring 2007 Engr. Faisal ur Rehman
2.1. Compilers and Interpreters
Introduction to C# AKEEL AHMED.
Programming in C# CHAPTER 1
11/21/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
Compiler Back End Panel
Compiler Back End Panel
Module 10: Implementing Managed Code in the Database
Introduction to CUDA.
Finishing Up.
Presentation transcript:

.NET Native deep dive Andrew Pardoe (andrew.pardoe@microsoft.com) Build 2014 4/17/2017 .NET Native deep dive Andrew Pardoe (andrew.pardoe@microsoft.com) .NET Native (dotnetnative@microsoft.com) Program Manager, .NET Runtime © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Questions?

.NET code generation: A primer Build 2014 4/17/2017 .NET code generation: A primer Source code (C#/VB/F#) MSIL bytecode Machine code C#/VB/F# compiler Code generation Code generation is done either…. Lazily at runtime with a Just-In-Time, or JIT, compiler Optimistically at build time with NGen, Triton or .NET Native © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

.NET Code Execution today C++ Performance Self-contained apps Dynamic experience “Unlimited” class libraries

Code execution in CLR 4.5 Code generation One JIT compiler for each architecture 64-bit JIT emphasizes code quality over throughput for server scenarios 32-bit JITs emphasize throughput over code quality for app scenarios Two native code generators with different deployment properties NGen runs on the user’s machine, at install time or automatically Triton runs in the Windows Phone 8 Store, app bound to libraries at install One runtime (VM or VEE) spans multiple scenarios Desktop CLR for Windows Client and Server workloads (different GC modes) CoreCLR for Mobile and targeted Server workloads built from the same codebase

Triton: Native code on Windows Phone Build 2013 4/17/2017 Triton: Native code on Windows Phone MDIL  native code C# MSIL MSIL  MDIL Windows Phone apps are compiled to native code in the cloud on WP8 © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

The properties of code execution Code generation properties Throughput Code quality Memory usage Deployment properties Distribution format Acquisition process Serviceability Security properties Typesafe execution Code identity & isolation Security functionality Developer experience Everything is a tradeoff! “Make simple things easy and hard things possible.”

.NET Code Execution tomorrow .NET Native RyuJIT & CLR VM C# Productivity with C++ Performance C# Language with dynamic experiences Today: One runtime engine & same code execution for all scenarios Tomorrow: Refactored engine & multiple execution strategies provide best of class on both extremes. From there, we target the middle.

.NET Native (Project N)

.NET Native

Wordament on .NET Native: Build 2014 4/17/2017 .NET Native Next Generation Compiler in the Cloud for Store Apps represents an evolution of Triton & NGen Uses lean runtime and VC++ optimizer for fast code execution and reduced memory usage Based on a refactored CLR engine. Native code is shared, managed code has moved into the libraries Provides converged developer experience for .NET across devices . Wordament on .NET Native: Scenario Improvement (%) Cold Startup 39.32% Warm Startup 31.21% Memory Usage 12.68% © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Visual Studio Experience for .NET Native Debug and test your app with .NET Native Enable .NET Native for your project

.NET Native Compiler Toolchain

IL Compiler: C# -> MSIL Compile C# source code Generate & compile marshalling and serialization code

Pregenerated interop code Today, interop code is generated as MSIL at runtime, JIT-compiled, executed and thrown out JIT compilation takes time (but the methods are small) If your P/Invoke signature has an issue your compiled code is gone In .NET Native, the Marshalling Code Generator creates interop code as a C# file at compile-time Compilation is done at build-time The code can be debugged as C#, not assembly The code can be inspected and optimized before compilation to MSIL

IL Compiler: Merge & reduce app code Merge all app & library code “Reduce” app to throw away unneeded types, code, metadata, etc.

Static dynamic code (dynamic static code?) A bit of a conundrum… Static compilation means any code that can run is generated at compile-time Reflection requires that anything you can inspect at runtime can be executed The solution: preserve the set of classes, methods, generic types, etc., that the code might want to call And if the compiler gets it wrong? Missing metadata results in an exception File a bug with the .NET Native team?

Runtime directives (default.rd.xml) <Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata"> <Application> <Assembly Name="*Application*" Dynamic="Required All" /> <!-- Add your application specific runtime directives here. --> </Application> </Directives> The type specifies the class, namespace or assembly affected Types: class, interface, or struct Group of types: namespace, assembly (*Application* is all types in the app assemblies) Type member: method, field, property, or event The degree tells the compiler what behavior is needed Reflection behaviors, Serialization behaviors, Interop behaviors The policy notes the scope to apply that behavior inside the type Accessibility: All, Public, Private, Internal Required: Including this keyword means “Include these types in the final binary”

IL Compiler: MSIL -> MDIL -> machine code C++ optimizer compiles MSIL to MDIL, Machine Dependent Intermediate Format. App is mostly machine code but cannot execute. “Bind” MDIL app code into machine code. App distributed as a stub, app.exe, and app code in a dll. MRT Runtime is distributed in the app package, making the app package self-sufficient.

Example: automatic vectorization/parallelization for (long j = 0; j < numBodies; j++) // From Nbody sample { Float_4 r; r.x = A[j].pos.x - B.pos.x; r.y = A[j].pos.y - B.pos.y; r.z = A[j].pos.z - B.pos.z; float distSqr = r.x * r.x + r.y * r.y + r.z * r.z; distSqr += softeningSquared; float invDist = 1.0f / (float)Math1.Sqrt(distSqr); float invDistCube = invDist * invDist * invDist; float s = fParticleMass * invDistCube; acc.x += r.x * s; acc.y += r.y * s; acc.z += r.z * s; } The C++ optimizer can recognize this code as parallel and generate vector (SIMD) instructions

.NET Native performance gains Build 2014 4/17/2017 .NET Native performance gains Optimized runtime Refactored core libraries Pregenerated interop Pregenerated serializers Tree-shaken code Pay-for-play metadata C++ optimizer Global optimizations © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

.NET Native: Call to action Build 2014 4/17/2017 .NET Native: Call to action Learn more about .NET Native http://aka.ms/dotnetnative http://blogs.msdn.com/b/dotnet Download the .NET Native VS add-In http://aka.ms/dotnetnative Requires Visual Studio 2013 Update 2 RC Try out your Store app with .NET Native Do you have a top Store app or library? Reach out to us: dotnetnative@microsoft.com Help us make .NET Native better Participate in the .NET Native Forum Reach out to us: dotnetnative@microsoft.com © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

We would love to hear from you! Build 2014 4/17/2017 We would love to hear from you! Blog E-mail dotnet @dotnet MSDN Forums UserVoice © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.