-
Notifications
You must be signed in to change notification settings - Fork 82
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
In API Trace Syntactic Consistency #28
Comments
An alternate idea is to favor more C'ish syntax and list raw values with optional decoding as
For example
The disadvantage to this is that it relies on the programmer knowing the argument name ordering or they have to take the step to look it up (not a hard step). |
Yeah, although we try to maintain consistent output for API tracing / call logging, it's all very ad-hoc right now. The "real" way to fix this IMHO is to create a machine readable grammar file for OpenCL APIs and then to automatically generate the API tracing functionality, which would guarantee consistent output, but we aren't quite there yet. In the meantime, a low hanging fruit change would seem to be to terminate the API trace with some other delimiter (say, ";") before appending any other call logging information, such as the enqueue counter. This is part of your proposed (formal) syntax:
This is a trivial change. Should we start there, and then investigate a way to guarantee consistent output as part of a longer-term improvement? |
Yeah. A generative process would be great and extensible to other API intercept projects. But since our API set is just OpenCL we could use an embedded-DSL approach as well. That is we could describe the API declaratively via regular C++ constructs within the intercept method and implement the behavior once for consistency.
I haven't looked to how this fits into the project practice. I just point out that the approach can be embedded instead of having to have some tool generate everything. The OCL header file lacks some domain knowledge (e.g. what's an input pointer and what's an output pointer). So we'll need some annotation anyways. |
Here's a little more concrete idea on how to embed this. Here's an example API intercept with the adjustments.
Note, I piloted the above intercept implementation for several other calls (e.g. This all leverages a single templated method
It uses variadic templates to process each parameter. The The API call argument is a SINGLE LINE OUTPUT:
Example output would be
We could omit the parameter names for brevity if preferable
This "single line" output has two implications.
Any information the E.g. for
The second line presumably comes from the lambda body.
|
Just to follow up on this (NOTE: we decided against this "functional" approach for the moment, but I wanted to record the gist of the idea). My experiments demonstrated a way to remove a lot of boilerplate code in the intercept calls. As a full example we could have
An implementation of the macro
In the end we decided against the above judging it to be too invasive. This specific enhancement is trying to formalize the call log syntax, not remove boilerplate code or simplify the implementation in any way. In addition, we would have to be very careful we wouldn't break the current semantics. Maybe we can revisit this later. |
A more conservative approach is to retain the type driven features of the above and simply edit calls to
|
Observed Behavior
For example clGetPlatformIDs omits arguments and uses
,
separator instead of:
like all other API callsProbably the
,
belongs to theEnqueueCounter
suffix,clGetPlatformIDs
omits its arguments.Desired Behavior
Perhaps we could use a syntax like the following.
This would give us.
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 likenew_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.The text was updated successfully, but these errors were encountered: