for (i = 0; i < 1024; i++) c[i] = a[i]*b[i]; for (i = 0; i < 1024; i+=4) c[i:i+3] =...

41
What's New in Visual C++ 2012 Rong Lu Program Manager Visual C++ team Microsoft Corporation

Upload: sharon-evans

Post on 16-Dec-2015

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

What's New in Visual C++ 2012

Rong LuProgram ManagerVisual C++ teamMicrosoft Corporation

Page 2: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Agenda

Performance and C++

Modern C++

Build metro style apps

It’s all about Productivity

Page 3: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Agenda

Performance and C++

Modern C++

Build metro style apps

It’s all about Productivity

Page 4: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Performance and C++

1.0

Power - driver at all scales: mobile, desktop, datacenter

Size - Limits on processor resources: desktop, mobile

Experience - Bigger experience on smaller hardware

Things have changed. Performance is king

again.

Page 5: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

How do I speed up the code?

Page 6: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

VC11 Compiler makes easier• Auto-Vectorization• Take advantage of vector

processors on CPU• Vectorize loops and use

SSE2 instructions automatically.

• ON by default.• No code changes required.for (i = 0; i < 1024; i++)

C[i] = A[i]*B[i];

for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3];

• Auto-Parallelization• Take advantage of multi-

core• Reorganizes the loop to on

multiple threads • Not ON by default• Hint in the code

#pragma loop(hint_parallel ( N ) )

for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; N is the number of

cores you want to parallelize over

Page 7: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

demo: Vectorization and Parellelization

Page 8: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

VC11 Compiler makes easier (Cont’d)• C++ AMP (Accelerated Massive Parallelism)• Heterogeneous platform support• A new C++ language feature• STL-like library• Open spec

performance

productivity

portability

Part of VC11 compiler, Visual Studio integration

Builds on DirectX, one EXE runs across hardware from different vendors

Increase performance of data-parallel algorithms by offloading to hardware

accelerators. E.g. GPU.

Page 9: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Summary

Performance and C++

• Speed up code using VC11 compiler• Auto-Vectorization• ON by default. Just recompile your

code

• Auto-Parallelization• Utilize multi-processor and multi-core

CPUs

• C++ AMP• Offload data parallel algorithms to

hardware accelerators, e.g. GPU

Page 10: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Agenda

Performance and C++

Modern C++

Build metro style apps

It’s all about Productivity

Page 11: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Modern C++: Clean, Safe and Fast

circle* p = new circle( 42 );

vector<shape*> vw = load_shapes();

for( vector<circle*>::iterator i = vw.begin(); i != vw.end(); ++i ) { if( *i && **i == *p ) cout << **i << “ is a match\n”;}

for( vector<circle*>::iterator i = vw.begin(); i != vw.end(); ++i ) { delete *i;}

delete p;

auto p = make_shared<circle>( 42 );

vector<shared_ptr<shape>> vw = load_shapes();

for_each( begin(vw), end(vw), [&]( shared_ptr<circle>& s ) { if( s && *s == *p ) cout << *s << “ is a match\n”;} );

• Then • Nownew

make_shared

T* shared_ptr<T>

no need for “delete”

automatic lifetime management

exception-safe

for/while/do std:: algorithms

[&] lambda functions

auto type deduction

not exception-safe

missing try/catch, __try/__finally

Page 12: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

C++ 11 language featuresC++11 Core Language Features VC10 VC11

Rvalue references v2.0 v2.1*Lambdas v1.0 v1.1decltype v1.0 v1.1**

auto v1.0 v1.0static_Assert Yes Yes

Trailing return types Yes Yesnullptr Yes Yes

Strongly typed enums Partial YesForward declared enums No Yes

Standard-layout and trivial types No YesAtomics No Yes

Strong compare and exchange No YesBidirectional fences No Yes

Data-dependency ordering No Yes

Page 13: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

C++ Libraries• STL• C++ 11 conformant• Support for new headers• <atomic>, <chrono>, <condition_variable>,

<filesystem>, <future>, <mutex>, <ratio>, <thread>.

• PPL (Parallel Pattern Library)• A rich task-based programming model that

supports asynchrony and continuations• Parallel algorithms• Concurrency-safe containers

Page 14: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Summary

• Modern C++ is Clean, Safe, Fast

• C++ 11 language features in VC11• Enhancement and new additions

• Libraries in VC11• C++ 11 conformant• Parallel pattern libraries (PPL)

Modern C++

Page 15: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Agenda

Performance and C++

Modern C++

Build metro style apps

It’s all about Productivity

Page 16: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Building metro style apps using C++First class support for building Windows

metro style apps using C++. XAML/C++ apps DirectX games Build your own C++ Windows runtime (WinRT)

component and access it from the language of your choice: C#, VB, JS, C++

Page 17: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Build metro style app using XAML/C++

Whole stack is native code

Full debugging support

(local, simulator, device)

C++ access to Windows runtime

XAML visual designer in VS

Page 18: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

demo: Build metro style app using XAML/C++

Page 19: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

XAML designer in VS• Object creation• Layout• Property editing• Create and reuse

resources• Configurable

design-time workspace

• XAML editor and IntelliSense

Page 20: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

C++ for Windows runtimeA set of language extensions and libraries

to allow direct consumption and authoring of Windows runtime (WinRT) types. Strongly-typed system for Windows runtime Automatically reference counted Exception-based Deep integration with STL Well defined binary contract across module boundaries

Page 21: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Consume WinRT type in C++ (Code sample)void MainPage::detectButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e){// detectButton handlerFaceFileList->Clear();

WinRTComponent^ faceDetectComponent = ref new WinRTComponent();auto action = faceDetectComponent->ExtractFacesFromFilesAsync(localSrcFileVector);}

Page 22: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Author WinRT type in C++ (Code sample)namespace winrtfacedetect{public ref class WinRTComponent sealed{public:WinRTComponent();

IAsyncActionWithProgress<String^>^ ExtractFacesFromFilesAsync(IVector<StorageFile^>^ inFileVector);

IVector<String^>^ SearchFiles(String^ query);

private:Vector<String^>^ getPathsFromFiles(IVector<StorageFile^>^ inFileVector);};}

Page 23: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Build metro style games using DirectX

Debugging/Packaging support

Mesh Viewer/Shader designer

HLSL editor/ compiler

Graphics Debugging

Page 24: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Images / textures• Modern image formats• PNG, JPG, GIF, BMP, TIFF• Direct Draw Surface (DDS)

• 32-bit!• Channels!• Paint tools• Filters• MIP maps

Page 25: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Graphics debugger• D3D11 / D3D11.1• Event history• Pixel history• Call stack• Object table• Object visualization• Custom events

Page 26: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Models / meshes• Inspect models• FBX, X, OBJ

• Camera controls• Experiment & Learn• Basic shapes• Transforms (e.g. scale)

Page 27: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

HLSL

Page 28: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Pixel Shaders• Visual designer• Intermediate rendering• Export to HLSL• Real-time rendering• Use with models

Page 29: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Build metro style apps

Summary• First class support in VS11 for

building Windows metro style apps using C++.• XAML/C++• DirectX• Build your own C++ WinRT

component

• C++/CX language extension for consuming and authoring Windows Runtime types.• Access C++ WinRT component

from the language of your choice: C#, VB, JS, C++

Page 30: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Agenda

Performance and C++

Modern C++

Build metro style apps

It’s all about Productivity

Page 31: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Improve development productivity using VC11

Additional C++ features• Reference Highlighting• Semantic Colorization• C++/CLI IntelliSense is

back!• Auto-display of member

list• Member list filtering• Code snippets

IDE enhancements in VS11• Solution Explorer• Project Compatibility with

VS2010 SP1 projects• Quick Launch• Find and Replace control• Simplified Toolbars• Search everywhere

Page 32: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Visual Studio 2012 ALM and C++

ALM features in VS 2012

Additional ALM features for C++ in VS 2012

User Story/Product Backlog mgmtLightweight RequirementsSprint planning, Taskboards planningContext SwitchingStakeholder FeedbackCode ReviewExploratory Testing

2010 features UpdatedCode AnalysisCode Coverage

Architectural DiscoveryUnit Testing

Page 33: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Architectural Discovery • Use dependency graphs to better understand your

code• Generate graphs for whole solution• Generate graphs for include file (C++)• It is your diagram, edit it!

• Use Architecture Explorer to browse assets and generate customized graphs

Page 34: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Code Analysis • Improved user experience and analysis capabilities• 64 bit support• Available in all editions• Concurrency rules (Pro+)• Customize ruleset (Pro+)

Page 35: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Unit Testing• New native C++ unit test framework in VS11• Author tests, manage tests and view results in VS• Available in all editions• Continuous run after build (Premium+)• Extensible: plug in 3rd party native framework to VS

(Pro+)

Page 36: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Code Coverage• Simplified experience and integrated with unit test

framework• Analyze code coverage by one single click in VS• For all tests• For selected tests

• Allow integration with 3rd party unit test frameworks

Page 37: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

It’s all about Productivity

Summary• VC11 helps improve

productivity• IDE enhancements

• Solution explorer• Project compatibility with VC10• Reference highlighting• Member list filtering

• Application Lifecycle management tools• Architecture discovery tools• Unit testing• Code analysis • Code coverage

Page 38: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Summary• Visual C++ 2012 has a lot to offer to C++

developers:

Performance and C++

Modern C++

Build metro style apps

It’s all about Productivity

Page 40: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

Resources • Keep up with Visual C++ team: http://blogs.msdn.com/vcblog• Deep Dives:

• A lap around Visual Studio 11 Express for Metro style apps using C++ • Using the Windows Runtime from C++ • Bringing existing C++ code into Metro style apps • Taming GPU compute with C++ AMP • Tips & tricks: how to use Visual Studio to the fullest • Writing modern C++ code: how C++ has evolved over the years • Tips and tricks for developing Metro style apps using C++ • Under the covers with C++ for Metro style apps • A lap around DirectX game development tools • First Look at the New C++ IDE Productivity Features in Visual Studio 11• ALM for C++ in Visual Studio 11• What's new in Visual Studio 11 for Application Lifecycle Management • Working on an agile team with Visual Studio 11 and Team Foundation Server 11 • Improving software quality using Visual Studio 11 C++ Code Analysis

Page 41: for (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; for (i = 0; i < 1024; i+=4) C[i:i+3] = A[i:i+3]*B[i:i+3]; #pragma loop(hint_parallel ( N ) ) for

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista 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.