(source: string)
| 722 | // braces it never closes, so it fails the balance check and stays untouched. |
| 723 | const CUDA_LAUNCH_CONFIG_RE = /<<<[^;]{0,400}?>>>/g; |
| 724 | export function blankCudaConstructs(source: string): string { |
| 725 | let out = source; |
| 726 | if (out.indexOf('__') !== -1) { |
| 727 | out = out |
| 728 | .replace(CUDA_LAUNCH_BOUNDS_RE, (m) => ' '.repeat(m.length)) |
| 729 | .replace(CUDA_SPECIFIER_RE, (m) => ' '.repeat(m.length)); |
| 730 | } |
| 731 | if (out.indexOf('<<<') !== -1) { |
| 732 | out = out.replace(CUDA_LAUNCH_CONFIG_RE, (m) => { |
| 733 | let depth = 0; |
| 734 | for (let i = 0; i < m.length; i++) { |
| 735 | const ch = m.charCodeAt(i); |
| 736 | if (ch === 0x7b /* { */) depth++; |
| 737 | else if (ch === 0x7d /* } */ && --depth < 0) return m; |
| 738 | } |
| 739 | return depth === 0 ? m.replace(/[^\n]/g, ' ') : m; |
| 740 | }); |
| 741 | } |
| 742 | return out; |
| 743 | } |
| 744 | |
| 745 | /** Strong content markers for CUDA source in files without a CUDA extension |
| 746 | * (headers). The dunders are execution-space specifiers that only nvcc defines; |
no outgoing calls
no test coverage detected