Download presentation
Presentation is loading. Please wait.
Published bySharon Evans Modified over 10 years ago
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 (i = 0; i < 1024; i++) C[i] = A[i]*B[i]; N is the number of cores you want to parallelize over
10
#include using namespace concurrency; 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.extent, [=](index i) restrict(amp) { sum[i] = a[i] + b[i]; } ); } void AddArrays(int n, int * pA, int * pB, int * pC) { for (int i=0; i<n; i++) { pC[i] = pA[i] + pB[i]; } portable view that works like an N-dimensional “iterator range” tells the compiler to check that this code can execute on Direct3D hardware execute the lambda on the accelerator once per thread
13
circle* p = new circle( 42 ); vector vw = load_shapes(); for( vector ::iterator i = vw.begin(); i != vw.end(); ++i ) { if( *i && **i == *p ) cout << **i << “ is a match\n”; } for( vector ::iterator i = vw.begin(); i != vw.end(); ++i ) { delete *i; } delete p; auto p = make_shared ( 42 ); vector > vw = load_shapes(); for_each( begin(vw), end(vw), [&]( shared_ptr & s ) { if( s && *s == *p ) cout << *s << “ is a match\n”; } ); Then Now new make_shared T* shared_ptr 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
15
C++11 Core Language Features VC10VC11 Rvalue referencesv2.0v2.1* Lambdasv1.0v1.1 decltypev1.0v1.1** autov1.0 static_AssertYes Trailing return typesYes nullptrYes Strongly typed enumsPartialYes Forward declared enumsNoYes Standard-layout and trivial typesNoYes AtomicsNoYes Strong compare and exchangeNoYes Bidirectional fencesNoYes Data-dependency orderingNoYes
19
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++
24
void MainPage::detectButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { // detectButton handler FaceFileList->Clear(); WinRTComponent^ faceDetectComponent = ref new WinRTComponent(); auto action = faceDetectComponent- >ExtractFacesFromFilesAsync(localSrcFileVector); }
25
namespace winrtfacedetect { public ref class WinRTComponent sealed { public: WinRTComponent(); IAsyncActionWithProgress ^ ExtractFacesFromFilesAsync(IVector ^ inFileVector); IVector ^ SearchFiles(String^ query); private: Vector ^ getPathsFromFiles(IVector ^ inFileVector); }; }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.