fix som solaris

This commit is contained in:
tqchen 2014-09-02 00:12:15 -07:00
parent bb5c151f57
commit c9f2f47acb
5 changed files with 17 additions and 19 deletions

View File

@ -147,9 +147,9 @@ class DMatrixSimple : public DataMatrix {
* \param fname file name, used to print message * \param fname file name, used to print message
*/ */
inline void LoadBinary(utils::IStream &fs, bool silent = false, const char *fname = NULL) { inline void LoadBinary(utils::IStream &fs, bool silent = false, const char *fname = NULL) {
int magic; int tmagic;
utils::Check(fs.Read(&magic, sizeof(magic)) != 0, "invalid input file format"); utils::Check(fs.Read(&tmagic, sizeof(tmagic)) != 0, "invalid input file format");
utils::Check(magic == kMagic, "invalid format,magic number mismatch"); utils::Check(tmagic == kMagic, "invalid format,magic number mismatch");
info.LoadBinary(fs); info.LoadBinary(fs);
FMatrixS::LoadBinary(fs, &row_ptr_, &row_data_); FMatrixS::LoadBinary(fs, &row_ptr_, &row_data_);
@ -177,8 +177,8 @@ class DMatrixSimple : public DataMatrix {
*/ */
inline void SaveBinary(const char* fname, bool silent = false) const { inline void SaveBinary(const char* fname, bool silent = false) const {
utils::FileStream fs(utils::FopenCheck(fname, "wb")); utils::FileStream fs(utils::FopenCheck(fname, "wb"));
int magic = kMagic; int tmagic = kMagic;
fs.Write(&magic, sizeof(magic)); fs.Write(&tmagic, sizeof(tmagic));
info.SaveBinary(fs); info.SaveBinary(fs);
FMatrixS::SaveBinary(fs, row_ptr_, row_data_); FMatrixS::SaveBinary(fs, row_ptr_, row_data_);

View File

@ -125,12 +125,12 @@ struct MetaInfo {
} }
// try to load weight information from file, if exists // try to load weight information from file, if exists
inline bool TryLoadFloatInfo(const char *field, const char* fname, bool silent = false) { inline bool TryLoadFloatInfo(const char *field, const char* fname, bool silent = false) {
std::vector<float> &weights = this->GetFloatInfo(field); std::vector<float> &data = this->GetFloatInfo(field);
FILE *fi = fopen64(fname, "r"); FILE *fi = fopen64(fname, "r");
if (fi == NULL) return false; if (fi == NULL) return false;
float wt; float wt;
while (fscanf(fi, "%f", &wt) == 1) { while (fscanf(fi, "%f", &wt) == 1) {
weights.push_back(wt); data.push_back(wt);
} }
if (!silent) { if (!silent) {
utils::Printf("loading %s from %s\n", field, fname); utils::Printf("loading %s from %s\n", field, fname);

View File

@ -295,14 +295,14 @@ struct SplitEntry{
* \brief decides whether a we can replace current entry with the statistics given * \brief decides whether a we can replace current entry with the statistics given
* This function gives better priority to lower index when loss_chg equals * This function gives better priority to lower index when loss_chg equals
* not the best way, but helps to give consistent result during multi-thread execution * not the best way, but helps to give consistent result during multi-thread execution
* \param loss_chg the loss reduction get through the split * \param new_loss_chg the loss reduction get through the split
* \param split_index the feature index where the split is on * \param split_index the feature index where the split is on
*/ */
inline bool NeedReplace(bst_float loss_chg, unsigned split_index) const { inline bool NeedReplace(bst_float new_loss_chg, unsigned split_index) const {
if (this->split_index() <= split_index) { if (this->split_index() <= split_index) {
return loss_chg > this->loss_chg; return new_loss_chg > this->loss_chg;
} else { } else {
return !(this->loss_chg > loss_chg); return !(this->loss_chg > new_loss_chg);
} }
} }
/*! /*!
@ -322,19 +322,19 @@ struct SplitEntry{
} }
/*! /*!
* \brief update the split entry, replace it if e is better * \brief update the split entry, replace it if e is better
* \param loss_chg loss reduction of new candidate * \param new_loss_chg loss reduction of new candidate
* \param split_index feature index to split on * \param split_index feature index to split on
* \param split_value the split point * \param split_value the split point
* \param default_left whether the missing value goes to left * \param default_left whether the missing value goes to left
* \return whether the proposed split is better and can replace current split * \return whether the proposed split is better and can replace current split
*/ */
inline bool Update(bst_float loss_chg, unsigned split_index, inline bool Update(bst_float new_loss_chg, unsigned split_index,
float split_value, bool default_left) { float new_split_value, bool default_left) {
if (this->NeedReplace(loss_chg, split_index)) { if (this->NeedReplace(loss_chg, split_index)) {
this->loss_chg = loss_chg; this->loss_chg = new_loss_chg;
if (default_left) split_index |= (1U << 31); if (default_left) split_index |= (1U << 31);
this->sindex = split_index; this->sindex = split_index;
this->split_value = split_value; this->split_value = new_split_value;
return true; return true;
} else { } else {
return false; return false;

View File

@ -29,7 +29,6 @@ class TreeRefresher: public IUpdater {
const std::vector<RegTree*> &trees) { const std::vector<RegTree*> &trees) {
if (trees.size() == 0) return; if (trees.size() == 0) return;
// number of threads // number of threads
int nthread;
// thread temporal space // thread temporal space
std::vector< std::vector<TStats> > stemp; std::vector< std::vector<TStats> > stemp;
std::vector<RegTree::FVec> fvec_temp; std::vector<RegTree::FVec> fvec_temp;

View File

@ -93,8 +93,7 @@ class FileStream : public IStream {
private: private:
FILE *fp; FILE *fp;
public: public:
explicit FileStream(FILE *fp) { explicit FileStream(FILE *fp) : fp(fp) {
this->fp = fp;
} }
virtual size_t Read(void *ptr, size_t size) { virtual size_t Read(void *ptr, size_t size) {
return fread(ptr, size, 1, fp); return fread(ptr, size, 1, fp);