From 31d8e93ef3aebb42625c0be4aa74792ad34ac2d0 Mon Sep 17 00:00:00 2001 From: tqchen Date: Tue, 12 Jan 2016 17:54:09 -0800 Subject: [PATCH] [FIX] fix plugin system --- Makefile | 8 +++----- make/config.mk | 4 ++-- plugin/README.md | 2 +- plugin/example/README.md | 2 +- plugin/lz4/sparse_page_lz4_format.cc | 3 ++- src/common/quantile.h | 3 ++- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 3528104f4..9252acfb9 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,3 @@ -# flags by plugin -PLUGIN_OBJS= -PLUGIN_LDFLAGS= -PLUGIN_CFLAGS= - ifndef config ifneq ("$(wildcard ./config.mk)","") config = config.mk @@ -28,6 +23,9 @@ ifeq ($(USE_OPENMP), 0) endif include $(DMLC_CORE)/make/dmlc.mk +# include the plugins +include $(XGB_PLUGINS) + # use customized config file ifndef CC export CC = $(if $(shell which gcc-5),gcc-5,gcc) diff --git a/make/config.mk b/make/config.mk index d0954fce4..ff6844617 100644 --- a/make/config.mk +++ b/make/config.mk @@ -50,5 +50,5 @@ LIBJVM=$(JAVA_HOME)/jre/lib/amd64/server # List of additional plugins, checkout plugin folder. # uncomment the following lines to include these plugins # you can also add your own plugin like this - -# include plugin/example/plugin.mk +# +# XGB_PLUGINS += plugin/example/plugin.mk diff --git a/plugin/README.md b/plugin/README.md index 445b60f8e..56d973fd3 100644 --- a/plugin/README.md +++ b/plugin/README.md @@ -8,7 +8,7 @@ To include a certain plugin, say ```plugin_a```, you only need to add the follow ```makefile # Add plugin by include the plugin in config -include plugin/plugin_a/plugin.mk +XGB_PLUGINS += plugin/plugin_a/plugin.mk ``` Then rebuild libxgboost by typing make, you can get a new library with the plugin enabled. diff --git a/plugin/example/README.md b/plugin/example/README.md index 7a3eb6685..f0ff5478c 100644 --- a/plugin/example/README.md +++ b/plugin/example/README.md @@ -12,7 +12,7 @@ There are three steps you need to to do to add plugin to xgboost To add this plugin, add the following line to ```config.mk```(template in make/config.mk). ```makefile # Add plugin by include the plugin in config -include plugin/example/plugin.mk +XGB_PLUGINS += plugin/plugin_a/plugin.mk ``` Then you can test this plugin by using ```objective=mylogistic``` parameter. diff --git a/plugin/lz4/sparse_page_lz4_format.cc b/plugin/lz4/sparse_page_lz4_format.cc index 11d80defe..f8421238b 100644 --- a/plugin/lz4/sparse_page_lz4_format.cc +++ b/plugin/lz4/sparse_page_lz4_format.cc @@ -104,7 +104,8 @@ inline void CompressArray::InitCompressChunks(size_t chunk_size, size_t m chunk_size = std::max(min_chunk_size, chunk_size); size_t nstep = data.size() / chunk_size; for (size_t i = 0; i < nstep; ++i) { - raw_chunks_.push_back(raw_chunks_.back() + chunk_size * i); + raw_chunks_.push_back(raw_chunks_.back() + chunk_size); + CHECK_LE(raw_chunks_.back(), data.size()); } if (nstep == 0) raw_chunks_.push_back(0); raw_chunks_.back() = data.size(); diff --git a/src/common/quantile.h b/src/common/quantile.h index 824689e3a..72ebf5a16 100644 --- a/src/common/quantile.h +++ b/src/common/quantile.h @@ -658,7 +658,8 @@ class QuantileSketchTemplate { CHECK_EQ(fi.Read(&this->size, sizeof(this->size)), sizeof(this->size)); this->Reserve(this->size); if (this->size != 0) { - CHECK_EQ(fi.Read(this->data, this->size * sizeof(Entry)), sizeof(this->size)); + CHECK_EQ(fi.Read(this->data, this->size * sizeof(Entry)), + this->size * sizeof(Entry)); } } };