Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

Can _Cilk_for iterate on STL maps?

Jorge_Martinis
Beginner
505 Views
Hi!
I have this loop iterating over a std::map:
for(std::map::const_iterator it = MyMap.begin(); it != MyMap.end(); it++)
No insertions/deletions are performer within the loop. Instead, values are just read from the tree as it is traversed.
1) Is random-access to elements and loop count computation at constant time mandatory?
2) Is it safe to use _Cilk_for on this loop?
Thanks!
0 Kudos
1 Reply
Brandon_H_Intel
Employee
505 Views
Hi Jorge,

This kind of loop won't work with a cilk_for. You'll get the following compiler error:

[plain] error: no operator "-" matches these operands[/plain]

This is because cilk_for needs to be able to randomly access the container elements so it can dynamically split ranges in half as it spawns out work to be done in parallel.
0 Kudos
Reply