|
Prev | Next | harmonic_common |
# 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 thread
typedef struct {
// 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];
}