choosegenerators.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #ifndef CHOOSEGENERATORS_H
  2. #define CHOOSEGENERATORS_H
  3. #include "ui_choosegenerators.h"
  4. #include <Mandel.h>
  5. #include <IterationCompiler.h>
  6. #include "Bitmap.h"
  7. #include <QDialog>
  8. #include <QValidator>
  9. #include <QLineEdit>
  10. #include <QComboBox>
  11. #include <QRunnable>
  12. #include <QThread>
  13. #include <QThreadPool>
  14. #include <memory>
  15. #include <map>
  16. class Almond;
  17. namespace Ui
  18. {
  19. class ChooseGenerators;
  20. }
  21. class Benchmarker : public QObject, public QRunnable
  22. {
  23. Q_OBJECT
  24. private:
  25. mnd::MandelContext& mndContext;
  26. mnd::MandelGenerator& generator;
  27. int row;
  28. float percentage;
  29. static const std::vector<mnd::MandelInfo> benches;
  30. public:
  31. inline Benchmarker(mnd::MandelContext& mndContext, mnd::MandelGenerator& generator, int row, float percentage) :
  32. mndContext{ mndContext },
  33. generator{ generator },
  34. row{ row },
  35. percentage{ percentage }
  36. {
  37. }
  38. virtual ~Benchmarker(void) override;
  39. static mnd::MandelViewport benchViewport(void);
  40. std::pair<long long, std::chrono::nanoseconds> measureMips(const std::function<Bitmap<float>*()>& bench) const;
  41. double benchmarkResult(mnd::MandelGenerator& mg) const;
  42. void run(void) override;
  43. signals:
  44. void finished(int row, float percentage, double mips);
  45. };
  46. class ChooseGenerators : public QDialog
  47. {
  48. Q_OBJECT
  49. private:
  50. Almond& owner;
  51. Ui::ChooseGenerators* sadfgsdfg;
  52. std::unique_ptr<Ui::ChooseGenerators> ui;
  53. mnd::MandelContext& mndCtxt;
  54. std::map<QString, mnd::MandelGenerator*> generators;
  55. std::vector<std::pair<QLineEdit*, QComboBox*>> tableContent;
  56. mnd::MandelGenerator* chosenGenerator;
  57. std::vector<mnd::MandelGenerator*> actualGenerators;
  58. mnd::AdaptiveGenerator& generator;
  59. std::vector<mnd::MandelGenerator*> allGenerators;
  60. std::unique_ptr<QValidator> floatValidator;
  61. QThreadPool benchmarker;
  62. public:
  63. ChooseGenerators(mnd::MandelContext& mndCtxt, mnd::AdaptiveGenerator& generator, std::vector<mnd::MandelGenerator*> allGenerators, Almond& owner);
  64. ~ChooseGenerators();
  65. inline mnd::MandelGenerator* getChosenGenerator(void) { return chosenGenerator; }
  66. private:
  67. QComboBox* createComboBox(void);
  68. QLineEdit* createFloatText(void);
  69. public slots:
  70. private slots:
  71. void setBenchmarkResult(int row, float percentage, double mips);
  72. void on_buttonBox_accepted();
  73. void on_run_clicked();
  74. void on_generatorTable_cellDoubleClicked(int row, int column);
  75. void on_compile_clicked();
  76. void on_benchmark_clicked();
  77. };
  78. #endif // CHOOSEGENERATORS_H