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

Continue to make KvikIO a shared library by moving code from hpp to cpp #581

Open
wants to merge 8 commits into
base: branch-25.02
Choose a base branch
from

Conversation

kingcrimsontianyu
Copy link
Contributor

@kingcrimsontianyu kingcrimsontianyu commented Jan 7, 2025

In light of the initiative to make KvikiIO a shared library, this PR further separates the implementation from the interface as thoroughly as possible.

This PR is marked "breaking" because:

  • The function getenv_or initially in the detail namespace has been moved outside to become part of the public API. cuDF uses this function and needs a timely code update.
  • Other classes and functions initially in the detail namespace for internal use only have been relocated to the .cpp files, so downstream applications that happen to use those entities will now see compile errors.

Notes:

  • Functions initially prefixed with the attribute [[nodiscard]] in the header now have them in the declaration (.hpp) only, not in the definition (.cpp).
  • Classes or functions initially in the detail namespace from X.hpp are now moved to the unnamed namespace in the X.cpp files, unless they are used elsewhere (e.g. Y.cpp).

@kingcrimsontianyu kingcrimsontianyu added non-breaking Introduces a non-breaking change c++ Affects the C++ API of KvikIO labels Jan 7, 2025
@kingcrimsontianyu kingcrimsontianyu self-assigned this Jan 7, 2025
Copy link

copy-pr-bot bot commented Jan 7, 2025

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@kingcrimsontianyu kingcrimsontianyu added the improvement Improves an existing functionality label Jan 7, 2025
@kingcrimsontianyu
Copy link
Contributor Author

/ok to test

@kingcrimsontianyu
Copy link
Contributor Author

/ok to test

@kingcrimsontianyu
Copy link
Contributor Author

/ok to test

@kingcrimsontianyu kingcrimsontianyu added breaking Introduces a breaking change and removed non-breaking Introduces a non-breaking change labels Jan 8, 2025
@kingcrimsontianyu
Copy link
Contributor Author

/ok to test

@kingcrimsontianyu kingcrimsontianyu marked this pull request as ready for review January 9, 2025 15:24
@kingcrimsontianyu kingcrimsontianyu requested review from a team as code owners January 9, 2025 15:24
Copy link
Contributor

@KyleFromNVIDIA KyleFromNVIDIA left a comment

Choose a reason for hiding this comment

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

Approved trivial CMake changes

cpp/include/kvikio/cufile/driver.hpp Outdated Show resolved Hide resolved
cpp/include/kvikio/defaults.hpp Show resolved Hide resolved
cpp/include/kvikio/utils.hpp Outdated Show resolved Hide resolved
cpp/src/cufile/config.cpp Outdated Show resolved Hide resolved
cpp/src/cufile/driver.cpp Outdated Show resolved Hide resolved
cpp/src/cufile/driver.cpp Outdated Show resolved Hide resolved
Comment on lines +1 to +17
/*
* Copyright (c) 2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <kvikio/error.hpp>
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this file?

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'd like to have a .cpp file for each .hpp (except cuda/cufile_h_wrapper.hpp). But it's just a matter of style. You make the call please 😄

Copy link
Member

Choose a reason for hiding this comment

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

I think I lean more to no empty .cpp :)

We could implement the body of the error macros in regular detail functions; to make them more readable and also give error.cpp something to do :P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. The catch is that the 3 macros defined in error.hpp have an optional second parameter _exception_type which is a type. So I only managed to improve the readability by moving most of the macro content to template functions. error.cpp still has no wine.

Let me know if the new change is worth keeping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Introduces a breaking change c++ Affects the C++ API of KvikIO improvement Improves an existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants