NVBIO
Main Page
Modules
Classes
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
nvBowtie
bowtie2
cuda
seed_hit_deque_array_inl.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
namespace
nvbio {
29
namespace
bowtie2 {
30
namespace
cuda {
31
32
// return the device view
33
//
34
inline
35
SeedHitDequeArrayDeviceView
SeedHitDequeArray::device_view
()
36
{
37
return
SeedHitDequeArrayDeviceView
(
38
nvbio::device_view
(
m_counts
),
39
nvbio::device_view
(
m_index
),
40
nvbio::device_view
(
m_hits
),
41
nvbio::device_view
(
m_probs_index
),
42
nvbio::device_view
(
m_probs
),
43
nvbio::device_view
(
m_pool
),
44
nvbio::device_view
(
m_probs_pool
) );
45
}
46
47
// constructor
48
//
49
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
50
SeedHitDequeArrayDeviceView::SeedHitDequeArrayDeviceView
(
51
index_storage_type
counts,
52
index_storage_type
index,
53
hits_storage_type
hits,
54
index_storage_type
probs_index,
55
prob_storage_type
probs,
56
index_storage_type
pool,
57
index_storage_type
probs_pool) :
58
m_counts( counts ),
59
m_hits( hits ),
60
m_probs( probs ),
61
m_index( index ),
62
m_probs_index( probs_index ),
63
m_pool( pool ),
64
m_probs_pool( probs_pool )
65
{}
66
67
// return a reference to the given deque
68
//
69
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
70
SeedHitDequeArrayDeviceView::reference
SeedHitDequeArrayDeviceView::operator[]
(
const
uint32
read_id)
71
{
72
return
reference
( *
this
, read_id );
73
}
74
75
// allocate some storage for the deque bound to a given read
76
//
77
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
78
SeedHit
*
SeedHitDequeArrayDeviceView::alloc_deque
(
const
uint32
read_id,
const
uint32
size)
79
{
80
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ > 0
81
m_counts
[read_id] = 0u;
82
const
uint32
index = size ? atomicAdd(
m_pool
, size ) : 0u;
83
const
uint32
probs_index = size ? atomicAdd(
m_probs_pool
,
SumTree<float*>::node_count
( size ) ) : 0u;
84
if
(index <
m_hits
.size())
85
{
86
m_index
[read_id] = index;
87
m_probs_index
[read_id] = probs_index;
88
return
m_hits
+
m_index
[read_id];
89
}
90
else
91
{
92
// allocation failed
93
m_index
[read_id] = 0;
94
m_probs_index
[read_id] = 0;
95
return
NULL;
96
}
97
#else
98
return
NULL;
99
#endif
100
}
101
102
// return the deque bound to a given read
103
//
104
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
105
typename
SeedHitDequeArrayDeviceView::hit_deque_type
SeedHitDequeArrayDeviceView::get_deque
(
const
uint32
read_id,
bool
build_heap)
const
106
{
107
hit_vector_type
hit_vector(
m_counts
[read_id],
get_data
( read_id ) );
108
return
hit_deque_type
( hit_vector, build_heap );
109
}
110
111
}
// namespace cuda
112
}
// namespace bowtie2
113
}
// namespace nvbio
Generated on Wed Feb 25 2015 08:33:06 for NVBIO by
1.8.4