Skip to content

Commit

Permalink
trying to bring thread affinitization, various lock types, TBB fully …
Browse files Browse the repository at this point in the history
…over from Bowtie2
  • Loading branch information
BenLangmead committed Mar 20, 2016
1 parent 8d999ce commit d2d908f
Show file tree
Hide file tree
Showing 18 changed files with 418 additions and 223 deletions.
31 changes: 25 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ ifneq (,$(findstring Darwin,$(shell uname)))
ifneq (,$(findstring 13,$(shell uname -r)))
CPP = clang++
CC = clang
EXTRA_FLAGS += -stdlib=libstdc++
override EXTRA_FLAGS += -stdlib=libstdc++
endif
ifneq (,$(findstring 14,$(shell uname -r)))
CPP = clang++
CC = clang
EXTRA_FLAGS += -stdlib=libstdc++
override EXTRA_FLAGS += -stdlib=libstdc++
endif
endif

LINUX = 0
ifneq (,$(findstring Linux,$(shell uname)))
LINUX = 1
EXTRA_FLAGS += -Wl,--hash-style=both
override EXTRA_FLAGS += -Wl,--hash-style=both
endif

MM_DEF =
Expand All @@ -75,21 +75,25 @@ PTHREAD_DEF =

ifeq (1,$(MINGW))
PTHREAD_LIB =
EXTRA_FLAGS += -static-libgcc -static-libstdc++
override EXTRA_FLAGS += -static-libgcc -static-libstdc++
else
PTHREAD_LIB = -lpthread
endif

ifeq (1,$(NO_SPINLOCK))
override EXTRA_FLAGS += -DNO_SPINLOCK
endif

ifeq (1,$(WITH_TBB))
LIBS = $(PTHREAD_LIB) -ltbb -ltbbmalloc_proxy
EXTRA_FLAGS += -DWITH_TBB
override EXTRA_FLAGS += -DWITH_TBB
else
LIBS = $(PTHREAD_LIB)
endif

POPCNT_CAPABILITY ?= 1
ifeq (1, $(POPCNT_CAPABILITY))
EXTRA_FLAGS += -DPOPCNT_CAPABILITY
override EXTRA_FLAGS += -DPOPCNT_CAPABILITY
INC += -I third_party
endif

Expand All @@ -110,12 +114,27 @@ ifeq (1,$(WITH_THREAD_PROFILING))
override EXTRA_FLAGS += -DPER_THREAD_TIMING=1
endif

ifeq (1,$(WITH_AFFINITY))
override EXTRA_FLAGS += -DWITH_AFFINITY=1
endif

ifeq (1,$(WITH_QUEUELOCK))
override EXTRA_FLAGS += -DWITH_QUEUELOCK=1
endif

ifeq (1,$(WITH_FINE_TIMER))
override EXTRA_FLAGS += -DUSE_FINE_TIMER=1
endif

OTHER_CPPS = ccnt_lut.cpp ref_read.cpp alphabet.cpp shmem.cpp \
edit.cpp ebwt.cpp

ifeq (1,$(WITH_COHORTLOCK))
LIBS += -lnuma
override EXTRA_FLAGS += -DWITH_COHORTLOCK=1
OTHER_CPPS += cohort.cpp cpu_numa_info.cpp
endif

ifneq (1,$(WITH_TBB))
OTHER_CPPS += tinythread.cpp
endif
Expand Down
1 change: 0 additions & 1 deletion SeqAn-1.1/seqan/file/file_format_cgviz.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ void _write_impl(TFile& target, Align<TSource, TSpec>& align, TStringContainer&
SEQAN_CHECKPOINT

typedef Align<TSource, TSpec> const TAlign;
typedef typename Row<TAlign>::Type TRow;
typedef typename Position<typename Rows<TAlign>::Type>::Type TRowsPosition;
typedef typename Position<TAlign>::Type TPosition;
TRowsPosition row_count = length(rows(align));
Expand Down
4 changes: 0 additions & 4 deletions SeqAn-1.1/seqan/file/file_format_fasta_align.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ SEQAN_CHECKPOINT
TSize numRows=length(beg_end_length) / 3;
resize(rows(align), numRows); //rows

typedef Align<TSource, TSpec> TAlign;
typedef typename Row<TAlign>::Type TRow;

for(TSize i=0;i<numRows;++i) {
TSize begin = beg_end_length[i*3];
// TSize end = beg_end_length[i*3+1];
Expand Down Expand Up @@ -249,7 +246,6 @@ void _write_impl(TFile& file, Align<TSource, TSpec>& align, TStringContainer& id
typedef Align<TSource, TSpec> const TAlign;
typedef typename Row<TAlign>::Type TRow;
typedef typename Position<typename Rows<TAlign>::Type>::Type TRowsPosition;
typedef typename Position<TAlign>::Type TPosition;
TRowsPosition row_count = length(rows(align));

for(TRowsPosition i=0;i<row_count;++i) {
Expand Down
8 changes: 2 additions & 6 deletions aligner_0mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ class UnpairedExactAlignerV1Factory : public AlignerFactory {
strandFix_(strandFix),
rangeMode_(rangeMode),
verbose_(verbose),
quiet_(quiet),
seed_(seed)
quiet_(quiet)
{
assert(ebwtFw.isInMemory());
}
Expand Down Expand Up @@ -133,7 +132,6 @@ class UnpairedExactAlignerV1Factory : public AlignerFactory {
bool rangeMode_;
bool verbose_;
bool quiet_;
uint32_t seed_;
};

/**
Expand Down Expand Up @@ -201,8 +199,7 @@ class PairedExactAlignerV1Factory : public AlignerFactory {
strandFix_(strandFix),
rangeMode_(rangeMode),
verbose_(verbose),
quiet_(quiet),
seed_(seed)
quiet_(quiet)
{
assert(ebwtFw.isInMemory());
}
Expand Down Expand Up @@ -376,7 +373,6 @@ class PairedExactAlignerV1Factory : public AlignerFactory {
const bool rangeMode_;
const bool verbose_;
const bool quiet_;
const uint32_t seed_;
};

#endif /* ALIGNER_0MM_H_ */
8 changes: 2 additions & 6 deletions aligner_1mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ class Unpaired1mmAlignerV1Factory : public AlignerFactory {
strandFix_(strandFix),
rangeMode_(rangeMode),
verbose_(verbose),
quiet_(quiet),
seed_(seed)
quiet_(quiet)
{
assert(ebwtFw.isInMemory());
assert(ebwtBw != NULL);
Expand Down Expand Up @@ -170,7 +169,6 @@ class Unpaired1mmAlignerV1Factory : public AlignerFactory {
bool rangeMode_;
bool verbose_;
bool quiet_;
uint32_t seed_;
};

/**
Expand Down Expand Up @@ -239,8 +237,7 @@ class Paired1mmAlignerV1Factory : public AlignerFactory {
strandFix_(strandFix),
rangeMode_(rangeMode),
verbose_(verbose),
quiet_(quiet),
seed_(seed)
quiet_(quiet)
{
assert(ebwtBw != NULL);
assert(ebwtFw.isInMemory());
Expand Down Expand Up @@ -488,7 +485,6 @@ class Paired1mmAlignerV1Factory : public AlignerFactory {
const bool rangeMode_;
const bool verbose_;
const bool quiet_;
const uint32_t seed_;
};

#endif /* ALIGNER_1MM_H_ */
8 changes: 2 additions & 6 deletions aligner_23mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ class Unpaired23mmAlignerV1Factory : public AlignerFactory {
strandFix_(strandFix),
rangeMode_(rangeMode),
verbose_(verbose),
quiet_(quiet),
seed_(seed)
quiet_(quiet)
{
assert(ebwtFw.isInMemory());
assert(ebwtBw != NULL);
Expand Down Expand Up @@ -240,7 +239,6 @@ class Unpaired23mmAlignerV1Factory : public AlignerFactory {
const bool rangeMode_;
const bool verbose_;
const bool quiet_;
uint32_t seed_;
};

/**
Expand Down Expand Up @@ -312,8 +310,7 @@ class Paired23mmAlignerV1Factory : public AlignerFactory {
strandFix_(strandFix),
rangeMode_(rangeMode),
verbose_(verbose),
quiet_(quiet),
seed_(seed)
quiet_(quiet)
{
assert(ebwtBw != NULL);
assert(ebwtFw.isInMemory());
Expand Down Expand Up @@ -685,7 +682,6 @@ class Paired23mmAlignerV1Factory : public AlignerFactory {
const bool rangeMode_;
const bool verbose_;
const bool quiet_;
const uint32_t seed_;
};

#endif /* ALIGNER_23MM_H_ */
6 changes: 3 additions & 3 deletions bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class SyncBitset {
*/
bool test(uint32_t i) {
bool ret;
GUARD_LOCK(mutex_m);
ThreadSafe _ts(&mutex_m);
ret = testUnsync(i);
return ret;
}
Expand All @@ -103,7 +103,7 @@ class SyncBitset {
* it has been set. Uses synchronization.
*/
void set(uint32_t i) {
GUARD_LOCK(mutex_m);
ThreadSafe _ts(&mutex_m);
while(i >= _sz) {
// Slow path: bitset needs to be expanded before the
// specified bit can be set
Expand All @@ -123,7 +123,7 @@ class SyncBitset {
* synchronization.
*/
void setOver(uint32_t i) {
GUARD_LOCK(mutex_m);
ThreadSafe _ts(&mutex_m);
while(i >= _sz) {
// Slow path: bitset needs to be expanded before the
// specified bit can be set
Expand Down
16 changes: 8 additions & 8 deletions ebwt_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ static Ebwt<String<Dna> >* exactSearch_ebwt;
static vector<String<Dna5> >* exactSearch_os;
static BitPairReference* exactSearch_refs;
#ifdef WITH_TBB
void exactSearchWorker::operator()() {
void exactSearchWorker::operator()() const {
#else
static void exactSearchWorker(void *vp) {
int tid = *((int*)vp);
Expand Down Expand Up @@ -1218,7 +1218,7 @@ static void exactSearchWorker(void *vp) {
* A statefulness-aware worker driver. Uses UnpairedExactAlignerV1.
*/
#ifdef WITH_TBB
void exactSearchWorkerStateful::operator()() {
void exactSearchWorkerStateful::operator()() const {
#else
static void exactSearchWorkerStateful(void *vp) {
int tid = *((int*)vp);
Expand Down Expand Up @@ -1402,7 +1402,7 @@ static BitPairReference* mismatchSearch_refs;
* A statefulness-aware worker driver. Uses Unpaired/Paired1mmAlignerV1.
*/
#ifdef WITH_TBB
void mismatchSearchWorkerFullStateful::operator()() {
void mismatchSearchWorkerFullStateful::operator()() const {
#else
static void mismatchSearchWorkerFullStateful(void *vp) {
int tid = *((int*)vp);
Expand Down Expand Up @@ -1487,7 +1487,7 @@ static void mismatchSearchWorkerFullStateful(void *vp) {
return;
}
#ifdef WITH_TBB
void mismatchSearchWorkerFull::operator()(){
void mismatchSearchWorkerFull::operator()() const {
#else
static void mismatchSearchWorkerFull(void *vp){
int tid = *((int*)vp);
Expand Down Expand Up @@ -1734,7 +1734,7 @@ static BitPairReference* twoOrThreeMismatchSearch_refs;
* A statefulness-aware worker driver. Uses UnpairedExactAlignerV1.
*/
#ifdef WITH_TBB
void twoOrThreeMismatchSearchWorkerStateful::operator()(){
void twoOrThreeMismatchSearchWorkerStateful::operator()() const {
#else
static void twoOrThreeMismatchSearchWorkerStateful(void *vp) {
int tid = *((int*)vp);
Expand Down Expand Up @@ -1822,7 +1822,7 @@ static void twoOrThreeMismatchSearchWorkerStateful(void *vp) {
return;
}
#ifdef WITH_TBB
void twoOrThreeMismatchSearchWorkerFull::operator()(){
void twoOrThreeMismatchSearchWorkerFull::operator()() const {
#else
static void twoOrThreeMismatchSearchWorkerFull(void *vp) {
int tid = *((int*)vp);
Expand Down Expand Up @@ -2042,7 +2042,7 @@ static int seededQualSearch_qualCutoff;
static BitPairReference* seededQualSearch_refs;

#ifdef WITH_TBB
void seededQualSearchWorkerFull::operator()(){
void seededQualSearchWorkerFull::operator()() const {
#else
static void seededQualSearchWorkerFull(void *vp) {
int tid = *((int*)vp);
Expand Down Expand Up @@ -2268,7 +2268,7 @@ static void seededQualSearchWorkerFull(void *vp) {
WORKER_EXIT();
}
#ifdef WITH_TBB
void seededQualSearchWorkerFullStateful::operator()(){
void seededQualSearchWorkerFullStateful::operator()() const {
#else
static void seededQualSearchWorkerFullStateful(void *vp) {
int tid = *((int*)vp);
Expand Down
16 changes: 8 additions & 8 deletions ebwt_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class exactSearchWorkerStateful {
public:
exactSearchWorkerStateful(const exactSearchWorkerStateful& W): tid(W.tid) {};
exactSearchWorkerStateful(int id):tid(id) {};
void operator()();
void operator()() const;
};

class exactSearchWorker {
Expand All @@ -27,7 +27,7 @@ class exactSearchWorker {
public:
exactSearchWorker(const exactSearchWorker& W): tid(W.tid) {};
exactSearchWorker(int id):tid(id) {};
void operator()();
void operator()() const;

};

Expand All @@ -37,7 +37,7 @@ class mismatchSearchWorkerFull {
public:
mismatchSearchWorkerFull(const mismatchSearchWorkerFull& W): tid(W.tid) {};
mismatchSearchWorkerFull(int id):tid(id) {};
void operator()();
void operator()() const;

};

Expand All @@ -47,7 +47,7 @@ class mismatchSearchWorkerFullStateful {
public:
mismatchSearchWorkerFullStateful(const mismatchSearchWorkerFullStateful& W): tid(W.tid) {};
mismatchSearchWorkerFullStateful(int id):tid(id) {};
void operator()();
void operator()() const;

};
class twoOrThreeMismatchSearchWorkerStateful {
Expand All @@ -56,7 +56,7 @@ class twoOrThreeMismatchSearchWorkerStateful {
public:
twoOrThreeMismatchSearchWorkerStateful(const twoOrThreeMismatchSearchWorkerStateful& W): tid(W.tid) {};
twoOrThreeMismatchSearchWorkerStateful(int id):tid(id) {};
void operator()();
void operator()() const;

};
class twoOrThreeMismatchSearchWorkerFull {
Expand All @@ -65,7 +65,7 @@ class twoOrThreeMismatchSearchWorkerFull {
public:
twoOrThreeMismatchSearchWorkerFull(const twoOrThreeMismatchSearchWorkerFull& W): tid(W.tid) {};
twoOrThreeMismatchSearchWorkerFull(int id):tid(id) {};
void operator()();
void operator()() const;

};

Expand All @@ -75,7 +75,7 @@ class seededQualSearchWorkerFullStateful {
public:
seededQualSearchWorkerFullStateful(const seededQualSearchWorkerFullStateful& W): tid(W.tid) {};
seededQualSearchWorkerFullStateful(int id):tid(id) {};
void operator()();
void operator()() const;

};
class seededQualSearchWorkerFull {
Expand All @@ -84,7 +84,7 @@ class seededQualSearchWorkerFull {
public:
seededQualSearchWorkerFull(const seededQualSearchWorkerFull& W): tid(W.tid) {};
seededQualSearchWorkerFull(int id):tid(id) {};
void operator()();
void operator()() const;

};

Expand Down
Loading

0 comments on commit d2d908f

Please sign in to comment.