Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector...

19
Your corporate logo here Optimization of LESlie3D for the Cray X1 Architecture Sam Cable and Tom Oppe, ERDC MSRC Vicksburg, MS

Transcript of Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector...

Page 1: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

Your corporatelogo here

Optimization ofLESlie3D for the

Cray X1Architecture

Sam Cable and Tom Oppe, ERDC MSRCVicksburg, MS

Page 2: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

We compare execution speeds andprofiles of the CFD code LESlie3D ….…. On the X1, optimized code vs. original.

…. On the X1 vs. on the IBM POWER4.

Page 3: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

The ERDC X1: “Diamond”

• 64 Cray X1 MSPs (256SSPs)

• 60 MSPs available forcomputation(240 SSPs)

• 16 nodes of 4 MSPs each

• Liquid cooled

• 4.5 TB scratch space

Page 4: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

The Code: LESlie3D

Large Eddy Simulation Linear Eddy Model in 3D

•3D Navier-Stokes solver forturbulent reacting flows (e.g.combustion), developed byGa. Tech’s ComputationalCombustion Laboratory•Finite-volume predictor-corrector conservativescheme•4th order accurate in space;2nd order in time•Direct simulation mode andLarge Eddy Simulationmodes available

Page 5: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

LESlie3D Divides Its Structured Mesh IntoSeveral Structured Sub-meshes.

264132 132

264

264

6666

6666

EXAMPLE:

2643 mesh

With 2x4x4 PEs.

Page 6: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

LESlie3D is a vector code, which makes ita good candidate for porting to the X1.

Page 7: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

LESlie3D consistently runs faster inMSP mode than in SSP mode.

100

1000

1 10 100

MSPs ( = SSPs/4)

tim

e (s

ec)

128 mesh; MSPs

128 mesh; SSPs

192 mesh; MSPs

192 mesh; SSPs

216 mesh; MSPs

216 mesh; SSPs

Run times of several 500 timestep runs.

Page 8: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

MSP mode spends less time incommunication.

0.01

0.1

1

1 10 100MSPs ( = SSPs/4)

tim

e (

se

c)

128 mesh; MSPs

128 mesh; SSPs

192 mesh; MSPs

192 mesh; SSPs

264 mesh; MSPs

264 mesh; SSPs

Communication time per timestep.

Page 9: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

MSP runs are also faster incalculation time.

0.1

1

10

1 10 100MSPs ( = SSPs/4)

tim

e (

se

c)

128 mesh; MSPs

128 mesh; SSPs

192 mesh; MSPs

192 mesh; SSPs

216 mesh; MSPs

216 mesh; SSPs

Calculation time per timestep.

Page 10: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

Cray analysts added streamingdirectives to several loops to obtain

multistreaming.

do k = k1,k2 do j = j1,j2 do i = i1,i2

(work) end do end doend do

!CSD$ PARALLEL DOPRIVATE(vars)

do k = k1,k2 do j = j1,j2 do i = i1,i2

(work) end do end doend do!CSD END PARALLEL DO

Page 11: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

Cray analysts broke up other loops topromote load balancing.

do nn = 1,nspeci do k = k1,k2 do j = j1,j2 do i = i1,i2 (work) end do end do end doend do

!CSD$ PARALLEL DOPRIVATE( vars )

do kth=1,4 k1new=k1+(k2-k1+4)/

4*(kth-1) k2new=k1new+(k2-k1+4)/

4 - 1 do nn = 1,nspeci do k = k1new,k2new do j = j1,j2 do i = i1,i2 (work) end do end do end do (other nested loops) end do !CSD$ END PARALLEL DO

Page 12: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

Cray CSD optimizations sped up LESlie3Dby about 20 per cent.

% speedupOriginal Optimized Original Optimized Original Optimized Original Optimized

1923 mesh;16 MSPs;500 timesteps

3:29 2:47 20.10% 84.46% 78.95% 11.06% 15.42% 4.47% 5.63%

2643 mesh;32 MSPs;4000 timesteps

0:44:35 0:35:56 19.40% 83.78% 76.26% 12.44% 18.99% 3.78% 4.75%

Run time% time in

computation% time in

communication% time in

stats

Page 13: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

Optimization generally increased vectoroperations and decreased scalars.

0.01 0.10 1.00 10.00 100.00

Scalar FP ops Scalar integer ops

Scalar memory refs Vector TLB misses Scalar TLB misses

Instr TLB misses Total TLB misses

Dcache references Dcache bypass refs

Dcache misses Vector integer adds

Vector shifts Vector int ops

Scalar memory refs Scalar FP Instr Syncs Instr

Vector Load Index

Counts, Optimized/Unoptimized

From runs on 1923 mesh, 1x4x4 PEs

Page 14: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

%CPU by routine before optimization

19%

14%

13%11%

8%

8%

7%

5%

3%

2%

10% emsk_

emsi_

emsj_

mpi_send_

extrapi_

extrapj_

update_

extrapk_

cxchg_

MPI_CRAY_bcast

other

Optimization created significant changes inperformance of individual routines.

Page 15: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

%CPU by routine after optimization

12%

4%

14%

13%

6%7%12%

13%

3%

3%13%

emsk_

emsi_

emsj_

mpi_send_

extrapi_

extrapj_

update_

extrapk_

cxchg_

MPI_CRAY_bcast

other

Optimization created significant changes inperformance of individual routines.

Page 16: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

We ran LESlie3D on the X1 and the IBMP4 and compared timings.

X1 X1 * 4 % of total P4 % of totalRun time (sec) 2:47 11:08 36:34Time per timestep 0.334 1.336 100% 4.392 100%Calc. time per timestep 0.264 1.056 79% 3.430 78%Comm. time per timestep 0.052 0.208 16% 0.471 11%Stat. time per timestep 0.019 0.076 6% 0.490 11%

From 1923 mesh; 16 PEs; 500 timesteps

Page 17: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

We have also collected hardwareperformance data on the Cray X1 and the

IBM P4.

• X1:

• pat_hwpc counters– Cycles

– Instructionsgraduated

– Vector Instructions

– Scalar memory refs

– Vector FP adds

• P4:

• PAPI counters– PM_CYC

– PM_BR_ISSUED

– PM_FPU_ALL

– PM_FXU_ALL

– PM_LD_REF_L1

– PM_FPU_FMA

Comparison is not so straightforward….

Page 18: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

… but we did our best.

X1 pat_hwpc counter counts/MSP P4 PAPI counter counts/PECycles 2.800E+11 PM_CYC 2.831E+12Branches & Jumps 1.384E+09 PM_BR_ISSUED 1.052E+11Branches mispredicted 3.554E+07 PM_BR_MPED_CR+

PM_BR_MPRED_TA2.178E+09

Total FP ops 3.524E+11 PM_FPU_ALL 1.705E+11Vector int ops + Scalar int ops

1.117E+09 PM_FXU_FIN 3.335E+11

Dcache refs 8.715E+08 PM_LD_REF_L1 3.398E+11

From 1923 mesh; 16 PEs; 500 timesteps

Page 19: Optimization of LESlie3D for the Cray X1 Architecture...Optimization generally increased vector operations and decreased scalars. 0.01 0.10 1.00 10.00 100.00 Scalar FP ops Scalar integer

Conclusion

Optimized vs. original codeOptimized code ran 20% faster than original.

Optimizations resulted in more vector operations.

X1 vs. P4The X1 outperforms the P4 by a factor of 12 at MSP

level, factor of 3 at SSP level.

The X1 gets better hardware performance in severalareas:

Integer ops

Cache

Branches