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

Function blankCudaConstructs

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

Source from the content-addressed store, hash-verified

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

Callers 3

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

Calls

no outgoing calls

Tested by

no test coverage detected