NVBIO
Main Page
Modules
Classes
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
nvbio
fmindex
ssa.h
Go to the documentation of this file.
1
/*
2
* nvbio
3
* Copyright (c) 2011-2014, NVIDIA CORPORATION. All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
7
* * Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* * Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
12
* * Neither the name of the NVIDIA CORPORATION nor the
13
* names of its contributors may be used to endorse or promote products
14
* derived from this software without specific prior written permission.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
* DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
20
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
*/
27
28
#pragma once
29
30
#include <
nvbio/basic/types.h
>
31
#include <
nvbio/basic/popcount.h
>
32
#include <
nvbio/basic/cuda/arch.h
>
33
#include <
nvbio/basic/cuda/ldg.h
>
34
#include <vector_types.h>
35
#include <vector_functions.h>
36
#include <cuda_runtime.h>
37
#include <vector>
38
#include <stdexcept>
39
#include <thrust/device_vector.h>
40
41
namespace
nvbio {
42
45
86
89
90
struct
SSA_value_multiple_device;
91
92
template
<u
int
32 K,
typename
index_type = u
int
32>
93
struct
SSA_index_multiple_device
;
94
98
template
<
typename
SSAIterator,
typename
BitmaskIterator,
typename
BlockIterator>
99
struct
SSA_value_multiple_context
100
{
103
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
SSA_value_multiple_context
() {}
104
107
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
SSA_value_multiple_context
(
108
SSAIterator ssa,
109
BitmaskIterator bitmask,
110
BlockIterator blocks) :
m_ssa
( ssa ),
m_bitmask
( bitmask ),
m_blocks
( blocks ) {}
111
117
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
bool
fetch
(
const
uint32
i,
uint32
& r)
const
;
118
123
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
bool
has
(
const
uint32
i)
const
;
124
125
SSAIterator
m_ssa
;
126
BitmaskIterator
m_bitmask
;
127
BlockIterator
m_blocks
;
128
};
129
134
struct
SSA_value_multiple
135
{
136
typedef
SSA_value_multiple_context
<
137
const
uint32
*,
138
const
uint32
*,
139
const
uint32
*>
context_type
;
140
typedef
SSA_value_multiple_device
device_type
;
141
typedef
context_type
device_view_type
;
142
typedef
context_type
plain_view_type
;
143
146
SSA_value_multiple
() :
m_n
(0),
m_stored
(0) {}
147
153
SSA_value_multiple
(
154
const
uint32
n,
155
const
int32
* sa,
156
const
uint32
K
);
157
162
template
<
typename
FMIndexType>
163
SSA_value_multiple
(
164
const
FMIndexType& fmi,
165
const
uint32
K
);
166
169
context_type
get_context
()
const
170
{
171
return
context_type
( &
m_ssa
[0], &
m_bitmask
[0], &
m_blocks
[0] );
172
}
173
174
uint32
m_n
;
175
uint32
m_stored
;
176
std::vector<uint32>
m_ssa
;
177
std::vector<uint32>
m_bitmask
;
178
std::vector<uint32>
m_blocks
;
179
180
private
:
181
uint32
index(
const
uint32
i)
const
;
182
};
183
184
struct
SSA_value_multiple_device
185
{
186
typedef
SSA_value_multiple_context
<
187
cuda::ldg_pointer<uint32>
,
188
cuda::ldg_pointer<uint32>
,
189
cuda::ldg_pointer<uint32>
>
context_type
;
190
typedef
context_type
device_view_type
;
191
typedef
context_type
plain_view_type
;
192
196
SSA_value_multiple_device
(
const
SSA_value_multiple
& ssa);
197
200
~SSA_value_multiple_device
();
201
204
context_type
get_context
()
const
205
{
206
return
context_type
(
cuda::ldg_pointer<uint32>
(
m_ssa
),
cuda::ldg_pointer<uint32>
(
m_bitmask
),
cuda::ldg_pointer<uint32>
(
m_blocks
) );
207
}
208
209
uint32
m_n
;
210
uint32
m_stored
;
211
uint32
*
m_ssa
;
212
uint32
*
m_bitmask
;
213
uint32
*
m_blocks
;
214
};
215
219
template
<u
int
32 K,
typename
Iterator = const u
int
32*>
220
struct
SSA_index_multiple_context
221
{
222
typedef
typename
std::iterator_traits<Iterator>::value_type
index_type
;
223
typedef
index_type
value_type
;
224
227
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
SSA_index_multiple_context
() {}
228
231
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
SSA_index_multiple_context
(
232
const
Iterator ssa) :
m_ssa
( ssa ) {}
233
239
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
bool
fetch
(
const
index_type
i,
index_type
& r)
const
;
240
245
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
bool
has
(
const
index_type
i)
const
;
246
247
Iterator
m_ssa
;
248
};
249
254
template
<u
int
32 K,
typename
index_type = u
int
32>
255
struct
SSA_index_multiple
256
{
257
typedef
index_type
value_type
;
258
typedef
SSA_index_multiple_context<K, const index_type*>
context_type
;
259
typedef
SSA_index_multiple_device<K,index_type>
device_type
;
260
typedef
context_type
device_view_type
;
261
typedef
context_type
plain_view_type
;
262
265
SSA_index_multiple
() :
m_n
(0) {}
266
271
SSA_index_multiple
(
272
const
index_type n,
273
const
index_type* sa);
274
279
template
<
typename
FMIndexType>
280
SSA_index_multiple
(
281
const
FMIndexType& fmi);
282
286
SSA_index_multiple
(
287
const
SSA_index_multiple_device<K,index_type>
& ssa);
288
292
SSA_index_multiple
&
operator=
(
293
const
SSA_index_multiple_device<K,index_type>
& ssa);
294
297
context_type
get_context
()
const
{
return
context_type
( &
m_ssa
[0] ); }
298
299
index_type
m_n
;
300
std::vector<index_type>
m_ssa
;
301
};
302
303
template
<u
int
32 K,
typename
index_type>
304
struct
SSA_index_multiple_device
305
{
306
typedef
index_type
value_type
;
307
typedef
SSA_index_multiple_context<K, const index_type*>
context_type
;
308
typedef
context_type
device_view_type
;
309
typedef
context_type
plain_view_type
;
310
313
SSA_index_multiple_device
() :
m_n
(0) {}
314
318
SSA_index_multiple_device
(
const
SSA_index_multiple<K, index_type>
& ssa);
319
320
#ifdef __CUDACC__
321
template
<
typename
FMIndexType>
325
SSA_index_multiple_device
(
326
const
FMIndexType& fmi);
327
#endif
328
331
~SSA_index_multiple_device
() {}
332
333
#ifdef __CUDACC__
334
template
<
typename
FMIndexType>
335
void
init(
const
FMIndexType& fmi);
336
#endif
337
340
context_type
get_context
()
const
{
return
context_type
( thrust::raw_pointer_cast(&
m_ssa
[0]) ); }
341
342
index_type
m_n
;
343
thrust::device_vector<index_type>
m_ssa
;
344
};
345
348
inline
349
SSA_value_multiple::plain_view_type
plain_view
(
const
SSA_value_multiple
& vec) {
return
vec.
get_context
(); }
350
353
inline
354
SSA_value_multiple_device::plain_view_type
plain_view
(
const
SSA_value_multiple_device
& vec) {
return
vec.
get_context
(); }
355
358
template
<u
int
32 K,
typename
index_type>
359
typename
SSA_index_multiple<K,index_type>::plain_view_type
plain_view
(
const
SSA_index_multiple<K,index_type>
& vec) {
return
vec.
get_context
(); }
360
361
364
365
}
// namespace nvbio
366
367
#include <
nvbio/fmindex/ssa_inl.h
>
Generated on Wed Feb 25 2015 08:32:59 for NVBIO by
1.8.4