-
Notifications
You must be signed in to change notification settings - Fork 197
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
CAGRA pad dataset for 128bit vectorized load #1505
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
21e2d08
Pad dataset to allow 128bit vectorized load
tfeher 08f4dcb
Fix style
tfeher 0808401
Merge branch 'branch-23.08' into cagra_pad_dataset
tfeher b914a3b
Merge branch 'branch-23.08' into cagra_pad_dataset
tfeher f826ecb
Merge branch 'branch-23.08' into cagra_pad_dataset
tfeher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
namespace raft::neighbors::experimental::cagra::detail { | ||
|
||
// Serialization version 1. | ||
constexpr int serialization_version = 1; | ||
constexpr int serialization_version = 2; | ||
|
||
// NB: we wrap this check in a struct, so that the updated RealSize is easy to see in the error | ||
// message. | ||
|
@@ -36,7 +36,8 @@ struct check_index_layout { | |
"paste in the new size and consider updating the serialization logic"); | ||
}; | ||
|
||
template struct check_index_layout<sizeof(index<double, std::uint64_t>), 136>; | ||
constexpr size_t expected_size = 176; | ||
template struct check_index_layout<sizeof(index<double, std::uint64_t>), expected_size>; | ||
|
||
/** | ||
* Save the index to file. | ||
|
@@ -59,7 +60,19 @@ void serialize(raft::resources const& res, std::ostream& os, const index<T, IdxT | |
serialize_scalar(res, os, index_.dim()); | ||
serialize_scalar(res, os, index_.graph_degree()); | ||
serialize_scalar(res, os, index_.metric()); | ||
serialize_mdspan(res, os, index_.dataset()); | ||
auto dataset = index_.dataset(); | ||
// Remove padding before saving the dataset | ||
auto host_dataset = make_host_matrix<T, IdxT>(dataset.extent(0), dataset.extent(1)); | ||
RAFT_CUDA_TRY(cudaMemcpy2DAsync(host_dataset.data_handle(), | ||
sizeof(T) * host_dataset.extent(1), | ||
dataset.data_handle(), | ||
sizeof(T) * dataset.stride(0), | ||
sizeof(T) * host_dataset.extent(1), | ||
dataset.extent(0), | ||
cudaMemcpyDefault, | ||
resource::get_cuda_stream(res))); | ||
resource::sync_stream(res); | ||
serialize_mdspan(res, os, host_dataset.view()); | ||
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. Mostly a side question, but are we still planning to remove the dataset from the serialization in a future change? |
||
serialize_mdspan(res, os, index_.graph()); | ||
} | ||
|
||
|
@@ -100,7 +113,6 @@ auto deserialize(raft::resources const& res, std::istream& is) -> index<T, IdxT> | |
|
||
auto dataset = raft::make_host_matrix<T, IdxT>(n_rows, dim); | ||
auto graph = raft::make_host_matrix<IdxT, IdxT>(n_rows, graph_degree); | ||
|
||
deserialize_mdspan(res, is, dataset.view()); | ||
deserialize_mdspan(res, is, graph.view()); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If this is going to be a more common practice, I wonder if we should consider centralizing this somewhere eventually. Probably doesn't need to be done yet, or even in this PR, though.