@@ -13,6 +13,31 @@ function _sample_sort_histogram!(
1313end
1414
1515
16+ function _sample_sort_compute_offsets!(histograms, max_tasks)
17+ @inbounds begin
18+ # Sum up histograms and compute global offsets for each task
19+ offsets = @view histograms[1 : max_tasks, max_tasks + 1 ]
20+ for itask in 1 : max_tasks
21+ for j in 1 : max_tasks
22+ offsets[j] += histograms[j, itask]
23+ end
24+ end
25+ accumulate!(+ , offsets, init= 0 , inclusive= false )
26+
27+ # Compute each task's local offset into each bucket
28+ for itask in 1 : max_tasks
29+ accumulate!(
30+ + , @view(histograms[itask, 1 : max_tasks]),
31+ init= 0 ,
32+ inclusive= false ,
33+ )
34+ end
35+ end
36+
37+ offsets
38+ end
39+
40+
1641function _sample_sort_move_buckets!(
1742 v, dest, ord,
1843 splitters, global_offsets, task_offsets,
@@ -41,31 +66,6 @@ function _sample_sort_move_buckets!(
4166end
4267
4368
44- function _sample_sort_compute_offsets!(histograms, max_tasks)
45- @inbounds begin
46- # Sum up histograms and compute global offsets for each task
47- offsets = @view histograms[1 : max_tasks, max_tasks + 1 ]
48- for itask in 1 : max_tasks
49- for j in 1 : max_tasks
50- offsets[j] += histograms[j, itask]
51- end
52- end
53- accumulate!(+ , offsets, init= 0 , inclusive= false )
54-
55- # Compute each task's local offset into each bucket
56- for itask in 1 : max_tasks
57- accumulate!(
58- + , @view(histograms[itask, 1 : max_tasks]),
59- init= 0 ,
60- inclusive= false ,
61- )
62- end
63- end
64-
65- offsets
66- end
67-
68-
6969function _sample_sort_sort_bucket!(
7070 v, dest, offsets, itask, max_tasks;
7171 lt, by, rev, order
0 commit comments