enabled most warnings on gcc, and fixed them

This commit is contained in:
Frank Seide 2018-11-05 20:21:50 -08:00
parent cf09776141
commit fca0510133
28 changed files with 110 additions and 47 deletions

View File

@ -38,10 +38,10 @@ if(MSVC)
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /LTCG:incremental")
else()
set(CMAKE_CXX_FLAGS_RELEASE " -std=c++11 -O3 -Ofast -m64 -pthread -march=${BUILD_ARCH} -msse4.1 -Wl,--no-as-needed -funroll-loops -ffinite-math-only -fPIC -Wno-unused-result -Wno-deprecated -Wno-deprecated-gpu-targets -Wsuggest-override -Werror")
set(CMAKE_CXX_FLAGS_RELEASE " -std=c++11 -O3 -Ofast -m64 -pthread -march=${BUILD_ARCH} -msse4.1 -Wl,--no-as-needed -funroll-loops -ffinite-math-only -fPIC -Wno-unused-result -Wno-deprecated -Werror -Wno-pragmas")
set(CMAKE_CXX_FLAGS_DEBUG " -std=c++11 -g -rdynamic -O0 -pthread -fPIC -Wno-unused-result -Wno-deprecated -Wno-deprecated-gpu-targets -Wsuggest-override -Werror")
set(CMAKE_CXX_FLAGS_ST "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -pg -g -rdynamic")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -pg -g -rdynamic -Wall -Wextra -Wsuggest-override -Wno-unused-value -Wno-unknown-pragmas -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-variable")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -pg -g -rdynamic")
set(CMAKE_CXX_FLAGS_PROFGEN "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-generate -fprofile-correction")
set(CMAKE_CXX_FLAGS_PROFUSE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-use -fprofile-correction")

View File

@ -13,7 +13,8 @@
char cnpy::BigEndianTest() {
unsigned char x[] = {1,0};
short y = *(short*) x;
short y;
memcpy(&y, x, sizeof(y));
return y == 1 ? '<' : '>';
}

View File

@ -106,7 +106,7 @@ class ThreadPool {
// the constructor just launches some amount of workers
inline ThreadPool::ThreadPool(size_t threads, size_t in_bound)
: stop(false), bound(in_bound) {
: bound(in_bound), stop(false) {
reserve(threads);
}

View File

@ -20,8 +20,8 @@ namespace cli {
//
// TODO: make use of it in the current CLI or remove. This is an old code used
// for boost::program_options and might not be needed anymore.
static uint16_t guess_terminal_width(uint16_t max_width = 0,
uint16_t default_width = 180);
//static uint16_t guess_terminal_width(uint16_t max_width = 0,
// uint16_t default_width = 180);
// TODO: use validators in ConfigParser
namespace validators {

View File

@ -19,6 +19,7 @@
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include <boost/iostreams/filtering_stream.hpp>
#ifdef __GNUC__

View File

@ -7,6 +7,7 @@
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsuggest-override"
#endif
#include <boost/filesystem.hpp>

View File

@ -133,9 +133,9 @@ static void setErrorHandlers() {
struct sigaction sa = { 0 };
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = [](int signal, siginfo_t *si, void *arg) { ABORT("Segmentation fault"); };
sa.sa_sigaction = [](int /*signal*/, siginfo_t*, void*) { ABORT("Segmentation fault"); };
sigaction(SIGSEGV, &sa, NULL);
sa.sa_sigaction = [](int signal, siginfo_t *si, void *arg) { ABORT("Floating-point exception"); };
sa.sa_sigaction = [](int /*signal*/, siginfo_t*, void*) { ABORT("Floating-point exception"); };
sigaction(SIGFPE, &sa, NULL);
#endif
}

View File

@ -133,7 +133,7 @@ Ptr<VocabBase> createSentencePieceVocab(const std::string& vocabPath, Ptr<Option
#ifdef USE_SENTENCEPIECE
return New<SentencePieceVocab>(options, batchIndex);
#else
batchIndex;
batchIndex; options;
ABORT("*.spm suffix in path {} reserved for SentencePiece models, "
"but support for SentencePiece is not compiled into Marian. "
"Try to recompile after `cmake .. -DUSE_SENTENCEPIECE=on [...]`",

View File

@ -288,7 +288,7 @@ public:
}
}
Ptr<Shortlist> generate(Ptr<data::CorpusBatch> batch) override {
Ptr<Shortlist> generate(Ptr<data::CorpusBatch> /*batch*/) override {
std::vector<Word> tmp;
return New<Shortlist>(idx_, tmp, reverseIdx_);
}

4
src/examples/mnist/dataset.h Normal file → Executable file
View File

@ -135,7 +135,7 @@ private:
public:
MNISTData(std::vector<std::string> paths,
std::vector<Ptr<Vocab>> vocabs = {},
std::vector<Ptr<Vocab>> /*vocabs*/ = {},
Ptr<Config> options = nullptr)
: Dataset(paths, options), IMAGE_MAGIC_NUMBER(2051), LABEL_MAGIC_NUMBER(2049) {
loadData();
@ -154,7 +154,7 @@ public:
}
}
Example next() override {}
Example next() override { return{ }; } //@TODO: this return was added to fix a warning. Is it correct?
private:
typedef unsigned char uchar;

14
src/examples/mnist/model.h Normal file → Executable file
View File

@ -58,24 +58,24 @@ public:
virtual Expr build(Ptr<ExpressionGraph> graph,
Ptr<data::Batch> batch,
bool clean = false) override {
bool /*clean*/ = false) override {
return construct(graph, batch, inference_);
}
void load(Ptr<ExpressionGraph> graph, const std::string& name, bool) override {
void load(Ptr<ExpressionGraph> /*graph*/, const std::string& /*name*/, bool) override {
LOG(critical, "Loading MNIST model is not supported");
}
void save(Ptr<ExpressionGraph> graph, const std::string& name, bool) override {
void save(Ptr<ExpressionGraph> /*graph*/, const std::string& /*name*/, bool) override {
LOG(critical, "Saving MNIST model is not supported");
}
void save(Ptr<ExpressionGraph> graph, const std::string& name) {
void save(Ptr<ExpressionGraph> /*graph*/, const std::string& /*name*/) {
LOG(critical, "Saving MNIST model is not supported");
}
Ptr<data::BatchStats> collectStats(Ptr<ExpressionGraph> graph,
size_t multiplier) {
Ptr<data::BatchStats> collectStats(Ptr<ExpressionGraph> /*graph*/,
size_t /*multiplier*/) {
LOG(critical, "Collecting stats in MNIST model is not supported");
return nullptr;
}
@ -98,7 +98,7 @@ protected:
*/
virtual Expr construct(Ptr<ExpressionGraph> g,
Ptr<data::Batch> batch,
bool inference = false) {
bool /*inference*/ = false) {
const std::vector<int> dims = {784, 2048, 2048, 10};
// Start with an empty expression graph

2
src/graph/expression_graph.cpp Normal file → Executable file
View File

@ -25,7 +25,7 @@ Expr ExpressionGraph::dropout(float prob, const Shape& shape) {
}
void ExpressionGraph::checkNan(Tensor t) {
ABORT_IF(throwNaN_, "Not implemented");
ABORT_IF(throwNaN_, "Not implemented"); t;
// ABORT_IF(throwNaN_ && IsNan(t), "Tensor has NaN");
}

View File

@ -35,7 +35,7 @@ NodeInitializer dropout(float prob);
void gumbel(Tensor t);
static inline void dummy(Tensor t) {}
static inline void dummy(Tensor) {}
NodeInitializer from_vector(const std::vector<float>& v);
NodeInitializer from_vector(const std::vector<IndexType>& v);

6
src/layers/weight.h Normal file → Executable file
View File

@ -14,9 +14,9 @@ public:
virtual Expr getWeights(Ptr<ExpressionGraph> graph,
Ptr<data::CorpusBatch> batch)
= 0;
virtual void debugWeighting(std::vector<float> weightedMask,
std::vector<float> freqMask,
Ptr<data::CorpusBatch> batch){};
virtual void debugWeighting(std::vector<float> /*weightedMask*/,
std::vector<float> /*freqMask*/,
Ptr<data::CorpusBatch> /*batch*/){};
};
class DataWeighting : public WeightingBase {

View File

@ -97,6 +97,6 @@ public:
// Set current target token position in state when decoding
void setPosition(size_t position) { position_ = position; }
virtual void blacklist(Expr totalCosts, Ptr<data::CorpusBatch> batch) {}
virtual void blacklist(Expr /*totalCosts*/, Ptr<data::CorpusBatch> /*batch*/) {}
};
} // namespace marian

View File

@ -200,7 +200,7 @@ public:
// determine the multiplicative-attention probability and performs the associative lookup as well
// q, k, and v have already been split into multiple heads, undergone any desired linear transform.
Expr Attention(std::string prefix,
Expr Attention(std::string /*prefix*/,
Expr q, // [-4: beam depth * batch size, -3: num heads, -2: max tgt length, -1: split vector dim]
Expr k, // [-4: batch size, -3: num heads, -2: max src length, -1: split vector dim]
Expr v, // [-4: batch size, -3: num heads, -2: max src length, -1: split vector dim]
@ -444,7 +444,7 @@ public:
const rnn::State& prevDecoderState,
std::string prefix,
Expr input,
Expr selfMask,
Expr /*selfMask*/,
int /*startPos*/) const {
float dropoutRnn = inference_ ? 0.f : opt<float>("dropout-rnn");
@ -609,7 +609,7 @@ private:
Ptr<mlp::MLP> output_;
private:
void LazyCreateOutputLayer(std::string prefix)
void LazyCreateOutputLayer()
{
if(output_) // create it lazily
return;
@ -667,7 +667,7 @@ public:
virtual Ptr<DecoderState> step(Ptr<ExpressionGraph> graph,
Ptr<DecoderState> state) override {
ABORT_IF(graph != graph_, "An inconsistent graph parameter was passed to step().");
LazyCreateOutputLayer(prefix_ + "_ff_logit_out");
LazyCreateOutputLayer();
return step(state);
}

2
src/rnn/constructors.h Normal file → Executable file
View File

@ -92,7 +92,7 @@ public:
}
virtual void add_input(Expr input) {
inputs_.push_back([input](Ptr<rnn::RNN> rnn) { return input; });
inputs_.push_back([input](Ptr<rnn::RNN> /*rnn*/) { return input; });
}
};

View File

@ -92,6 +92,7 @@ void Prod(marian::Tensor C,
C->data(),
ldc);
#else
C; A; B; transA; transB; beta; scalar;
ABORT("You need to compile with MKL in order to use the CPU version");
#endif
}
@ -148,6 +149,7 @@ void ProdBatched(marian::Tensor C,
(int)ldc);
}
#else
C; allocator; A; B; transA; transB; beta; scalar;
ABORT("You need to compile with MKL in order to use the CPU version");
#endif
}

View File

@ -148,16 +148,21 @@ public:
#pragma warning(disable: 4100) // unreferenced formal parameter
// most functions are no-ops when applied to a single process
virtual void barrier(MPI_Comm comm) const override {
comm;
}
virtual void bCast(void* buf, size_t count, MPI_Datatype datatype, size_t rootRank, MPI_Comm comm) const override {
buf; count; datatype; rootRank; comm;
}
virtual void sSend(void* buf, size_t count, MPI_Datatype datatype, size_t destRank, int tag, MPI_Comm comm) const override {
buf; count; datatype; destRank; tag; comm;
}
virtual void recv(void* buf, size_t count, MPI_Datatype datatype, size_t sourceRank, int tag, MPI_Comm comm, MPI_Status* status) const override {
buf; count; datatype; sourceRank; tag; comm;
// @TODO: fill in status
ABORT_IF(status != MPI_STATUS_IGNORE, "FakeMPIWrapper::recv() does not yet implement returning a status object");
}
virtual void allReduce(const void* sendbuf, void* recvbuf, size_t count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) const override {
count; datatype; op; comm;
// @TODO: There is only one place where this is called with sendbuf != recvbuf, which is sync multi-node.
// I think that can be changed to use the same buffer. Then we should change this API
// to only accept one parameter, and remove this error check can be removed.

View File

@ -126,8 +126,8 @@ public:
comms_(graphs.size()),
streams_(graphs.size()),
devices_(graphs.size()),
threadPool_(graphs.size(), graphs.size()), threadResults_(graphs.size()),
mpi_(mpi) {
mpi_(mpi),
threadPool_(graphs.size(), graphs.size()), threadResults_(graphs.size()) {
mpiBarrier(); // barrier to group the multiple log messages from MPI processes
LOG(info, "[comm] Using NCCL {} {}for GPU communication",
ncclVersionString(),

View File

@ -34,7 +34,7 @@ class SparseTensorBase : public std::enable_shared_from_this<SparseTensorBase> {
public:
SparseTensorBase(int capacity, Ptr<Backend> backend)
: backend_(backend), capacity_(capacity) {
: capacity_(capacity), backend_(backend) {
data_ = newData<float>(capacity, backend);
indices_ = newData<int>(capacity, backend);
}

View File

@ -106,8 +106,10 @@ void AsyncGraphGroupDrop::init(Ptr<data::Batch> batch) {
// prepare droppers
std::vector<GradientDrop> tmpDropper;
for(auto device : devices_)
for(auto device : devices_) {
device; // @TODO: 'device' is not used. Is this nested loop correct?
tmpDropper.push_back(PrepareGradientDrop(graphs_[i]->getDeviceId()));
}
droppers_.push_back(tmpDropper);
// sparsetensor to store sparsified gradients per-device per-shard

View File

@ -32,8 +32,8 @@ protected:
public:
AsyncGraphGroupDrop(Ptr<Config> options)
: AsyncGraphGroup(options),
dropping_warmup{options->get<size_t>("grad-dropping-warmup")},
droping_rate{options->get<float>("grad-dropping-rate")},
dropping_momentum{options->get<float>("grad-dropping-momentum")},
dropping_warmup{options->get<size_t>("grad-dropping-warmup")} {}
dropping_momentum{options->get<float>("grad-dropping-momentum")} {}
};
} // namespace marian

View File

@ -269,7 +269,7 @@ void MultiNodeGraphGroup::launchServerThread() {
size_t size = shardSizes_[gpu];
threads.emplace_back(std::thread(
[=](int gpu, size_t offset, size_t size, size_t batchWords) {
[=](int gpu, size_t offset, size_t size) {
std::lock_guard<std::mutex> guard(shardMutex_[gpu]);
// Copy grads to appropriate GPU
@ -292,8 +292,7 @@ void MultiNodeGraphGroup::launchServerThread() {
},
gpu,
offset,
size,
messageInfo[MSG_INFO_BATCHWORDS_]));
size));
offset += size;
}

View File

@ -134,9 +134,9 @@ public:
MultiNodeGraphGroupSync(Ptr<Config> options)
: Base(options),
tau_{options_->get<size_t>("optimizer-delay")},
syncOptimizer_{Optimizer(options_)},
movingAvg_{options_->get<float>("exponential-smoothing") > 0},
mvDecay_{options_->get<float>("exponential-smoothing")},
syncOptimizer_{Optimizer(options_)} {
mvDecay_{options_->get<float>("exponential-smoothing")} {
}
/**

View File

@ -390,8 +390,8 @@ private:
public:
BleuValidator(std::vector<Ptr<Vocab>> vocabs, Ptr<Config> options, bool detok = false)
: Validator(vocabs, options, false),
quiet_(options_->get<bool>("quiet-translation")),
detok_(detok) {
detok_(detok),
quiet_(options_->get<bool>("quiet-translation")) {
Ptr<Options> opts = New<Options>();
opts->merge(options);
opts->set("inference", true);

View File

@ -13,7 +13,7 @@ public:
virtual float breakDown(size_t i) { return getLogProbs()->val()->get(i); }
virtual void blacklist(Expr totalCosts, Ptr<data::CorpusBatch> batch){};
virtual void blacklist(Expr /*totalCosts*/, Ptr<data::CorpusBatch> /*batch*/){};
};
class Scorer {
@ -40,10 +40,9 @@ public:
int beamSize)
= 0;
virtual void init(Ptr<ExpressionGraph> graph) {}
virtual void init(Ptr<ExpressionGraph>) {}
virtual void setShortlistGenerator(
Ptr<data::ShortlistGenerator> shortlistGenerator){};
virtual void setShortlistGenerator( Ptr<data::ShortlistGenerator> /*shortlistGenerator*/){};
virtual Ptr<data::Shortlist> getShortlist() { return nullptr; };
virtual std::vector<float> getAlignment() { return {}; };
};

View File

@ -268,6 +268,15 @@
<ClCompile Include="..\src\common\version.cpp">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="..\src\examples\iris\helper.cpp">
<Filter>examples\iris</Filter>
</ClCompile>
<ClCompile Include="..\src\examples\iris\iris.cpp">
<Filter>examples\iris</Filter>
</ClCompile>
<ClCompile Include="..\src\examples\mnist\mnist_ffnn.cpp">
<Filter>examples\mnist</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\marian.h" />
@ -1093,6 +1102,21 @@
<ClInclude Include="..\src\common\version.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="..\src\examples\mnist\dataset.h">
<Filter>examples\mnist</Filter>
</ClInclude>
<ClInclude Include="..\src\examples\mnist\model.h">
<Filter>examples\mnist</Filter>
</ClInclude>
<ClInclude Include="..\src\examples\mnist\model_lenet.h">
<Filter>examples\mnist</Filter>
</ClInclude>
<ClInclude Include="..\src\examples\mnist\training.h">
<Filter>examples\mnist</Filter>
</ClInclude>
<ClInclude Include="..\src\examples\mnist\validator.h">
<Filter>examples\mnist</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="3rd_party">
@ -1212,11 +1236,40 @@
<Filter Include="microsoft">
<UniqueIdentifier>{bf291eae-3de9-4294-b5aa-07ab631951e1}</UniqueIdentifier>
</Filter>
<Filter Include="examples">
<UniqueIdentifier>{3dbe1ce2-4645-42d0-99b1-0989e42cd7df}</UniqueIdentifier>
</Filter>
<Filter Include="examples\iris">
<UniqueIdentifier>{c1ebcdfa-3994-4430-aad0-0d9d54cf10e3}</UniqueIdentifier>
</Filter>
<Filter Include="examples\mnist">
<UniqueIdentifier>{55dd3952-a6fd-41d8-b99c-306b9e6c348d}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include=".editorConfig" />
<None Include="..\src\training\communicator_nccl.h">
<Filter>training</Filter>
</None>
<None Include="..\src\examples\cmake_install.cmake">
<Filter>examples</Filter>
</None>
<None Include="..\src\examples\Makefile">
<Filter>examples</Filter>
</None>
<None Include="..\src\examples\README.md">
<Filter>examples</Filter>
</None>
<None Include="..\src\examples\iris\iris.data">
<Filter>examples\iris</Filter>
</None>
<None Include="..\src\examples\mnist\download.sh">
<Filter>examples\mnist</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="..\src\examples\CMakeLists.txt">
<Filter>examples</Filter>
</Text>
</ItemGroup>
</Project>