the c++ compiler is obsessed with optimization: in this case, it will auto-vectorize the loop

Download The C++ compiler is obsessed with optimization: In this case, it will auto-vectorize the loop

If you can't read please download the document

Upload: orlando-marn

Post on 14-Dec-2015

220 views

Category:

Documents


4 download

TRANSCRIPT

  • Slide 1

Slide 2 Slide 3 Slide 4 Slide 5 Slide 6 Slide 7 Slide 8 Slide 9 Slide 10 Slide 11 Slide 12 The C++ compiler is obsessed with optimization: In this case, it will auto-vectorize the loop Slide 13 B[0] B[1] B[2] B[3] A[0] A[1] A[2] A[3] A[0] + B[0] A[1] + B[1] A[2] + B[2] A[3] + B[3] + xmm1 xmm0 addps xmm1, xmm0 xmm1 for (i = 0; i < 1000; i++) { C[i] = A[i]+B[i] } for (i = 0; i < 1000; i+=4) { C[i:i+3] = A[i:i+3]+B[i:i+3] } Slide 14 Slide 15 info C5002: loop not vectorized due to reason 501 Slide 16 Slide 17 info C5001: loop vectorized Slide 18 Slide 19 Slide 20 Lots of triangles: we have less than 15ms to turn a page in real time; we need to parallelize this algorithm C++ AMP is a good candidate, since the data size is pretty large Slide 21 Were looping over each triangle This set of operations is safe, because it works on a single triangle at each time, no races But here were updating vertexes which are shared between triangles -> race! This algorithm only works on a single thread Slide 22 for each triangle for each vertex Slide 23 We use C++ AMP Same as before, we calculate the normals for each triangle We collect the normals into a temporary array, which stay in GPU memory Slide 24 We go over each vertex, so no races In sumTriangleNormals, we fetch the normals from tempTriangleNormals, i.e., the temporary we kept on the GPU memory Slide 25 Slide 26 Slide 27 Slide 28 Slide 29 Slide 30 Slide 31 Please submit session evals on the Build Windows 8 App or at http://aka.ms/BuildSessionshttp://aka.ms/BuildSessions Slide 32 MICROSOFT DEVELOPER DIVISION DESIGN RESEARCH EXPERIENCE DEVELOPMENT TOOLS AND FEATURES EARLY IN THEIR DESIGN AND DEVELOPMENT INFLUENCE FUTURE DESIGN DECISIONS FILL IT ONLINE AT http://bit.ly/x6dtHt Slide 33 Slide 34 Slide 35 Slide 36 Slide 37 Slide 38