Skip to content

Commit 882d809

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Fix shadowed variable in gloo/alltoallv.cc
Summary: Our upcoming compiler upgrade will require us not to have shadowed variables. Such variables have a _high_ bug rate and reduce readability, so we would like to avoid them even if the compiler was not forcing us to do so. This codemod attempts to fix an instance of a shadowed variable. Please review with care: if it's failed the result will be a silent bug. **What's a shadowed variable?** Shadowed variables are variables in an inner scope with the same name as another variable in an outer scope. Having the same name for both variables might be semantically correct, but it can make the code confusing to read! It can also hide subtle bugs. This diff fixes such an issue by renaming the variable. - If you approve of this diff, please use the "Accept & Ship" button :-) Reviewed By: dmm-fb Differential Revision: D52959036 fbshipit-source-id: ce16eb7d7c260dd85cd2efb4012a94376bd3bd3f
1 parent 90782f9 commit 882d809

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

gloo/alltoallv.cc

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,75 +45,75 @@ void AlltoallvOptions::setElementSize(size_t elementSize_2) {
4545
void AlltoallvOptions::setInput(
4646
std::unique_ptr<transport::UnboundBuffer> buf,
4747
std::vector<int64_t> elementsPerRank,
48-
size_t elementSize) {
48+
size_t elementSize_2) {
4949
const auto totalElements = std::accumulate(
5050
elementsPerRank.begin(), elementsPerRank.end(), size_t(0));
51-
this->setElementSize(elementSize);
51+
this->setElementSize(elementSize_2);
5252
GLOO_ENFORCE_EQ(elementsPerRank.size(), context->size);
5353
this->inOffsetPerRank.reserve(elementsPerRank.size());
5454
this->inLengthPerRank.reserve(elementsPerRank.size());
5555
splitOffsetsAndLengths(
5656
elementsPerRank,
57-
elementSize,
57+
elementSize_2,
5858
this->inOffsetPerRank,
5959
this->inLengthPerRank);
60-
GLOO_ENFORCE_EQ(totalElements * elementSize, buf->size);
60+
GLOO_ENFORCE_EQ(totalElements * elementSize_2, buf->size);
6161
this->in = std::move(buf);
6262
}
6363

6464
void AlltoallvOptions::setInput(
6565
void* ptr,
6666
std::vector<int64_t> elementsPerRank,
67-
size_t elementSize) {
67+
size_t elementSize_2) {
6868
const auto totalElements = std::accumulate(
6969
elementsPerRank.begin(), elementsPerRank.end(), size_t(0));
70-
this->setElementSize(elementSize);
70+
this->setElementSize(elementSize_2);
7171
GLOO_ENFORCE_EQ(elementsPerRank.size(), context->size);
7272
this->inOffsetPerRank.reserve(elementsPerRank.size());
7373
this->inLengthPerRank.reserve(elementsPerRank.size());
7474
splitOffsetsAndLengths(
7575
elementsPerRank,
76-
elementSize,
76+
elementSize_2,
7777
this->inOffsetPerRank,
7878
this->inLengthPerRank);
79-
this->in = context->createUnboundBuffer(ptr, totalElements * elementSize);
79+
this->in = context->createUnboundBuffer(ptr, totalElements * elementSize_2);
8080
}
8181

8282
void AlltoallvOptions::setOutput(
8383
std::unique_ptr<transport::UnboundBuffer> buf,
8484
std::vector<int64_t> elementsPerRank,
85-
size_t elementSize) {
85+
size_t elementSize_2) {
8686
const auto totalElements = std::accumulate(
8787
elementsPerRank.begin(), elementsPerRank.end(), size_t(0));
88-
this->setElementSize(elementSize);
88+
this->setElementSize(elementSize_2);
8989
GLOO_ENFORCE_EQ(elementsPerRank.size(), context->size);
9090
this->outOffsetPerRank.reserve(elementsPerRank.size());
9191
this->outLengthPerRank.reserve(elementsPerRank.size());
9292
splitOffsetsAndLengths(
9393
elementsPerRank,
94-
elementSize,
94+
elementSize_2,
9595
this->outOffsetPerRank,
9696
this->outLengthPerRank);
97-
GLOO_ENFORCE_EQ(totalElements * elementSize, buf->size);
97+
GLOO_ENFORCE_EQ(totalElements * elementSize_2, buf->size);
9898
this->out = std::move(buf);
9999
}
100100

101101
void AlltoallvOptions::setOutput(
102102
void* ptr,
103103
std::vector<int64_t> elementsPerRank,
104-
size_t elementSize) {
104+
size_t elementSize_2) {
105105
const auto totalElements = std::accumulate(
106106
elementsPerRank.begin(), elementsPerRank.end(), size_t(0));
107-
this->setElementSize(elementSize);
107+
this->setElementSize(elementSize_2);
108108
GLOO_ENFORCE_EQ(elementsPerRank.size(), context->size);
109109
this->outOffsetPerRank.reserve(elementsPerRank.size());
110110
this->outLengthPerRank.reserve(elementsPerRank.size());
111111
splitOffsetsAndLengths(
112112
elementsPerRank,
113-
elementSize,
113+
elementSize_2,
114114
this->outOffsetPerRank,
115115
this->outLengthPerRank);
116-
this->out = context->createUnboundBuffer(ptr, totalElements * elementSize);
116+
this->out = context->createUnboundBuffer(ptr, totalElements * elementSize_2);
117117
}
118118

119119
void alltoallv(AlltoallvOptions& opts) {

0 commit comments

Comments
 (0)