Default stream usage cleanup in libcudf source
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
**Describe the problem**
Default stream usage has been removed in most of cudf/ code and we have a method to find the default stream usage in runtime using stream tests.
There are still some places where `cudf::get_default_stream()` is either called explicitly or implicitly defaulted arguments. These are not triggered at runtime but they are still left in the code. Following method captures them at compile time.
By adding this attribute to get_default_stream function, the compiler can identify its usage.
```cpp
diff --git a/cpp/include/cudf/utilities/default_stream.hpp b/cpp/include/cudf/utilities/default_stream.hpp
index aeb8e0c34f..01e79dbbda 100644
--- a/cpp/include/cudf/utilities/default_stream.hpp
+++ b/cpp/include/cudf/utilities/default_stream.hpp
@@ -21,6 +21,9 @@ namespace CUDF_EXPORT cudf {
*
* @return The current default stream.
*/
+ __attribute__((
+ error("cudf default stream argument used. Pass stream explicitly."),
+ noinline))
rmm::cuda_stream_view const get_default_stream();
/**
```
compiled using `ninja libcudf.so`, to capture only cpp/src/ usage only. Following are the usages and their counts.
```
1 /home/coder/cudf/cpp/include/cudf/detail/indexalator.cuh:387:78: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
1 /home/coder/cudf/cpp/src/io/comp/nvcomp_adapter.cpp:814:49: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
1 /home/coder/cudf/cpp/src/io/parquet/reader_impl.cpp:483:5: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
1 /home/coder/cudf/cpp/src/io/text/bgzip_data_chunk_source.cu:249:55: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
1 /home/coder/cudf/cpp/src/io/text/bgzip_data_chunk_source.cu:249:97: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
1 /home/coder/cudf/cpp/src/io/utilities/hostdevice_vector.hpp:143:85: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
1 /home/coder/cudf/cpp/src/reductions/histogram.cu:91:49: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
1 /home/coder/cudf/cpp/src/reductions/scan/ewm.cu:137:52: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
2 /home/coder/cudf/cpp/src/column/column_view.cpp:35:48: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
2 /home/coder/cudf/cpp/src/column/column_view.cpp:43:48: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
2 /home/coder/cudf/cpp/src/column/column_view.cpp:45:23: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
2 /home/coder/cudf/cpp/src/io/text/bgzip_data_chunk_source.cu:165:39: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
2 /home/coder/cudf/cpp/src/io/text/data_chunk_source_factories.cpp:24:19: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
2 /home/coder/cudf/cpp/src/reductions/scan/ewm.cu:162:6: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
2 /home/coder/cudf/cpp/src/reductions/scan/ewm.cu:249:6: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
4 /home/coder/cudf/cpp/src/io/parquet/reader_impl_chunking.hpp:76:1: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
10 /home/coder/cudf/cpp/src/io/utilities/hostdevice_vector.hpp:44:70: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
12 /home/coder/cudf/cpp/src/io/parquet/reader_impl_chunking.hpp:135:1: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
15 /home/coder/cudf/cpp/src/quantiles/tdigest/tdigest_aggregation.cu:353:8: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
24 /home/coder/cudf/cpp/include/cudf/detail/gather.cuh:346:120: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
24 /home/coder/cudf/cpp/include/cudf/detail/gather.cuh:357:120: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
84 /home/coder/cudf/cpp/src/rolling/detail/rolling_operators.cuh:507:106: error: call to 'cudf::get_default_stream' declared with attribute error: cudf default stream argument used. Pass stream explicitly.
```
A few of these are coming up due to design choices, and missing defaulted arguments.
For example:
`make_lists_column` does not need stream, and mr, but it's used and defaulted.
`cluster_info` in `tdigest_aggregation.cu` could be designed without default stream usage.
**Proposed solution**
A few of these `cudf::get_default_stream` usage could be avoided by changing some design choices, and passing defaulted arguments. The goal of this issue is to minimize the `cudf::get_default_stream` usage.
Contributor guide
Assessment
This issue has not been assessed yet.