OmniSciDB  a5dc49c757
 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 TableFunctions_Namespace::OneHotEncoder_Namespace::allocate_one_hot_cols(), approximate_distinct_tuples(), approximate_distinct_tuples_bbox_intersect(), approximate_distinct_tuples_range(), RangeJoinHashTable::approximateTupleCount(), BoundingBoxIntersectJoinHashTable::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(), foreign_storage::create_futures_for_workers(), 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(), anonymous_namespace{ForeignDataImporter.cpp}::import_foreign_data(), import_export::Importer::importDelimited(), import_export::Importer::importGDALGeo(), import_export::Importer::importGDALRaster(), import_export::ForeignDataImporter::importGeneralS3(), inclusive_scan(), File_Namespace::FileMgr::init(), BaselineJoinHashTableBuilder::initHashTableOnCpu(), PerfectJoinHashTableBuilder::initOneToManyHashTableOnCpu(), PerfectJoinHashTableBuilder::initOneToOneHashTableOnCpu(), Fragmenter_Namespace::InsertDataLoader::insertChunks(), Fragmenter_Namespace::InsertDataLoader::insertData(), foreign_storage::AbstractTextFileDataWrapper::iterativeFileScan(), ColumnFetcher::linearizeVarLenArrayColFrags(), foreign_storage::LazyParquetChunkLoader::loadRowGroups(), ColumnarResults::locateAndCountEntries(), ColumnarResults::materializeAllColumnsThroughIteration(), ColumnarResults::materializeAllLazyColumns(), foreign_storage::LazyParquetChunkLoader::metadataScan(), ResultSetStorage::moveEntriesToBuffer(), File_Namespace::FileMgr::openFiles(), threading_std::parallel_for(), threading_std::parallel_reduce(), foreign_storage::populate_chunks_using_data_blocks(), StringDictionary::populate_string_array_ids(), foreign_storage::AbstractTextFileDataWrapper::populateChunkMetadata(), foreign_storage::AbstractTextFileDataWrapper::populateChunks(), Parser::InsertIntoTableAsSelectStmt::populateData(), File_Namespace::FileBuffer::read(), ResultSetStorage::reduce(), PerfectJoinHashTable::reify(), BoundingBoxIntersectJoinHashTable::reifyImpl(), RangeJoinHashTable::reifyWithLayout(), BaselineJoinHashTable::reifyWithLayout(), ThreadController_NS::SimpleThreadController< FutureReturnType >::startThread(), StringDictionary::StringDictionary(), 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(), and threading_common::blocked_range< Value >::size().

Referenced by TreeModelPredictionMgr::allocateAndPopulateHostBuffers(), StringDictionary::buildDictionaryNumericTranslationMap(), StringDictionary::buildDictionaryTranslationMap(), StringDictionaryProxy::buildNumericTranslationMap(), GeoRaster< T, Z >::calculate_slope_and_aspect(), CodeGenerator::codegenTreeRegPredict(), WindowFunctionContext::compute(), GeoRaster< T, Z >::compute(), compute_table_function_col_chunk_stats(), GeoRaster< T, Z >::computeParallelImpl(), GeoRaster< T, Z >::computeParallelReductionAggImpl(), DataBufferCache::copyData(), ArrowForeignStorageBase::createDecimalColumn(), ArrowForeignStorageBase::createDictionaryEncodedColumn(), GeoRaster< T, Z >::fill_bins_from_box_neighborhood(), GeoRaster< T, Z >::fill_bins_from_gaussian_neighborhood(), RasterFormat_Namespace::fill_col_halo(), RasterFormat_Namespace::fill_row_halo(), RasterFormat_Namespace::format_raster_data(), generate_random_strings__cpu_(), generate_series_parallel(), get_column_mean(), get_column_metadata(), get_column_min_max(), get_column_stats(), get_column_std_dev(), TableFunctions_Namespace::OneHotEncoder_Namespace::get_top_k_keys(), StringDictionary::getBulk(), StringDictionary::getLikeImpl(), StringDictionary::getStringViews(), StringDictionary::hashStrings(), QueryMemoryInitializer::initRowGroups(), Mandelbrot::mandelbrot_cpu_template(), ResultSet::ResultSetComparator< BUFFER_ITERATOR_TYPE >::materializeModeColumn(), TableFunctions_Namespace::OneHotEncoder_Namespace::one_hot_encode(), GeoRaster< T, Z >::outputDenseColumn(), GeoRaster< T, Z >::outputDenseColumns(), GeoRaster< T, Z >::outputDenseColumnsAndFill(), threading_tbb::parallel_for(), parallel_for(), ArrowForeignStorageBase::parseArrowTable(), r2_score_impl(), TableFunctions_Namespace::remove_null_rows(), ArrowForeignStorageBase::replaceNullValuesImpl(), synthesize_metadata(), CrossSectionTableFunctions::tf_cross_section_2d_impl(), StringDictionaryProxy::transientLookupBulkParallelUnlocked(), TableFunctions_Namespace::unmask_data(), and z_std_normalize_col().

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:25

+ 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(), 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
torch::Tensor f(torch::Tensor x, torch::Tensor W_target, torch::Tensor b_target)
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

+ 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(), and threading_common::blocked_range< Value >::size().

Referenced by anonymous_namespace{ColumnarResults.cpp}::computeTotalNofValuesForColumnArray(), anonymous_namespace{ColumnarResults.cpp}::computeTotalNofValuesForColumnGeoType(), anonymous_namespace{ColumnarResults.cpp}::computeTotalNofValuesForColumnTextEncodingNone(), 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:25

+ Here is the call graph for this function:

+ Here is the caller graph for this function: