Skip to content

add InjectProgramBinariesForBinary control to inject binaries for clC…#468

Open
MaciejPlewka wants to merge 1 commit into
intel:mainfrom
MaciejPlewka:InjectBinaries
Open

add InjectProgramBinariesForBinary control to inject binaries for clC…#468
MaciejPlewka wants to merge 1 commit into
intel:mainfrom
MaciejPlewka:InjectBinaries

Conversation

@MaciejPlewka
Copy link
Copy Markdown

…reateProgramWithBinary

Add a new control flag that allows injecting replacement kernel binaries when an application creates a program via clCreateProgramWithBinary(). This is analogous to InjectProgramBinaries which only intercepts clCreateProgramWithSource() calls. When the injection binary is not found, the original application-provided binary is used as a fallback.

…reateProgramWithBinary

Add a new control flag that allows injecting replacement kernel binaries
when an application creates a program via clCreateProgramWithBinary().
This is analogous to InjectProgramBinaries which only intercepts
clCreateProgramWithSource() calls. When the injection binary is not
found, the original application-provided binary is used as a fallback.

Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
Copy link
Copy Markdown
Contributor

@bashbaug bashbaug left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! Could you please have a look at the suggestions below and see if they make sense?

Comment thread intercept/src/controls.h
CLI_CONTROL( bool, DumpProgramSPIRV, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump every program IL binary passed to clCreateProgramWithIL() to its own file. The file name will have the form \"CLI_<Program Number>_<Unique Program Hash Code>_0000.spv\" - for now at least!. Program options will be dumped to the same directory with the file name \"CLI_<Program Number>_<Unique Program Hash Code>_<Compile Count>_<Unique Build Options Hash Code>_<API>_options.txt\", where <API> is an empty string for clBuildProgram(), \"compile\" for clCompileProgram(), and \"link\" for clLinkProgram(). This setting can be used for information purposes to see all kernels that are used by an application or to dump SPIRV programs for SPIRV injection." )
CLI_CONTROL( bool, InjectProgramSource, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will look to inject potentially modified kernel source to clCreateProgramWithSource() and/or potentially modified options to clCompileProgram() or clBuildProgram(). Note that program options currently cannot be injected for clLinkProgram()." )
CLI_CONTROL( bool, InjectProgramBinaries, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will look to inject potentially modified kernel binaries via clCreateProgramWithBinary() in place of program text for each call to clCreateProgramWithSource(). This is typically done to reduce program compilation time or to use known good program binaries." )
CLI_CONTROL( bool, InjectProgramBinariesForBinary, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will look to inject potentially modified kernel binaries via clCreateProgramWithBinary() in place of binaries for each call to clCreateProgramWithBinary(). This can be used to replace application-provided program binaries with known good or modified program binaries." )
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.

I'm starting to become sensitive to the number of controls we have, especially when there are multiple controls that behave subtly different. In this case, do we really need a new control InjectProgramBinariesForBinary, or can we expand the behavior of InjectProgramBinaries slightly instead?

I can't think of many downsides to reusing the existing control, since the user still needs to prepare the injection binaries to properly inject binaries, regardless whether the injection is originating from clCreateProgramWithSource or clCreateProgramWithBinary.

Comment on lines +2060 to +2067
retVal = pIntercept->dispatch().clCreateProgramWithBinary(
context,
num_devices,
device_list,
lengths,
binaries,
binary_status,
errcode_ret );
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.

Can you please refactor this flow control slightly to eliminate this duplicated call to clCreateProgramWithBinary?

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.

2 participants