-
Notifications
You must be signed in to change notification settings - Fork 0
/
parallelslidesort.h
223 lines (199 loc) · 7.08 KB
/
parallelslidesort.h
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#include <omp.h>
class BlockCombination
{
public:
TYPE_INDEX fst_head;
TYPE_INDEX fst_size;
TYPE_INDEX snd_head;
TYPE_INDEX snd_size;
bool isMapMode;
bool isPartialMode;
// for Hadoop
TYPE_INDEX fst_byte_head;
TYPE_INDEX fst_byte_size;
TYPE_INDEX snd_byte_head;
TYPE_INDEX snd_byte_size;
BlockCombination() {}
~BlockCombination() {}
// BlockCombination のデフォルトコンストラクタ
BlockCombination(const BlockCombination& rbc) {
fst_head = rbc.fst_head;
fst_size = rbc.fst_size;
snd_head = rbc.snd_head;
snd_size = rbc.snd_size;
isMapMode = rbc.isMapMode;
isPartialMode = rbc.isPartialMode;
fst_byte_head = rbc.fst_byte_head;
fst_byte_size = rbc.fst_byte_size;
snd_byte_head = rbc.snd_byte_head;
snd_byte_size = rbc.snd_byte_size;
}
// BlockCombination のコピーコンストラクタ
BlockCombination& Copy(const BlockCombination& rbc) {
if(this == &rbc) {
return *this;
}
fst_head = rbc.fst_head;
fst_size = rbc.fst_size;
snd_head = rbc.snd_head;
snd_size = rbc.snd_size;
isMapMode = rbc.isMapMode;
isPartialMode = rbc.isPartialMode;
fst_byte_head = rbc.fst_byte_head;
fst_byte_size = rbc.fst_byte_size;
snd_byte_head = rbc.snd_byte_head;
snd_byte_size = rbc.snd_byte_size;
return *this;
}
BlockCombination& operator =(const BlockCombination& rbc) {
return Copy(rbc);
}
};
class BlockInformation
{
public:
TYPE_INDEX head;
TYPE_INDEX size;
// for Hadoop
unsigned long long int byte_head;
unsigned long long int byte_size;
BlockInformation() {}
~BlockInformation() {}
// BlockInformation のデフォルトコンストラクタ
BlockInformation(const BlockInformation& rbi) {
head = rbi.head;
size = rbi.size;
byte_head = rbi.byte_head;
byte_size = rbi.byte_size;
}
// BlockInformation のコピーコンストラクタ
BlockInformation& Copy(const BlockInformation& rbi) {
if(this == &rbi) {
return *this;
}
head = rbi.head;
size = rbi.size;
byte_head = rbi.byte_head;
byte_size = rbi.byte_size;
return *this;
}
BlockInformation& operator =(const BlockInformation& rbi) {
return Copy(rbi);
}
};
class blockutil
{
public:
bool isMapMode;
bool isMergeBlock;
int getBlockInfo(unsigned int proc_num, TYPE_INDEX *seq_head, TYPE_INDEX *seq_num, vector<BlockInformation> &fbi, vector<BlockInformation> &sbi, char *msg);
int pushBlockInfo(vector<BlockInformation> &bi, TYPE_INDEX seq_head, TYPE_INDEX seq_num, TYPE_INDEX block_num);
int calcBlockNum(unsigned int proc_num, TYPE_INDEX *seq_num, TYPE_INDEX *block_num);
int setBlockCombination(vector<BlockInformation> &fbi, vector<BlockInformation> &sbi, vector<BlockCombination> &bc);
int calcDivisor(unsigned int num, vector<unsigned int> * ds);
int calcBlockNumForMap(unsigned int proc_num, vector<unsigned int> *ds, TYPE_INDEX *seq_num, TYPE_INDEX *block_num);
int calcBlockForNormal(unsigned int proc_num, unsigned int *real_proc_num, unsigned int *virt_proc_num, TYPE_INDEX *block_num);
int mergeBlockCombination(TYPE_INDEX block_num, vector < vector <TYPE_INDEX> > &bc_info, vector<BlockCombination> &bc);
int countSeqForFasta(string *filename);
int countSeqForFastq(string *filename);
int convertBytesForFasta(vector<BlockInformation> &fbi, vector<BlockInformation> &sbi, string *filename);
int convertBytesForFastq(vector<BlockInformation> &fbi, vector<BlockInformation> &sbi, string *filename);
void debugPrintBlockInformation(vector<BlockInformation> &bi);
blockutil() {
isMergeBlock = true;
}
};
class blockOptions
{
private:
void debugPrintOptions();
void debugPrintGetSeqSize(TYPE_INDEX *seq_head, TYPE_INDEX *seq_num);
public:
TYPE_INDEX num_of_seq;
TYPE_INDEX proc_num;
TYPE_INDEX fst_head;
TYPE_INDEX snd_head;
TYPE_INDEX fst_size;
TYPE_INDEX snd_size;
long long int fst_bz;
long long int snd_bz;
int inputFileType;
bool isMapMode;
bool isPartialMode;
string inputFileName;
int setOptions(int argc, char **argv);
int getSeqSize(TYPE_INDEX num_of_seq, TYPE_INDEX *seq_head, TYPE_INDEX *seq_num);
blockOptions(){
isMapMode = false;
inputFileType=FORMAT_FASTA;
fst_bz = 0;
snd_bz = 0;
}
};
class blockCountOptions
{
private:
void debugPrintOptions();
public:
TYPE_INDEX proc_num;
long long int fst_bz;
long long int snd_bz;
int inputFileType;
bool isMapMode;
bool isPartialMode;
string inputFileName;
int setOptions(int argc, char **argv);
blockCountOptions(){
inputFileType=FORMAT_FASTA;
isMapMode = false;
fst_bz = 0;
snd_bz = 0;
}
};
class parallelslidesort : public multisort
{
private:
omp_lock_t myLock;
double gettimeofday_sec();
int dieWithMsg(char *msg);
void debugprint(vector<BlockInformation> &fbi, vector<BlockInformation> &sbi, vector<BlockCombination> &bc);
public:
TYPE_INDEX mt; // -mt オプションの値
TYPE_INDEX mr; // -mr オプションの値
TYPE_INDEX mp; // -mp オプションの値
bool isMTOptSet; // -mt オプション設定:1, なし:false
bool isMROptSet; // -mr オプション設定:1, なし:false
bool isMPOptSet; // -mp オプション設定:1, なし:false
BlockCombination *p_bc;
int setResGetFuncPtr(GETRESFUNC fptr);
int getParam(int argc, char **argv);
int getParam(cmlOptions co);
int exec();
int ss_main();
int setPSSOptions(int argc, char **argv, char *msg);
TYPE_INDEX getPSSOptions(char *argv);
bool chkOpts(char *opt);
bool isNumber(char *str);
int getSeqSize(TYPE_INDEX *seq_head, TYPE_INDEX *seq_num);
int getFstSizeForMap();
int getBlockInfo(vector<BlockInformation> &fbi, vector<BlockInformation> &sbi, char *msg);
int printHeader(seq *sq);
};
class pssExecutor : public multisort
{
private:
omp_lock_t *myLock_ptr;
BlockCombination *p_bc;
public:
int execCallbackFunc(const char *seqid1, const char *seqid2, TYPE_INDEX index_of_seq1, TYPE_INDEX index_of_seq2, char* aln1, char* aln2, double dist, int aln_size);
void setMyLock(omp_lock_t *myLock);
void setBC(BlockCombination *p_bc);
};
// マルチ処理数の上限値
#define LIMIT_PROCS 1225 // ブロック数50の場合のマルチ処理数
// parallelslidesort のオプション名
#define OPT_MT "mt"
#define OPT_MR "mr"
#define OPT_MP "mp"
#define TYPE_BYTE_SIZE unsigned long long
//#define DEBUG_PSS