diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index 2606b487c07..5c137433dc5 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -659,10 +659,14 @@ defaults. ## NVTX Ranges In order to aid in performance optimization and debugging, all compute intensive libcudf functions -should have a corresponding NVTX range. libcudf has a convenience macro `CUDF_FUNC_RANGE()` that -automatically annotates the lifetime of the enclosing function and uses the function's name as -the name of the NVTX range. For more information about NVTX, see -[here](https://github.com/NVIDIA/NVTX/tree/dev/c). +should have a corresponding NVTX range. Choose between `CUDF_FUNC_RANGE` or `cudf::thread_range` +for declaring NVTX ranges in the current scope: +- Use the `CUDF_FUNC_RANGE()` macro if you want to use the name of the function as the name of the +NVTX range +- Use `cudf::thread_range rng{"custom_name"};` to provide a custom name for the current scope's +NVTX range + +For more information about NVTX, see [here](https://github.com/NVIDIA/NVTX/tree/dev/c). ## Input/Output Style diff --git a/cpp/include/cudf/detail/nvtx/nvtx3.hpp b/cpp/include/cudf/detail/nvtx/nvtx3.hpp index 4b840724034..5d44c565077 100644 --- a/cpp/include/cudf/detail/nvtx/nvtx3.hpp +++ b/cpp/include/cudf/detail/nvtx/nvtx3.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2023, NVIDIA CORPORATION. + * Copyright (c) 2020-2024, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1901,33 +1901,9 @@ inline void mark(event_attributes const& attr) noexcept * * @param[in] D Type containing `name` member used to identify the * `domain` to which the `registered_message` belongs. Else, - * `domain::global` to indicate that the global NVTX domain should be used. + * `domain::global` to indicate that the global NVTX domain should be used. */ #define NVTX3_FUNC_RANGE_IN(D) \ static ::nvtx3::registered_message const nvtx3_func_name__{__func__}; \ static ::nvtx3::event_attributes const nvtx3_func_attr__{nvtx3_func_name__}; \ [[maybe_unused]] ::nvtx3::domain_thread_range const nvtx3_range__{nvtx3_func_attr__}; - -/** - * @brief Convenience macro for generating a range in the global domain from the - * lifetime of a function. - * - * This macro is useful for generating an NVTX range in the global domain from - * the entry point of a function to its exit. It is intended to be the first - * line of the function. - * - * Constructs a static `registered_message` using the name of the immediately - * enclosing function returned by `__func__` and constructs a - * `nvtx3::thread_range` using the registered function name as the range's - * message. - * - * Example: - * ``` - * void foo(...){ - * NVTX3_FUNC_RANGE(); // Range begins on entry to foo() - * // do stuff - * ... - * } // Range ends on return from foo() - * ``` - */ -#define NVTX3_FUNC_RANGE() NVTX3_FUNC_RANGE_IN(::nvtx3::domain::global) diff --git a/cpp/include/cudf/detail/nvtx/ranges.hpp b/cpp/include/cudf/detail/nvtx/ranges.hpp index de5f9901506..6ed30e871fa 100644 --- a/cpp/include/cudf/detail/nvtx/ranges.hpp +++ b/cpp/include/cudf/detail/nvtx/ranges.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2024, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,16 @@ struct libcudf_domain { /** * @brief Alias for an NVTX range in the libcudf domain. + * + * Customizes an NVTX range with the given input. + * + * Example: + * ``` + * void some_function(){ + * cudf::thread_range rng{"custom_name"}; // Customizes range name + * ... + * } + * ``` */ using thread_range = ::nvtx3::domain_thread_range;