(source: string)
| 1661 | // braces it never closes, so it fails the balance check and stays untouched. |
| 1662 | const CUDA_LAUNCH_CONFIG_RE = /<<<[^;]{0,400}?>>>/g; |
| 1663 | export function blankCudaConstructs(source: string): string { |
| 1664 | let out = source; |
| 1665 | if (out.indexOf('__') !== -1) { |
| 1666 | out = out |
| 1667 | .replace(CUDA_LAUNCH_BOUNDS_RE, (m) => ' '.repeat(m.length)) |
| 1668 | .replace(CUDA_SPECIFIER_RE, (m) => ' '.repeat(m.length)); |
| 1669 | } |
| 1670 | if (out.indexOf('<<<') !== -1) { |
| 1671 | out = out.replace(CUDA_LAUNCH_CONFIG_RE, (m) => { |
| 1672 | let depth = 0; |
| 1673 | for (let i = 0; i < m.length; i++) { |
| 1674 | const ch = m.charCodeAt(i); |
| 1675 | if (ch === 0x7b /* { */) depth++; |
| 1676 | else if (ch === 0x7d /* } */ && --depth < 0) return m; |
| 1677 | } |
| 1678 | return depth === 0 ? m.replace(/[^\n]/g, ' ') : m; |
| 1679 | }); |
| 1680 | } |
| 1681 | return out; |
| 1682 | } |
| 1683 | |
| 1684 | /** Strong content markers for CUDA source in files without a CUDA extension |
| 1685 | * (headers). The dunders are execution-space specifiers that only nvcc defines; |
no outgoing calls
no test coverage detected