NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
defs.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 
31 
34 
35 #pragma once
36 
37 //#define NVBIO_CUDA_DEBUG
38 //#define NVBIO_CUDA_NON_BLOCKING_ASSERTS
39 //#define NVBIO_CUDA_ASSERTS
40 
41 #define USE_TEX 1
42 #define USE_TEX_READS 1
43 #define USE_UINT4_PACKING 0
44 
45 #if USE_TEX
46 #define TEX_STATEMENT(x) x
47 #define TEX_SELECTOR( vec, tex ) tex
48 #else
49 #define TEX_STATEMENT(x)
50 #define TEX_SELECTOR( vec, tex ) vec
51 #endif
52 
53 #if USE_TEX_READS
54 #define READ_TEX_STATEMENT(x) x
55 #define READ_TEX_SELECTOR( vec, tex ) tex
56 #else
57 #define READ_TEX_STATEMENT(x)
58 #define READ_TEX_SELECTOR( vec, tex ) vec
59 #endif
60 
61 #define USE_WARP_SYNCHRONOUS_QUEUES 1
62 #define USE_REVERSE_INDEX 0
63 
64 #define DO_OPTIONAL_SYNCHRONIZE 1
65 #define DO_DEVICE_TIMING 0
66 
67 #define DP_REPORT_MULTIPLE 0
68 
69 #include <nvbio/basic/cuda/arch.h>
70 #include <nvbio/basic/pod.h>
71 #include <nvbio/io/sequence/sequence.h> // FIXME: for PE_POLICY!
72 #include <algorithm>
73 
74 namespace nvbio {
75 namespace bowtie2 {
76 namespace cuda {
77 
80 
83 
84 enum EndType { kSingleEnd = 0u, kPairedEnds = 1u };
85 
86 // We assume reads contain, on average, this many bps
87 enum { AVG_READ_LENGTH = 175 };
88 // The device will launch blocks of size BLOCKDIM.
89 enum { BLOCKDIM = 96 };
90 // The device will launch blocks of size BLOCKDIM.
91 enum { SCORE_MATE_BLOCKDIM = 128 };
92 // Edit distance kernel band size.
93 // for N errors we need band length 2*N+1
94 enum { MAX_BAND_LEN = 63 };
95 // We allow for at most this read length
96 enum { MAXIMUM_READ_LENGTH = 512 };
97 // We allow for at most this insert length
98 enum { MAXIMUM_INSERT_LENGTH = 1024 };
99 // We allow for at most this band length
100 enum { MAXIMUM_BAND_LENGTH = 31 };
101 // We allow at most MAXIMUM_BAND_LENGTH*MAXIMUM_BAND_LEN_MULT errors
103 
104 enum { BANDED_DP_CHECKPOINTS = 16 };
105 enum { FULL_DP_CHECKPOINTS = 64 };
106 
107 // Maximum number of words allocated for local memory strings
108 enum { LMEM_CACHE_WORDS = 64 };
109 
112 
117 {
119  bool select;
120  bool locate;
121  bool score;
122  bool score_bad;
124  bool reduce;
125  bool traceback;
126  bool asserts;
127 
128  NVBIO_FORCEINLINE NVBIO_HOST_DEVICE bool show_select (const uint32 id) const { return select && id == read_id; }
129  NVBIO_FORCEINLINE NVBIO_HOST_DEVICE bool show_locate (const uint32 id) const { return locate && id == read_id; }
130  NVBIO_FORCEINLINE NVBIO_HOST_DEVICE bool show_score (const uint32 id, const bool good) const { return score && id == read_id && (score_bad || good); }
131  NVBIO_FORCEINLINE NVBIO_HOST_DEVICE bool show_score_info (const uint32 id) const { return score_info && id == read_id; }
132  NVBIO_FORCEINLINE NVBIO_HOST_DEVICE bool show_reduce (const uint32 id) const { return reduce && id == read_id; }
133  NVBIO_FORCEINLINE NVBIO_HOST_DEVICE bool show_traceback (const uint32 id) const { return traceback && id == read_id; }
134 };
135 
136 enum {
145 };
146 
148 
153 {
156 
158  packed_read(const uint32 _read_id, const uint32 _top_flag = 1u) :
159  read_id( _read_id ), top_flag(_top_flag) {}
160 
162 };
163 
172 {
175 
177  packed_seed(const uint32 _pos_in_read, const uint32 _index_dir, const uint32 _rc, const uint32 _top_flag) :
178  pos_in_read(_pos_in_read), index_dir(_index_dir), rc(_rc), top_flag(_top_flag) {}
179 
181 };
182 
185 struct pack_read
186 {
189 
192  pack_read() : top_flag(0u) {}
193 
198  pack_read(const uint32 _top_flag) : top_flag(_top_flag) {}
199 
203  packed_read operator() (const uint32 i) const { return packed_read(i, top_flag); }
204 
206 };
207 
209 
210 } // namespace cuda
211 } // namespace bowtie2
212 } // namespace nvbio