@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* Copyright by Contributors
|
||||
* Copyright (c) 2014-2019 by Contributors
|
||||
* \file rabit-inl.h
|
||||
* \brief implementation of inline template function for rabit interface
|
||||
*
|
||||
@@ -188,7 +188,7 @@ inline void TrackerPrintf(const char *fmt, ...) {
|
||||
msg.resize(strlen(msg.c_str()));
|
||||
TrackerPrint(msg);
|
||||
}
|
||||
#endif
|
||||
#endif // RABIT_STRICT_CXX98_
|
||||
// load latest check point
|
||||
inline int LoadCheckPoint(Serializable *global_model,
|
||||
Serializable *local_model) {
|
||||
@@ -323,6 +323,6 @@ inline void SerializeReducer<DType>::Allreduce(DType *sendrecvobj,
|
||||
std::function<void()> prepare_fun) {
|
||||
this->Allreduce(sendrecvobj, max_nbytes, count, InvokeLambda_, &prepare_fun);
|
||||
}
|
||||
#endif
|
||||
#endif // DMLC_USE_CXX11
|
||||
} // namespace rabit
|
||||
#endif // RABIT_INTERNAL_RABIT_INL_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* Copyright by Contributors
|
||||
* Copyright (c) 2014-2019 by Contributors
|
||||
* \file timer.h
|
||||
* \brief This file defines the utils for timing
|
||||
* \author Tianqi Chen, Nacho, Tianyi
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifdef __MACH__
|
||||
#include <mach/clock.h>
|
||||
#include <mach/mach.h>
|
||||
#endif
|
||||
#endif // __MACH__
|
||||
#include "./utils.h"
|
||||
|
||||
namespace rabit {
|
||||
@@ -19,22 +19,22 @@ namespace utils {
|
||||
* \brief return time in seconds, not cross platform, avoid to use this in most places
|
||||
*/
|
||||
inline double GetTime(void) {
|
||||
#ifdef __MACH__
|
||||
#ifdef __MACH__
|
||||
clock_serv_t cclock;
|
||||
mach_timespec_t mts;
|
||||
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||
utils::Check(clock_get_time(cclock, &mts) == 0, "failed to get time");
|
||||
mach_port_deallocate(mach_task_self(), cclock);
|
||||
return static_cast<double>(mts.tv_sec) + static_cast<double>(mts.tv_nsec) * 1e-9;
|
||||
#else
|
||||
#if defined(__unix__) || defined(__linux__)
|
||||
#else
|
||||
#if defined(__unix__) || defined(__linux__)
|
||||
timespec ts;
|
||||
utils::Check(clock_gettime(CLOCK_REALTIME, &ts) == 0, "failed to get time");
|
||||
return static_cast<double>(ts.tv_sec) + static_cast<double>(ts.tv_nsec) * 1e-9;
|
||||
#else
|
||||
#else
|
||||
return static_cast<double>(time(NULL));
|
||||
#endif
|
||||
#endif
|
||||
#endif // defined(__unix__) || defined(__linux__)
|
||||
#endif // __MACH__
|
||||
}
|
||||
} // namespace utils
|
||||
} // namespace rabit
|
||||
|
||||
@@ -14,32 +14,35 @@
|
||||
|
||||
#ifndef RABIT_STRICT_CXX98_
|
||||
#include <cstdarg>
|
||||
#endif
|
||||
#endif // RABIT_STRICT_CXX98_
|
||||
|
||||
#if !defined(__GNUC__) || defined(__FreeBSD__)
|
||||
#define fopen64 std::fopen
|
||||
#endif
|
||||
#endif // !defined(__GNUC__) || defined(__FreeBSD__)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// NOTE: sprintf_s is not equivalent to snprintf,
|
||||
// they are equivalent when success, which is sufficient for our case
|
||||
#define snprintf sprintf_s
|
||||
#define vsnprintf vsprintf_s
|
||||
|
||||
#else
|
||||
|
||||
#ifdef _FILE_OFFSET_BITS
|
||||
#if _FILE_OFFSET_BITS == 32
|
||||
#pragma message("Warning: FILE OFFSET BITS defined to be 32 bit")
|
||||
#endif
|
||||
#endif
|
||||
#endif // _FILE_OFFSET_BITS == 32
|
||||
#endif // _FILE_OFFSET_BITS
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define off64_t off_t
|
||||
#define fopen64 std::fopen
|
||||
#endif
|
||||
#endif // __APPLE__
|
||||
|
||||
extern "C" {
|
||||
#include <sys/types.h>
|
||||
}
|
||||
#endif
|
||||
#endif // _MSC_VER
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef unsigned char uint8_t;
|
||||
@@ -49,7 +52,7 @@ typedef unsigned __int64 uint64_t;
|
||||
typedef __int64 int64_t;
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
#endif // _MSC_VER
|
||||
|
||||
namespace rabit {
|
||||
/*! \brief namespace for helper utils of the project */
|
||||
@@ -88,8 +91,8 @@ inline void HandleLogPrint(const char *msg) {
|
||||
void HandleAssertError(const char *msg);
|
||||
void HandleCheckError(const char *msg);
|
||||
void HandlePrint(const char *msg);
|
||||
#endif
|
||||
#endif
|
||||
#endif // RABIT_STRICT_CXX98_
|
||||
#endif // RABIT_CUSTOMIZE_MSG_
|
||||
#ifdef RABIT_STRICT_CXX98_
|
||||
// these function pointers are to be assigned
|
||||
extern "C" void (*Printf)(const char *fmt, ...);
|
||||
@@ -151,7 +154,7 @@ inline void Error(const char *fmt, ...) {
|
||||
HandleCheckError(msg.c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // RABIT_STRICT_CXX98_
|
||||
|
||||
/*! \brief replace fopen, report error when the file open fails */
|
||||
inline std::FILE *FopenCheck(const char *fname, const char *flag) {
|
||||
|
||||
Reference in New Issue
Block a user