![]() |
paceval. 4.26
Documentation of the paceval. source-code, Copyright ©1994-2024. Version 1.x, 2.x, 3.x, 4.x ©1994-2025 Joerg Koenning & paceval UG [Registered Trade Mark] All rights reserved., Author(s) : Joerg Koenning
|
implementation of the main routines for handling threads (annotation: the source code of paceval_fThreadHandling.cpp can be given to customers to perform specialized thread handling) More...
#include <time.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "./inc/paceval_fThreadHandling.h"
Classes | |
class | paceval_sGetComputationResultThreadData |
The struct paceval_sGetComputationResultThreadData is used by pacevalLibrary_InternalGetComputationResult(). More... | |
Functions | |
long | paceval_cComputation_lockAndGetToDoLevelMultithreadPosition (PACEVAL_HANDLE handle_pacevalComputation_in, const unsigned long stackNumber_in, unsigned long idSingleCalculationToDo_in, unsigned long *lastToDoLevelMultithreadPosition_in, unsigned long *startSpecificAtNode_in, unsigned long *endSpecificAtNode_in) |
long | paceval_cComputation_getSingleCalculationPosition (PACEVAL_HANDLE handle_pacevalComputation_in) |
bool | paceval_cComputation_doComputation (PACEVAL_HANDLE handle_pacevalComputation_in, const bool singleCalculation_in, const unsigned long startSpecificAtNode_in, const unsigned long endSpecificAtNode_in, const unsigned int sizeOfLongDouble_in, const paceval_eCalculationPrecisionTypes useCalculationPrecision_in, void *result_out, const unsigned long stackNumber_in, bool *error_out, void *errorInformation_out, void *trustedMinResult_out, void *trustedMaxResult_out) |
bool | paceval_cComputation_unlockToDoLevelMultithreadPosition (PACEVAL_HANDLE handle_pacevalComputation_in, const unsigned long stackNumber_in, unsigned long lockedLevelMultithreadPosition_in, unsigned long idSingleCalculationToDo_in) |
unsigned long | paceval_cComputation_getIdSingleCalculation (PACEVAL_HANDLE handle_pacevalComputation_in) |
void | paceval_cComputation_increaseIdSingleCalculation (PACEVAL_HANDLE handle_pacevalComputation_in) |
void | increasePacevalLibraryNumberThreadsFailure () |
void | increasePacevalLibraryNumberThreadsUsed () |
unsigned long | paceval_activityGet_Thread_system_maxNumberThreads (unsigned long system_numberCores_in, unsigned long system_maxNumberThreads_in) |
void | paceval_activityStart_Thread_CreateComputation (PACEVAL_HANDLE handle_pacevalComputation_in, const char *functionString_in, unsigned long numberOfVariables_in, const char *variables_in, bool useInterval_in) |
void | paceval_activityEnd_Thread_CreateComputation (PACEVAL_HANDLE handle_pacevalComputation_in, const char *functionString_in, unsigned long numberOfVariables_in, const char *variables_in, bool useInterval_in, bool success_in, unsigned long numberOfNodes_in) |
void | paceval_activityStart_Thread_DeleteComputation (PACEVAL_HANDLE handle_pacevalComputation_in) |
bool | paceval_activityAccept_Thread_MultithreadOpportunity (PACEVAL_HANDLE handle_pacevalComputation_in, unsigned long startSpecificAtNode_in, unsigned long endSpecificAtNode_in) |
void | paceval_activityStart_Thread_GetComputationResult (PACEVAL_HANDLE handle_pacevalComputation_in) |
void * | paceval_activityThread_GetComputationResult (void *arg) |
bool | paceval_activityMain_Thread_GetComputationResult (PACEVAL_HANDLE handle_pacevalComputation_in, paceval_eCalculationPrecisionTypes useCalculationPrecision_in, unsigned long numberOfThreads_in, unsigned int sizeOfLongDouble_in, void *result_out, void *lastErrorInformation_out, void *trustedMinResult_out, void *trustedMaxResult_out) |
void | paceval_activitySetCache_Thread_GetComputationResult (PACEVAL_HANDLE handle_pacevalComputation_in, bool *useMutex_out_in, const unsigned long stackNumber_in, unsigned long startSpecificAtNode_in, unsigned long endSpecificAtNode_in) |
void | paceval_activityUseCache_Thread_GetComputationResult (PACEVAL_HANDLE handle_pacevalComputation_in, const bool isMainCalculation_in, const unsigned long stackNumber_in, unsigned long startSpecificAtNode_in, unsigned long endSpecificAtNode_in) |
void | paceval_activityEnd_Thread_GetComputationResult (PACEVAL_HANDLE handle_pacevalComputation_in, bool success_in) |
implementation of the main routines for handling threads (annotation: the source code of paceval_fThreadHandling.cpp can be given to customers to perform specialized thread handling)
void increasePacevalLibraryNumberThreadsFailure | ( | ) |
increases the count of the number of failed threads by 1
void increasePacevalLibraryNumberThreadsUsed | ( | ) |
increases the counter for the number of threads used by 1
bool paceval_activityAccept_Thread_MultithreadOpportunity | ( | PACEVAL_HANDLE | handle_pacevalComputation_in, |
unsigned long | startSpecificAtNode_in, | ||
unsigned long | endSpecificAtNode_in ) |
decides the multithreaded lookahead caching capabilities for a sequence of node objects and returns whether such caching capability exists (true) or not (false)
handle_pacevalComputation_in | identifies the computation object created via pacevalLibrary_CreateComputation() |
startSpecificAtNode_in | specifies the node at which the calculation is started |
endSpecificAtNode_in | specifies the node at which the calculation ends |
void paceval_activityEnd_Thread_CreateComputation | ( | PACEVAL_HANDLE | handle_pacevalComputation_in, |
const char * | functionString_in, | ||
unsigned long | numberOfVariables_in, | ||
const char * | variables_in, | ||
bool | useInterval_in, | ||
bool | success_in, | ||
unsigned long | numberOfNodes_in ) |
this function is called when the creation of the computation object ends (annotation: success_in specifies whether the computation object was created successfully (true) or not (false))
handle_pacevalComputation_in | identifies the computation object created via pacevalLibrary_CreateComputation() |
functionString_in | points to a null-terminated string to be used as the function to work with |
numberOfVariables_in | specifies the number of variables to work with (e.g. if the variables are "xValue yValue zValue" or "x y z" numberOfVariables_in must be set to 3) |
variables_in | points to a null-terminated string specifying the names of the working variables (generally the variables must be separated by a blank, e.g. the variables xValue, yValue, zValue must be set with "xValue yValue zValue" or the variables x, y, z must be set with "x y z") |
useInterval_in | enables or disables the Trusted Interval Computation, TINC (paceval specific) putting bounds on rounding errors and measurement errors of the computation system to yield reliable results |
success_in | specifies whether the computation object was created successfully (true) or not (false) |
numberOfNodes_in | specifies the number of nodes in the linked list of atomic suboperations |
void paceval_activityEnd_Thread_GetComputationResult | ( | PACEVAL_HANDLE | handle_pacevalComputation_in, |
bool | success_in ) |
this function is called when the calculation on a paceval_cComputation object ends
handle_pacevalComputation_in | identifies the computation object created via pacevalLibrary_CreateComputation() |
success_in | specifies whether the calculation was successful (true) or not (false) |
unsigned long paceval_activityGet_Thread_system_maxNumberThreads | ( | unsigned long | system_numberCores_in, |
unsigned long | system_maxNumberThreads_in ) |
returns the maximum number of threads for a computation for this system
system_numberCores_in | specifies the the number of cores available in the system |
system_maxNumberThreads_in | specifies the the number of threads available in the system (annotation: this number is precomputed by paceval and can be overridden by the return value of this function) |
bool paceval_activityMain_Thread_GetComputationResult | ( | PACEVAL_HANDLE | handle_pacevalComputation_in, |
paceval_eCalculationPrecisionTypes | useCalculationPrecision_in, | ||
unsigned long | numberOfThreads_in, | ||
unsigned int | sizeOfLongDouble_in, | ||
void * | result_out, | ||
void * | lastErrorInformation_out, | ||
void * | trustedMinResult_out, | ||
void * | trustedMaxResult_out ) |
this function is called when the calculation is to be performed on a computation object (annotation: the general strategy is that only the strongest, i.e. the fastest, survive)
handle_pacevalComputation_in | identifies the computation object created via pacevalLibrary_CreateComputation() |
useCalculationPrecision_in | specifies the precision with which the calculation should be performed |
numberOfThreads_in | specifies the number of threads to use |
sizeOfLongDouble_in | specifies the size in bytes of long double in the calling system determined via sizeof(long double) |
result_out | the buffer for the result of the calculation in the precision defined with useCalculationPrecision_in (annotation: in case of an error the value is not specified) |
trustedMinResult_out | if Trusted Interval Computation was enabled by pacevalLibrary_CreateComputation() this retrieves the minimum/lower interval limit of the computation (annotation: in case of an error the value is not specified) |
trustedMaxResult_out | if Trusted Interval Computation was enabled by pacevalLibrary_CreateComputation() this retrieves the maximum/upper interval limit limit of the computation (annotation: in case of an error the value is not specified) |
void paceval_activitySetCache_Thread_GetComputationResult | ( | PACEVAL_HANDLE | handle_pacevalComputation_in, |
bool * | useMutex_out_in, | ||
const unsigned long | stackNumber_in, | ||
unsigned long | startSpecificAtNode_in, | ||
unsigned long | endSpecificAtNode_in ) |
this function is called when the calculation locks parallel computation by a thread so that data for caching, for example, does not overwrite each other
handle_pacevalComputation_in | identifies the computation object created via pacevalLibrary_CreateComputation() |
useMutex_out_in | specifies whether a mutex object should be used for locking (true) or not (false) (annotation: by default, useMutex_out_in is set so that a mutex is used when writing the cache) |
stackNumber_in | specifies the number of the stack that is being worked with in a locked manner |
startSpecificAtNode_in | specifies the node at which the calculation is started by the thread |
endSpecificAtNode_in | specifies the node at which the calculation ends by the thread |
void paceval_activityStart_Thread_CreateComputation | ( | PACEVAL_HANDLE | handle_pacevalComputation_in, |
const char * | functionString_in, | ||
unsigned long | numberOfVariables_in, | ||
const char * | variables_in, | ||
bool | useInterval_in ) |
this function is called when the creation of the computation object starts
handle_pacevalComputation_in | identifies the computation object created via pacevalLibrary_CreateComputation() |
functionString_in | points to a null-terminated string to be used as the function to work with |
numberOfVariables_in | specifies the number of variables to work with (e.g. if the variables are "xValue yValue zValue" or "x y z" numberOfVariables_in must be set to 3) |
variables_in | points to a null-terminated string specifying the names of the working variables (generally the variables must be separated by a blank, e.g. the variables xValue, yValue, zValue must be set with "xValue yValue zValue" or the variables x, y, z must be set with "x y z") |
useInterval_in | enables or disables the Trusted Interval Computation, TINC (paceval specific) putting bounds on rounding errors and measurement errors of the computation system to yield reliable results |
void paceval_activityStart_Thread_DeleteComputation | ( | PACEVAL_HANDLE | handle_pacevalComputation_in | ) |
this function is called when the deletion of the computation object starts
handle_pacevalComputation_in | identifies the computation object created via pacevalLibrary_CreateComputation() |
void paceval_activityStart_Thread_GetComputationResult | ( | PACEVAL_HANDLE | handle_pacevalComputation_in | ) |
this function is called when the calculation on a paceval_cComputation object starts
handle_pacevalComputation_in | identifies the computation object created via pacevalLibrary_CreateComputation() |
void * paceval_activityThread_GetComputationResult | ( | void * | arg | ) |
void paceval_activityUseCache_Thread_GetComputationResult | ( | PACEVAL_HANDLE | handle_pacevalComputation_in, |
const bool | isMainCalculation_in, | ||
const unsigned long | stackNumber_in, | ||
unsigned long | startSpecificAtNode_in, | ||
unsigned long | endSpecificAtNode_in ) |
this function is called when the calculation uses data for caching
handle_pacevalComputation_in | identifies the computation object created via pacevalLibrary_CreateComputation() |
isMainCalculation_in | specifies whether this is the main calculation (true) or not (false) |
stackNumber_in | specifies the number of the stack that is being worked with in a locked manner |
startSpecificAtNode_in | specifies the node at which the calculation is started by the thread |
endSpecificAtNode_in | specifies the node at which the calculation ends by the thread |
bool paceval_cComputation_doComputation | ( | PACEVAL_HANDLE | handle_pacevalComputation_in, |
const bool | singleCalculation_in, | ||
const unsigned long | startSpecificAtNode_in, | ||
const unsigned long | endSpecificAtNode_in, | ||
const unsigned int | sizeOfLongDouble_in, | ||
const paceval_eCalculationPrecisionTypes | useCalculationPrecision_in, | ||
void * | result_out, | ||
const unsigned long | stackNumber_in, | ||
bool * | error_out, | ||
void * | errorInformation_out, | ||
void * | trustedMinResult_out, | ||
void * | trustedMaxResult_out ) |
carries out a concrete calculation in the area of a start node and end node and returns whether an error occurred
handle_pacevalComputation_in | the pointer to the paceval computation object managed in the paceval library |
singleCalculation_in | specifies whether this is the main computation that traverses the entire list of nodes (true) or is a minor computation that traverses only part of the list of nodes (false) |
startSpecificAtNode_in | specifies the node at which the calculation is started |
endSpecificAtNode_in | specifies the node at which the calculation ends |
sizeOfLongDouble_in | specifies the size in bytes of long double in the calling system determined via sizeof(long double) |
useCalculationPrecision_in | specifies the precision with which the calculation is performed |
result_out | the buffer for the result of the calculation with the specified precision |
stackNumber_in | the number of the stack, e.g. for the values of the variables of the specific calculation |
error_out | the buffer whether an error occurred during the calculation (true) or not (false) |
errorInformation_out | the specific error information |
trustedMinResult_out | this buffer retrieves the minimum/lower interval limit of the calculation (annotation: in case of an error the value is not specified) |
trustedMaxResult_out | this buffer retrieves the maximum/upper limit of the calculation (annotation: in case of an error the value is not specified) |
unsigned long paceval_cComputation_getIdSingleCalculation | ( | PACEVAL_HANDLE | handle_pacevalComputation_in | ) |
gets the identification of the main computation that traverses the entire list of nodes (this is used by paceval for locking method because we want to avoid using mutex)
handle_pacevalComputation_in | the pointer to the paceval computation object managed in the paceval library |
long paceval_cComputation_getSingleCalculationPosition | ( | PACEVAL_HANDLE | handle_pacevalComputation_in | ) |
gets the node position where the main computation that traverses the entire list of nodes is currently located
handle_pacevalComputation_in | the pointer to the paceval computation object managed in the paceval library |
void paceval_cComputation_increaseIdSingleCalculation | ( | PACEVAL_HANDLE | handle_pacevalComputation_in | ) |
increases the identification of the main computation that traverses the entire list of nodes by 1
handle_pacevalComputation_in | the pointer to the paceval computation object managed in the paceval library |
long paceval_cComputation_lockAndGetToDoLevelMultithreadPosition | ( | PACEVAL_HANDLE | handle_pacevalComputation_in, |
const unsigned long | stackNumber_in, | ||
unsigned long | idSingleCalculationToDo_in, | ||
unsigned long * | lastToDoLevelMultithreadPosition_in, | ||
unsigned long * | startSpecificAtNode_in, | ||
unsigned long * | endSpecificAtNode_in ) |
locks parallel computation by a thread so that data for caching, for example, does not overwrite each other and returns its position, see paceval_fThreadHandling.cpp and paceval_cGraph.cpp
handle_pacevalComputation_in | the pointer to the paceval computation object managed in the paceval library |
idSingleCalculationToDo_in | specifies the identification of the main computation |
stackNumber_in | specifies the number of the stack that is being worked with in a locked manner |
lastToDoLevelMultithreadPosition_in | specifies the starting point for a possible parallel computation for a lookahead chaching thread |
startSpecificAtNode_in | specifies the node at which the calculation is started by the thread |
endSpecificAtNode_in | specifies the node at which the calculation ends by the thread |
bool paceval_cComputation_unlockToDoLevelMultithreadPosition | ( | PACEVAL_HANDLE | handle_pacevalComputation_in, |
const unsigned long | stackNumber_in, | ||
unsigned long | lockedLevelMultithreadPosition_in, | ||
unsigned long | idSingleCalculationToDo_in ) |
unlocks parallel computation by a thread, see paceval_fThreadHandling.cpp and paceval_cGraph.cpp
handle_pacevalComputation_in | the pointer to the paceval computation object managed in the paceval library |
stackNumber_in | specifies the number of the stack that was worked with locked |
lockedLevelMultithreadPosition_in | specifies the position of the lock for unlocking |
idSingleCalculationToDo_in | specifies the identification of the main computation |