Skip to content

Commit

Permalink
Add debug tips section to libcudf developer guide (#15329)
Browse files Browse the repository at this point in the history
Adds a debugging tips section to the developer guide.

Authors:
  - David Wendt (https://github.com/davidwendt)

Approvers:
  - Lawrence Mitchell (https://github.com/wence-)
  - Yunsong Wang (https://github.com/PointKernel)
  - Nghia Truong (https://github.com/ttnghia)
  - Bradley Dice (https://github.com/bdice)

URL: #15329
  • Loading branch information
davidwendt authored Mar 21, 2024
1 parent aa7d991 commit 4456428
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ cuda-gdb -ex r --args python <program_name>.py <program_arguments>
```

```bash
cuda-memcheck python <program_name>.py <program_arguments>
compute-sanitizer --tool memcheck python <program_name>.py <program_arguments>
```

### Device debug symbols
Expand Down
22 changes: 22 additions & 0 deletions cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1384,3 +1384,25 @@ 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 to cuDF guide](../../../CONTRIBUTING.md#debugging-cudf) to build
and run libcudf with debug symbols.
2. `compute-sanitizer`\
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` 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)
4. GCC Address Sanitizer\
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 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`.
15 changes: 12 additions & 3 deletions cpp/doxygen/developer_guide/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<cudf_test/debug_utilities.hpp>` 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`).

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<int32_t> input({1,2,3,4});
auto splits = cudf::split(input,{2});
cudf::test::print(input);
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
the null mask bits.
## Validating Stream Usage
Expand Down

0 comments on commit 4456428

Please sign in to comment.