I have concurrency::parallel_for, inside which I call a function that takes a functor, passing it a lambda, for example
concurrency::parallel_for
concurrency::parallel_for(0, particleCount, [&](int i) { ... kdTree->VisitCells([&](const KDTreeNode &node) //defining and passing { //code dealing with tree traversal } }
... and the question is, what bad practice is to define a lambda inside parallel_forthat runs for each of the many particles. Will this essentially define one functor for each particle? An alternative is to write a lambda outside parallel_forand design it to make a few more arguments (since it can no longer perform the same captures as before) and pass this to the tree inside parallel_for.
parallel_for
When testing, it seems that it detects it a little faster parallel_for, but the data is inconclusive, and I donβt know exactly how several identical lambdas with different captured data are really processed.
In general, it depends on two things.
-, "" parallel_for , - parallel_for, . [&] - . , / ( , ) , , .
[&]
-, , , , .
, , , (, , ).
, ( ), , , " parallel_for", , struct definition , ( ). , .
.... , . .
Source: https://habr.com/ru/post/1611124/More articles:Get maximum values ββfor categories in a dictionary list - pythonjQuery - Find a dynamically created element without events - javascriptSaving CMSampleBufferRef causes random crashes - iosAVCaptureSession returns blank image only on iPhone 3G - iphoneEnlightenment of the Xamarin memory profiler object - memory-managementConvert long [] to String using Java 8 streams - javaWhere does the Standard say that every distribution returned by `new` is aligned with` std :: max_align_t`? - c ++Is the largest decimal literal of type int - 2147483648 or 2147483647? - javaCan I take βsnapshotsβ for IO Monad? - ioSeparate integers in a list (python) - pythonAll Articles