-
Notifications
You must be signed in to change notification settings - Fork 123
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
Move serialization functions to include #875
Conversation
scripts/templates/print.hpp.mako
Outdated
namespace ${x}_params { | ||
namespace ${x}_print { | ||
## API functions declarations ################################################# | ||
// RFC: Should is_handle stay in the common dir? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as long as it's in a namespace, I don't see why not. Maybe we can move it to details
(see below).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to details
scripts/templates/print.hpp.mako
Outdated
template <typename T> inline void serializePtr(std::ostream &os, const T *ptr); | ||
template <typename T> inline void serializeFlag(std::ostream &os, uint32_t flag); | ||
template <typename T> inline void serializeTagged(std::ostream &os, const void *ptr, T value, size_t size); | ||
template <typename T> UR_DLLEXPORT inline ${x}_result_t UR_APICALL ${x}PtrPrint(std::ostream &os, const T *ptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a print
header, my preference would be to name all these urPrintSomething
. Makes it easier to find all print functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to call these functions this way, too. I just adhered to the function naming convention of UR API (https://github.com/oneapi-src/unified-runtime/blob/main/scripts/core/CONTRIB.rst#naming-convention). Can I ignore this convention in the case of a printing API then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we now have something like ur_print::urFunctionParamsPrint
, which seems a bit excessive. Why not just ur::printFunctionParams()
(i.e. rename namespace to ur
, remove ur
prefix from the function name and possibly start the function name with print
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ur::print::functionParams()
or maybe ur::extras::printFunctionParams()
?
I think I'd prefer this whole thing be in its own namespace. Hypothetically, we might want to add some more C++ functionality or bindings, and imho it should be possible to use that functionality without having to import all these operator overloads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, you don't have to include ur_print.hpp header if you don't want to. But I like the ur::extras::printFunctionParams()
or perhaps (ur::info::printFunctionParams()
)
scripts/templates/print.hpp.mako
Outdated
template <typename T> inline void serializePtr(std::ostream &os, const T *ptr) { | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// @brief Print pointer value | ||
template <typename T> inline ${x}_result_t ${x}PtrPrint(std::ostream &os, const T *ptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be part of the public API. Maybe we should have a ur_print::details
namespace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to a nested namespace
scripts/templates/print.hpp.mako
Outdated
inline int serializeFunctionParams(std::ostream &os, uint32_t function, const void *params) { | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// @brief Print function parameters | ||
UR_DLLEXPORT inline ${x}_result_t UR_APICALL ${x}FunctionParamsPrint(std::ostream &os, uint32_t function, const void *params) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is useful outside of urtrace (but I guess someone might want to implement a similar functionality themselves).
UR_DLLEXPORT inline ${x}_result_t UR_APICALL ${x}FunctionParamsPrint(std::ostream &os, uint32_t function, const void *params) { | |
UR_DLLEXPORT inline ${x}_result_t UR_APICALL ${x}FunctionParamsPrint(std::ostream &os, enum ur_function_t function, const void *params) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
b2a32a3
to
cbc9f53
Compare
@@ -848,7 +848,8 @@ RECURSIVE = YES | |||
# Note that relative paths are relative to the directory from which doxygen is | |||
# run. | |||
|
|||
EXCLUDE = README.md | |||
EXCLUDE = README.md \ | |||
../include/ur_print.hpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just occurred to me that these APIs won't have doxygen docs. We should eventually address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added generation of docs for all operators and a function from ::extras.
scripts/templates/print.hpp.mako
Outdated
template <typename T> inline void serializePtr(std::ostream &os, const T *ptr); | ||
template <typename T> inline void serializeFlag(std::ostream &os, uint32_t flag); | ||
template <typename T> inline void serializeTagged(std::ostream &os, const void *ptr, T value, size_t size); | ||
template <typename T> UR_DLLEXPORT inline ${x}_result_t UR_APICALL ${x}PrintPtr(std::ostream &os, const T *ptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, do we actually need UR_DLLEXPORT? All those functions are defined in the header, right?
Replaced with |
cbc9f53
to
41bc180
Compare
Added generation of docs for all operators and a function from ::extras. |
Rearanged namespaces in the header. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed the review request last week. These changes are looking good 👍
df6d992
to
1f2cd55
Compare
1f2cd55
to
5f0e6d4
Compare
Related to issue #828 .
C API will be introduced in another PR.