Explorar el Código

restructure generator properties

Nicolas Winkler hace 5 años
padre
commit
9e80f1eebd

+ 43 - 18
Almond.cpp

@@ -172,7 +172,7 @@ void Almond::on_displayInfo_stateChanged(int checked)
 void Almond::on_chooseGenerator_clicked()
 {
     if (!generatorsDialog)
-        generatorsDialog = std::make_unique<ChooseGenerators>(mandelContext, *this);
+        generatorsDialog = std::make_unique<ChooseGenerators>(mandelContext, mandelContext.getDefaultGenerator(), *this);
     generatorsDialog->exec();
 
     if (generatorsDialog->getChosenGenerator()) {
@@ -239,10 +239,10 @@ void Almond::saveView()
 }
 
 
-void Almond::on_wMandel_toggled(bool checked)
+void Almond::setViewType(ViewType v)
 {
     saveView();
-    if (checked) {
+    if (v == MANDELBROT) {
         currentGenerator = mandelGenerator;
         emit this->mw->stopSelectingPoint();
         this->mw->setViewport(mandelViewSave);
@@ -251,12 +251,21 @@ void Almond::on_wMandel_toggled(bool checked)
         this->mw->clearAll();
         currentView = MANDELBROT;
     }
-}
-
-void Almond::on_radioButton_toggled(bool checked)
-{
-    saveView();
-    if (checked) {
+    else if (v == CUSTOM) {
+        if (customGenerator != nullptr) {
+            currentGenerator = customGenerator;
+            this->mw->setGenerator(currentGenerator);
+            emit this->mw->stopSelectingPoint();
+            this->mw->setViewport(customViewSave);
+            this->mw->getMandelInfo().julia = false;
+            this->mw->clearAll();
+            currentView = CUSTOM;
+        }
+        else {
+            setViewType(MANDELBROT);
+        }
+    }
+    else if (v == JULIA) {
         if (currentView == MANDELBROT) {
             emit this->mw->selectPoint();
         }
@@ -272,6 +281,21 @@ void Almond::on_radioButton_toggled(bool checked)
     }
 }
 
+
+void Almond::on_wMandel_toggled(bool checked)
+{
+    if (checked)
+        setViewType(MANDELBROT);
+}
+
+void Almond::on_radioButton_toggled(bool checked)
+{
+    saveView();
+    if (checked) {
+        setViewType(JULIA);
+    }
+}
+
 void Almond::on_radioButton_2_toggled(bool checked)
 {
     saveView();
@@ -282,14 +306,15 @@ void Almond::on_radioButton_2_toggled(bool checked)
                 customGenerator = frac->gc.cpuGenerators[0].get();
             }
         }
-        if (customGenerator != nullptr) {
-            currentGenerator = customGenerator;
-            this->mw->setGenerator(currentGenerator);
-            emit this->mw->stopSelectingPoint();
-            this->mw->setViewport(customViewSave);
-            this->mw->getMandelInfo().julia = false;
-            this->mw->clearAll();
-            currentView = CUSTOM;
-        }
+        setViewType(CUSTOM);
+    }
+}
+
+void Almond::on_createCustom_clicked()
+{
+    customGeneratorDialog->exec();
+    if (auto* frac = customGeneratorDialog->getLastCompiled()) {
+        customGenerator = frac->gc.cpuGenerators[0].get();
     }
+    setViewType(CUSTOM);
 }

+ 2 - 2
Almond.h

@@ -80,12 +80,12 @@ private slots:
     void on_groupBox_toggled(bool arg1);
 
     void saveView(void);
+    void setViewType(ViewType v);
 
     void on_wMandel_clicked();
-
     void on_radioButton_toggled(bool checked);
-
     void on_radioButton_2_toggled(bool checked);
+    void on_createCustom_clicked();
 
 private:
     Ui::AlmondClass ui;

+ 2 - 2
Almond.ui

@@ -10,7 +10,7 @@
     <x>0</x>
     <y>0</y>
     <width>950</width>
-    <height>665</height>
+    <height>744</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -197,7 +197,7 @@
             <item>
              <widget class="QPushButton" name="createCustom">
               <property name="text">
-               <string>Create</string>
+               <string>Change</string>
               </property>
              </widget>
             </item>

+ 1 - 1
MandelVideoGenerator.cpp

@@ -138,7 +138,7 @@ Bitmap<RGBColor> MandelVideoGenerator::overlay(const Bitmap<RGBColor>& outer,
         }
     }
     auto after = std::chrono::high_resolution_clock::now();
-    printf("gradient applied in: %lld microseconds\n", std::chrono::duration_cast<std::chrono::microseconds>(after - before).count());
+    //printf("gradient applied in: %lld microseconds\n", std::chrono::duration_cast<std::chrono::microseconds>(after - before).count());
     fflush(stdout);
     /*for (int i = 0; i < ret.height * ret.width; i++) {
         ret.pixels[i] = outer.pixels[i];

+ 15 - 5
choosegenerators.cpp

@@ -124,12 +124,15 @@ void Benchmarker::run(void)
 }
 
 
-ChooseGenerators::ChooseGenerators(mnd::MandelContext& mndCtxt, Almond& owner) :
+ChooseGenerators::ChooseGenerators(mnd::MandelContext& mndCtxt, mnd::AdaptiveGenerator& generator,
+                                   std::vector<mnd::MandelGenerator*> allGenerators, Almond& owner) :
     QDialog{ &owner },
     owner{ owner },
     ui{ std::make_unique<Ui::ChooseGenerators>() },
     mndCtxt{ mndCtxt },
-    tableContent{}
+    tableContent{},
+    generator{ generator },
+    allGenerators{ allGenerators }
 {
     ui->setupUi(this);
     ui->progressBar->setRange(0, 1000);
@@ -153,8 +156,7 @@ ChooseGenerators::ChooseGenerators(mnd::MandelContext& mndCtxt, Almond& owner) :
         }
     }
 
-    auto& defGen = mndCtxt.getDefaultGenerator();
-    for (auto it = defGen.getGenerators().rbegin(); it != defGen.getGenerators().rend(); it++) {
+    for (auto it = generator.getGenerators().rbegin(); it != generator.getGenerators().rend(); it++) {
         auto& [prec, gen] = *it;
         ui->table->insertRow(0);
         QLineEdit* le = createFloatText();
@@ -175,7 +177,15 @@ ChooseGenerators::ChooseGenerators(mnd::MandelContext& mndCtxt, Almond& owner) :
     }
     ui->table->resizeColumnsToContents();
 
-    std::vector<mnd::GeneratorType> generatorTypes = mndCtxt.getSupportedTypes();
+    std::vector<mnd::GeneratorType> generatorTypes;
+
+    for (auto* gen : allGenerators) {
+        if(gen->getPrecision()) {
+
+        }
+    }
+
+    //std::vector<mnd::GeneratorType> generatorTypes = mndCtxt.getSupportedTypes();
     for (size_t i = 0; i < generatorTypes.size(); i++) {
         int rowCount = ui->generatorTable->rowCount();
         ui->generatorTable->insertRow(rowCount);

+ 5 - 3
choosegenerators.h

@@ -67,14 +67,16 @@ private:
     mnd::MandelContext& mndCtxt;
     std::map<QString, mnd::MandelGenerator*> generators;
     std::vector<std::pair<QLineEdit*, QComboBox*>> tableContent;
-    std::unique_ptr<QValidator> floatValidator;
-    //std::unique_ptr<mnd::AdaptiveGenerator> createdGenerator;
     mnd::MandelGenerator* chosenGenerator;
     std::vector<mnd::MandelGenerator*> actualGenerators;
 
+    mnd::AdaptiveGenerator& generator;
+    std::vector<mnd::MandelGenerator*> allGenerators;
+
+    std::unique_ptr<QValidator> floatValidator;
     QThreadPool benchmarker;
 public:
-    ChooseGenerators(mnd::MandelContext& mndCtxt, Almond& owner);
+    ChooseGenerators(mnd::MandelContext& mndCtxt, mnd::AdaptiveGenerator& generator, std::vector<mnd::MandelGenerator*> allGenerators, Almond& owner);
     ~ChooseGenerators();
 
     inline mnd::MandelGenerator* getChosenGenerator(void) { return chosenGenerator; }

+ 3 - 3
choosegenerators.ui

@@ -39,12 +39,12 @@
              <attribute name="horizontalHeaderVisible">
               <bool>false</bool>
              </attribute>
-             <attribute name="horizontalHeaderDefaultSectionSize">
-              <number>180</number>
-             </attribute>
              <attribute name="horizontalHeaderMinimumSectionSize">
               <number>100</number>
              </attribute>
+             <attribute name="horizontalHeaderDefaultSectionSize">
+              <number>180</number>
+             </attribute>
              <attribute name="verticalHeaderVisible">
               <bool>false</bool>
              </attribute>

+ 13 - 1
customgenerator.cpp

@@ -17,7 +17,8 @@ CustomGenerator::~CustomGenerator()
     delete ui;
 }
 
-void CustomGenerator::on_compile_clicked()
+
+void CustomGenerator::compile()
 {
     QString z0formula = this->ui->formula_z0->text();
     QString ziformula = this->ui->formula_zi->text();
@@ -53,6 +54,12 @@ void CustomGenerator::on_compile_clicked()
 }
 
 
+void CustomGenerator::on_compile_clicked()
+{
+    compile();
+}
+
+
 FractalDef* CustomGenerator::getLastCompiled(void)
 {
     if (!fractalDefs.empty())
@@ -60,3 +67,8 @@ FractalDef* CustomGenerator::getLastCompiled(void)
     else
         return nullptr;
 }
+
+void CustomGenerator::on_buttonBox_accepted()
+{
+    compile();
+}

+ 4 - 0
customgenerator.h

@@ -32,9 +32,13 @@ public:
 
     FractalDef* getLastCompiled(void);
 
+    void compile();
+
 private slots:
     void on_compile_clicked();
 
+    void on_buttonBox_accepted();
+
 private:
     Ui::CustomGenerator *ui;
 };

+ 2 - 9
customgenerator.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>892</width>
-    <height>556</height>
+    <width>835</width>
+    <height>479</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -136,13 +136,6 @@
          </item>
         </layout>
        </item>
-       <item>
-        <widget class="QPushButton" name="compile">
-         <property name="text">
-          <string>Compile</string>
-         </property>
-        </widget>
-       </item>
       </layout>
      </item>
     </layout>

+ 0 - 1
libmandel/CMakeLists.txt

@@ -26,7 +26,6 @@ SET(MandelSources
     src/MandelUtil.cpp
     src/Types.cpp
     src/OpenClCode.cpp
-    src/JuliaGenerators.cpp
     src/IterationGenerator.cpp
     src/IterationFormula.cpp
     src/IterationCompiler.cpp

+ 1 - 1
libmandel/include/ClGenerators.h

@@ -36,7 +36,7 @@ protected:
     cl::CommandQueue queue;
     cl::Kernel kernel;
 public:
-    ClGenerator(MandelDevice& device, const std::string& source, const mnd::Real& precision);
+    ClGenerator(MandelDevice& device, const std::string& source, mnd::Precision type);
     virtual ~ClGenerator(void);
 
     virtual void generate(const MandelInfo& info, float* data) = 0;

+ 15 - 24
libmandel/include/CpuGenerators.h

@@ -5,16 +5,6 @@
 
 namespace mnd
 {
-    enum CpuExtension
-    {
-        NONE,
-        X86_SSE2,
-        X86_AVX,
-        X86_AVX_FMA,
-        X86_AVX_512,
-        ARM_NEON,
-    };
-
     template<typename T, mnd::CpuExtension ex = mnd::NONE, bool parallel = true>
     class CpuGenerator;
 }
@@ -25,7 +15,7 @@ class mnd::CpuGenerator : public MandelGenerator
 {
 public:
     inline CpuGenerator(void) :
-        MandelGenerator{ mnd::getPrecision<T>() }
+        MandelGenerator{ mnd::getType<T>(), ex }
     {
     }
     virtual void generate(const MandelInfo& info, float* data);
@@ -37,7 +27,7 @@ class mnd::CpuGenerator<T, mnd::NONE, parallel> : public MandelGenerator
 {
 public:
     inline CpuGenerator(void) :
-        MandelGenerator{ mnd::getPrecision<T>() }
+        MandelGenerator{ mnd::getType<T>(), mnd::NONE }
     {
     }
     virtual void generate(const MandelInfo& info, float* data);
@@ -49,7 +39,7 @@ class mnd::CpuGenerator<float, mnd::X86_SSE2, parallel> : public MandelGenerator
 {
 public:
     inline CpuGenerator(void) :
-        MandelGenerator{ mnd::getPrecision<float>() }
+        MandelGenerator{ mnd::Precision::FLOAT, mnd::X86_SSE2 }
     {
     }
     virtual void generate(const MandelInfo& info, float* data);
@@ -60,7 +50,7 @@ class mnd::CpuGenerator<double, mnd::X86_SSE2, parallel> : public MandelGenerato
 {
 public:
     inline CpuGenerator(void) :
-        MandelGenerator{ mnd::getPrecision<double>() }
+        MandelGenerator{ mnd::Precision::DOUBLE, mnd::X86_SSE2 }
     {
     }
     virtual void generate(const MandelInfo& info, float* data);
@@ -72,7 +62,7 @@ class mnd::CpuGenerator<float, mnd::X86_AVX, parallel> : public MandelGenerator
 {
 public:
     inline CpuGenerator(void) :
-        MandelGenerator{ mnd::getPrecision<float>() }
+        MandelGenerator{ mnd::Precision::FLOAT, mnd::X86_AVX }
     {
     }
     virtual void generate(const MandelInfo& info, float* data);
@@ -83,7 +73,7 @@ class mnd::CpuGenerator<double, mnd::X86_AVX, parallel> : public MandelGenerator
 {
 public:
     inline CpuGenerator(void) :
-        MandelGenerator{ mnd::getPrecision<double>() }
+        MandelGenerator{ mnd::Precision::DOUBLE, mnd::X86_AVX }
     {
     }
     virtual void generate(const MandelInfo& info, float* data);
@@ -94,7 +84,7 @@ class mnd::CpuGenerator<mnd::DoubleDouble, mnd::X86_AVX, parallel> : public Mand
 {
 public:
     inline CpuGenerator(void) :
-        MandelGenerator{ mnd::getPrecision<DoubleDouble>() }
+        MandelGenerator{ mnd::Precision::DOUBLE_DOUBLE, mnd::X86_AVX }
     {
     }
     virtual void generate(const MandelInfo& info, float* data);
@@ -107,7 +97,7 @@ class mnd::CpuGenerator<float, mnd::ARM_NEON, parallel> : public Generator
 public:
     CpuGenerator(void);
     inline CpuGenerator(void) :
-        Generator{ mnd::getPrecision<float>() }
+        MandelGenerator{ mnd::Precision::FLOAT, mnd::ARM_NEON }
     {
     }
     virtual void generate(const MandelInfo& info, float* data);
@@ -118,7 +108,7 @@ class mnd::CpuGenerator<double, mnd::ARM_NEON, parallel> : public Generator
 {
 public:
     inline CpuGenerator(void) :
-        Generator{ mnd::getPrecision<double>() }
+        MandelGenerator{ mnd::Precision::DOUBLE, mnd::ARM_NEON }
     {
     }
     virtual void generate(const MandelInfo& info, float* data);
@@ -131,7 +121,7 @@ class mnd::CpuGenerator<float, mnd::X86_AVX_FMA, parallel> : public MandelGenera
 {
 public:
     inline CpuGenerator(void) :
-        MandelGenerator{ mnd::getPrecision<float>() }
+        MandelGenerator{ mnd::Precision::FLOAT, mnd::X86_AVX_FMA }
     {
     }
     virtual void generate(const MandelInfo& info, float* data);
@@ -143,7 +133,7 @@ class mnd::CpuGenerator<double, mnd::X86_AVX_FMA, parallel> : public MandelGener
 {
 public:
     inline CpuGenerator(void) :
-        MandelGenerator{ mnd::getPrecision<double>() }
+        MandelGenerator{ mnd::Precision::DOUBLE, mnd::X86_AVX_FMA }
     {
     }
     virtual void generate(const MandelInfo& info, float* data);
@@ -155,7 +145,7 @@ class mnd::CpuGenerator<mnd::DoubleDouble, mnd::X86_AVX_FMA, parallel> : public
 {
 public:
     inline CpuGenerator(void) :
-        MandelGenerator{ mnd::getPrecision<DoubleDouble>() }
+        MandelGenerator{ mnd::Precision::DOUBLE_DOUBLE, mnd::X86_AVX_FMA }
     {
     }
     virtual void generate(const MandelInfo& info, float* data);
@@ -167,7 +157,7 @@ class mnd::CpuGenerator<float, mnd::X86_AVX_512, parallel> : public MandelGenera
 {
 public:
     inline CpuGenerator(void) :
-        MandelGenerator{ mnd::getPrecision<float>() }
+        MandelGenerator{ mnd::Precision::FLOAT, mnd::X86_AVX_512 }
     {
     }
     virtual void generate(const MandelInfo& info, float* data);
@@ -179,10 +169,11 @@ class mnd::CpuGenerator<double, mnd::X86_AVX_512, parallel> : public MandelGener
 {
 public:
     inline CpuGenerator(void) :
-        MandelGenerator{ mnd::getPrecision<double>() }
+        MandelGenerator{ mnd::Precision::DOUBLE, mnd::X86_AVX_512 }
     {
     }
     virtual void generate(const MandelInfo& info, float* data);
 };
 
 #endif // MANDEL_CPUGENERATORS_H
+

+ 78 - 26
libmandel/include/Generators.h

@@ -12,10 +12,10 @@
 namespace mnd
 {
     class MandelGenerator;
-    class JuliaGenerator;
 
     class AdaptiveGenerator;
 
+    enum class GeneratorType : int;
     enum class Precision : int
     {
         FLOAT,
@@ -23,14 +23,28 @@ namespace mnd
         DOUBLE,
         DOUBLE_DOUBLE,
         FLOAT128,
+        FLOAT256,
+        FLOAT512,
         FIXED64,
         FIXED128,
+        FIXED512,
         QUAD_DOUBLE,
-        FLOAT256,
         INF_PREC,
     };
 
+
+    enum CpuExtension : int
+    {
+        NONE,
+        X86_SSE2,
+        X86_AVX,
+        X86_AVX_FMA,
+        X86_AVX_512,
+        ARM_NEON,
+    };
+
     Real getPrecision(Precision p);
+    Real getPrecision(GeneratorType p);
     
     template<typename T>
     Real getPrecision(void);
@@ -45,16 +59,76 @@ namespace mnd
     template<> Real getPrecision<Float128>();
     template<> Real getPrecision<Float256>();
     template<> Real getPrecision<Float512>();
+
+    template<typename T>
+    Precision getType(void);
+    template<> Precision getType<float>() { return Precision::FLOAT; }
+    template<> Precision getType<double>() { return Precision::DOUBLE; }
+    template<> Precision getType<DoubleDouble>() { return Precision::DOUBLE_DOUBLE; }
+    template<> Precision getType<QuadDouble>() { return Precision::QUAD_DOUBLE; }
+    template<> Precision getType<Fixed64>() { return Precision::FIXED64; }
+    template<> Precision getType<Fixed128>() { return Precision::FIXED128; }
+    template<> Precision getType<Fixed512>() { return Precision::FIXED512; }
+    template<> Precision getType<Float128>() { return Precision::FLOAT128; }
+    template<> Precision getType<Float256>() { return Precision::FLOAT256; }
+    template<> Precision getType<Float512>() { return Precision::FLOAT512; }
 }
 
 
+enum class mnd::GeneratorType : int
+{
+    UNSPECIFIED,
+    FLOAT,
+    FLOAT_SSE2,
+    FLOAT_AVX,
+    FLOAT_AVX_FMA,
+    FLOAT_AVX512,
+    FLOAT_NEON,
+    DOUBLE_FLOAT,
+    DOUBLE,
+    DOUBLE_SSE2,
+    DOUBLE_AVX,
+    DOUBLE_AVX_FMA,
+    DOUBLE_AVX512,
+    DOUBLE_NEON,
+    DOUBLE_DOUBLE,
+    DOUBLE_DOUBLE_AVX,
+    DOUBLE_DOUBLE_AVX_FMA,
+    QUAD_DOUBLE,
+    FLOAT128,
+    FLOAT256,
+    FIXED64,
+    FIXED128,
+    FIXED512
+};
+
+
 class mnd::MandelGenerator
 {
 protected:
     Real precision;
+    Precision type;
+    CpuExtension extension;
 public:
-    inline MandelGenerator(const Real& precision) :
-        precision{ precision }
+    MandelGenerator();
+    inline MandelGenerator(Precision type) :
+        type{ type },
+        precision{ mnd::getPrecision(type) },
+        extension{ mnd::CpuExtension::NONE }
+    {
+    }
+
+    inline MandelGenerator(Precision type, CpuExtension extension) :
+        type{ type },
+        precision{ mnd::getPrecision(type) },
+        extension{ extension }
+    {
+    }
+
+    inline MandelGenerator(Precision type, CpuExtension extension, const Real& precision) :
+        type{ type },
+        precision{ precision },
+        extension{ extension }
     {
     }
 
@@ -72,28 +146,6 @@ public:
 };
 
 
-class mnd::JuliaGenerator : public MandelGenerator
-{
-public:
-    inline JuliaGenerator(const Real& precision) :
-        MandelGenerator{ precision }
-    {
-    }
-
-    virtual ~JuliaGenerator(void);
-
-
-    JuliaGenerator(const JuliaGenerator&) = delete;
-    JuliaGenerator& operator=(const JuliaGenerator&) = delete;
-
-    JuliaGenerator(JuliaGenerator&&) = default;
-    JuliaGenerator& operator=(JuliaGenerator&&) = default;
-
-    virtual void generate(const MandelInfo& info, float* data) = 0;
-};
-
-
-
 class mnd::AdaptiveGenerator : public MandelGenerator
 {
     std::map<Real, MandelGenerator*, std::greater<Real>> generators;

+ 7 - 3
libmandel/include/IterationGenerator.h

@@ -33,14 +33,18 @@ protected:
     IterationFormula z0;
     IterationFormula zi;
 public:
-    IterationGenerator(IterationFormula z0, IterationFormula zi, const mnd::Real& prec);
+    IterationGenerator(IterationFormula z0, IterationFormula zi,
+            mnd::Precision prec,
+            mnd::CpuExtension ex = mnd::CpuExtension::NONE);
 };
 
 
 class mnd::NaiveGenerator : public mnd::IterationGenerator
 {
 public:
-    NaiveGenerator(IterationFormula z0, IterationFormula zi, const mnd::Real& prec);
+    NaiveGenerator(IterationFormula z0, IterationFormula zi,
+            mnd::Precision prec,
+            mnd::CpuExtension ex = mnd::CpuExtension::NONE);
     NaiveGenerator(NaiveGenerator&&) = default;
 
     virtual void generate(const MandelInfo& info, float* data);
@@ -55,7 +59,7 @@ class mnd::NaiveIRGenerator : public mnd::MandelGenerator
 {
     const ir::Formula& form;
 public:
-    NaiveIRGenerator(const ir::Formula& irf, const mnd::Real& prec);
+    NaiveIRGenerator(const ir::Formula& irf, mnd::Precision prec);
     NaiveIRGenerator(NaiveIRGenerator&&) = default;
 
     virtual void generate(const MandelInfo& info, float* data);

+ 0 - 27
libmandel/include/JuliaGenerators.h

@@ -1,27 +0,0 @@
-#ifndef MANDEL_JULIAGENERATORS_H
-#define MANDEL_JULIAGENERATORS_H
-
-#include "Generators.h"
-
-
-
-namespace mnd
-{
-    class JuliaGeneratorFloat;
-}
-
-
-class mnd::JuliaGeneratorFloat : public JuliaGenerator
-{
-protected:
-    mnd::Real a;
-    mnd::Real b;
-public:
-    JuliaGeneratorFloat(const mnd::Real& precision);
-    virtual ~JuliaGeneratorFloat(void);
-
-    virtual void generate(const MandelInfo& info, float* data);
-};
-
-#endif // MANDEL_JULIAGENERATORS_H
-

+ 0 - 31
libmandel/include/Mandel.h

@@ -21,7 +21,6 @@ namespace asmjit { class JitRuntime; }
 
 namespace mnd
 {
-    enum class GeneratorType : int;
     class MandelContext;
     class MandelDevice;
 
@@ -34,33 +33,6 @@ namespace mnd
 }
 
 
-enum class mnd::GeneratorType : int
-{
-    FLOAT,
-    FLOAT_SSE2,
-    FLOAT_AVX,
-    FLOAT_AVX_FMA,
-    FLOAT_AVX512,
-    FLOAT_NEON,
-    DOUBLE_FLOAT,
-    DOUBLE,
-    DOUBLE_SSE2,
-    DOUBLE_AVX,
-    DOUBLE_AVX_FMA,
-    DOUBLE_AVX512,
-    DOUBLE_NEON,
-    DOUBLE_DOUBLE,
-    DOUBLE_DOUBLE_AVX,
-    DOUBLE_DOUBLE_AVX_FMA,
-    QUAD_DOUBLE,
-    FLOAT128,
-    FLOAT256,
-    FIXED64,
-    FIXED128,
-    FIXED512
-};
-
-
 class mnd::MandelDevice
 {
 private:
@@ -101,7 +73,6 @@ private:
     std::map<GeneratorType, std::unique_ptr<MandelGenerator>> cpuGenerators;
 
     std::unique_ptr<AdaptiveGenerator> adaptiveGenerator;
-    std::unique_ptr<JuliaGenerator> juliaGenerator;
 
     std::vector<MandelDevice> devices;
 
@@ -125,8 +96,6 @@ public:
     std::vector<GeneratorType> getSupportedTypes(void) const;
 
     const CpuInfo& getCpuInfo(void) const { return cpuInfo; }
-
-    JuliaGenerator& getJuliaGenerator(void);
 };
 
 

+ 9 - 9
libmandel/src/ClGenerators.cpp

@@ -61,8 +61,8 @@ Device getDevice(Platform& platform, int i, bool display = false) {
 }
 
 
-ClGenerator::ClGenerator(mnd::MandelDevice& device, const std::string& source, const mnd::Real& precision) :
-    MandelGenerator{ precision },
+ClGenerator::ClGenerator(mnd::MandelDevice& device, const std::string& source, mnd::Precision type) :
+    MandelGenerator{ type },
     device{ device },
     context{ device.getClDevice().context }
 {
@@ -106,7 +106,7 @@ ClGenerator::~ClGenerator(void)
 
 
 ClGeneratorFloat::ClGeneratorFloat(mnd::MandelDevice& device, const std::string& code) :
-    ClGenerator{ device, code, mnd::getPrecision<float>() }
+    ClGenerator{ device, code, mnd::Precision::FLOAT }
 {
     const cl::Device& dev = device.getClDevice().device;
     useVec = dev.getInfo<CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT>() >= 4;
@@ -152,7 +152,7 @@ std::string ClGeneratorFloat::getKernelCode(bool smooth) const
 
 
 ClGeneratorDoubleFloat::ClGeneratorDoubleFloat(mnd::MandelDevice& device) :
-    ClGenerator{ device, this->getKernelCode(false), mnd::getPrecision(mnd::Precision::DOUBLE_FLOAT)  }
+    ClGenerator{ device, this->getKernelCode(false), mnd::Precision::DOUBLE_FLOAT  }
 {
     kernel = Kernel(program, "iterate");
 }
@@ -303,7 +303,7 @@ std::string ClGeneratorDoubleFloat::getKernelCode(bool smooth) const
 
 
 ClGeneratorDouble::ClGeneratorDouble(mnd::MandelDevice& device, const std::string& source) :
-    ClGenerator{ device, source, mnd::getPrecision<double>() }
+    ClGenerator{ device, source, mnd::Precision::DOUBLE }
 {
     kernel = Kernel(program, "iterate");
 }
@@ -371,7 +371,7 @@ std::string ClGeneratorDouble::getKernelCode(bool smooth) const
 
 
 ClGeneratorDoubleDouble::ClGeneratorDoubleDouble(mnd::MandelDevice& device) :
-    ClGenerator{ device, getDoubleDouble_cl(), mnd::getPrecision<DoubleDouble>() }
+    ClGenerator{ device, getDoubleDouble_cl(), mnd::Precision::DOUBLE_DOUBLE }
 {
     kernel = Kernel(program, "iterate");
 }
@@ -414,7 +414,7 @@ std::string ClGeneratorDoubleDouble::getKernelCode(bool smooth) const
 
 
 ClGeneratorQuadDouble::ClGeneratorQuadDouble(mnd::MandelDevice& device) :
-    ClGenerator{ device, getQuadDouble_cl(), mnd::getPrecision<QuadDouble>() }
+    ClGenerator{ device, getQuadDouble_cl(), mnd::Precision::QUAD_DOUBLE }
 {
     kernel = Kernel(program, "iterate");
 }
@@ -466,7 +466,7 @@ std::string ClGeneratorQuadDouble::getKernelCode(bool smooth) const
 
 
 ClGenerator128::ClGenerator128(mnd::MandelDevice& device) :
-    ClGenerator{ device, getFixed512_cl(), mnd::getPrecision<Fixed128>() }
+    ClGenerator{ device, getFixed512_cl(), mnd::Precision::FIXED128 }
 {
     kernel = Kernel(program, "iterate");
 }
@@ -521,7 +521,7 @@ std::string ClGenerator128::getKernelCode(bool smooth) const
 
 
 ClGenerator64::ClGenerator64(mnd::MandelDevice& device) :
-    ClGenerator{ device, getFixed64_cl(), mnd::getPrecision<Fixed64>() }
+    ClGenerator{ device, getFixed64_cl(), mnd::Precision::FIXED64 }
 {
     kernel = Kernel(program, "iterate");
 }

+ 44 - 8
libmandel/src/Generators.cpp

@@ -3,9 +3,9 @@
 #include <cstdio>
 
 using mnd::MandelGenerator;
-using mnd::JuliaGenerator;
 using mnd::AdaptiveGenerator;
 
+
 MandelGenerator::~MandelGenerator(void)
 {
 }
@@ -17,14 +17,8 @@ mnd::Real MandelGenerator::getPrecision(void) const
 }
 
 
-
-JuliaGenerator::~JuliaGenerator(void)
-{
-}
-
-
 AdaptiveGenerator::AdaptiveGenerator(void) :
-    MandelGenerator{ 0.0 }
+    MandelGenerator{ mnd::Precision::INF_PREC }
 {
 }
 
@@ -115,6 +109,48 @@ namespace mnd
         return precs.at(p);
     }
 
+    Real getPrecision(GeneratorType t)
+    {
+        switch(t) {
+        case GeneratorType::FLOAT:
+        case GeneratorType::FLOAT_SSE2:
+        case GeneratorType::FLOAT_AVX:
+        case GeneratorType::FLOAT_AVX_FMA:
+        case GeneratorType::FLOAT_AVX512:
+        case GeneratorType::FLOAT_NEON:
+            return getPrecision<float>();
+        case GeneratorType::DOUBLE_FLOAT:
+            return getPrecision(Precision::DOUBLE_FLOAT);
+        case GeneratorType::DOUBLE:
+        case GeneratorType::DOUBLE_SSE2:
+        case GeneratorType::DOUBLE_AVX:
+        case GeneratorType::DOUBLE_AVX_FMA:
+        case GeneratorType::DOUBLE_AVX512:
+        case GeneratorType::DOUBLE_NEON:
+            return getPrecision<double>();
+        case GeneratorType::DOUBLE_DOUBLE:
+        case GeneratorType::DOUBLE_DOUBLE_AVX:
+        case GeneratorType::DOUBLE_DOUBLE_AVX_FMA:
+            return getPrecision<DoubleDouble>();
+        case GeneratorType::QUAD_DOUBLE:
+            return getPrecision<QuadDouble>();
+        case GeneratorType::FLOAT128:
+            return getPrecision<Float128>();
+        case GeneratorType::FLOAT256:
+            return getPrecision<Float256>();
+        case GeneratorType::FIXED64:
+            return getPrecision<Fixed64>();
+        case GeneratorType::FIXED128:
+            return getPrecision<Fixed128>();
+        case GeneratorType::FIXED512:
+            return getPrecision<Fixed512>();
+
+        case GeneratorType::UNSPECIFIED:
+        default:
+            return Real(0);
+        }
+    }
+
 
     template<>
     Real getPrecision<float>() {

+ 7 - 7
libmandel/src/IterationGenerator.cpp

@@ -23,8 +23,8 @@ namespace mnd
 
 
 IterationGenerator::IterationGenerator(IterationFormula z0, IterationFormula zi,
-                                   const mnd::Real& prec) :
-    mnd::MandelGenerator{ prec },
+            mnd::Precision prec, mnd::CpuExtension ex) :
+    mnd::MandelGenerator{ prec, ex },
     z0{ std::move(z0) },
     zi{ std::move(zi) }
 {
@@ -32,8 +32,8 @@ IterationGenerator::IterationGenerator(IterationFormula z0, IterationFormula zi,
 
 
 NaiveGenerator::NaiveGenerator(IterationFormula z0, IterationFormula zi,
-                                   const mnd::Real& prec) :
-    IterationGenerator{ std::move(z0), std::move(zi), prec }
+            mnd::Precision prec, mnd::CpuExtension ex) :
+    IterationGenerator{ std::move(z0), std::move(zi), prec, ex }
 {
     this->z0.optimize();
     this->zi.optimize();
@@ -136,7 +136,7 @@ std::complex<double> NaiveGenerator::calc(mnd::Expression& expr, std::complex<do
 
 template<typename T>
 NaiveIRGenerator<T>::NaiveIRGenerator(const mnd::ir::Formula& irf,
-                                   const mnd::Real& prec) :
+            mnd::Precision prec) :
     mnd::MandelGenerator{ prec },
     form{ irf }
 {
@@ -265,7 +265,7 @@ using mnd::CompiledClGeneratorDouble;
 
 
 CompiledGenerator::CompiledGenerator(std::unique_ptr<mnd::ExecData> execData) :
-    MandelGenerator{ 1.0e-15 },
+    MandelGenerator{ mnd::Precision::DOUBLE },
     execData{ std::move(execData) }
 {
 }
@@ -330,7 +330,7 @@ std::string CompiledGenerator::dump(void) const
 
 #ifdef WITH_OPENCL
 CompiledClGenerator::CompiledClGenerator(mnd::MandelDevice& device, const std::string& code) :
-    ClGeneratorFloat{ device, code }
+    ClGeneratorFloat{ device, code, mnd::Precision::FLOAT }
 {
 }
 

+ 0 - 118
libmandel/src/JuliaGenerators.cpp

@@ -1,118 +0,0 @@
-#include "Generators.h"
-#include "JuliaGenerators.h"
-
-#include <immintrin.h>
-#include <omp.h>
-
-mnd::JuliaGeneratorFloat::JuliaGeneratorFloat(const mnd::Real& precision) :
-    JuliaGenerator{ precision },
-    a{ a },
-    b{ b }
-{
-}
-
-
-mnd::JuliaGeneratorFloat::~JuliaGeneratorFloat(void)
-{
-}
-
-
-void mnd::JuliaGeneratorFloat::generate(const MandelInfo& info, float * data)
-{
-    const MandelViewport& view = info.view;
-
-    using T = double;
-
-
-    const float dppf = float(view.width / info.bWidth);
-    const float viewxf = float(view.x);
-    __m256 viewx = _mm256_set1_ps(viewxf);
-    __m256 dpp = _mm256_set1_ps(dppf);
-
-
-    T juliaa = mnd::convert<T>(info.juliaX);
-    T juliab = mnd::convert<T>(info.juliaY);
-    __m256 constA = _mm256_set1_ps(juliaa);
-    __m256 constB = _mm256_set1_ps(juliab);
-
-    omp_set_num_threads(omp_get_num_procs());
-#pragma omp parallel for schedule(static, 1)
-    for (long j = 0; j < info.bHeight; j++) {
-        T y = T(view.y) + T(j) * T(view.height / info.bHeight);
-        __m256 ys = _mm256_set1_ps(y);
-        long i = 0;
-        for (i; i < info.bWidth; i += 8) {
-            __m256 pixc = { float(i), float(i + 1), float(i + 2), float(i + 3), float(i + 4), float(i + 5), float(i + 6), float(i + 7) };
-
-            __m256 xs = _mm256_add_ps(_mm256_mul_ps(dpp, pixc), viewx);
-
-            __m256 counter = _mm256_setzero_ps();
-            __m256 adder = _mm256_set1_ps(1.0f);
-            __m256 resultsa = _mm256_setzero_ps();
-            __m256 resultsb = _mm256_setzero_ps();
-
-            __m256 threshold = _mm256_set1_ps(16.0f);
-
-            __m256 a = xs;
-            __m256 b = ys;
-            if (info.smooth) {
-                for (int k = 0; k < info.maxIter; k++) {
-                    __m256 aa = _mm256_mul_ps(a, a);
-                    __m256 bb = _mm256_mul_ps(b, b);
-                    __m256 abab = _mm256_mul_ps(a, b); abab = _mm256_add_ps(abab, abab);
-                    a = _mm256_add_ps(_mm256_sub_ps(aa, bb), constA);
-                    b = _mm256_add_ps(abab, constB);
-                    __m256 cmp = _mm256_cmp_ps(_mm256_add_ps(aa, bb), threshold, _CMP_LE_OQ);
-                    resultsa = _mm256_or_ps(_mm256_andnot_ps(cmp, resultsa), _mm256_and_ps(cmp, a));
-                    resultsb = _mm256_or_ps(_mm256_andnot_ps(cmp, resultsb), _mm256_and_ps(cmp, b));
-                    adder = _mm256_and_ps(adder, cmp);
-                    counter = _mm256_add_ps(counter, adder);
-                    if ((k & 0x7) == 0 && _mm256_testz_ps(cmp, cmp) != 0) {
-                        break;
-                    }
-                }
-            }
-            else {
-                for (int k = 0; k < info.maxIter; k++) {
-                    __m256 aa = _mm256_mul_ps(a, a);
-                    __m256 bb = _mm256_mul_ps(b, b);
-                    __m256 abab = _mm256_mul_ps(a, b); abab = _mm256_add_ps(abab, abab);
-                    a = _mm256_add_ps(_mm256_sub_ps(aa, bb), constA);
-                    b = _mm256_add_ps(abab, constB);
-                    __m256 cmp = _mm256_cmp_ps(_mm256_add_ps(aa, bb), threshold, _CMP_LE_OQ);
-                    adder = _mm256_and_ps(adder, cmp);
-                    counter = _mm256_add_ps(counter, adder);
-                    if ((k & 0x7) == 0 && _mm256_testz_ps(cmp, cmp) != 0) {
-                        break;
-                    }
-                }
-            }
-
-
-            auto alignVec = [](float* data) -> float* {
-                void* aligned = data;
-                ::size_t length = 64;
-                std::align(32, 8 * sizeof(float), aligned, length);
-                return static_cast<float*>(aligned);
-            };
-
-            float resData[16];
-            float* ftRes = alignVec(resData);
-            float* resa = (float*) &resultsa;
-            float* resb = (float*) &resultsb;
-
-            _mm256_store_ps(ftRes, counter);
-            for (int k = 0; k < 8 && i + k < info.bWidth; k++) {
-                if (info.smooth) {
-                    data[i + k + j * info.bWidth] = ftRes[k] <= 0 ? info.maxIter :
-                        ftRes[k] >= info.maxIter ? info.maxIter :
-                        ((float)ftRes[k]) + 1 - ::log(::log(resa[k] * resa[k] + resb[k] * resb[k]) / 2) / ::log(2.0f);
-                }
-                else {
-                    data[i + k + j * info.bWidth] = ftRes[k] <= 0 ? info.maxIter : ftRes[k];
-                }
-            }
-        }
-    }
-}
-

+ 0 - 8
libmandel/src/Mandel.cpp

@@ -2,7 +2,6 @@
 #include "Fixed.h"
 
 #include "CpuGenerators.h"
-#include "JuliaGenerators.h"
 #include "ClGenerators.h"
 #include "OpenClInternal.h"
 #include "OpenClCode.h"
@@ -357,10 +356,3 @@ std::vector<mnd::GeneratorType> MandelContext::getSupportedTypes(void) const
 }
 
 
-mnd::JuliaGenerator& MandelContext::getJuliaGenerator()
-{
-    juliaGenerator = std::make_unique<JuliaGeneratorFloat>(getPrecision<double>());
-    return *juliaGenerator;
-}
-
-