-
Notifications
You must be signed in to change notification settings - Fork 466
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
Generate polygonToCells benchmark with Natural Earth country geometry #795
Generate polygonToCells benchmark with Natural Earth country geometry #795
Conversation
https://github.com/uber/h3/actions/runs/6713819602/job/18246045886?pr=795 This looks like an unrelated fuzzer timeout |
scripts/make_countries.js
Outdated
function formatGeoLoop(loop) { | ||
return `{ | ||
.numVerts = ${loop.length}, | ||
.verts = (LatLng[]){ |
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.
.verts = (LatLng[]){ | |
.verts = { |
Can we elide this cast?
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.
No, the casts to LatLng[]
and GeoLoop[]
seem to be necessary to get the compiler to understand the nested arrays. Is there any significant downside to including the cast?
@@ -105,3 +106,4 @@ KML/res*centers.kml | |||
|
|||
# Generated files | |||
src/h3lib/include/h3api.h | |||
src/apps/benchmarks/benchmarkCountries.c |
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.
Maybe this could be put into a different directory to indicate it's generated?
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.
I guess it can go into the build directory - the nice thing about having it here is that it's a bit easier to edit, e.g. if your IDE is eliding build
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.
My understanding is that like h3api.h
, it would get placed in the build directory if you are doing an out-of-source build, and this was just in case you're doing an in-source build.
CMakeLists.txt
Outdated
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/apps/benchmarks/benchmarkCountries.c") | ||
add_h3_benchmark(benchmarkCountries src/apps/benchmarks/benchmarkCountries.c) | ||
endif() |
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.
Maybe this should be an optional compilation step and require the user specify -DBUILD_COUNTRIES_BENCHMARK=ON
? Then you would need to add a dependency from the benchmarkCountries target to the generate-country-benchmark target, e.g. with add_dependency
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.
The thing I struggled with here is that I want to be able to edit the generated files and then re-run, e.g. to benchmark a single country or change the res. If I add the generate-country-benchmark
target as a dependency, I think it'll run every time I run make bench_benchmarkCountries
, overriding local changes. Open to ideas here.
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.
Perhaps this can be done with BYPRODUCTS
? https://cmake.org/cmake/help/latest/command/add_custom_target.html I can try to look into coding that later
Edit: The docs say you need https://cmake.org/cmake/help/latest/command/add_custom_command.html#command:add_custom_command to tell CMake you are generating a file in the build system.
CMakeLists.txt
Outdated
@@ -577,6 +577,16 @@ if(BUILD_BENCHMARKS) | |||
if(ENABLE_REQUIRES_ALL_SYMBOLS) | |||
add_h3_benchmark(benchmarkPolygon src/apps/benchmarks/benchmarkPolygon.c) | |||
endif() | |||
|
|||
# Country benchmark: Downloads country geometry and generates the benchmark file | |||
add_custom_target(generate-country-benchmark |
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.
add_custom_target(generate-country-benchmark | |
add_custom_target(generate_country_benchmark |
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.
Will rename, thanks
scripts/make_countries.js
Outdated
} | ||
}); | ||
|
||
BENCHMARK(polygonToCells_AllCountries, 5, { |
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.
BENCHMARK(polygonToCells_AllCountries, 5, { | |
BENCHMARK(polygonToCellsExperimental_AllCountries, 5, { |
Or perhaps add 1
(previous)/2
(experimental) after both names
Adds a script and CMake targets to download relatively simple geometry for all countries and create a benchmark file. The benchmark currently runs both old and new algos for comparison; my local output:
At present, the CMake setup is a little awkward, as I wasn't sure how to add targets before you generate the source. To run the benchmark, you need:
I might be able to consolidate those steps, but I also want to be able to hand-edit the output and easily make/run again to try different benchmarks. Would love advice from someone more adept at CMake.