half ram support

This commit is contained in:
tqchen 2015-04-19 21:29:13 -07:00
parent 5ad1555daf
commit dfec406afd
3 changed files with 32 additions and 7 deletions

View File

@ -66,10 +66,16 @@ DataMatrix* LoadDataMatrix(const char *fname,
dmat->LoadBinary(fs, silent, cache_file);
fs.Close();
return dmat;
} else {
DMatrixPage *dmat = new DMatrixPage();
dmat->LoadText(fname, cache_file, false, loadsplit);
return dmat;
} else {
if (fname[0] == '!') {
DMatrixHalfRAM *dmat = new DMatrixHalfRAM();
dmat->LoadText(fname + 1, cache_file, false, loadsplit);
return dmat;
} else {
DMatrixPage *dmat = new DMatrixPage();
dmat->LoadText(fname, cache_file, false, loadsplit);
return dmat;
}
}
}
}

View File

@ -224,6 +224,25 @@ class DMatrixPage : public DMatrixPageBase<0xffffab02> {
/*! \brief the real fmatrix */
FMatrixPage *fmat_;
};
// mix of FMatrix S and DMatrix
// cost half of ram usually as DMatrixSimple
class DMatrixHalfRAM : public DMatrixPageBase<0xffffab03> {
public:
DMatrixHalfRAM(void) {
fmat_ = new FMatrixS(iter_);
}
virtual ~DMatrixHalfRAM(void) {
delete fmat_;
}
virtual IFMatrix *fmat(void) const {
return fmat_;
}
virtual void set_cache_file(const std::string &cache_file) {
}
/*! \brief the real fmatrix */
IFMatrix *fmat_;
};
} // namespace io
} // namespace xgboost
#endif // XGBOOST_IO_PAGE_ROW_ITER_INL_HPP_

View File

@ -260,9 +260,9 @@ class BoostLearner : public rabit::Serializable {
std::vector<bool> enabled(ncol, true);
// initialize column access
p_train->fmat()->InitColAccess(enabled, prob_buffer_row);
const int kMagicSimple = 0xffffab01;
// check, if it is not DMatrix simple, then use hist maker
if (p_train->magic != kMagicSimple) {
const int kMagicPage = 0xffffab02;
// check, if it is DMatrixPage, then use hist maker
if (p_train->magic == kMagicPage) {
this->SetParam("updater", "grow_histmaker,prune");
}
}