Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FST, JSON gtests & benchmarks coded in namespace cudf::test #12907

Merged
merged 4 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions cpp/benchmarks/io/fst.cu
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@

#include <cstdlib>

namespace cudf {
namespace {
auto make_test_json_data(nvbench::state& state)
{
auto const string_size{size_type(state.get_int64("string_size"))};
auto const string_size{cudf::size_type(state.get_int64("string_size"))};

// Test input
std::string input = R"( {)"
Expand All @@ -59,13 +58,12 @@ auto make_test_json_data(nvbench::state& state)
R"("price": 8.95)"
R"(} {} [] [ ])";

auto d_input_scalar = cudf::make_string_scalar(input);
auto& d_string_scalar = static_cast<cudf::string_scalar&>(*d_input_scalar);
const size_type repeat_times = string_size / input.size();
auto d_input_scalar = cudf::make_string_scalar(input);
auto& d_string_scalar = static_cast<cudf::string_scalar&>(*d_input_scalar);
const cudf::size_type repeat_times = string_size / input.size();
return cudf::strings::repeat_string(d_string_scalar, repeat_times);
}

using namespace cudf::test::io::json;
// Type used to represent the atomic symbol type used within the finite-state machine
using SymbolT = char;
// Type sufficiently large to index symbols within the input and output (may be unsigned)
Expand All @@ -78,9 +76,9 @@ constexpr std::size_t single_item = 1;

void BM_FST_JSON(nvbench::state& state)
{
CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits<size_type>::max(),
CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits<cudf::size_type>::max(),
"Benchmarks only support up to size_type's maximum number of items");
auto const string_size{size_type(state.get_int64("string_size"))};
auto const string_size{cudf::size_type(state.get_int64("string_size"))};
// Prepare cuda stream for data transfers & kernels
rmm::cuda_stream stream{};
rmm::cuda_stream_view stream_view(stream);
Expand Down Expand Up @@ -113,9 +111,9 @@ void BM_FST_JSON(nvbench::state& state)

void BM_FST_JSON_no_outidx(nvbench::state& state)
{
CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits<size_type>::max(),
CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits<cudf::size_type>::max(),
"Benchmarks only support up to size_type's maximum number of items");
auto const string_size{size_type(state.get_int64("string_size"))};
auto const string_size{cudf::size_type(state.get_int64("string_size"))};
// Prepare cuda stream for data transfers & kernels
rmm::cuda_stream stream{};
rmm::cuda_stream_view stream_view(stream);
Expand Down Expand Up @@ -148,9 +146,9 @@ void BM_FST_JSON_no_outidx(nvbench::state& state)

void BM_FST_JSON_no_out(nvbench::state& state)
{
CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits<size_type>::max(),
CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits<cudf::size_type>::max(),
"Benchmarks only support up to size_type's maximum number of items");
auto const string_size{size_type(state.get_int64("string_size"))};
auto const string_size{cudf::size_type(state.get_int64("string_size"))};
// Prepare cuda stream for data transfers & kernels
rmm::cuda_stream stream{};
rmm::cuda_stream_view stream_view(stream);
Expand Down Expand Up @@ -181,9 +179,9 @@ void BM_FST_JSON_no_out(nvbench::state& state)

void BM_FST_JSON_no_str(nvbench::state& state)
{
CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits<size_type>::max(),
CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits<cudf::size_type>::max(),
"Benchmarks only support up to size_type's maximum number of items");
auto const string_size{size_type(state.get_int64("string_size"))};
auto const string_size{cudf::size_type(state.get_int64("string_size"))};
// Prepare cuda stream for data transfers & kernels
rmm::cuda_stream stream{};
rmm::cuda_stream_view stream_view(stream);
Expand Down Expand Up @@ -228,5 +226,3 @@ NVBENCH_BENCH(BM_FST_JSON_no_out)
NVBENCH_BENCH(BM_FST_JSON_no_str)
.set_name("FST_JSON_no_str")
.add_int64_power_of_two_axis("string_size", nvbench::range(20, 30, 1));

} // namespace cudf
5 changes: 1 addition & 4 deletions cpp/tests/io/fst/common.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,6 @@
#include <string>
#include <vector>

namespace cudf::test::io::json {
//------------------------------------------------------------------------------
// TEST FST SPECIFICATIONS
//------------------------------------------------------------------------------
Expand Down Expand Up @@ -81,5 +80,3 @@ std::array<std::string, NUM_SYMBOL_GROUPS - 1> const pda_sgs{"{", "[", "}", "]",

// The DFA's starting state
constexpr char start_state = static_cast<char>(dfa_states::TT_OOS);

} // namespace cudf::test::io::json
4 changes: 1 addition & 3 deletions cpp/tests/io/fst/fst_test.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -116,8 +116,6 @@ static std::pair<OutputItT, IndexOutputItT> fst_baseline(InputItT begin,
}
return {out_tape, out_index_tape};
}

using namespace cudf::test::io::json;
} // namespace

// Base test fixture for tests
Expand Down
Loading