Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 06/09/2011, COSMO GM Xavier Lapillonne Porting the physical parametrizations on GPU using directives X. Lapillonne, O. Fuhrer Eidgenössisches Departement.

Similar presentations


Presentation on theme: "1 06/09/2011, COSMO GM Xavier Lapillonne Porting the physical parametrizations on GPU using directives X. Lapillonne, O. Fuhrer Eidgenössisches Departement."— Presentation transcript:

1 1 06/09/2011, COSMO GM Xavier Lapillonne Porting the physical parametrizations on GPU using directives X. Lapillonne, O. Fuhrer Eidgenössisches Departement des Innern EDI Bundesamt für Meteorologie und Klimatologie MeteoSchweiz

2 2 06/09/2011, COSMO GM Xavier Lapillonne Outline Physics with 2d data structure Porting the physical parametrization to GPU using directives Running COSMO on an hybrid GPU-CPU system

3 3 06/09/2011, COSMO GM Xavier Lapillonne New data structure 2D data fields inside the physics packages with one horizontal and one vertical dimensions: f(nproma,ke), with nproma = ie x je / nblock. Goals: Physics package could be shared with ICON code Blocking strategy: all physics parametrization could be computed while data remains in the cache organize_physics should be structured as follow: call init_radiation call init_turbulence … do ib=1,nblock call copy_to block call organize_radiation … call organize_turbulence call copy_back end do Note : an omp parallelization could be introduced around the block loop where data inside organise_scheme is in block form t_b(nproma,ke) Routines below organize_scheme will be shared with ICON. Fields are passed via argument list: call fesft(t_b(:,:), …

4 4 06/09/2011, COSMO GM Xavier Lapillonne Current status Base code: COSMO 4.18 2d version of microphysics (hydci_pp), radiation (Ritter-Geleyn), turbulence (turbtran+turbdiff). For the moment microphysics and radiation are in separate block loop. The turbulence scheme is copying 3d fields (i.e turbdiff(t(:,je,:) …) Next steps All 3 parametrizations (microphysics + radiation + turbulence) in a common block loop Performance analysis OMP parallelization (?) Longer term All parametrization required for operational runs should be inside the block loop and in 2 dimensional form

5 5 06/09/2011, COSMO GM Xavier Lapillonne Outline Physics with 2d data structure Porting the physical parametrization to GPU using directives Running COSMO on an hybrid GPU-CPU system

6 6 06/09/2011, COSMO GM Xavier Lapillonne Computing on Graphical Processing Units (GPUs) Benefit from the highly parallel architecture of GPUs Higher peak performance at lower cost / power consumption. High memory bandwidth Cores Freq. (GHz) Peak Perf. S.P. (GFLOPs) Peak Perf. D.P. (GFLOPs) Memory Bandwith (GB/sec) Power Cons. (W) CPU: AMD Magny-cours 122.120210142.7115 GPU: Fermi M2050 4481.151030515144225

7 7 06/09/2011, COSMO GM Xavier Lapillonne Execution model Host (CPU) Kernel Sequential Device (GPU) Data Transfer Copy data from CPU to GPU (CPU and GPU memory are separate) Load specific GPU program (Kernel) Execution: Same kernel is executed by all threads, SIMD parallelism (Single instruction, multiple data) Copy back data from GPU to CPU … … … … Parallel threads

8 8 06/09/2011, COSMO GM Xavier Lapillonne The directive approach, an example !$acc data region local(a,b) !$acc update device(b) !initialization !$acc region do k=1,nlev do i=1,N a(i,k)=0.0D0 end do end do !$acc end region ! first layer !$acc region do i=1,N a(i,1)=0.1D0 end do !$acc end region ! vertical computation !$acc region do k=2,nlev do i=1,N a(i,k)=0.95D0*a(i,k-1)+exp(-2*a(i,k)**2)*b(i,k) end do end do !$acc end region !$acc update host(a) !$acc end data region !$acc data region local(a,b) !$acc update device(b) !initialization !$acc region do kernel do i=1,N do k=1,nlev a(i,k)=0.0D0 end do end do !$acc end region ! first layer !$acc region do i=1,N a(i,1)=0.1D0 end do !$acc end region ! vertical computation !$acc region do kernel do i=1,N do k=2,nlev a(i,k)=0.95D0*a(i,k-1)+exp(-2*a(i,k)**2)*b(i,k) end do end do !$acc end region !$acc update host(a) !$acc end data region N=1000, nlev=60: t= 555 μs t= 225 μs note : PGI directives Loop reordering 3 different kernels Array “a” remains on the GPU between the different kernel calls

9 9 06/09/2011, COSMO GM Xavier Lapillonne Physical parametrizations on GPU using directives Physical parametrizations are tested using standalone code. Currently ported parametrizations: PGI : microphysics (hydci_pp), radiation (fesft), turbulence (only turbdiff yet) OMP – acc (Cray) : microphysics, radiation GPU optimizaiton: loop reordering, replacement of arrays with scalars Note: hydci_pp, fesft and turbdiff subroutines represents respectively 6.7%, 8% and 7.3% of the total execution time of a typical cosmo-2 run. Current version of OMP-acc are a subset of PGI directives and it is possible to write PGI code so that there is almost a one to one translation to omp-acc. First investigation show similar performance between the two compilers, but would need further analysis

10 10 06/09/2011, COSMO GM Xavier Lapillonne Results, Fermi card using PGI directives Peak performance of a Fermi card for double precision is 515 GFlop/s, i.e. we are getting respectively 5%, 4.5% and 2.5% peak performance for the microphysics, radiation and turbulence schemes Theoretical bandwith is 140 GB/s, but maximum achievable is around 110 GB/s Test domain: n x x n y x n z = 80 x 60 x 60

11 11 06/09/2011, COSMO GM Xavier Lapillonne Results: Comparison with CPU Parallel CPU code run on 12 cores AMD magny-cours CPU – however there are no mpi-communications in these standalone test codes. Note: Expected performance would be between 3x and 5x and depending whether the problem is compute or memory bandwith bound. Overhead of data transfer for microphysics and turbulence is very large.

12 12 06/09/2011, COSMO GM Xavier Lapillonne Comments on the observed performance The microphysics has the largest compute intensity (with respect to memory access) and as such is more suited for the GPU. The lower speed up observed for the radiation is quite relative, and essentially comes from the fact that it is very well optimized and is vectorized on the CPU (~9% Peak performance) The turbulence scheme requires more memory access. Next steps Port turbtran subroutine with pgi + additional test and optimizations (october 2011) Further investigation of radiation and turbulence schemes with Cray directives (november 2011) GPU version of microphysics + radiation + turbulence inside COSMO (november-december 2011)

13 13 06/09/2011, COSMO GM Xavier Lapillonne Outline Physics with 2d data structure Porting the physical parametrization to GPU using directives Running COSMO on an hybrid GPU-CPU system

14 14 06/09/2011, COSMO GM Xavier Lapillonne Possible future implementations in COSMO DynamicMicrophysicsTurbulenceRadiation Phys. parametrization I/O GPU DynamicMicrophysicsTurbulenceRadiation Phys. parametrization I/O GPU Data movement for each routine “Full GPU” : Data remain on device, only send to CPU for I/O and communication C++ - CUDA Directives

15 15 06/09/2011, COSMO GM Xavier Lapillonne Running COSMO-2 on Hybrid-system Multicores Processor GPUs One (or more) multicores CPU Domain decomposition One GPU per subdomain.

16 16 06/09/2011, COSMO GM Xavier Lapillonne Summary Porting of the microphysics, radiation and turbulence scheme on GPU was successfully carried out using a directive based approach Comparing with a 12 cores CPU, a speed up between 2.4x and 6.5x was observed using one Fermi GPU card These results are within the expected values considering hardware properties The large overhead of data transfer shows that the “full GPU” approach (i.e. data remains on the GPU, all computation on the device) is the prefered approach for COSMO

17 17 06/09/2011, COSMO GM Xavier Lapillonne Additional slides

18 18 06/09/2011, COSMO GM Xavier Lapillonne Comparison between PGI and OMP-acc !$acc data region local(a) !time loop do itime=1,nt !initialization !$acc region do k=1,nlev do i=1,N a(i,k)=0.0D0 end do end do !$acc end region ! first layer !$acc region do kernel do i=1,N a(i,1)=0.1D0 end do !$acc end region ! vertical computation !$acc region do kernel do i=1,N do k=2,nlev a(i,k)=0.95D0*a(i,k-1)+exp(-2*a(i,k)**2)*a(i,k) end do end do !$acc end region end do ! end time loop !$acc update host(a) !$acc end data region !$omp acc_data acc_shared(a) !time loop do itime=1,nt !initialization !$omp acc_region_loop do k=1,nlev do i=1,N a(i,k)=0.0D0 end do end do !$omp end acc_region loop ! first layer !$omp acc_region_loop do i=1,N a(i,1)=0.1D0 end do !$omp end acc_region_loop ! vertical computation !$omp acc_region_loop kernel do i=1,N do k=2,nlev a(i,k)=0.95D0*a(i,k-1)+exp(-2*a(i,k)**2)*a(i,k) end do end do !$omp end acc_region_loop end do ! end time loop !$omp acc_update host(a) !$omp end acc_data

19 19 06/09/2011, COSMO GM Xavier Lapillonne MAIN_ / mo_gscp_dwd_hydci_pp_ _ (x10) ------------------------------------------------------------------------ User time (approx) 2.999 secs 7197500711 cycles System to D1 refill 2.434M/sec 7300271 lines System to D1 bandwidth 148.576MB/sec 467217344 bytes D2 to D1 bandwidth 1025.770MB/sec 3225672832 bytes L2 to System BW per core 140.940MB/sec 443203504 bytes HW FP Ops / User time 435.162M/sec 1308546592 ops 4.5%peak(DP) MAIN_ / src_radiation_fesft_ (x1) ------------------------------------------------------------------------ User time (approx) 7.226 secs 17342858074 cycles 100.0%Time System to D1 refill 11.380M/sec 82232710 lines System to D1 bandwidth 694.569MB/sec 5262893440 bytes D2 to D1 bandwidth 1162.252MB/sec 8806624128 bytes L2 to System BW per core 645.679MB/sec 4892446080 bytes HW FP Ops / User time 893.252M/sec 6511701846 ops 9.3%peak(DP) Craypat infos MAIN_ / turbulence_diff_ref_turbdiff_ (x10) ------------------------------------------------------------------------ User time (approx) 4.397 secs 10551890928 cycles 100.0%Time System to D1 refill 15.757M/sec 69278266 lines System to D1 bandwidth 961.741MB/sec 4433809024 bytes D2 to D1 bandwidth 485.462MB/sec 2238073856 bytes L2 to System BW per core 982.474MB/sec 4529394160 bytes HW FP Ops / User time 326.405M/sec 1452061875 ops 3.4%peak(DP)

20 20 06/09/2011, COSMO GM Xavier Lapillonne Palu Results

21 21 06/09/2011, COSMO GM Xavier Lapillonne Results, microphysics, double precision, Palu

22 22 06/09/2011, COSMO GM Xavier Lapillonne Results, Radiation, double precision, Palu

23 23 06/09/2011, COSMO GM Xavier Lapillonne Results, Turbulence, double precision, Palu


Download ppt "1 06/09/2011, COSMO GM Xavier Lapillonne Porting the physical parametrizations on GPU using directives X. Lapillonne, O. Fuhrer Eidgenössisches Departement."

Similar presentations


Ads by Google