.TH "opmphmpredictor.c" 3elektra "Fri Aug 4 2023" "Version 0.11.0" "Elektra" \" -*- nroff -*-
.ad l
.nh
.SH NAME
opmphmpredictor.c \- The Order Preserving Minimal Perfect Hash Map Predictor\&.  

.SH SYNOPSIS
.br
.PP
\fC#include <kdbassert\&.h>\fP
.br
\fC#include <kdbhelper\&.h>\fP
.br
\fC#include <kdblogger\&.h>\fP
.br
\fC#include <kdbopmphmpredictor\&.h>\fP
.br
\fC#include <kdbprivate\&.h>\fP
.br
\fC#include <stdlib\&.h>\fP
.br
\fC#include <string\&.h>\fP
.br

.SS "Functions"

.in +1c
.ti -1c
.RI "size_t \fBopmphmPredictorWorthOpmphm\fP (size_t n)"
.br
.RI "Heuristic function above the OPMPHM usage is worth\&. "
.ti -1c
.RI "void \fBopmphmPredictorIncCountOpmphm\fP (OpmphmPredictor *op)"
.br
.RI "Increases the counter when the OPMPHM was used for the ksLookup (\&.\&.\&.) \&. "
.ti -1c
.RI "int \fBopmphmPredictorIncCountBinarySearch\fP (OpmphmPredictor *op, size_t n)"
.br
.RI "Increases the counter when the Binary Search was used for the ksLookup (\&.\&.\&.) \&. "
.ti -1c
.RI "int \fBopmphmPredictor\fP (OpmphmPredictor *op, size_t n)"
.br
.RI "Predictcs at the first ksLookup (\&.\&.\&.) after a KeySet changed if it will be worth using the OPMPHM\&. "
.ti -1c
.RI "OpmphmPredictor * \fBopmphmPredictorNew\fP (void)"
.br
.RI "Allocates and initializes the OpmphmPredictor\&. "
.ti -1c
.RI "void \fBopmphmPredictorCopy\fP (OpmphmPredictor *dest, OpmphmPredictor *source)"
.br
.RI "Make a copy of the OpmphmPredictor\&. "
.ti -1c
.RI "void \fBopmphmPredictorDel\fP (OpmphmPredictor *op)"
.br
.RI "Deletes the OpmphmPredictor\&. "
.in -1c
.SS "Variables"

.in +1c
.ti -1c
.RI "const uint16_t \fBopmphmPredictorHistoryMask\fP = 0x1FF"
.br
.RI "The benchmarked and evaluated values of the predictors configuration\&. "
.ti -1c
.RI "const size_t \fBopmphmPredictorActionLimit\fP = 599"
.br
.RI "The opmphmPredictorActionLimit define the minimum KeySet size necessary for predictor actions\&. "
.in -1c
.SH "Detailed Description"
.PP 
The Order Preserving Minimal Perfect Hash Map Predictor\&. 


.PP
\fBCopyright\fP
.RS 4
BSD License (see LICENSE\&.md or https://www.libelektra.org) 
.RE
.PP

.SH "Function Documentation"
.PP 
.SS "int opmphmPredictor (OpmphmPredictor * op, size_t n)"

.PP
Predictcs at the first ksLookup (\&.\&.\&.) after a KeySet changed if it will be worth using the OPMPHM\&. Predictor functions\&.
.PP
Uses the opmphmPredictorWorthOpmphm (\&.\&.\&.) to check if the previous sequence of ksLookup (\&.\&.\&.) invocations without alteration was worth using the OPMPHM\&. Updates the state with the predictionAutomata and the worth information of the previous history\&. Alters the history with the worth information and makes the prediction for the next sequence of ksLookup (\&.\&.\&.) invocations\&.
.PP
\fBParameters\fP
.RS 4
\fIop\fP the Predictor 
.br
\fIn\fP the number of elements in the KeySet
.RE
.PP
\fBReturn values\fP
.RS 4
\fI1\fP it is worth using the OPMPHM 
.br
\fI0\fP it is not worth using the OPMPHM 
.RE
.PP

.SS "void opmphmPredictorCopy (OpmphmPredictor * dest, OpmphmPredictor * source)"

.PP
Make a copy of the OpmphmPredictor\&. 
.PP
\fBParameters\fP
.RS 4
\fIsource\fP the OpmphmPredictor source 
.br
\fIdest\fP the OpmphmPredictor destination 
.RE
.PP

.SS "void opmphmPredictorDel (OpmphmPredictor * op)"

.PP
Deletes the OpmphmPredictor\&. Clears and frees all memory in OpmphmPredictor\&.
.PP
\fBParameters\fP
.RS 4
\fIop\fP the OpmphmPredictor 
.RE
.PP

.SS "int opmphmPredictorIncCountBinarySearch (OpmphmPredictor * op, size_t n)\fC [inline]\fP"

.PP
Increases the counter when the Binary Search was used for the ksLookup (\&.\&.\&.) \&. Prevents also an endless Binary Search usage by a simple heuristic\&.
.PP
\fBParameters\fP
.RS 4
\fIop\fP the Predictor 
.br
\fIn\fP the number of elements in the KeySet
.RE
.PP
\fBReturn values\fP
.RS 4
\fI1\fP it is worth using the OPMPHM 
.br
\fI0\fP it is not worth using the OPMPHM 
.RE
.PP

.SS "void opmphmPredictorIncCountOpmphm (OpmphmPredictor * op)\fC [inline]\fP"

.PP
Increases the counter when the OPMPHM was used for the ksLookup (\&.\&.\&.) \&. 
.PP
\fBParameters\fP
.RS 4
\fIop\fP the Predictor 
.RE
.PP

.SS "OpmphmPredictor* opmphmPredictorNew (void)"

.PP
Allocates and initializes the OpmphmPredictor\&. Basic functions\&.
.PP
Reserves for all possible values of opmphmPredictorHistoryMask two bits to store all 4 states of the Prediction Automata A2\&. Sets the initial state to 0\&.
.PP
\fBReturn values\fP
.RS 4
\fIOpmphmPredictor\fP * success 
.br
\fINULL\fP memory error 
.RE
.PP

.SS "size_t opmphmPredictorWorthOpmphm (size_t n)\fC [inline]\fP"

.PP
Heuristic function above the OPMPHM usage is worth\&. Heuristic function\&.
.PP
This easy and fast computable heuristic function tells how many ksLookup (\&.\&.\&.) invocations without alteration of the KeySet need to be made to justify the OPMPHM usage\&. This heuristic function is developed and measured by benchmarks\&.
.PP
\fBParameters\fP
.RS 4
\fIn\fP the number of elements in the KeySet
.RE
.PP
\fBReturn values\fP
.RS 4
\fIsize_t\fP the heuristic value 
.RE
.PP

.SH "Variable Documentation"
.PP 
.SS "const uint16_t opmphmPredictorHistoryMask = 0x1FF"

.PP
The benchmarked and evaluated values of the predictors configuration\&. Order Preserving Minimal Perfect Hash Map Predictor\&. 
.SH "Author"
.PP 
Generated automatically by Doxygen for Elektra from the source code\&.
