Skip to content

[SYCL] Augment SYCL_DUMP_IMAGES to dump only used device images - #22996

Open
uditagarwal97 wants to merge 5 commits into
syclfrom
private/udit/dump_images
Open

[SYCL] Augment SYCL_DUMP_IMAGES to dump only used device images#22996
uditagarwal97 wants to merge 5 commits into
syclfrom
private/udit/dump_images

Conversation

@uditagarwal97

@uditagarwal97 uditagarwal97 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Problem

SYCL_DUMP_IMAGES dumps every device image the runtime loads, at load time. For an application that links many device images but only runs a few kernels (like any PyTorch test), the output is dominated by images that are never used, and there is no way to tell from the dump which of them the runtime actually built and ran.

Changes proposed in this PR

SYCL_DUMP_IMAGES is now read as an integer level:

Value Behavior
unset No dumping (unchanged).
2 Dump only the device images that are actually used, at first use, and log the file name to stderr.
any other value Dump all loaded device images at load time (previous behavior).

@uditagarwal97 uditagarwal97 self-assigned this Aug 22, 2026
uditagarwal97 and others added 3 commits August 22, 2026 03:52
Handle SYCL_DUMP_IMAGES like the other SYCL RT environment variables: add
it to config.def and give it a SYCLConfig specialization instead of reading
it with std::getenv in ProgramManager.

When images are dumped upon use, print the name of the file each image was
dumped to, and report the file name again when an already dumped image is
used by a subsequent build.

Also document that any positive value other than 2 dumps all device images
and that dumping is off by default.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Check that level 2 dumps a device image on first use, reports the file it
was dumped to, reports a second kernel from the same image as already
dumped, and does not dump anything at image load time, while level 1 dumps
all loaded images without reporting.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Drop the single-use DumpImages local in ProgramManager::addImage, tighten
blank lines in SYCLConfig<SYCL_DUMP_IMAGES>, and remove the dump-file
existence RUN lines from the E2E test since the FileCheck patterns
already cover which images get dumped.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends SYCL_DUMP_IMAGES to support a new mode that dumps only the device images actually used at runtime (and reports the dump filename), while preserving the existing “dump all loaded images” behavior and documenting the updated semantics.

Changes:

  • Add SYCL_DUMP_IMAGES=2 (“dump used images only”) behavior in ProgramManager::getBuiltURProgram, including reporting and de-duplication of dumps.
  • Refactor dumpImage() to return the written filename and introduce a typed SYCLConfig<SYCL_DUMP_IMAGES> config parser.
  • Add an end-to-end test for dump levels and update user documentation for the new SYCL_DUMP_IMAGES behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sycl/test-e2e/SPVDumpUse/dump_levels.cpp New e2e coverage for “dump used only” vs “dump all” behavior.
sycl/source/detail/program_manager/program_manager.hpp dumpImage() now returns filename; adds state to track images dumped-on-use.
sycl/source/detail/program_manager/program_manager.cpp Implements “dump used only” and adjusts “dump all” gating via SYCLConfig.
sycl/source/detail/config.hpp Adds SYCLConfig<SYCL_DUMP_IMAGES> parsing helpers (dumpAll, dumpUsedOnly).
sycl/source/detail/config.def Registers SYCL_DUMP_IMAGES as a config key.
sycl/doc/EnvironmentVariables.md Documents the integer semantics, including level 2 used-only dumping.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread sycl/source/detail/program_manager/program_manager.cpp
Comment thread sycl/source/detail/config.hpp
Comment thread sycl/source/detail/program_manager/program_manager.hpp
- Treat an explicit SYCL_DUMP_IMAGES=0 as "off" instead of "dump all", so
  the value matches the documentation. A non-numeric value still dumps all
  images, preserving the historical behavior of the variable.
- Replace the function-local static sequence ID used by the dump-on-use
  path with a ProgramManager member guarded by m_DumpedImagesMutex.
- Erase the image from m_DumpedImages in removeImages(), so the map does
  not grow unboundedly and a reused image address cannot be mistaken for
  an already dumped one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@uditagarwal97
uditagarwal97 marked this pull request as ready for review August 24, 2026 16:42
@uditagarwal97
uditagarwal97 requested review from a team as code owners August 24, 2026 16:42

@YuriPlyakhin YuriPlyakhin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sycl/doc/EnvironmentVariables.md LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants