1
Hybrid CUDA/JAVA model for GPU Calculations of Gas Line-by-Line Absorption of Atmospheric Radiation William F. Godoy NASA Langley Research Center, Hampton, Virginia Abstract This work shows the potential in the use of graphics processing units (GPU) to speed up the calculation of radiative energy absorption by atmospheric gases. Gas absorption calculations are needed at millions of spectral lines (wavelengths) in order to have an accurate depiction of the Earth’s in-coming and out-coming radia- tive energies. The CUDA/GPU portion of the code obtains fast Voigt lineshapes at several spectral locations, whereas the NIO/Java portion of the code performs efficient random file access on the large HITRAN database to obtain molecular gas parameters. The first advantage of this programming model is the great speed up obtain by the introduction of parallel GPU algorithms, and the second advan- tage is the modular combination of the lower-level CUDA algorithms for the GPU calculations and the higher-level Java language for efficient input/output of files (I/O). The latter results in an accessible interface to the end-user that is not an expert in GPU programming. Introduction Modeling radiative transfer in the atmosphere is an extremely challenging task Current needs : -Fast, accurate and robust PARALLEL models (GPU, MPI, Threads) - Sub-grid models for coupling with other phenomena (i.e. turbulence, convec- tion, cloud physics) - Avoid computationally expensive codes (i.e. Monte Carlo) General computing in graphic processing (GPGPU) units is a powerful alterna- tive Drawbacks: - Full speed up only for single precision (4 bytes) - GPU low memory and CPU/GPU communication are bottlenecks - Lack of documentation, validation and applications to radiative transfer Mathematical Formulation Gas absorption is a extremelly noisy function along the spectrum [1] Line-by-line (LBL) calculations using Voigt lineshapes are required for every single gas at every single state [2] Slow process as there is many gas species and thousands of millions of important wavenumbers CUDA GPU / JAVA IO Programming Model GPU Parallel Model: Voigt Lineshape - Integral Function[2] f V ( ν ¯ ν,γ L G ) = −∞ f L ( ν ν ,T,p ) f G ( ν ¯ ν,T ) (1) = ln 2 πγ G K (x, y ) = Re e z 2 (1 erf [iz ]) (2) x = ln 2 ν ¯ ν γ G y = ln 2 γ L γ G . (3) Voigt lineshape calculation on GPU f (cm -1 ) -6 -4 -2 0 2 4 6 0 0.1 0.2 0.3 0.4 0.5 f G f L f V ν-ν γ =γ = L G 1 Gauss (Doppler effect broadening) Lorentz (natural and collision broadening) Voigt ( f L f G ) - (cm -1 ) X CUDA / JAVA flow diagram GPGPU programming basis [3, 4] Cost, $ per teraflop (10 12 floating point operations) is low A GPU has thousands of processors for lightweigth tasks Parallel processes (threads) launch from CPU High CPU/GPU data transfer reduces efficiency Double precision is needed for Jacobian-free calculations Results and Speed up for Atmospheric H 2 O and CO 2 Atmospheric Profile at 50 Altitudes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + T (K) p (mbar), f v x 10 6 h (km) 200 300 400 500 60 10 -6 10 -4 10 -2 10 0 10 2 10 4 10 0 20 40 60 80 100 120 temperature U.S. Standard Atmosphere 1976 pressure H 2 O CO 2 O 2 CH 4 wavenumber (cm -1 ) k (cm -1 ) 3650 3700 3750 3800 3850 10 -8 10 -7 10 -6 10 -5 10 -4 10 -3 10 -2 10 -1 H 2 O CO 2 10,000 wavenumbers Gas Absorption Coefficients at z = 0 m number of sample wavenumbers time (s) 0 20000 40000 60000 80000 100000 0 5000 10000 15000 CPU 3.4 Ghz AMD Phenom II GPU GeForce GTX 570 Nvidia CPU vs GPU computational times wavenumber (cm -1 ) relative error (%) 3650 3700 3750 3800 3850 -0.4 -0.2 0 0.2 0.4 H 2 O CO 2 k CPU -k GPU k CPU Gas Absorption Relative Error on GPU x 100% 10,000 wavenumbers number of sample wavenumbers Speed up (CPU time /GPU time ) 0 20000 40000 60000 80000 1000 0 5 10 15 20 GPU Speed up for 2 Gaseous Species Summary & Conclusions A hybrid Java/CUDA model allows the modular combination of GPU and high-level I/O algorithms The model allows for code reusability with an accesible learning curve for the end user Errors due to GPU single precision are less than 0.3% in the case of atmospheric H 2 O and CO 2 at sea level Maximum speed up of 18 for 50,000 tested wavenumbers, speed ups grow proportional to the number of wavenumbers Potential extension to entire spectrum and multiple gaseous species is a must! References [1] R. M. Goody, Y. L. Yung, Atmospheric Radiation: Theoretical Basis, 2nd Edition, Oxford University Press, New York, NY, 1995. [2] M. F. Modest, Radiative Heat Transfer, 2nd Edition, Academic Press, Elsevier Science, San Diego, CA, 2003. [3] CUDA: Compute Unified Device Architecture, NVIDIA Corporation., http://www.nvidia.com/object/cuda home new.html, 2010. [4] W. F. Godoy, X. Liu, Introduction of parallel GPGPU acceleration algorithms for the solution of radiative transfer, Num Heat Trans, Part B: Fundamentals 59 (2011) 1–25.

NASA Langley Research Center, Hampton, Virginiadeveloper.download.nvidia.com › GTC › PDF › GTC2012 › ... · Absorption of Atmospheric Radiation William F. Godoy NASA Langley

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: NASA Langley Research Center, Hampton, Virginiadeveloper.download.nvidia.com › GTC › PDF › GTC2012 › ... · Absorption of Atmospheric Radiation William F. Godoy NASA Langley

Hybrid CUDA/JAVA model for GPU Calculations of Gas Line-by-LineAbsorption of Atmospheric Radiation

William F. GodoyNASA Langley Research Center, Hampton, Virginia

Abstract

This work shows the potential in the use of graphics processing units (GPU) tospeed up the calculation of radiative energy absorption by atmospheric gases. Gasabsorption calculations are needed at millions of spectral lines (wavelengths) inorder to have an accurate depiction of the Earth’s in-coming and out-coming radia-tive energies. The CUDA/GPU portion of the code obtains fast Voigt lineshapesat several spectral locations, whereas the NIO/Java portion of the code performsefficient random file access on the large HITRAN database to obtain moleculargas parameters. The first advantage of this programming model is the great speedup obtain by the introduction of parallel GPU algorithms, and the second advan-tage is the modular combination of the lower-level CUDA algorithms for the GPUcalculations and the higher-level Java language for efficient input/output of files(I/O). The latter results in an accessible interface to the end-user that is not anexpert in GPU programming.

Introduction

•Modeling radiative transfer in the atmosphere is an extremely challenging task

•Current needs :

- Fast, accurate and robust PARALLEL models (GPU, MPI, Threads)

- Sub-grid models for coupling with other phenomena (i.e. turbulence, convec-tion, cloud physics)

- Avoid computationally expensive codes (i.e. Monte Carlo)

•General computing in graphic processing (GPGPU) units is a powerful alterna-tive

•Drawbacks:

- Full speed up only for single precision (4 bytes)

- GPU low memory and CPU/GPU communication are bottlenecks

- Lack of documentation, validation and applications to radiative transfer

Mathematical Formulation

•Gas absorption is a extremelly noisy functionalong the spectrum [1]

•Line-by-line (LBL) calculations using Voigtlineshapes are required for every single gas atevery single state [2]

• Slow process as there is many gas species andthousands of millions of importantwavenumbers

CUDA GPU / JAVA IO Programming Model

GPU Parallel Model: Voigt Lineshape -Integral Function[2]

fV ( ν−ν̄,γL,γG ) =

∞∫

−∞

fL ( ν−ν ′,T,p ) fG ( ν ′−ν̄,T )d ν (1)

=

√ln 2

√π γG

K(x, y) = Re[

e−z2 ( 1− erf [−iz] )]

(2)

x =√ln 2

ν − ν̄

γGy =

√ln 2

γLγG

. (3)

Voigt lineshape calculation on GPU

f(cm

-1)

-6 -4 -2 0 2 4 60

0.1

0.2

0.3

0.4

0.5

fG

fL

fV

ν − ν

γ = γ =L G 1

Gauss (Doppler effectbroadening)

Lorentz(natural and collisionbroadening)

Voigt ( f L fG )

− (cm-1)

X

CUDA / JAVA flow diagramGPGPU programming basis [3, 4]

• Cost, $ per teraflop (1012 floating point operations) is low

•A GPU has thousands of processors for lightweigth tasks

• Parallel processes (threads) launch from CPU

•High CPU/GPU data transfer reduces efficiency

•Double precision is needed for Jacobian-free calculations

Results and Speed up for Atmospheric H2O and CO2

Atmospheric Profile at 50 Altitudes

+

+

+

+

+

+

+

+

+

+

+

+

+

+

++++++++++++++++++++++++++++++++++++

+

+

+

+

+

+

+

+

+

+

+

+

+

+

++

++

++

++

++++++++++++++++++++++++++++

+

+

+

+

+

+

+

+

+

+

+

+

+

+

++++++++++++++++++++++ + + + + + +++++++++

+

+

+

+

+

+

+

+

+

+

+

+

+

+

++++++++++++++++++++++++++++++++++++

+

+

+

+

+

+

+

+

+

+

+

+

+

+

++++++++++++++++++++++++++++++++++++

+

+

+

+

+

+

+

+

+

+

+

+

+

+

++++++++++++++++++++++++++++++++++++

T (K)

p (mbar), f v x 106

h(k

m)

200 300 400 500 60

10-6 10-4 10-2 100 102 104 10

0

20

40

60

80

100

120

temperature

U.S. StandardAtmosphere 1976

pressure

H2O

CO2

O2

CH4 wavenumber (cm -1)

k(cm

-1)

3650 3700 3750 3800 385010-8

10-7

10-6

10-5

10-4

10-3

10-2

10-1

H2OCO2

10,000 wavenumbers

Gas Absorption Coefficients at z = 0 m

number of sample wavenumbers

time(

s)

0 20000 40000 60000 80000 1000000

5000

10000

15000CPU 3.4 Ghz AMD Phenom IIGPU GeForce GTX 570 Nvidia

CPU vs GPU computational times

wavenumber (cm -1)

relati

veerr

or(%

)

3650 3700 3750 3800 3850-0.4

-0.2

0

0.2

0.4

H2OCO2

kCPU - kGPU

kCPU

Gas Absorption Relative Error on GPU

x 100%

10,000 wavenumbers

number of sample wavenumbers

Spee

dup(

CPU

time/G

PUtim

e)

0 20000 40000 60000 80000 10000

5

10

15

20GPU Speed up for 2 Gaseous Species

Summary & Conclusions•A hybrid Java/CUDA model allows the modular combination of GPU and high-level I/O algorithms

•The model allows for code reusability with an accesible learning curve for the end user

• Errors due to GPU single precision are less than 0.3% in the case of atmospheric H2O and CO2 at sea level

•Maximum speed up of 18 for 50,000 tested wavenumbers, speed ups grow proportional to the number of wavenumbers

• Potential extension to entire spectrum and multiple gaseous species is a must!

References[1] R. M. Goody, Y. L. Yung, Atmospheric Radiation: Theoretical Basis, 2nd Edition, Oxford

University Press, New York, NY, 1995.

[2] M. F. Modest, Radiative Heat Transfer, 2nd Edition, Academic Press, Elsevier Science, SanDiego, CA, 2003.

[3] CUDA: Compute Unified Device Architecture, NVIDIA Corporation.,http://www.nvidia.com/object/cuda home new.html, 2010.

[4] W. F. Godoy, X. Liu, Introduction of parallel GPGPU acceleration algorithms for the solutionof radiative transfer, Num Heat Trans, Part B: Fundamentals 59 (2011) 1–25.