fix win32
This commit is contained in:
parent
8bbed35736
commit
fd8920c71d
@ -5,6 +5,8 @@
|
|||||||
*
|
*
|
||||||
* \author Tianqi Chen
|
* \author Tianqi Chen
|
||||||
*/
|
*/
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#define _CRT_SECURE_NO_DEPRECATE
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <rabit.h>
|
#include <rabit.h>
|
||||||
using namespace rabit;
|
using namespace rabit;
|
||||||
|
|||||||
@ -513,7 +513,7 @@ AllreduceBase::TryAllreduceTree(void *sendrecvbuf_,
|
|||||||
if (len != -1) {
|
if (len != -1) {
|
||||||
size_up_out += static_cast<size_t>(len);
|
size_up_out += static_cast<size_t>(len);
|
||||||
} else {
|
} else {
|
||||||
ReturnType ret = Errno2Return(errno);
|
ReturnType ret = Errno2Return();
|
||||||
if (ret != kSuccess) {
|
if (ret != kSuccess) {
|
||||||
return ReportError(&links[parent_index], ret);
|
return ReportError(&links[parent_index], ret);
|
||||||
}
|
}
|
||||||
@ -533,7 +533,7 @@ AllreduceBase::TryAllreduceTree(void *sendrecvbuf_,
|
|||||||
utils::Assert(size_down_in <= size_up_out,
|
utils::Assert(size_down_in <= size_up_out,
|
||||||
"Allreduce: boundary error");
|
"Allreduce: boundary error");
|
||||||
} else {
|
} else {
|
||||||
ReturnType ret = Errno2Return(errno);
|
ReturnType ret = Errno2Return();
|
||||||
if (ret != kSuccess) {
|
if (ret != kSuccess) {
|
||||||
return ReportError(&links[parent_index], ret);
|
return ReportError(&links[parent_index], ret);
|
||||||
}
|
}
|
||||||
@ -709,7 +709,7 @@ AllreduceBase::TryAllgatherRing(void *sendrecvbuf_, size_t total_size,
|
|||||||
if (len != -1) {
|
if (len != -1) {
|
||||||
read_ptr += static_cast<size_t>(len);
|
read_ptr += static_cast<size_t>(len);
|
||||||
} else {
|
} else {
|
||||||
ReturnType ret = Errno2Return(errno);
|
ReturnType ret = Errno2Return();
|
||||||
if (ret != kSuccess) return ReportError(&next, ret);
|
if (ret != kSuccess) return ReportError(&next, ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -723,7 +723,7 @@ AllreduceBase::TryAllgatherRing(void *sendrecvbuf_, size_t total_size,
|
|||||||
if (len != -1) {
|
if (len != -1) {
|
||||||
write_ptr += static_cast<size_t>(len);
|
write_ptr += static_cast<size_t>(len);
|
||||||
} else {
|
} else {
|
||||||
ReturnType ret = Errno2Return(errno);
|
ReturnType ret = Errno2Return();
|
||||||
if (ret != kSuccess) return ReportError(&prev, ret);
|
if (ret != kSuccess) return ReportError(&prev, ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -826,7 +826,7 @@ AllreduceBase::TryReduceScatterRing(void *sendrecvbuf_,
|
|||||||
if (len != -1) {
|
if (len != -1) {
|
||||||
write_ptr += static_cast<size_t>(len);
|
write_ptr += static_cast<size_t>(len);
|
||||||
} else {
|
} else {
|
||||||
ReturnType ret = Errno2Return(errno);
|
ReturnType ret = Errno2Return();
|
||||||
if (ret != kSuccess) return ReportError(&prev, ret);
|
if (ret != kSuccess) return ReportError(&prev, ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -234,8 +234,13 @@ class AllreduceBase : public IEngine {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
/*! \brief translate errno to return type */
|
/*! \brief translate errno to return type */
|
||||||
inline static ReturnType Errno2Return(int errsv) {
|
inline static ReturnType Errno2Return() {
|
||||||
if (errsv == EAGAIN || errsv == EWOULDBLOCK) return kSuccess;
|
int errsv = utils::Socket::GetLastError();
|
||||||
|
if (errsv == EAGAIN || errsv == EWOULDBLOCK || errsv == 0) return kSuccess;
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (errsv == WSAEWOULDBLOCK) return kSuccess;
|
||||||
|
if (errsv == WSAECONNRESET) return kConnReset;
|
||||||
|
#endif
|
||||||
if (errsv == ECONNRESET) return kConnReset;
|
if (errsv == ECONNRESET) return kConnReset;
|
||||||
return kSockError;
|
return kSockError;
|
||||||
}
|
}
|
||||||
@ -299,7 +304,7 @@ class AllreduceBase : public IEngine {
|
|||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
sock.Close(); return kRecvZeroLen;
|
sock.Close(); return kRecvZeroLen;
|
||||||
}
|
}
|
||||||
if (len == -1) return Errno2Return(errno);
|
if (len == -1) return Errno2Return();
|
||||||
size_read += static_cast<size_t>(len);
|
size_read += static_cast<size_t>(len);
|
||||||
return kSuccess;
|
return kSuccess;
|
||||||
}
|
}
|
||||||
@ -318,7 +323,7 @@ class AllreduceBase : public IEngine {
|
|||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
sock.Close(); return kRecvZeroLen;
|
sock.Close(); return kRecvZeroLen;
|
||||||
}
|
}
|
||||||
if (len == -1) return Errno2Return(errno);
|
if (len == -1) return Errno2Return();
|
||||||
size_read += static_cast<size_t>(len);
|
size_read += static_cast<size_t>(len);
|
||||||
return kSuccess;
|
return kSuccess;
|
||||||
}
|
}
|
||||||
@ -331,7 +336,7 @@ class AllreduceBase : public IEngine {
|
|||||||
inline ReturnType WriteFromArray(const void *sendbuf_, size_t max_size) {
|
inline ReturnType WriteFromArray(const void *sendbuf_, size_t max_size) {
|
||||||
const char *p = static_cast<const char*>(sendbuf_);
|
const char *p = static_cast<const char*>(sendbuf_);
|
||||||
ssize_t len = sock.Send(p + size_write, max_size - size_write);
|
ssize_t len = sock.Send(p + size_write, max_size - size_write);
|
||||||
if (len == -1) return Errno2Return(errno);
|
if (len == -1) return Errno2Return();
|
||||||
size_write += static_cast<size_t>(len);
|
size_write += static_cast<size_t>(len);
|
||||||
return kSuccess;
|
return kSuccess;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -691,7 +691,7 @@ AllreduceRobust::TryRecoverData(RecoverType role,
|
|||||||
if (len != -1) {
|
if (len != -1) {
|
||||||
links[i].size_write += len;
|
links[i].size_write += len;
|
||||||
} else {
|
} else {
|
||||||
ReturnType ret = Errno2Return(errno);
|
ReturnType ret = Errno2Return();
|
||||||
if (ret != kSuccess) return ReportError(&links[i], ret);
|
if (ret != kSuccess) return ReportError(&links[i], ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1161,7 +1161,7 @@ AllreduceRobust::RingPassing(void *sendrecvbuf_,
|
|||||||
if (len != -1) {
|
if (len != -1) {
|
||||||
read_ptr += static_cast<size_t>(len);
|
read_ptr += static_cast<size_t>(len);
|
||||||
} else {
|
} else {
|
||||||
ReturnType ret = Errno2Return(errno);
|
ReturnType ret = Errno2Return();
|
||||||
if (ret != kSuccess) return ReportError(&prev, ret);
|
if (ret != kSuccess) return ReportError(&prev, ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1171,7 +1171,7 @@ AllreduceRobust::RingPassing(void *sendrecvbuf_,
|
|||||||
if (len != -1) {
|
if (len != -1) {
|
||||||
write_ptr += static_cast<size_t>(len);
|
write_ptr += static_cast<size_t>(len);
|
||||||
} else {
|
} else {
|
||||||
ReturnType ret = Errno2Return(errno);
|
ReturnType ret = Errno2Return();
|
||||||
if (ret != kSuccess) return ReportError(&prev, ret);
|
if (ret != kSuccess) return ReportError(&prev, ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,6 +94,13 @@ class Socket {
|
|||||||
inline operator SOCKET() const {
|
inline operator SOCKET() const {
|
||||||
return sockfd;
|
return sockfd;
|
||||||
}
|
}
|
||||||
|
inline static int GetLastError(void) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
return WSAGetLastError();
|
||||||
|
#else
|
||||||
|
return errno;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
/*!
|
/*!
|
||||||
* \brief start up the socket module
|
* \brief start up the socket module
|
||||||
* call this before using the sockets
|
* call this before using the sockets
|
||||||
|
|||||||
@ -100,6 +100,7 @@
|
|||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user