Skip to content

Commit 598e882

Browse files
authoredMar 12, 2025
[libc] Template the writing mode for the writer class (#111559)
Summary: Currently we dispatch the writing mode off of a runtime enum passed in by the constructor. This causes very unfortunate codegen for the GPU targets where we get worst-case codegen because of the unused function pointer for `sprintf`. Instead, this patch moves all of this to a template so it can be masked out. This results in no dynamic stack and uses 60 VGPRs instead of 117. It also compiles about 5x as fast.
1 parent 3aa96f5 commit 598e882

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+508
-509
lines changed
 

‎libc/config/config.json

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
"LIBC_CONF_PRINTF_DISABLE_STRERROR": {
4242
"value": false,
4343
"doc": "Disable handling of %m to print strerror in printf and friends."
44+
},
45+
"LIBC_CONF_PRINTF_RUNTIME_DISPATCH": {
46+
"value": true,
47+
"doc": "Use dynamic dispatch for the output mechanism to reduce code size."
4448
}
4549
},
4650
"scanf": {

‎libc/config/gpu/amdgpu/config.json

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
},
2020
"LIBC_CONF_PRINTF_DISABLE_STRERROR": {
2121
"value": true
22+
},
23+
"LIBC_CONF_PRINTF_RUNTIME_DISPATCH": {
24+
"value": false
2225
}
2326
},
2427
"scanf": {

0 commit comments

Comments
 (0)