Repository navigation
compiler: hash the input file name for C/C++ compilations - #2974
Conversation
The compiler records the source file name in the object (an STT_FILE symbol on ELF), but the preprocessed output it is hashed from has no line markers, so two sources that preprocess to the same text, such as files that are entirely #ifdef'd out, ended up sharing one cache entry and one of them got an object naming the other. Hash the file name without its directory, so the same file still hits across checkouts. Closes mozilla#2959
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2974 +/- ##
==========================================
- Coverage 78.54% 78.54% -0.01%
==========================================
Files 74 74
Lines 44039 44095 +56
==========================================
+ Hits 34592 34635 +43
- Misses 9447 9460 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ptxas reads a .ptx file that nvcc names after the source, so identical device code from two sources stopped sharing a cubin.
| // after the source, and identical device code from different sources | ||
| // is meant to be shared. | ||
| let input_file_name = match self.parsed_args.language { | ||
| Language::CudaFE | Language::Ptx | Language::Cubin => None, |
There was a problem hiding this comment.
please add a test showing two sources with the same device code still share the cubin/ptx
There was a problem hiding this comment.
Added test_device_code_input_file_name_ignored in e2c0d3c: it checks that cudafe++, PTX and cubin inputs with different names but the same content hash the same, while C and CUDA sources with different names still differ.
… file names Move the choice of which inputs keep their file name in the hash key into hashed_input_file_name, and check that cudafe++, PTX and cubin inputs with the same content but different names hash the same, while C and CUDA sources with different names still differ.
|
If the content is identical, do we want to duplicate the object or strip the filename before posting, and then "re-hydrating" it on the client? In practice this would allow for avoiding recompilation, at the cost of a seek, write and copy operation. Food for thought, don't treat this as direction! |
|
Thanks, I thought about that too. Putting the name back is more than a seek and write, though: on ELF it lives in |
The source file name, without its directory, is now part of the C/C++ cache key, so two files that preprocess to the same thing no longer share an object that carries only one of their names. The whitespace system test now reformats the same file instead of compiling a second one, since a different name is now a different key.
Closes #2959