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

Sanitize #1683

Merged
merged 4 commits into from
Aug 29, 2019
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 bindings/C/adios2/c/adios2_c_attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ adios2_error adios2_attribute_data(void *data, size_t *size,
*size = attributeCpp->m_Elements;
char **dataT = reinterpret_cast<char **>(data);

for (auto e = 0; e < *size; ++e)
for (size_t e = 0; e < *size; ++e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick comment: size is going to become a worse variable name in the future, as C++17 introduces std::size and using std::size has gotten into various popular C++ libraries. Whether there will actually be a conflict, I don't know.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NAThompson thanks for pointing this out. We need to be in the lookout for new language features.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NAThompson another reason to avoid using namespace std as in our coding guidelines

{
attributeCpp->m_DataArray[e].copy(
dataT[e], attributeCpp->m_DataArray[e].size());
Expand Down
3 changes: 1 addition & 2 deletions bindings/CXX11/adios2/cxx11/Attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ namespace adios2
} \
else \
{ \
return reinterpret_cast<std::vector<T> &>( \
m_Attribute->m_DataArray); \
return helper::NewVectorType<IOType, T>(m_Attribute->m_DataArray); \
} \
} \
\
Expand Down
2 changes: 1 addition & 1 deletion bindings/Fortran/f2c/adios2_f2c_variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void FC_GLOBAL(adios2_variable_shape_f2c,
return;
}

for (auto d = 0; d < ndims; ++d)
for (size_t d = 0; d < ndims; ++d)
{
shape[d] = static_cast<int64_t>(shapeC[d]);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/basics/globalArray/globalArray_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ int main(int argc, char *argv[])
// but Advance() will append steps to the same file.
adios2::Engine writer = io.Open("globalArray.bp", adios2::Mode::Write);

for (int step = 0; step < NSTEPS; step++)
for (size_t step = 0; step < NSTEPS; step++)
{
writer.BeginStep();

for (int i = 0; i < Nx; i++)
for (size_t i = 0; i < Nx; i++)
{
row[i] = step * Nx * nproc * 1.0 + rank * Nx * 1.0 + (double)i;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/heatTransfer/read/ReadSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ReadSettings::ReadSettings(int argc, char *argv[], int rank, int nproc)
npx = convertToUint("N", argv[4]);
npy = convertToUint("M", argv[5]);

if (npx * npy != this->nproc)
if (npx * npy != static_cast<unsigned int>(this->nproc))
{
throw std::invalid_argument("N*M must equal the number of processes");
}
Expand Down
4 changes: 2 additions & 2 deletions examples/heatTransfer/read/heatRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ void Compute(const std::vector<double> &Tin, std::vector<double> &Tout,
*/
if (firstStep)
{
for (int i = 0; i < dT.size(); i++)
for (size_t i = 0; i < dT.size(); ++i)
{
dT[i] = 0;
Tout[i] = Tin[i];
}
}
else
{
for (int i = 0; i < dT.size(); i++)
for (size_t i = 0; i < dT.size(); ++i)
{
dT[i] = Tout[i] - Tin[i];
Tout[i] = Tin[i];
Expand Down
6 changes: 3 additions & 3 deletions examples/heatTransfer/read_fileonly/PrintData.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ void printData(double *xy, T *size, T *offset, int rank, int steps)
myfile << " time row columns " << offset[1] << "..."
<< offset[1] + size[1] - 1 << std::endl;
myfile << " ";
for (int j = 0; j < size[1]; j++)
for (int j = 0; j < static_cast<int>(size[1]); j++)
{
myfile << std::setw(9) << offset[1] + j;
}
myfile << std::endl;
myfile << "------------------------------------------------------------"
"--\n";
for (int i = 0; i < size[0]; i++)
for (int i = 0; i < static_cast<int>(size[0]); i++)
{
myfile << std::setw(5) << step << std::setw(5) << offset[0] + i;
for (int j = 0; j < size[1]; j++)
for (int j = 0; j < static_cast<int>(size[1]); j++)
{
myfile << std::setw(9) << std::setprecision(2)
<< data[i * size[1] + j];
Expand Down
2 changes: 1 addition & 1 deletion examples/heatTransfer/write/IO.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class IO
int step = -1)
{
std::string name;
int ss = outputfile.size();
const size_t ss = outputfile.size();
if (rank == -1 && step == -1)
{
// add suffix if not present already
Expand Down
6 changes: 3 additions & 3 deletions examples/heatTransfer/write/IO_ascii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void IO::write(int step, const HeatTransfer &ht, const Settings &s,
out << " time row columns " << s.offsy << "..."
<< s.offsy + s.ndy - 1 << std::endl;
out << " ";
for (int j = 1; j <= s.ndy; ++j)
for (unsigned int j = 1; j <= s.ndy; ++j)
{
out << std::setw(9) << s.offsy + j - 1;
}
Expand All @@ -66,10 +66,10 @@ void IO::write(int step, const HeatTransfer &ht, const Settings &s,
}

out << std::fixed;
for (int i = 1; i <= s.ndx; ++i)
for (unsigned int i = 1; i <= s.ndx; ++i)
{
out << std::setw(5) << step << std::setw(5) << s.offsx + i - 1;
for (int j = 1; j <= s.ndy; ++j)
for (unsigned int j = 1; j <= s.ndy; ++j)
{
out << std::setw(9) << std::setprecision(5) << ht.T(i, j);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/hello/bpFWriteCRead/CppReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ int main(int argc, char *argv[])
bpReader.Close();

std::cout << "Selection size: " << bpData.SelectionSize() << "\n";
for (auto i = 0; i < bpData.Count()[0]; ++i)
for (size_t i = 0; i < bpData.Count()[0]; ++i)
{
for (auto j = 0; j < bpData.Count()[1]; ++j)
for (size_t j = 0; j < bpData.Count()[1]; ++j)
{
std::cout << data[i * bpData.Count()[1] + j] << " ";
}
Expand Down
4 changes: 2 additions & 2 deletions examples/hello/bpFWriteCRead/CppWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ int main(int argc, char *argv[])
const size_t ny = 3;
std::vector<float> data(nx * ny);

for (auto i = 0; i < nx; ++i)
for (size_t i = 0; i < nx; ++i)
{
for (auto j = 0; j < ny; ++j)
for (size_t j = 0; j < ny; ++j)
{
data[i * ny + j] = rank * nx * ny + i * ny + j;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/hello/bpReader/helloBPReaderHeatMap3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int main(int argc, char *argv[])
std::cout << "Temperature map selection: ";
std::cout << "{ start = [2,2,2], count = [4,4,4] }\n";

for (auto i = 0; i < inTemperatures.size(); ++i)
for (size_t i = 0; i < inTemperatures.size(); ++i)
{
std::cout << inTemperatures[i] << " ";
if ((i + 1) % inTemperature.Count().back() == 0)
Expand Down
5 changes: 2 additions & 3 deletions examples/hello/datamanReader/helloDataManP2PReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@ int main(int argc, char *argv[])
adios2::Engine dataManReader = dataManIO.Open("stream", adios2::Mode::Read);

// read data
size_t i = 0;
adios2::Variable<float> bpFloats;
auto start_time = std::chrono::system_clock::now();
adios2::StepStatus status;
for (int i = 0; i < steps; ++i)

for (size_t i = 0; i < steps; ++i)
{
status = dataManReader.BeginStep();
if (status == adios2::StepStatus::OK)
Expand Down
2 changes: 1 addition & 1 deletion examples/hello/datamanWriter/helloDataManP2PWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int main(int argc, char *argv[])
dataManIO.DefineVariable<float>("bpFloats", shape, start, count);

// write data
for (int i = 0; i < steps; ++i)
for (size_t i = 0; i < steps; ++i)
{
dataManWriter.BeginStep();
dataManWriter.Put<float>(bpFloats, myFloats.data(), adios2::Mode::Sync);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int main(int argc, char *argv[])
dataManIO.DefineVariable<float>("bpFloats", shape, start, count);

// write data
for (int i = 0; i < steps; ++i)
for (size_t i = 0; i < steps; ++i)
{
dataManWriter.BeginStep();
dataManWriter.Put<float>(bpFloats, myFloats.data(), adios2::Mode::Sync);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void DoAnalysis(adios2::IO &inlineIO, adios2::Engine &inlineReader, int rank,
{
adios2::Dims count = info.Count;
const float *vectData = info.Data();
for (int i = 0; i < count[0]; ++i)
for (size_t i = 0; i < count[0]; ++i)
{
float datum = vectData[i];
std::cout << datum << " ";
Expand Down
2 changes: 1 addition & 1 deletion examples/hello/insituMPI/HelloInsituArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ HelloInsituArgs::HelloInsituArgs(bool isWriter, int argc, char *argv[],
offsy = posy * ndy;
}

if (npx * npy != nproc)
if (npx * npy != static_cast<size_t>(nproc))
{
throw std::invalid_argument(
"N*M must equal the number of processes");
Expand Down
6 changes: 3 additions & 3 deletions examples/hello/insituMPI/HelloInsituPrint.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ void printDataStep(const float *data, const adios2::Dims &size,
myfile << " step row columns " << offset[1] << "..."
<< offset[1] + size[1] - 1 << std::endl;
myfile << " ";
for (int j = 0; j < size[1]; j++)
for (size_t j = 0; j < size[1]; j++)
{
myfile << std::setw(9) << offset[1] + j;
}
myfile << std::endl;
myfile << "------------------------------------------------------------"
"--\n";
for (int i = 0; i < size[0]; i++)
for (size_t i = 0; i < size[0]; i++)
{
myfile << std::setw(5) << step << std::setw(5) << offset[0] + i;
for (int j = 0; j < size[1]; j++)
for (size_t j = 0; j < size[1]; j++)
{
myfile << std::setw(9) << std::setprecision(5)
<< data[i * size[1] + j];
Expand Down
4 changes: 2 additions & 2 deletions examples/hello/skeleton/HelloSkeletonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ HelloSkeletonArgs::HelloSkeletonArgs(bool isWriter, int argc, char *argv[],
npx = npy = ndx = ndy = steps = sleeptime = 0;
gndx = gndy = posx = posy = offsx = offsy = 0;
int expargs = (isWriter ? 8 : 4);
this->nproc = (unsigned int)nproc;
this->nproc = static_cast<unsigned int>(nproc);

try
{
Expand Down Expand Up @@ -90,7 +90,7 @@ HelloSkeletonArgs::HelloSkeletonArgs(bool isWriter, int argc, char *argv[],
offsy = posy * ndy;
}

if (npx * npy != nproc)
if (npx * npy != static_cast<size_t>(nproc))
{
throw std::invalid_argument(
"N*M must equal the number of processes");
Expand Down
6 changes: 3 additions & 3 deletions examples/hello/skeleton/HelloSkeletonPrint.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ void printDataStep(const float *data, const adios2::Dims &size,
myfile << " step row columns " << offset[1] << "..."
<< offset[1] + size[1] - 1 << std::endl;
myfile << " ";
for (int j = 0; j < size[1]; j++)
for (size_t j = 0; j < size[1]; j++)
{
myfile << std::setw(9) << offset[1] + j;
}
myfile << std::endl;
myfile << "------------------------------------------------------------"
"--\n";
for (int i = 0; i < size[0]; i++)
for (size_t i = 0; i < size[0]; i++)
{
myfile << std::setw(5) << step << std::setw(5) << offset[0] + i;
for (int j = 0; j < size[1]; j++)
for (size_t j = 0; j < size[1]; j++)
{
myfile << std::setw(9) << std::setprecision(4)
<< data[i * size[1] + j];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ typedef struct
std::string DimsToString(adios2::Dims &dims)
{
std::string s = "\"";
for (int i = 0; i < dims.size(); i++)
for (size_t i = 0; i < dims.size(); i++)
{
if (i > 0)
{
Expand All @@ -66,7 +66,8 @@ void ProcessVariableMetadata(int rank, const std::string &name,
for (auto &block : blocks)
{
/* offset in first dimension is encoding writer's rank */
if (block.Start.size() > 0 && block.Start[0] == rank)
if (block.Start.size() > 0 &&
block.Start[0] == static_cast<size_t>(rank))
{
/*std::cout << " Rank " << rank << " Variable '" << name
<< "' found a block dimensions = "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int main(int argc, char *argv[])
#endif

const size_t maxProc = VarTree.size();
if (nproc > maxProc)
if (static_cast<size_t>(nproc) > maxProc)
{
if (!rank)
{
Expand Down Expand Up @@ -143,7 +143,7 @@ int main(int argc, char *argv[])
const size_t nvars = VarTree[rank].size();
// A 1D array for each variable
std::vector<std::vector<double>> Vars(nvars);
for (int i = 0; i < nvars; i++)
for (size_t i = 0; i < nvars; i++)
{
Vars[i].resize(SizesTree[rank][i]);
}
Expand All @@ -160,7 +160,7 @@ int main(int argc, char *argv[])
io.AddTransport(t.first, t.second);
}

for (int i = 0; i < nvars; i++)
for (size_t i = 0; i < nvars; i++)
{
size_t nelems = SizesTree[rank][i];
Vars[i].resize(nelems);
Expand All @@ -170,14 +170,14 @@ int main(int argc, char *argv[])

adios2::Engine writer = io.Open("output.bp", adios2::Mode::Write);

for (int step = 0; step < NSTEPS; step++)
for (size_t step = 0; step < NSTEPS; step++)
{
writer.BeginStep();

for (int i = 0; i < nvars; i++)
for (size_t i = 0; i < nvars; i++)
{
size_t nelems = SizesTree[rank][i];
for (int j = 0; j < nelems; j++)
for (size_t j = 0; j < nelems; j++)
{
Vars[i][j] = ((double)step + 1.0) / 100.0 + (double)rank;
}
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/engine/insitumpi/InSituMPIFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ std::vector<MPI_Status> CompleteRequests(std::vector<MPI_Request> &requests,

if (ierr == MPI_ERR_IN_STATUS)
{
for (auto i = 0; i < requests.size(); i++)
for (size_t i = 0; i < requests.size(); i++)
{
if (statuses[i].MPI_ERROR == MPI_ERR_PENDING)
{
Expand Down
4 changes: 3 additions & 1 deletion source/adios2/engine/insitumpi/InSituMPISchedules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,13 @@ void PrintBox(const Box<size_t> &box) noexcept
void PrintDims(const Dims &dims) noexcept
{
std::cout << "{";
for (int i = 0; i < dims.size(); i++)
for (size_t i = 0; i < dims.size(); i++)
{
std::cout << dims[i];
if (i < dims.size() - 1)
{
std::cout << ",";
}
}
std::cout << "}";
}
Expand Down
8 changes: 4 additions & 4 deletions source/adios2/helper/adiosMath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Box<Dims> IntersectionStartCount(const Dims &start1, const Dims &count1,
Box<Dims> intersectionStartCount;
const size_t dimensionsSize = start1.size();

for (auto d = 0; d < dimensionsSize; ++d)
for (size_t d = 0; d < dimensionsSize; ++d)
{
// Don't intercept
const size_t end1 = start1[d] + count1[d] - 1;
Expand All @@ -165,7 +165,7 @@ Box<Dims> IntersectionStartCount(const Dims &start1, const Dims &count1,
intersectionStartCount.first.reserve(dimensionsSize);
intersectionStartCount.second.reserve(dimensionsSize);

for (auto d = 0; d < dimensionsSize; ++d)
for (size_t d = 0; d < dimensionsSize; ++d)
{
const size_t intersectionStart =
(start1[d] < start2[d]) ? start2[d] : start1[d];
Expand Down Expand Up @@ -226,7 +226,7 @@ bool IsIntersectionContiguousSubarray(const Box<Dims> &blockBox,
dSlowest = static_cast<int>(dimensionsSize - 1);
}

for (size_t d = dStart; d <= dEnd; ++d)
for (int d = dStart; d <= dEnd; ++d)
{
if (blockBox.first[d] != intersectionBox.first[d] ||
blockBox.second[d] != intersectionBox.second[d])
Expand Down Expand Up @@ -263,7 +263,7 @@ size_t LinearIndex(const Dims &start, const Dims &count, const Dims &point,
size_t linearIndex = normalizedPoint[0]; // fastest
size_t product = 1;

for (auto p = 1; p < countSize; ++p)
for (size_t p = 1; p < countSize; ++p)
{
product *= count[p - 1];
linearIndex += normalizedPoint[p] * product;
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/helper/adiosMath.inl
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void GetMinMaxComplex(const std::complex<T> *values, const size_t size,
T minNorm = std::norm(values[0]);
T maxNorm = minNorm;

for (auto i = 1; i < size; ++i)
for (size_t i = 1; i < size; ++i)
{
T norm = std::norm(values[i]);

Expand Down
Loading