fix warnings

This commit is contained in:
Marcin Junczys-Dowmunt 2018-11-28 17:27:12 -08:00
parent 67124f8937
commit 1c4602ea47
7 changed files with 46 additions and 17 deletions

View File

@ -38,15 +38,26 @@ if(MSVC)
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /LTCG:incremental")
else()
set(CMAKE_CXX_FLAGS " -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(DISABLE_GLOBALLY "-Wno-unused-result")
# These are used in src/CMakeLists.txt on a per-target basis
list(APPEND ALL_WARNINGS -Wall; -Werror; -Wno-unused-result; -Wno-deprecated; -Wno-pragmas; -Wno-unused-parameter; -Wextra; -Wno-unused-function;
-Wno-unused-value; -Wno-unknown-pragmas; -Wno-sign-compare; -Wno-missing-field-initializers)
# This warning does not exist prior to gcc 5.0
if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0)
list(APPEND ALL_WARNINGS -Wsuggest-override)
endif()
set(CMAKE_CXX_FLAGS "-std=c++11 -O3 -Ofast -m64 -pthread -march=${BUILD_ARCH} -msse4.1 -Wl,--no-as-needed -funroll-loops -ffinite-math-only -fPIC ${DISABLE_GLOBALLY}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -g -rdynamic")
set(CMAKE_CXX_FLAGS_DEBUG " -std=c++11 -g -rdynamic -O0 -pthread -Wl,--no-as-needed -fPIC -Wno-unused-result -Wno-deprecated -Werror -Wno-pragmas")
set(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -g -rdynamic -O0 -pthread -Wl,--no-as-needed -fPIC -Wno-unused-result -Wno-deprecated -Werror -Wno-pragmas")
set(CMAKE_CXX_FLAGS_SLIM "${CMAKE_CXX_FLAGS} -DNDEBUG")
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")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -g -rdynamic")
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")
endif()
endif()
# Downloading SentencePiece if requested and set to compile with it.
# Requires all the dependencies imposed by SentencePiece
@ -106,6 +117,7 @@ else(CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND CUDA_NVCC_FLAGS --default-stream per-thread; -O3; -g; --use_fast_math; -arch=sm_30; -gencode=arch=compute_30,code=sm_30; -gencode=arch=compute_50,code=sm_50; -gencode=arch=compute_52,code=sm_52; -gencode=arch=compute_60,code=sm_60; -gencode=arch=compute_61,code=sm_61; -gencode=arch=compute_61,code=compute_61 ;)
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(NOT MSVC)
# @TODO: add warnings here too
list(APPEND CUDA_NVCC_FLAGS -std=c++11; -Xcompiler\ -fPIC; -Xcompiler\ -Wno-unused-result; -Xcompiler\ -Wno-deprecated; -Xcompiler\ -Wno-pragmas; -Xcompiler\ -Wno-unused-value; -Xcompiler\ -Werror;)
else()
list(APPEND CUDA_NVCC_FLAGS -Xcompiler\ /FS; )

View File

@ -85,6 +85,7 @@ add_library(marian STATIC
$<TARGET_OBJECTS:SQLiteCpp>
$<TARGET_OBJECTS:pathie-cpp>
)
target_compile_options(marian PUBLIC ${ALL_WARNINGS})
# Generate git_revision.h to reflect current git revision information
# [https://stackoverflow.com/questions/1435953/how-can-i-pass-git-sha1-to-compiler-as-definition-using-cmake]
@ -111,6 +112,8 @@ cuda_add_library(marian_cuda
training/gradient_dropping/gpu/dropper.cu
training/gradient_dropping/gpu/sparse_algorithm.cu
STATIC)
target_compile_options(marian_cuda PUBLIC ${ALL_WARNINGS})
endif(CUDA_FOUND)
set_target_properties(marian PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
@ -118,18 +121,23 @@ set_target_properties(marian PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY
add_executable(marian_train command/marian.cpp)
set_target_properties(marian_train PROPERTIES OUTPUT_NAME marian)
target_compile_options(marian_train PUBLIC ${ALL_WARNINGS})
add_executable(marian_decoder command/marian_decoder.cpp)
set_target_properties(marian_decoder PROPERTIES OUTPUT_NAME marian-decoder)
target_compile_options(marian_decoder PUBLIC ${ALL_WARNINGS})
add_executable(marian_scorer command/marian_scorer.cpp)
set_target_properties(marian_scorer PROPERTIES OUTPUT_NAME marian-scorer)
target_compile_options(marian_scorer PUBLIC ${ALL_WARNINGS})
add_executable(marian_vocab command/marian_vocab.cpp)
set_target_properties(marian_vocab PROPERTIES OUTPUT_NAME marian-vocab)
target_compile_options(marian_vocab PUBLIC ${ALL_WARNINGS})
add_executable(marian_conv command/marian_conv.cpp)
set_target_properties(marian_conv PROPERTIES OUTPUT_NAME marian-conv)
target_compile_options(marian_conv PUBLIC ${ALL_WARNINGS})
set(EXECUTABLES ${EXECUTABLES} marian_train marian_decoder marian_scorer marian_vocab marian_conv)
@ -167,6 +175,7 @@ endif()
if(COMPILE_SERVER)
add_executable(marian_server command/marian_server.cpp)
set_target_properties(marian_server PROPERTIES OUTPUT_NAME marian-server)
target_compile_options(marian_server PUBLIC ${ALL_WARNINGS})
set(EXECUTABLES ${EXECUTABLES} marian_server)
endif(COMPILE_SERVER)

View File

@ -3,7 +3,11 @@
#include "common/filesystem.h"
#include "common/logging.h"
#include "common/definitions.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#include "3rd_party/zstr/zstr.hpp"
#pragma GCC diagnostic pop
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream_buffer.hpp>

View File

@ -7,8 +7,11 @@
// @TODO: go back to canonical names for functions and objects
// as specified in C++17 so it becomes easy to move in the future
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#include "3rd_party/pathie-cpp/include/path.hpp"
#include "3rd_party/pathie-cpp/include/errors.hpp"
#pragma GCC diagnostic pop
namespace marian {
namespace filesystem {

View File

@ -185,7 +185,7 @@ public:
virtual void create(const std::string& vocabPath,
const std::vector<std::string>& trainPaths,
size_t maxSize = 0) {
size_t maxSize = 0) override {
LOG(info, "[data] Creating vocabulary {} from {}",
vocabPath,

View File

@ -12,6 +12,7 @@
#include "common/regex.h"
#include <sstream>
#include <random>
namespace marian {
@ -55,12 +56,12 @@ public:
}
virtual const std::string& canonicalExtension() const { return suffixes_[0]; }
virtual const std::vector<std::string>& suffixes() const { return suffixes_; }
virtual const std::string& canonicalExtension() const override { return suffixes_[0]; }
virtual const std::vector<std::string>& suffixes() const override { return suffixes_; }
virtual std::string suffix() { return suffixes_[0]; };
virtual std::string type() const { return "SentencePieceVocab"; }
virtual std::string type() const override { return "SentencePieceVocab"; }
virtual Word getEosId() const override { return (Word)spm_->eos_id(); }
virtual Word getUnkId() const override { return (Word)spm_->unk_id(); }
@ -192,20 +193,20 @@ public:
vocabPath + ".model", vocabPath);
}
void createFake() {
void createFake() override {
ABORT("[SentencePiece] Fake SentencePiece vocabulary not supported");
}
Word operator[](const std::string& token) const {
Word operator[](const std::string& token) const override {
return (Word)spm_->PieceToId(token);
}
const std::string& operator[](Word id) const {
const std::string& operator[](Word id) const override {
ABORT_IF(id >= size(), "Unknown word id: ", id);
return spm_->IdToPiece(id);
}
Words encode(const std::string& line, bool addEOS, bool inference) const {
Words encode(const std::string& line, bool addEOS, bool inference) const override {
std::vector<int> spmIds;
if(inference || alpha_ == 0)
spm_->Encode(line, &spmIds);
@ -219,7 +220,7 @@ public:
return words;
}
std::string decode(const Words& sentence, bool ignoreEOS) const {
std::string decode(const Words& sentence, bool /*ignoreEOS*/) const override {
std::string line;
// convert vector of Word to vector of int
std::vector<int> spmSentence(sentence.begin(), sentence.end());
@ -227,11 +228,11 @@ public:
return line;
}
size_t size() const {
size_t size() const override {
return spm_->GetPieceSize();
}
int load(const std::string& vocabPath, int /*max*/) {
int load(const std::string& vocabPath, int /*max*/) override {
LOG(info, "[data] Loading SentencePiece vocabulary from file {}", vocabPath);
ABORT_IF(!filesystem::exists(vocabPath),

View File

@ -99,7 +99,7 @@ void Prod(marian::Tensor C,
}
void ProdBatched(marian::Tensor C,
Ptr<Allocator> allocator,
Ptr<Allocator> /*allocator*/,
const marian::Tensor A,
const marian::Tensor B,
bool transA,
@ -150,7 +150,7 @@ void ProdBatched(marian::Tensor C,
(int)ldc);
}
#else
C; allocator; A; B; transA; transB; beta; scalar;
C; A; B; transA; transB; beta; scalar;
ABORT("You need to compile with MKL in order to use the CPU version");
#endif
}