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

MikkelSchubert / adapterremoval / #45

20 Sep 2024 06:49PM UTC coverage: 26.244% (-49.2%) from 75.443%
#45

push

travis-ci

web-flow
attempt to fix coveralls run

2458 of 9366 relevant lines covered (26.24%)

4362.23 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"  // declarations
20
#include "debug.hpp" // for AR_FAIL
21

22
#ifdef MESON
23
#include "config-ar3.hpp" // for HAVE_SSE2, HAVE_AVX2, HAVE_AVX512...
24
#else
25
#define HAVE_SSE2 1
26
#define HAVE_AVX2 1
27

28
#if __GNUC__ >= 11 || (defined(__clang_major__) && __clang_major__ >= 8)
29
#define HAVE_AVX512 1
30
#else
31
#pragma GCC warning "AVX512 support requires GCC >= 11.0 or Clang >= 8.0"
32
#define HAVE_AVX512 0
33
#endif
34
#endif
35

36
namespace adapterremoval {
37

38
namespace simd {
39

40
bool
41
compare_subsequences_std(size_t& n_mismatches,
42
                         size_t& n_ambiguous,
43
                         const char* seq_1,
44
                         const char* seq_2,
45
                         size_t length,
46
                         size_t max_penalty);
47

48
bool
49
compare_subsequences_sse2(size_t& n_mismatches,
50
                          size_t& n_ambiguous,
51
                          const char* seq_1,
52
                          const char* seq_2,
53
                          size_t length,
54
                          size_t max_penalty);
55

56
bool
57
compare_subsequences_avx2(size_t& n_mismatches,
58
                          size_t& n_ambiguous,
59
                          const char* seq_1,
60
                          const char* seq_2,
61
                          size_t length,
62
                          size_t max_penalty);
63

64
bool
65
compare_subsequences_avx512(size_t& n_mismatches,
66
                            size_t& n_ambiguous,
67
                            const char* seq_1,
68
                            const char* seq_2,
69
                            size_t length,
70
                            size_t max_penalty);
71

72
std::vector<instruction_set>
73
supported()
40✔
74
{
75
  std::vector<instruction_set> choices = { instruction_set::none };
80✔
76

77
#if HAVE_SSE2
78
  if (__builtin_cpu_supports("sse2")) {
40✔
79
    choices.push_back(instruction_set::sse2);
80✔
80
  }
81
#endif
82

83
#if HAVE_AVX2
84
  if (__builtin_cpu_supports("avx2")) {
40✔
85
    choices.push_back(instruction_set::avx2);
80✔
86
  }
87
#endif
88

89
#if HAVE_AVX512
90
  if (__builtin_cpu_supports("avx512bw")) {
40✔
91
    choices.push_back(instruction_set::avx512);
×
92
  }
93
#endif
94

95
  return choices;
40✔
96
}
×
97

98
const char*
99
name(instruction_set value)
405✔
100
{
101
  switch (value) {
405✔
102
    case instruction_set::none:
103
      return "none";
104
    case instruction_set::sse2:
135✔
105
      return "SSE2";
135✔
106
    case instruction_set::avx2:
135✔
107
      return "AVX2";
135✔
108
    case instruction_set::avx512:
×
109
      return "AVX512";
×
110
    default:
×
111
      AR_FAIL("SIMD function not implemented!");
×
112
  }
113
}
114

115
size_t
116
padding(instruction_set value)
525✔
117
{
118
  switch (value) {
525✔
119
    case instruction_set::none:
120
      return 0;
121
    case instruction_set::sse2:
122
#if HAVE_SSE2
123
      return 15;
124
#else
125
      AR_FAIL("SSE2 not supported!");
126
#endif
127
    case instruction_set::avx2:
128
#if HAVE_AVX2
129
      return 31;
130
#else
131
      AR_FAIL("AVX2 not supported!");
132
#endif
133
    case instruction_set::avx512:
134
#if HAVE_AVX512
135
      return 0;
136
#else
137
      AR_FAIL("AVX512 not supported!");
138
#endif
139
    default:
×
140
      AR_FAIL("SIMD function not implemented!");
×
141
  }
142
}
143

144
compare_subsequences_func
145
get_compare_subsequences_func(instruction_set is)
525✔
146
{
147
  switch (is) {
525✔
148
    case instruction_set::none:
149
      return &compare_subsequences_std;
150
    case instruction_set::sse2:
175✔
151
#if HAVE_SSE2
152
      return &compare_subsequences_sse2;
175✔
153
#else
154
      AR_FAIL("SSE2 not supported!");
155
#endif
156
    case instruction_set::avx2:
175✔
157
#if HAVE_AVX2
158
      return &compare_subsequences_avx2;
175✔
159
#else
160
      AR_FAIL("AVX2 not supported!");
161
#endif
162
    case instruction_set::avx512:
×
163
#if HAVE_AVX512
164
      return &compare_subsequences_avx512;
×
165
#else
166
      AR_FAIL("AVX512 not supported!");
167
#endif
168
    default:
×
169
      AR_FAIL("SIMD function not implemented!");
×
170
  }
171
}
172

173
} // namespace simd
174

175
} // 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