1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #pragma once
- #include <nvbio/basic/timer.h>
- #include <nvbio/basic/cuda/timer.h>
- #include <cuda_runtime.h>
- namespace nvbio {
- namespace bowtie2 {
- namespace cuda {
- inline void optional_device_synchronize()
- {
- #if DO_OPTIONAL_SYNCHRONIZE
- cudaDeviceSynchronize();
- #endif
- }
- #if DO_DEVICE_TIMING
- typedef nvbio::cuda::Timer DeviceTimer;
- #else
- typedef nvbio::FakeTimer DeviceTimer;
- #endif
- NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
- uint2 inclusive_to_exclusive(const uint2 range) { return make_uint2( range.x, range.y + 1u ); }
- #ifdef __CUDACC__
- NVBIO_FORCEINLINE NVBIO_DEVICE uint32 alloc(uint32* counter, volatile uint32 *warp_broadcast)
- {
- #if USE_WARP_SYNCHRONOUS_QUEUES
- const uint32 mask = __ballot( true );
- const uint32 pop_scan = __popc( mask << (32u - warp_tid()) );
- const uint32 pop_count = __popc( mask );
- if (pop_scan == 0)
- *warp_broadcast = atomicAdd( counter, pop_count );
- return *warp_broadcast + pop_scan;
- #else
- return atomicAdd( counter, 1u );
- #endif
- }
- #endif
- }
- }
- }
|