Skip to content

Commit 7b4ceb2

Browse files
committed
updated code to do quicksort for all buckets
1 parent 39fdabf commit 7b4ceb2

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

indexer/qsort.cu

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,17 +338,10 @@ void free_gpu_memory(){
338338
}
339339

340340

341-
static int max_bucket_size = -1;
342-
343-
void quick_sort_bucket(int *device_arr, char *gpu_genome, int bucket_size, int bucket_number, bool last_bucket){
341+
void quick_sort_bucket(int *device_arr, char *gpu_genome, int bucket_size, int bucket_number, bool last_bucket, int max_bucket_size){
344342

345343
if(bucket_number == 0){
346-
alloc_device_pointers(bucket_size);
347-
max_bucket_size = bucket_size;
348-
} else if(max_bucket_size < bucket_size){
349-
free_gpu_memory();
350-
alloc_device_pointers(bucket_size);
351-
max_bucket_size = bucket_size;
344+
alloc_device_pointers(max_bucket_size);
352345
}
353346

354347
quick_sort_genome(device_arr, bucket_size, gpu_genome);

indexer/qsort.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
void set_quickSort_kernel(int suff_size);
66

7-
void quick_sort_bucket(int *device_arr, char *gpu_genome, int bucket_size, int bucket_number, bool last_bucket);
7+
void quick_sort_bucket(int *device_arr, char *gpu_genome, int bucket_size, int bucket_number, bool last_bucket, int max_bucket_size);
88

99
#endif

indexer/sort.cu

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,11 @@ int main( int argc, char** argv)
127127
/*
128128
Do Quick sort here on gpu_aux_arr[0...n_buck]
129129
*/
130-
131-
//quick_sort_bucket(gpu_suf_arr, gpu_genome, suff_size, 0, true);
130+
if(i == b_info->n_buckets-1){
131+
quick_sort_bucket(gpu_aux_arr, gpu_genome, n_buck, i, true, b_info->max_bucket_sz);
132+
} else {
133+
quick_sort_bucket(gpu_aux_arr, gpu_genome, n_buck, i, false, b_info->max_bucket_sz);
134+
}
132135

133136
if(n_buck > 0)
134137
{
@@ -142,18 +145,15 @@ int main( int argc, char** argv)
142145
}
143146
}
144147

145-
/*
146-
CUDA_SAFE_CALL( cudaMemcpy(cpu_final_arr, gpu_suf_arr, sizeof(int) * suff_size, cudaMemcpyDeviceToHost) );
148+
// CUDA_SAFE_CALL( cudaMemcpy(cpu_final_arr, gpu_suf_arr, sizeof(int) * suff_size, cudaMemcpyDeviceToHost) );
147149
cout << "Suffix Array for Genome: " << endl;
148-
print_gene_array(cpu_final_arr, suff_size);
149-
150+
print_gene_array(cpu_suf_arr, suff_size);
150151

151152
cudaEventRecord( stop, 0 );
152153
cudaEventSynchronize( stop );
153154
cudaEventElapsedTime( &elapsedTime, start, stop );
154155

155156
printf("%d %f\n", suff_size, elapsedTime * (0.001));
156-
*/
157157

158158
free_memory();
159159

0 commit comments

Comments
 (0)