From b3acd514c5d629781e816b847aff9891015fa7bd Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 29 Jun 2019 23:45:47 +0200 Subject: Implement layout and memory padding There are at least two distinct areas where padding can be beneficial on a GPU: 1. Padding the global thread sizes to support specific thread layouts e.g. (32,1) layouts require the global lattice width to be a multiple of 32 2. Padding the memory layout at the lowest level to align memory accesses i.e. some GPUs read memory in 128 Byte chunks and as such it is beneficial if the operations are aligned accordingly For lattice and thread layout sizes that are exponents of two these two padding areas are equivalent. However when one operates on e.g. a (300,300) lattice using a (30,1) layout, padding to 128 bytes yields a performance improvement of about 10 MLUPS on a K2200. Note that I am getting quite unsatisfied with how the Lattice class and its suroundings continue to accumulate parameters. The naming distinction between Geometry, Grid, Memory and Lattice is also not very intuitive. --- ldc_2d.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ldc_2d.py') diff --git a/ldc_2d.py b/ldc_2d.py index 8268e10..52f0912 100644 --- a/ldc_2d.py +++ b/ldc_2d.py @@ -61,7 +61,11 @@ lbm = LBM(D2Q9) lattice = Lattice( descriptor = D2Q9, - geometry = Geometry(256, 256), + geometry = Geometry(300, 300), + + layout = (30,1), + padding = (30,1,1), + align = True, moments = lbm.moments(optimize = False), collide = lbm.bgk(f_eq = lbm.equilibrium(), tau = relaxation_time), -- cgit v1.2.3