Presentation is loading. Please wait.

Presentation is loading. Please wait.

MAXIMISE.NET WITH C++ FOR INTEROP, PERFORMANCE AND PRODUCTIVITY Angel Hernandez Avanade Australia (c) 2011 Microsoft. All rights reserved. SESSION CODE:

Similar presentations


Presentation on theme: "MAXIMISE.NET WITH C++ FOR INTEROP, PERFORMANCE AND PRODUCTIVITY Angel Hernandez Avanade Australia (c) 2011 Microsoft. All rights reserved. SESSION CODE:"— Presentation transcript:

1

2 MAXIMISE.NET WITH C++ FOR INTEROP, PERFORMANCE AND PRODUCTIVITY Angel Hernandez Avanade Australia (c) 2011 Microsoft. All rights reserved. SESSION CODE: DEV301 http://www.bonafideideas.com

3 regex_searchregex_search replace_ifreplace_if thread_localthread_local find_if_notfind_if_not VisualC++VisualC++ binary_searchbinary_search setlocalesetlocale s t d :: v e c t o r s t d :: c o u t inlineinline typedeftypedef 01010110101011 make_pairmake_pair s t d :: f o r _ e a c h getlinegetline volatilevolatile sleep_forsleep_for templatetemplate void(*ptr)void(*ptr) dynamic_castdynamic_cast bitsetbitset is_sortedis_sorted #include<iostream>#include<iostream> LambdasLambdas nullptrnullptr mutexmutex.. : ¦

4 Agenda ► What’s going on with C++ these days? ► C++ is the champion of speed ► Best situations for C++ ► C++/CLI ► Commonly used techniques for interop ► Native code without sacrificing.NET performance ► C++ and the cloud ► Introducing C++ AMP ► Basic Elements of C++ AMP Coding ► C++ AMP at a Glance (c) 2011 Microsoft. All rights reserved.

5 What’s going on with C++ these days? ► The new standard C++11 (previously known as C++0x) will be released soon ► Native support for multi-threaded applications ► New smart pointer classes, algorithms and containers ► Lambda expressions ► Automatic Type Deduction and decltype ► Lots more! (c) 2011 Microsoft. All rights reserved.

6 C++ is the champion of speed! (c) 2011 Microsoft. All rights reserved.

7

8 Best situations for C++ ► Graphical and audio workstation software ► Large-scale productivity applications like Adobe Photoshop ► Legacy codebases ► Real-time systems of all sizes and descriptions ► Anything involving extreme numerical computation ► Large-scale data storage and retrieval ► Device drivers ► And so forth (c) 2011 Microsoft. All rights reserved.

9 C++/CLI ► C++/CLI is a binding between the standard C++ programming language and the CLI. ► C++/CLI lets developers reuse their native code base, saving the agony of rewriting it all to run on the.NET Framework. ► C++/CLI is designed to be the lowest-level language for the.NET framework. (c) 2011 Microsoft. All rights reserved.

10 C++/CLI (cont.) ► C++ developers can Leverage their existing C++ knowledge to write powerful managed applications ► C++/CLI allows developers to leverage the latest managed frameworks ► C++/CLI is the most powerful language for interop (Marshalling made easy!) (c) 2011 Microsoft. All rights reserved.

11

12 Commonly used techniques for Interop ► Straightforward P/Invoke – [DllImport] & [MarshalAs] ► COM Interop ► C++/CLI wrapper class ► CALLI Instruction (Reflection.Emit) (c) 2011 Microsoft. All rights reserved.

13 Native code without sacrificing.NET performance ► Things to consider: – Mode Transition (Moving data between the managed & unmanaged modes of operation) – Marshalling the data to move across the boundary Marshalling is computationally expensive and the more data you move back and forth, the more expensive it becomes. (c) 2011 Microsoft. All rights reserved.

14 Native code without sacrificing.NET performance (cont.) ► Ways to transition code & data: – Traditional DLLs (code) – COM-based DLLs (code) – Marshalling (data) – Implement any IPC mechanism (data) (c) 2011 Microsoft. All rights reserved.

15

16 C++ and the cloud ► We can leverage the power of C++ with Windows Azure ► Microsoft refreshes C++ for the cloud Not for this version though…. (c) 2011 Microsoft. All rights reserved.

17 Introducing C++AMP (c) 2011 Microsoft. All rights reserved. What – Part of C++ & Visual Studio – STL-like library for parallel patterns on large arrays – Builds on Direct3D – open spec Why – Performance – Productivity – Portability How #include #include using namespace concurrency; void AddArrays(int n, int *pA, int *pB, int *pC) { array_view a(n, pA); array_view a(n, pA); array_view b(n, pB); array_view b(n, pB); array_view sum(n, pC); array_view sum(n, pC); parallel_for_each( sum.grid, parallel_for_each( sum.grid, [=](index idx) restrict(direct3d) { [=](index idx) restrict(direct3d) { sum[idx] = a[idx] + b[idx]; sum[idx] = a[idx] + b[idx]; } ); );}

18 Matrix Multiply (C++ AMP Sample) (c) 2011 Microsoft. All rights reserved.

19 Basic Elements of C++ AMP Coding (c) 2011 Microsoft. All rights reserved. void AddArrays(int n, int * pA, int * pB, int * pC) { array_view a(n, pA); array_view b(n, pB); array_view sum(n, pC); parallel_for_each( sum.grid, [=](index idx) restrict(direct3d) { sum[idx] = a[idx] + b[idx]; } ); } array_view variables captured and associated data copied to accelerator (on demand) restrict(direct3d): tells the compiler to check that this code can execute on Direct3D hardware parallel_for_each: execute the lambda on the accelerator once per thread grid: the number and shape of threads to execute the lambda index: the thread ID that is running the lambda, used to index into data array_view: Wraps the data to operate on the accelerator

20 (c) 2011 Microsoft. All rights reserved.

21 Session Objectives and Takeaways ► No universally “better” language – C++ robust, scalable and amazingly fast – Direct access to hardware and memory – Managed languages for RAD and business applications ► C++ native out-of-the-box support for multithreading (C++0X) ► Develop memory or CPU intensive components in C++ – Consume from any managed language (c) 2011 Microsoft. All rights reserved.

22 Related Content ► Visual C++ MVPs Visual C++ MVPs ► Bonafide Ideas - My Blog Bonafide Ideas ► Visual C++ Team Blog Visual C++ Team Blog ► C9::GoingNative | Channel 9 C9::GoingNative | Channel 9 ► Herb Sutter’s Blog Herb Sutter’s Blog ► Daniel Moth’s Blog (C++ AMP) Daniel Moth’s Blog (C++ AMP) ► Google’s paper on language performance Google’s paper on language performance ► The C++ Standards Committee The C++ Standards Committee ► The Visual C++ Weekly The Visual C++ Weekly ► Visual C++ MSDN Forums Visual C++ MSDN Forums (c) 2011 Microsoft. All rights reserved.

23 Enrol in Microsoft Virtual Academy Today Why Enroll, other than it being free? The MVA helps improve your IT skill set and advance your career with a free, easy to access training portal that allows you to learn at your own pace, focusing on Microsoft technologies. What Do I get for enrolment? ► Free training to make you become the Cloud-Hero in my Organization ► Help mastering your Training Path and get the recognition ► Connect with other IT Pros and discuss The Cloud Where do I Enrol? www.microsoftvirtualacademy.com Then tell us what you think. TellTheDean@microsoft.com

24 www.msteched.com/Australia Sessions On-Demand & Community http:// technet.microsoft.com/en-au Resources for IT Professionals http://msdn.microsoft.com/en-au Resources for Developers www.microsoft.com/australia/learning Microsoft Certification & Training Resources Resources (c) 2011 Microsoft. All rights reserved.

25 © 2010 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. (c) 2011 Microsoft. All rights reserved.


Download ppt "MAXIMISE.NET WITH C++ FOR INTEROP, PERFORMANCE AND PRODUCTIVITY Angel Hernandez Avanade Australia (c) 2011 Microsoft. All rights reserved. SESSION CODE:"

Similar presentations


Ads by Google