12.07.2015 Views

Algorithmes de la morphologie mathématique pour - Pastel - HAL

Algorithmes de la morphologie mathématique pour - Pastel - HAL

Algorithmes de la morphologie mathématique pour - Pastel - HAL

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Jaromír BRAMBOR6.4. NOTES SUR L’IMPLÉMENTATION, RÉSULTATS EXPÉRIMENTAUXImageTransposition parMétho<strong>de</strong> diagonale antidiagonaled’implémentation Temps Taux Temps Tauxms d’accélération ms d’accélérationgénérique élément par élément 2.61 0.58 3.02 0.50512 2 × 8 bitsvia pointer++ 1.51 1.00 1.51 1.00instructions MMX 0.30 5.03 0.31 4.87instructions SSE2 0.23 6.57 — —générique élément par élément 61.3 0.99 61.9 0.991024 2 × 8 bitsvia pointer++ 60.9 1.00 61.7 1.00instructions MMX 2.2 27.7 2.2 28.0instructions SSE2 1.8 33.8 — —Implémentation sur Intel Pentium 4 @ 2.4 GHz (single thread, 8 ko L1, 512 ko L2). La zone <strong>de</strong> mémoire <strong>de</strong> sortie est distincte <strong>de</strong>celle d’entrée. Compi<strong>la</strong>teur Intel ICC 8. Taux d’accélération est calculé par rapport à l’implémentation via pointer++ que nousprenons comme étalon (en gras).TAB. 6.1 : <strong>Algorithmes</strong> <strong>de</strong> transposition par diagonale et antidiagonale ; comparaison <strong>de</strong>s temps <strong>de</strong> calcul et<strong>de</strong>s taux d’accélération <strong>pour</strong> diverses implémentations et <strong>de</strong>s tailles d’imagesLe <strong>de</strong>uxième graphique <strong>de</strong> <strong>la</strong> même figure, 6.9(b),void inline Transpose8x8_SSE2(nous présente encore un comportement intéressant <strong>de</strong>sIu8vec8 & mm0, Iu8vec8 & mm1,Iu8vec8 & mm2, Iu8vec8 & mm3,processeurs sur les chiffres <strong>de</strong>s temps d’exécution normalisés<strong>pour</strong> 1 pixel. Il s’agit <strong>de</strong> l’impact <strong>de</strong> <strong>la</strong> mémoire)Iu8vec8 & mm4, Iu8vec8 & mm5,Iu8vec8 & mm6, Iu8vec8 & mm7{cache sur le calcul <strong>de</strong>s images dont <strong>la</strong> taille excè<strong>de</strong> celle__m128i xmm0, xmm1, xmm2, xmm3,__m128i xmm4, xmm5, xmm6, xmm7;<strong>de</strong> <strong>la</strong> mémoire cache. Il s’agit, dans ce cas précis, <strong>de</strong> <strong>la</strong>xmm0 = _mm_movpi64_epi64( (__m64 &) mm0 );mémoire cache L2 <strong>de</strong> notre processeur Intel Pentium 4xmm1 = _mm_movpi64_epi64( (__m64 &) mm1 );xmm2 = _mm_movpi64_epi64( (__m64 &) mm2 );et dont <strong>la</strong> taille est <strong>de</strong> 512 ko.xmm3 = _mm_movpi64_epi64( (__m64 &) mm3 );xmm4 = _mm_movpi64_epi64( (__m64 &) mm4 );Il y a, en effet, <strong>de</strong>ux points à remarquer. Premièrement,on voit bien que <strong>pour</strong> les images qui entrent en-xmm7 = _mm_movpi64_epi64( (__m64 &) mm7 );xmm5 = _mm_movpi64_epi64( (__m64 &) mm5 );xmm6 = _mm_movpi64_epi64( (__m64 &) mm6 );tièrement dans <strong>la</strong> mémoire cache (images 128 2 , 256 2 etxmm4 = _mm_unpacklo_epi8(xmm0, xmm4);xmm5 = _mm_unpacklo_epi8(xmm1, xmm5);512 2 ), le coût du calcul est moindre à celui <strong>de</strong>s imagesxmm6 = _mm_unpacklo_epi8(xmm2, xmm6);xmm7 = _mm_unpacklo_epi8(xmm3, xmm7);qui n’y entrent pas (1024 2 , 2048 2 , 4096 2 ). Pour lesxmm2 = xmm6;<strong>de</strong>rnières, nous ne profitons pas d’un accès rapi<strong>de</strong> auxxmm2 = _mm_unpacklo_epi8(xmm4, xmm2);xmm3 = xmm7;données et le surcoût <strong>de</strong>vrait correspondre au tempsxmm3 = _mm_unpacklo_epi8(xmm5, xmm3);xmm6 = _mm_unpackhi_epi8(xmm4, xmm6);d’attente re<strong>la</strong>tive à <strong>la</strong> préparation <strong>de</strong>s données nonprésentesdans <strong>la</strong> mémoire cache.xmm1 = _mm_unpacklo_epi8(xmm2, xmm1);xmm7 = _mm_unpackhi_epi8(xmm5, xmm7);xmm1 = xmm3;xmm3 = _mm_unpackhi_epi8(xmm2, xmm3);Deuxièmement, nous pouvons apercevoir un comportementparticulier <strong>pour</strong> les images 1024 2 , 2048 2 ,xmm7 = _mm_unpackhi_epi8(xmm6, xmm7);xmm5 = xmm7;xmm5 = _mm_unpacklo_epi8(xmm6, xmm5);4096 2 , c’est-à-dire les images dont <strong>la</strong> taille est plus(__m64 &)mm0 = _mm_movepi64_pi64(xmm1);xmm1 = _mm_srli_si128(xmm1, 8);gran<strong>de</strong> que celle <strong>de</strong> <strong>la</strong> mémoire cache L2. Pour ces(__m64 &)mm1 = _mm_movepi64_pi64(xmm1);(__m64 &)mm2 = _mm_movepi64_pi64(xmm3);<strong>de</strong>rnières, l’écart entre les implémentations SIMD etxmm3 = _mm_srli_si128(xmm3, 8);(__m64 &)mm3 = _mm_movepi64_pi64(xmm3);non-SIMD est beaucoup plus important que <strong>pour</strong> les(__m64 &)mm4 = _mm_movepi64_pi64(xmm5);xmm5 = _mm_srli_si128(xmm5, 8);images qui entrent entièrement dans <strong>la</strong> mémoire cache.(__m64 &)mm5 = _mm_movepi64_pi64(xmm5);Pourtant, le surcoût <strong>de</strong>s transferts <strong>de</strong>s données entre <strong>la</strong>(__m64 &)mm6 = _mm_movepi64_pi64(xmm7);xmm7 = _mm_srli_si128(xmm7, 8);mémoire cache et <strong>la</strong> mémoire principale <strong>de</strong>vrait être,(__m64 &)mm7 = _mm_movepi64_pi64(xmm7);en théorie, le même <strong>pour</strong> les <strong>de</strong>ux manières d’implémentation,puisque le volume <strong>de</strong> données transférées }_mm_empty();return;est i<strong>de</strong>ntique.FIG. 6.8 : Co<strong>de</strong> <strong>de</strong> <strong>la</strong> transposition par diagonaleL’explication <strong>de</strong> ce comportement n’a pas pu êtred’un macro bloc 8 × 8 écrit manuellement eni<strong>de</strong>ntifiée mais vu que les temps <strong>de</strong> traitement <strong>de</strong>viennentimportants <strong>pour</strong> les gran<strong>de</strong>s images, nous bits Intel SSE2<strong>la</strong>ngage C en utilisant le jeu d’instructions 128n’excluons pas <strong>la</strong> possibilité que ce comportement soitlié à <strong>la</strong> manière d’exécution <strong>de</strong> notre programme dans le système d’exploitation multi-tâche, Linux Man-143

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!