1
0
Nicolas Winkler 5 gadi atpakaļ
vecāks
revīzija
703bc9a95e

+ 0 - 11
Almond.cpp

@@ -12,17 +12,6 @@ Almond::Almond(QWidget* parent) :
     mandelContext{ mnd::initializeContext() }
 {
     ui.setupUi(this);
-
-    /*mnd::IterationFormula form;
-    try {
-        form = mnd::IterationFormula{
-            std::make_unique<mnd::Expression>(mnd::parse("z*z*z + c*z + c"))
-        };
-    }
-    catch (mnd::ParseError& pe) {
-        printf("parse error: %s\n", pe.what());
-    }*/
-
     mw = std::make_unique<MandelWidget>(mandelContext,
                                         &mandelContext.getDefaultGenerator(),
                                         ui.centralWidget);

+ 10 - 5
choosegenerators.cpp

@@ -13,7 +13,8 @@
 
 mnd::MandelViewport Benchmarker::benchViewport(void)
 {
-    return mnd::MandelViewport{ -1.250000598933854152929, 0.0001879894057291665530, 0.0000003839916666666565, 0.0000003839916666666565 };
+    //return mnd::MandelViewport{ -1.250000598933854152929, 0.0001879894057291665530, 0.0000003839916666666565, 0.0000003839916666666565 };
+    return mnd::MandelViewport::centerView();
 }
 
 
@@ -309,18 +310,22 @@ void ChooseGenerators::on_compile_clicked()
     //zi.optimize();
     //z0.optimize();
 
-    const mnd::MandelDevice& dev = mndCtxt.getDevices()[0];
+    mnd::MandelDevice& dev = mndCtxt.getDevices()[0];
     //auto cls = mnd::compileOpenCl(dev, z0, itf);
     std::vector<std::unique_ptr<mnd::MandelGenerator>> cpuGenerators;
     try {
-        std::cout << mnd::toString(*z0.expr) << std::endl;
-        std::cout << mnd::toString(*zi.expr) << std::endl;
-        cpuGenerators = mnd::compileCpu(mndCtxt, z0, zi);
+        //std::cout << mnd::toString(*z0.expr) << std::endl;
+        //std::cout << mnd::toString(*zi.expr) << std::endl;
+        cpuGenerators = mnd::compileOpenCl(dev, z0, zi);
     }
     catch(const mnd::ParseError& pe) {
         printf("Parse error: %s\n", pe.what());
         return;
     }
+    catch(const std::string& e) {
+        printf("error: %s\n", e.c_str());
+        return;
+    }
     /*catch(const char* e) {
         printf("error: %s\n", e);
         return;

+ 1 - 1
libmandel/include/Mandel.h

@@ -117,7 +117,7 @@ public:
     MandelContext& operator=(MandelContext&&) = default;
 
     AdaptiveGenerator& getDefaultGenerator(void);
-    const std::vector<MandelDevice>& getDevices(void);
+    std::vector<MandelDevice>& getDevices(void);
 
     asmjit::JitRuntime& getJitRuntime(void);
 

+ 2 - 1
libmandel/src/ClGenerators.cpp

@@ -66,13 +66,14 @@ ClGenerator::ClGenerator(mnd::MandelDevice& device, const std::string& source, c
     device{ device },
     context{ device.getClDevice().context }
 {
-    Program::Sources sources;
     const cl::Device& dev = device.getClDevice().device;
 
+    Program::Sources sources;
     sources.push_back({ source.c_str(), source.length() });
 
     program = Program{ context, sources };
     if (program.build({ dev }) != CL_SUCCESS) {
+        printf("code -> %s\n", source.c_str());
         throw std::string(program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(dev));
     }
 

+ 7 - 2
libmandel/src/IterationCompiler.cpp

@@ -313,7 +313,7 @@ namespace mnd
         }
 
         std::string operator()(const ir::Constant& c) {
-            return std::to_string(mnd::convert<double>(c.value));
+            return std::to_string(mnd::convert<double>(c.value)) + "f";
         }
 
         std::string operator()(const ir::Variable& v) {
@@ -456,7 +456,12 @@ namespace mnd
         const IterationFormula& z0,
         const IterationFormula& zi)
     {
-        ir::Formula irf = mnd::expand(z0, zi);
+        IterationFormula z0o = z0.clone();
+        IterationFormula zio = zi.clone();
+        z0o.optimize();
+        zio.optimize();
+
+        ir::Formula irf = mnd::expand(z0o, zio);
         irf.optimize();
         printf("ir: %s\n", irf.toString().c_str()); fflush(stdout);
         auto fl = compileCl(irf, dev);

+ 2 - 2
libmandel/src/Mandel.cpp

@@ -270,7 +270,7 @@ std::vector<MandelDevice> MandelContext::createDevices(void)
             auto supportsDouble = extensions.find("cl_khr_fp64") != std::string::npos;
 
             //printf("Device extensions: %s\n", ext.c_str());
-            MandelDevice md{ ClDeviceWrapper{ device } };
+            MandelDevice md{ ClDeviceWrapper{ device, cl::Context{ device } } };
 
             //printf("clock: %d", device.getInfo<CL_DEVICE_MAX_CLOCK_FREQUENCY>());
 
@@ -325,7 +325,7 @@ AdaptiveGenerator& MandelContext::getDefaultGenerator(void)
 }
 
 
-const std::vector<MandelDevice>& MandelContext::getDevices(void)
+std::vector<MandelDevice>& MandelContext::getDevices(void)
 {
     return devices;
 }