@(@\newcommand{\W}[1]{ \; #1 \; }
\newcommand{\R}[1]{ {\rm #1} }
\newcommand{\B}[1]{ {\bf #1} }
\newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} }
\newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} }
\newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} }
\newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }@)@This is cppad-20221105 documentation. Here is a link to its
current documentation
.
Common Variables Used by Multi-threading Sum of 1/i
Purpose
This source code defines the common
include files, defines, and variables that are used by
the summation that defines the harmonic series
@[@
1 + 1/2 + 1/3 + ... + 1/n
@]@
# include <cppad/cppad.hpp>
# include "harmonic.hpp"
# include "team_thread.hpp"
# define MAX_NUMBER_THREADS 48
namespace {
using CppAD::thread_alloc; // fast multi-threadeding memory allocator// Number of threads, set by previous call to harmonic_time// (zero means one thread with no multi-threading setup)
size_t num_threads_ = 0;
// value of mega_sum, set by previous call to harmonic_time.
size_t mega_sum_;
// structure with information for one threadtypedefstruct {
// index to start summation at (worker input)// set by previous call to harmonic_setup
size_t start;
// index to end summation at (worker input)// set by previous call to harmonic_setup
size_t stop;
// summation for this thread// set by worker
double sum;
// false if an error occurs, true otherwise// set by worker
bool ok;
} work_one_t;
// vector with information for all threads// (use pointers instead of values to avoid false sharing)
work_one_t* work_all_[MAX_NUMBER_THREADS];
}