[ROCm] re-add support for ROCm builds
Previously #6086 added ROCm support but after numerous rebases it lost
critical changes. This PR restores the ROCm build.
There are many source file changes but most were automated using the
following:
```bash
for f in `grep -rl '#ifdef USE_CUDA'`
do
sed -i 's@#ifdef USE_CUDA@#if defined(USE_CUDA) || defined(USE_ROCM)@g' $f
done
for f in `grep -rl '#endif // USE_CUDA'`
do
sed -i 's@#endif // USE_CUDA@#endif // USE_CUDA || USE_ROCM@g' $f
done
```
Showing