2.
Revision 1.1

Copyright© 2011, XLsoft K.K. All rights reserved.

1•––––••(PGO)

Copyright© 2011, XLsoft K.K. All rights reserved.

2C++ Front End

FortranFront EndInter-procedural
Optimizer (IPO)
High-level
Optimizer (HLO)

Profile Guided
Optimizer (PGO)

Vectolizer
Pallalelizer
Code Generator

Copyright© 2011, XLsoft K.K. All rights reserved.

3

High Performance Optimizer (HPO)
subroutine matmul(a,b,c,n)real(8), dimension(n,n) :: a,b,c!4
c=0.d0!$omp parallel do!5
do i=1,n!6do j=1,n!7
do k=1,n!8c(j,i)=c(j,i)+a(k,i)*b(j,k)
enddo
enddo
enddo
end

matmul.f90(5): (col. 7) : OpenMP DEFINED LOOP WAS
PARALLELIZEDHigh Level Optimizer Report (matmul_)matmul.f90(4): (col. 1) : LOOP WAS VECTORIZED.
matmul.f90(7): (col. 3) : PERMUTED LOOP WAS VECTORIZED.
LOOP INTERCHANGE in loops at line: 7 8
Loopnest permutation ( 1 2 3 ) --> ( 1 3 2 )Block, Unroll, Jam Report:(loop line numbers, unroll factors and type of transformation)
Loop at line 7 blocked by 111
Loop at line 8 blocked by 111
Loop at line 6 blocked by 111
Loop at line 6 unrolled and jammed by 4
Loop at line 8 unrolled and jammed by 4

OpenMP

4-4
Copyright© 2011, XLsoft K.K. All rights reserved.

4

•
–
•

:
––––––––

Copyright© 2011, XLsoft K.K. All rights reserved.

5

:
RAW••
•

:

for (j=1; j<MAX; j++) {A[j]=A[j-1];}
A[1]=A[0];A[2]=A[1];Copyright© 2011, XLsoft K.K. All rights reserved.

6

float a[Y+1][X+1];
a[0][0]~a[0][X]

a[1][0]~a[1][X]a[2][0]~a[2][X]a[Y][0]~a[Y][X]a[0][0], a[0][1], a[0][2], a[0][3],…..

i 1
C/C++
Fortrana[ j][ i]a( i , j)
Copyright© 2011, XLsoft K.K. All rights reserved.

7

for (i=0;i<=MAX;i++)for (j=0;j<=MAX;j++) {c[i][j]+=1; //c[j][i]+=1; //A[j*j]+=1;//
A[B[j]]+=1; //if (A[MAX-j]=1) last1=j;}//••

Copyright© 2011, XLsoft K.K. All rights reserved.

8••::•1264

Index 0Index 0Index 1

Copyright© 2011, XLsoft K.K. All rights reserved.

Index 15

Index 169• movdqa16•

16• AVX32(256bit)__declspec(align(16)) float A[100][1024];
real*4 A(1024,100)!DEC$ATTRIBUTES ALIGN: 16:: A

Copyright© 2011, XLsoft K.K. All rights reserved.

10

•

float

real*41250*1250

float A[1250][1250];
real*4 A(1250,1250)•16, 32
16, 32(padding bytes) 414
4 * 1264 = 2 * 2 * 16 * 79

(56)

float A[1250][1264];
real*4 A(1264,1250)

16(32)

Copyright© 2011, XLsoft K.K. All rights reserved.

11

C,C++#pragma vector alignedfor (i=0; i<n; i++){C[i] = A[i] * B[i];}Fortran!DIR$ VECTOR ALIGNEDDO I=1, N
C(I) = A(I) * B(I)ENDDO

Copyright© 2011, XLsoft K.K. All rights reserved.

12

#pragma pack(push,thepack,1)struct PackedStr {charData;intptr_t Next;/*Pointer */intExtraInfo; /*int*/};#pragma pack(pop,thepack)Linux*-Zp[n]1 2 4 8

Windows*/Zp[n]16Copyright© 2011, XLsoft K.K. All rights reserved.

13

x86x86_64

Struct Astruct {char A; ////Padchar B; ////Padvoid *B;////Padchar C; ////Pad1012401310168017}

12 Byte24 Byte//TotalCopyright© 2011, XLsoft K.K. All rights reserved.

14

•
––––

••

(PGO)

Copyright© 2011, XLsoft K.K. All rights reserved.

15

-ip:-ipo:––––––

Copyright© 2011, XLsoft K.K. All rights reserved.

16

- IPO
2Linux*icc -c -ipo main.c func1.c func2.c

Windows*

icl -c /Qipo main.c func1.c func2.c

1.o

※

2
※

Linuxicc -ipo main.o func1.o func2.oWindows

icl /Qipo main.o func1.o func2.o

Copyright© 2011, XLsoft K.K. All rights reserved.

17

for (i=1;i<nx;i++) {x = x0 + i*h;sumx = sumx + func(x,y,xp,yp);}
float func(float x, float y, float xp, float yp){
float denom;
denom = (x-xp)*(x-xp) + (y-yp)*(y-yp);
denom = 1./sqrt(denom);return denom; }for (i=1;i<nx;i++) {x = x0 + i*h;sumx = sumx +1./sqrt((x-xp)*(x-xp) + (y-yp)*(y-yp));}

Copyright© 2011, XLsoft K.K. All rights reserved.

18

•
––––

•
•

(PGO)

Copyright© 2011, XLsoft K.K. All rights reserved.

19

Profile Guided Optimization (PGO)••:––––––

Copyright© 2011, XLsoft K.K. All rights reserved.

20

: -prof_gen/-prof_use
Profile-Guided Optimization: PGO•––
Step 1-prof_gen
icc -prof_gen prog.c: prog.out

Step 2:12345678.dyn ※Step 3:-prof_use

pgopti.dpi

icc -prof_use prog.c※:prog.out.dyn

Copyright© 2011, XLsoft K.K. All rights reserved.

21

PGO:

•if•

switchif•switchCPU()for (i=0; i < NUM_BLOCKS; i++){switch (check3(i)) {case 3:/* 25% */x[i] = 3; break;case 10:/* 75% */x[i] = 10; break;default:/* 0% */
x[i] = 99; break; }}※CPUPGOcase 3case 1075%

Copyright© 2011, XLsoft K.K. All rights reserved.

22

Copyright© 2011, XLsoft K.K. All rights reserved.

23