Fix AMD OpenCL float3 array optimization bug
authorSzilárd Páll <pall.szilard@gmail.com>
Thu, 6 Feb 2020 23:40:12 +0000 (00:40 +0100)
committerArtem Zhmurov <zhmurov@gmail.com>
Fri, 30 Oct 2020 05:45:43 +0000 (05:45 +0000)
commit85c36b9a1ca9c62702da2a0d6f97853c9f1d889c
tree9898446e71284989b1f46bb114b94c57ab882e18
parent5145e7cfcd8a0be3efaa19ad7311e039148a3108
Fix AMD OpenCL float3 array optimization bug

Because float3 by OpenCL spec is 16-byte, when used as an array type
the allocation needs to optimized to avoid unnecessary register use.
The nbnxm kernels use a float3 i-force accumulator array in registers.

Starting with ROCm 2.3 the AMD OpenCL compiler regressed and lost
its ability to effectively optimize code that uses float3 register
arrays. The large amount of extra registers used limits the kernel
occupancy and significantly impacts performance.
Only the AMD platform is affected, other vendors' compilers are able to
do the necessary transformations to avoid the extra register use.

This change converts the float3 array to a float[3] saving 8*4 bytes
register space. This improves nonbonded kernel performance
on an AMD Vega GPU by 25% and 40% for the most common flavor of the
Ewald and RF force-only kernels, respectively.

Note that eliminating the rest of the non-array use of float3 has no
significant impact.
src/gromacs/nbnxm/opencl/nbnxm_ocl_kernel.clh
src/gromacs/nbnxm/opencl/nbnxm_ocl_kernel_utils.clh