Skip to content

Commit

Permalink
Enable some windows compiler flags
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkulakowski committed Jan 23, 2025
1 parent 664a5d1 commit 71cb1d0
Show file tree
Hide file tree
Showing 99 changed files with 501 additions and 110 deletions.
7 changes: 7 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ build:windows --host_copt=/D_USE_MATH_DEFINES
build:windows --features=compiler_param_file
build:windows --features=archive_param_file

build:windows --copt=/W0
build:windows --host_copt=/W0
build:windows --copt=/external:env:BAZEL_VC
build:windows --host_copt=/external:env:BAZEL_VC
build:windows --copt=/external:W0
build:windows --host_copt=/external:W0

# Speed Windows compile times. Available in VS 16.4 (we are on 16.11). See
# https://groups.google.com/a/tensorflow.org/d/topic/build/SsW98Eo7l3o/discussion
build:windows --copt=/d2ReducedOptimizeHugeFunctions
Expand Down
126 changes: 121 additions & 5 deletions common_settings.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,45 @@ COMMON_STATIC_LIBS_COPTS = select({
"-Werror",
],
"//src:windows" : [
"-Wall",
"/W4",
"/WX",
"/external:anglebrackets",
"/external:W0",
"/sdl",
"/analyze",
"/Gy",
"/DYNAMICBASE",
"/wd4099", # level 2
"/wd4018", # level 3
"/wd4068", # level 1
"/wd4458", # level 4
"/wd4100", # level 4
"/wd4267", # level 1
"/wd4389", # level 4
"/wd4005", # level 1
"/wd4127", # level 4
"/wd4456", # level 4
"/wd4673", # level 4
"/wd4670", # level 4
"/wd4244", # level 3
"/wd4457", # level 4
"/wd4505", # level 4
"/wd6346", # level 1
"/wd6011", # level 1
"/wd6246", # level 3
"/wd4702", # level 4
"/wd4309", # level 2
"/wd4101", # level 3/4
"/wd6294", # level 2
"/wd6201", # level 2
"/wd6269", # level 2
"/wd6387", # level 4
"/wd6308", # level 4
"/wd6295", # level 2
"/wd4661", # level 1
"/wd6319", # level 3/4
"/wd4297", # level 3/4
"/wd4701",
],
})

Expand All @@ -136,8 +174,46 @@ COMMON_STATIC_TEST_COPTS = select({
"-fvisibility=hidden",# Needed for pybind targets
],
"//src:windows" : [
"-W0",
"-Isrc",
"/W4",
"/WX",
"/external:anglebrackets",
"/external:W0",
"/sdl",
"/analyze",
"/Gy",
"/DYNAMICBASE",
"/wd4099",
"/wd4018",
"/wd4068",
"/wd4458",
"/wd4100",
"/wd4267",
"/wd4389",
"/wd4005",
"/wd4127",
"/wd4456",
"/wd4673",
"/wd4670",
"/wd4244",
"/wd4457",
"/wd4505",
"/wd6326",
"/wd6346",
"/wd6011",
"/wd6246",
"/wd4702",
"/wd4309",
"/wd4101",
"/wd6294",
"/wd6201",
"/wd6269",
"/wd6387",
"/wd6308",
"/wd6295",
"/wd4661",
"/wd6319",
"/wd4297",
"/wd4701",
],
})

Expand All @@ -150,7 +226,46 @@ COMMON_STATIC_LIBS_COPTS_VISIBLE = select({
"-Werror",
],
"//src:windows" : [
"-Wall",
"/W4",
"/WX",
"/external:anglebrackets",
"/external:W0",
"/sdl",
"/analyze",
"/Gy",
"/DYNAMICBASE",
"/wd4099",
"/wd4018",
"/wd4068",
"/wd4458",
"/wd4100",
"/wd4267",
"/wd4389",
"/wd4005",
"/wd4127",
"/wd4456",
"/wd4673",
"/wd4670",
"/wd4244",
"/wd4457",
"/wd4505",
"/wd6326",
"/wd6346",
"/wd6011",
"/wd6246",
"/wd4702",
"/wd4309",
"/wd4101",
"/wd6294",
"/wd6201",
"/wd6269",
"/wd6387",
"/wd6308",
"/wd6295",
"/wd4661",
"/wd6319",
"/wd4297",
"/wd4701",
],
})

Expand All @@ -164,7 +279,8 @@ COMMON_STATIC_LIBS_LINKOPTS = select({
# "-lovms_shared", # Use for dynamic linking when necessary
],
"//src:windows" : [
"",
"/LTCG",
"/NXCOMPAT",
],
})
COPTS_PYTHON = select({
Expand Down
5 changes: 2 additions & 3 deletions demos/common/cpp/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ build:mkl_open_source_only --define=tensorflow_mkldnn_contraction_kernel=0
# Processor native optimizations (depends on build host capabilities).
build:nativeopt --copt=-march=native
build:nativeopt --host_copt=-march=native
build:nativeopt --copt=-O3

build --action_env PYTHON_BIN_PATH="/usr/bin/python3"
build --define PYTHON_BIN_PATH=/usr/bin/python3
Expand All @@ -54,8 +53,8 @@ build -c opt
build --copt=-DGRPC_BAZEL_BUILD

# LLVM, MLIR and TF require C++14, we use C++17 in project
build --cxxopt=-std=c++17
build --host_cxxopt=-std=c++17
build --cxxopt=-std=c++11
build --host_cxxopt=-std=c++11

# Security options
build --cxxopt=-fno-strict-overflow
Expand Down
13 changes: 8 additions & 5 deletions src/capi_frontend/capi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
#include <iterator>
#include <memory>
#include <string>

#pragma warning(push)
#pragma warning(disable : 6313)
#include <rapidjson/document.h>
#include <rapidjson/pointer.h>
#include <rapidjson/rapidjson.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
#pragma warning(pop)

#include "../dags/pipeline.hpp"
#include "../dags/pipelinedefinition.hpp"
Expand Down Expand Up @@ -208,7 +210,7 @@ DLL_PUBLIC OVMS_Status* OVMS_MetadataFieldByPointer(OVMS_Metadata* metadata, con
if (!val) {
return reinterpret_cast<OVMS_Status*>(new Status(StatusCode::JSON_SERIALIZATION_ERROR, "value not found"));
}
*value = strdup(val->GetString());
*value = _strdup(val->GetString());
*size = val->GetStringLength();
return nullptr;
}
Expand All @@ -229,7 +231,7 @@ DLL_PUBLIC OVMS_Status* OVMS_SerializeMetadataToString(OVMS_Metadata* metadata,

rapidjson::Writer<rapidjson::StringBuffer> writer(strbuf);
doc->Accept(writer);
*json = strdup(strbuf.GetString());
*json = _strdup(strbuf.GetString());
*size = strbuf.GetSize();

return nullptr;
Expand Down Expand Up @@ -878,7 +880,8 @@ enum : uint32_t {
TIMER_CALLBACK,
TIMER_END
};

#pragma warning(push)
#pragma warning(disable : 4190) // TODO verify
static Status getModelManager(Server& server, ModelManager** modelManager) {
if (!server.isLive()) {
return ovms::Status(ovms::StatusCode::SERVER_NOT_READY, "not live");
Expand Down Expand Up @@ -926,7 +929,7 @@ static Status getPipelineDefinition(Server& server, const std::string& servableN
}
return (*pipelineDefinition)->waitForLoaded(unloadGuard, 0);
}

#pragma warning(pop)
} // namespace

DLL_PUBLIC OVMS_Status* OVMS_Inference(OVMS_Server* serverPtr, OVMS_InferenceRequest* request, OVMS_InferenceResponse** response) {
Expand Down
4 changes: 3 additions & 1 deletion src/customloaderconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
#pragma once

#include <string>

#pragma warning(push)
#pragma warning(disable : 6313)
#include <rapidjson/document.h>
#include <rapidjson/istreamwrapper.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
#pragma warning(pop)
#include <spdlog/spdlog.h>

#include "filesystem.hpp"
Expand Down
4 changes: 2 additions & 2 deletions src/dags/custom_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

namespace ovms {

class NodeLibrary;
struct NodeLibrary;
class Status;
class CNLIMWrapper;
struct CNLIMWrapper;

class CustomNode : public Node {
NodeLibrary library;
Expand Down
6 changes: 3 additions & 3 deletions src/dags/customnodesession.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
#include "pipelineeventqueue.hpp"
#include "tensormap.hpp"

class CustomNodeTensor;
class CustomNodeParam;
struct CustomNodeTensor;
struct CustomNodeParam;

namespace ovms {

class Node;
class NodeLibrary;
struct NodeLibrary;
class Status;

class CustomNodeSession : public NodeSession {
Expand Down
3 changes: 3 additions & 0 deletions src/dags/entry_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@
#include "../tfs_frontend/tfs_utils.hpp"
#include "nodesession.hpp"

#pragma warning(push)
#pragma warning(disable : 4624 6001 6385 6386 6326)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wall"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow_serving/apis/prediction_service.grpc.pb.h"
#pragma GCC diagnostic pop
#pragma warning(pop)

namespace ovms {

Expand Down
4 changes: 3 additions & 1 deletion src/dags/exit_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

#include <string>
#include <utility>

#pragma warning(push)
#pragma warning(disable : 4624 6001 6385 6386 6326)
#include "../capi_frontend/inferenceresponse.hpp"
#include "../logging.hpp"
#include "../ov_utils.hpp"
Expand All @@ -28,6 +29,7 @@
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#include "tensorflow/core/framework/tensor.h"
#pragma GCC diagnostic pop
#pragma warning(pop)

#include "exitnodesession.hpp"

Expand Down
8 changes: 4 additions & 4 deletions src/dags/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Status Node::setInputs(const Node& dependency, TensorWithSourceMap& inputs, Node
try {
static const std::set<std::string> emptySet;
shardId = metadata.getShardId(gatherFrom.value_or(emptySet));
} catch (const std::exception& e) {
} catch (const std::exception&) {
SPDLOG_LOGGER_ERROR(dag_executor_logger, "Failed to get shardId for node: {}", getName());
return StatusCode::INTERNAL_ERROR;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ NodeSession* Node::getNodeSession(const NodeSessionMetadata& metadata) {
if (gatherFrom) {
try {
sessionKey = metadata.getSessionKey(gatherFrom.value());
} catch (const std::exception& e) {
} catch (const std::exception&) {
SPDLOG_LOGGER_ERROR(dag_executor_logger, "Failed to create collapsed metadata session key for node: {}, incoming session key: {}",
getName(), metadata.getSessionKey());
return nullptr;
Expand All @@ -177,7 +177,7 @@ NodeSession* Node::getNodeSession(const NodeSessionMetadata& metadata) {
if (gatherFrom) {
try {
std::tie(newSessionMetadata, collapsingDetails) = metadata.getCollapsedSessionMetadata(gatherFrom.value());
} catch (const std::exception& e) {
} catch (const std::exception&) {
SPDLOG_LOGGER_ERROR(dag_executor_logger, "Failed to create collapsed metadata for node: {}", getName());
return nullptr;
}
Expand Down Expand Up @@ -210,7 +210,7 @@ Status Node::demultiplyOutputs(SessionResults& nodeSessionOutputs) {
}
auto& [metadata, tensorMap] = nodeSessionOutputs.begin()->second;
auto firstTensorShape = tensorMap.begin()->second.getActualTensor().get_shape();
uint32_t resultsDemultiplyCount = firstTensorShape[0];
size_t resultsDemultiplyCount = firstTensorShape[0];
if (firstTensorShape[0] > DEMULTIPLY_LIMIT) {
SPDLOG_LOGGER_ERROR(dag_executor_logger, "Node: {} - too large dim[0] size: {} of tensor: {}. Maximum allowed is: {}",
getName(), firstTensorShape[0], tensorMap.begin()->first, DEMULTIPLY_LIMIT);
Expand Down
2 changes: 1 addition & 1 deletion src/dags/nodeinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct NodeInfo {
std::string modelName;
std::optional<model_version_t> modelVersion;
std::unordered_map<std::string, std::string> outputNameAliases;
std::optional<int32_t> demultiplyCount;
std::optional<size_t> demultiplyCount;
std::set<std::string> gatherFromNode;
NodeLibrary library;
parameters_t parameters;
Expand Down
2 changes: 1 addition & 1 deletion src/dags/nodesession.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "nodesessionmetadata.hpp"

namespace ovms {
struct NodeInputHandler;
class NodeInputHandler;
struct NodeOutputHandler;
class Status;
class TensorWithSource;
Expand Down
2 changes: 1 addition & 1 deletion src/dags/nodesessionmetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ std::string NodeSessionMetadata::createSessionKey(const std::set<std::string>& i
}
std::stringstream ss;
size_t j = 0;
for (int32_t i = sessionsLevels.size() - 1; i >= 0; --i, ++j) {
for (size_t i = sessionsLevels.size() - 1; i >= 0; --i, ++j) {
if ((ignoredNodeNames.size() > 0) &&
(ignoredNodeNames.size() > j) &&
(sessionsLevels.size() >= ignoredNodeNames.size()) &&
Expand Down
Loading

0 comments on commit 71cb1d0

Please sign in to comment.