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

Improve C++ source and header organization #663

Closed
5 tasks done
harrism opened this issue Aug 25, 2022 · 1 comment · Fixed by #1115
Closed
5 tasks done

Improve C++ source and header organization #663

harrism opened this issue Aug 25, 2022 · 1 comment · Fixed by #1115
Assignees
Labels
feature request New feature or request libcuspatial Relates to the cuSpatial C++ library

Comments

@harrism
Copy link
Member

harrism commented Aug 25, 2022

** Update: converting to epic/tasklist **

Tasks

Preview Give feedback
  1. improvement libcuspatial
    harrism
  2. improvement libcuspatial
    harrism

Is your feature request related to a problem? Please describe.
I think we should organize our headers and source better. To make implementations, tests, and benchmarks easier to find and navigate, I would like the directories of source files, tests, and benchmarks to match the names of the API header that they implement. Currently this is not strictly true. Here is the current include tree (ignoring experimental directory)

include
├── cuspatial
│   ├── constants.hpp
│   ├── coordinate_transform.hpp
│   ├── cubic_spline.hpp
│   ├── cuda_utils.hpp
│   ├── cusparse_error.hpp
│   ├── detail
│   │   ├── cubic_spline.hpp
│   │   ├── iterator.hpp
│   │   ├── nvtx
│   │   │   ├── nvtx3.hpp
│   │   │   └── ranges.hpp
│   │   └── utility
│   │       ├── device_atomics.cuh
│   │       ├── linestring.cuh
│   │       └── traits.hpp
│   ├── distances
│   │   └── linestring_distance.hpp
│   ├── error.hpp
│   ├── hausdorff.hpp
│   ├── haversine.hpp
│   ├── point_in_polygon.hpp
│   ├── point_quadtree.hpp
│   ├── polygon_bounding_box.hpp
│   ├── polyline_bounding_box.hpp
│   ├── shapefile_reader.hpp
│   ├── spatial_join.hpp
│   ├── spatial_window.hpp
│   ├── trajectory.hpp
│   └── vec_2d.hpp
└── doxygen_groups.h

Note that this is relatively flat -- algorithms are in top level headers, with the exception of linestring_distance.hpp. Another library that takes this flat approach is Thrust. It's nice that it's mostly easy to include things:

#include <thrust/gather.h>
#include <thrust/scan.h>
#include <thrust/device_vector.h>

Thrust iterators are an exception:

#include <thrust/iterator/transform_iterator.h>

There is a natural tradeoff between ease of including headers, and clutter when browsing the include directory. However, if there is a natural logical grouping of headers (as with Thrust iterators), then they can be grouped in directories. But this grouping can happen in many ways, and therefore leads to much bikeshedding with lots of discussion about noun-form group names vs. verb-form group names, as we experienced in #644.

cuspatial/cpp/src directory already does some of this grouping, which doesn't match the cuspatial/cpp/include directory at all:

src
├── indexing
│   └── construction
│       ├── detail
│       │   ├── phase_1.cuh
│       │   ├── phase_2.cuh
│       │   └── utilities.cuh
│       └── point_quadtree.cu
├── interpolate
│   └── cubic_spline.cu
├── io
│   └── shp
│       ├── polygon_shapefile_reader.cpp
│       └── polygon_shapefile_reader.cu
├── join
│   ├── detail
│   │   ├── intersection.cuh
│   │   ├── point.cuh
│   │   └── traversal.cuh
│   ├── quadtree_point_in_polygon.cu
│   ├── quadtree_point_to_nearest_polyline.cu
│   └── quadtree_poly_filtering.cu
├── spatial
│   ├── hausdorff.cu
│   ├── haversine.cu
│   ├── linestring_distance.cu
│   ├── lonlat_to_cartesian.cu
│   ├── point_in_polygon.cu
│   ├── polygon_bounding_box.cu
│   └── polyline_bounding_box.cu
├── spatial_window
│   └── spatial_window.cu
├── trajectory
│   ├── derive_trajectories.cu
│   ├── trajectory_bounding_boxes.cu
│   └── trajectory_distances_and_speeds.cu
└── utility
    ├── point_in_polygon.cuh
    ├── point_to_nearest_polyline.cuh
    ├── scatter_output_iterator.cuh
    ├── size_from_offsets.cuh
    └── z_order.cuh

I don't mind this, except for the "spatial" folder, which contains distance, projection, containment, and bounding algorithms. Then there is the "spatial_window" folder, which is apparently different from "spatial", but only has one file. (I think this should be called "filtering").

The "utility" directory seems to conflate the concept of "utility" (helper code generally reusable across modules) and "detail" (implementation details not intended for reuse).

Let the bikeshedding begin!

@harrism harrism added feature request New feature or request Needs Triage Need team to review and classify labels Aug 25, 2022
@harrism harrism added c++ and removed Needs Triage Need team to review and classify labels Aug 25, 2022
@harrism harrism moved this to Todo in cuSpatial Aug 25, 2022
@harrism harrism changed the title [FEA] Improve C++ source and header organization [DISCUSSION] Improve C++ source and header organization Aug 25, 2022
@isVoid
Copy link
Contributor

isVoid commented Oct 7, 2022

Considering most our c++ primitives are 1-1 exposed to cuspatial python, perhaps we can try mirroring the cuspatial python taxonomy until something breaks?

Another elephant in the room is that when we merge experimental into the main library, where should these new header file go? I can see two one way:

  • Keep cuh file, and leave the column API separate in .hpp file.

- Merge header only and column API, use a single .cuh file. (This would defeat our purpose of removing cudf dependency)

@harrism harrism added libcuspatial Relates to the cuSpatial C++ library and removed c++ labels Nov 16, 2022
@harrism harrism self-assigned this Apr 18, 2023
@harrism harrism changed the title [DISCUSSION] Improve C++ source and header organization Improve C++ source and header organization Apr 19, 2023
@harrism harrism moved this from Todo to Review in cuSpatial May 3, 2023
@rapids-bot rapids-bot bot closed this as completed in #1115 May 4, 2023
rapids-bot bot pushed a commit that referenced this issue May 4, 2023
Fixes #663. 
Also fixes #1105 

Organizes all source, test, and benchmark files into directories matching the names of the associated headers that define the APIs they implement/test/benchmark.

Also fixes up documentation so it is consistent with this.

Authors:
  - Mark Harris (https://github.com/harrism)

Approvers:
  - Paul Taylor (https://github.com/trxcllnt)
  - H. Thomson Comer (https://github.com/thomcom)
  - Michael Wang (https://github.com/isVoid)

URL: #1115
@github-project-automation github-project-automation bot moved this from Review to Done in cuSpatial May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request libcuspatial Relates to the cuSpatial C++ library
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants