[PATCH] D17111: [CUDA] pass debug options to ptxas.

Eric Christopher via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 10 16:49:53 PST 2016


echristo added inline comments.

================
Comment at: lib/Driver/Tools.cpp:10707
@@ +10706,3 @@
+    // ptxas does not accept -g option if optimization is enabled, so we ignore
+    // compiler's -O* options if we want debug info.
+    CmdArgs.push_back("-g");
----------------
tra wrote:
> hfinkel wrote:
> > echristo wrote:
> > > jlebar wrote:
> > > > 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?
> > > 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?
> > 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.
> 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?
> 
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.

================
Comment at: lib/Driver/Tools.cpp:10707
@@ +10706,3 @@
+    // ptxas does not accept -g option if optimization is enabled, so we ignore
+    // compiler's -O* options if we want debug info.
+    CmdArgs.push_back("-g");
----------------
tra wrote:
> echristo wrote:
> > tra wrote:
> > > hfinkel wrote:
> > > > echristo wrote:
> > > > > jlebar wrote:
> > > > > > 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?
> > > > > 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?
> > > > 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.
> > > 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?
> > > 
> > 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.
> @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!
> 
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.


http://reviews.llvm.org/D17111





More information about the cfe-commits mailing list