Reapply Windows fix

Summary:
Last fix was uncommitted due to a bug in internal build (CAFFE2_API causing error). This one re-applies it as well as a few more, especially enabling gtest.

Earlier commit message: Basically, this should make windows {static_lib, shared_lib} * {static_runtime, shared_runtime} * {cpu, gpu} work other than gpu shared_lib, which willyd kindly pointed out a symbol limit problem. A few highlights:
(1) Updated newest protobuf.
(2) use protoc dllexport command to ensure proper symbol export for windows.
(3) various code updates to make sure that C2 symbols are properly shown
(4) cmake file changes to make build proper
(5) option to choose static runtime and shared runtime similar to protobuf
(6) revert to visual studio 2015 as current cuda and msvc 2017 do not play well together.
(7) enabled gtest and fixed testing bugs.

Earlier PR is #1793

Closes https://github.com/caffe2/caffe2/pull/1827

Differential Revision: D6832086

Pulled By: Yangqing

fbshipit-source-id: 85f86e9a992ee5c53c70b484b761c9d6aed721df
This commit is contained in:
Yangqing Jia
2018-01-29 10:00:43 -08:00
committed by Facebook Github Bot
parent 657214543c
commit 91d76f5dbd
38 changed files with 400 additions and 238 deletions

View File

@ -30,15 +30,19 @@
namespace caffe2 {
class Task;
struct Task;
class WorkersPool;
constexpr size_t kCacheLineSize = 64;
// A work-stealing threadpool with the given number of threads.
// NOTE: the kCacheLineSize alignment is present only for cache
// performance, and is not strictly enforced (for example, when
// the object is created on the heap). Thus, in order to avoid
// misaligned intrinsics, no SSE instructions shall be involved in
// the ThreadPool implemetation.
class alignas(kCacheLineSize) ThreadPool {
public:
// Constructs a work-stealing threadpool with the given number of
// threads
static std::unique_ptr<ThreadPool> defaultThreadPool();
ThreadPool(int numThreads);
~ThreadPool();