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
Loading...
Searching...
No Matches
Classes | Functions
paceval_fThreadHandling.cpp File Reference

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"
Include dependency graph for paceval_fThreadHandling.cpp:

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)
 

Detailed Description

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)

Function Documentation

◆ increasePacevalLibraryNumberThreadsFailure()

void increasePacevalLibraryNumberThreadsFailure ( )

increases the count of the number of failed threads by 1

Here is the caller graph for this function:

◆ increasePacevalLibraryNumberThreadsUsed()

void increasePacevalLibraryNumberThreadsUsed ( )

increases the counter for the number of threads used by 1

Here is the caller graph for this function:

◆ paceval_activityAccept_Thread_MultithreadOpportunity()

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)

Parameters
handle_pacevalComputation_inidentifies the computation object created via pacevalLibrary_CreateComputation()
startSpecificAtNode_inspecifies the node at which the calculation is started
endSpecificAtNode_inspecifies the node at which the calculation ends
Here is the caller graph for this function:

◆ paceval_activityEnd_Thread_CreateComputation()

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))

Parameters
handle_pacevalComputation_inidentifies the computation object created via pacevalLibrary_CreateComputation()
functionString_inpoints to a null-terminated string to be used as the function to work with
numberOfVariables_inspecifies 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_inpoints 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_inenables 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_inspecifies whether the computation object was created successfully (true) or not (false)
numberOfNodes_inspecifies the number of nodes in the linked list of atomic suboperations
Here is the caller graph for this function:

◆ paceval_activityEnd_Thread_GetComputationResult()

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

Parameters
handle_pacevalComputation_inidentifies the computation object created via pacevalLibrary_CreateComputation()
success_inspecifies whether the calculation was successful (true) or not (false)
Here is the caller graph for this function:

◆ paceval_activityGet_Thread_system_maxNumberThreads()

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

Parameters
system_numberCores_inspecifies the the number of cores available in the system
system_maxNumberThreads_inspecifies 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)
Here is the caller graph for this function:

◆ paceval_activityMain_Thread_GetComputationResult()

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)

Parameters
handle_pacevalComputation_inidentifies the computation object created via pacevalLibrary_CreateComputation()
useCalculationPrecision_inspecifies the precision with which the calculation should be performed
numberOfThreads_inspecifies the number of threads to use
sizeOfLongDouble_inspecifies the size in bytes of long double in the calling system determined via sizeof(long double)
result_outthe 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_outif 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_outif 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)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ paceval_activitySetCache_Thread_GetComputationResult()

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

Parameters
handle_pacevalComputation_inidentifies the computation object created via pacevalLibrary_CreateComputation()
useMutex_out_inspecifies 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_inspecifies the number of the stack that is being worked with in a locked manner
startSpecificAtNode_inspecifies the node at which the calculation is started by the thread
endSpecificAtNode_inspecifies the node at which the calculation ends by the thread
Here is the caller graph for this function:

◆ paceval_activityStart_Thread_CreateComputation()

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

Parameters
handle_pacevalComputation_inidentifies the computation object created via pacevalLibrary_CreateComputation()
functionString_inpoints to a null-terminated string to be used as the function to work with
numberOfVariables_inspecifies 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_inpoints 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_inenables 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
Here is the caller graph for this function:

◆ paceval_activityStart_Thread_DeleteComputation()

void paceval_activityStart_Thread_DeleteComputation ( PACEVAL_HANDLE handle_pacevalComputation_in)

this function is called when the deletion of the computation object starts

Parameters
handle_pacevalComputation_inidentifies the computation object created via pacevalLibrary_CreateComputation()
Here is the caller graph for this function:

◆ paceval_activityStart_Thread_GetComputationResult()

void paceval_activityStart_Thread_GetComputationResult ( PACEVAL_HANDLE handle_pacevalComputation_in)

this function is called when the calculation on a paceval_cComputation object starts

Parameters
handle_pacevalComputation_inidentifies the computation object created via pacevalLibrary_CreateComputation()
Here is the caller graph for this function:

◆ paceval_activityThread_GetComputationResult()

void * paceval_activityThread_GetComputationResult ( void * arg)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ paceval_activityUseCache_Thread_GetComputationResult()

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

Parameters
handle_pacevalComputation_inidentifies the computation object created via pacevalLibrary_CreateComputation()
isMainCalculation_inspecifies whether this is the main calculation (true) or not (false)
stackNumber_inspecifies the number of the stack that is being worked with in a locked manner
startSpecificAtNode_inspecifies the node at which the calculation is started by the thread
endSpecificAtNode_inspecifies the node at which the calculation ends by the thread
Here is the caller graph for this function:

◆ paceval_cComputation_doComputation()

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

Parameters
handle_pacevalComputation_inthe pointer to the paceval computation object managed in the paceval library
singleCalculation_inspecifies 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_inspecifies the node at which the calculation is started
endSpecificAtNode_inspecifies the node at which the calculation ends
sizeOfLongDouble_inspecifies the size in bytes of long double in the calling system determined via sizeof(long double)
useCalculationPrecision_inspecifies the precision with which the calculation is performed
result_outthe buffer for the result of the calculation with the specified precision
stackNumber_inthe number of the stack, e.g. for the values of the variables of the specific calculation
error_outthe buffer whether an error occurred during the calculation (true) or not (false)
errorInformation_outthe specific error information
trustedMinResult_outthis buffer retrieves the minimum/lower interval limit of the calculation (annotation: in case of an error the value is not specified)
trustedMaxResult_outthis buffer retrieves the maximum/upper limit of the calculation (annotation: in case of an error the value is not specified)
Here is the caller graph for this function:

◆ paceval_cComputation_getIdSingleCalculation()

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)

Parameters
handle_pacevalComputation_inthe pointer to the paceval computation object managed in the paceval library
Here is the caller graph for this function:

◆ paceval_cComputation_getSingleCalculationPosition()

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

Parameters
handle_pacevalComputation_inthe pointer to the paceval computation object managed in the paceval library
Here is the caller graph for this function:

◆ paceval_cComputation_increaseIdSingleCalculation()

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

Parameters
handle_pacevalComputation_inthe pointer to the paceval computation object managed in the paceval library
Here is the caller graph for this function:

◆ paceval_cComputation_lockAndGetToDoLevelMultithreadPosition()

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

Parameters
handle_pacevalComputation_inthe pointer to the paceval computation object managed in the paceval library
idSingleCalculationToDo_inspecifies the identification of the main computation
stackNumber_inspecifies the number of the stack that is being worked with in a locked manner
lastToDoLevelMultithreadPosition_inspecifies the starting point for a possible parallel computation for a lookahead chaching thread
startSpecificAtNode_inspecifies the node at which the calculation is started by the thread
endSpecificAtNode_inspecifies the node at which the calculation ends by the thread
Here is the caller graph for this function:

◆ paceval_cComputation_unlockToDoLevelMultithreadPosition()

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

Parameters
handle_pacevalComputation_inthe pointer to the paceval computation object managed in the paceval library
stackNumber_inspecifies the number of the stack that was worked with locked
lockedLevelMultithreadPosition_inspecifies the position of the lock for unlocking
idSingleCalculationToDo_inspecifies the identification of the main computation
Here is the caller graph for this function:

https://paceval.com