Skip to content

Commit

Permalink
Fix FST, JSON gtests & benchmarks coded in namespace cudf::test (#12907)
Browse files Browse the repository at this point in the history
Fixes FST_TEST gtests source files coded in namespace cudf::test
Fixes NESTED_JSON_TEST gtests source files coded in namespace cudf::test, and fixes using cudf::io::json namespace
Fixes FST_NVBENCH benchmark coded in namespace cudf

Reference #11734

Authors:
  - Karthikeyan (https://github.com/karthikeyann)

Approvers:
  - Yunsong Wang (https://github.com/PointKernel)
  - David Wendt (https://github.com/davidwendt)
  - Elias Stehle (https://github.com/elstehle)

URL: #12907
  • Loading branch information
karthikeyann authored Mar 9, 2023
1 parent ea62e0e commit ff96cd1
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 150 deletions.
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

0 comments on commit ff96cd1

Please sign in to comment.