Skip to content

Commit

Permalink
fix some more warnings issued by MSVC, re #49
Browse files Browse the repository at this point in the history
  • Loading branch information
gentryx committed Feb 23, 2017
1 parent e83f081 commit 82cdcb2
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 42 deletions.
8 changes: 5 additions & 3 deletions src/examples/circle/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,21 @@ class CellToColor

void runSimulation()
{
int outputFrequency = 1;
int outputPeriod = 1;
CircleCellInitializer *init = new CircleCellInitializer();
SerialSimulator<CircleCell> sim(init);

sim.addWriter(
new PPMWriter<CircleCell>(
&CircleCell::state,
CellToColor(),
"./circle",
outputFrequency,
outputPeriod,
Coord<2>(8, 8)));

sim.addWriter(
new TracingWriter<CircleCell>(
1,
outputPeriod,
init->maxSteps()));

sim.run();
Expand Down
4 changes: 3 additions & 1 deletion src/libgeodecomp/geometry/region.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <libgeodecomp/geometry/topologies.h>
#include <libgeodecomp/misc/stdcontaineroverloads.h>
#include <libgeodecomp/storage/selector.h>
#include <cstddef>
#include <vector>

namespace LibGeoDecomp {

Expand Down Expand Up @@ -1301,7 +1303,7 @@ class Region

inline IndexVectorType::const_iterator indicesAt(std::size_t dim, std::size_t offset) const
{
return indices[dim].begin() + offset;
return indices[dim].begin() + std::ptrdiff_t(offset);
}

inline IndexVectorType::const_iterator indicesBegin(std::size_t dim) const
Expand Down
4 changes: 2 additions & 2 deletions src/libgeodecomp/io/initializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Initializer : public AdjacencyManufacturer<APITraits::SelectTopology<CELL>
* is assumed to be a neighbor of n_1, iff there is a directed
* edge (n_1, n_2) in the adjacency list of the unstructured grid.
*/
AdjacencyPtr getAdjacency(const Region<DIM>& region) const
AdjacencyPtr getAdjacency(const Region<DIM>& /* region */) const
{
checkTopologyIfAdjacencyIsNeeded(Topology());
return AdjacencyPtr();
Expand Down Expand Up @@ -135,7 +135,7 @@ class Initializer : public AdjacencyManufacturer<APITraits::SelectTopology<CELL>
* is the opposite of the direction in the original unstructured
* grid. See UnstructuredTestInitializer for an example.
*/
SharedPtr<Adjacency>::Type getReverseAdjacency(const Region<DIM>& region) const
SharedPtr<Adjacency>::Type getReverseAdjacency(const Region<DIM>& /* region */) const
{
return makeShared<Adjacency>(new RegionBasedAdjacency());
}
Expand Down
2 changes: 1 addition & 1 deletion src/libgeodecomp/loadbalancer/noopbalancer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace LibGeoDecomp {
class NoOpBalancer : public LoadBalancer
{
public:
virtual WeightVec balance(const WeightVec& weights, const LoadVec& relativeLoads)
virtual WeightVec balance(const WeightVec& weights, const LoadVec& /* relativeLoads */)
{
return weights;
}
Expand Down
4 changes: 2 additions & 2 deletions src/libgeodecomp/misc/chronometer.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ namespace ChronometerHelpers {
class EventToString
{
public:
std::string operator()(int id)
std::string operator()(std::size_t id)
{
switch(id) {
case 0:
Expand Down Expand Up @@ -266,7 +266,7 @@ class Chronometer

}

double interval(int i) const
double interval(std::size_t i) const
{
return totalTimes[i];
}
Expand Down
4 changes: 2 additions & 2 deletions src/libgeodecomp/storage/grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Grid : public GridBase<CELL_TYPE, TOPOLOGY::DIM>
const CELL_TYPE& defaultCell = CELL_TYPE(),
const CELL_TYPE& edgeCell = CELL_TYPE()) :
dimensions(dim),
cellVector(dim.prod(), defaultCell),
cellVector(std::size_t(dim.prod()), defaultCell),
edgeCell(edgeCell)
{}

Expand Down Expand Up @@ -78,7 +78,7 @@ class Grid : public GridBase<CELL_TYPE, TOPOLOGY::DIM>
inline void resize(const Coord<DIM>& newDim)
{
dimensions = newDim;
cellVector.resize(newDim.prod());
cellVector.resize(std::size_t(newDim.prod()));
}

/**
Expand Down
22 changes: 17 additions & 5 deletions src/libgeodecomp/storage/gridbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class LoadSaveRegionCharInterface
* This will typically be implemented by grids with Struct of
* Arrays (SoA) layout.
*/
virtual void saveRegion(std::vector<char> *buffer, const Region<DIM>& region, const Coord<DIM>& offset = Coord<DIM>()) const
virtual void saveRegion(
std::vector<char> */* buffer */,
const Region<DIM>& /* region */,
const Coord<DIM>& /* offset */ = Coord<DIM>()) const
{
throw std::logic_error("saveRegion not implemented for char buffers, not an SoA grid?");
}
Expand All @@ -38,7 +41,10 @@ class LoadSaveRegionCharInterface
* This will typically be implemented by grids with Struct of
* Arrays (SoA) layout.
*/
virtual void loadRegion(const std::vector<char>& buffer, const Region<DIM>& region, const Coord<DIM>& offset = Coord<DIM>())
virtual void loadRegion(
const std::vector<char>& /* buffer */,
const Region<DIM>& /* region */,
const Coord<DIM>& /* offset */ = Coord<DIM>())
{
throw std::logic_error("loadRegion not implemented for char buffers, not an SoA grid?");
}
Expand Down Expand Up @@ -148,7 +154,10 @@ class GridBase : GridBaseHelpers::LoadSaveRegionCharInterface<DIMENSIONS>
* (AoS) grids. SoA grids implement the variant that uses char
* buffers.
*/
virtual void saveRegion(std::vector<CELL> *buffer, const Region<DIM>& region, const Coord<DIM>& offset = Coord<DIM>()) const
virtual void saveRegion(
std::vector<CELL> * /* buffer */,
const Region<DIM>& /* region */,
const Coord<DIM>& /* offset */ = Coord<DIM>()) const
{
throw std::logic_error("loadRegion not implemented for buffers of type CELL, not an AoS grid?");
}
Expand All @@ -162,7 +171,10 @@ class GridBase : GridBaseHelpers::LoadSaveRegionCharInterface<DIMENSIONS>
* (AoS) grids. SoA grids implement the variant that uses char
* buffers.
*/
virtual void loadRegion(const std::vector<CELL>& buffer, const Region<DIM>& region, const Coord<DIM>& offset = Coord<DIM>())
virtual void loadRegion(
const std::vector<CELL>& /* buffer */,
const Region<DIM>& /* region */,
const Coord<DIM>& /* offset */ = Coord<DIM>())
{
throw std::logic_error("loadRegion not implemented for buffers of type CELL, not an AoS grid?");
}
Expand Down Expand Up @@ -252,7 +264,7 @@ class GridBase : GridBaseHelpers::LoadSaveRegionCharInterface<DIMENSIONS>
* Through this function the weights of the edges on unstructured
* grids can be set. Unavailable on regular grids.
*/
virtual void setWeights(std::size_t matrixID, const SparseMatrix& matrix)
virtual void setWeights(std::size_t /* matrixID */, const SparseMatrix& /* matrix*/)
{
throw std::logic_error("edge weights cannot be set on this grid type");
}
Expand Down
43 changes: 30 additions & 13 deletions src/libgeodecomp/storage/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,28 @@

namespace LibGeoDecomp {

namespace ImageHelpers {

void copy(
const Coord<2>& upperLeftSource,
const Image& source,
const Coord<2>& upperLeftTarget,
Image* target,
const unsigned width,
const unsigned height)
const int width,
const int height)
{
const Coord<2>& uls = upperLeftSource;
const Coord<2>& ult = upperLeftTarget;

CoordBox<2> sourceRect(
Coord<2>(0, 0),
Coord<2>(source.getDimensions().x(), source.getDimensions().y()));
CoordBox<2> targetRect(
Coord<2>(0, 0),
Coord<2>(target->getDimensions().x(), target->getDimensions().y()));

for (unsigned y = 0; y < height; y++) {
for (unsigned x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
Coord<2> cTarget = ult + Coord<2>(x, y);
Coord<2> cSource = uls + Coord<2>(x, y);

Expand All @@ -41,22 +44,30 @@ void copy(
}
}

}

Image Image::slice(
const Coord<2>& upperLeft,
const unsigned width,
const unsigned height)
const int width,
const int height)
{
Image ret(width, height);
copy(upperLeft, *this, Coord<2>(0,0), &ret, width, height);
ImageHelpers::copy(
upperLeft,
*this,
Coord<2>(0,0),
&ret,
width,
height);
return ret;
}


Image Image::slice(
const unsigned x,
const unsigned y,
const unsigned width,
const unsigned height)
const int x,
const int y,
const int width,
const int height)
{
return slice(Coord<2>(x, y), width, height);
}
Expand All @@ -66,8 +77,13 @@ void Image::paste(
const Coord<2>& upperLeft,
const Image& img)
{
copy(Coord<2>(0,0), img, upperLeft, this,
img.getDimensions().x(), img.getDimensions().y());
ImageHelpers::copy(
Coord<2>(0,0),
img,
upperLeft,
this,
img.getDimensions().x(),
img.getDimensions().y());
}


Expand All @@ -76,4 +92,5 @@ void Image::paste(const int x, const int y, const Image& img)
paste(Coord<2>(x, y), img);
}


}
32 changes: 19 additions & 13 deletions src/libgeodecomp/storage/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Image : public Grid<Color>
class IllegalCoordException {};

inline Image(
const unsigned width,
const unsigned height,
const int width,
const int height,
const Color col=Color()) :
Grid<Color>(Coord<2>(width, height), col)
{}
Expand All @@ -31,23 +31,29 @@ class Image : public Grid<Color>

Image slice(
const Coord<2>& upperLeft,
const unsigned width,
const unsigned height);
const int width,
const int height);

Image slice(
const unsigned x,
const unsigned y,
const unsigned width,
const unsigned height);
const int x,
const int y,
const int width,
const int height);

void paste(const Coord<2>& upperLeft, const Image& img);
void paste(
const Coord<2>& upperLeft,
const Image& img);

void paste(const int x, const int y, const Image& img);
void paste(
const int x,
const int y,
const Image& img);

inline void fillBox(
inline
void fillBox(
const Coord<2>& upperLeft,
const unsigned boxWidth,
const unsigned boxHeight,
const int boxWidth,
const int boxHeight,
const Color& col)
{
Coord<2> lowerRight = upperLeft + Coord<2>(boxWidth, boxHeight);
Expand Down

0 comments on commit 82cdcb2

Please sign in to comment.