File: ParallelMemHash.h

package info (click to toggle)
libmems 1.6.0%2B4725-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 2,120 kB
  • sloc: cpp: 21,579; ansic: 4,312; xml: 115; makefile: 103; sh: 26
file content (75 lines) | stat: -rw-r--r-- 1,976 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*******************************************************************************
 * $Id: ParallelMemHash.h,v 1.23 2004/03/01 02:40:08 darling Exp $
 * This file is copyright 2002-2007 Aaron Darling and authors listed in the AUTHORS file.
 * This file is licensed under the GPL.
 * Please see the file called COPYING for licensing details.
 * **************
 ******************************************************************************/

#ifndef _ParallelMemHash_h_
#define _ParallelMemHash_h_

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifdef _OPENMP

#include "libMUSCLE/threadstorage.h"
#include <omp.h>
#include "libMems/MemHash.h"

namespace mems {


/**
 * ParallelMemHash implements an algorithm for finding exact matches of a certain minimal
 * length in several sequences.
 */
class ParallelMemHash : public MemHash {
public:
	ParallelMemHash();
	ParallelMemHash(const ParallelMemHash& mh);
	ParallelMemHash& operator=( const ParallelMemHash& mh );
	virtual ParallelMemHash* Clone() const;
	
	/**
	 * Finds (in parallel) all matches in the sequences contained by "match_list"
	 * The resulting list of matches is stored within "match_list"
	 */
	virtual void FindMatches( MatchList& match_list );


protected:
	virtual MatchHashEntry* AddHashEntry(MatchHashEntry& mhe);
	virtual void MergeTable();

	TLS< std::vector< std::vector<MatchHashEntry*> > > thread_mem_table;
};


}

#else // _OPENMP

namespace mems {


/**
 * When built without OpenMP, the ParallelMemHash is just a stub wrapper around MemHash
 */
class ParallelMemHash : public MemHash {
public:
	ParallelMemHash() : MemHash();
	ParallelMemHash(const ParallelMemHash& mh) : MemHash(mh);
	ParallelMemHash& operator=( const ParallelMemHash& mh ) : MemHash::operator=(mh){ return *this; }
	virtual ParallelMemHash* Clone() const{ return new ParallelMemHash(*this); }
};


}


#endif // _OPENMP

#endif //_ParallelMemHash_h_