Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed doc/equation/Thumbs.db
Binary file not shown.
Binary file removed doc/images/Thumbs.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
#ifndef __BOOST_SORT_PARALLEL_DETAIL_BACKBONE_HPP
#define __BOOST_SORT_PARALLEL_DETAIL_BACKBONE_HPP

#include <ciso646>
#include <atomic>
#include <future>
#include <iostream>
#include <iterator>
#include <boost/sort/pdqsort/pdqsort.hpp>
#include <boost/sort/common/util/atomic.hpp>
#include <boost/sort/common/util/algorithm.hpp>
#include <boost/sort/common/stack_cnc.hpp>
#include <future>
#include <iostream>
#include <iterator>

#include <boost/sort/block_indirect_sort/blk_detail/block.hpp>

namespace boost
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#ifndef __BOOST_SORT_PARALLEL_DETAIL_BLOCK_HPP
#define __BOOST_SORT_PARALLEL_DETAIL_BLOCK_HPP

#include <ciso646>
#include <boost/sort/common/range.hpp>

namespace boost
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
#ifndef __BOOST_SORT_PARALLEL_DETAIL_MERGE_BLOCKS_HPP
#define __BOOST_SORT_PARALLEL_DETAIL_MERGE_BLOCKS_HPP

#include <ciso646>
#include <atomic>
#include <boost/sort/block_indirect_sort/blk_detail/backbone.hpp>
#include <boost/sort/common/range.hpp>
#include <future>
#include <iostream>
#include <iterator>
#include <boost/sort/block_indirect_sort/blk_detail/backbone.hpp>
#include <boost/sort/common/range.hpp>


namespace boost
{
Expand Down Expand Up @@ -103,7 +105,7 @@ struct merge_blocks
{
this->merge_range_pos (rng_input);
}
catch (std::bad_alloc &ba)
catch (std::bad_alloc )
{
error = true;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
#define __BOOST_SORT_PARALLEL_DETAIL_MOVE_BLOCKS_HPP

#include <atomic>
#include <boost/sort/block_indirect_sort/blk_detail/backbone.hpp>
#include <ciso646>
#include <future>
#include <iostream>
#include <iterator>
#include <boost/sort/block_indirect_sort/blk_detail/backbone.hpp>

namespace boost
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#ifndef __BOOST_SORT_PARALLEL_DETAIL_PARALLEL_SORT_HPP
#define __BOOST_SORT_PARALLEL_DETAIL_PARALLEL_SORT_HPP

#include <ciso646>
#include <boost/sort/block_indirect_sort/blk_detail/backbone.hpp>
#include <boost/sort/pdqsort/pdqsort.hpp>
#include <boost/sort/common/pivot.hpp>
Expand Down Expand Up @@ -159,7 +160,7 @@ ::parallel_sort(backbone_t &bkbn, Iter_t first, Iter_t last)
//-------------------max_per_thread ---------------------------
uint32_t nbits_size = (nbits64(sizeof(value_t))) >> 1;
if (nbits_size > 5) nbits_size = 5;
max_per_thread = 1 << (18 - nbits_size);
max_per_thread = (size_t) 1 << (18 - nbits_size);

uint32_t level = ((nbits64(nelem / max_per_thread)) * 3) / 2;

Expand Down
31 changes: 18 additions & 13 deletions include/boost/sort/block_indirect_sort/block_indirect_sort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@
#ifndef __BOOST_SORT_PARALLEL_DETAIL_BLOCK_INDIRECT_SORT_HPP
#define __BOOST_SORT_PARALLEL_DETAIL_BLOCK_INDIRECT_SORT_HPP

#include <ciso646>
#include <atomic>
#include <cstdlib>
#include <future>
#include <iterator>

#include <boost/sort/block_indirect_sort/blk_detail/merge_blocks.hpp>
#include <boost/sort/block_indirect_sort/blk_detail/move_blocks.hpp>
#include <boost/sort/block_indirect_sort/blk_detail/parallel_sort.hpp>
#include <boost/sort/pdqsort/pdqsort.hpp>
#include <boost/sort/common/util/traits.hpp>
#include <boost/sort/common/util/algorithm.hpp>
#include <future>
#include <iterator>


// This value is the minimal number of threads for to use the
// block_indirect_sort algorithm
Expand Down Expand Up @@ -141,7 +145,7 @@ struct block_indirect_sort
destroy(rglobal_buf);
construct = false;
};
std::return_temporary_buffer(ptr);
std::free (ptr);
ptr = nullptr;
};
}
Expand Down Expand Up @@ -223,7 +227,7 @@ ::block_indirect_sort(Iter_t first, Iter_t last, Compare cmp, uint32_t nthr)

uint32_t nbits_size = (nbits64(sizeof(value_t)) >> 1);
if (nbits_size > 5) nbits_size = 5;
size_t max_per_thread = 1 << (18 - nbits_size);
size_t max_per_thread = (size_t) 1 << (18 - nbits_size);

if (nelem < (max_per_thread) or nthread < 2)
{
Expand All @@ -233,8 +237,9 @@ ::block_indirect_sort(Iter_t first, Iter_t last, Compare cmp, uint32_t nthr)
};

//----------- creation of the temporary buffer --------------------
ptr = std::get_temporary_buffer<value_t>(Block_size * nthread).first;
if (ptr == nullptr)
ptr = reinterpret_cast <value_t*>
(std::malloc (Block_size * nthread * sizeof(value_t)));
if (ptr == nullptr)
{
bk.error = true;
throw std::bad_alloc();
Expand Down Expand Up @@ -271,7 +276,7 @@ ::block_indirect_sort(Iter_t first, Iter_t last, Compare cmp, uint32_t nthr)
// thread local buffer
for (uint32_t i = 0; i < nthread; ++i)
{
auto f1 = [=, &vbuf]( )
auto f1 = [=, &vbuf, this]( )
{ bk.exec (vbuf[i], this->counter);};
vfuture[i] = std::async(std::launch::async, f1);
};
Expand Down Expand Up @@ -322,7 +327,7 @@ ::split_range(size_t pos_index1, size_t pos_index2, uint32_t level_thread)
//-------------------------------------------------------------------------
if (level_thread != 0)
{
auto f1 = [=, &son_counter]( )
auto f1 = [=, &son_counter, this]( )
{
split_range (pos_index_mid, pos_index2, level_thread - 1);
bscu::atomic_sub (son_counter, 1);
Expand All @@ -334,7 +339,7 @@ ::split_range(size_t pos_index1, size_t pos_index2, uint32_t level_thread)
else
{
Iter_t mid = first + ((nblock >> 1) * Block_size);
auto f1 = [=, &son_counter]( )
auto f1 = [=, &son_counter, this]( )
{
parallel_sort_t (bk, mid, last);
bscu::atomic_sub (son_counter, 1);
Expand Down Expand Up @@ -364,7 +369,7 @@ ::start_function(void)
}
else
{
size_t level_thread = nbits64(nthread - 1) - 1;
uint32_t level_thread = nbits64 (nthread - 1) - 1;
split_range(0, bk.nblock, level_thread - 1);
if (bk.error) return;
move_blocks_t k(bk);
Expand Down Expand Up @@ -443,7 +448,7 @@ void block_indirect_sort(Iter_t first, Iter_t last)
//
//-----------------------------------------------------------------------------
// function : block_indirect_sort
/// @brief invocation of block_indirtect_sort with 3 parameters. The third is
/// @brief invocation of block_indirtect_sort with 3 parameters. The third is
/// the number of threads
///
/// @param first : iterator to the first element of the range to sort
Expand All @@ -460,7 +465,7 @@ void block_indirect_sort(Iter_t first, Iter_t last, uint32_t nthread)
//
//-----------------------------------------------------------------------------
// function : block_indirect_sort
/// @brief invocation of block_indirtect_sort with 3 parameters. The third is
/// @brief invocation of block_indirtect_sort with 3 parameters. The third is
/// the comparison object
///
/// @param first : iterator to the first element of the range to sort
Expand All @@ -479,7 +484,7 @@ void block_indirect_sort(Iter_t first, Iter_t last, Compare comp)
//
//-----------------------------------------------------------------------------
// function : block_indirect_sort
/// @brief invocation of block_indirtect_sort with 4 parameters.
/// @brief invocation of block_indirtect_sort with 4 parameters.
///
/// @param first : iterator to the first element of the range to sort
/// @param last : iterator after the last element to the range to sort
Expand Down
Loading