[R] enable R compile

[R] Enable R build for windows and linux
This commit is contained in:
tqchen
2016-01-10 23:15:18 -08:00
parent 72347e2d45
commit 2dc6c2dc52
16 changed files with 625 additions and 540 deletions

View File

@@ -8,9 +8,12 @@
#include "./sparse_batch_page.h"
#include "./simple_dmatrix.h"
#include "./simple_csr_source.h"
#include "../common/io.h"
#if DMLC_ENABLE_STD_THREAD
#include "./sparse_page_source.h"
#include "./sparse_page_dmatrix.h"
#include "../common/io.h"
#endif
namespace xgboost {
// implementation of inline functions
@@ -194,11 +197,16 @@ DMatrix* DMatrix::Create(dmlc::Parser<uint32_t>* parser,
source->CopyFrom(parser);
return DMatrix::Create(std::move(source), cache_prefix);
} else {
#if DMLC_ENABLE_STD_THREAD
if (!data::SparsePageSource::CacheExist(cache_prefix)) {
data::SparsePageSource::Create(parser, cache_prefix);
}
std::unique_ptr<data::SparsePageSource> source(new data::SparsePageSource(cache_prefix));
return DMatrix::Create(std::move(source), cache_prefix);
#else
LOG(FATAL) << "External memory is not enabled in mingw";
return nullptr;
#endif
}
}
@@ -214,7 +222,12 @@ DMatrix* DMatrix::Create(std::unique_ptr<DataSource>&& source,
if (cache_prefix.length() == 0) {
return new data::SimpleDMatrix(std::move(source));
} else {
#if DMLC_ENABLE_STD_THREAD
return new data::SparsePageDMatrix(std::move(source), cache_prefix);
#else
LOG(FATAL) << "External memory is not enabled in mingw";
return nullptr;
#endif
}
}
} // namespace xgboost

View File

@@ -51,7 +51,7 @@ void SimpleCSRSource::CopyFrom(dmlc::Parser<uint32_t>* parser) {
bst_float fvalue = batch.value == nullptr ? 1.0f : batch.value[i];
row_data_.push_back(SparseBatch::Entry(index, fvalue));
this->info.num_col = std::max(this->info.num_col,
static_cast<size_t>(index + 1));
static_cast<uint64_t>(index + 1));
}
size_t top = row_ptr_.size();
row_ptr_.resize(top + batch.size);

View File

@@ -4,15 +4,15 @@
* \brief In-memory version of DMatrix.
* \author Tianqi Chen
*/
#ifndef XGBOOST_SPARSE_PAGE_DMATRIX_H_
#define XGBOOST_SPARSE_PAGE_DMATRIX_H_
#ifndef XGBOOST_DATA_SPARSE_PAGE_DMATRIX_H_
#define XGBOOST_DATA_SPARSE_PAGE_DMATRIX_H_
#include <xgboost/base.h>
#include <xgboost/data.h>
#include <dmlc/threadediter.h>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include "./sparse_batch_page.h"
namespace xgboost {
@@ -125,4 +125,4 @@ class SparsePageDMatrix : public DMatrix {
};
} // namespace data
} // namespace xgboost
#endif // XGBOOST_SPARSE_PAGE_DMATRIX_H_
#endif // XGBOOST_DATA_SPARSE_PAGE_DMATRIX_H_