update
This commit is contained in:
parent
29d63c2424
commit
7c8fa8de85
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,4 +3,5 @@
|
|||||||
build
|
build
|
||||||
filteredReads.txt
|
filteredReads.txt
|
||||||
reversedSequence.txt
|
reversedSequence.txt
|
||||||
vsxmake*
|
vsxmake*
|
||||||
|
*.txt
|
11
src/main.cpp
11
src/main.cpp
@ -10,15 +10,8 @@ void reverseComplement(char *begin, char *end)
|
|||||||
{'G', 'C'}, {'g', 'C'}
|
{'G', 'C'}, {'g', 'C'}
|
||||||
};
|
};
|
||||||
|
|
||||||
// std::reverse(begin, end); //翻转DNA序列
|
std::reverse(begin, end); //翻转DNA序列
|
||||||
// 并行翻转序列 //似乎没用
|
|
||||||
#pragma omp parallel for
|
|
||||||
for (ptrdiff_t i = 0; i < (end - begin) / 2; ++i) {
|
|
||||||
std::swap(begin[i], begin[(end - begin) - i - 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 并行查表替换
|
|
||||||
#pragma omp parallel for
|
|
||||||
for (ptrdiff_t i = 0; i < (end - begin); ++i) {
|
for (ptrdiff_t i = 0; i < (end - begin); ++i) {
|
||||||
static int _ = (zt::print(NAME_VALUE(omp_get_num_threads()),"\n"),0); // 打印线程数量
|
static int _ = (zt::print(NAME_VALUE(omp_get_num_threads()),"\n"),0); // 打印线程数量
|
||||||
auto it = complement.find(begin[i]);
|
auto it = complement.find(begin[i]);
|
||||||
|
@ -117,13 +117,37 @@ namespace dna {
|
|||||||
{
|
{
|
||||||
Spent calculate_spent(zt::fmt("calculate_chunk_id:[",chunk_id,"]"));
|
Spent calculate_spent(zt::fmt("calculate_chunk_id:[",chunk_id,"]"));
|
||||||
|
|
||||||
while((end_pos=buf_str_v.find('\n',start_pos)) != std::string_view::npos){
|
#pragma omp parallel
|
||||||
if(get_lines_add()){
|
#pragma omp single
|
||||||
reverseComplement(buf.data()+start_pos, buf.data()+end_pos); //我想要这个函数并行优化
|
{
|
||||||
|
while ((end_pos = buf_str_v.find('\n', start_pos)) != std::string_view::npos) {
|
||||||
|
char *start = buf.data() + start_pos;
|
||||||
|
char *end = buf.data() + end_pos;
|
||||||
|
|
||||||
|
// 确保每个任务只操作属于它的独立数据
|
||||||
|
if (get_lines_add()) {
|
||||||
|
// 为每一块数据创建一个任务
|
||||||
|
#pragma omp task firstprivate(start, end)
|
||||||
|
{
|
||||||
|
reverseComplement(start, end); // 任务内处理反转互补
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
start_pos = end_pos + 1;
|
||||||
}
|
}
|
||||||
// lines=!lines;
|
|
||||||
start_pos=end_pos+1;
|
// 等待所有任务完成
|
||||||
|
#pragma omp taskwait
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// while((end_pos=buf_str_v.find('\n',start_pos)) != std::string_view::npos){
|
||||||
|
// if(get_lines_add()){
|
||||||
|
// reverseComplement(buf.data()+start_pos, buf.data()+end_pos); //我想要这个函数并行优化
|
||||||
|
// }
|
||||||
|
// // lines=!lines;
|
||||||
|
// start_pos=end_pos+1;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if(start_pos!=buf_len){
|
if(start_pos!=buf_len){
|
||||||
|
@ -15,7 +15,7 @@ if is_mode("release")then
|
|||||||
end
|
end
|
||||||
|
|
||||||
if is_plat("windows")then
|
if is_plat("windows")then
|
||||||
add_cxxflags("/openmp")
|
add_cxxflags("/openmp:llvm")
|
||||||
elseif is_plat("linux") or is_plat("mingw") or is_plat("clang")then
|
elseif is_plat("linux") or is_plat("mingw") or is_plat("clang")then
|
||||||
add_cxxflags("-fopenmp")
|
add_cxxflags("-fopenmp")
|
||||||
add_ldflags("-fopenmp")
|
add_ldflags("-fopenmp")
|
||||||
|
Loading…
Reference in New Issue
Block a user