Use __ldg for CUDA kernels in fuser (#18540)
authorThomas Viehmann <tv.code@beamnet.de>
Thu, 28 Mar 2019 03:17:01 +0000 (20:17 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 28 Mar 2019 03:22:17 +0000 (20:22 -0700)
commit9696f06bcf426db4504e2e566ce231c6b84206e2
tree48da65fe1cc6f6db798045e067692c909203b941
parent8635078d9ed47266e6df89ad5ef887b598a76f25
Use __ldg for CUDA kernels in fuser (#18540)

Summary:
While benchmarking a kernel with broadcasted inputs, I noticed
that is was much slower than a hand-coded kernel for the smae task.

The kernel in question computed a * b + c for a of shape
32 x 32 x 10240 and b and c of shape 1 x 32 x 1.

This patch accellerates said kernel from 450us to 250us on my GTX1080Ti.

I didn't change half because there doesn't seem to be __ldg for
half.

An alternative could be to sprinkle const and restrict.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18540

Differential Revision: D14657840

Pulled By: soumith

fbshipit-source-id: 408847346ec12d1d1d9b119ac50bbc70f0d9ed33
torch/csrc/jit/fuser/codegen.cpp