From fc4000ce10554c18f60f9d6af4993484b1021fef Mon Sep 17 00:00:00 2001 From: David Wendt Date: Tue, 29 Apr 2025 18:51:43 -0400 Subject: [PATCH 1/2] Enable reporting peak memory usage for gtests --- cpp/include/cudf_test/testing_main.hpp | 26 ++++++++++++++----- cpp/scripts/gtest_memory_usage.sh | 16 ++++++++++++ cpp/tests/CMakeLists.txt | 12 +++++---- cpp/tests/streams/binaryop_test.cpp | 6 ++++- cpp/tests/streams/concatenate_test.cpp | 5 +++- cpp/tests/streams/copying_test.cpp | 3 +++ cpp/tests/streams/datetime_test.cpp | 5 +++- cpp/tests/streams/dictionary_test.cpp | 5 +++- cpp/tests/streams/filling_test.cpp | 5 +++- cpp/tests/streams/groupby_test.cpp | 5 +++- cpp/tests/streams/hash_test.cpp | 5 +++- cpp/tests/streams/interop_test.cpp | 5 +++- cpp/tests/streams/io/csv_test.cpp | 5 +++- cpp/tests/streams/io/json_test.cpp | 5 +++- cpp/tests/streams/io/multibyte_split_test.cpp | 5 +++- cpp/tests/streams/io/orc_test.cpp | 5 +++- cpp/tests/streams/io/parquet_test.cpp | 5 +++- cpp/tests/streams/join_test.cpp | 3 +++ cpp/tests/streams/labeling_bins_test.cpp | 5 +++- cpp/tests/streams/lists_test.cpp | 3 +++ cpp/tests/streams/null_mask_test.cpp | 5 +++- cpp/tests/streams/partitioning_test.cpp | 5 +++- cpp/tests/streams/pool_test.cu | 5 +++- cpp/tests/streams/quantile_test.cpp | 5 +++- cpp/tests/streams/reduction_test.cpp | 5 +++- cpp/tests/streams/replace_test.cpp | 5 +++- cpp/tests/streams/reshape_test.cpp | 5 +++- cpp/tests/streams/rolling_test.cpp | 3 +++ cpp/tests/streams/round_test.cpp | 5 +++- cpp/tests/streams/scalar_test.cpp | 3 +++ cpp/tests/streams/search_test.cpp | 5 +++- cpp/tests/streams/sorting_test.cpp | 5 +++- cpp/tests/streams/stream_compaction_test.cpp | 5 +++- cpp/tests/streams/strings/strings_tests.cpp | 5 +++- cpp/tests/streams/text/tokenize_test.cpp | 5 +++- cpp/tests/streams/transform_test.cpp | 3 +++ cpp/tests/streams/unary_test.cpp | 5 +++- 37 files changed, 173 insertions(+), 40 deletions(-) create mode 100755 cpp/scripts/gtest_memory_usage.sh diff --git a/cpp/include/cudf_test/testing_main.hpp b/cpp/include/cudf_test/testing_main.hpp index 2bd08f410e0..ec533be3bea 100644 --- a/cpp/include/cudf_test/testing_main.hpp +++ b/cpp/include/cudf_test/testing_main.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,9 @@ #include #include #include +#include + +#include namespace CUDF_EXPORT cudf { namespace test { @@ -226,10 +229,19 @@ inline void init_cudf_test(int argc, char** argv, cudf::test::config const& conf * This `main` function is a wrapper around the google test generated `main`, * maintaining the original functionality. */ -#define CUDF_TEST_PROGRAM_MAIN() \ - int main(int argc, char** argv) \ - { \ - ::testing::InitGoogleTest(&argc, argv); \ - init_cudf_test(argc, argv); \ - return RUN_ALL_TESTS(); \ +#define CUDF_TEST_PROGRAM_MAIN() \ + int main(int argc, char** argv) \ + { \ + ::testing::InitGoogleTest(&argc, argv); \ + init_cudf_test(argc, argv); \ + if (std::getenv("GTEST_CUDF_MEMORY_PEAK")) { \ + auto mr = rmm::mr::statistics_resource_adaptor( \ + cudf::get_current_device_resource()); \ + cudf::set_current_device_resource(&mr); \ + auto rc = RUN_ALL_TESTS(); \ + std::cout << "Peak memory usage " << mr.get_bytes_counter().peak << " bytes" << std::endl; \ + return rc; \ + } else { \ + return RUN_ALL_TESTS(); \ + } \ } diff --git a/cpp/scripts/gtest_memory_usage.sh b/cpp/scripts/gtest_memory_usage.sh new file mode 100755 index 00000000000..b11075c6f27 --- /dev/null +++ b/cpp/scripts/gtest_memory_usage.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Copyright (c) 2025, NVIDIA CORPORATION. + +export GTEST_CUDF_RMM_MODE=cuda +export GTEST_CUDF_MEMORY_PEAK=1 +export GTEST_BRIEF=1 +for gt in gtests/*_TEST ; do + test_name=$(basename "${gt}") + echo -n "$test_name" + # dependent on the string output from testing_main.hpp + bytes=$(${gt} 2>/dev/null | grep Peak | cut -d' ' -f4) + echo ",${bytes}" +done +unset GTEST_BRIEF +unset GTEST_CUDF_RMM_MODE +unset GTEST_CUDF_MEMORY_PEAK diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 9f4ee692d87..bd78bcad54e 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -697,22 +697,24 @@ ConfigureTest(STREAM_BINARYOP_TEST streams/binaryop_test.cpp STREAM_MODE testing ConfigureTest(STREAM_COLUMN_VIEW_TEST streams/column_view_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_CONCATENATE_TEST streams/concatenate_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_COPYING_TEST streams/copying_test.cpp STREAM_MODE testing) -ConfigureTest(STREAM_CSVIO_TEST streams/io/csv_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_DATETIME_TEST streams/datetime_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_DICTIONARY_TEST streams/dictionary_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_FILLING_TEST streams/filling_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_GROUPBY_TEST streams/groupby_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_HASHING_TEST streams/hash_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_INTEROP streams/interop_test.cpp STREAM_MODE testing) +ConfigureTest(STREAM_IO_CSV_TEST streams/io/csv_test.cpp STREAM_MODE testing) +ConfigureTest(STREAM_IO_JSON_TEST streams/io/json_test.cpp STREAM_MODE testing) +ConfigureTest( + STREAM_IO_MULTIBYTE_SPLIT_TEST streams/io/multibyte_split_test.cpp STREAM_MODE testing +) +ConfigureTest(STREAM_IO_ORC_TEST streams/io/orc_test.cpp STREAM_MODE testing) +ConfigureTest(STREAM_IO_PARQUET_TEST streams/io/parquet_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_JOIN_TEST streams/join_test.cpp STREAM_MODE testing) -ConfigureTest(STREAM_JSONIO_TEST streams/io/json_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_LABELING_BINS_TEST streams/labeling_bins_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_LISTS_TEST streams/lists_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_MERGE_TEST streams/merge_test.cpp STREAM_MODE testing) -ConfigureTest(STREAM_MULTIBYTE_SPLIT_TEST streams/io/multibyte_split_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_NULL_MASK_TEST streams/null_mask_test.cpp STREAM_MODE testing) -ConfigureTest(STREAM_ORCIO_TEST streams/io/orc_test.cpp STREAM_MODE testing) -ConfigureTest(STREAM_PARQUETIO_TEST streams/io/parquet_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_PARTITIONING_TEST streams/partitioning_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_POOL_TEST streams/pool_test.cu STREAM_MODE testing) ConfigureTest(STREAM_QUANTILE_TEST streams/quantile_test.cpp STREAM_MODE testing) diff --git a/cpp/tests/streams/binaryop_test.cpp b/cpp/tests/streams/binaryop_test.cpp index 350af2f0c58..3557b2e9a8f 100644 --- a/cpp/tests/streams/binaryop_test.cpp +++ b/cpp/tests/streams/binaryop_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -122,5 +123,8 @@ TEST_F(BinaryopPTXTest, ColumnColumnPTX) cudf::binary_operation( lhs, rhs, ptx, cudf::data_type(cudf::type_to_id()), cudf::test::get_default_stream()); - cudf::binary_operation(lhs, rhs, ptx, cudf::data_type(cudf::type_to_id())); + cudf::binary_operation( + lhs, rhs, ptx, cudf::data_type(cudf::type_to_id()), cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/concatenate_test.cpp b/cpp/tests/streams/concatenate_test.cpp index 648fb01a636..e99d7d159a4 100644 --- a/cpp/tests/streams/concatenate_test.cpp +++ b/cpp/tests/streams/concatenate_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -49,3 +50,5 @@ TEST_F(ConcatenateTest, Masks) std::vector views{input1, input2}; auto result = cudf::concatenate_masks(views, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/copying_test.cpp b/cpp/tests/streams/copying_test.cpp index c845ff611e8..4d36280a413 100644 --- a/cpp/tests/streams/copying_test.cpp +++ b/cpp/tests/streams/copying_test.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -360,3 +361,5 @@ TEST_F(CopyingTest, ContiguousSplit) cudf::table_view tbl({col, col2}); auto result = cudf::contiguous_split(tbl, splits, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/datetime_test.cpp b/cpp/tests/streams/datetime_test.cpp index 29b302c3637..73ca827c5b9 100644 --- a/cpp/tests/streams/datetime_test.cpp +++ b/cpp/tests/streams/datetime_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -147,3 +148,5 @@ TEST_F(DatetimeTest, RoundDatetimes) cudf::datetime::round_datetimes( timestamps, cudf::datetime::rounding_frequency::HOUR, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/dictionary_test.cpp b/cpp/tests/streams/dictionary_test.cpp index 498504ef212..1a0b629fd9f 100644 --- a/cpp/tests/streams/dictionary_test.cpp +++ b/cpp/tests/streams/dictionary_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -149,3 +150,5 @@ TEST_F(DictionaryTest, MatchDictionaries) cudf::test::fixed_width_column_wrapper keys_col({2, 6}); cudf::dictionary::match_dictionaries(dicts, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/filling_test.cpp b/cpp/tests/streams/filling_test.cpp index d8d48fe6557..b87e6f2661b 100644 --- a/cpp/tests/streams/filling_test.cpp +++ b/cpp/tests/streams/filling_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -74,3 +75,5 @@ TEST_F(FillingTest, CalendricalMonthSequence) cudf::calendrical_month_sequence(10, init, 2, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/groupby_test.cpp b/cpp/tests/streams/groupby_test.cpp index 73d6d31b282..7be48ca6a66 100644 --- a/cpp/tests/streams/groupby_test.cpp +++ b/cpp/tests/streams/groupby_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -120,3 +121,5 @@ TEST_F(GroupbyTest, ReplaceNullsTest) auto p = gb_obj.replace_nulls(cudf::table_view({val}), policies, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/hash_test.cpp b/cpp/tests/streams/hash_test.cpp index 64ae6987a3d..fa36d26789a 100644 --- a/cpp/tests/streams/hash_test.cpp +++ b/cpp/tests/streams/hash_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -52,3 +53,5 @@ TEST_F(HashTest, MultiValue) auto const output1 = cudf::hashing::murmurhash3_x86_32( input1, cudf::DEFAULT_HASH_SEED, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/interop_test.cpp b/cpp/tests/streams/interop_test.cpp index 79ea6b7d6d4..e0033720cb8 100644 --- a/cpp/tests/streams/interop_test.cpp +++ b/cpp/tests/streams/interop_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -46,3 +47,5 @@ TEST_F(DLPackTest, FromDLPack) unique_managed_tensor tensor(cudf::to_dlpack(input, cudf::test::get_default_stream())); auto result = cudf::from_dlpack(tensor.get(), cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/io/csv_test.cpp b/cpp/tests/streams/io/csv_test.cpp index a74ee64f8de..eb61bf03ed8 100644 --- a/cpp/tests/streams/io/csv_test.cpp +++ b/cpp/tests/streams/io/csv_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -90,3 +91,5 @@ TEST_F(CSVTest, CSVReader) cudf::io::csv_reader_options::builder(cudf::io::source_info{filepath}).build(); cudf::io::read_csv(r_options, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/io/json_test.cpp b/cpp/tests/streams/io/json_test.cpp index d352c6c3b2a..ca2d99f8bb1 100644 --- a/cpp/tests/streams/io/json_test.cpp +++ b/cpp/tests/streams/io/json_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -61,3 +62,5 @@ TEST_F(JSONTest, JSONwriter) cudf::io::write_json(options_builder.build(), cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/io/multibyte_split_test.cpp b/cpp/tests/streams/io/multibyte_split_test.cpp index 5bb17226029..30ed6e363fc 100644 --- a/cpp/tests/streams/io/multibyte_split_test.cpp +++ b/cpp/tests/streams/io/multibyte_split_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -33,3 +34,5 @@ TEST_F(MultibyteSplitTest, Reader) auto result = cudf::io::text::multibyte_split(*source, delimiter, options, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/io/orc_test.cpp b/cpp/tests/streams/io/orc_test.cpp index 10722557e6a..ed6c4542a1f 100644 --- a/cpp/tests/streams/io/orc_test.cpp +++ b/cpp/tests/streams/io/orc_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -115,3 +116,5 @@ TEST_F(ORCTest, ORCReader) auto meta = read_orc_metadata(cudf::io::source_info{filepath}); auto const stats = cudf::io::read_parsed_orc_statistics(cudf::io::source_info{filepath}); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/io/parquet_test.cpp b/cpp/tests/streams/io/parquet_test.cpp index 18bb80e64af..e072d300556 100644 --- a/cpp/tests/streams/io/parquet_test.cpp +++ b/cpp/tests/streams/io/parquet_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -122,3 +123,5 @@ TEST_F(ParquetTest, ChunkedOperations) auto chunk = reader.read_chunk(); } } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/join_test.cpp b/cpp/tests/streams/join_test.cpp index 5a6a83aaf9c..9eb9d2a98c7 100644 --- a/cpp/tests/streams/join_test.cpp +++ b/cpp/tests/streams/join_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -218,3 +219,5 @@ TEST_F(JoinTest, ConditionalLeftAntiJoinSize) cudf::conditional_left_anti_join_size( table0, table1, left_zero_eq_right_zero, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/labeling_bins_test.cpp b/cpp/tests/streams/labeling_bins_test.cpp index c7dc49436b0..4c8d20b2bed 100644 --- a/cpp/tests/streams/labeling_bins_test.cpp +++ b/cpp/tests/streams/labeling_bins_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -35,3 +36,5 @@ TEST_F(LabelingBinsStreamTest, SimpleStringsTest) cudf::inclusive::NO, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/lists_test.cpp b/cpp/tests/streams/lists_test.cpp index 7e4fad366f7..5d6e544dcaf 100644 --- a/cpp/tests/streams/lists_test.cpp +++ b/cpp/tests/streams/lists_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -269,3 +270,5 @@ TEST_F(ListTest, ExplodeOuterPosition) cudf::table_view lists_table({list_col_a, list_col_b}); cudf::explode_outer_position(lists_table, 0, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/null_mask_test.cpp b/cpp/tests/streams/null_mask_test.cpp index ed37a72545f..41b592d2c0a 100644 --- a/cpp/tests/streams/null_mask_test.cpp +++ b/cpp/tests/streams/null_mask_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -87,3 +88,5 @@ TEST_F(NullMaskTest, NullCount) cudf::null_count( static_cast(col).null_mask(), 0, 4, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/partitioning_test.cpp b/cpp/tests/streams/partitioning_test.cpp index 636c5c1f1f9..540f6f44c0e 100644 --- a/cpp/tests/streams/partitioning_test.cpp +++ b/cpp/tests/streams/partitioning_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -71,3 +72,5 @@ TEST_F(PartitionTest, ZeroPartitions) cudf::DEFAULT_HASH_SEED, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/pool_test.cu b/cpp/tests/streams/pool_test.cu index 92aa43b101a..574e29b9cd2 100644 --- a/cpp/tests/streams/pool_test.cu +++ b/cpp/tests/streams/pool_test.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ #include #include +#include #include @@ -32,3 +33,5 @@ TEST_F(StreamPoolTest, ForkStreams) do_nothing_kernel<<<1, 32, 0, stream.value()>>>(); } } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/quantile_test.cpp b/cpp/tests/streams/quantile_test.cpp index 4f4f16a9e70..ab2dfc0961d 100644 --- a/cpp/tests/streams/quantile_test.cpp +++ b/cpp/tests/streams/quantile_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -72,3 +73,5 @@ TEST_F(QuantileTest, EmptyInput) cudf::tdigest::tdigest_column_view tdv(*empty); auto result = cudf::percentile_approx(tdv, percentiles, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/reduction_test.cpp b/cpp/tests/streams/reduction_test.cpp index 9ab972302e4..a6d63e19654 100644 --- a/cpp/tests/streams/reduction_test.cpp +++ b/cpp/tests/streams/reduction_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -102,3 +103,5 @@ TEST_F(ReductionTest, MinMax) cudf::minmax(input, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/replace_test.cpp b/cpp/tests/streams/replace_test.cpp index e3fdc177b50..f5c9a2cfc2b 100644 --- a/cpp/tests/streams/replace_test.cpp +++ b/cpp/tests/streams/replace_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -110,3 +111,5 @@ TEST_F(ReplaceTest, NormalizeNansAndZerosMutable) auto view = input->mutable_view(); cudf::normalize_nans_and_zeros(view, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/reshape_test.cpp b/cpp/tests/streams/reshape_test.cpp index d7c5da91bca..047c9a798b0 100644 --- a/cpp/tests/streams/reshape_test.cpp +++ b/cpp/tests/streams/reshape_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -45,3 +46,5 @@ TEST_F(ReshapeTest, ByteCast) cudf::byte_cast(a, cudf::flip_endianness::YES, cudf::test::get_default_stream()); cudf::byte_cast(a, cudf::flip_endianness::NO, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/rolling_test.cpp b/cpp/tests/streams/rolling_test.cpp index c7d7b4aa5c4..b3ef90e9941 100644 --- a/cpp/tests/streams/rolling_test.cpp +++ b/cpp/tests/streams/rolling_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -247,3 +248,5 @@ TEST_F(GroupedRangeRollingTest, RangeWindowBounds) *cudf::make_count_aggregation(), cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/round_test.cpp b/cpp/tests/streams/round_test.cpp index b8fda022db8..b8c4e72be20 100644 --- a/cpp/tests/streams/round_test.cpp +++ b/cpp/tests/streams/round_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -38,3 +39,5 @@ TEST_F(RoundTest, RoundHalfAwayFromEven) cudf::test::fixed_width_column_wrapper input(vals.begin(), vals.end()); cudf::round(input, -1, cudf::rounding_method::HALF_EVEN, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/scalar_test.cpp b/cpp/tests/streams/scalar_test.cpp index a626afc8530..a3e37dd56a6 100644 --- a/cpp/tests/streams/scalar_test.cpp +++ b/cpp/tests/streams/scalar_test.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -41,3 +42,5 @@ TEST_F(StringScalarTest, DefaultValidity) auto s = cudf::string_scalar(value, true, cudf::test::get_default_stream()); EXPECT_EQ(value, s.to_string(cudf::test::get_default_stream())); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/search_test.cpp b/cpp/tests/streams/search_test.cpp index d0249b0a45e..85c2549fcdc 100644 --- a/cpp/tests/streams/search_test.cpp +++ b/cpp/tests/streams/search_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -67,3 +68,5 @@ TEST_F(SearchTest, ContainsColumn) cudf::contains(haystack, needles, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/sorting_test.cpp b/cpp/tests/streams/sorting_test.cpp index ae0e293c8e6..8a71ca75c42 100644 --- a/cpp/tests/streams/sorting_test.cpp +++ b/cpp/tests/streams/sorting_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -130,3 +131,5 @@ TEST_F(SortingTest, StableSegmentedSortByKey) cudf::stable_segmented_sort_by_key( values, keys, segment_offsets, {}, {}, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/stream_compaction_test.cpp b/cpp/tests/streams/stream_compaction_test.cpp index e7b282601e1..ab9af49ee2e 100644 --- a/cpp/tests/streams/stream_compaction_test.cpp +++ b/cpp/tests/streams/stream_compaction_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -456,3 +457,5 @@ TEST_F(StreamCompactionTest, DistinctCountTable) expected, cudf::distinct_count(input_table, null_equality::EQUAL, cudf::test::get_default_stream())); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/strings/strings_tests.cpp b/cpp/tests/streams/strings/strings_tests.cpp index 482d39e866b..63d6450be3d 100644 --- a/cpp/tests/streams/strings/strings_tests.cpp +++ b/cpp/tests/streams/strings/strings_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -69,3 +70,5 @@ TEST_F(StringsTest, Slice) auto stops = cudf::test::fixed_width_column_wrapper({4, 5, 6}); cudf::strings::slice_strings(view, starts, stops, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/text/tokenize_test.cpp b/cpp/tests/streams/text/tokenize_test.cpp index 619aaeeaeab..31aa67c6b2f 100644 --- a/cpp/tests/streams/text/tokenize_test.cpp +++ b/cpp/tests/streams/text/tokenize_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -51,3 +52,5 @@ TEST_F(TextTokenizeTest, Detokenize) auto const separator = cudf::string_scalar{" ", true, cudf::test::get_default_stream()}; nvtext::detokenize(view, indices, separator, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/transform_test.cpp b/cpp/tests/streams/transform_test.cpp index 8e8934e933e..bf1f09a1517 100644 --- a/cpp/tests/streams/transform_test.cpp +++ b/cpp/tests/streams/transform_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -168,3 +169,5 @@ TEST_F(TransformTest, SegmentedRowBitCount) auto constexpr segment_length = 2; cudf::segmented_row_bit_count(input, segment_length, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/streams/unary_test.cpp b/cpp/tests/streams/unary_test.cpp index 15f04df70d3..b0c2e2ff944 100644 --- a/cpp/tests/streams/unary_test.cpp +++ b/cpp/tests/streams/unary_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -63,3 +64,5 @@ TEST_F(UnaryTest, IsNotNan) cudf::is_not_nan(column, cudf::test::get_default_stream()); } + +CUDF_TEST_PROGRAM_MAIN() From 84b21cd9654f6f77257cf0adb2b515291d893d29 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Wed, 30 Apr 2025 12:55:38 -0400 Subject: [PATCH 2/2] add statitics mr to large-strings fixture --- cpp/tests/large_strings/large_strings_fixture.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cpp/tests/large_strings/large_strings_fixture.cpp b/cpp/tests/large_strings/large_strings_fixture.cpp index f1404990354..f12d828ab2d 100644 --- a/cpp/tests/large_strings/large_strings_fixture.cpp +++ b/cpp/tests/large_strings/large_strings_fixture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -127,5 +127,13 @@ int main(int argc, char** argv) // create object to automatically be destroyed at the end of main() auto lsd = cudf::test::StringsLargeTest::get_ls_data(); + if (std::getenv("GTEST_CUDF_MEMORY_PEAK")) { + auto mr = rmm::mr::statistics_resource_adaptor( + cudf::get_current_device_resource()); + cudf::set_current_device_resource(&mr); + auto rc = RUN_ALL_TESTS(); + std::cout << "Peak memory usage " << mr.get_bytes_counter().peak << " bytes" << std::endl; + return rc; + } return RUN_ALL_TESTS(); }