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