-
Notifications
You must be signed in to change notification settings - Fork 922
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
Adds Nested Json benchmark #11466
Adds Nested Json benchmark #11466
Changes from all commits
0557d41
355d1e4
39a6b65
239f138
39cff80
e24a133
caf6195
ea79a81
17dcbfd
6fdd24a
eccf970
9fe8e4b
694a365
f656f49
485a1c6
5f1c4b5
e6f8def
a798852
eb24962
f52e614
3038058
d351e5c
3f47952
cba1619
bea2a02
8a184e9
78dd893
7a19f64
4783aae
6203709
ad5817a
dc55653
378be9f
4ba5472
7980978
2bce061
b37f716
d42869a
6c889f7
8a54c72
cc1e135
7dba177
ff7144a
61a76b7
c28e327
a2f27ae
fe4762d
a064bdd
2c729c0
dbefb6c
d54f3e5
5fc3399
6f65947
6ffc7f3
0a7821e
7396335
6252208
191d71d
4e99962
3b9a1ed
632be35
3237772
d2832b9
618ed3f
19b37b7
f015594
389e8e8
42f7c4a
3e9db89
ecf68fc
93cbe1a
a1d8901
b9296d6
5eddcc7
cfcd7a1
4c2ea7b
8fc3adc
c1b9213
e5b1ba6
fd02437
f5810f8
342d3c3
f6a531a
2f22899
a141110
188b140
ba3483f
cad1060
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright (c) 2022, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <benchmarks/common/generate_input.hpp> | ||
#include <benchmarks/fixture/rmm_pool_raii.hpp> | ||
|
||
#include <nvbench/nvbench.cuh> | ||
karthikeyann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#include <io/json/nested_json.hpp> | ||
|
||
#include <tests/io/fst/common.hpp> | ||
|
||
#include <cudf/scalar/scalar_factories.hpp> | ||
#include <cudf/strings/repeat_strings.hpp> | ||
#include <cudf/types.hpp> | ||
|
||
#include <cstdlib> | ||
|
||
namespace cudf { | ||
namespace { | ||
auto make_test_json_data(size_type string_size, rmm::cuda_stream_view stream) | ||
{ | ||
// Test input | ||
std::string input = R"( | ||
{"a":1,"b":2,"c":[3], "d": {}}, | ||
{"a":1,"b":4.0,"c":[], "d": {"year":1882,"author": "Bharathi"}}, | ||
{"a":1,"b":6.0,"c":[5, 7], "d": null}, | ||
{"a":1,"b":null,"c":null}, | ||
{ | ||
"a" : 1 | ||
}, | ||
{"a":1,"b":Infinity,"c":[null], "d": {"year":-600,"author": "Kaniyan"}}, | ||
{"a": 1, "b": 8.0, "d": { "author": "Jean-Jacques Rousseau"}},)"; | ||
|
||
const size_type repeat_times = string_size / input.size(); | ||
|
||
auto d_input_scalar = cudf::make_string_scalar(input, stream); | ||
auto& d_string_scalar = static_cast<cudf::string_scalar&>(*d_input_scalar); | ||
auto d_scalar = cudf::strings::repeat_string(d_string_scalar, repeat_times); | ||
auto& d_input = static_cast<cudf::scalar_type_t<std::string>&>(*d_scalar); | ||
|
||
auto generated_json = std::string(d_input); | ||
generated_json.front() = '['; | ||
generated_json.back() = ']'; | ||
davidwendt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return generated_json; | ||
} | ||
} // namespace | ||
|
||
void BM_NESTED_JSON(nvbench::state& state) | ||
{ | ||
// TODO: to be replaced by nvbench fixture once it's ready | ||
cudf::rmm_pool_raii rmm_pool; | ||
|
||
auto const string_size{size_type(state.get_int64("string_size"))}; | ||
|
||
auto input = make_test_json_data(string_size, cudf::default_stream_value); | ||
state.add_element_count(input.size()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this show/compute throughput? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you. This is very helpful. 👍 |
||
|
||
// Run algorithm | ||
state.set_cuda_stream(nvbench::make_cuda_stream_view(cudf::default_stream_value.value())); | ||
state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) { | ||
// Allocate device-side temporary storage & run algorithm | ||
cudf::io::json::detail::parse_nested_json(input, cudf::default_stream_value); | ||
}); | ||
} | ||
|
||
NVBENCH_BENCH(BM_NESTED_JSON) | ||
.set_name("nested_json_gpu_parser") | ||
.add_int64_power_of_two_axis("string_size", nvbench::range(20, 31, 1)); | ||
|
||
} // namespace cudf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this file to be
cu
file in order to include this header?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a
hpp
version of this file available?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You only need to be
.cu
file if you are doing device calls.Including a
.cuh
file is fine as long as you are not using any of the device functions (or data) in it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we place this include right before
#include <cstdlib>
sincenvbench
header is further than cudf ones?