add InjectProgramBinariesForBinary control to inject binaries for clC…#468
add InjectProgramBinariesForBinary control to inject binaries for clC…#468MaciejPlewka wants to merge 1 commit into
Conversation
…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>
bashbaug
left a comment
There was a problem hiding this comment.
Thanks for your contribution! Could you please have a look at the suggestions below and see if they make sense?
| 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." ) |
There was a problem hiding this comment.
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.
| retVal = pIntercept->dispatch().clCreateProgramWithBinary( | ||
| context, | ||
| num_devices, | ||
| device_list, | ||
| lengths, | ||
| binaries, | ||
| binary_status, | ||
| errcode_ret ); |
There was a problem hiding this comment.
Can you please refactor this flow control slightly to eliminate this duplicated call to clCreateProgramWithBinary?
…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.