Skip to content

Conversation

@adurang
Copy link
Contributor

@adurang adurang commented Nov 20, 2025

Decouple building and linking the device image from creating the L0ProgramTy representing it. Use the GPU ELF image as the internal Image data for L0ProgramTy. This improves compatibility with the main library which expects to be an ELF in several places.

Copy link
Contributor

Copilot AI left a comment

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 decouples the building and linking of device images from the creation of L0ProgramTy objects. The key improvement is using the GPU ELF binary retrieved from the Level Zero driver as the internal image data, rather than the original input image, which improves compatibility with the main library.

  • Introduces L0ProgramBuilderTy class to handle module building and linking
  • Modifies L0ProgramTy to store the final ELF binary instead of the original image
  • Removes library module detection logic from L0ProgramTy

Reviewed Changes

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

Show a summary per file
File Description
offload/plugins-nextgen/level_zero/src/L0Program.cpp Refactors module building/linking into L0ProgramBuilderTy; adds getELF() to retrieve native binary
offload/plugins-nextgen/level_zero/src/L0DynWrapper.cpp Adds zeModuleGetNativeBinary wrapper function
offload/plugins-nextgen/level_zero/src/L0Device.cpp Updates loadBinaryImpl to use builder pattern and retrieve ELF before creating L0ProgramTy
offload/plugins-nextgen/level_zero/include/L0Program.h Defines L0ProgramBuilderTy class and updates L0ProgramTy constructor
offload/plugins-nextgen/level_zero/include/L0Device.h Changes addProgram to accept builder and return Expected<L0ProgramTy &>

Copy link
Contributor

@sarnex sarnex left a comment

Choose a reason for hiding this comment

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

seems ok to me until we decide on getting rid of the ELF requirement

Copy link
Contributor

@pbalcer pbalcer left a comment

Choose a reason for hiding this comment

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

I checked docs, and level-zero doesn't guarantee what is the specific format of the binary returned by zeModuleGetNativeBinary. By reading it, we are relaying on implementation-defined behavior. While ok for now, we need to either work with the driver team to standardize this, or, preferably, move reading ELF metadata up to libomptarget.

Otherwise lgtm. Thanks for doing this, it does look like a smaller, likely less controversial, change than @lplewa proposal.

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.

4 participants