From 0b163ce473899734fd1a6135b535c1da558fe36e Mon Sep 17 00:00:00 2001 From: David Wendt Date: Mon, 18 Mar 2024 13:13:12 -0400 Subject: [PATCH 1/7] Add debug tips section to libcudf developer guide --- CONTRIBUTING.md | 2 +- cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md | 15 +++++++++++++++ cpp/doxygen/developer_guide/TESTING.md | 15 ++++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e7f7a20e307..dce92d7e613 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -217,7 +217,7 @@ cuda-gdb -ex r --args python .py ``` ```bash -cuda-memcheck python .py +compute-sanitizer --tool memcheck python .py ``` ### Device debug symbols diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index 8188c466312..2e3e103633c 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -1384,3 +1384,18 @@ cuIO is a component of libcudf that provides GPU-accelerated reading and writing formats commonly used in data analytics, including CSV, Parquet, ORC, Avro, and JSON_Lines. // TODO: add more detail and move to a separate file. + +# Debugging Tips + +Here are some tools that can help with debugging libcudf (besides printf of course): +1. cuda-gdb + Follow the instructions in the [contributor guide](../../CONTRIBUTING.md#debugging-cudf) to build + and run libcudf with debug symbols. +2. compute-sanitizer + The sanitizer tool can be used to locate many CUDA reported errors by providing a call stack + close to where the error occurs even with a non-debug build. The sanitizer includes various + tools including memcheck, racecheck, and initcheck. The racecheck and initcheck have been + known to produce false positives. +3. cudf::test::print() + The `print()` utility can be called within a gtest to output the data in a `cudf::column_view`. + More information is available in the [Testing Guide](TESTING.md#printing-and-accessing-column-data) diff --git a/cpp/doxygen/developer_guide/TESTING.md b/cpp/doxygen/developer_guide/TESTING.md index a4ffe0f575b..854ecadaec5 100644 --- a/cpp/doxygen/developer_guide/TESTING.md +++ b/cpp/doxygen/developer_guide/TESTING.md @@ -455,10 +455,19 @@ Column comparison functions in the `cudf::test::detail` namespace should **NOT** ### Printing and accessing column data -`include/cudf_test/column_utilities.hpp` defines various functions and overloads for printing +The `` defines various functions and overloads for printing columns (`print`), converting column data to string (`to_string`, `to_strings`), and copying data to -the host (`to_host`). - +the host (`to_host`). For example, to print a `cudf::column_view` contents or `column_wrapper` instance +to the console use the `cudf::test::print()`: +``` + cudf::test::fixed_width_column_wrapper input({1,2,3,4}); + auto splits = cudf::split(input,{2}); + cudf::test::print(input); + cudf::test::print(splits.begin()); +``` +Fixed-width and strings columns output as comma-separated entries including null rows. +Nested columns are also supported and output includes the offsets and data children as well as +the null mask bits. ## Validating Stream Usage From e3e393adf4e963cee2bfd9183847756f40569339 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Tue, 19 Mar 2024 12:32:15 -0400 Subject: [PATCH 2/7] add gcc ASAN --- cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index 2e3e103633c..3b4c43be7ef 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -1388,14 +1388,20 @@ formats commonly used in data analytics, including CSV, Parquet, ORC, Avro, and # Debugging Tips Here are some tools that can help with debugging libcudf (besides printf of course): -1. cuda-gdb +1. `cuda-gdb`\ Follow the instructions in the [contributor guide](../../CONTRIBUTING.md#debugging-cudf) to build and run libcudf with debug symbols. -2. compute-sanitizer +2. `compute-sanitizer`\ The sanitizer tool can be used to locate many CUDA reported errors by providing a call stack close to where the error occurs even with a non-debug build. The sanitizer includes various tools including memcheck, racecheck, and initcheck. The racecheck and initcheck have been known to produce false positives. -3. cudf::test::print() +3. `cudf::test::print()`\ The `print()` utility can be called within a gtest to output the data in a `cudf::column_view`. More information is available in the [Testing Guide](TESTING.md#printing-and-accessing-column-data) +4. GCC Address Sanitizer\ + The GCC ASAN can also be used by adding the `-fsanitize=address` compiler flags. + There is a compatibility issue with the CUDA runtime that can be worked around by setting + environment variable `ASAN_OPTIONS=protect_shadow_gap=0` before running the executable. + Note also the CUDA compute-sanitizer can also be used with GCC ASAN with the + environment variable `ASAN_OPTIONS=protect_shadow_gap=0,alloc_dealloc_mismatch=0` From 86c665c2c6ecb661958e3328dee3884b25cfb928 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Tue, 19 Mar 2024 12:34:04 -0400 Subject: [PATCH 3/7] fix some typos --- cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index 3b4c43be7ef..475f74192af 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -1400,8 +1400,8 @@ Here are some tools that can help with debugging libcudf (besides printf of cour The `print()` utility can be called within a gtest to output the data in a `cudf::column_view`. More information is available in the [Testing Guide](TESTING.md#printing-and-accessing-column-data) 4. GCC Address Sanitizer\ - The GCC ASAN can also be used by adding the `-fsanitize=address` compiler flags. + The GCC ASAN can also be used by adding the `-fsanitize=address` compiler flag. There is a compatibility issue with the CUDA runtime that can be worked around by setting environment variable `ASAN_OPTIONS=protect_shadow_gap=0` before running the executable. - Note also the CUDA compute-sanitizer can also be used with GCC ASAN with the + Note also the CUDA `compute-sanitizer` can also be used with GCC ASAN with the environment variable `ASAN_OPTIONS=protect_shadow_gap=0,alloc_dealloc_mismatch=0` From 50f61551d4ae939b115a239f52169535422eeb8a Mon Sep 17 00:00:00 2001 From: David Wendt Date: Tue, 19 Mar 2024 12:51:25 -0400 Subject: [PATCH 4/7] two many alsos --- cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index 475f74192af..b72e1f04df1 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -1403,5 +1403,5 @@ Here are some tools that can help with debugging libcudf (besides printf of cour The GCC ASAN can also be used by adding the `-fsanitize=address` compiler flag. There is a compatibility issue with the CUDA runtime that can be worked around by setting environment variable `ASAN_OPTIONS=protect_shadow_gap=0` before running the executable. - Note also the CUDA `compute-sanitizer` can also be used with GCC ASAN with the - environment variable `ASAN_OPTIONS=protect_shadow_gap=0,alloc_dealloc_mismatch=0` + Note that the CUDA `compute-sanitizer` can also be used with GCC ASAN by setting the + environment variable `ASAN_OPTIONS=protect_shadow_gap=0,alloc_dealloc_mismatch=0`. From c67cdab15f3dca79ade829a91ebbd75b5f641d92 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Wed, 20 Mar 2024 11:15:13 -0400 Subject: [PATCH 5/7] add more links --- cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index b72e1f04df1..55a4f232d45 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -1389,12 +1389,13 @@ formats commonly used in data analytics, including CSV, Parquet, ORC, Avro, and Here are some tools that can help with debugging libcudf (besides printf of course): 1. `cuda-gdb`\ - Follow the instructions in the [contributor guide](../../CONTRIBUTING.md#debugging-cudf) to build + Follow the instructions in the [Contributor to cuDF guide](../../../CONTRIBUTING.md#debugging-cudf) to build and run libcudf with debug symbols. 2. `compute-sanitizer`\ - The sanitizer tool can be used to locate many CUDA reported errors by providing a call stack + The [CUDA Compute Sanitizer](https://docs.nvidia.com/compute-sanitizer/ComputeSanitizer/index.html) + tool can be used to locate many CUDA reported errors by providing a call stack close to where the error occurs even with a non-debug build. The sanitizer includes various - tools including memcheck, racecheck, and initcheck. The racecheck and initcheck have been + tools including `memcheck`, `racecheck`, and `initcheck`. The `racecheck` and `initcheck` have been known to produce false positives. 3. `cudf::test::print()`\ The `print()` utility can be called within a gtest to output the data in a `cudf::column_view`. From 2982e2597474ef1d10d2997e9adcfc31fb931264 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Wed, 20 Mar 2024 13:14:22 -0400 Subject: [PATCH 6/7] update wording, add cpp format --- cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md | 4 ++-- cpp/doxygen/developer_guide/TESTING.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index 55a4f232d45..ce9840050a9 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -1395,8 +1395,8 @@ Here are some tools that can help with debugging libcudf (besides printf of cour The [CUDA Compute Sanitizer](https://docs.nvidia.com/compute-sanitizer/ComputeSanitizer/index.html) tool can be used to locate many CUDA reported errors by providing a call stack close to where the error occurs even with a non-debug build. The sanitizer includes various - tools including `memcheck`, `racecheck`, and `initcheck`. The `racecheck` and `initcheck` have been - known to produce false positives. + tools including `memcheck`, `racecheck`, and `initcheck` as well as others. + The `racecheck` and `initcheck` have been known to produce false positives. 3. `cudf::test::print()`\ The `print()` utility can be called within a gtest to output the data in a `cudf::column_view`. More information is available in the [Testing Guide](TESTING.md#printing-and-accessing-column-data) diff --git a/cpp/doxygen/developer_guide/TESTING.md b/cpp/doxygen/developer_guide/TESTING.md index 854ecadaec5..0ab989238be 100644 --- a/cpp/doxygen/developer_guide/TESTING.md +++ b/cpp/doxygen/developer_guide/TESTING.md @@ -455,11 +455,11 @@ Column comparison functions in the `cudf::test::detail` namespace should **NOT** ### Printing and accessing column data -The `` defines various functions and overloads for printing +The `` header defines various functions and overloads for printing columns (`print`), converting column data to string (`to_string`, `to_strings`), and copying data to the host (`to_host`). For example, to print a `cudf::column_view` contents or `column_wrapper` instance to the console use the `cudf::test::print()`: -``` +```cpp cudf::test::fixed_width_column_wrapper input({1,2,3,4}); auto splits = cudf::split(input,{2}); cudf::test::print(input); From b5cd673f53eb69a420f2c7bd91f56d34fcb1fed5 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Wed, 20 Mar 2024 13:15:53 -0400 Subject: [PATCH 7/7] change begin() to front() --- cpp/doxygen/developer_guide/TESTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/doxygen/developer_guide/TESTING.md b/cpp/doxygen/developer_guide/TESTING.md index 0ab989238be..9c86be5a55d 100644 --- a/cpp/doxygen/developer_guide/TESTING.md +++ b/cpp/doxygen/developer_guide/TESTING.md @@ -463,7 +463,7 @@ to the console use the `cudf::test::print()`: cudf::test::fixed_width_column_wrapper input({1,2,3,4}); auto splits = cudf::split(input,{2}); cudf::test::print(input); - cudf::test::print(splits.begin()); + cudf::test::print(splits.front()); ``` Fixed-width and strings columns output as comma-separated entries including null rows. Nested columns are also supported and output includes the offsets and data children as well as