Skip to content

Commit

Permalink
ifdef guard KVIKIO_NVTX_FUNC_RANGE instead
Browse files Browse the repository at this point in the history
  • Loading branch information
madsbk committed Oct 3, 2024
1 parent 3f9a8a1 commit 168dd0c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cpp/include/kvikio/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ inline bool is_future_done(const T& future)
return future.wait_for(std::chrono::seconds(0)) != std::future_status::timeout;
}

#ifdef KVIKIO_CUDA_FOUND
/**
* @brief Tag type for libkvikio's NVTX domain.
*/
Expand All @@ -302,7 +303,6 @@ struct libkvikio_domain {

// Macro overloads of KVIKIO_NVTX_FUNC_RANGE
#define KVIKIO_NVTX_FUNC_RANGE_1() NVTX3_FUNC_RANGE_IN(libkvikio_domain)
#ifdef KVIKIO_CUDA_FOUND
#define KVIKIO_NVTX_FUNC_RANGE_2(msg, val) \
nvtx3::scoped_range_in<libkvikio_domain> _kvikio_nvtx_range \
{ \
Expand All @@ -311,12 +311,8 @@ struct libkvikio_domain {
msg, nvtx3::payload { convert_to_64bit(val) } \
} \
}
#else
#define KVIKIO_NVTX_FUNC_RANGE_2(msg, val) \
do { \
} while (0)
#endif
#define GET_KVIKIO_NVTX_FUNC_RANGE_MACRO(_1, _2, NAME, ...) NAME
#endif

/**
* @brief Convenience macro for generating an NVTX range in the `libkvikio` domain
Expand All @@ -337,9 +333,15 @@ struct libkvikio_domain {
* }
* ```
*/
#ifdef KVIKIO_CUDA_FOUND
#define KVIKIO_NVTX_FUNC_RANGE(...) \
GET_KVIKIO_NVTX_FUNC_RANGE_MACRO( \
__VA_ARGS__, KVIKIO_NVTX_FUNC_RANGE_2, KVIKIO_NVTX_FUNC_RANGE_1) \
(__VA_ARGS__)
#else
#define KVIKIO_NVTX_FUNC_RANGE(...) \
do { \
} while (0)
#endif

} // namespace kvikio

0 comments on commit 168dd0c

Please sign in to comment.