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

Use registered strings for NVTX. Add more NVTX annotations. #518

Merged
merged 7 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use registered strings for nvtx. Add more nvtx annotations
  • Loading branch information
kingcrimsontianyu committed Oct 27, 2024
commit 3f3868ad4ff815125182b53b6d7cce11a7e57208
7 changes: 7 additions & 0 deletions cpp/include/kvikio/file_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ class FileHandle {
std::size_t devPtr_offset,
bool sync_default_stream = true)
{
KVIKIO_NVTX_FUNC_RANGE("FileHandle::read()", size);

if (_compat_mode) {
return detail::posix_device_read(
_fd_direct_off, devPtr_base, size, file_offset, devPtr_offset);
Expand Down Expand Up @@ -379,6 +381,8 @@ class FileHandle {
std::size_t devPtr_offset,
bool sync_default_stream = true)
{
KVIKIO_NVTX_FUNC_RANGE("FileHandle::write()", size);

_nbytes = 0; // Invalidate the computed file size

if (_compat_mode) {
Expand Down Expand Up @@ -434,6 +438,8 @@ class FileHandle {
std::size_t gds_threshold = defaults::gds_threshold(),
bool sync_default_stream = true)
{
KVIKIO_NVTX_FUNC_RANGE("FileHandle::pread()", size);

if (is_host_memory(buf)) {
auto op = [this](void* hostPtr_base,
std::size_t size,
Expand Down Expand Up @@ -510,6 +516,7 @@ class FileHandle {
std::size_t gds_threshold = defaults::gds_threshold(),
bool sync_default_stream = true)
{
KVIKIO_NVTX_FUNC_RANGE("FileHandle::pwrite()", size);
if (is_host_memory(buf)) {
auto op = [this](const void* hostPtr_base,
std::size_t size,
Expand Down
19 changes: 12 additions & 7 deletions cpp/include/kvikio/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,20 @@ struct libkvikio_domain {
static constexpr char const* name{"libkvikio"};
};

// Macro to concatenate two tokens x and y
#define CONCAT_HELPER(x, y) x##y
#define CONCAT(x, y) CONCAT_HELPER(x, y)

// Macro overloads of KVIKIO_NVTX_FUNC_RANGE
#define KVIKIO_NVTX_FUNC_RANGE_1() NVTX3_FUNC_RANGE_IN(libkvikio_domain)
#define KVIKIO_NVTX_FUNC_RANGE_2(msg, val) \
nvtx3::scoped_range_in<libkvikio_domain> _kvikio_nvtx_range \
{ \
nvtx3::event_attributes \
{ \
msg, nvtx3::payload { convert_to_64bit(val) } \
} \
#define KVIKIO_NVTX_FUNC_RANGE_2(msg, val) \
static nvtx3::registered_string_in<libkvikio_domain> CONCAT(a_reg_str, __LINE__){msg}; \
nvtx3::scoped_range_in<libkvikio_domain> CONCAT(_kvikio_nvtx_range, __LINE__) \
{ \
nvtx3::event_attributes \
{ \
CONCAT(a_reg_str, __LINE__), nvtx3::payload { convert_to_64bit(val) } \
} \
}
#define GET_KVIKIO_NVTX_FUNC_RANGE_MACRO(_1, _2, NAME, ...) NAME
#endif
Expand Down
Loading