Permalink
Browse files

Added the tiny thread spinlock and started the tiny thread usage impl…

…ementation changes.
  • Loading branch information...
1 parent a4964e9 commit 2e3ee1a71b3285b0e4dccb13aa8132df94791f2b @val-antonescu val-antonescu committed Mar 21, 2013
Showing with 315 additions and 148 deletions.
  1. +33 −42 Makefile
  2. +7 −8 bitset.h
  3. +248 −0 fast_mutex.h
  4. +6 −42 pat.h
  5. +21 −56 threading.h
View
@@ -5,13 +5,10 @@
SEQAN_DIR = SeqAn-1.1
SEQAN_INC = -I $(SEQAN_DIR)
INC = $(SEQAN_INC)
-GCC_PREFIX = $(shell dirname `which gcc`)
-GCC_SUFFIX =
-CC = $(GCC_PREFIX)/gcc$(GCC_SUFFIX)
-CPP = $(GCC_PREFIX)/g++$(GCC_SUFFIX)
+CPP = g++
CXX = $(CPP)
+CC = gcc
HEADERS = $(wildcard *.h)
-BOWTIE_PTHREADS = 1
BOWTIE_MM = 1
BOWTIE_SHARED_MEM = 1
EXTRA_FLAGS =
@@ -25,64 +22,62 @@ WINDOWS = 0
CYGWIN = 0
MINGW = 0
ifneq (,$(findstring CYGWIN,$(shell uname)))
-WINDOWS = 1
-CYGWIN = 1
-# POSIX memory-mapped files not currently supported on Windows
-BOWTIE_MM = 0
-BOWTIE_SHARED_MEM = 0
+ WINDOWS = 1
+ CYGWIN = 1
+ # POSIX memory-mapped files not currently supported on Windows
+ BOWTIE_MM = 0
+ BOWTIE_SHARED_MEM = 0
else
-ifneq (,$(findstring MINGW,$(shell uname)))
-WINDOWS = 1
-CYGWIN = 1
-# POSIX memory-mapped files not currently supported on Windows
-BOWTIE_MM = 0
-BOWTIE_SHARED_MEM = 0
-endif
+ ifneq (,$(findstring MINGW,$(shell uname)))
+ WINDOWS = 1
+ CYGWIN = 1
+ # POSIX memory-mapped files not currently supported on Windows
+ BOWTIE_MM = 0
+ BOWTIE_SHARED_MEM = 0
+ endif
endif
MACOS = 0
ifneq (,$(findstring Darwin,$(shell uname)))
-MACOS = 1
+ MACOS = 1
endif
LINUX = 0
ifneq (,$(findstring Linux,$(shell uname)))
-LINUX = 1
-EXTRA_FLAGS += -Wl,--hash-style=both
+ LINUX = 1
+ EXTRA_FLAGS += -Wl,--hash-style=both
endif
MM_DEF =
ifeq (1,$(BOWTIE_MM))
-MM_DEF = -DBOWTIE_MM
+ MM_DEF = -DBOWTIE_MM
endif
SHMEM_DEF =
ifeq (1,$(BOWTIE_SHARED_MEM))
-SHMEM_DEF = -DBOWTIE_SHARED_MEM
+ SHMEM_DEF = -DBOWTIE_SHARED_MEM
endif
PTHREAD_PKG =
PTHREAD_LIB =
PTHREAD_DEF =
-ifeq (1,$(BOWTIE_PTHREADS))
-PTHREAD_DEF = -DBOWTIE_PTHREADS
-PTHREAD_LIB = -lpthread
+
ifeq (1,$(MINGW))
-# pthreads for windows forces us to be specific about the library
-EXTRA_FLAGS = -static-libgcc -static-libstdc++
-PTHREAD_LIB = -lpthread
-endif
+ PTHREAD_LIB =
+ EXTRA_FLAGS = -static-libgcc -static-libstdc++
+else
+ PTHREAD_LIB = -lpthread
endif
PREFETCH_LOCALITY = 2
PREF_DEF = -DPREFETCH_LOCALITY=$(PREFETCH_LOCALITY)
-LIBS =
-SEARCH_LIBS = $(PTHREAD_LIB)
+LIBS = $(PTHREAD_LIB)
+SEARCH_LIBS =
BUILD_LIBS =
INSPECT_LIBS =
ifeq (1,$(MINGW))
-BUILD_LIBS = $(PTHREAD_LIB)
-INSPECT_LIBS = $(PTHREAD_LIB)
+ BUILD_LIBS =
+ INSPECT_LIBS =
endif
OTHER_CPPS = ccnt_lut.cpp ref_read.cpp alphabet.cpp shmem.cpp \
@@ -100,16 +95,18 @@ VERSION = $(shell cat VERSION)
# msys will always be 32 bit so look at the cpu arch instead.
ifneq (,$(findstring AMD64,$(PROCESSOR_ARCHITEW6432)))
-BITS=64
+ ifeq (1,$(MINGW))
+ BITS=64
+ endif
endif
# Convert BITS=?? to a -m flag
BITS_FLAG =
ifeq (32,$(BITS))
-BITS_FLAG = -m32
+ BITS_FLAG = -m32
endif
ifeq (64,$(BITS))
-BITS_FLAG = -m64
+ BITS_FLAG = -m64
endif
DEBUG_FLAGS = -O0 -g3 $(BITS_FLAG)
@@ -144,16 +141,10 @@ GENERAL_LIST = $(wildcard scripts/*.sh) \
TUTORIAL \
VERSION
-# This is helpful on Windows under MinGW/MSYS, where Make might go for
-# the Windows FIND tool instead.
-FIND=$(shell which find)
-
SRC_PKG_LIST = $(wildcard *.h) \
$(wildcard *.hh) \
$(wildcard *.c) \
$(wildcard *.cpp) \
- $(shell $(FIND) SeqAn-1.1 -name "*.h") \
- $(shell $(FIND) SeqAn-1.1 -name "*.txt") \
doc/strip_markdown.pl \
Makefile \
$(GENERAL_LIST)
View
@@ -57,7 +57,6 @@ class SyncBitset {
* error message and quit if allocation fails.
*/
SyncBitset(uint32_t sz, const char *errmsg = NULL) : _errmsg(errmsg) {
- MUTEX_INIT(_lock);
uint32_t nwords = (sz >> 5)+1; // divide by 32 and add 1
try {
_words = new uint32_t[nwords];
@@ -94,9 +93,9 @@ class SyncBitset {
*/
bool test(uint32_t i) {
bool ret;
- MUTEX_LOCK(_lock);
+ mutex_m.lock();
ret = testUnsync(i);
- MUTEX_UNLOCK(_lock);
+ mutex_m.unlock();
return ret;
}
@@ -105,7 +104,7 @@ class SyncBitset {
* it has been set. Uses synchronization.
*/
void set(uint32_t i) {
- MUTEX_LOCK(_lock);
+ mutex_m.lock();
while(i >= _sz) {
// Slow path: bitset needs to be expanded before the
// specified bit can be set
@@ -118,15 +117,15 @@ class SyncBitset {
assert(((_words[i >> 5] >> (i & 0x1f)) & 1) == 0);
_words[i >> 5] |= (1 << (i & 0x1f));
assert(((_words[i >> 5] >> (i & 0x1f)) & 1) == 1);
- MUTEX_UNLOCK(_lock);
+ mutex_m.unlock();
}
/**
* Set a bit in the vector that might have already been set. Uses
* synchronization.
*/
void setOver(uint32_t i) {
- MUTEX_LOCK(_lock);
+ mutex_m.lock();
while(i >= _sz) {
// Slow path: bitset needs to be expanded before the
// specified bit can be set
@@ -138,7 +137,7 @@ class SyncBitset {
assert_lt(i, _sz);
_words[i >> 5] |= (1 << (i & 0x1f));
assert(((_words[i >> 5] >> (i & 0x1f)) & 1) == 1);
- MUTEX_UNLOCK(_lock);
+ mutex_m.unlock();
}
@@ -156,7 +155,7 @@ class SyncBitset {
const char *_errmsg; // error message if an allocation fails
uint32_t _sz; // size as # of bits
- MUTEX_T _lock; // mutex
+ MUTEX_T mutex_m; // mutex
uint32_t *_words; // storage
};
Oops, something went wrong.

0 comments on commit 2e3ee1a

Please sign in to comment.