This is an automated email from the git hooks/post-receive script. malex-guest pushed a commit to branch master in repository bowtie2.
commit a003e9ef3246dce097a70dbf1a9caabb1541daa2 Author: Alexandre Mestiashvili <[email protected]> Date: Sat Mar 12 15:25:21 2016 +0100 Imported Upstream version 2.2.8 --- Makefile | 6 +- NEWS | 6 ++ VERSION | 2 +- blockwise_sa.h | 194 ++++++++++++++++++++++++++++++++++++++++----------------- diff_sample.h | 51 ++++++++++++--- 5 files changed, 191 insertions(+), 68 deletions(-) diff --git a/Makefile b/Makefile index 6c93f04..667eda1 100644 --- a/Makefile +++ b/Makefile @@ -210,7 +210,11 @@ GENERAL_LIST = $(wildcard scripts/*.sh) \ ifeq (1,$(WINDOWS)) BOWTIE2_BIN_LIST := $(BOWTIE2_BIN_LIST) bowtie2.bat bowtie2-build.bat bowtie2-inspect.bat - EXTRA_FLAGS += -static-libgcc -static-libstdc++ + ifeq (1,$(WITH_TBB)) + override EXTRA_FLAGS += -static-libgcc -static-libstdc++ + else + override EXTRA_FLAGS += -static -static-libgcc -static-libstdc++ + endif endif # This is helpful on Windows under MinGW/MSYS, where Make might go for diff --git a/NEWS b/NEWS index 105f0a5..eb2c0e8 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,12 @@ Please report any issues using the Sourceforge bug tracker: Version Release History ======================= +Version 2.2.8 - Mar 10, 2016 + * Various website updates. + * Fixed the bowtie2-build issue that made TBB compilation fail. + * Fixed the static build for Win32 platform. + + Version 2.2.7 - Feb 10, 2016 * Added a parallel index build option: bowtie2-build --threads <# threads>. * Fixed an issue whereby IUPAC codes (other than A/C/G/T/N) in reads were diff --git a/VERSION b/VERSION index 5bc1cc4..23a63f5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.7 +2.2.8 diff --git a/blockwise_sa.h b/blockwise_sa.h index 9cae3f2..b11ad28 100644 --- a/blockwise_sa.h +++ b/blockwise_sa.h @@ -20,6 +20,11 @@ #ifndef BLOCKWISE_SA_H_ #define BLOCKWISE_SA_H_ +#ifdef WITH_TBB +#include <tbb/tbb.h> +#include <tbb/task_group.h> +#endif + #include <stdint.h> #include <stdlib.h> #include <iostream> @@ -182,6 +187,8 @@ public: { } }; + + /** * Build the SA a block at a time according to the scheme outlined in * Karkkainen's "Fast BWT" paper. @@ -203,16 +210,24 @@ public: ostream& __logger = cout) : InorderBlockwiseSA<TStr>(__text, __bucketSz, __sanityCheck, __passMemExc, __verbose, __logger), _sampleSuffs(EBWTB_CAT), _nthreads(__nthreads), _itrBucketIdx(0), _cur(0), _dcV(__dcV), _dc(EBWTB_CAT), _built(false), _base_fname(base_fname), _bigEndian(currentlyBigEndian()) - { _randomSrc.init(__seed); reset(); } +#ifdef WITH_TBB +,thread_group_started(false) +#endif + { _randomSrc.init(__seed); reset(); _done = new bool[_nthreads]; } ~KarkkainenBlockwiseSA() { +#ifdef WITH_TBB + tbb_grp.wait(); +#else if(_threads.size() > 0) { for (size_t tid = 0; tid < _threads.size(); tid++) { _threads[tid]->join(); delete _threads[tid]; } } + delete [] _done; +#endif } /** @@ -230,56 +245,38 @@ public: return bsz; } - static void nextBlock_Worker(void *vp) { - pair<KarkkainenBlockwiseSA*, int> param = *(pair<KarkkainenBlockwiseSA*, int>*)vp; - KarkkainenBlockwiseSA* sa = param.first; - int tid = param.second; - while(true) { - size_t cur = 0; - { - ThreadSafe ts(&sa->_mutex, sa->_nthreads > 1); - cur = sa->_cur; - if(cur > sa->_sampleSuffs.size()) break; - sa->_cur++; - } - sa->nextBlock((int)cur, tid); - // Write suffixes into a file - std::ostringstream number; number << cur; - const string fname = sa->_base_fname + "." + number.str() + ".sa"; - ofstream sa_file(fname.c_str(), ios::binary); - if(!sa_file.good()) { - cerr << "Could not open file for writing a reference graph: \"" << fname << "\"" << endl; - throw 1; - } - const EList<TIndexOffU>& bucket = sa->_itrBuckets[tid]; - writeU<TIndexOffU>(sa_file, (TIndexOffU)bucket.size(), sa->_bigEndian); - for(size_t i = 0; i < bucket.size(); i++) { - writeU<TIndexOffU>(sa_file, bucket[i], sa->_bigEndian); - } - sa_file.close(); - sa->_itrBuckets[tid].clear(); - sa->_done[cur] = true; - } - } /** * Get the next suffix; compute the next bucket if necessary. */ - virtual TIndexOffU nextSuffix() { + virtual TIndexOffU nextSuffix() + { // Launch threads if not - if(this->_nthreads > 1) { - if(_threads.size() == 0) { - _done.resize(_sampleSuffs.size() + 1); - _done.fill(false); + if(this->_nthreads > 1) + { +#ifdef WITH_TBB + if(!thread_group_started) + { +#else + if(_threads.size() == 0) + { +#endif _itrBuckets.resize(this->_nthreads); + _tparams.resize(this->_nthreads); for(int tid = 0; tid < this->_nthreads; tid++) { - _tparams.expand(); - _tparams.back().first = this; - _tparams.back().second = tid; - _threads.push_back(new tthread::thread(nextBlock_Worker, (void*)&_tparams.back())); + _tparams[tid].first = this; + _tparams[tid].second = tid; +#ifdef WITH_TBB + tbb_grp.run(nextBlock_Worker((void*)&_tparams[tid])); + } + thread_group_started = true; + } +#else + _threads.push_back(new tthread::thread(nextBlock_Worker, (void*)&_tparams[tid])); } assert_eq(_threads.size(), (size_t)this->_nthreads); } +#endif } if(this->_itrPushedBackSuffix != OFF_MASK) { TIndexOffU tmp = this->_itrPushedBackSuffix; @@ -295,11 +292,14 @@ public: if(this->_nthreads == 1) { nextBlock((int)_cur); _cur++; - } else { - while(!_done[this->_itrBucketIdx]) { + } + else + { + while(!_done[this->_itrBucketIdx]) + { #if defined(_TTHREAD_WIN32_) Sleep(1); -#elif defined(_TTHREAD_POSIX_) +#else const static timespec ts = {0, 1000000}; // 1 millisecond nanosleep(&ts, NULL); #endif @@ -340,6 +340,54 @@ public: /// Return the difference-cover period uint32_t dcV() const { return _dcV; } +//TBB requires a Functor to be passed to the thread group +//hence the nested class +#ifdef WITH_TBB +class nextBlock_Worker { + void *vp; + +public: + + nextBlock_Worker(const nextBlock_Worker& W): vp(W.vp) {}; + nextBlock_Worker(void *vp_):vp(vp_) {}; + void operator()() { +#else + static void nextBlock_Worker(void *vp) { +#endif + pair<KarkkainenBlockwiseSA*, int> param = *(pair<KarkkainenBlockwiseSA*, int>*)vp; + KarkkainenBlockwiseSA* sa = param.first; + int tid = param.second; + while(true) { + size_t cur = 0; + { + ThreadSafe ts(&sa->_mutex, sa->_nthreads > 1); + cur = sa->_cur; + if(cur > sa->_sampleSuffs.size()) break; + sa->_cur++; + } + sa->nextBlock((int)cur, tid); + // Write suffixes into a file + std::ostringstream number; number << cur; + const string fname = sa->_base_fname + "." + number.str() + ".sa"; + ofstream sa_file(fname.c_str(), ios::binary); + if(!sa_file.good()) { + cerr << "Could not open file for writing a reference graph: \"" << fname << "\"" << endl; + throw 1; + } + const EList<TIndexOffU>& bucket = sa->_itrBuckets[tid]; + writeU<TIndexOffU>(sa_file, (TIndexOffU)bucket.size(), sa->_bigEndian); + for(size_t i = 0; i < bucket.size(); i++) { + writeU<TIndexOffU>(sa_file, bucket[i], sa->_bigEndian); + } + sa_file.close(); + sa->_itrBuckets[tid].clear(); + sa->_done[cur] = true; + } + } +#ifdef WITH_TBB +}; +#endif + protected: /** @@ -421,12 +469,19 @@ private: MUTEX_T _mutex; /// synchronization of output message string _base_fname; /// base file name for storing SA blocks bool _bigEndian; /// bigEndian? +#ifdef WITH_TBB + tbb::task_group tbb_grp; /// thread "list" via Intel TBB + bool thread_group_started; +#else EList<tthread::thread*> _threads; /// thread list +#endif EList<pair<KarkkainenBlockwiseSA*, int> > _tparams; ELList<TIndexOffU> _itrBuckets; /// buckets - EList<bool> _done; /// is a block processed? + bool* _done; /// is a block processed? }; + + /** * Qsort the set of suffixes whose offsets are in 'bucket'. */ @@ -495,8 +550,20 @@ struct BinarySortingParam { }; template<typename TStr> +#ifdef WITH_TBB +class BinarySorting_worker { + void *vp; + +public: + + BinarySorting_worker(const BinarySorting_worker& W): vp(W.vp) {}; + BinarySorting_worker(void *vp_):vp(vp_) {}; + void operator()() + { +#else static void BinarySorting_worker(void *vp) { +#endif BinarySortingParam<TStr>* param = (BinarySortingParam<TStr>*)vp; const TStr& t = *(param->t); size_t len = t.length(); @@ -525,6 +592,10 @@ static void BinarySorting_worker(void *vp) } } +#ifdef WITH_TBB +}; +#endif + /** * Select a set of bucket-delineating sample suffixes such that no * bucket is greater than the requested upper limit. Some care is @@ -604,19 +675,23 @@ void KarkkainenBlockwiseSA<TStr>::buildSamples() { // Iterate until all buckets are less than while(--limit >= 0) { TIndexOffU numBuckets = (TIndexOffU)_sampleSuffs.size()+1; +#ifdef WITH_TBB + tbb::task_group tbb_grp; +#else AutoArray<tthread::thread*> threads(this->_nthreads); +#endif EList<BinarySortingParam<TStr> > tparams; + tparams.resize(this->_nthreads); for(int tid = 0; tid < this->_nthreads; tid++) { // Calculate bucket sizes by doing a binary search for each // suffix and noting where it lands - tparams.expand(); try { // Allocate and initialize containers for holding bucket // sizes and representatives. - tparams.back().bucketSzs.resizeExact(numBuckets); - tparams.back().bucketReps.resizeExact(numBuckets); - tparams.back().bucketSzs.fillZero(); - tparams.back().bucketReps.fill(OFF_MASK); + tparams[tid].bucketSzs.resizeExact(numBuckets); + tparams[tid].bucketReps.resizeExact(numBuckets); + tparams[tid].bucketSzs.fillZero(); + tparams[tid].bucketReps.fill(OFF_MASK); } catch(bad_alloc &e) { if(this->_passMemExc) { throw e; // rethrow immediately @@ -627,14 +702,20 @@ void KarkkainenBlockwiseSA<TStr>::buildSamples() { throw 1; } } - tparams.back().t = &t; - tparams.back().sampleSuffs = &_sampleSuffs; - tparams.back().begin = (tid == 0 ? 0 : len / this->_nthreads * tid); - tparams.back().end = (tid + 1 == this->_nthreads ? len : len / this->_nthreads * (tid + 1)); + tparams[tid].t = &t; + tparams[tid].sampleSuffs = &_sampleSuffs; + tparams[tid].begin = (tid == 0 ? 0 : len / this->_nthreads * tid); + tparams[tid].end = (tid + 1 == this->_nthreads ? len : len / this->_nthreads * (tid + 1)); if(this->_nthreads == 1) { - BinarySorting_worker<TStr>((void*)&tparams.back()); + BinarySorting_worker<TStr>((void*)&tparams[tid]); } else { - threads[tid] = new tthread::thread(BinarySorting_worker<TStr>, (void*)&tparams.back()); +#ifdef WITH_TBB + tbb_grp.run(BinarySorting_worker<TStr>(((void*)&tparams[tid]))); + } + } + tbb_grp.wait(); +#else + threads[tid] = new tthread::thread(BinarySorting_worker<TStr>, (void*)&tparams[tid]); } } @@ -643,6 +724,7 @@ void KarkkainenBlockwiseSA<TStr>::buildSamples() { threads[tid]->join(); } } +#endif EList<TIndexOffU>& bucketSzs = tparams[0].bucketSzs; EList<TIndexOffU>& bucketReps = tparams[0].bucketReps; diff --git a/diff_sample.h b/diff_sample.h index 6099421..7c7afff 100644 --- a/diff_sample.h +++ b/diff_sample.h @@ -20,6 +20,11 @@ #ifndef DIFF_SAMPLE_H_ #define DIFF_SAMPLE_H_ +#ifdef WITH_TBB +#include <tbb/tbb.h> +#include <tbb/task_group.h> +#endif + #include <stdint.h> #include <string.h> #include "assert_helpers.h" @@ -683,8 +688,20 @@ struct VSortingParam { }; template<typename TStr> +#ifdef WITH_TBB +class VSorting_worker { + void *vp; + +public: + + VSorting_worker(const VSorting_worker& W): vp(W.vp) {}; + VSorting_worker(void *vp_):vp(vp_) {}; + void operator()() + { +#else static void VSorting_worker(void *vp) { +#endif VSortingParam<TStr>* param = (VSortingParam<TStr>*)vp; DifferenceCoverSample<TStr>* dcs = param->dcs; const TStr& host = dcs->text(); @@ -716,6 +733,10 @@ static void VSorting_worker(void *vp) } } +#ifdef WITH_TBB +}; +#endif + /** * Calculates a ranking of all suffixes in the sample and stores them, * packed according to the mu mapping, in _isaPrime. @@ -787,27 +808,37 @@ void DifferenceCoverSample<TStr>::build(int nthreads) { mkeyQSortSuf2(t, sPrimeArr, sPrimeSz, sPrimeOrderArr, 4, this->verbose(), false, query_depth, &boundaries); if(boundaries.size() > 0) { +#ifdef WITH_TBB + tbb::task_group tbb_grp; +#else AutoArray<tthread::thread*> threads(nthreads); +#endif EList<VSortingParam<TStr> > tparams; size_t cur = 0; MUTEX_T mutex; + tparams.resize(nthreads); for(int tid = 0; tid < nthreads; tid++) { // Calculate bucket sizes by doing a binary search for each // suffix and noting where it lands - tparams.expand(); - tparams.back().dcs = this; - tparams.back().sPrimeArr = sPrimeArr; - tparams.back().sPrimeSz = sPrimeSz; - tparams.back().sPrimeOrderArr = sPrimeOrderArr; - tparams.back().depth = query_depth; - tparams.back().boundaries = &boundaries; - tparams.back().cur = &cur; - tparams.back().mutex = &mutex; - threads[tid] = new tthread::thread(VSorting_worker<TStr>, (void*)&tparams.back()); + tparams[tid].dcs = this; + tparams[tid].sPrimeArr = sPrimeArr; + tparams[tid].sPrimeSz = sPrimeSz; + tparams[tid].sPrimeOrderArr = sPrimeOrderArr; + tparams[tid].depth = query_depth; + tparams[tid].boundaries = &boundaries; + tparams[tid].cur = &cur; + tparams[tid].mutex = &mutex; +#ifdef WITH_TBB + tbb_grp.run(VSorting_worker<TStr>(((void*)&tparams[tid]))); + } + tbb_grp.wait(); +#else + threads[tid] = new tthread::thread(VSorting_worker<TStr>, (void*)&tparams[tid]); } for (int tid = 0; tid < nthreads; tid++) { threads[tid]->join(); } +#endif } if(this->sanityCheck()) { sanityCheckOrderedSufs(t, t.length(), sPrimeArr, sPrimeSz, v); -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/bowtie2.git _______________________________________________ debian-med-commit mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit
