Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows compatibility fix #368

Merged
merged 3 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/treelite/predictor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
#include <mutex>
#include <cstdint>

#ifdef _WIN32
#define NOMINMAX
#include <windows.h>
#endif // _WIN32

namespace treelite {
namespace predictor {

Expand Down Expand Up @@ -71,8 +76,13 @@ union Entry {

class SharedLibrary {
public:
#ifdef _WIN32
using LibraryHandle = HMODULE;
using FunctionHandle = FARPROC;
#else // _WIN32
using LibraryHandle = void*;
using FunctionHandle = void*;
#endif // _WIN32
SharedLibrary();
~SharedLibrary();
void Load(const char* libpath);
Expand Down
7 changes: 1 addition & 6 deletions src/predictor/thread_pool/thread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,7 @@ class ThreadPool {

inline void SetAffinity() {
#ifdef _WIN32
/* Windows */
SetThreadAffinityMask(GetCurrentThread(), 0x1);
for (int i = 0; i < num_worker_; ++i) {
const int core_id = i + 1;
SetThreadAffinityMask(thread_[i].native_handle(), (1ULL << core_id));
}
/* Do not set thread affinity on Windows */
#elif defined(__APPLE__) && defined(__MACH__)
#include <TargetConditionals.h>
#if TARGET_OS_MAC == 1
Expand Down