dynclock.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef DYNCLOCK_H
  2. #define DYNCLOCK_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. struct thr_info;
  6. #define DCLK_MAXMAXERRORRATE 0.05
  7. #define DCLK_ERRORHYSTERESIS 0.1
  8. #define DCLK_OVERHEATTHRESHOLD 0.4
  9. struct dclk_data {
  10. uint8_t freqM;
  11. uint8_t freqMaxM;
  12. uint8_t freqMDefault;
  13. double errorCount[256];
  14. double errorWeight[256];
  15. double errorRate[256];
  16. double maxErrorRate[256];
  17. };
  18. typedef bool (*dclk_change_clock_func_t)(struct thr_info *, int multiplier);
  19. extern void dclk_msg_freqchange(const char *, int oldFreq, int newFreq, const char *tail);
  20. // Called to initialize dclk_data at startup
  21. extern void dclk_prepare(struct dclk_data *data);
  22. // Called for every quarter of a second to age error rate info
  23. extern void dclk_gotNonces(struct dclk_data *);
  24. // Called for errors (1.0 "portion" is a quarter second)
  25. extern void dclk_errorCount(struct dclk_data *, double portion);
  26. // Called after a nonce range is completed to update actual error rate
  27. extern void dclk_preUpdate(struct dclk_data *data);
  28. // Called after a nonce range is completed, and error rate updated, to make actual clock adjustments
  29. extern bool dclk_updateFreq(struct dclk_data *, dclk_change_clock_func_t changeclock, struct thr_info *);
  30. #endif