38 template <
typename string_type>
43 const string_type
string,
46 thrust::device_vector<uint8> d_temp_storage;
55 qgrams.resize( string_len );
56 index.resize( string_len );
58 thrust::device_vector<qgram_type> d_all_qgrams( align<32>( string_len ) * 2u );
59 thrust::device_vector<uint32> d_temp_index( string_len );
63 thrust::make_counting_iterator<uint32>(0u),
64 thrust::make_counting_iterator<uint32>(0u) + string_len,
70 thrust::make_counting_iterator<uint32>(0u),
71 thrust::make_counting_iterator<uint32>(0u) + string_len,
75 cub::DoubleBuffer<qgram_type> key_buffers;
76 cub::DoubleBuffer<uint32> value_buffers;
78 key_buffers.selector = 0;
79 value_buffers.selector = 0;
81 key_buffers.d_buffers[1] =
nvbio::raw_pointer( d_all_qgrams ) + align<32>( string_len );
85 size_t temp_storage_bytes = 0;
88 cub::DeviceRadixSort::SortPairs( NULL, temp_storage_bytes, key_buffers, value_buffers, string_len, 0u, Q * symbol_size );
91 d_temp_storage.clear();
92 d_temp_storage.resize( temp_storage_bytes );
95 cub::DeviceRadixSort::SortPairs(
nvbio::raw_pointer( d_temp_storage ), temp_storage_bytes, key_buffers, value_buffers, string_len, 0u, Q * symbol_size );
98 if (value_buffers.selector)
99 index.swap( d_temp_index );
102 thrust::device_vector<uint32> d_counts( string_len + 1u );
106 key_buffers.d_buffers[ key_buffers.selector ],
119 thrust::plus<uint32>(),
127 if (n_slots != string_len)
128 throw runtime_error(
"mismatching number of q-grams: inserted %u q-grams, got: %u\n" );
140 lut_size *= ALPHABET_SIZE;
143 lut.resize( lut_size+1 );
161 template <
typename string_set_type>
182 return make_uint2( string_id, global_idx - base_offset );
194 template <
typename string_set_type,
typename seed_functor>
198 const string_set_type string_set,
199 const seed_functor seeder,
202 thrust::device_vector<uint8> d_temp_storage;
215 thrust::device_vector<qgram_type> d_all_qgrams( align<32>(
n_qgrams ) * 2u );
216 thrust::device_vector<uint2> d_temp_index(
n_qgrams );
222 d_all_qgrams.begin(),
226 cub::DoubleBuffer<qgram_type> key_buffers;
227 cub::DoubleBuffer<uint64> value_buffers;
229 key_buffers.selector = 0;
230 value_buffers.selector = 0;
236 size_t temp_storage_bytes = 0;
239 cub::DeviceRadixSort::SortPairs( NULL, temp_storage_bytes, key_buffers, value_buffers,
n_qgrams, 0u, Q * symbol_size );
242 d_temp_storage.clear();
243 d_temp_storage.resize( temp_storage_bytes );
246 cub::DeviceRadixSort::SortPairs(
nvbio::raw_pointer( d_temp_storage ), temp_storage_bytes, key_buffers, value_buffers,
n_qgrams, 0u, Q * symbol_size );
249 if (value_buffers.selector)
250 index.swap( d_temp_index );
256 thrust::device_vector<uint32> d_counts(
n_qgrams + 1u );
260 key_buffers.d_buffers[ key_buffers.selector ],
273 thrust::plus<uint32>(),
282 throw runtime_error(
"mismatching number of q-grams: inserted %u q-grams, got: %u\n" );
294 lut_size *= ALPHABET_SIZE;
297 lut.resize( lut_size+1 );
318 template <
typename string_set_type>
322 const string_set_type string_set,
335 template <
typename SystemTag>
353 template <
typename SystemTag>
371 template <
typename SystemTag>
388 template <
typename SystemTag>
417 template <
typename string_type,
typename index_iterator,
typename qgram_iterator>
422 const string_type
string,
424 const index_iterator indices,
425 qgram_iterator qgrams)
447 template <
typename string_set_type,
typename index_iterator,
typename qgram_iterator>
451 const string_set_type string_set,
453 const index_iterator indices,
454 qgram_iterator qgrams)