MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / blankCudaConstructs

Function blankCudaConstructs

src/extraction/languages/c-cpp.ts:1664–1683  ·  view source on GitHub ↗
(source: string)

Source from the content-addressed store, hash-verified

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

Callers 3

extraction.test.tsFile · 0.90
preParseCppSourceFunction · 0.85
preParseCSourceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected