This is an archive of the discontinued LLVM Phabricator instance.

[HIP] Support -fcuda-flush-denormals-to-zero for amdgcn
ClosedPublic

Authored by yaxunl on Jun 18 2018, 10:05 AM.

Diff Detail

Repository
rC Clang

Event Timeline

yaxunl created this revision.Jun 18 2018, 10:05 AM
yaxunl added a reviewer: scchan.
yaxunl updated this revision to Diff 151748.Jun 18 2018, 10:42 AM

Correct comments in test.

tra added a comment.Jun 20 2018, 1:35 PM

Using OpenCL's flag for the purpose adds a *third* way we handle denormals flushing in clang. Now it would be HIP (which is CUDA-like) using OpenCL's flag for denormals instead of CUDA's one.
You could change AMDGPUTargetInfo::adjustTargetOptions() to use CGOpts.getLangOpts().CUDADeviceFlushDenormalsToZero instead. That would at least make HIP and CUDA do the same thing.

I think it would work better if we could coalesce CUDADeviceFlushDenormalsToZero and CodeGenOpts.FlushDenorm and, maybe move the flag to LangOpts , so we could use LangOpts.CUDAIsDevice.

In D48287#1138262, @tra wrote:

Using OpenCL's flag for the purpose adds a *third* way we handle denormals flushing in clang. Now it would be HIP (which is CUDA-like) using OpenCL's flag for denormals instead of CUDA's one.
You could change AMDGPUTargetInfo::adjustTargetOptions() to use CGOpts.getLangOpts().CUDADeviceFlushDenormalsToZero instead. That would at least make HIP and CUDA do the same thing.

I think it would work better if we could coalesce CUDADeviceFlushDenormalsToZero and CodeGenOpts.FlushDenorm and, maybe move the flag to LangOpts , so we could use LangOpts.CUDAIsDevice.

Sorry for the delay.

CGOpts does not have member function getLangOpts(). It seems whereever we need to refer to LangOpts.CUDADeviceFlushDenormalsToZero, we can use Opts.FlushDenorm, but not true vice versa. Therefore if we want a unified option, Opts.FlushDenorm is a better choice.

yaxunl updated this revision to Diff 155580.Jul 14 2018, 8:37 PM

Replace LangOpts.CUDADeviceFlushDenormalsToZero with CodeGenOpts.FlushDenorm.

tra accepted this revision.Jul 20 2018, 3:17 PM

Thank you. That should work.

This revision is now accepted and ready to land.Jul 20 2018, 3:17 PM
This revision was automatically updated to reflect the committed changes.