Skip to content

Commit 1b2b344

Browse files
authored
enable DumpBuffers to work with USM allocations (#201)
1 parent 81c0e46 commit 1b2b344

File tree

5 files changed

+178
-46
lines changed

5 files changed

+178
-46
lines changed

docs/controls.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -481,43 +481,43 @@ If set, the Intercept Layer for OpenCL Applications will dump the contents of a
481481

482482
##### `DumpBuffersBeforeEnqueue` (bool)
483483

484-
If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump buffers before calls to clEnqueueNDRangeKernel(). Only buffers that are kernel arguments for the kernel being enqueued are dumped. Buffers are dumped as raw binary data to a "memDumpPreEnqueue" subdirectory of the dump directory. The filenames will have the form "Enqueue\_\<Enqueue Number\>\_Kernel\_\<Kernel Name\>\_Arg\_\<Argument Number\>\_Buffer\_\<Unique Memory Object Number\>.bin".
484+
If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump buffer, SVM, and USM kernel arguments before calls to clEnqueueNDRangeKernel(). Only buffers that are kernel arguments for the kernel being enqueued are dumped. Buffers are dumped as raw binary data to a "memDumpPreEnqueue" subdirectory of the dump directory. The filenames will have the form "Enqueue\_\<Enqueue Number\>\_Kernel\_\<Kernel Name\>\_Arg\_\<Argument Number\>\_Buffer\_\<Unique Memory Object Number\>.bin".
485485

486486
##### `DumpBuffersAfterEnqueue` (bool)
487487

488-
If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump buffers after calls to clEnqueueNDRangeKernel(). Only buffers that are kernel arguments for the kernel being enqueued are dumped. Buffers are dumped as raw binary data to a "memDumpPostEnqueue" subdirectory of the dump directory. The filenames will have the form "Enqueue\_\<Enqueue Number\>\_Kernel\_\<Kernel Name\>\_Arg\_\<Argument Number\>\_Buffer\_\<Unique Memory Object Number\>.bin". Note that this is the same naming convention as with DumpBuffersBeforeEnqueue, so the changes resulting from an enqueue can be determined by diff'ing the preEnqueue folder with the postEnqueue folder.
488+
If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump buffer, SVM, and USM kernel arguments after calls to clEnqueueNDRangeKernel(). Only buffers that are kernel arguments for the kernel being enqueued are dumped. Buffers are dumped as raw binary data to a "memDumpPostEnqueue" subdirectory of the dump directory. The filenames will have the form "Enqueue\_\<Enqueue Number\>\_Kernel\_\<Kernel Name\>\_Arg\_\<Argument Number\>\_Buffer\_\<Unique Memory Object Number\>.bin". Note that this is the same naming convention as with DumpBuffersBeforeEnqueue, so the changes resulting from an enqueue can be determined by diff'ing the preEnqueue folder with the postEnqueue folder.
489489

490490
##### `DumpBuffersForKernel` (string)
491491

492-
If set, the Intercept Layer for OpenCL Applications will only dump buffers when the specified kernel is enqueued. This control is ignored unless DumpBuffersBeforeEnqueue or DumpBuffersAfterEnqueue are enabled.
492+
If set, the Intercept Layer for OpenCL Applications will only dump buffer, SVM, and USM kernel arguments when the specified kernel is enqueued. This control is ignored unless DumpBuffersBeforeEnqueue or DumpBuffersAfterEnqueue are enabled.
493493

494494
##### `DumpImagesBeforeEnqueue` (bool)
495495

496-
If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump images before calls to clEnqueueNDRangeKernel(). Only images that are kernel arguments for the kernel being enqueued are dumped. Images are dumped as raw binary data to a "memDumpPreEnqueue" subdirectory of the dump directory. The filenames 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".
496+
If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump image kernel arguments before calls to clEnqueueNDRangeKernel(). Only images that are kernel arguments for the kernel being enqueued are dumped. Images are dumped as raw binary data to a "memDumpPreEnqueue" subdirectory of the dump directory. The filenames 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".
497497

498498
##### `DumpImagesAfterEnqueue` (bool)
499499

500-
If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump images after calls to clEnqueueNDRangeKernel(). Only images that are kernel arguments for the kernel being enqueued are dumped. Images are dumped as raw binary data to a "memDumpPostEnqueue" subdirectory of the dump directory. The filenames 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". Note that this is the same naming convention as with DumpImagesBeforeEnqueue, so the changes resulting from an enqueue can be determined by diff'ing the preEnqueue folder with the postEnqueue folder.
500+
If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump image kernel arguments after calls to clEnqueueNDRangeKernel(). Only images that are kernel arguments for the kernel being enqueued are dumped. Images are dumped as raw binary data to a "memDumpPostEnqueue" subdirectory of the dump directory. The filenames 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". Note that this is the same naming convention as with DumpImagesBeforeEnqueue, so the changes resulting from an enqueue can be determined by diff'ing the preEnqueue folder with the postEnqueue folder.
501501

502502
##### `DumpImagesForKernel` (string)
503503

504-
If set, the Intercept Layer for OpenCL Applications will only dump image when the specified kernel is enqueued. This control is ignored unless DumpImagesBeforeEnqueue or DumpImagesAfterEnqueue are enabled.
504+
If set, the Intercept Layer for OpenCL Applications will only dump image kernel arguments when the specified kernel is enqueued. This control is ignored unless DumpImagesBeforeEnqueue or DumpImagesAfterEnqueue are enabled.
505505

506506
##### `DumpBuffersMinEnqueue` (cl_uint)
507507

508-
The Intercept Layer for OpenCL Applications will only dump buffers when the enqueue counter is greater than this value, inclusive.
508+
The Intercept Layer for OpenCL Applications will only dump buffer, SVM, and USM kernel arguments when the enqueue counter is greater than this value, inclusive.
509509

510510
##### `DumpBuffersMaxEnqueue` (cl_uint)
511511

512-
The Intercept Layer for OpenCL Applications will only dump buffers when the enqueue counter is less than this value, inclusive.
512+
The Intercept Layer for OpenCL Applications will only dump buffer, SVM, and USM kernel arguments when the enqueue counter is less than this value, inclusive.
513513

514514
##### `DumpImagesMinEnqueue` (cl_uint)
515515

516-
The Intercept Layer for OpenCL Applications will only dump images when the enqueue counter is greater than this value, inclusive.
516+
The Intercept Layer for OpenCL Applications will only dump image kernel arguments when the enqueue counter is greater than this value, inclusive.
517517

518518
##### `DumpImagesMaxEnqueue` (cl_uint)
519519

520-
The Intercept Layer for OpenCL Applications will only dump images when the enqueue counter is less than this value, inclusive.
520+
The Intercept Layer for OpenCL Applications will only dump image kernel arguments when the enqueue counter is less than this value, inclusive.
521521

522522
### Device Partitioning Controls
523523

intercept/src/controls.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,16 @@ CLI_CONTROL( bool, DumpArgumentsOnSet, false, "If s
126126
CLI_CONTROL( bool, DumpBuffersAfterCreate, false, "If set, the Intercept Layer for OpenCL Applications will dump buffers to a file after creation. This control still honors the enqueue counter limits, even though no enqueues are involved during buffer creation. Currently only works for cl_mem buffers created from host pointers." )
127127
CLI_CONTROL( bool, DumpBuffersAfterMap, false, "If set, the Intercept Layer for OpenCL Applications will dump the contents of a buffer to a file after the buffer is mapped. Only valid if the buffer is NOT mapped with CL_MAP_WRITE_INVALIDATE_REGION. If the buffer was mapped non-blocking, this may insert a clFinish() into the command queue, which may have functional or performance implications." )
128128
CLI_CONTROL( bool, DumpBuffersBeforeUnmap, false, "If set, the Intercept Layer for OpenCL Applications will dump the contents of a buffer to a file immediately before the buffer is unmapped. This is done by inserting a blocking clEnqueueMapBuffer() (and matching clEnqueueUnmapMemObject()) into the command queue, which may have functional or performance implications." )
129-
CLI_CONTROL( bool, DumpBuffersBeforeEnqueue, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump buffers before calls to clEnqueueNDRangeKernel(). Only buffers that are kernel arguments for the kernel being enqueued are dumped. Buffers are dumped as raw binary data to a \"memDumpPreEnqueue\" subdirectory of the dump directory. The filenames will have the form \"Enqueue_<Enqueue Number>_Kernel_<Kernel Name>_Arg_<Argument Number>_Buffer_<Unique Memory Object Number>.bin\"." )
130-
CLI_CONTROL( bool, DumpBuffersAfterEnqueue, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump buffers after calls to clEnqueueNDRangeKernel(). Only buffers that are kernel arguments for the kernel being enqueued are dumped. Buffers are dumped as raw binary data to a \"memDumpPostEnqueue\" subdirectory of the dump directory. The filenames will have the form \"Enqueue_<Enqueue Number>_Kernel_<Kernel Name>_Arg_<Argument Number>_Buffer_<Unique Memory Object Number>.bin\". Note that this is the same naming convention as with DumpBuffersBeforeEnqueue, so the changes resulting from an enqueue can be determined by diff'ing the preEnqueue folder with the postEnqueue folder." )
131-
CLI_CONTROL( std::string, DumpBuffersForKernel, "", "If set, the Intercept Layer for OpenCL Applications will only dump buffers when the specified kernel is enqueued. This control is ignored unless DumpBuffersBeforeEnqueue or DumpBuffersAfterEnqueue are enabled." )
132-
CLI_CONTROL( bool, DumpImagesBeforeEnqueue, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump images before calls to clEnqueueNDRangeKernel(). Only images that are kernel arguments for the kernel being enqueued are dumped. Images are dumped as raw binary data to a \"memDumpPreEnqueue\" subdirectory of the dump directory. The filenames 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\"." )
133-
CLI_CONTROL( bool, DumpImagesAfterEnqueue, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump images after calls to clEnqueueNDRangeKernel(). Only images that are kernel arguments for the kernel being enqueued are dumped. Images are dumped as raw binary data to a \"memDumpPostEnqueue\" subdirectory of the dump directory. The filenames 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\". Note that this is the same naming convention as with DumpImagesBeforeEnqueue, so the changes resulting from an enqueue can be determined by diff'ing the preEnqueue folder with the postEnqueue folder." )
134-
CLI_CONTROL( std::string, DumpImagesForKernel, "", "If set, the Intercept Layer for OpenCL Applications will only dump image when the specified kernel is enqueued. This control is ignored unless DumpImagesBeforeEnqueue or DumpImagesAfterEnqueue are enabled." )
135-
CLI_CONTROL( cl_uint, DumpBuffersMinEnqueue, 0, "The Intercept Layer for OpenCL Applications will only dump buffers when the enqueue counter is greater than this value, inclusive." )
136-
CLI_CONTROL( cl_uint, DumpBuffersMaxEnqueue, UINT_MAX, "The Intercept Layer for OpenCL Applications will only dump buffers when the enqueue counter is less than this value, inclusive." )
137-
CLI_CONTROL( cl_uint, DumpImagesMinEnqueue, 0, "The Intercept Layer for OpenCL Applications will only dump images when the enqueue counter is greater than this value, inclusive." )
138-
CLI_CONTROL( cl_uint, DumpImagesMaxEnqueue, UINT_MAX, "The Intercept Layer for OpenCL Applications will only dump images when the enqueue counter is less than this value, inclusive." )
129+
CLI_CONTROL( bool, DumpBuffersBeforeEnqueue, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump buffer, SVM, and USM kernel arguments before calls to clEnqueueNDRangeKernel(). Only buffers that are kernel arguments for the kernel being enqueued are dumped. Buffers are dumped as raw binary data to a \"memDumpPreEnqueue\" subdirectory of the dump directory. The filenames will have the form \"Enqueue_<Enqueue Number>_Kernel_<Kernel Name>_Arg_<Argument Number>_Buffer_<Unique Memory Object Number>.bin\"." )
130+
CLI_CONTROL( bool, DumpBuffersAfterEnqueue, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump buffer, SVM, and USM kernel arguments after calls to clEnqueueNDRangeKernel(). Only buffers that are kernel arguments for the kernel being enqueued are dumped. Buffers are dumped as raw binary data to a \"memDumpPostEnqueue\" subdirectory of the dump directory. The filenames will have the form \"Enqueue_<Enqueue Number>_Kernel_<Kernel Name>_Arg_<Argument Number>_Buffer_<Unique Memory Object Number>.bin\". Note that this is the same naming convention as with DumpBuffersBeforeEnqueue, so the changes resulting from an enqueue can be determined by diff'ing the preEnqueue folder with the postEnqueue folder." )
131+
CLI_CONTROL( std::string, DumpBuffersForKernel, "", "If set, the Intercept Layer for OpenCL Applications will only dump buffer, SVM, and USM kernel arguments when the specified kernel is enqueued. This control is ignored unless DumpBuffersBeforeEnqueue or DumpBuffersAfterEnqueue are enabled." )
132+
CLI_CONTROL( bool, DumpImagesBeforeEnqueue, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump image kernel arguments before calls to clEnqueueNDRangeKernel(). Only images that are kernel arguments for the kernel being enqueued are dumped. Images are dumped as raw binary data to a \"memDumpPreEnqueue\" subdirectory of the dump directory. The filenames 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\"." )
133+
CLI_CONTROL( bool, DumpImagesAfterEnqueue, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump image kernel arguments after calls to clEnqueueNDRangeKernel(). Only images that are kernel arguments for the kernel being enqueued are dumped. Images are dumped as raw binary data to a \"memDumpPostEnqueue\" subdirectory of the dump directory. The filenames 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\". Note that this is the same naming convention as with DumpImagesBeforeEnqueue, so the changes resulting from an enqueue can be determined by diff'ing the preEnqueue folder with the postEnqueue folder." )
134+
CLI_CONTROL( std::string, DumpImagesForKernel, "", "If set, the Intercept Layer for OpenCL Applications will only dump image kernel arguments when the specified kernel is enqueued. This control is ignored unless DumpImagesBeforeEnqueue or DumpImagesAfterEnqueue are enabled." )
135+
CLI_CONTROL( cl_uint, DumpBuffersMinEnqueue, 0, "The Intercept Layer for OpenCL Applications will only dump buffer, SVM, and USM kernel arguments when the enqueue counter is greater than this value, inclusive." )
136+
CLI_CONTROL( cl_uint, DumpBuffersMaxEnqueue, UINT_MAX, "The Intercept Layer for OpenCL Applications will only dump buffer, SVM, and USM kernel arguments when the enqueue counter is less than this value, inclusive." )
137+
CLI_CONTROL( cl_uint, DumpImagesMinEnqueue, 0, "The Intercept Layer for OpenCL Applications will only dump image kernel arguments when the enqueue counter is greater than this value, inclusive." )
138+
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." )
139139

140140
CLI_CONTROL_SEPARATOR( Device Partitioning Controls: )
141141
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." )

intercept/src/dispatch.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8457,6 +8457,7 @@ CL_API_ENTRY void* CL_API_CALL clHostMemAllocINTEL(
84578457
}
84588458

84598459
CPU_PERFORMANCE_TIMING_END();
8460+
ADD_USM_ALLOCATION( retVal, size );
84608461
USM_ALLOC_PROPERTIES_CLEANUP( newProperties );
84618462
CHECK_ERROR( errcode_ret[0] );
84628463
CALL_LOGGING_EXIT( errcode_ret[0], "returned %p", retVal );
@@ -8532,6 +8533,7 @@ CL_API_ENTRY void* CL_API_CALL clDeviceMemAllocINTEL(
85328533
}
85338534

85348535
CPU_PERFORMANCE_TIMING_END();
8536+
ADD_USM_ALLOCATION( retVal, size );
85358537
USM_ALLOC_PROPERTIES_CLEANUP( newProperties );
85368538
CHECK_ERROR( errcode_ret[0] );
85378539
CALL_LOGGING_EXIT( errcode_ret[0], "returned %p", retVal );
@@ -8607,6 +8609,7 @@ CL_API_ENTRY void* CL_API_CALL clSharedMemAllocINTEL(
86078609
}
86088610

86098611
CPU_PERFORMANCE_TIMING_END();
8612+
ADD_USM_ALLOCATION( retVal, size );
86108613
USM_ALLOC_PROPERTIES_CLEANUP( newProperties );
86118614
CHECK_ERROR( errcode_ret[0] );
86128615
CALL_LOGGING_EXIT( errcode_ret[0], "returned %p", retVal );
@@ -8643,6 +8646,7 @@ CL_API_ENTRY cl_int CL_API_CALL clMemFreeINTEL(
86438646
ptr );
86448647

86458648
CPU_PERFORMANCE_TIMING_END();
8649+
REMOVE_USM_ALLOCATION( ptr );
86468650
CHECK_ERROR( retVal );
86478651
CALL_LOGGING_EXIT( retVal );
86488652

@@ -8679,6 +8683,7 @@ clMemBlockingFreeINTEL(
86798683
ptr );
86808684

86818685
CPU_PERFORMANCE_TIMING_END();
8686+
REMOVE_USM_ALLOCATION( ptr );
86828687
CHECK_ERROR( retVal );
86838688
CALL_LOGGING_EXIT( retVal );
86848689

@@ -8757,6 +8762,7 @@ CL_API_ENTRY cl_int CL_API_CALL clSetKernelArgMemPointerINTEL(
87578762
arg_index,
87588763
arg_value );
87598764
CHECK_KERNEL_ARG_USM_POINTER( kernel, arg_value );
8765+
SET_KERNEL_ARG_USM_POINTER( kernel, arg_index, arg_value );
87608766
CPU_PERFORMANCE_TIMING_START();
87618767

87628768
cl_int retVal = dispatchX.clSetKernelArgMemPointerINTEL(

0 commit comments

Comments
 (0)