OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
threading_serial Namespace Reference

Classes

class  task_group
 

Functions

template<typename Fn , typename... Args, typename Result = std::result_of_t<Fn && (Args && ...)>>
future< Result > async (Fn &&fn, Args &&...args)
 
template<typename Int , typename Body , typename Partitioner = auto_partitioner>
void parallel_for (const blocked_range< Int > &range, const Body &body, const Partitioner &p=Partitioner())
 
template<typename Index , typename Function , typename Partitioner = auto_partitioner>
void parallel_for (Index first, Index last, const Function &f, const Partitioner &p=Partitioner())
 
template<typename Int , typename Value , typename RealBody , typename Reduction , typename Partitioner = auto_partitioner>
Value parallel_reduce (const blocked_range< Int > &range, const Value &identity, const RealBody &real_body, const Reduction &reduction, const Partitioner &p=Partitioner())
 Parallel iteration with reduction. More...
 

Function Documentation

template<typename Fn , typename... Args, typename Result = std::result_of_t<Fn && (Args && ...)>>
future<Result> threading_serial::async ( Fn &&  fn,
Args &&...  args 
)

Definition at line 11 of file threading_serial.h.

References run_benchmark_import::args.

Referenced by approximate_distinct_tuples(), approximate_distinct_tuples_overlaps(), approximate_distinct_tuples_range(), RangeJoinHashTable::approximateTupleCount(), OverlapsJoinHashTable::approximateTupleCount(), BaselineJoinHashTable::approximateTupleCount(), threading_std::async(), ColumnarResults::compactAndCopyEntriesWithoutTargetSkipping(), ColumnarResults::compactAndCopyEntriesWithTargetSkipping(), Fragmenter_Namespace::InsertOrderFragmenter::compactRows(), compute_bucket_sizes_on_cpu(), foreign_storage::TextFileBufferParser::convertImportBuffersToDataBlocks(), ColumnarResults::copyAllNonLazyColumns(), Fragmenter_Namespace::copyDataOfShard(), StringDictionary::copyStrings(), CodeGenerator::createInValuesBitmap(), fill_one_to_many_baseline_hash_table(), fill_one_to_many_hash_table_impl(), fill_one_to_many_hash_table_sharded_impl(), import_export::TypedImportBuffer::get_data_block_pointers(), anonymous_namespace{RelAlgTranslator.cpp}::get_in_values_expr(), ArrowResultSetConverter::getArrowBatch(), RelAlgTranslator::getInIntegerSetExpr(), Fragmenter_Namespace::InsertOrderFragmenter::getVacuumOffsets(), import_export::Importer::importDelimited(), import_export::Importer::importGDAL(), inclusive_scan(), File_Namespace::FileMgr::init(), BaselineJoinHashTableBuilder::initHashTableOnCpu(), PerfectJoinHashTableBuilder::initOneToManyHashTableOnCpu(), Fragmenter_Namespace::InsertDataLoader::insertData(), ColumnFetcher::linearizeVarLenArrayColFrags(), ColumnarResults::locateAndCountEntries(), ColumnarResults::materializeAllColumnsThroughIteration(), ColumnarResults::materializeAllLazyColumns(), foreign_storage::LazyParquetChunkLoader::metadataScan(), ResultSetStorage::moveEntriesToBuffer(), File_Namespace::FileMgr::openFiles(), threading_std::parallel_for(), threading_std::parallel_reduce(), StringDictionary::populate_string_array_ids(), foreign_storage::ParquetDataWrapper::populateChunkBuffers(), foreign_storage::AbstractTextFileDataWrapper::populateChunkMetadata(), foreign_storage::AbstractTextFileDataWrapper::populateChunks(), Parser::InsertIntoTableAsSelectStmt::populateData(), File_Namespace::FileBuffer::read(), ResultSetStorage::reduce(), PerfectJoinHashTable::reify(), OverlapsJoinHashTable::reifyImpl(), RangeJoinHashTable::reifyWithLayout(), BaselineJoinHashTable::reifyWithLayout(), ThreadController_NS::SimpleThreadController< FutureReturnType >::startThread(), StringDictionary::StringDictionary(), synthesize_metadata(), Fragmenter_Namespace::InsertOrderFragmenter::updateColumn(), Fragmenter_Namespace::InsertOrderFragmenter::updateColumns(), StorageIOFacility::yieldDeleteCallback(), and StorageIOFacility::yieldUpdateCallback().

11  {
12  std::promise<Result> pr;
13  if constexpr (std::is_same<void, Result>::value) {
14  fn(std::forward<Args>(args)...);
15  pr.set_value();
16  } else {
17  pr.set_value(fn(std::forward<Args>(args)...));
18  }
19  return pr.get_future();
20 }
template<typename Int , typename Body , typename Partitioner = auto_partitioner>
void threading_serial::parallel_for ( const blocked_range< Int > &  range,
const Body &  body,
const Partitioner &  p = Partitioner() 
)

Definition at line 34 of file threading_serial.h.

References threading_common::blocked_range< Value >::begin(), cpu_threads(), threading_common::blocked_range< Value >::end(), i, and threading_common::blocked_range< Value >::size().

Referenced by ArrowForeignStorageBase::createDecimalColumn(), ArrowForeignStorageBase::createDictionaryEncodedColumn(), StringDictionary::hashStrings(), threading_tbb::parallel_for(), parallel_for(), ArrowForeignStorageBase::parseArrowTable(), and ArrowForeignStorageBase::setNullValues().

36  {
37  const Int worker_count = cpu_threads();
38 
39  for (Int i = 0,
40  start_entry = range.begin(),
41  stop_entry = range.end(),
42  stride = (range.size() + worker_count - 1) / worker_count;
43  i < worker_count && start_entry < stop_entry;
44  ++i, start_entry += stride) {
45  const auto end_entry = std::min(start_entry + stride, stop_entry);
46  body(blocked_range<Int>(start_entry, end_entry));
47  }
48 }
size_type size() const
Size of the range.
Definition: threading_std.h:47
A range over which to iterate.
Definition: threading_std.h:21
const_iterator end() const
One past last value in range.
Definition: threading_std.h:43
const_iterator begin() const
Beginning of range.
Definition: threading_std.h:40
int cpu_threads()
Definition: thread_count.h:24

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename Index , typename Function , typename Partitioner = auto_partitioner>
void threading_serial::parallel_for ( Index  first,
Index  last,
const Function f,
const Partitioner &  p = Partitioner() 
)

Parallel iteration over a range of integers with a default step value and default partitioner

Definition at line 53 of file threading_serial.h.

References threading_common::blocked_range< Value >::begin(), threading_common::blocked_range< Value >::end(), f, i, and parallel_for().

56  {
58  blocked_range<Index>(first, last),
59  [&f](const blocked_range<Index>& r) {
60  for (auto i = r.begin(), e = r.end(); i < e; i++) {
61  f(i);
62  }
63  },
64  p);
65 }
A range over which to iterate.
Definition: threading_std.h:21
void parallel_for(const blocked_range< Int > &range, const Body &body, const Partitioner &p=Partitioner())
const_iterator end() const
One past last value in range.
Definition: threading_std.h:43
const_iterator begin() const
Beginning of range.
Definition: threading_std.h:40
char * f

+ Here is the call graph for this function:

template<typename Int , typename Value , typename RealBody , typename Reduction , typename Partitioner = auto_partitioner>
Value threading_serial::parallel_reduce ( const blocked_range< Int > &  range,
const Value identity,
const RealBody &  real_body,
const Reduction &  reduction,
const Partitioner &  p = Partitioner() 
)

Parallel iteration with reduction.

Definition at line 74 of file threading_serial.h.

References threading_common::blocked_range< Value >::begin(), cpu_threads(), threading_common::blocked_range< Value >::end(), i, and threading_common::blocked_range< Value >::size().

Referenced by threading_tbb::parallel_reduce(), ResultSet::parallelRowCount(), FixedLengthEncoder< T, V >::updateStatsEncoded(), and NoneEncoder< T >::updateStatsEncoded().

78  {
79  const size_t worker_count = cpu_threads();
80  std::vector<Value> worker_threads;
81  worker_threads.reserve(worker_count);
82 
83  for (Int i = 0,
84  start_entry = range.begin(),
85  stop_entry = range.end(),
86  stride = (range.size() + worker_count - 1) / worker_count;
87  i < worker_count && start_entry < stop_entry;
88  ++i, start_entry += stride) {
89  const auto end_entry = std::min(start_entry + stride, stop_entry);
90  // TODO grainsize?
91  worker_threads.emplace_back(
92  real_body(blocked_range<Int>(start_entry, end_entry), Value{}));
93  }
94  Value v = identity;
95  for (auto& child : worker_threads) {
96  v = reduction(v, child);
97  }
98 
99  return v;
100 }
size_type size() const
Size of the range.
Definition: threading_std.h:47
A range over which to iterate.
Definition: threading_std.h:21
const_iterator end() const
One past last value in range.
Definition: threading_std.h:43
const_iterator begin() const
Beginning of range.
Definition: threading_std.h:40
int cpu_threads()
Definition: thread_count.h:24

+ Here is the call graph for this function:

+ Here is the caller graph for this function: