 		(1 & numPasses) ? valsDest : valsSource, support.ranges_global, 
 		comp);
 	MGPU_SYNC_CHECK("KernelSegBlocksortFlags");
+
+	std::vector<int> rangesHost(numBlocks);
+	copyDtoH(&rangesHost[0], support.ranges_global, numBlocks);
 
 	if(1 & numPasses) {
 		std::swap(keysSource, keysDest);


template<typename KeyType, typename ValType, typename Comp>
MGPU_HOST void SegSortPairsFromFlags(KeyType* keys_global,
	ValType* values_global,  int count, const uint* flags_global,
	CudaContext& context, Comp comp, bool verbose) {

	const bool Stable = true;

	const int NV = NT * VT;
	struct Shared {
		union {
			KeyType keys[NV + VT];
			ValType values[NV];
		};
		union {
