This is an archive of the discontinued LLVM Phabricator instance.

[CUDA] Added --cuda-noopt-device-debug option to control ptxas' debug info generation.
ClosedPublic

Authored by tra on Feb 10 2016, 4:19 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

tra updated this revision to Diff 47558.Feb 10 2016, 4:19 PM
tra retitled this revision from to [CUDA] pass debug options to ptxas..
tra updated this object.
tra added reviewers: jlebar, echristo.
tra added a subscriber: cfe-commits.
echristo accepted this revision.Feb 10 2016, 4:23 PM
echristo edited edge metadata.

Wow really? That's ... wow.

OK

This revision is now accepted and ready to land.Feb 10 2016, 4:23 PM
jlebar added inline comments.Feb 10 2016, 4:23 PM
lib/Driver/Tools.cpp
10707 ↗(On Diff #47558)

I think this is would be very surprising to users. -g does not usually have a large performance impact, so -O2 -g does not generally mean "generate slow code," as far as I know. I'm concerned that this will result in people accidentally compiling with ptxas -O0 (which is why I didn't do it like this to begin with).

Can we accomplish this in a more explicit way?

echristo added inline comments.Feb 10 2016, 4:27 PM
lib/Driver/Tools.cpp
10707 ↗(On Diff #47558)

Other than warning I'm not sure what we can do, we could do that instead and make everyone use O0 that wants debug info in their ptx?

hfinkel added inline comments.
lib/Driver/Tools.cpp
10707 ↗(On Diff #47558)

I'd rather we refuse to do anything (i.e. produce an error) than silently remove either optimizations or -g. Do we have a way to separately specify the optimization level for host and device code? If not, looks like we should add one.

tra added inline comments.Feb 10 2016, 4:36 PM
lib/Driver/Tools.cpp
10707 ↗(On Diff #47558)

NVCC has -G option to control ptxas' debug options. If it's present, ptxas optimizations are disabled. I could add a similar option. "-gcuda-device" perhaps?

tra added inline comments.Feb 10 2016, 4:46 PM
lib/Driver/Tools.cpp
10707 ↗(On Diff #47558)

@hfinkel: separate option should work. Any suggestions for a good name? -gcuda-device sounds awkward.

@echristo: "-O0" is not going to work for everyone in practice due to ptxas limitations. For instance on some thrust files ptxas runs out of memory on all non-inlined functions in unoptimized code. Compiling with -O2 is one way to work around that, but I do want device-side debug info!

echristo added inline comments.Feb 10 2016, 4:49 PM
lib/Driver/Tools.cpp
10707 ↗(On Diff #47558)

We can do that, I'd have warned because it doesn't seem like something we should hard error on, but I can see that perspective, i.e. we asked for "incompatible" options.

And no, we don't currently have a way to do that. We can try to come up with a driver interface.

10707 ↗(On Diff #47558)

Huh? I'm not sure what you're doing here then with turning off optimizations in the presence of debug info requests. Your commentary made it sound like you can't have both.

hfinkel added inline comments.Feb 10 2016, 4:54 PM
lib/Driver/Tools.cpp
10707 ↗(On Diff #47558)

@hfinkel: separate option should work. Any suggestions for a good name? -gcuda-device sounds awkward.

I agree it sounds awkward, but I currently have no better suggestion.

tra added inline comments.Feb 10 2016, 5:15 PM
lib/Driver/Tools.cpp
10707 ↗(On Diff #47558)

@echristo: I assumed you were talking about compiler when you said "make everyone use O0". I need compiler to optimize code with -O2, but run ptxas with -g and -O0 which this patch makes possible.

I'll update the patch to add an option to control device-side debug info explicitly.

echristo added inline comments.Feb 10 2016, 5:32 PM
lib/Driver/Tools.cpp
10707 ↗(On Diff #47558)

OK.

tra updated this revision to Diff 47680.Feb 11 2016, 10:39 AM
tra retitled this revision from [CUDA] pass debug options to ptxas. to [CUDA] Added --cuda-noopt-device-debug option to control ptxas' debug info generation..
tra updated this object.
tra edited edge metadata.

Added --cuda-noopt-device-debug option to control ptxas' debug info generation.

The idea was to make it painfully obvious that unlike regular -g this option 8s going to affect performance of device-side code.
The option name is a mouthful, so feel free to suggest better alternatives.

jlebar accepted this revision.Feb 11 2016, 1:09 PM
jlebar edited edge metadata.
jlebar added inline comments.
lib/Driver/Tools.cpp
10696 ↗(On Diff #47680)

Nit: ignore the compiler's

This revision was automatically updated to reflect the committed changes.