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

Allow users to control iteration via the concept of iteration spaces. #80

Open
wants to merge 30 commits into
base: main
Choose a base branch
from

Conversation

robertmaynard
Copy link
Collaborator

@robertmaynard robertmaynard commented Feb 25, 2022

Changes in the work include:

  • Internally use linear_space for iterating
  • Simplify type and value iteration in state_iterator::build_axis_configs
  • Store the iteration space in axes_metadata
  • Expose zip and user spaces to user
  • Add tests for linear, zip, and user
  • Add examples for zip and user

Fixes #68

Changes in the work include:
- [x] Internally use linear_space for iterating
- [x] Simplify type and value iteration in `state_iterator::build_axis_configs`
- [x] Store the iteration space in `axes_metadata`
- [x] Expose `tie` and `user` spaces to user
- [x] Add tests for `linear`, `tie`, and `user`
- [x] Add examples for `tie` and `user`
docs/benchmarks.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@jrhemstad jrhemstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re: naming, I'd stick with zip as opposed to tie.

I think "zip" is more intuitive and descriptive based on the precedence of things like thrust::zip_iterator and std::ranges::zip_view.

Comment on lines 53 to 56
virtual std::unique_ptr<axis_space_base> do_clone() const = 0;
virtual detail::axis_space_iterator do_iter(axes_info info) const = 0;
virtual std::size_t do_size(const axes_info &info) const = 0;
virtual std::size_t do_valid_count(const axes_info &info) const = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to get some docs on the concept of a "axis space" as well as the semantics of these functions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, same for the linear_axis_space and other subclasses below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added more documentation

docs/benchmarks.md Outdated Show resolved Hide resolved
@robertmaynard robertmaynard force-pushed the fea/axes_iteration_space branch from 182f1da to a25f578 Compare February 28, 2022 19:23
@robertmaynard robertmaynard force-pushed the fea/axes_iteration_space branch from 0a2130f to c3c86e1 Compare February 28, 2022 21:44
docs/benchmarks.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@alliepiper alliepiper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did an initial round of review, but didn't finish -- sharing my comments so far. Will give this a closer look later.

In the meantime, can you go through this and add documentation for the new interfaces?

Having a high-level overview of how these pieces fit together would also be helpful, maybe include that in the class docs for nvbench::detail::axes_iterator.

docs/benchmarks.md Outdated Show resolved Hide resolved
docs/benchmarks.md Outdated Show resolved Hide resolved
docs/benchmarks.md Outdated Show resolved Hide resolved
nvbench/benchmark_base.cuh Outdated Show resolved Hide resolved
docs/benchmarks.md Outdated Show resolved Hide resolved
nvbench/axis_iteration_space.cuh Outdated Show resolved Hide resolved
nvbench/axis_iteration_space.cuh Outdated Show resolved Hide resolved
nvbench/axis_iteration_space.cxx Outdated Show resolved Hide resolved
nvbench/axis_iteration_space.cuh Outdated Show resolved Hide resolved
nvbench/axis_iteration_space.cxx Outdated Show resolved Hide resolved
@robertmaynard robertmaynard force-pushed the fea/axes_iteration_space branch 3 times, most recently from 5dc6c83 to d8d80e4 Compare April 12, 2022 16:22
@robertmaynard robertmaynard force-pushed the fea/axes_iteration_space branch from d8d80e4 to ba8356f Compare April 12, 2022 16:35
@robertmaynard robertmaynard force-pushed the fea/axes_iteration_space branch from f66cca3 to f4396bd Compare April 12, 2022 17:47
@robertmaynard robertmaynard force-pushed the fea/axes_iteration_space branch from f4396bd to e7b4800 Compare April 13, 2022 19:26
docs/benchmarks.md Outdated Show resolved Hide resolved
docs/benchmarks.md Outdated Show resolved Hide resolved
Comment on lines 54 to 60
* Construct a new derived iteration_space
*
* @param[input_indices]
* @param[output_indices]
*/
iteration_space_base(std::vector<std::size_t> input_indices,
std::vector<std::size_t> output_indices);
Copy link
Collaborator

@jrhemstad jrhemstad Aug 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not obvious what the input_indices/output_indices represent here and could use docs to explain.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the docs with more information, does that help clarify it?

Comment on lines +64 to +66
* The input_indices and output_indices combine together to allow the iteration space to know
* what axi they should query from axes_metadata and where each of those map to in the output
* iteration space.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So input_indices determines which elements from the std::vector<std::unique_ptr<nvbench::axis_base>> inside axes_metadata are referenced by the iteration_space?

What do the output_indices reference?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So input_indices determines which elements from the std::vector<std::unique_ptrnvbench::axis_base> inside axes_metadata are referenced by the iteration_space?

Correct.

What do the output_indices reference?

The location in the detail::state_iterator vector of results for a given entry in the cross produce of both type and value axis

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been awhile since I wrote this class, and with the removal of adding abitrary zips the output_indices might be unneeded if we have the number of type axis. I will see if I can refactor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the PR and was able to both remove output_indices and simplify the interator update logic.

std::size_t active_size;
};

struct axis_space_iterator
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this is a pretty central piece of new machinery, this could use some docs for what is going on here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, given this isn't really an iterator in the sense that it doesn't satisfy any std::iterator concepts, I think the iterator name is confusing (it confused me anyways).

I'd either make it satisfy an appropriate iterator concept or give it a different name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class matches the naming pattern of the existing state_iterator ( https://github.com/NVIDIA/nvbench/blob/main/nvbench/detail/state_generator.cuh#L74 ) which calls the axis_iterator.

* std::move(output_indices))
* {}
*
* nvbench::detail::axis_space_iterator do_get_iterator(axes_info info) const
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having things in the detail namespace appear in something called user_axis_space seems incongruous.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the implementation around here, so it would be good to review again. If we are happy with axis_space_iterator I will promote it to nvbench::

@robertmaynard robertmaynard force-pushed the fea/axes_iteration_space branch from 0ade18a to 282754b Compare August 31, 2022 15:08
@robertmaynard robertmaynard force-pushed the fea/axes_iteration_space branch from 282754b to 5708e6c Compare August 31, 2022 15:08
@bdice
Copy link
Contributor

bdice commented Aug 7, 2024

Can we revive this PR? Are there blockers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a zip_axis / tuple_axis that iterates through multiple parameter axes in lockstep
4 participants