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

[REVIEW] Remaining sparse semiring distances #261

Merged
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
5b28699
moving sparse dist optim to raft
divyegala Mar 18, 2021
8e841ac
bucketing bloom filter
divyegala Mar 24, 2021
efcf972
trying stuff
divyegala Mar 26, 2021
8f5cc26
dropping tpb as template in strategies
divyegala Mar 29, 2021
78aff5a
New distances
cjnolet Apr 1, 2021
9aa58f2
Uncommenting hash strategy
cjnolet Apr 1, 2021
cf57c9f
Udating hash strategy
cjnolet Apr 1, 2021
530dd87
Updating to add hash table and bloom strategies
cjnolet Apr 1, 2021
62b3df4
Updates
cjnolet Apr 1, 2021
28d6e2d
More updates
cjnolet Apr 2, 2021
c79ee7a
Updating hash strategy
cjnolet Apr 2, 2021
e5d93dd
Merge branch 'branch-0.19' into HEAD
cjnolet Apr 2, 2021
628b169
Updates
cjnolet Apr 7, 2021
fc708a9
Merge branch 'branch-0.19' into fea-020-sparse_spmv_optim
cjnolet Apr 7, 2021
d9ecc40
trying to merge chunking bug fixes
divyegala Apr 7, 2021
d299cb8
correcting int to value_idx
divyegala Apr 7, 2021
900ad8c
correction to expansion and start index
divyegala Apr 7, 2021
634bc99
Adding correlation distance
cjnolet Apr 7, 2021
82cdbe1
Baseline
cjnolet Apr 9, 2021
4e819c0
Enabling baseline
cjnolet Apr 9, 2021
6bd450f
Enabling optimized primitive
cjnolet Apr 9, 2021
f1c1d06
Fixing style
cjnolet Apr 19, 2021
219a813
Cleanup
cjnolet Apr 19, 2021
0fee984
Style
cjnolet Apr 19, 2021
b7105d7
Removing unecessary deltas
cjnolet Apr 20, 2021
e264514
Updating distances_config_t to use handle directly
cjnolet Apr 20, 2021
65f82bd
Merge branch 'branch-0.20' into semiring_primitives_optim_final
cjnolet May 4, 2021
2975fe3
Adding tests for newer distances
cjnolet May 4, 2021
0d064cc
NOrmalizing
cjnolet May 20, 2021
2057985
Separating new distances from optimizations
cjnolet May 21, 2021
3a669f5
Fixing style
cjnolet May 21, 2021
a415ebf
Merge branch 'branch-21.06' into semiring_primitives_optim_final
cjnolet May 21, 2021
99b4e14
Trying to get cuco working
cjnolet May 21, 2021
46c7d10
Removing dependencies.cmake
cjnolet May 21, 2021
ef9efa7
Raft is building all gpu archs. Checking this in the meantime
cjnolet May 21, 2021
a9d3608
changing cuo to dev branch
divyegala May 26, 2021
d613a77
working through build
divyegala Jun 7, 2021
2394084
fixing build
divyegala Jun 7, 2021
09b5b2c
Updating correlation
cjnolet Jun 7, 2021
339ae67
Merge branch 'semiring_primitives_optim_final' into semiring_primitiv…
cjnolet Jun 7, 2021
b40d7ce
Corr updates
cjnolet Jun 7, 2021
d0e0ea7
Yes! Correlation distance works!
cjnolet Jun 7, 2021
2d3855d
Adding russelrao dist
cjnolet Jun 7, 2021
69ff625
tests passing for all strategies
divyegala Jun 8, 2021
67562a0
Adding russelrao
cjnolet Jun 8, 2021
c43c496
Merge branch 'semiring_primitives_optim_final' into semiring_primitiv…
cjnolet Jun 8, 2021
149d67f
Getting tests to work for russellrao
cjnolet Jun 8, 2021
deb01b2
Adding hamming distance
cjnolet Jun 8, 2021
fad730a
Adding jensenshannon and kldivergence
cjnolet Jun 8, 2021
c97e8e4
Testing remaining distances
cjnolet Jun 8, 2021
7739d1f
integrating cuco changes and some small refactors
divyegala Jun 9, 2021
1098d89
merging upstream
divyegala Jun 9, 2021
a3e263b
removing thrust::device_vector usage because stream unsafe
divyegala Jun 15, 2021
b991081
Merge branch 'branch-21.08' of https://github.com/rapidsai/raft into …
divyegala Jun 15, 2021
6ef7a02
restructuring tests and addressing review related to tests
divyegala Jun 15, 2021
9b63fc8
addressing other review comments
divyegala Jun 15, 2021
a270833
Merge branch 'branch-21.08' of https://github.com/rapidsai/raft into …
divyegala Jun 15, 2021
cca6fa6
pointing back to dev cuco commit
divyegala Jun 23, 2021
6c2f707
Merge branch 'branch-21.08' of https://github.com/rapidsai/raft into …
divyegala Jun 23, 2021
ea597d6
removing print
divyegala Jun 23, 2021
318a95a
Merge remote-tracking branch 'divye/semiring_primitives_optim_final' …
cjnolet Jun 23, 2021
591f9f2
Merge branch 'branch-21.08' into semiring_primitive_additional_distances
cjnolet Jun 23, 2021
fc185e5
Additional consts needed
cjnolet Jun 24, 2021
924d8db
Using rmm::device_uvector
cjnolet Jul 7, 2021
72dd60e
More removal of device buffer
cjnolet Jul 7, 2021
cc59ad6
Merge branch 'branch-21.08' of github.com:rapidsai/raft into branch-2…
cjnolet Jul 8, 2021
1da9ef0
Merge branch 'branch-21.08' of github.com:rapidsai/raft into branch-2…
cjnolet Jul 12, 2021
6e68e40
Merge branch 'branch-21.08' into semiring_primitive_additional_distances
cjnolet Jul 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cpp/cmake/thirdparty/get_cuco.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function(find_and_configure_cuco VERSION)
rapids_cpm_find(cuco ${VERSION}
GLOBAL_TARGETS cuco cuco::cuco
CPM_ARGS
GIT_REPOSITORY https://github.com/NVIDIA/cuCollections.git
GIT_TAG 8fce363b40254f4170d97eaedcb12fc8e84e1b74
GIT_REPOSITORY https://github.com/divyegala/cuCollections.git
GIT_TAG view-initialization-ctor
cjnolet marked this conversation as resolved.
Show resolved Hide resolved
OPTIONS "BUILD_TESTS OFF"
"BUILD_BENCHMARKS OFF"
"BUILD_EXAMPLES OFF"
Expand Down
8 changes: 4 additions & 4 deletions cpp/include/raft/cudart_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,12 @@ void allocate(Type*& ptr, size_t len, bool setZero = false) {
}

/** helper method to get max usable shared mem per block parameter */
inline int getSharedMemPerBlock() {
__host__ __device__ inline int getSharedMemPerBlock() {
int devId;
CUDA_CHECK(cudaGetDevice(&devId));
cudaGetDevice(&devId);
int smemPerBlk;
CUDA_CHECK(cudaDeviceGetAttribute(&smemPerBlk,
cudaDevAttrMaxSharedMemoryPerBlock, devId));
cudaDeviceGetAttribute(&smemPerBlk, cudaDevAttrMaxSharedMemoryPerBlock,
devId);
return smemPerBlk;
}

Expand Down
10 changes: 8 additions & 2 deletions cpp/include/raft/linalg/distance_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ enum DistanceType : unsigned short {
Haversine = 13,
/** Bray-Curtis distance **/
BrayCurtis = 14,
/** Jensen-Shannon distance **/
/** Jensen-Shannon distance**/
JensenShannon = 15,
/** Hamming distance **/
HammingUnexpanded = 16,
/** KLDivergence **/
KLDivergence = 17,
/** RusselRao **/
RusselRaoExpanded = 18,
/** Dice-Sorensen distance **/
DiceExpanded = 16,
DiceExpanded = 19,
/** Precomputed (special value) **/
Precomputed = 100
};
Expand Down
21 changes: 12 additions & 9 deletions cpp/include/raft/sparse/distance/bin_distance.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ void compute_bin_distance(value_t *out, const value_idx *Q_coo_rows,
const value_t *Q_data, value_idx Q_nnz,
const value_idx *R_coo_rows, const value_t *R_data,
value_idx R_nnz, value_idx m, value_idx n,
cusparseHandle_t handle,
std::shared_ptr<raft::mr::device::allocator> alloc,
cudaStream_t stream, expansion_f expansion_func) {
raft::mr::device::buffer<value_t> Q_norms(alloc, stream, m);
Expand Down Expand Up @@ -114,7 +113,8 @@ class jaccard_expanded_distances_t : public distances_t<value_t> {
explicit jaccard_expanded_distances_t(
const distances_config_t<value_idx, value_t> &config)
: config_(&config),
workspace(config.allocator, config.stream, 0),
workspace(config.handle.get_device_allocator(),
config.handle.get_stream(), 0),
ip_dists(config) {}

void compute(value_t *out_dists) {
Expand All @@ -124,15 +124,16 @@ class jaccard_expanded_distances_t : public distances_t<value_t> {
value_t *b_data = ip_dists.b_data_coo();

raft::mr::device::buffer<value_idx> search_coo_rows(
config_->allocator, config_->stream, config_->a_nnz);
config_->handle.get_device_allocator(), config_->handle.get_stream(),
config_->a_nnz);
raft::sparse::convert::csr_to_coo(config_->a_indptr, config_->a_nrows,
search_coo_rows.data(), config_->a_nnz,
config_->stream);
config_->handle.get_stream());

compute_bin_distance(
out_dists, search_coo_rows.data(), config_->a_data, config_->a_nnz,
b_indices, b_data, config_->b_nnz, config_->a_nrows, config_->b_nrows,
config_->handle, config_->allocator, config_->stream,
config_->handle.get_device_allocator(), config_->handle.get_stream(),
[] __device__ __host__(value_t dot, value_t q_norm, value_t r_norm) {
value_t q_r_union = q_norm + r_norm;
value_t denom = q_r_union - dot;
Expand Down Expand Up @@ -163,7 +164,8 @@ class dice_expanded_distances_t : public distances_t<value_t> {
explicit dice_expanded_distances_t(
const distances_config_t<value_idx, value_t> &config)
: config_(&config),
workspace(config.allocator, config.stream, 0),
workspace(config.handle.get_device_allocator(),
config.handle.get_stream(), 0),
ip_dists(config) {}

void compute(value_t *out_dists) {
Expand All @@ -173,15 +175,16 @@ class dice_expanded_distances_t : public distances_t<value_t> {
value_t *b_data = ip_dists.b_data_coo();

raft::mr::device::buffer<value_idx> search_coo_rows(
config_->allocator, config_->stream, config_->a_nnz);
config_->handle.get_device_allocator(), config_->handle.get_stream(),
config_->a_nnz);
raft::sparse::convert::csr_to_coo(config_->a_indptr, config_->a_nrows,
search_coo_rows.data(), config_->a_nnz,
config_->stream);
config_->handle.get_stream());

compute_bin_distance(
out_dists, search_coo_rows.data(), config_->a_data, config_->a_nnz,
b_indices, b_data, config_->b_nnz, config_->a_nrows, config_->b_nrows,
config_->handle, config_->allocator, config_->stream,
config_->handle.get_device_allocator(), config_->handle.get_stream(),
[] __device__ __host__(value_t dot, value_t q_norm, value_t r_norm) {
value_t q_r_union = q_norm + r_norm;
value_t dice = (2 * dot) / q_r_union;
Expand Down
10 changes: 4 additions & 6 deletions cpp/include/raft/sparse/distance/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@

#pragma once

#include <cusparse_v2.h>
#include <raft/mr/device/allocator.hpp>
#include <raft/handle.hpp>

namespace raft {
namespace sparse {
namespace distance {

template <typename value_idx, typename value_t>
struct distances_config_t {
distances_config_t(raft::handle_t &handle_) : handle(handle_) {}

// left side
value_idx a_nrows;
value_idx a_ncols;
Expand All @@ -41,10 +42,7 @@ struct distances_config_t {
value_idx *b_indices;
value_t *b_data;

cusparseHandle_t handle;

std::shared_ptr<raft::mr::device::allocator> allocator;
cudaStream_t stream;
raft::handle_t &handle;
};

template <typename value_t>
Expand Down
Loading