|
@@ -69,14 +69,12 @@ void sort_precompute_evalplan(uint32_t N, threadid_t nthreads)
|
|
|
pthread_mutex_unlock(&precomp_eps.mutex);
|
|
|
}
|
|
|
|
|
|
-// Perform the sort using up to nthreads threads. The items to sort are
|
|
|
-// byte arrays of size msg_size. The key is the first 4 bytes of each
|
|
|
-// item.
|
|
|
-void sort_mtobliv(threadid_t nthreads, uint8_t* items, uint16_t msg_size,
|
|
|
- uint32_t Nr, uint32_t Na,
|
|
|
- // the arguments to the callback are items, the sorted indices, and
|
|
|
- // the number of non-padding items
|
|
|
- std::function<void(const uint8_t*, const uint64_t*, uint32_t Nr)> cb)
|
|
|
+// Shuffle Nr items at the beginning of an allocated array of Na items
|
|
|
+// using up to nthreads threads. The items to shuffle are byte arrays
|
|
|
+// of size msg_size. Return Nw, the size of the Waksman network we
|
|
|
+// used, which must satisfy Nr <= Nw <= Na.
|
|
|
+uint32_t shuffle_mtobliv(threadid_t nthreads, uint8_t* items, uint16_t msg_size,
|
|
|
+ uint32_t Nr, uint32_t Na)
|
|
|
{
|
|
|
// Find the smallest Nw for which we have a precomputed
|
|
|
// WaksmanNetwork with Nr <= Nw <= Na
|
|
@@ -127,6 +125,21 @@ void sort_mtobliv(threadid_t nthreads, uint8_t* items, uint16_t msg_size,
|
|
|
wn.value().applyInversePermutation<OSWAP_16X>(
|
|
|
items, msg_size, eval_plan);
|
|
|
|
|
|
+ return Nw;
|
|
|
+}
|
|
|
+
|
|
|
+// Perform the sort using up to nthreads threads. The items to sort are
|
|
|
+// byte arrays of size msg_size. The key is the 10-bit storage server
|
|
|
+// id concatenated with the 22-bit uid at the storage server.
|
|
|
+void sort_mtobliv(threadid_t nthreads, uint8_t* items, uint16_t msg_size,
|
|
|
+ uint32_t Nr, uint32_t Na,
|
|
|
+ // the arguments to the callback are items, the sorted indices, and
|
|
|
+ // the number of non-padding items
|
|
|
+ std::function<void(const uint8_t*, const uint64_t*, uint32_t Nr)> cb)
|
|
|
+{
|
|
|
+ // Shuffle the items
|
|
|
+ uint32_t Nw = shuffle_mtobliv(nthreads, items, msg_size, Nr, Na);
|
|
|
+
|
|
|
// Create the indices
|
|
|
uint64_t *idx = new uint64_t[Nr];
|
|
|
uint64_t *nextidx = idx;
|