• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MikkelSchubert / adapterremoval / #39

20 Aug 2024 01:31PM UTC coverage: 79.602% (-3.8%) from 83.365%
#39

push

travis-ci

MikkelSchubert
update schema URL to use github pages

2279 of 2863 relevant lines covered (79.6%)

14257.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.71
/src/simd.cpp
1
/*************************************************************************\
2
 * AdapterRemoval - cleaning next-generation sequencing reads            *
3
 *                                                                       *
4
 * Copyright (C) 2022 by Mikkel Schubert - mikkelsch@gmail.com           *
5
 *                                                                       *
6
 * This program is free software: you can redistribute it and/or modify  *
7
 * it under the terms of the GNU General Public License as published by  *
8
 * the Free Software Foundation, either version 3 of the License, or     *
9
 * (at your option) any later version.                                   *
10
 *                                                                       *
11
 * This program is distributed in the hope that it will be useful,       *
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 * GNU General Public License for more details.                          *
15
 *                                                                       *
16
 * You should have received a copy of the GNU General Public License     *
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. *
18
\*************************************************************************/
19
#include "simd.hpp"
20
#include "debug.hpp"
21
#include <string> // for basic_string
22

23
namespace adapterremoval {
24

25
namespace simd {
26

27
bool
28
compare_subsequences_std(size_t& n_mismatches,
29
                         size_t& n_ambiguous,
30
                         const char* seq_1,
31
                         const char* seq_2,
32
                         size_t length,
33
                         size_t max_penalty);
34

35
bool
36
compare_subsequences_sse2(size_t& n_mismatches,
37
                          size_t& n_ambiguous,
38
                          const char* seq_1,
39
                          const char* seq_2,
40
                          size_t length,
41
                          size_t max_penalty);
42

43
bool
44
compare_subsequences_avx2(size_t& n_mismatches,
45
                          size_t& n_ambiguous,
46
                          const char* seq_1,
47
                          const char* seq_2,
48
                          size_t length,
49
                          size_t max_penalty);
50

51
#ifdef AR_SUPPORTS_AVX512
52
bool
53
compare_subsequences_avx512(size_t& n_mismatches,
54
                            size_t& n_ambiguous,
55
                            const char* seq_1,
56
                            const char* seq_2,
57
                            size_t length,
58
                            size_t max_penalty);
59
#endif
60

61
std::vector<instruction_set>
62
supported()
38✔
63
{
64
  std::vector<instruction_set> choices = { instruction_set::none };
76✔
65

66
  if (__builtin_cpu_supports("sse2")) {
38✔
67
    choices.push_back(instruction_set::sse2);
76✔
68
  }
69

70
  if (__builtin_cpu_supports("avx2")) {
38✔
71
    choices.push_back(instruction_set::avx2);
76✔
72
  }
73

74
#ifdef AR_SUPPORTS_AVX512
75
  if (__builtin_cpu_supports("avx512bw")) {
38✔
76
    choices.push_back(instruction_set::avx512);
×
77
  }
78
#endif
79

80
  return choices;
38✔
81
}
×
82

83
const char*
84
name(instruction_set value)
405✔
85
{
86
  switch (value) {
405✔
87
    case instruction_set::none:
88
      return "none";
89
    case instruction_set::sse2:
135✔
90
      return "SSE2";
135✔
91
    case instruction_set::avx2:
135✔
92
      return "AVX2";
135✔
93
#ifdef AR_SUPPORTS_AVX512
94
    case instruction_set::avx512:
×
95
      return "AVX512";
×
96
#endif
97
    default:
×
98
      AR_FAIL("SIMD function not implemented!");
×
99
  }
100
}
101

102
size_t
103
padding(instruction_set value)
519✔
104
{
105
  switch (value) {
519✔
106
    case instruction_set::none:
107
      return 0;
108
    case instruction_set::sse2:
109
      return 15;
110
    case instruction_set::avx2:
111
      return 31;
112
#ifdef AR_SUPPORTS_AVX512
113
    case instruction_set::avx512:
114
      return 0;
115
#endif
116
    default:
×
117
      AR_FAIL("SIMD function not implemented!");
×
118
  }
119
}
120

121
compare_subsequences_func
122
get_compare_subsequences_func(instruction_set is)
519✔
123
{
124
  switch (is) {
519✔
125
    case instruction_set::none:
126
      return &compare_subsequences_std;
127
    case instruction_set::sse2:
173✔
128
      return &compare_subsequences_sse2;
173✔
129
    case instruction_set::avx2:
173✔
130
      return &compare_subsequences_avx2;
173✔
131
#ifdef AR_SUPPORTS_AVX512
132
    case instruction_set::avx512:
×
133
      return &compare_subsequences_avx512;
×
134
#endif
135
    default:
×
136
      AR_FAIL("SIMD function not implemented!");
×
137
  }
138
}
139

140
} // namespace simd
141

142
} // namespace adapterremoval
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc