How to view source code side by side with SASS?

I saw some blog showing source code and sass side by side. Is there a flag that I need to turn on at compiling> Thanks,

It would probably help if you provide an example (i.e. a link to the blog in question). The new profilers (e.g. nsight compute) can show source and sass if you compile with -lineinfo.

Thanks, I have compiled with -lineinfo. But I can only see sass code, not the source code. Below is snapshot of the nsight compute screen.

You want to select Source and SASS at the top, as is shown here. (I suggest reading that section.) And you need to make sure that the source code file is “available”.

1 Like

got it working now. thanks,

Hi, I meet the same problem. I run ncu command on linux remote, then download ncu-rep file to local mechine and open it in nsight compute.

how can I view source code side by side with SASS? should I add some flags in ncu command or connect the local machine’s nsight compute to remote.

Thanks a lot!

If the source page in the UI shows both Source and SASS views, but Source is empty, you can either use the Resolve button to load the source from the remote machine, or you can run the collection with --import-source yes.

If the source page does only show a SASS view, you are missing the correlation information between the two and need to compile your application with -lineinfo.

All of this is also explained in the documentation referenced by the previous post.

1 Like

thanks! It works for me.

Two related questions:

  1. How to persist line info as the source code is edited? Line information within an executable are only references to the source code, but whenever the source is edited, the linking becomes meaningless and Nsight Compute also indicates (File Mismatch) in orange in the Source or Source/SASS views. What are best practices to keep track of the source code that generated the SASS for a specific executable, for each saved .ncu-rep file, even as the source code and the executable change during development?

  2. How to link PTX, as well, in order to inspect all Source, PTX and SASS combinations in Nsight Compute?

So far, I have Source and SASS in Nsight Compute, and PTX separately, via the following make config. Whenever I look at PTX, generated as a separate file (i.e., not as line info within the executable) and viewed externally, I miss the useful quick linking to either Source of SASS, within Nsight Compute.

Thanks!

add_executable(perftests main.cu dataInterface.c)

add_library(ctm OBJECT main.cu)

target_compile_options(perftests PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--generate-line-info>)

set_property(TARGET ctm PROPERTY CUDA_PTX_COMPILATION ON "--keep")

You can use --import-source yes or the respective UI options to embed the high-level source directly into the report and have the tool use that rather than an on-disk version for the Source page.

You have to build your executable such that ptx is embedded in the ELF for Nsight Compute to be able to show it. This implies you can’t use separate linking during compilation. External ptx files are not supported.

1 Like

Thanks so much Felix.

I can clearly see the effects. Can you say a bit more about why not using separate linking embeds PTX in the ELF, though? I mean, in principle, even without separate linking the SASS could be embedded without the PTX needing to end up in the cubin, but please correct me if I’m wrong. I can see a lesson waiting to be learned about the build process here.

I mean, in principle, even without separate linking the SASS could be embedded without the PTX needing to end up in the cubin

That’s true, and the SASS is in fact ending up in the cubin (or is jitt’ed from PTX at runtime and made available to the tool by the driver).

When using separate linking at the ELF level, there is no PTX available in the ELF that would correspond to the final SASS. As such, Nsight Compute does not show any PTX even though it would be available statically in the executable and could be shown with cuobjdump -all -lptx. However, this is a pre-linked version of the PTX and cannot be reliably used for correlation.

For more detailed questions about the compilation and linking workflow, please ask in the compiler forum.