[td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanbat and ayman shoukly)

72
Ayman Shoukry – Principal Group Program Manager – Visual C++, Microsoft Ulzii Luvsanbat – Principal Software Engineering Manager – Visual C++, Microsoft What’s New in Visual Studio 2015 and Future Directions

Upload: sang-don-kim

Post on 21-Jan-2018

688 views

Category:

Software


1 download

TRANSCRIPT

Ayman Shoukry – Principal Group Program Manager – Visual C++, Microsoft

Ulzii Luvsanbat – Principal Software Engineering Manager – Visual C++, Microsoft

What’s New in Visual Studio 2015 and Future Directions

A note on our mission

• Visual Studio will be the best IDE out there for EVERY C++ developer. • Not just Windows developers • Especially for Open Source developers

• C++ is *the* language for cross platform development • Which is why C++ development is actually growing share amongst p

ro devs

• We can make C++ development more productive

• Finish catching up on conformance, participate in standards bodies to help make the language better. Stay caught up.

Saving the worst for second

Pick ME!!!

Not new: Common Misconceptions

•You can still target XP in VS2015

•You can still do app-local deployment

Demo: Language Agnostic IDE Goodness

• Custom Window Layouts

• Touch screen enhancements

• Send-a-smile (or frown if you must)

• Find in file append

• Git and Github integration

Demo: C++ IDE Productivity

• Refactors (precision and accuracy) • Create Definition <-> Declaration (multiple)

• Move function definition

• Implement Pure Virtual

• Rename

• Extract Method

• Convert to Raw String Literal

• Single File Intellisense • Quick editing of a makefile project or file->new file and int main, etc

Refactoring for C++

• Extract Method (VS Extension)

Refactoring for C++

• Rename

Productivity (IDE)

Refactoring for C++

• Implement Pure Virtuals Quickly implement pure virtual functions in inherited constructs

• Create Declaration/Definition Quickly create a function’s declaration from its definition (and vice-versa)

• Move Definition Location Move a function’s declaration inline and out-of-line

• Convert to Raw-String Literal Convert strings littered with escape sequences into a much more easily readable form

Productivity (IDE)

std::string s = "\nSome reasons this string is hard to read:\n\t1. It would go off the screen in your editor\n\t2. It has sooooo many escape sequences.\n\nThey should make a type for this called \"long\" string, har har har.\n\nHave fun parsing this! (maybe\?)\n";

std::string s = R"( Some reasons this string is hard to read:

1. It would go off the screen in your editor 2. It has sooooo many escape sequences.

They should make a type for this called "long" string, har har har. Have fun parsing this! (maybe?) )";

Single-File Browsing and IntelliSense support

• Open any source file from disk, and enjoy basic browsing and IntelliSense features

(May require setting some defaults)

Productivity (IDE)

• Universal App Easily create projects targeting Store and Phone simultaneously, with a unified IntelliSense experience in the IDE

• Faster, Improved Database Population Operations like Go To Definition are generally no longer blocked during solution scan, which in turn completes much faster especially for large solutions

• Simplified QuickInfo for Template Deduction Elimination of redundant/unhelpful information

• Auto-PCH (VS Extension) Generate a pre-compiled header based on your project structure for faster compile time

Productivity (IDE)

• New and Improved Exceptions “Dialog”

Productivity (IDE)

• New and Improved Error List

Productivity (IDE)

GPU Usage (available in VS2013 Update 4)

• Launch from the Diagnostics hub

• Create real-time graphs for Frame Time, Frame Rate, and GPU Utilization

• Analyze detailed GPU usage by inspecting the GPU and CPU execution time of each individual DirectX event

Productivity (Diagnostics)

Visual Studio Graphics Diagnostics

• Visual Studio Graphics Analyzer (VSGA) A dedicated space for analyzing graphics frames

• Shader Edit & Apply View impact of shader code changes without re-running the app

• Full support for DirectX12

Productivity (Diagnostics)

Native Memory Profiler

• Monitor live memory consumption and take heap snapshots during a debugging session inside Visual Studio. • View heap contents with C++ types, values, and call stack for each allocation (valu

es are shown only during a break point).

• Diff two snapshots to identify potential leaks.

• Navigate directly to source code from the allocations of interest.

• In-line data tips that show line by line memory performance and link to source • See how much memory is being consumed between break points.

• Easily navigate between source code and heap snapshots.

Productivity (Diagnostics)

Inspect instance values and their allocation call stacks

• Memory Performance Data Tips

Take heap snapshots and view C++ object types

See how much memory is consumed between two breakpoints!

Productivity (Diagnostics)

Native Memory Profiler

• Real-time heap analysis

IDE • Refactoring for C++

• Rename

• Extract Method (VS Extension)

• Implement Pure Virtuals

• Create Declaration/Definition

• Move Function Definition

• Convert to Raw-String Literal

• Single-File Browsing and IntelliSense Support

• Universal App

• Faster, Improved Database Buildup

• Simplified QuickInfo for Template Deduction

• Auto-PCH (VS Extension)

Productivity

Build Improvements • Faster linker when performing full linking

• Improvements in Compiler for template processing and diagnostics

Diagnostics • GPU Usage Tool (VS2013 Update 4)

• Visual Studio Graphics Analyzer

• Shader Edit & Apply

• Full support for DirectX12

• Native Memory Profiler

Simplified Template IntelliSense

• Visual Studio 2013:

• Visual Studio 2015:

New C++11 / C++14 features in VS2015 + Update 1 • Generic lambdas (C++14) • Init-captures (C++14) • Auto and decltype(auto) return types

(C++14) • Inheriting constructors • Magic statics • C++11 constexpr (bugfixes in Updat

e 1) • Noexcept • Sized-deallocation (C++14) • Attributes • Alignment

• User-defined literals • char16_t and char32_t • Unrestricted unions • Ref-qualifiers • Inline namespaces • Universal character names in literals • Unicode string literals • Binary literals (C++14) • Digit separators (C++14) • Await (update 1) (C++17?) • Expression SFINAE (Update 1)

// Generic Lambdas

auto const print = [](auto&& thing)

{

std::cout << thing << '\n';

};

print("Hello, world!");

print(123);

// Generalized Lambda Capture

std::unique_ptr<int> four = std::make_unique<int>(4);

auto const multiply = [multiplier = std::move(four)](int const multiplicand)

{

return *multiplier * multiplicand;

}

Lambda Enhancements

// Non-throwing functions may be declared noexcept

void f() noexcept;

void g();

// Can test whether a function is declared noexcept

bool const is_f_noexcept = noexcept(f());

bool const is_g_noexcept = noexcept(g());

//Can conditionally make a function noexcept

void h() noexcept(f);

template <typename F>

void call(F&& lambda) noexcept(lambda());

// If you violate a noexcept specification, std::terminate is called deterministically

noexcept

namespace foo

{

inline namespace bar

{

void print() { /* ... */ }

}

}

// Names in foo::bar are used without inline namespace name:

foo::print();

// Name is decorated with inline namespace name:

?print@bar@foo@@YAXXZ (void __cdecl foo::bar::print(void))

Inline Namespaces

void f()

{

// Every thread will get its own 'state' variable

thread_local int state = 0;

}

Thread-Local Storage (thread_local)

std::ofstream open_log_stream();

void write_to_log(std::string&& value)

{

std::ofstream log_stream = open_log_stream();

log_stream << value;

}

Thread-Safe Local Static Initialization

struct detector

{

void print() & { puts("non-const lvalue"); }

void print() const& { puts("const lvalue"); }

void print() && { puts("non-const rvalue"); }

void print() const&& { puts("const rvalue"); }

};

detector x;

x.print(); // non-const lvalue

const_cast<detector const&>(x).print(); // const lvalue

detector().print(); // non-const rvalue

const_cast<detector const&&>(detector()).print(); // const rvalue

Ref-Qualifiers

// Literals may now be specified in binary

uint16_t const hex_mask = 0xf0f0;

uint16_t const bin_mask = 0b1111000011110000;

// The ' may now be used as a digit separator

uint32_t const max_value = 4'294'967'295;

uint32_t const max_value = 0xff'ff'ff'ff;

uint16_t const bin_mask = 0b1111'0000'1111'0000;

uint16_t const bin_mask = 0b111'100'001'111'000'0;

uint16_t const bin_mask = 0b1'1'1'1'0'0'0'0'1'1'1'1'0'0'0'0;

Binary Literals and Digit Separators

int main()

{

std::cout << __func__ << '\n'; // main

std::cout << __FUNCTION__ << '\n'; // main

}

template <typename T>

void f(T const& s)

{

std::cout << __func__ << '\n'; // f

std::cout << __FUNCTION__ << '\n'; // f

}

__func__

// Can inspect alignment of things using alignof

size_t const alignment_of_uint16_t = alignof(uint16_t); // 4

size_t const alignment_of_m256 = alignof(__m256 ); // 32

// Can align objects to a specified alignment

alignas(alignof(32)) unsigned char buffer[32];

Alignment: alignof and alignas

char a = 'x';

char b = '☃'; // Wrong

char c = '🍸'; // Wrong

char16_t d = u'x';

char16_t e = u'☃';

char16_t f = u'🍸'; // Wrong

char32_t g = U'x';

char32_t h = U'☃';

char32_t i = U'🍸';

char a = '\u0078';

char b = '\u2603'; // Wrong

char c = '\U0001F378'; // Wrong

char16_t d = u'\u0078';

char16_t e = u'\u2603';

char16_t f = u'\U0001F378'; // Wrong

char32_t g = U'\U00000078';

char32_t h = U'\U00002603';

char32_t i = U'\U0001F378';

Unicode Character Literals

char const a[] = u8"Hello, \u2603!";

char const b[] = u8"Hello, ☃!";

// sizeof(a) == sizeof(b) == 12

char16_t const c[] = u"Hello, \u2603!";

char16_t const d[] = u"Hello, ☃!";

// sizeof(c) == sizeof(d) == 20

char32_t const e[] = U"Hello, \u2603!";

char32_t const f[] = U"Hello, ☃!";

// sizeof(e) == sizeof(f) == 40

Unicode String Literals

std::string a = u8"Hello, \u2603!";

std::string b = u8"Hello, ☃!";

std::u16string c = u"Hello, \u2603!";

std::u16string d = u"Hello, ☃!";

std::u32string e = U"Hello, \u2603!";

std::u32string f = U"Hello, ☃!";

Unicode std::string Specializations

// Return types can be automatically deduced:

auto get_value() { return 10; }

// ...This is especially useful for templates:

template <typename T, typename U>

auto multiply(T&& multiplier, U&& multiplicand)

{

return multiplier * multiplicand;

}

Return Type Deduction

// Your entire program in C++17:

auto auto(auto) { auto; }

A Brief Interlude: A Preview of C++ 17

struct my_type

{

std::unique_ptr<int> _x;

std::unique_ptr<int> _y;

};

my_type get_object()

{

my_type value;

value._x.reset(new int(1));

value._y.reset(new int(4));

return value; // C2280 Attempting to reference a deleted function

}

Implicitly-Defined Move Operations (Before)

struct my_type

{

std::unique_ptr<int> _x;

std::unique_ptr<int> _y;

};

my_type get_object()

{

my_type value;

value._x.reset(new int(1));

value._y.reset(new int(4));

return value; // C2280 Attempting to reference a deleted function

}

Implicitly-Defined Move Operations (Now)

long double operator""_€(long double const euros)

{

return euros * 1.11;

}

double cost_of_🍺_in_dollars = 3.50_€; // $3.885

User-Defined Literals

#define countof(x) (sizeof((x)) / sizeof((x[0])))

char input_buffer[100];

char output_buffer[countof(input_buffer)];

constexpr

template <typename T, size_t N>

size_t countof(T(&)[N])

{

return N;

}

char input_buffer[100];

char output_buffer[countof(input_buffer)]; // C2057: Expected constant expression

constexpr

template <typename T, size_t N>

constexpr size_t countof(T(&)[N])

{

return N;

}

char input_buffer[100];

char output_buffer[countof(input_buffer)]; // C2057: Expected constant expression

constexpr

constexpr size_t fibonacci(size_t const n)

{

return n == 0 ? 0

: n == 1 ? 1

: fibonacci(n - 1) + fibonacci(n - 2);

}

char buffer[fibonacci(10)]; // buffer has 55 elements

constexpr

auto multiples_of(unsigned n)

{

unsigned current = n;

for (;;)

{

yield current;

current += n;

}

}

int main()

{

for (unsigned i : multiples_of(3))

{

printf("%d ", i);

if (i > 100) { break; }

}

}

// 3 6 9 12 15 18 21 24 27 30 33 36 39 42 ...

Resumable Functions (await)

size_t fibonacci(size_t const n)

{

return n == 0 ? 0

: n == 1 ? 1

: fibonacci(n - 1) + fibonacci(n - 2);

}

char buffer[fibonacci(10)]; // buffer has 55 elements

Expression SFINAE

What’s still missing?

• Expression SFINAE to complete C++11 • Major refactor needed -> parse trees • Significant progress in Update 1 – Partial Support

• Generalized Constexpr (C++14) • LARGE

• NSDMIs for aggregates (C++14) • small

• Variable templates (C++14) • Available under an experimental switch in Update 1

• Two-phase lookup

• C99 Preprocessor

STL conformance for VS2015

• Everything but:

Status Std Paper Title

missing C++14 N3462 SFINAE-Friendly result_of

missing C++17 N4387 Improving pair And tuple

missing C++17 N4508 shared_mutex (Untimed)

Library updates

• Universal CRT • From Windows 10 and up, CRT is an OS component • Still supported down to XP • No more breaking changes

• MFC updates: • Dynamic Layout / Auto-resize for dialogs

• New libraries • Parallel STL

• New version of Casablanca C++ REST SDK • OSS and takes contributions • WebSockets • oAuth 1.0 and 2.0 • OSX/iOS support, Android, WP8.1, Windows 10 Universal

Introducing Clang / C2 Toolset

• Clang / C2 hooks up the Clang front-end to the MSVC backend

• Why? • use the same frontend to reduce overhead of bring cross-plat librari

es and code to Windows • no compromises debugging • link compatible with MSVC code (same libraries) • Preview coming in Update

• No, we aren't going to stop investing in our existing front-end (c1/c1xx) • we respect your investment in your existing code base

A quick note on C99 / C11

• We care about C.

• Our gap isn’t really that large in practice • Tgmath.h

• Variable length arrays (optional in C11)

• Complex types

• Some other nits

• We’ll get this via Clang / C2

New for DirectX Devs

• DirectX12 support • Shader Edit and

Apply • Consecutive Capture • Programmatic

Capture • Dedicated UI for

Graphics Analysis

Productivity pt. 2: Build Throughput

credit: This is my favorite xkcd.com strip

of all time

• Compiler • Faster template processing

• PDB • Reduced PDB generation time • /Debug:fastlink

• Linker • Incremental linking for static libraries • Algorithmic improvements

• LTCG & PGO • Fast LTCG • PGO instrumented builds has lower overhead

• General algorithmic improvements

across tools

Build Throughput Improvements

958 595 57

71

(7%)

285

(48%)

39

(68%)

K INECT SPORTS R IVAL CHROME OGRE 3D

INCREMENTAL BUILD (SEC)

VS2013 VS2015

715 2417 508

(71%) 1480

(61%)

OGRE 3D B ING ( STAT IC L I B )

FULL BUILD (SEC)

VS2013 VS2015

• 75%

C++

• Messenger • Facebook • Pandora Radio • Instagram • Minecraft • Snapchat • Spotify Music • Du Speed Booster • Twitter • The Game of Life • Super Bright LED FlashLight • Soda Saga • Skype – Free • Whatsapp Messenger • Clean Master • Netflix • Kik • Crossy Road • Clash of Clans • Amazon Shopping • Candy Crush e IM and Video Calls • 8 Ball Pool • Glass Tower • Subway Surfers • Pinterest • Cooking Fever • Zedge Ringtones and Wallpaper • Word Academy

• Poshmark - Buy and Sell • Candy Crush Saga • Dragon Blaze • Marvel Future Fight • Emoji Keyboard • DU Battery saver • SoundCloud - Music and Radio • Monopoly • Twitter • CM Security Antivirus • Slots - Journey of Magic • Yahoo Mail - Free Email App • iHeart Radio - Radio and Music • Temple Run 2 • Boom Beach • Despicable me • ebay • Wish - shopping made fun • Trivia Check • Juice Jam • Game of War - Fire Age • TouchPal Keyboard • Geometry Dash Lite • Flow Free • Bird Climb • Coin Dozer • Uber

• Google Earth • Flow Free • Bird Climb • Coin Dozer • Uber • Google Earth • Archery Master 3d • Go Keyboard - Emoji • ooVoo video call • Inbox by Gmail • Samsung Smart Switch Mobile • Tango - Free video call and chat • Earn to Die 2 • Fruit Ninja Free • Farm Heroes Saga • Wallapop • Capital One Wallet • Truck Driver 3d: offroad • Solitare • Plants vs Zombies • Hidden Object - Marrinotes • Tinder • DropBox • Hulu • Extreme Car driving simulator • The Sims 3 • Word Search • Hidden Object - Marrinotes

• Tinder • Hulu • Extreme Car driving simulator • Need for Speed Most Wanted • Angry Birds • Shazam • MyRadar Weather Radar • Vine • Line: Free calls and messages • Waze Social GPS Maps • Google Translate • Don't tap the white tile • Panda Pop • EA Sports UFC • Flipagram • Hill Climb Racing • Tasty Tale - The Cooking Game • Yelp • Offer Up - Buy, sell • CM Launcher - Boost, Secure • Temple Run • Empire and Allies • Google Docs • Tetris • Battery Doctor • Beats Music • Walmart • Surgery Doctor • EA FrostBite

C++ C++ C++

• Code Reuse

• Performance

• Security

.appx .apk .ipa

C#, C++/Cx Java Dex / ART

ObjC Swift

Dynamic Link Library (.dll) Static Library (.lib)

Dynamic shared library (.so) Static library (.a)

Static library (.a)

Shared C++ backend is compiled as:

DropBox

Cross-platform C++ demo

Android Development Features

• Supported versions • 4.4 “KitKat”, API Level 19

• 5.0 “Lollipop”, API Level 21

• Emulator features include • OpenGL ES 2.0

• Multi-touch gestures

• Advanced camera simulation

• WiFi network simulation

• Debug directly from Visual Studio • Integrated LogCat viewer

• Natvis debugger visualizations

• Externally built native activity apps

• Can attach to running APKs

• “Stripped” debugging to reduce deployment size

• Deploy, Debug directly from VStudio. Emulator or devices.

iOS Development Features

• Supports versions 6, 7, and 8 • Debug directly from Visual Studio

• Need a Mac connected deploy and debug on devices only (no emulator)

Universal Windows Platform Development • Develop one app for all Windows 10 devices

• Apps automatically switch between desktop, phone, tablet, Xbox and Surface Hub configurations to fit screen size and input types

• Unified app store

• Design your UI in XAML with WYSIWYG editor

• You can use C++, C#, VB, or HTML/JavaScript

• Easily port Android and iOS apps

Vectorization of control flow

• Vectorization of loops with if-then-else

void blackscholes(float* input, int *signArray, int n) { for (int i = 0; i < n; i++) { float InputX = input[i]; int sign; if (InputX < 0.0f) { InputX = -InputX; sign = 1; } else { sign = 0; } input[i] = InputX; signArray[i] = sign; } }

mask = InputX < 0.0f ? 0xFFFFFFFF : 0; InputX = (mask & -InputX) | (~mask & InputX); sign = (mask & 1) | (~mask & 0);

Optimized to branch-less code

300%+ speedup in blackscholes benchmark

Better stall-forward-avoidance

• Writes to large structures followed by reads from substructures can lead to hardware stalls.

• New optimizations targeted at std::complex<float> and std::complex<double>

• Improved code generation of VUNPCKLPD/VUNPCKLPS instructions

• 40% speedup in Eigen quaternion multiplication

code • 35% speedup in Eigen FFT code

Bit-test merging

• Optimizations targeting cascading bit tests:

if ((((data->bitfield >> 3) & 1) != 0) || (((data->bitfield >> 6) & 1) != 0) || (((data->bitfield >> 9) & 1) != 0) || (((data->bitfield >> 4) & 1) != 0) || (((data->bitfield >> 8) & 1) != 0)) { ... }

Source code:

if ((data->bitfield & 0x1258) != 0) { ... }

Optimized as if:

• Matters in code dealing with bitfields 14% speedup in

quantum mechanics benchmark

Loop-if unswitching

• Improved code generation for loop-invariant control flow

for (int i = 0; i < 100; i++) if (some_invariant_condition) ...

Source code:

if (some_invariant_condition) for (int i = 0; i < 100; i++) ...

Optimized as if:

Hits often, especially when considering inlining

Other code generation improvements • #pragma loop(ivdep)

• Better vectorization of STL constructs (range based for-loops, std::vector)

• Vectorization under /O1 (optimize for size)

• Better codegen of std::min/std::max (200% improvement in runtime)

• Better instruction emission for bit-test (more BT, BTC, BTR, BTS)

• Plus much more…

What’s next: Compiler features (conformance) in Updates • No need to wait for major VS updates

• Features include: • Safer C++ • Modules • Await completed in Update 1 (to current proposal) • Clang/C2

• No breaking changes by default

What’s next: IDE productivity and build-lab scenario • More Refactorings

• VC ++ Scalability and Perf

• Build-time improvements

• Standalone Build tools

What’s next: Early thoughts!!

• Come talk to us about your Linux / IoT dev! • E.g. Remote Linux debugging

• Come talk to us about what you want from VS Code for C++!

Resources

• VCBlog – best way to follow us • http://blogs.msdn.com/b/vcblog/

• Channel 9 – Going Native • https://channel9.msdn.com/Shows/C9-GoingNative

감사합니다.

• MSDN Forum http://aka.ms/msdnforum

• TechNet Forum http://aka.ms/technetforum

• Ayman Shoukry: [email protected]

• Ulzii Luvsanbat: [email protected]

http://aka.ms/td2015_again

TechDays Korea 2015에서 놓치신 세션은 Microsoft 기술 동영상 커뮤니티 Channel 9에서

추후에 다시 보실 수 있습니다.