efficient computation of radial distribution function on ......in procs. of 15th ieee international...

32
Efficient Computation of Radial Distribution Function on GPUs Yi-Cheng Tu * and Anand Kumar Department of Computer Science and Engineering University of South Florida, Tampa, Florida

Upload: others

Post on 01-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Efficient Computation of Radial Distribution Function on GPUs

Yi-Cheng Tu * and Anand Kumar Department of Computer Science and Engineering University of South Florida, Tampa, Florida

Page 2: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Overview •  Introduction and Motivation • Spatial Distance Histogram (SDH) • GPU Architecture • Brute-force SDH Algorithm on GPU • Advanced SDH Algorithms on GPU • Conclusions and Future Work

2

Page 3: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Introduction and Motivation •  Scientific databases: very large amount of data

•  CERN Hadron Collider generates 15 PB every year •  Next Generation Genome Sequencer generates

100s of GB in few days

•  Molecular / Particle simulations •  Study physical systems through simulations •  System state is stored at many time instances •  Each instance is named a frame

•  Frame constitutes – system state •  Measurement of particle properties

•  Physical location, velocity, charge, mass etc. •  Thousands of frames are generated in a simulation

3

Page 4: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Introduction and Motivation •  Millions of particles / atoms are

simulated •  Analytical query processing in

MS data •  Center of mass •  System density, energy •  Mean square displacement •  Radial distribution function (RDF)

4

Simulation Space (diagonal 4w)

0 w 2w 3w 4w

Histogram buckets (of width w)

Spatial Distance Histogram (SDH) •  Key step for computing RDF

and other queries •  Interesting and tough as

compared to others - O(N2)

Page 5: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Overview •  Introduction and Motivation • Spatial Distance Histogram (SDH) • GPU Architecture • Brute-force SDH Algorithm on GPU • Advanced SDH Algorithms on GPU • Conclusions and Future Work

5

Page 6: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

SDH Algorithms on CPUs • Naïve algorithm in simulation software (e.g., GROMACS) • Space partitioning trees (kd-tree) [NIPS00]

•  Process group of particles as one unit

• Density-Map SDH (DM-SDH) based on Quad/Oct-trees [ICDE09,VLDBJ11,EDBT12,TKDE13,TKDE14] •  Runs in O(N(2d-1)/d) for d-dimensional data •  Approximate variants with running time independent of N

• Modern multicore hardware posses tremendous power • Utilize the power for On-the-fly SDH computation • All aforementioned algorithms are easily parallelizable

6

Page 7: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Overview •  Introduction and Motivation • Spatial Distance Histogram (SDH) • GPU Architecture • Brute-force SDH Algorithm on GPU • Advanced SDH Algorithms on GPU • Conclusions and Future Work

7

Page 8: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

GPU Architecture •  GPU host thousands of cores •  Hierarchy of memory with different

access latency •  Process data in SIMD fashion •  Multiple threads access memory in

parallel

8

Multi- Processor

Global Memory

GPU Device

CPU Main Memory

Host

Multi- Processor

Multi- Processor

Core

Register File

Instruction Cache

Shared Memory | L1 Cache

L2 Cache

Multi-Processor

Core Core Core

Core Core Core Core

Block (1, 1)

Thread BlockThread Block (0, 0)

Device Level Global MemoryShared MemoryBlock Level

Private MemoryThread Level

Block (1, 0)

Block (0, 1)

Block (2, 0)Multiprocessor Blocks

Block (2, 1)

Page 9: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Overview •  Introduction and Motivation • Spatial Distance Histogram (SDH) • GPU Architecture • Brute-force SDH Algorithm on GPU • Advanced SDH Algorithms on GPU • Conclusions and Future Work

9

Page 10: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Brute-force SDH on GPU – Naïve Method •  Load all N points into GPU global memory • Compute all distances and generate histogram

!for each point p!! !Compute distance with all other N-1 points!

10

Read 4-byte word per thread

one point to other points on rightEach thread computes distance of

Multiprocessor 1

Multiprocessor 3Multiprocessor 2

Multiprocessor 4

Hisotgram Buckets

Device Level Global Memory

Page 11: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

SDH on GPU – Shared Memory Method •  To deal with:

•  High access latency of global memory •  Histogram buckets are updated by all threads -> serialized writes

into buckets

11

Device Level Global Memory

Hisotgram Buckets

Hisotgram Buckets

Multiprocessor Level Shared Memory

MultiprocessorInterïsegment distancesIntraïsegment distances

Page 12: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Experimental Results • GeForce GTX TITAN

•  CUDA Driver Version / Runtime Version: 6.0 / 5.0 •  CUDA Capability Major/Minor version number: 3.5 •  (14) Multiprocessors x (192) CUDA Cores/MP: 2688 CUDA Cores •  Total amount of global memory: 6144 Mbytes •  Total amount of shared memory per block: 49152 bytes

•  SDH of various number of data points •  Histogram is assumed to fit in portion of shared memory •  All data is assumed to fit in global memory

12

Page 13: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Experimental Results – Time

13

GPU running time Comparison

Data Points

CPU Main Memory

Shared Memory

Global Memory

100,000 424.7 (7m) 1.54 3.40 300,000 3812 (1h) 11.39 26.42 800,000 27142 (7h) 77.20 177.92 1,600,000 1.5 Day 316.01 699.16 3,200,000 Days 1317.21 2771.21 6,400,000 Days 5335.71 11036.78

Page 14: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Experimental Results – Speedup

Data Points Shared Memory

Global Memory

100,000 275.7 124.9 300,000 334.6 144.2 800,000 351.5 152.5 1,600,000 410.1 185.3 3,200,000 6,400,000

14

GPU Speedup Comparison with respect to CPU

Page 15: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Overview •  Introduction and Motivation • Spatial Distance Histogram (SDH) • GPU Architecture • Brute-force SDH Algorithm on GPU • Advanced SDH Algorithms on GPU • Conclusions and Future Work

15

Page 16: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Background of DM-SDH • Main idea: avoid the calculation of pairwise distances • Observation:

•  two groups of points can be processed in one shot if the range of all inter-group distances falls into a histogram bucket

•  We say these two groups are resolved into that bucket

16

17  

21  

29  

bucket i

Histogram[i] += 17*29;

Page 17: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Background of DM-SDH

17

2

7

15

6 13 4 2

9

1

6 10 3

5 12

6 8

Density Map - DM2

17

42 21

29

Density Map - DM1

The simulation space Density Map – DM0

x%

Distances = 17*21

y% z%

bucket i bucket i+1 bucket i+2

Min distance Max distance

17  

21  

29  

Page 18: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Spatial Uniformity •  Closed from PDF of distances – approximate PDF is derived •  Monte-Carlo simulation is another approximation to PDF

18

bucket i bucket i+1 bucket i+2

x% y% z%

A  

B  

Uniform cells Monte-Carlo Simulations

Compute Exact Proportions to Buckets

Theorem: Number of distinct Monte-Carlo simulations performed for all pair of cells in density map of M cells is O(M)

Page 19: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

DM-SDH on GPUs •  Load all density maps on global memory. • Shared memory is loaded by threads in a CUDA block

•  Each thread loads information about one cell

• Each thread processes a pair of cells •  Replacing only one cell in loop until all cell are processed •  Next a new cell is loaded and paired with distinct other cells

19

Page 20: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

DM-SDH Algorithm on GPUs

20

Gi Gj Gk

slide

Density Map (DM) Tree

Load DM cells

Global Memory

Shared Memory

Histogram Buckets

Histogram Buckets

Inter-group cell pairs

Intra-group cell pairs

Page 21: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

DM-SDH Algorithm on GPUs • Each CUDA thread

•  Processes a pair of cells from DM

•  If pair of cells contain uniformly distributed points •  Threads in each CUDA block perform Monte-Carlo simulations •  The probability distribution function for histogram buckets is hashed

• Now for each pair of cells •  If they have uniformly distributed points

•  Retrieve information from hash and update histogram buckets •  Else

•  Either compute pair-wise distance of all pairs of points in both cells by naïve way

•  Or use some heuristics

21

Page 22: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Experimental Results – Performance

22

MM: CPU version, GM: GPU version

Page 23: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Experimental Results – Performance

23

MM: CPU version, GM: GPU Global Memory, SM: GPU Shared Memory

Page 24: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Experimental Results - Energy Consumption

24

Page 25: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

DM-SDH vs. Brute-force

25

• Brute-force algorithm more suitable for GPU deployment

• Main problems for DM-SDH on GPUs: • Code divergence (i.e., tree traverse) • Size of a cell is much larger than size of a point

Page 26: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Overview •  Introduction and Motivation • Spatial Distance Histogram (SDH) • GPU Architecture • Brute-force SDH Algorithm on GPU • Advanced SDH Algorithms on GPU • Conclusions and Future Work

26

Page 27: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Conclusions and Future Work

• Computing power of GPUs can be harnessed for SDH processing

• Speedup varies (3X – 400X) with the algorithm implemented and problem parameter

•  Take advantage of new GPU/CUDA features •  Shuffle instruction •  Large register pool •  Read-only cache

• Extension to other correlation functions

27

Page 28: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Relevant Publications •  [TKDE14] A. Kumar, V. Grupcev, Y. Yuan, Y. Tu, Jin Huang, and G. Shen.

Computing Spatial Distance Histograms for Large Scientific Datasets On-the-fly. To appear in IEEE Transactions on Knowledge and Data Engineering (TKDE).

•  [TKDE13] V. Grupcev, Y. Yuan, Y. Tu, Jin Huang, S. Chen, S. Pandit, and M. Weng. Approximate Algorithms for Computing Distance Histograms with Accuracy Guarantees. IEEE Transactions on Knowledge and Data Engineering (TKDE) 25(9):1982-1996, September 2013.

•  [VLDBJ11] S. Chen, Y. Tu, and Y. Xia. Performance Analysis of A Dual-Tree Algorithm for Computing Spatial Distance Histograms. The VLDB Journal. 20(4):471-494, August 2011.

•  [EDBT12] A. Kumar, V. Grupcev, Y. Tu, Y. Yuan, and G. Shen. Distance Histogram Computation Based on Spatiotemporal Uniformity in Scientific Data. In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany, March 26-30, 2012.

•  [ICDE09] Y. Tu, S. Chen, and S. Pandit. Computing Distance Histograms Efficiently in Scientific Databases. In Procs. of 25th International Conference on Data Engineering (ICDE), pp. 796-807, Shanghai, China, March 2009.

•  [NIPS00] Gray, A.G., Moore, A.W. N-body problems in statistical learning. In Advances in Neural Information Processing Systems (NIPS), 1408 pp. 521–527, MIT Press (2000)

28

Page 29: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

THANK YOU Questions ?

29

Page 30: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

Background of DM-SDH •  The Approximate Algorithm (ADM-SDH)

•  Organize  all  data  into  a  Quad-­‐tree  (2D  data)  or  Oct-­‐tree  (3D  data).    •  Cache  the  atoms  counts  of  each  tree  node  (cell)  

•  Density  map:  all  counts  in  one  tree  level  

30

start from one proper density map M0 FOR every pair of cells A and B in M0

resolve A and B IF A and B are not resolvable THEN IF at desired density map level THEN distribute distances proportionally into overlapping buckets ELSE FOR each child cell A’ of A FOR each child cell B’ of B resolve A’ and B’

Page 31: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

SDH on GPU – Using Registers • GPU with compute capability 3.0 and up support the

_shift__ instruction. •  Load large number of registers with distinct point • Compute the SDH by shifting one set of register

•  While keeping another set constant •  All pairs of distances between the two sets will be computed

31

Page 32: Efficient Computation of Radial Distribution Function on ......In Procs. of 15th IEEE International Conference on Extending Database Technology (EDBT). pp.288-299, Berlin, Germany,

SDH on GPU – Using Registers

32

Pair-wise distance

Points in global memory of device

Shift left after one iteration of pair-wise computation

If N is odd – N/2 shifts If N is even – (N-1)/2 shifts

Keep moving selection