de en es fr nl pl pt sv zh

perl

optimization of SASS stall counts

redp

Optimal instructions scheduling is NP-hard task. For this reason almost all compilers implement metaheuristic methods like list scheduling/Gibbons–Muchnick algorithm etc. ptxas is no exception - it also generates non-optimal scheduling, and this opens some opportunity for automatic optimization....

RE of PTX grammar from ptxas, part 4

redp

Parts 1, 2 & 3First of all, it should be noted that the mask of instruction attributes has size 20 bytes, so I updated dump for them.structure for this attributes descriptor has size 0xd8 bytes and some fields:mask at offset 0name of instruction at 0xC8index at 0xD0 Instructions selecting...

RE of PTX grammar from ptxas, part 3

redp

Parts 1 & 2Pseudo instructionsSurprise-surprise - some PTX instructions not mapped directly to underlying SASS 1:1. Instead they generate lots of another PTX code. I already extracted their decrypted bodies, so it's time to describe how they connected to specific PTX pseudo instructions There...

RE of PTX grammar from ptxas, part 2

redp

Part 1PTX instructions that cicc cannot generateWhile reverse-engineering Nvidia's compilation pipeline, I extracted the set of PTX instructions that cicc (the CUDA C++ frontend) is capable of emitting. The next logical step is to intersect them with full set of instructions accepted by ptxas - so...

RE of PTX grammar from ptxas

redp

DisclaimerHighly likely that author is an illiterate, inattentive, and incompetent lazy person with a poor imagination - therefore his hypotheses may be questionable, ideas delusional and his analysis simply incorrect. Also maybe I still haven't mastered ida pro in 28 years so extracted data can...

SASS latency analysis

redp

After extracting latency table I became curious how good the code produced by ptxas. Projects like CuAsmRL never estimated limits of profit after rescheduling - it's strange and looks even worse than famous "proof left as an exercise to the reader" - what if ptxas generates perfect code and there...

print & analyse CUDA coredumps

redp

inconvenient cuda-gdb can't automatically processing them - you need explicitly say something liketarget cudacore /full/path/to/coredumpand then type lots of info cuda XXX So last weekend I wrote tool to parse/dump CUDA coredumps and it even works on machine without CUDA SDK (what might be useful...

2025 Advent of Code Day 7 Part 2

adamcrussell

Perl. Developed and tested with Perl 5.40.0.use v5.40; no warnings q/recursion/; my @grid; open DATA, q/data/; while(<DATA>){ chomp; push @grid, [split //, $_]; } close(DATA); my $count = 1; my $line = shift @grid; my @beam = (1, (grep {$line->[$_] eq q/S/} 0 .. @{$line} -...

2025 Advent of Code Day 6 Part 2

adamcrussell

Perl. Developed and tested with Perl 5.40.0.use v5.40; my @grid; open DATA, q/data/; while(<DATA>){ chop; push @grid, $_; } close(DATA); my $format = build_unpack_format(@grid); @grid = (); open DATA, q/data/; while(<DATA>){ chop; my @fields = unpack $format, $_;...

SASS latency table & instructions reordering

redp

In these difficult times, no one wants to report bad or simply weak results (and this will destroy this hypocritical civilization). Since this is my personal blog and I am not looking for grants, I don't care.Let's dissect one truly inspiring paper - they employed reinforcement learning and claim...

sass registers reusing

redp

Lets continue to compose some useful things based on perl driven Ced. This time I add couple of new options to test script dg.pl for registers reusingWhat is it at all? Nvidia as usually don't want you to know. It implemented in SASS as set of operand attributes "reuse_src_XX" and located usually...

barriers & registers tracking for sass disasm

redp

Finally I add registers tracking in my perl sass disasmNow I can do some full-featured analysis of sass - like find candidates pairs of instruction to swap/run them in so called "dual" mode - and all of this in barely 1200 LoC of perl codeLet's think what must mean for couple of instructions to be...

sass disasm on perl

redp

as an illustration of the use of the modules presented in my previous post I made yet another sass disasm - fully written on Perl. It is almost exact copy of my nvd - implemented just in 460 LoC, the only unsupported feature is registers tracking - bcs I still don't make perl binding for it. What...

perl modules for CUBINs patching

redp

After playing a bit with my ced I came to the conclusion that implemented DSL for editing is not enough - like it would be good to have subroutines to patch repeated/similar instructions, check that patched instruction is what I want, patch attributes/relocs etcIn other words, I need full-fledged...