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

Move serialization functions to include #875

Merged
merged 3 commits into from
Oct 24, 2023

Conversation

PatKamin
Copy link
Contributor

Related to issue #828 .

C API will be introduced in another PR.

namespace ${x}_params {
namespace ${x}_print {
## API functions declarations #################################################
// RFC: Should is_handle stay in the common dir?
Copy link
Contributor

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to details

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed

Copy link
Member

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)

Copy link
Contributor

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.

Copy link
Member

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())

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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

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) {
Copy link
Contributor

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).

Suggested change
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) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@PatKamin PatKamin force-pushed the expose-serialization branch 6 times, most recently from b2a32a3 to cbc9f53 Compare October 3, 2023 12:02
@PatKamin PatKamin requested a review from pbalcer October 4, 2023 10:45
@@ -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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

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);
Copy link
Member

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?

@PatKamin
Copy link
Contributor Author

Hm, do we actually need UR_DLLEXPORT? All those functions are defined in the header, right?

Replaced with UR_APIEXPORT for functions visibility on Windows. Also removed these macros from functions of the ::details namespace.

@PatKamin
Copy link
Contributor Author

Just occurred to me that these APIs won't have doxygen docs. We should eventually address this.

Added generation of docs for all operators and a function from ::extras.

@PatKamin
Copy link
Contributor Author

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())

Rearanged namespaces in the header.

Copy link
Contributor

@kbenzie kbenzie left a 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 👍

@pbalcer pbalcer merged commit a2d23dc into oneapi-src:main Oct 24, 2023
26 checks passed
@PatKamin PatKamin deleted the expose-serialization branch June 26, 2024 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants