diff --git a/tutorial/CoreTutorial/CoreTutorial.upp b/tutorial/CoreTutorial/CoreTutorial.upp index ab1b0a874..ae9964e33 100644 --- a/tutorial/CoreTutorial/CoreTutorial.upp +++ b/tutorial/CoreTutorial/CoreTutorial.upp @@ -46,6 +46,7 @@ file test.txt, CoWork.cpp, CoPartition.cpp, + Parallel.cpp, tutorial2.cpp, help.qtf; diff --git a/tutorial/CoreTutorial/Parallel.cpp b/tutorial/CoreTutorial/Parallel.cpp new file mode 100644 index 000000000..11029a134 --- /dev/null +++ b/tutorial/CoreTutorial/Parallel.cpp @@ -0,0 +1,22 @@ +#include "Tutorial.h" + +void CoAlgoTutorial() +{ + /// .Parallel algorithms + + /// U++ provides a parallel version of algorithms where it makes sense. The naming scheme + /// is 'Co' prefix before the name of algorithm designates the parallel version. + + /// So the parallel version of e.g. `FindIndex` is `CoFindIndex`, for 'Sort' it is 'CoSort': + + Vector x{ "zero", "one", "two", "three", "four", "five" }; + + DUMP(FindIndex(x, "two")); + DUMP(CoFindIndex(x, "two")); + + CoSort(x); + DUMP(x); + + /// Caution should be exercised when using these algorithms - for small datasets, they are + /// almost certainly slower than single-threaded versions. +} \ No newline at end of file diff --git a/tutorial/CoreTutorial/tutorial2.cpp b/tutorial/CoreTutorial/tutorial2.cpp index e074f5196..db9a22a90 100644 --- a/tutorial/CoreTutorial/tutorial2.cpp +++ b/tutorial/CoreTutorial/tutorial2.cpp @@ -45,6 +45,7 @@ GUI_APP_MAIN DO(ConditionVariableTutorial); DO(CoWorkTutorial); DO(CoPartitionTutorial); + DO(CoAlgoTutorial); MakeTutorial(); }