8000 Fix possible integer overflow in multiplication by EnricoMi · Pull Request #3368 · horovod/horovod · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix possible integer overflow in multiplication #3368

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

Merged
merged 1 commit into from
Jan 14, 2022
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
2 changes: 1 addition & 1 deletion horovod/common/controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ int64_t Controller::TensorFusionThresholdBytes() {
// Ensuring that fusion buffer can hold a number of elements divisible by
// FUSION_BUFFER_ATOMIC_UNIT for performance
int double_size = GetTypeSize(HOROVOD_FLOAT64);
int64_t div = local_size_ * double_size * FUSION_BUFFER_ATOMIC_UNIT;
int64_t div = (int64_t)local_size_ * (int64_t)double_size * FUSION_BUFFER_ATOMIC_UNIT;
return ((proposed_fusion_threshold + div - 1) / div) * div;
}
return proposed_fusion_threshold;
Expand Down
8 changes: 4 additions & 4 deletions horovod/common/ops/adasum/adasum.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ template <typename Communicator_type> class Adasum {
nghrCountVec_index++;

this->PointToPointSendRecv(
(char*)(&grad_buffer[sendOffset]), nghrCount * per_element_size,
(char*)(&recv_buffer[recvOffset]), myCount * per_element_size,
(char*)(&grad_buffer[sendOffset]), (int64_t)nghrCount * (int64_t)per_element_size,
(char*)(&recv_buffer[recvOffset]), (int64_t)myCount * (int64_t)per_element_size,
horovod_datatype, neighbor_rank, tag, communicator, global_state);
if ((rank & level) != 0) {
grad_buffer = &grad_buffer[nghrCount];
Expand Down Expand Up @@ -329,8 +329,8 @@ template <typename Communicator_type> class Adasum {
} else {
recv_buffer = &grad_buffer[-nghrCount];
}
this->PointToPointSendRecv(grad_buffer, myCount * per_element_size,
recv_buffer, nghrCount * per_element_size,
this->PointToPointSendRecv(grad_buffer, (int64_t)myCount * (int64_t)per_element_size,
recv_buffer, (int64_t)nghrCount * (int64_t)per_element_size,
horovod_datatype, neighbor_rank, tag,
communicator, global_state);
if ((rank & level) != 0) {
Expand Down
2 changes: 1 addition & 1 deletion horovod/common/ops/collective_operations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void AllgatherOp::MemcpyInFusionBuffer(

auto& process_set =
global_state_->process_set_table.Get(first_entry.process_set_id);
int64_t offset = displcmnts[process_set.controller->GetRank()] * element_size;
int64_t offset = (int64_t)displcmnts[process_set.controller->GetRank()] * (int64_t)element_size;
for (auto& e : entries) {
void* buffer_data_at_offset = (uint8_t*)buffer_data + offset;
MemcpyEntryInFusionBuffer(entries, e, buffer_data_at_offset);
Expand Down
0