Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(gpu): accept PTX compute target aliases

morlutof250c8cca503
diff --git a/docs/gpu-code-objects.md b/docs/gpu-code-objects.md
index ead60041c..0c377c216 100644
--- a/docs/gpu-code-objects.md
+++ b/docs/gpu-code-objects.md
@@ -81,6 +81,8 @@ Kernel representations have different meanings:
- PTX reports parameter declarations and virtual registers. Shared bytes cover
supported static declarations inside that entry; they do not establish module
shared memory, dynamic allocation or physical device resources.
+ A `.target compute_xx` spelling is retained as written; NVIDIA PTX defines it
+ as a synonym for `.target sm_xx`.
Scalar register declarations count each bare or percent-prefixed name and
each parameterized range. Unsupported declaration forms or overflowing totals
retain an unknown count and partial decoding coverage. Unsupported parameter
diff --git a/src/gpu/PtxKernels.ts b/src/gpu/PtxKernels.ts
index 008f52942..b1edccf59 100644
--- a/src/gpu/PtxKernels.ts
+++ b/src/gpu/PtxKernels.ts
@@ -406,7 +406,7 @@ export const readPtxTarget = (text: string): string | null => {
if (token.value === ".target") {
const value = stream.next();
target =
- !value.done && /^sm_[0-9]+[a-z]?$/u.test(value.value.value)
+ !value.done && /^(?:sm|compute)_[0-9]+[a-z]?$/u.test(value.value.value)
? value.value.value
: null;
}
diff --git a/tests/acceptance/gpuCodeObjectsCli.test.ts b/tests/acceptance/gpuCodeObjectsCli.test.ts
index 1579d6ad0..4483c6a44 100644
--- a/tests/acceptance/gpuCodeObjectsCli.test.ts
+++ b/tests/acceptance/gpuCodeObjectsCli.test.ts
@@ -111,6 +111,25 @@ cliTest(
},
);
+cliTest("accepts the PTX compute_xx .target synonym verbatim", async ({ cli }) => {
+ const root = await createTestTempDirectory("rea-ptx-target-cli-");
+ const text = `.version 8.8\n.target compute_80\n.address_size 64\n.entry kernel() {\nret;\n}\n`;
+ const path = join(root, "target.ptx");
+ await writeFile(path, text);
+ const response = await cli.run({
+ arguments: ["inspect-gpu-code-objects", path, "--json"],
+ });
+ expect(response.exitCode, response.stderr).toBe(0);
+ const evidence = parseEvidence(
+ toolContract("inspect_gpu_code_objects").outputSchema.parse(response.json),
+ );
+ const report = gpuCodeObjectsSchema.parse(evidence.normalized_result);
+ expect(report.objects[0]!.target).toBe("compute_80");
+ expect(report.ptx_artifacts[0]!.sha256).toBe(
+ createHash("sha256").update(text).digest("hex"),
+ );
+});
+
cliTest(
"attributes malformed selector JSON to its actual CLI option",
async ({ cli }) => {