Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tracing for cl_intel_create_buffer_with_properties #365

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions intercept/src/cli_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,20 @@ typedef struct _cl_queue_family_properties_intel {
#define CL_QUEUE_CAPABILITY_BARRIER_INTEL (1 << 25)
#define CL_QUEUE_CAPABILITY_KERNEL_INTEL (1 << 26)

///////////////////////////////////////////////////////////////////////////////
// cl_intel_create_buffer_with_properties

typedef cl_properties cl_mem_properties_intel;

extern CL_API_ENTRY
cl_mem CL_API_CALL clCreateBufferWithPropertiesINTEL(
cl_context context,
const cl_mem_properties_intel* properties,
cl_mem_flags flags,
size_t size,
void* host_ptr,
cl_int* errcode_ret);

///////////////////////////////////////////////////////////////////////////////
// cl_intel_device_attribute_query
typedef cl_bitfield cl_device_feature_capabilities_intel;
Expand Down Expand Up @@ -1498,9 +1512,7 @@ cl_int CL_API_CALL clGetSupportedVA_APIMediaSurfaceFormatsINTEL(
#define CL_QUEUE_THREAD_LOCAL_EXEC_ENABLE_INTEL (((cl_bitfield)1) << 31)

///////////////////////////////////////////////////////////////////////////////
// cl_intel_unified_shared_memory POC

// These enums are in sync with revision Q of the USM spec.
// cl_intel_unified_shared_memory

// cl_device_info
#define CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL 0x4190
Expand All @@ -1517,7 +1529,8 @@ typedef cl_bitfield cl_device_unified_shared_memory_capabilities_intel;
#define CL_UNIFIED_SHARED_MEMORY_CONCURRENT_ACCESS_INTEL (1 << 2)
#define CL_UNIFIED_SHARED_MEMORY_CONCURRENT_ATOMIC_ACCESS_INTEL (1 << 3)

typedef cl_properties cl_mem_properties_intel;
// Declared previously:
// typedef cl_properties cl_mem_properties_intel;

// cl_mem_properties_intel
#define CL_MEM_ALLOC_FLAGS_INTEL 0x4195
Expand Down
62 changes: 62 additions & 0 deletions intercept/src/dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,68 @@ CL_API_ENTRY cl_mem CL_API_CALL CLIRN(clCreateBufferWithProperties)(
NULL_FUNCTION_POINTER_SET_ERROR_RETURN_NULL(errcode_ret);
}

///////////////////////////////////////////////////////////////////////////////
//
// cl_intel_create_buffer_with_properties
// This function should stay in sync with clCreateBufferWithProperties, above.
CL_API_ENTRY cl_mem CL_API_CALL clCreateBufferWithPropertiesINTEL(
cl_context context,
const cl_mem_properties_intel* properties,
cl_mem_flags flags,
size_t size,
void* host_ptr,
cl_int* errcode_ret )
{
CLIntercept* pIntercept = GetIntercept();

if( pIntercept )
{
const auto& dispatchX = pIntercept->dispatchX(context);
if( dispatchX.clCreateBufferWithPropertiesINTEL )
{
GET_ENQUEUE_COUNTER();

std::string propsStr;
if( pIntercept->config().CallLogging )
{
pIntercept->getMemPropertiesString(
properties,
propsStr );
}
CALL_LOGGING_ENTER( "context = %p, properties = [ %s ], flags = %s (%llX), size = %zu, host_ptr = %p",
context,
propsStr.c_str(),
pIntercept->enumName().name_mem_flags( flags ).c_str(),
flags,
size,
host_ptr );
INITIALIZE_BUFFER_CONTENTS_INIT( flags, size, host_ptr );
CHECK_ERROR_INIT( errcode_ret );
HOST_PERFORMANCE_TIMING_START();

cl_mem retVal = dispatchX.clCreateBufferWithPropertiesINTEL(
context,
properties,
flags,
size,
host_ptr,
errcode_ret );

HOST_PERFORMANCE_TIMING_END();
ADD_BUFFER( retVal );
INITIALIZE_BUFFER_CONTENTS_CLEANUP( flags, host_ptr );
DUMP_BUFFER_AFTER_CREATE( retVal, flags, host_ptr, size );
CHECK_ERROR( errcode_ret[0] );
ADD_OBJECT_ALLOCATION( retVal );
CALL_LOGGING_EXIT( errcode_ret[0], "returned %p", retVal );

return retVal;
}
}

NULL_FUNCTION_POINTER_SET_ERROR_RETURN_NULL(errcode_ret);
}

///////////////////////////////////////////////////////////////////////////////
//
// cl_nv_create_buffer
Expand Down
9 changes: 9 additions & 0 deletions intercept/src/dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,15 @@ struct CLdispatchX
cl_int (CL_API_CALL *clReleaseAcceleratorINTEL) (
cl_accelerator_intel accelerator );

// cl_intel_create_buffer_with_properties
cl_mem (CL_API_CALL *clCreateBufferWithPropertiesINTEL) (
cl_context context,
const cl_mem_properties_intel* properties,
cl_mem_flags flags,
size_t size,
void* host_ptr,
cl_int* errcode_ret);

#if defined(_WIN32)
// cl_intel_dx9_media_sharing
cl_int (CL_API_CALL *clGetDeviceIDsFromDX9INTEL) (
Expand Down
3 changes: 3 additions & 0 deletions intercept/src/intercept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13171,6 +13171,9 @@ void* CLIntercept::getExtensionFunctionAddress(
CHECK_RETURN_EXTENSION_FUNCTION( clRetainAcceleratorINTEL );
CHECK_RETURN_EXTENSION_FUNCTION( clReleaseAcceleratorINTEL );

// cl_intel_create_buffer_with_properties
CHECK_RETURN_EXTENSION_FUNCTION( clCreateBufferWithPropertiesINTEL );

#if defined(_WIN32)
// cl_intel_dx9_media_sharing
CHECK_RETURN_EXTENSION_FUNCTION( clGetDeviceIDsFromDX9INTEL );
Expand Down