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

Use exceptions instead of exit(-1) #1594

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 6 additions & 8 deletions cpp/include/raft/neighbors/detail/cagra/graph_core.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,11 @@ void sort_knn_graph(raft::resources const& res,
constexpr int numElementsPerThread = 32;
kernel_sort = kern_sort<DataT, IdxT, numElementsPerThread>;
} else {
RAFT_LOG_ERROR(
"[ERROR] The degree of input knn graph is too large (%u). "
"It must be equal to or small than %d.\n",
RAFT_FAIL(
"The degree of input knn graph is too large (%u). "
"It must be equal to or smaller than %d.",
input_graph_degree,
1024);
exit(-1);
}
const auto block_size = 256;
const auto num_warps_per_block = block_size / raft::WarpSize;
Expand Down Expand Up @@ -394,12 +393,11 @@ void prune(raft::resources const& res,
if (input_graph_degree <= MAX_DEGREE) {
kernel_prune = kern_prune<MAX_DEGREE, IdxT>;
} else {
RAFT_LOG_ERROR(
"[ERROR] The degree of input knn graph is too large (%u). "
"It must be equal to or small than %d.\n",
RAFT_FAIL(
"The degree of input knn graph is too large (%u). "
"It must be equal to or smaller than %d.",
input_graph_degree,
1024);
exit(-1);
}
const uint32_t batch_size =
std::min(static_cast<uint32_t>(graph_size), static_cast<uint32_t>(256 * 1024));
Expand Down
4 changes: 1 addition & 3 deletions cpp/include/raft/neighbors/detail/cagra/search_plan.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,9 @@ struct search_plan_impl : public search_plan_impl_base {
hash_bitlen = 0;
break;
} else {
RAFT_LOG_DEBUG(
"[CAGRA Error]"
RAFT_FAIL(
"small-hash cannot be used because the required hash size exceeds the limit (%u)",
hashmap::get_size(max_bitlen));
exit(-1);
}
}
small_hash_bitlen = hash_bitlen;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,38 +871,36 @@ inline void _cuann_find_topk(uint32_t topK,
} while (0)

// V: vecLen
#define SET_KERNEL_V(V, ValT) \
do { \
if (topK <= 32) { \
SET_KERNEL_VKT(V, 32, 32, ValT); \
} else if (topK <= 64) { \
SET_KERNEL_VKT(V, 64, 32, ValT); \
} else if (topK <= 96) { \
SET_KERNEL_VKT(V, 96, 32, ValT); \
} else if (topK <= 128) { \
SET_KERNEL_VKT(V, 128, 32, ValT); \
} else if (topK <= 192) { \
SET_KERNEL_VKT(V, 192, 64, ValT); \
} else if (topK <= 256) { \
SET_KERNEL_VKT(V, 256, 64, ValT); \
} else if (topK <= 384) { \
SET_KERNEL_VKT(V, 384, 128, ValT); \
} else if (topK <= 512) { \
SET_KERNEL_VKT(V, 512, 128, ValT); \
} else if (topK <= 768) { \
SET_KERNEL_VKT(V, 768, 256, ValT); \
} else if (topK <= 1024) { \
SET_KERNEL_VKT(V, 1024, 256, ValT); \
#define SET_KERNEL_V(V, ValT) \
do { \
if (topK <= 32) { \
SET_KERNEL_VKT(V, 32, 32, ValT); \
} else if (topK <= 64) { \
SET_KERNEL_VKT(V, 64, 32, ValT); \
} else if (topK <= 96) { \
SET_KERNEL_VKT(V, 96, 32, ValT); \
} else if (topK <= 128) { \
SET_KERNEL_VKT(V, 128, 32, ValT); \
} else if (topK <= 192) { \
SET_KERNEL_VKT(V, 192, 64, ValT); \
} else if (topK <= 256) { \
SET_KERNEL_VKT(V, 256, 64, ValT); \
} else if (topK <= 384) { \
SET_KERNEL_VKT(V, 384, 128, ValT); \
} else if (topK <= 512) { \
SET_KERNEL_VKT(V, 512, 128, ValT); \
} else if (topK <= 768) { \
SET_KERNEL_VKT(V, 768, 256, ValT); \
} else if (topK <= 1024) { \
SET_KERNEL_VKT(V, 1024, 256, ValT); \
} \
/* else if (topK <= 1536) { SET_KERNEL_VKT(V, 1536, 512); } */ \
/* else if (topK <= 2048) { SET_KERNEL_VKT(V, 2048, 512); } */ \
/* else if (topK <= 3072) { SET_KERNEL_VKT(V, 3072, 1024); } */ \
/* else if (topK <= 4096) { SET_KERNEL_VKT(V, 4096, 1024); } */ \
else { \
RAFT_LOG_DEBUG( \
"[ERROR] (%s, %d) topk must be lower than or equla to 1024.\n", __func__, __LINE__); \
exit(-1); \
} \
else { \
RAFT_FAIL("topk must be lower than or equal to 1024"); \
} \
} while (0)

int _vecLen = _get_vecLen(ldIK, 2);
Expand Down