autotuner.h 1.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   < BioEM software for Bayesian inference of Electron Microscopy images>
   Copyright (C) 2016 Pilar Cossio, David Rohr, Fabio Baruffa, Markus Rampp, 
        Volker Lindenstruth and Gerhard Hummer.
   Max Planck Institute of Biophysics, Frankfurt, Germany.

   See license statement for terms of distribution.

   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

#ifndef AUTOTUNER_H
#define AUTOTUNER_H

class Autotuner {

public:
	Autotuner() {stopTuning = true;}

	/* Setting variables to initial values */
	inline void Initialize(int alg=3, int st=7) {algo = alg; stable=st; Reset(); }

	/* Resetting variables to initial values */
	void Reset();

	/* Check if autotuning is needed, depending on which comparison is finished */
	bool Needed(int iteration);

	/* Check if optimal workload value has been computed */
	bool Finished();

	/* Set a new workload value to test, depending on the algorithm */
	void Tune(double compTime);

	/* Return workload value */
	inline int Workload() {return workload;}

private:
	int algo;
	int stable;

	bool stopTuning;
	int workload;

	/* Variables needed for AlgoSimple and AlgoRatio */
	double best_time;
	int best_workload;

	/* Variables needed for AlgoBisection */
	int a;
	int b;
	int c;
	int x;
	int limit;
	double fb, fx;

	/* Autotuning algorithms */
	void AlgoSimple(double compTime);
	void AlgoRatio(double compTime);
	void AlgoBisection(double compTime);
};

#endif