choosegenerators.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. std::unique_ptr<QValidator> floatValidator;
  57. //std::unique_ptr<mnd::AdaptiveGenerator> createdGenerator;
  58. mnd::MandelGenerator* chosenGenerator;
  59. std::vector<mnd::MandelGenerator*> actualGenerators;
  60. QThreadPool benchmarker;
  61. public:
  62. ChooseGenerators(mnd::MandelContext& mndCtxt, Almond& owner);
  63. ~ChooseGenerators();
  64. inline mnd::MandelGenerator* getChosenGenerator(void) { return chosenGenerator; }
  65. private:
  66. QComboBox* createComboBox(void);
  67. QLineEdit* createFloatText(void);
  68. public slots:
  69. private slots:
  70. void setBenchmarkResult(int row, float percentage, double mips);
  71. void on_buttonBox_accepted();
  72. void on_run_clicked();
  73. void on_generatorTable_cellDoubleClicked(int row, int column);
  74. void on_compile_clicked();
  75. void on_benchmark_clicked();
  76. };
  77. #endif // CHOOSEGENERATORS_H