auto‐tuning of hierarchical computations with ppopen‐at

31
AutoTuning of Hierarchical Computations with ppOpenAT Takahiro Katagiri i),ii),iii) , Masaharu Matsumoto i),ii) , Satoshi Ohshima i),ii) 1 17th SIAM Conference on Parallel Processing for Scientific Computing (SIAM PP16) Universite Pierre et Marie Curie, Cordeliers Campus, Paris, France Thursday, April 14, 2016, MS55:AutoTuning for the Post Moore’s Era – Part I of II, 2:403:00 i) Information Technology Center, The University of Tokyo ii) JST, CREST iii) Currently, Information Technology Center, Nagoya University

Upload: takahiro-katagiri

Post on 18-Feb-2017

150 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Auto‐Tuning of Hierarchical Computations with ppOpen‐AT 

Takahiro Katagiri i),ii),iii) , Masaharu Matsumoto i),ii), Satoshi Ohshima i),ii)

1

17th SIAM Conference on Parallel Processing for Scientific Computing (SIAM PP16)Universite Pierre et Marie Curie, Cordeliers Campus, Paris, FranceThursday, April 14, 2016, MS55:Auto‐Tuning for the Post Moore’s Era – Part I of II, 2:40‐3:00 

i) Information Technology Center, The University of Tokyo ii) JST, CREST

iii) Currently, Information Technology Center, Nagoya University

Page 2: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Outline1. Background2. ppOpen‐HPC and ppOpen‐AT3. Code Selection in Seism3D and Its Implementation by ppOpen‐AT 

4. Performance Evaluation5. Conclusion

Page 3: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Outline1. Background2. ppOpen‐HPC and ppOpen‐AT3. Code Selection in Seism3D and Its Implementation by ppOpen‐AT 

4. Performance Evaluation5. Conclusion

Page 4: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Source: http://www.engadget.com/2011/12/06/the‐big‐memory‐cube‐gamble‐ibm‐and‐micron‐stack‐their‐chips/

Reconstruction of algorithms w.r.t.  Increase memory bandwidth Increase local memory amounts (caches) Non‐Uniform  memory accesses latency 

Issues in AT Technologies. Hierarchical AT Methodology  Reducing Communication 

Algorithm. New algorithms and 

code (algorithm) selection utilizing high bandwidth ability.  Rethink classical algorithms. Non‐Blocking Algorithms. From explicit method to implicit 

method.  Out of Core algorithms 

(Out of main memory)

Source:http://www.theregister.co.uk/2015/07/28/intel_micron_3d_xpoint/

• It is expected that Moore’s Low is broken around end of 2020.

– End of “One‐time Speedup”: Many Cores, Wiring miniaturization to reduce power.

→ It cannot increase FLOPS inside node.

• However, memory bandwidth inside memory can increase by using “3D Stacking Memory”Technologies. 

• 3D Stacking Memory: – It can increase bandwidth for Z‐Direction 

(Stacking distance) , and keeping access latency (→ High performance)

– It can be low access latency for X‐Y directions. 

• Access latency between nodes goes down, but bandwidth can be increased by optical interconnection technology.

• We need to take care of new algorithms with respect to ability of data movements.

HMC

Intel 3D Xpoint

AT Technologies in Post Moore’s Era

Page 5: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Outline1. Background2. ppOpen‐HPC and ppOpen‐AT3. Code Selection in Seism3D and Its Implementation by ppOpen‐AT 

4. Performance Evaluation5. Conclusion

Page 6: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

ppOpen‐HPC Project• Middleware for HPC and Its AT Technology

– Supported by JST, CREST, from FY2011 to FY2015.– PI: Professor Kengo Nakajima (U. Tokyo)

• ppOpen‐HPC – An open source infrastructure for reliable simulation codes on post‐peta (pp) scale parallel computers.

– Consists of various types of libraries, which covers 5 kinds of discretization methods for scientific computations. 

• ppOpen‐AT – An auto‐tuning language for ppOpen‐HPC codes – Using knowledge of previous project: ABCLibScript Project 4). – Auto‐tuning language based on directives for AT.

6

Page 7: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Software Architecture of ppOpen‐HPC

7

FVM DEMFDMFEM

Many‐core CPUs GPUsMulti‐core

CPUs

MG

COMM

Auto‐Tuning FacilityCode Generation for Optimization CandidatesSearch for the best candidateAutomatic Execution for the optimization

ppOpen‐APPL

ppOpen‐MATH

BEM

ppOpen‐AT

User Program

GRAPH VIS MP

STATIC DYNAMIC

ppOpen‐SYS FT

Optimize memory accesses 

Page 8: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

ppOpen‐AT System  (Based on FIBER 2),3),4),5) ) ppOpen‐APPL /*

ppOpen‐ATDirectives

User KnowledgeLibrary 

Developer

① Before Release‐time

Candidate1

Candidate2

Candidate3

CandidatenppOpen‐AT

Auto‐Tuner

ppOpen‐APPL / *

AutomaticCodeGeneration②

:Target Computers

Execution Time④

Library User

Library Call

Selection

Auto‐tunedKernelExecution

Run‐time

This user benefited from AT.

Page 9: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Scenario of AT for ppOpen‐APPL/FDM

9Execution with optimized

kernels without AT process.

Library User

Set AT parameters, and execute the library

(OAT_AT_EXEC=1)

■Execute auto-tuner: With fixed loop lengths (by specifying problem size and number of MPI processes)Time measurement for target kernelsStore the best variant information.

Set AT parameters, and execute the library(OAT_AT_EXEC=0)

Store the fastest kernelinformation

Using the fastest kernel without AT (except for varying problem size, number of MPI processes and OpenMP threads.)

Specify problem size, number of MPI processes

and OpenMP threads.

Page 10: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

AT Timings of ppOpen‐AT (FIBER Framework)

OAT_ATexec()…do i=1, MAX_ITERTarget_kernel_k()…Target_kernel_m()…

enddo

Read the best parameter

Is this first call?

Yes

Read the best parameter

Is this first call?

Yes

One time execution (except for varying problem size and number of MPI processes )

AT for Before Execute‐time

Execute Target_Kernel_k() with varying parameters

Execute Target_Kernel_m() with varying parameters

parameter Store the best parameter 

Page 11: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Outline1. Background2. ppOpen‐HPC and ppOpen‐AT3. Code Selection in Seism3D and Its Implementation by ppOpen‐AT 

4. Performance Evaluation5. Conclusion

Page 12: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Target Application• Seism3D: Simulation for seismic wave analysis.

• Developed by Professor T.Furumuraat the University of Tokyo.– The code is re‐constructed as ppOpen‐APPL/FDM.

• Finite Differential Method (FDM) • 3D simulation

–3D arrays are allocated.• Data type: Single Precision (real*4) 12

Page 13: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Flow Diagram of ppOpen‐APPL/FDM

13

),,,(

}],,,)21({},,)

21({[1

),,(

2/

1

zyxqp

zyxmxzyxmxcx

zyxdxd

pqpq

M

mm

pq

Space difference by FDM.

),,(,121

21

zyxptfzyx

uu np

nzp

nyp

nxpn

p

n

p

Explicit time expansion by central difference.

Initialization

Velocity Derivative (def_vel)

Velocity Update (update_vel)

Stress Derivative (def_stress)

Stress Update (update_stress)

Stop Iteration?NO

YES

End

Velocity PML condition (update_vel_sponge)Velocity Passing (MPI) (passing_vel)

Stress PML condition (update_stress_sponge)Stress Passing (MPI) (passing_stress)

Page 14: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Original Implementation (For Vector Machines)

call ppohFDM_pdiffx3_m4_OAT( VX,DXVX, NXP,NYP,NZP,NXP0,NXP1,NYP0,…)call ppohFDM_pdiffy3_p4_OAT( VX,DYVX, NXP,NYP,NZP,NXP0,NXP1,NYP0,…)call ppohFDM_pdiffz3_p4_OAT( VX,DZVX, NXP,NYP,NZP,NXP0,NXP1,NYP0,…)call ppohFDM_pdiffy3_m4_OAT( VY,DYVY, NXP,NYP,NZP,NXP0,NXP1,NYP0,… )call ppohFDM_pdiffx3_p4_OAT( VY,DXVY, NXP,NYP,NZP,NXP0,NXP1,NYP0,… )call ppohFDM_pdiffz3_p4_OAT( VY,DZVY, NXP,NYP,NZP,NXP0,NXP1,NYP0,…)call ppohFDM_pdiffx3_p4_OAT( VZ,DXVZ, NXP,NYP,NZP,NXP0,NXP1,NYP0,…)call ppohFDM_pdiffy3_p4_OAT( VZ,DYVZ, NXP,NYP,NZP,NXP0,NXP1,NYP0,… )call ppohFDM_pdiffz3_m4_OAT( VZ,DZVZ, NXP,NYP,NZP,NXP0,NXP1,NYP0,…)

if( is_fs .or. is_nearfs ) thencall ppohFDM_bc_vel_deriv( KFSZ,NIFS,NJFS,IFSX,IFSY,IFSZ,JFSX,JFSY,JFSZ )

end if

call ppohFDM_update_stress(1, NXP, 1, NYP, 1, NZP)

Fourth‐order accurate central‐difference scheme for velocity. (def_stress)

Process of model boundary. 

Explicit time expansion by leap‐frog scheme. (update_stress)

Page 15: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Original Implementation (For Vector Machines)subroutine OAT_InstallppohFDMupdate_stress(..)!$omp parallel do private(i,j,k,RL1,RM1,RM2,RLRM2,DXVX1,DYVY1,DZVZ1,…)do k = NZ00, NZ01do j = NY00, NY01do i = NX00, NX01RL1   = LAM (I,J,K); RM1   = RIG (I,J,K);  RM2   = RM1 + RM1; RLRM2 = RL1+RM2DXVX1 = DXVX(I,J,K);  DYVY1 = DYVY(I,J,K);  DZVZ1 = DZVZ(I,J,K)D3V3  = DXVX1 + DYVY1 + DZVZ1SXX (I,J,K) = SXX (I,J,K) + (RLRM2*(D3V3)‐RM2*(DZVZ1+DYVY1) ) * DTSYY (I,J,K) = SYY (I,J,K)  + (RLRM2*(D3V3)‐RM2*(DXVX1+DZVZ1) ) * DTSZZ (I,J,K) = SZZ (I,J,K)  + (RLRM2*(D3V3)‐RM2*(DXVX1+DYVY1) ) * DTDXVYDYVX1 = DXVY(I,J,K)+DYVX(I,J,K);  DXVZDZVX1 = DXVZ(I,J,K)+DZVX(I,J,K)DYVZDZVY1 = DYVZ(I,J,K)+DZVY(I,J,K)SXY (I,J,K) = SXY (I,J,K) + RM1 * DXVYDYVX1 * DTSXZ (I,J,K) = SXZ (I,J,K) + RM1 * DXVZDZVX1 * DTSYZ (I,J,K) = SYZ (I,J,K) + RM1 * DYVZDZVY1 * DT

end doend do

end doretuenend

Explicit time expansion by leap‐frog scheme. (update_stress)

Input and output for arrays Input and output for arrays in each call ‐> Increase of 

B/F ratio: ~1.7

Page 16: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Code selection by ppOpen‐AT and hierarchical AT

Program main….!OAT$ install select region start!OAT$ name ppohFDMupdate_vel_select!OAT$ select sub region startcall ppohFDM_pdiffx3_p4( SXX,DXSXX,NXP,NYP,NZP,….)call ppohFDM_pdiffy3_p4( SYY,DYSYY, NXP,NYP,NZP,…..)…if( is_fs .or. is_nearfs ) thencall ppohFDM_bc_stress_deriv( KFSZ,NIFS,NJFS,IFSX,….)end ifcall ppohFDM_update_vel    ( 1, NXP, 1, NYP, 1, NZP )!OAT$ select sub region end

!OAT$ select sub region startCall ppohFDM_update_vel_Intel  ( 1, NXP, 1, NYP, 1, NZP )!OAT$ select sub region end

!OAT$ install select region end

Upper Code With Select clause, code selection can be 

specified.

subroutine ppohFDM_update_vel(….)….!OAT$ install LoopFusion region start!OAT$ name ppohFDMupdate_vel!OAT$ debug (pp)!$omp parallel do private(i,j,k,ROX,ROY,ROZ)do k = NZ00, NZ01do j = NY00, NY01do i = NX00, NX01

…..….

Lower Codesubroutine ppohFDM_pdiffx3_p4(….)….!OAT$ install LoopFusion region start….

Page 17: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Call tree graph by the ATStart

Stress Derivative (def_stress)

Stress Update (update_stress)

Stop iteration?NO

YES

End

Velocity PML condition (update_vel_sponge)

Velocity Passing (MPI) (passing_vel)

Stress PML condition (update_stress_sponge)

Stress Passing (MPI) (passing_stress)

Velocity Derivative (def_vel)

Velocity Update (update_vel)

MainProgram

Velocity Update (update_vel_Scalar)

Stress Update (update_stress_Scalar)

Selection

Selection

update_vel_select

update_stress_select

update_vel_select

update_stress_select

:auto‐generated codes

Velocity Update (update_vel_IF_free)Selection

Stress Update (update_stress_IF_free)Selection

CandidateCandidateCandidateCandidate

CandidateCandidateCandidateCandidate

CandidateCandidateCandidateCandidate

CandidateCandidateCandidateCandidate

CandidateCandidateCandidateCandidate

CandidateCandidateCandidateCandidate

CandidateCandidateCandidateCandidate

Page 18: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Execution Order of the AT

Velocity PML condition (update_vel_sponge)

Velocity Passing (MPI) (passing_vel)

Stress PML condition (update_stress_sponge)

Stress Passing (MPI) (passing_stress)

update_vel_select

update_stress_selectStress Derivative (def_stress)Stress Update (update_stress)

Velocity Derivative(def_vel)

Velocity Update(update_vel)Velocity Update 

(update_vel_Scalar)

Stress Update(update_stress_Scalar)

Def_* AT Candidates

Update_velAT Candidates

Update_stressAT Candidates

Update_vel_spongeAT Candidates

Update_stress_spongeAT Candidates

Passing_velAT Candidates

Passing_stressAT Candidates

Velocity Update (update_vel_IF_free)

Stress Update(update_stress_IF_free)

We can specify the order via a directive of ppOpen‐AT.(an extended function)

Page 19: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Outline1. Background2. ppOpen‐HPC and ppOpen‐AT3. Code Selection in Seism3D and Its Implementation by ppOpen‐AT 

4. Performance Evaluation5. Conclusion

Page 20: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

The Number of AT Candidates (ppOpen‐APPL/FDM)

20

Kernel Names AT Objects The Number of Candidates

1. update_stress ・Loop Collapses and Splits :8 Kinds・Code Selections : 2 Kinds

10

2. update_vel ・Loop Collapses, Splits, and re‐ordering of statements: :6 Kinds・Code Selections: 2 Kinds

8

3. update_stress_sponge ・Loop Collapses:3 Kinds 34. update_vel_sponge ・Loop Collapses:3 Kinds 35. ppohFDM_pdiffx3_p4 Kernel Names:def_update、def_vel

・Loop Collapses:3 Kinds3

6. ppohFDM_pdiffx3_m4 37. ppohFDM_pdiffy3_p4 38. ppohFDM_pdiffy3_m4 39. ppohFDM_pdiffz3_p4 310.ppohFDM_pdiffz3_m4 311. ppohFDM_ps_pack Data packing and unpacking

・Loop Collapses: 3 Kinds3

12. ppohFDM_ps_unpack 313. ppohFDM_pv_pack 314. ppohFDM_pv_unpack 3

Total:54 Kinds Hybrid 

MPI/OpenMP:7 Kinds

54×7 = 

378 Kinds

Page 21: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Machine Environment (8 nodes of the Xeon Phi) The Intel Xeon Phi  Xeon Phi 5110P (1.053 GHz), 60 cores Memory Amount:8 GB (GDDR5) Theoretical Peak Performance:1.01 TFLOPS One board per node of the Xeon phi cluster InfiniBand FDR x 2 Ports 

Mellanox Connect‐IB PCI‐E Gen3 x16 56Gbps x 2 Theoretical Peak bandwidth 13.6GB/s Full‐Bisection

Intel MPI Based on MPICH2, MVAPICH2 Version 5.0 Update 3 Build 20150128 

Compiler:Intel Fortran version 15.0.3 20150407 Compiler Options:

‐ipo20 ‐O3 ‐warn all ‐openmp ‐mcmodel=medium ‐shared‐intel –mmic‐align array64byte

KMP_AFFINITY=granularity=fine, balanced (Uniform Distribution of threads between sockets)

Page 22: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Execution Details• ppOpen‐APPL/FDM ver.0.2• ppOpen‐AT ver.0.2• The number of time step: 2000 steps• The number of nodes: 8 node• Native Mode Execution• Target Problem Size (Almost maximum size with 8 GB/node)– NX * NY * NZ = 512 x  512 x 512 / 8 Node– NX * NY * NZ = 256 * 256 * 256 / node(!= per MPI Process)

• The number of iterations for kernels to do auto‐tuning: 100

Page 23: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Execution Details of Hybrid MPI/OpenMP

• Target MPI Processes and OMP Threads on the Xeon Phi– The Xeon Phi with 4 HT (Hyper Threading) – PX TY: XMPI Processes and Y Threads per process– P8T240 : Minimum Hybrid MPI/OpenMP execution for ppOpen‐APPL/FDM, since it needs minimum 8 MPI Processes.

– P16T120– P32T60– P64T30– P128T15  – P240T8– P480T4

– Less than P960T2 cause an MPI error in this environment.

#0

#1

#2

#3

#4

#5

#6

#7

#8

#9

#10

#11

#12

#13

#14

#15

P2T8

#0

#1

#2

#3

#4

#5

#6

#7

#8

#9

#10

#11

#12

#13

#14

#15

P4T4 Target of cores for one MPI Process

Page 24: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

BREAK DOWN OF TIMINGS 

Page 25: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

THE BEST IMPLEMENTATION

Page 26: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Outline1. Background2. ppOpen‐HPC and ppOpen‐AT3. Code Selection in Seism3D and Its Implementation by ppOpen‐AT 

4. Performance Evaluation5. Conclusion

Page 27: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

RELATED WORK

Page 28: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Originality (AT Languages)AT Language 

/ Items#1

#2

#3

#4

#5

#6

#7

#8

ppOpen‐AT OAT Directives ✔ ✔ ✔ ✔ ✔ NoneVendor Compilers Out of Target Limited ‐Transformation 

Recipes Recipe

Descriptions✔ ✔ ChiLL

POET Xform Description ✔ ✔ POET translator, ROSE

X language  Xlang Pragmas ✔ ✔ X Translation,‘C and tcc

SPL SPL Expressions ✔ ✔ ✔ A Script Language

ADAPT

ADAPT Language

✔ ✔ Polaris Compiler Infrastructure, 

Remote Procedure Call (RPC)

Atune‐IL Atune Pragmas ✔ A Monitoring Daemon

PEPPHER PEPPHER Pragmas (interface)

✔ ✔ ✔ PEPPHER task graph and run-time

Xevolver Directive Extension(Recipe Descriptions)

(✔) (✔) (✔) ROSE,XSLT Translator

#1: Method for supporting multi-computer environments. #2: Obtaining loop length in run-time. #3: Loop split with increase of computations6) ,and loop collapses to the split loops6),7),8) . #4: Re-ordering of inner-loop sentences8) . #5:Code selection with loop transformations (Hierarchical AT descriptions*) *This is originality in current researches of AT as of 2015. #6:Algorithm selection. #7: Code generation with execution feedback. #8: Software requirement.

(Users need to define rules. )

Page 29: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Conclusion Remarks Propose an IF‐free kernel: An effective kernel implementation of an application with FDM by merging computations of central‐difference and explicit time expansion schemes. 

Use AT language to adapt code selection for new kernels: The effectiveness of the new implementation depends on the CPU architecture and execution situation, such as problem size and the number of MPI processes and OpenMP threads. 

To obtain free code (MIT Licensing):http://ppopenhpc.cc.u‐tokyo.ac.jp/

Page 30: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

Future Work• Improving Search Algorithm

– We use a brute‐force search in current implementation.• This is feasible by applying knowledge of application.

– We have implemented a new search algorithm based on black box performance models.

• d‐Spline Model (interpolation and incremental additionbased) ,collaborated with Prof. Tanaka (Kogakuin U.)

• Surrogate Model (interpolation and probability based) collaborated with Prof. Wang (National Taiwan U.) 

• Off‐loading Implementation Selection (for the Xeon Phi)– If problem size is too small to do off‐loading, the target execution is 

performed on CPU automatically.

• Adaptation of OpenACC for GPU computing– Selection of OpenACC directives with ppOpenAT by Dr. Ohshima.

• gang, vector, parallel, etc. 

Page 31: Auto‐Tuning of Hierarchical Computations with ppOpen‐AT

http://ppopenhpc.cc.u‐tokyo.ac.jp/

Thank you for your attention!Questions?