oneapi-src / oneapi-src/oneAPI-samples

How to `parallel_reduce` a C++ map key or value?

Open
#2,399 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
C++
Stars
1.2k
Forks
745
PR merge metrics
No merged PRs in 30d

Description

I don't find it from google. How can I parallel_reduce either the key or value of a map? For example:

       map<T, size_t> counts;
	size_t count = parallel_reduce(
		blocked_range<pair<T, size_t>>(0, counts.size()), 0,
		[&](tbb::blocked_range<pair<T, size_t>> const &r, size_t running_total)
		{
			for (auto it = r.begin(); it != r.end(); it++)
				running_total += it->second;
			return running_total;
		},
		std::plus<pair<T, size_t>>());

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the C++ example in the issue and determine what parallel_reduce operation is intended for the map's keys or values. A useful outcome would explain the correct reduction form for the shown counts map and clarify the required result and combining types.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
developer-experience
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.