Commit 7a36d70
authored
Add NVRTC PCH runtime APIs to cuda.core.Program (#1689)
* Add PCH support to cuda.core.Program (#670)
When `create_pch` is set in ProgramOptions, compile() now automatically
resizes the NVRTC PCH heap and retries with a fresh program when PCH
creation fails due to heap exhaustion. The `pch_status` property reports
the outcome ("created", "not_attempted", "failed", or None).
Made-with: Cursor
* Cache _has_nvrtc_pch_apis() result
Avoid repeated hasattr() calls on every compile by caching the result
in a module-level sentinel.
Made-with: Cursor
* Document that pch_status returns None for non-NVRTC backends
PCH is only relevant for code_type="c++" programs using NVRTC. Make
this explicit in the docstring so PTX/NVVM users aren't confused.
Made-with: Cursor
* Check errors on PCH heap resize in retry path
nvrtcGetPCHHeapSizeRequired and nvrtcSetPCHHeapSize were called without
error checking during the auto-retry. Route them through
HANDLE_RETURN_NVRTC so failures raise NVRTCError.
Made-with: Cursor
* Check pch option in addition to create_pch for PCH status/retry
The --pch flag (automatic PCH mode) can also trigger PCH creation,
not just --create-pch. Check both options when deciding whether to
query PCH status and attempt auto-retry.
Made-with: Cursor
* Catch RuntimeError from missing PCH symbols in old libnvrtc
When cuda.bindings is built against a newer toolkit but runs with an
older libnvrtc.so that lacks the PCH C symbols, the binding wrappers
exist (hasattr passes) but the actual call raises RuntimeError from
failing to resolve the function pointer at runtime.
Extract PCH status/retry logic into _pch_status_and_retry() and wrap
the call in try/except RuntimeError so we gracefully degrade to
pch_status=None instead of crashing.
Made-with: Cursor
* chore: fix toml1 parent 2d85f3e commit 7a36d70
File tree
4 files changed
+160
-5
lines changed- cuda_core
- cuda/core
- docs/source/release
- tests
4 files changed
+160
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
108 | 134 | | |
109 | 135 | | |
110 | 136 | | |
| |||
477 | 503 | | |
478 | 504 | | |
479 | 505 | | |
| 506 | + | |
| 507 | + | |
480 | 508 | | |
481 | 509 | | |
482 | 510 | | |
| |||
548 | 576 | | |
549 | 577 | | |
550 | 578 | | |
| 579 | + | |
| 580 | + | |
551 | 581 | | |
552 | 582 | | |
553 | 583 | | |
| |||
562 | 592 | | |
563 | 593 | | |
564 | 594 | | |
| 595 | + | |
565 | 596 | | |
566 | 597 | | |
567 | 598 | | |
| |||
649 | 680 | | |
650 | 681 | | |
651 | 682 | | |
652 | | - | |
653 | | - | |
654 | | - | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
655 | 692 | | |
656 | 693 | | |
657 | 694 | | |
| |||
669 | 706 | | |
670 | 707 | | |
671 | 708 | | |
672 | | - | |
673 | 709 | | |
674 | 710 | | |
675 | 711 | | |
| |||
716 | 752 | | |
717 | 753 | | |
718 | 754 | | |
719 | | - | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
720 | 833 | | |
721 | 834 | | |
722 | 835 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
57 | 62 | | |
58 | 63 | | |
59 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
60 | 76 | | |
61 | 77 | | |
62 | 78 | | |
| |||
316 | 332 | | |
317 | 333 | | |
318 | 334 | | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
319 | 354 | | |
320 | 355 | | |
321 | 356 | | |
| |||
0 commit comments