--------------------------------------------------------- lines 7-229 of file: example/multi_thread/thread_test.cpp --------------------------------------------------------- {xrst_begin thread_test.cpp} {xrst_spell posix } Run Multi-Threading Examples and Speed Tests ############################################ Purpose ******* Runs the CppAD multi-threading examples and timing tests: build ***** We use *build* for the directory where you run the :ref:`cmake-name` command. threading ********* If the :ref:`cmake-name` command output indicates that ``openmp``, ``bthread`` , ``pthread`` , or ``sthread`` is available, you can run the program below with *threading* equal to ``openmp``, ``bthread`` , ``pthread`` , or ``sthread`` respectively. program ******* We use the notation *program* for ``example_multi_thread_`` *threading* Running Tests ************* You can build this program and run the default version of its test parameters by executing the following commands: | |tab| ``cd`` *build* | |tab| ``make check_`` *program* After this operation, in the directory *build* / ``example/multi_thread/`` *threading* you can execute the following commands: | . | ./ *program* ``a11c`` | ./ *program* ``get_started`` | ./ *program* ``team_example`` | ./ *program* ``harmonic`` *test_time* *max_threads* *mega_sum* | ./ *program* ``atomic_two`` *test_time* *max_threads* *num_solve* | ./ *program* ``atomic_three`` *test_time* *max_threads* *num_solve* | ./ *program* ``chkpoint_one`` *test_time* *max_threads* *num_solve* | ./ *program* ``chkpoint_two`` *test_time* *max_threads* *num_solve* | ./ *program* ``multi_newton`` *test_time* *max_threads* \\ | |tab| *num_zero* *num_sub* *num_sum* *use_ad* We refer to the values ``a11c`` , ... , ``multi_newton`` as the *test_case* below. {xrst_toc_hidden example/multi_thread/openmp/a11c_openmp.cpp example/multi_thread/bthread/a11c_bthread.cpp example/multi_thread/pthread/a11c_pthread.cpp example/multi_thread/sthread/a11c_sthread.cpp example/multi_thread/openmp/get_started.cpp example/multi_thread/bthread/get_started.cpp example/multi_thread/pthread/get_started.cpp example/multi_thread/sthread/get_started.cpp example/multi_thread/team_example.cpp example/multi_thread/harmonic.xrst example/multi_thread/multi_atomic_three.xrst example/multi_thread/multi_chkpoint_two.xrst example/multi_thread/multi_newton.xrst example/multi_thread/team_thread.hpp } a11c **** The *test_case* ``a11c`` runs the examples :ref:`a11c_openmp.cpp-name` , :ref:`a11c_bthread.cpp-name` , :ref:`a11c_pthread.cpp-name` , and :ref:`a11c_sthread.cpp-name` . These cases demonstrate simple multi-threading, without algorithmic differentiation, using OpenMP, Boost Posix and Standard threads respectively. get_started *********** The *test_case* ``get_started`` runs the examples :ref:`openmp_get_started.cpp-name` , :ref:`bthread_get_started.cpp-name` , :ref:`pthread_get_started.cpp-name` , and :ref:`sthread_get_started.cpp-name` . These cases demonstrate simple multi-threading, with algorithmic differentiation, using OpenMP, Boost Posix and Standard threads respectively. team_example ************ The *test_case* ``team_example`` runs the :ref:`team_example.cpp-name` example. This case demonstrates simple multi-threading with algorithmic differentiation and using a :ref:`team of threads` . test_time ********* All of the other cases include the *test_time* argument. This is the minimum amount of wall clock time that the test should take. The number of repeats for the test will be increased until this time is reached. The reported time is the total wall clock time divided by the number of repeats. max_threads =========== All of the other cases include the *max_threads* argument. This is a non-negative integer specifying the maximum number of threads to use for the test. The specified test is run with the following number of threads: *num_threads* = 0 , ... , *max_threads* The value of zero corresponds to not using the multi-threading system. {xrst_comment -------------------------------------------------------------- } harmonic ******** The *test_case* ``harmonic`` runs the :ref:`harmonic_time-name` example. This is a timing test for a multi-threading example without algorithmic differentiation using a team of threads. mega_sum ======== The command line argument *mega_sum* is an integer greater than or equal one and has the same meaning as in :ref:`harmonic_time` . {xrst_comment -------------------------------------------------------------- } Atomic and Checkpoint ********************* The *test_case* values ``atomic_two`` , ``atomic_three`` , ``chkpoint_one`` , ``chkpoint_two`` , all run the same problem. These cases preforms a timing test for a multi-threading example without algorithmic differentiation using a team of threads. .. csv-table:: :widths: auto *test_case*,Documentation ``atomic_two``,:ref:`multi_atomic_two.cpp-name` ``atomic_three``,:ref:`multi_atomic_three.cpp-name` ``chkpoint_one``,:ref:`multi_chkpoint_one.cpp-name` ``chkpoint_two``,:ref:`multi_chkpoint_two.cpp-name` num_solve ========= The command line argument *num_solve* is an integer specifying the number of solves; see :ref:`multi_atomic_two_time@num_solve` in ``multi_atomic_two_time`` . {xrst_comment -------------------------------------------------------------- } multi_newton ************ The *test_case* ``multi_newton`` runs the :ref:`multi_newton.cpp-name` example. This preforms a timing test for a multi-threading example with algorithmic differentiation using a team of threads. num_zero ======== The command line argument *num_zero* is an integer greater than or equal two and has the same meaning as in :ref:`multi_newton_time` . num_sub ======= The command line argument *num_sub* is an integer greater than or equal one and has the same meaning as in :ref:`multi_newton_time` . num_sum ======= The command line argument *num_sum* is an integer greater than or equal one and has the same meaning as in :ref:`multi_newton_time` . use_ad ====== The command line argument *use_ad* is either ``true`` or ``false`` and has the same meaning as in :ref:`multi_newton_time` . {xrst_comment -------------------------------------------------------------- } Team Implementations ******************** The following routines are used to implement the specific threading systems through the common interface :ref:`team_thread.hpp-name` : .. csv-table:: :widths: auto team_openmp.cpp,:ref:`team_openmp.cpp-title` team_bthread.cpp,:ref:`team_bthread.cpp-title` team_pthread.cpp,:ref:`team_pthread.cpp-title` team_sthread.cpp,:ref:`team_sthread.cpp-title` Source ****** {xrst_literal // BEGIN C++ // END C++ } {xrst_end thread_test.cpp}