This is an archive of the discontinued LLVM Phabricator instance.

[CUDA] Do not allow using NVPTX target for host compilation.
ClosedPublic

Authored by tra on Aug 1 2016, 5:25 PM.

Details

Summary

Driver only knows how to construct NVPTX compilation pipeline for device side only.
Using NVPTX on the host side violates number of assumptions, trips several assertions and is not expected to produce anything useful in any case. It's better to thow an explicit error instead of letting user figure out what caused compilar to crash.

Diff Detail

Repository
rL LLVM

Event Timeline

tra updated this revision to Diff 66405.Aug 1 2016, 5:25 PM
tra retitled this revision from to [CUDA] Do not allow using NVPTX target for host compilation..
tra updated this object.
tra added a reviewer: jlebar.
tra added a subscriber: cfe-commits.
jlebar added inline comments.Aug 1 2016, 5:32 PM
lib/Driver/ToolChains.cpp
4834 ↗(On Diff #66405)

IRL we talked about putting an assert() here and bailing out earlier. Does that not work?

My hope was that we could avoid having to put checks everywhere that the -arch flag is non-empty.

Also, if we're going to print an error message saying "you can't use nvptx as the host compiler", it would be nice to do that at some point in the code where we have confidence that someone is actually trying to use nvptx as the host compiler, instead of assuming that, if we get here, that's what happened.

tra added inline comments.Aug 1 2016, 5:41 PM
lib/Driver/ToolChains.cpp
4834 ↗(On Diff #66405)

Haven't found a good place for it yet.
Another problem is that Driver::Diag() does not abort the program and we'll continue on and will execute these functions and will trigger asserts if they are there. I'll try changing diagnostics from Error to Fatal. If that stops clang right there, then we can keep asserts in place.

tra updated this revision to Diff 66505.Aug 2 2016, 11:03 AM

Abort pipeline constructions early if we detect that NVPTX is used for host compilation.
Restore assertions for presence of -march flag.

jlebar accepted this revision.Aug 2 2016, 1:31 PM
jlebar edited edge metadata.

Restore assertions for presence of -march flag.

We don't need an explicit assertion in TranslateArgs?

lib/Driver/Driver.cpp
1412 ↗(On Diff #66505)

This is probably worth a comment?

This revision is now accepted and ready to land.Aug 2 2016, 1:31 PM
tra added a comment.Aug 2 2016, 2:48 PM

Restore assertions for presence of -march flag.

We don't need an explicit assertion in TranslateArgs?

Nope. The action we create for fatbin uses CudaToolChain, but has nullptr BoundArch and there's no way to tell who's the caller of TranslateArgs().

tra updated this revision to Diff 66560.EditedAug 2 2016, 3:01 PM
tra updated this object.
tra edited edge metadata.

Added a comment describing why we deliberately error out on use of NVPTX for host compilation.

tra marked an inline comment as done.Aug 2 2016, 3:01 PM
This revision was automatically updated to reflect the committed changes.