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

Function blankCudaConstructs

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

Source from the content-addressed store, hash-verified

712// braces it never closes, so it fails the balance check and stays untouched.
713const CUDA_LAUNCH_CONFIG_RE = /<<<[^;]{0,400}?>>>/g;
714export 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;

Callers 3

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

Calls

no outgoing calls

Tested by

no test coverage detected