Skip to content

Commit 9800312

Browse files
Enable SDL related windows compiler flags (#2964)
--------- Co-authored-by: Trawinski, Dariusz <[email protected]>
1 parent 29ddc2f commit 9800312

File tree

106 files changed

+453
-127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+453
-127
lines changed

.bazelrc

+6-2
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,13 @@ build:monolithic --define framework_shared_object=false
176176
build:monolithic --define tsl_protobuf_header_only=false
177177
# On windows, we still link everything into a single DLL - required by TF
178178
build:windows --config=monolithic
179-
180-
build:windows --copt=/W0
179+
# Warnings are enabled in common_settings
180+
build:windows --copt=/W0
181181
build:windows --host_copt=/W0
182+
build:windows --copt=/external:anglebrackets
183+
build:windows --host_copt=/external:anglebrackets
184+
build:windows --copt=/external:W0
185+
build:windows --host_copt=/external:W0
182186

183187
# On Windows, `__cplusplus` is wrongly defined without this switch
184188
# See https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/

common_settings.bzl

+39-6
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,37 @@ COMMON_STATIC_LIBS_COPTS = select({
122122
"-Werror",
123123
],
124124
"//src:windows" : [
125-
"-Wall",
125+
"/W4",
126+
"/WX",
127+
"/external:anglebrackets",
128+
"/external:W0",
129+
"/sdl",
130+
"/analyze",
131+
"/Gy",
132+
"/DYNAMICBASE",
133+
"/Qspectre",
134+
"/wd4018", # level 3
135+
"/wd4068", # level 1
136+
"/wd4458", # level 4
137+
"/wd4100", # level 4
138+
"/wd4267", # level 1
139+
"/wd4389", # level 4
140+
"/wd4127", # level 4
141+
"/wd4456", # level 4
142+
"/wd4673", # level 4
143+
"/wd4670", # level 4
144+
"/wd4244", # level 3
145+
"/wd4457", # level 4
146+
"/wd4505", # level 4
147+
"/wd6246", # level 3
148+
"/wd4702", # level 4
149+
"/wd4101", # level 3/4
150+
"/wd6387", # level 4
151+
"/wd6308", # level 4
152+
"/wd6319", # level 3/4
153+
"/wd4297", # level 3/4
154+
"/wd4701",
155+
"/wd4804",
126156
],
127157
})
128158

@@ -136,8 +166,8 @@ COMMON_STATIC_TEST_COPTS = select({
136166
"-fvisibility=hidden",# Needed for pybind targets
137167
],
138168
"//src:windows" : [
139-
"-W0",
140-
"-Isrc",
169+
"-W0",
170+
"-Isrc",
141171
],
142172
})
143173

@@ -150,7 +180,8 @@ COMMON_STATIC_LIBS_COPTS_VISIBLE = select({
150180
"-Werror",
151181
],
152182
"//src:windows" : [
153-
"-Wall",
183+
"-W0",
184+
"-Isrc",
154185
],
155186
})
156187

@@ -164,8 +195,10 @@ COMMON_STATIC_LIBS_LINKOPTS = select({
164195
# "-lovms_shared", # Use for dynamic linking when necessary
165196
],
166197
"//src:windows" : [
167-
"",
168-
],
198+
"/NXCOMPAT",
199+
"/LTCG",
200+
"/QConditional-branch:Retpoline",
201+
],
169202
})
170203
COPTS_PYTHON = select({
171204
"//conditions:default": ["-DPYTHON_DISABLE=1"],

src/capi_frontend/capi.cpp

+17-4
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
#include <iterator>
1919
#include <memory>
2020
#include <string>
21-
21+
#pragma warning(push)
22+
#pragma warning(disable : 6313)
2223
#include <rapidjson/document.h>
2324
#include <rapidjson/pointer.h>
2425
#include <rapidjson/rapidjson.h>
2526
#include <rapidjson/stringbuffer.h>
2627
#include <rapidjson/writer.h>
28+
#pragma warning(pop)
2729

2830
#include "../dags/pipeline.hpp"
2931
#include "../dags/pipelinedefinition.hpp"
@@ -75,7 +77,8 @@ using std::chrono::microseconds;
7577
#ifdef __cplusplus
7678
extern "C" {
7779
#endif
78-
80+
#pragma warning(push)
81+
#pragma warning(disable : 4005)
7982
#ifdef __linux__
8083
#define DLL_PUBLIC __attribute__((visibility("default")))
8184
#define DLL_LOCAL __attribute__((visibility("hidden")))
@@ -84,6 +87,7 @@ extern "C" {
8487
// #define DLL_PUBLIC __declspec(dllexport)
8588
#define DLL_PUBLIC
8689
#endif
90+
#pragma warning(pop)
8791

8892
DLL_PUBLIC OVMS_Status* OVMS_ApiVersion(uint32_t* major, uint32_t* minor) {
8993
if (major == nullptr)
@@ -208,7 +212,11 @@ DLL_PUBLIC OVMS_Status* OVMS_MetadataFieldByPointer(OVMS_Metadata* metadata, con
208212
if (!val) {
209213
return reinterpret_cast<OVMS_Status*>(new Status(StatusCode::JSON_SERIALIZATION_ERROR, "value not found"));
210214
}
215+
#ifdef __linux__
211216
*value = strdup(val->GetString());
217+
#elif _WIN32
218+
*value = _strdup(val->GetString());
219+
#endif
212220
*size = val->GetStringLength();
213221
return nullptr;
214222
}
@@ -229,7 +237,11 @@ DLL_PUBLIC OVMS_Status* OVMS_SerializeMetadataToString(OVMS_Metadata* metadata,
229237

230238
rapidjson::Writer<rapidjson::StringBuffer> writer(strbuf);
231239
doc->Accept(writer);
240+
#ifdef __linux__
232241
*json = strdup(strbuf.GetString());
242+
#elif _WIN32
243+
*json = _strdup(strbuf.GetString());
244+
#endif
233245
*size = strbuf.GetSize();
234246

235247
return nullptr;
@@ -878,7 +890,8 @@ enum : uint32_t {
878890
TIMER_CALLBACK,
879891
TIMER_END
880892
};
881-
893+
#pragma warning(push)
894+
#pragma warning(disable : 4190) // TODO verify
882895
static Status getModelManager(Server& server, ModelManager** modelManager) {
883896
if (!server.isLive()) {
884897
return ovms::Status(ovms::StatusCode::SERVER_NOT_READY, "not live");
@@ -926,7 +939,7 @@ static Status getPipelineDefinition(Server& server, const std::string& servableN
926939
}
927940
return (*pipelineDefinition)->waitForLoaded(unloadGuard, 0);
928941
}
929-
942+
#pragma warning(pop)
930943
} // namespace
931944

932945
DLL_PUBLIC OVMS_Status* OVMS_Inference(OVMS_Server* serverPtr, OVMS_InferenceRequest* request, OVMS_InferenceResponse** response) {

src/cli_parser.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,15 @@ void CLIParser::parse(int argc, char** argv) {
194194
exit(3);
195195
#endif
196196
}
197-
197+
#pragma warning(push)
198+
#pragma warning(disable : 4129)
198199
if (result->count("version")) {
199200
std::string project_name(PROJECT_NAME);
200201
std::string project_version(PROJECT_VERSION);
201202
std::cout << project_name + " " + project_version << std::endl;
202203
std::cout << "OpenVINO backend " << OPENVINO_NAME << std::endl;
203204
std::cout << "Bazel build flags: " << BAZEL_BUILD_FLAGS << std::endl;
205+
#pragma warning(pop)
204206
#ifdef __linux__
205207
exit(EX_OK);
206208
#elif _WIN32

src/customloaderconfig.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
#pragma once
1717

1818
#include <string>
19-
19+
#pragma warning(push)
20+
#pragma warning(disable : 6313)
2021
#include <rapidjson/document.h>
2122
#include <rapidjson/istreamwrapper.h>
2223
#include <rapidjson/stringbuffer.h>
2324
#include <rapidjson/writer.h>
25+
#pragma warning(pop)
2426
#include <spdlog/spdlog.h>
2527

2628
#include "filesystem.hpp"

src/dags/custom_node.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828

2929
namespace ovms {
3030

31-
class NodeLibrary;
31+
struct NodeLibrary;
3232
class Status;
33-
class CNLIMWrapper;
33+
struct CNLIMWrapper;
3434

3535
class CustomNode : public Node {
3636
NodeLibrary library;

src/dags/customnodesession.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
#include "pipelineeventqueue.hpp"
3737
#include "tensormap.hpp"
3838

39-
class CustomNodeTensor;
40-
class CustomNodeParam;
39+
struct CustomNodeTensor;
40+
struct CustomNodeParam;
4141

4242
namespace ovms {
4343

4444
class Node;
45-
class NodeLibrary;
45+
struct NodeLibrary;
4646
class Status;
4747

4848
class CustomNodeSession : public NodeSession {

src/dags/entry_node.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@
3535
#include "../tfs_frontend/tfs_utils.hpp"
3636
#include "nodesession.hpp"
3737

38+
#pragma warning(push)
39+
#pragma warning(disable : 4624 6001 6385 6386 6326 6011)
3840
#pragma GCC diagnostic push
3941
#pragma GCC diagnostic ignored "-Wall"
4042
#include "tensorflow/core/framework/tensor.h"
4143
#include "tensorflow_serving/apis/prediction_service.grpc.pb.h"
4244
#pragma GCC diagnostic pop
45+
#pragma warning(pop)
4346

4447
namespace ovms {
4548

src/dags/entry_node.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ class EntryNode : public Node {
6262
throw std::logic_error("This node cannot have dependency");
6363
}
6464

65-
Status isInputBinary(const std::string& name, bool& isBinary) const;
66-
6765
const Status validate();
6866
};
6967

src/dags/exit_node.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
#include "../logging.hpp"
2323
#include "../ov_utils.hpp"
2424
#include "../serialization.hpp"
25-
25+
#pragma warning(push)
26+
#pragma warning(disable : 4624 6001 6385 6386 6326 6011)
2627
#pragma GCC diagnostic push
2728
#pragma GCC diagnostic ignored "-Wall"
2829
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
2930
#include "tensorflow/core/framework/tensor.h"
3031
#pragma GCC diagnostic pop
32+
#pragma warning(pop)
3133

3234
#include "exitnodesession.hpp"
3335

src/dags/exitnodesession.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "tensormap.hpp"
2525

2626
namespace ovms {
27-
class CollapseDetails;
27+
struct CollapseDetails;
2828
class NodeSessionMetadata;
2929

3030
template <typename ResponseType>

src/dags/gathernodeinputhandler.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace ovms {
3333

3434
using shard_map_t = std::unordered_map<session_id_t, ov::Tensor>;
3535

36-
class CollapseDetails;
36+
struct CollapseDetails;
3737

3838
class GatherNodeInputHandler : public NodeInputHandler {
3939
std::unordered_map<std::string, shard_map_t> shardsStorage;

src/dags/node.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Status Node::setInputs(const Node& dependency, TensorWithSourceMap& inputs, Node
112112
try {
113113
static const std::set<std::string> emptySet;
114114
shardId = metadata.getShardId(gatherFrom.value_or(emptySet));
115-
} catch (const std::exception& e) {
115+
} catch (const std::exception&) {
116116
SPDLOG_LOGGER_ERROR(dag_executor_logger, "Failed to get shardId for node: {}", getName());
117117
return StatusCode::INTERNAL_ERROR;
118118
}
@@ -158,7 +158,7 @@ NodeSession* Node::getNodeSession(const NodeSessionMetadata& metadata) {
158158
if (gatherFrom) {
159159
try {
160160
sessionKey = metadata.getSessionKey(gatherFrom.value());
161-
} catch (const std::exception& e) {
161+
} catch (const std::exception&) {
162162
SPDLOG_LOGGER_ERROR(dag_executor_logger, "Failed to create collapsed metadata session key for node: {}, incoming session key: {}",
163163
getName(), metadata.getSessionKey());
164164
return nullptr;
@@ -177,7 +177,7 @@ NodeSession* Node::getNodeSession(const NodeSessionMetadata& metadata) {
177177
if (gatherFrom) {
178178
try {
179179
std::tie(newSessionMetadata, collapsingDetails) = metadata.getCollapsedSessionMetadata(gatherFrom.value());
180-
} catch (const std::exception& e) {
180+
} catch (const std::exception&) {
181181
SPDLOG_LOGGER_ERROR(dag_executor_logger, "Failed to create collapsed metadata for node: {}", getName());
182182
return nullptr;
183183
}
@@ -210,7 +210,7 @@ Status Node::demultiplyOutputs(SessionResults& nodeSessionOutputs) {
210210
}
211211
auto& [metadata, tensorMap] = nodeSessionOutputs.begin()->second;
212212
auto firstTensorShape = tensorMap.begin()->second.getActualTensor().get_shape();
213-
uint32_t resultsDemultiplyCount = firstTensorShape[0];
213+
size_t resultsDemultiplyCount = firstTensorShape[0];
214214
if (firstTensorShape[0] > DEMULTIPLY_LIMIT) {
215215
SPDLOG_LOGGER_ERROR(dag_executor_logger, "Node: {} - too large dim[0] size: {} of tensor: {}. Maximum allowed is: {}",
216216
getName(), firstTensorShape[0], tensorMap.begin()->first, DEMULTIPLY_LIMIT);

src/dags/nodeinfo.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct NodeInfo {
6464
std::string modelName;
6565
std::optional<model_version_t> modelVersion;
6666
std::unordered_map<std::string, std::string> outputNameAliases;
67-
std::optional<int32_t> demultiplyCount;
67+
std::optional<size_t> demultiplyCount;
6868
std::set<std::string> gatherFromNode;
6969
NodeLibrary library;
7070
parameters_t parameters;

src/dags/nodesession.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "nodesessionmetadata.hpp"
2323

2424
namespace ovms {
25-
struct NodeInputHandler;
25+
class NodeInputHandler;
2626
struct NodeOutputHandler;
2727
class Status;
2828
class TensorWithSource;

src/dags/nodestreamidguard.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class OVInferRequestsQueue;
2424
class ModelMetricReporter;
2525
class OVInferRequestsQueue;
2626

27-
struct NodeStreamIdGuard {
27+
class NodeStreamIdGuard {
28+
public:
2829
NodeStreamIdGuard(OVInferRequestsQueue& inferRequestsQueue, ModelMetricReporter& reporter);
2930
~NodeStreamIdGuard();
3031

src/dags/pipeline.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ Status Pipeline::execute(ExecutionContext context) {
164164
DeferredNodeSessions tmpDeferredNodeSessions;
165165
for (auto& nextNode : nextNodesFromFinished) {
166166
auto readySessions = nextNode.get().getReadySessions();
167-
for (auto& sessionKey : readySessions) {
168-
SPDLOG_LOGGER_DEBUG(dag_executor_logger, "Started execution of pipeline: {} node: {} session: {}", getName(), nextNode.get().getName(), sessionKey);
169-
startedSessions.emplace(nextNode.get().getName() + sessionKey);
170-
status = nextNode.get().execute(sessionKey, finishedNodeQueue);
167+
for (auto& readySessionKey : readySessions) {
168+
SPDLOG_LOGGER_DEBUG(dag_executor_logger, "Started execution of pipeline: {} node: {} session: {}", getName(), nextNode.get().getName(), readySessionKey);
169+
startedSessions.emplace(nextNode.get().getName() + readySessionKey);
170+
status = nextNode.get().execute(readySessionKey, finishedNodeQueue);
171171
if (status == StatusCode::PIPELINE_STREAM_ID_NOT_READY_YET) {
172-
SPDLOG_LOGGER_DEBUG(dag_executor_logger, "Node: {} session: {} not ready for execution yet", nextNode.get().getName(), sessionKey);
173-
tmpDeferredNodeSessions.emplace_back(nextNode.get(), sessionKey);
172+
SPDLOG_LOGGER_DEBUG(dag_executor_logger, "Node: {} session: {} not ready for execution yet", nextNode.get().getName(), readySessionKey);
173+
tmpDeferredNodeSessions.emplace_back(nextNode.get(), readySessionKey);
174174
status = StatusCode::OK;
175175
}
176176
CHECK_AND_LOG_ERROR(nextNode.get())
@@ -192,18 +192,18 @@ Status Pipeline::execute(ExecutionContext context) {
192192
if (finishedNodeQueue.size() > 0) {
193193
break;
194194
}
195-
auto& [nodeRef, sessionKey] = *it;
195+
auto& [nodeRef, deferredSessionKey] = *it;
196196
auto& node = nodeRef.get();
197-
SPDLOG_LOGGER_DEBUG(dag_executor_logger, "Trying to trigger node: {} session: {} execution", node.getName(), sessionKey);
198-
status = node.execute(sessionKey, finishedNodeQueue);
197+
SPDLOG_LOGGER_DEBUG(dag_executor_logger, "Trying to trigger node: {} session: {} execution", node.getName(), deferredSessionKey);
198+
status = node.execute(deferredSessionKey, finishedNodeQueue);
199199
if (status.ok()) {
200-
SPDLOG_LOGGER_DEBUG(dag_executor_logger, "Node: {} session: {} is ready", node.getName(), sessionKey);
200+
SPDLOG_LOGGER_DEBUG(dag_executor_logger, "Node: {} session: {} is ready", node.getName(), deferredSessionKey);
201201
it = deferredNodeSessions.erase(it);
202202
continue;
203203
}
204204
it++;
205205
if (status == StatusCode::PIPELINE_STREAM_ID_NOT_READY_YET) {
206-
SPDLOG_LOGGER_DEBUG(dag_executor_logger, "Node: {} session: {} not ready for execution yet", node.getName(), sessionKey);
206+
SPDLOG_LOGGER_DEBUG(dag_executor_logger, "Node: {} session: {} not ready for execution yet", node.getName(), deferredSessionKey);
207207
status = StatusCode::OK;
208208
} else {
209209
CHECK_AND_LOG_ERROR(node)

0 commit comments

Comments
 (0)