Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1

2

3

4

5

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

7

8

9

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

11

12

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

14

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

16

17

18

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++

20

21

22

23

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); }; }

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46


Download ppt "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."

Similar presentations


Ads by Google