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

Method extractDeviceCode

lib/compilers/nvcc.ts:199–236  ·  view source on GitHub ↗
(
        result: CompilationResult,
        filters: ParseFiltersAndOutputOptions,
        compilationInfo: CompilationInfo,
    )

Source from the content-addressed store, hash-verified

197 }
198
199 override async extractDeviceCode(
200 result: CompilationResult,
201 filters: ParseFiltersAndOutputOptions,
202 compilationInfo: CompilationInfo,
203 ) {
204 const {dirPath} = result;
205 const {demangle} = filters;
206 const devices = {...result.devices};
207 if (dirPath) {
208 const files = await fs.readdir(dirPath);
209 const maxSize = this.env.ceProps('max-asm-size', 64 * 1024 * 1024);
210 await Promise.all(
211 files
212 .filter(f => f.endsWith('.ptx') || f.endsWith('.cubin'))
213 .map(async name => {
214 const type = name.endsWith('.ptx') ? 'PTX' : 'SASS';
215 const {asm} =
216 type === 'PTX'
217 ? {asm: await fs.readFile(Path.join(dirPath, name), 'utf8')}
218 : await this.nvdisasm(Path.join(dirPath, name), {dirPath}, maxSize);
219 const archAndCode = name.split('.').slice(1, -1).join(', ') || '';
220 const nameAndArch = type + (archAndCode ? ` (${archAndCode.toLowerCase()})` : '');
221 const parser = type === 'PTX' ? this.ptxParser : this.deviceAsmParser;
222 Object.assign(devices, {
223 [nameAndArch]: await this.postProcessAsm(
224 {
225 okToCache: demangle,
226 ...parser.process(asm, {...filters, binary: type === 'SASS'}),
227 },
228 {...filters, binary: type === 'SASS'},
229 ),
230 });
231 }),
232 );
233 result.devices = devices;
234 }
235 return result;
236 }
237}

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected