You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* initial support for injecting buffers
* initial support for injecting images
* cleanup, updated docs
* fix unused variable warning
* update README
* fix bug with image injection
During refactoring the read from the file was removed - oops!
* update documentation
Add a note that usage of the memory object after injection will
also be affected.
Copy file name to clipboardExpand all lines: docs/controls.md
+9-1Lines changed: 9 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -517,7 +517,7 @@ This is the list of options that is implicitly passed to CLANG to build a non-Op
517
517
518
518
This is the list of options that is implicitly passed to CLANG to build an OpenCL 2.0 SPIR-V module. Any application-provided build options will be appended to these build options.
519
519
520
-
### Controls for Dumping Buffers and Images
520
+
### Controls for Dumping and Injecting Buffers and Images
521
521
522
522
##### `DumpBufferHashes` (bool)
523
523
@@ -591,6 +591,14 @@ The Intercept Layer for OpenCL Applications will only dump argument values when
591
591
592
592
The Intercept Layer for OpenCL Applications will only dump kernel arguments when the enqueue counter is less than this value, inclusive.
593
593
594
+
##### `InjectBuffers` (bool)
595
+
596
+
If set to a nonzero value, the Intercept Layer for OpenCL Applications will look to inject potentially modified buffer, SVM, and USM contents before calls to clEnqueueNDRangeKernel(). Only buffers that are kernel arguments for the kernel being enqueued may be injected. The filename to inject will have the form "Enqueue\_\<Enqueue Number\>\_Kernel\_\<Kernel Name\>\_Arg\_\<Argument Number\>\_Buffer\_\<Unique Memory Object Number\>.bin", which matches the filename for dumped buffers.
597
+
598
+
##### `InjectImages` (bool)
599
+
600
+
If set to a nonzero value, the Intercept Layer for OpenCL Applications will look to inject potentially modified image contents before calls to clEnqueueNDRangeKernel(). Only images that are kernel arguments for the kernel being enqueued may be injected. The filename to inject will have the form "Enqueue\_\<Enqueue Number\>\_Kernel\_\<Kernel Name\>\_Arg\_\<Argument Number\>\_Image\_\<Unique Memory Object Number\>\_\<Width\>x\<Height\>x\<Depth\>\_\<Element Size\>bpp.raw", which matches the filename for dumped images.
# Using the Intercept Layer for OpenCL Applications to Inject Buffers and Images
2
+
3
+
Buffer and Image Injection allows an application to experiment with different kernel inputs.
4
+
A typical use-case is to dump buffers or images while an application is running on a known good device or driver, and then to inject these known good buffers or images at certain points during application execution on a different device or with a different driver that is producing incorrect results.
5
+
This can help to identify differences that are irrelevant and unrelated to the incorrect results from important differences.
6
+
7
+
The process to inject buffers and images is very similar to the process to inject programs, and requires several steps.
8
+
9
+
## Step 1: Dump Programs and Program Options for Injection
10
+
11
+
Run your application with `DumpBuffersBeforeEnqueue` or `DumpImagesBeforeEnqueue` enabled. This dumps buffers and images that are set as kernel arguments to the directory:
Because this can generate a lot of data, you may want to dump buffers and images only for a small region of the application's execution, using controls like `DumpBuffersMinEnqueue`, `DumpImagesMaxEnqueue`, or `DumpBuffersForKernel`.
20
+
21
+
**Note.** If the `AppendPid` option is enabled, dumps will be saved to the `<Process Name>.PID` directory, but the `<Process Name>` directory without the process ID will be used for buffer and image injection.
22
+
23
+
## Step 2: Find the Buffer or Image to Inject
24
+
25
+
Look through the dump directory to find the buffer or image you would like to inject.
26
+
27
+
## Step 3: Copy the Buffer or Image
28
+
29
+
Copy the buffer or image file to inject to the directory:
This is the directory that is searched when looking for buffers or images to inject.
38
+
Note that this is the same directory that is used to inject programs, and is a subdirectory of the top-level dump directory.
39
+
40
+
## Step 4: Modify the Buffer or Image (Optional)
41
+
42
+
For some use-cases you will want to manually modify the buffer or image before injecting.
43
+
For other use-cases, you will inject the dumped buffer or image, unmodified.
44
+
45
+
## Step 5: Set the InjectBuffers or InjectImages Controls and Go!
46
+
47
+
If all goes well you will see a line similar to
48
+
49
+
Injecting buffer file: <file name>
50
+
51
+
or:
52
+
53
+
Injecting image file: <file name>
54
+
55
+
in your log.
56
+
57
+
## Notes:
58
+
59
+
* The process to inject buffers also works for SVM or USM allocations.
60
+
* For buffers, the size of the buffer must be at least as big as the file to inject.
61
+
If the size of the buffer is smaller than the size of the file then injection will fail.
62
+
If the size of the buffer is larger than the size of the file then only the initial contents of the buffer will be modified.
63
+
* For OpenCL images, the size of the image must match the size of the file or injection will fail.
64
+
* Because buffer and image injection modifies the memory object itself and not a copy of the memory object, any usage of the memory object after injection will also be affected.
65
+
66
+
---
67
+
68
+
\* Other names and brands may be claimed as the property of others.
CLI_CONTROL( std::string, DefaultOptions, "-cc1 -x cl -cl-std=CL1.2 -D__OPENCL_C_VERSION__=120 -D__OPENCL_VERSION__=120 -emit-spirv -triple=spir", "This is the list of options that is implicitly passed to CLANG to build a non-OpenCL 2.0 SPIR-V module. Any application-provided build options will be appended to these build options." )
119
119
CLI_CONTROL( std::string, OpenCL2Options, "-cc1 -x cl -cl-std=CL2.0 -D__OPENCL_C_VERSION__=200 -D__OPENCL_VERSION__=200 -emit-spirv -triple=spir", "This is the list of options that is implicitly passed to CLANG to build an OpenCL 2.0 SPIR-V module. Any application-provided build options will be appended to these build options." )
120
120
121
-
CLI_CONTROL_SEPARATOR( Controls for Dumping Buffers and Images: )
121
+
CLI_CONTROL_SEPARATOR( Controls for Dumping and Injecting Buffers and Images: )
122
122
CLI_CONTROL( bool, DumpBufferHashes, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump hashes of a buffer, SVM, or USM allocation rather than the full contents of the buffer. This can be useful to identify which kernel enqueues generate different results without requiring a large amount of disk space." )
123
123
CLI_CONTROL( bool, DumpImageHashes, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump hashes of an image rather than the full contents of the image. This can be useful to identify which kernel enqueues generate different results without requiring a large amount of disk space." )
124
124
CLI_CONTROL( bool, DumpArgumentsOnSet, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump the argument value on calls to clSetKernelArg(). Arguments are dumped as raw binary data. The filenames will have the form \"SetKernelArg_<Enqueue Number>_Kernel_<Kernel Name>_Arg_<Argument Number>.bin\"." )
@@ -137,6 +137,8 @@ CLI_CONTROL( cl_uint, DumpImagesMinEnqueue, 0, "The
137
137
CLI_CONTROL( cl_uint, DumpImagesMaxEnqueue, UINT_MAX, "The Intercept Layer for OpenCL Applications will only dump image kernel arguments when the enqueue counter is less than this value, inclusive." )
138
138
CLI_CONTROL( cl_uint, DumpArgumentsOnSetMinEnqueue, 0, "The Intercept Layer for OpenCL Applications will only dump argument values when the enqueue counter is greater than this value, inclusive." )
139
139
CLI_CONTROL( cl_uint, DumpArgumentsOnSetMaxEnqueue, UINT_MAX, "The Intercept Layer for OpenCL Applications will only dump kernel arguments when the enqueue counter is less than this value, inclusive." )
140
+
CLI_CONTROL( bool, InjectBuffers, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will look to inject potentially modified buffer, SVM, and USM contents before calls to clEnqueueNDRangeKernel(). Only buffers that are kernel arguments for the kernel being enqueued may be injected. The filename to inject will have the form \"Enqueue_<Enqueue Number>_Kernel_<Kernel Name>_Arg_<Argument Number>_Buffer_<Unique Memory Object Number>.bin\", which matches the filename for dumped buffers." )
141
+
CLI_CONTROL( bool, InjectImages, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will look to inject potentially modified image contents before calls to clEnqueueNDRangeKernel(). Only images that are kernel arguments for the kernel being enqueued may be injected. The filename to inject will have the form \"Enqueue_<Enqueue Number>_Kernel_<Kernel Name>_Arg_<Argument Number>_Image_<Unique Memory Object Number>_<Width>x<Height>x<Depth>_<Element Size>bpp.raw\", which matches the filename for dumped images." )
CLI_CONTROL( bool, AutoPartitionAllDevices, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will automatically partition parent devices and return all parent devices and all sub-devices." )
0 commit comments