Description
Observed Behavior
For example clGetPlatformIDs omits arguments and uses ,
separator instead of :
like all other API calls
>>>> clGetPlatformIDs, EnqueueCounter: 1
^ uses comma
Host Time for call 1: clGetPlatformIDs = 1114623933
<<<< clGetPlatformIDs
....
>>>> clGetDeviceIDs: platform = [ Intel(R) OpenCL ], device_type = CL_DEVICE_TYPE_GPU (4), EnqueueCounter: 1
Host Time for call 3: clGetDeviceIDs = 292
<<<< clGetDeviceIDs
Probably the ,
belongs to the EnqueueCounter
suffix,
- Another way to view this is
clGetPlatformIDs
omits its arguments. - Perhaps suggest we should change the API trace to a more consistent syntax so that it's more consumable by tools? See below for a suggestion.
Desired Behavior
Perhaps we could use a syntax like the following.
<API-CALL> ::= <API-CALLING> <API-BODY> <API-CALL-RETURN>
<API-BODY> ::= anything but '<<<<'
<API-CALLING> ::= '>>>>' <THREAD-ID-ETC>? <API_NAME> ':' <ARG-LIST> <EXT-INFO>
<API-CALL-RETURN> ::= '<<<<' <THREAD-ID-ETC>? <API-NAME> ' returned '<RETURN-VALUE> (':' <CALL-RETURN-VALUES>)?
<ARG-LIST> ::= <ARG-NAME> ' = ' <ARG-VALUE> (',' <ARG-NAME> ' = ' <ARG-VALUE>)|
<CALL-RETURN-VALUES> :: ':' <ARG-LIST> // values returned via pointer or return value
<EXT-INFO> ::=<empty-string> | ';' <OTHER-STUFF-LIKE-ENQ-COUNTER>
<ARG-VALUE> ::= <ARG_SCALAR> | <ARG_PTR>
<ARG_SCALAR> = <HEX-VAL> | '{' <HEX-VAL> (',' <HEX-VAL>)* '}' // structs for things like float4's
<ARG_PTR> = '[' <HEX-VAL> ']' // means the value returned is indirect
This would give us.
>>>> clGetPlatformIds: num_entries = 10, platforms = [0x12345...], num_platforms = [0x22345...]; EnqueueCounter:1
....
<<<< clGetPlatformIds returned CL_SUCCESS: platforms[] = {...platform_id's...}, *num_platforms = 2
// note the return by ptr values are decoded to a minimal extent using API domain specific knowledge (e.g. num_platforms is a single int)
Note, I am not tied to the exact syntax, but am just proposing something consistent for tool consumability. Probably there are a lot of improvements we could apply to the above.
Regarding API's that return a pointer (e.g. clCreateProgram
) and return the status via pointer, we might consider untangling them logically to always present the cl_int (status) as the "returned" value and the new object allocated (e.g. program) as a pseudo argument like new_program
. Or we just leave it alone and decode the status as a regular "return by pointer" argument (but decode it). I see benefits either way.
Steps to Reproduce
Enable the API trace (with enqueue counters) and observe clintercept_report.txt
calls.