C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR...

59

Transcript of C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR...

Page 1: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)
Page 2: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Favorite Things for C++ Developers in Visual Studio 2013 Eric BattalioSenior Program Manager, Microsoft

DEV-B223

Page 3: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Worst kept secretsPerformancePortabilityCompatibility

Page 4: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Best Kept SecretsPick up arcane new skillsCreate support toolsConsume shared code librariesSupport hybrid devicesAccess to native codeBoundary-pushing apps

Tuning a managed applicationCode maintenanceCross platformPorting code to a new applicationGraphics

“It’s fun!”

Page 5: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C++

Windows 8.1PerformanceLanguage and LibrariesEditor and IDECommunity

Page 6: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C++

Windows 8.1PerformanceLanguage and LibrariesEditor and IDECommunity

Page 7: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Improvements to C++/CXBoxed TypesOverriding ToString()Improved WinRT ExceptionsFaster PerformanceImproved C++/CX Collections

Page 8: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Universal App Templates for C++Windows Runtime ComponentDirectXDirectX and XAML

Page 9: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Better XAML DesignerNew and updated templatesImproved designer performanceNew Windows 8.1 controlsRulers and dynamic guidesIn-place editingGo To Definition

Page 10: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Graphics ToolsGetting StartedProject Templates (+Windows Phone), Item Templates

Graphics Assets AuthoringImage Editor, Model Editor, Shader Designer, Content Pipeline, Compile HLSL in VS

Graphics DiagnosticsGraphics Debugger (+Windows Phone Apps), Graphics Profiler (+Graphics Frame Analysis)

Page 11: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Graphics DiagnosticsVS 2013 RTMRemote debuggingCompute shader debuggingAvailable in VS Express for Windows!

VS 2013 Update 2Consecutive captureProgrammatic captureEnhanced Event ListDebugging Windows Phone 8.1 appsGraphics Frame Analysis

Page 12: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Diagnostic HubXAML UI responsiveness profilingEnergy profilerCPU profilingMemory profiling

Page 13: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Debugging Goodness“Just My Code” for C++Improved Async debuggingJavaScript/C++ interop debuggingARM crash dump debugging

X

Page 14: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Demo

Graphics Diagnostics

Page 15: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C++

Windows 8.1PerformanceLanguage and LibrariesEditor and IDECommunity

Page 16: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Performance Optimizations Recap

Compilation Unit/O2 and friends

.cpp

.cpp .obj

.obj

.exe

.cpp

.cpp .obj

.obj

.exe

.cpp

.cpp .obj

.obj

.exe

Run TrainingScenario

s

.exe

Whole Program/GL and /LTCG

Whole Program/LTCG:PGI and /LTCG:PGO

Page 17: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Automatic VectorizationVisual Studio 2012Uses “vector” instructions where possible in loops.

Visual Studio 2013 adds more!Statement level vectorizationPermutation of perfect loop nestsRange propagation optimizationsReductions into array elements__restrict support for vector alias checkingImprovements to data dependence analysisC++ pointer vectorizationGather / scatter optimizationsSupport for more operations: min/max, converts, shifts, byteswap, averaging

+

r1 r2

r3

add r3, r1, r2

SCALAR(1 operation)

v1 v2

v3

+

vectorlength

vadd v3, v1, v2

VECTOR(N operations)

Page 18: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Automatic Vectorization// STL – pointers everywhere; not even a loop counter variablevoid transform1(int const* first1, int const* last1, int const* first2, int* result) { while (first1 != last1) { //converted to integer *result++ = *first1++ + *first2++; // make these array references }}// DirectX – no loops here! Vectorize operations on adjacent memory cellsXMVECTOR four_vector_example(XMVECTOR V) { XMVECTOR Result;    Result.vector4_f32[0] = 1.f / V.vector4_f32[0];    Result.vector4_f32[1] = 1.f / V.vector4_f32[1];    Result.vector4_f32[2] = 1.f / V.vector4_f32[2];    Result.vector4_f32[3] = 1.f / V.vector4_f32[3];    return Result;}// Machine Vision Libraryvoid machine_vision_filter_example (int* A, int boxStart) { for (int i = 0; i < 100; i++) A[boxStart + i] = A[boxStart + i] + 1;}

Page 19: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C++ AMPVisual Studio 2012 experienceProgramming model for heterogeneous computingAllowed C++ code to run on the GPU for general-purpose computationSTL-like library for multidimensional data

Visual Studio 2013 adds:Shared memory support to eliminate/reduce copying of data between CPU and GPUEnhanced texture support: texture sampling, mipmap support and staging texturesC++ AMP debugging on Win7 and side-by-side CPU/GPU debuggingFaster C++ AMP runtime: improved copy performance, reduce launch overheadBetter DirectX interop supportImproved C++ AMP runtime diagnosticsImprovements to array_view APIs

Page 20: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C++ AMP – Easy Peasy!#include "amp.h"using namespace concurrency;

void square_array(float* arr, int n){ // Create a view over the data on the CPU array_view<float, 1> dataView(n, &arr[0]);

// Run code on the GPU parallel_for_each(dataView.extent, [=](index<1> idx) restrict(amp) { dataView[idx] = dataView[idx] * dataView[idx]; });

// Copy data from GPU to CPU dataView.synchronize();}

Page 21: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Improved Compiler ThroughputEliminated bottlenecks in the writing of PDB filesAround 10% performance improvement in both /MP and non-/MP builds

Header file lookup has been made more efficientMajor performance gains in compiling large projects with lots of headersSpeedup is even greater on machines with many cores and SSDs

Page 22: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Demo

C++ AMP

Page 23: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C++

Windows 8.1PerformanceLanguage and LibrariesEditor and IDECommunity

Page 24: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Visual C++ Conformance UpdateVC++ Nov 2013 CTP

High confidence

Med confidence

VC++ CTP.next(upcoming)

Page 25: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

initializer_listsint main(){ std::map<int, int> m { { 0, 0 }, { 1, 1 }, { 2, 2 }, { 3, 3 } };}

Page 26: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Raw String Literalsvoid f(){ char* p = "\"Hello, world!\""; char* q = R"("Hello, world!")"; char* r = R"("Hello, """""""" world!")"; char* s = R"("Hello, \ \ \ \ \ world!")"; char* p = R"("Hello, many-lined world!")";}

Page 27: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Uniform Initializationvoid f(){ int x = 0; int y(0); int z{0};}

Page 28: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

= deleteclass NonCopyable{public: NonCopyable() { /* ... */ }

NonCopyable(NonCopyable const&) = delete; NonCopyable& operator=(NonCopyable const&) = delete;};

Page 29: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

= defaultclass C{public: C(int x) { /* ... */ } C() = default;};

Page 30: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C99 Designated Initializerstypedef struct S { int x; int y; int z; } S;

void f(){ S a = { .x = 1, .y = 2, .z = 3 };}

Page 31: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C99 Mixed Declarations and Statementsint f(){ int x = foo(); if (x != 0) return -1;

int y = bar(); if (y != 0) return -1;

return 0;}

Page 32: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Why C99 Support?

Page 33: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C++ Standard LibraryContainers support the C++11 fine-grained type requirementsSupport for several C++14 Features:Transparent operator functors (less<>, greater<>, plus<>, etc.)std::make_unique<T>(args…) and std::make_unique<T[]>(n)cbegin(), cend(), rbegin(), rend(), and crbegin(), crend() non-member functions

Improved performance in <atomic>Stabilization and bug fixes in <type_traits>

Page 34: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C Standard LibraryImplemented most of the missing C99 library functionalitymath.h, complex.h, fenv.h, and float.h math functionsinttypes.h format specifier macros and conversion functionsstdio.h: vscanf, vfscanf, vsscanfstdlib.h: atoll, strtof, strtold, strtoll, strtoullwchar.h: vwscanf, vfwscanf, vswscanf, wcstof, wcstold, wcstoll, wcstoull

A few C99 library features still not yet implementedprintf/scanf length modifiers, snprintf and snwprintf, a few other thingsBut we’re actively working on these remaining features

Page 35: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Parallel STLWorking draft, Technical Specification for C++ Extensions for ParallelismA proposal to add high-level parallel algorithms to ISO C++Prototype available, https://parallelstl.codeplex.com/

Page 36: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Parallel STLstd::sort(v.begin(), v.end());

std::experimental::parallel::sort(par, v.begin(), v.end());

Page 37: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

ATL and MFC (wut?)Removed the ATL DLL entirelyDeprecated support for the MBCS MFCRecommendation is to move applications to UnicodeFixed 105 MFC bugs; 60 ATL bugs

Page 38: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C++ REST SDKCloud-based client-server communications libraryConnecting and interacting with RESTful servicesAsynchronous for fast, fluid appsUses modern C++11 patternsCross-platform

What is included?HTTP Client, JSON Library, and asynchronous streams and buffers

Page 39: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

NuGet

Page 40: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Demo

NuGet

Page 41: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C++

Windows 8.1PerformanceLanguage and LibrariesEditor and IDECommunity

Page 42: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Code FormattingOver 40 new settings to control when and how your C++ code is formatted.Turn off individual options or all of them.

Page 43: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Enhanced ScrollbarProvides visual cues about source on vertical scrollbarQuickly locate errors, warning, bookmarks, etc.

No need to scroll away to see matches!

Page 44: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Peek DefinitionView, edit and move around inside the definition file while keeping your place in the original code.

Page 45: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

IntelliSense TweaksMember List windowHides private members of types, except when you're editing code that defines the type.

Parameter Help tooltip Automatically switch to the best matching overload based on the number of parameters you've typed thus far

Page 46: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Rename Refactor Helper ExtensionMore intelligent find/replace!Open to feedback and improvement suggestions.Grab it on the Visual Studio Gallery.

Page 47: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Send a SmileSomething delighting or bugging you? Let us know quickly with just a few clicks!

Switching configurations in the property pages makes this weird glitch happen :(

Crashes on empty project C++ when IntelliSense should come up...

****ing C++ lang, that is bugging me all the time

Thanks for amazing tool to write c++ apps!

std::vector<std::string> v = { "a", "b", "c" }; initializer for std collections

Thanks a lot, xoxoxo

Error C2227 is not in the help files, off or online.

Page 48: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Demo

Editor Awesomeness

Page 49: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C++

Windows 8.1PerformanceLanguage and LibrariesEditor and IDECommunity

Page 50: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C++ CommunityConnect with othersDiscover new tips and tricksShare your knowledge and experienceJoin (or create) a user group

Page 51: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C++ MVPsActive in the communityStrong developers and C++ wieldersProvide feedback directly to product group

Nominate a peer...or yourself!

Page 52: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Suggest and vote for featuresWe want your suggestions, help us improve Visual Studio and Visual C++Visit Visual C++ on User Voice http://aka.ms/UserVoiceVisualCPP

Found a bug? Let us knowReport a bug on our Connect site, http://aka.ms/VisualStudioConnect

Page 53: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Demo

Community Goodness

Page 54: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

C++ Scenarios for C# Developers, DEV-B371

Debugging Tips and Tricks in Visual Studio 2013, DEV-B352

Related content

What's New in Microsoft Visual Studio 2013 for C++ Developers, DEV-H223

Find me later in the Visual Studio booth, on Twitter @visualc or at [email protected]

Page 55: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Visit the Developer Platform & Tools BoothHaving a friend buy your coffee?Yea, it’s kind of like that.

MSDN Subscribers get up to $150/mo in Azure credits.

Stop by the Developer Platform and Tools booth and visit the MSDN Subscriptions station to activate your benefits and receive a gift!

http://aka.ms/msdn_teched

3 Steps to New Gear! With Application Insights

1. Create a Visual Studio Online account http://visualstudio.com

2. Install Application Insights Tools for Visual Studio Online http://aka.ms/aivsix

3. Come to our booth for a t-shirt and a chance to win!

VSIP QR Tag Contests Visit our booth to join the hunt for cool prizes!

Page 56: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

ResourcesMicrosoft Engineering Stories

How Microsoft Builds Softwarehttp://aka.ms/EngineeringStories

Visual Studio Industry Partner Program

Meet Our New Visual Studio Online Partners or Join Now.http://vsipprogram.com

Visual Studio | Integrate

Create Your Own Dev Environmenthttp://integrate.visualstudio.com

Development tools & services for teams of all sizeshttp://www.visualstudio.com

Page 57: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Complete an evaluation and enter to win!

Page 58: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

Evaluate this session

Scan this QR code to evaluate this session.

Page 59: C++ + r1 r2 r3 add r3, r1, r2 SCALAR (1 operation) v1 v2 v3 + vector length vadd v3, v1, v2 VECTOR (N operations)

© 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.