MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / extractDeviceCode

Method extractDeviceCode

lib/compilers/nvcpp.ts:96–138  ·  view source on GitHub ↗
(
        result: CompilationResult,
        filters: ParseFiltersAndOutputOptions,
        compilationInfo: CompilationInfo,
    )

Source from the content-addressed store, hash-verified

94 }
95
96 override async extractDeviceCode(
97 result: CompilationResult,
98 filters: ParseFiltersAndOutputOptions,
99 compilationInfo: CompilationInfo,
100 ) {
101 const {dirPath} = result;
102 const {demangle} = filters;
103 const devices = {...result.devices};
104
105 if (filters.binary) {
106 await this.extractDeviceBinariesFromExecutable(result, compilationInfo);
107 }
108
109 if (dirPath) {
110 const files = await fs.readdir(dirPath);
111 const maxSize = this.env.ceProps('max-asm-size', 64 * 1024 * 1024);
112 await Promise.all(
113 files
114 .filter(f => f.endsWith('.ptx') || f.endsWith('.cubin'))
115 .map(async name => {
116 const type = name.endsWith('.ptx') ? 'PTX' : 'SASS';
117 const {asm} =
118 type === 'PTX'
119 ? {asm: await fs.readFile(path.join(dirPath, name), 'utf8')}
120 : await this.nvdisasm(path.join(dirPath, name), maxSize);
121 const archAndCode = name.split('.').slice(1, -1).join(', ') || '';
122 const nameAndArch = type + (archAndCode ? ` (${archAndCode.toLowerCase()})` : '');
123 const parser = type === 'PTX' ? this.ptxParser : this.deviceAsmParser;
124 Object.assign(devices, {
125 [nameAndArch]: await this.postProcessAsm(
126 {
127 okToCache: demangle,
128 ...parser.process(asm, {...filters, binary: type === 'SASS'}),
129 },
130 {...filters, binary: type === 'SASS'},
131 ),
132 });
133 }),
134 );
135 result.devices = devices;
136 }
137 return result;
138 }
139}

Callers

nothing calls this directly

Calls 6

nvdisasmMethod · 0.95
readFileMethod · 0.80
processMethod · 0.65
readdirMethod · 0.45
postProcessAsmMethod · 0.45

Tested by

no test coverage detected