Pārlūkot izejas kodu

currently doesn't work

Nicolas Winkler 5 gadi atpakaļ
vecāks
revīzija
6eacb14a0d

+ 1 - 1
benchmarkdialog.cpp

@@ -106,7 +106,7 @@ void Benchmarker::start(void)
     mnd::Generator& cpuf = mndContext.getCpuGeneratorFloat();
     mnd::Generator& cpud = mndContext.getCpuGeneratorDouble();
     mnd::Generator* cpu128 = mndContext.getCpuGeneratorQuad();
-    mnd::Generator* cpu256 = mndContext.getCpuGeneratorOct();
+    mnd::Generator* cpu256 = mndContext.getCpuGenerator128();
 
     double nTests = 2;
 

+ 10 - 7
gradients/default.xml

@@ -3,13 +3,16 @@
     <color r="125" g="50" b="15" p="15" />
     <color r="250" g="70" b="24" p="30" />
     <color r="200" g="230" b="30" p="60" />
-    <color r="70" g="223" b="30" p="95" />
-    <color r="40" g="190" b="240" p="130" />
-    <color r="120" g="60" b="160" p="190" />
+    <color r="15" g="130" b="15" p="95" />
+    <color r="80" g="60" b="0" p="130" />
+    <color r="140" g="40" b="15" p="160" />
+    <color r="190" g="110" b="30" p="190" />
+    <color r="120" g="60" b="160" p="220" />
     <color r="14" g="20" b="180" p="250" />
     <color r="240" g="240" b="240" p="320" />
-    <color r="243" g="20" b="20" p="400" />
-    <color r="254" g="169" b="63" p="500" />
-    <color r="8" g="50" b="8" p="600" />
-    <color r="0" g="0" b="0" p="700" />
+    <color r="243" g="20" b="20" p="390" />
+    <color r="254" g="169" b="63" p="420" />
+    <color r="8" g="50" b="8" p="480" />
+    <color r="130" g="130" b="50" p="520" />
+    <color r="0" g="0" b="0" p="550" />
 </gradient>

+ 11 - 0
libmandel/CMakeLists.txt

@@ -26,6 +26,7 @@ find_library(MPFR_LIBRARIES mpfr PATHS $ENV{MPFR_DIR} ${LIB_INSTALL_DIR})
 
 set(CMAKE_CXX_STANDARD 17)
 
+
 #FILE(GLOB MandelSources src/*.cpp)
 SET(MandelSources
     src/ClGenerators.cpp
@@ -47,6 +48,16 @@ endif()
 
 add_library(mandel STATIC ${MandelSources})
 
+
+include(CheckIPOSupported)
+check_ipo_supported(RESULT LTO_SUPPORTED)
+
+if (LTO_SUPPORTED)
+    message("enable link-time optimization")
+    set_property(TARGET mandel PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
+endif(LTO_SUPPORTED)
+
+
 if(MPFR_INCLUDES AND MPFR_LIBRARIES)
     set(MPFR_FOUND TRUE)
     #target_compile_definitions(mandel PUBLIC WITH_MPFR)

+ 7 - 0
libmandel/include/CpuGenerators.h

@@ -94,6 +94,13 @@ public:
 };
 #endif
 
+template<bool parallel, bool smooth>
+class mnd::CpuGenerator<Fixed128, mnd::NONE, parallel, smooth> : public Generator
+{
+public:
+    virtual void generate(const MandelInfo& info, float* data);
+};
+
 /*
 class mnd::CpuGeneratorFloat : public Generator
 {

+ 3 - 5
libmandel/include/Mandel.h

@@ -62,14 +62,12 @@ private:
     std::unique_ptr<Generator> cpuGeneratorDouble;
     std::unique_ptr<Generator> cpuGeneratorQuad;
     std::unique_ptr<Generator> cpuGeneratorOct;
-    //std::unique_ptr<Generator> cpuGenerator128;
-    //std::unique_ptr<Generator> cpuGeneratorFixedp;
+    std::unique_ptr<Generator> cpuGenerator128;
 
     std::unique_ptr<Generator> cpuGeneratorFloatSmooth;
     std::unique_ptr<Generator> cpuGeneratorDoubleSmooth;
     std::unique_ptr<Generator> cpuGeneratorQuadSmooth;
-    //std::unique_ptr<Generator> cpuGenerator128Smooth;
-    //std::unique_ptr<Generator> cpuGeneratorFixedpSmooth;
+    std::unique_ptr<Generator> cpuGenerator128Smooth;
 
     std::unique_ptr<Generator> adaptiveGenerator;
     std::unique_ptr<Generator> adaptiveGeneratorSmooth;
@@ -88,7 +86,7 @@ public:
     Generator& getCpuGeneratorDouble(void); 
     Generator* getCpuGeneratorQuad(void); 
     Generator* getCpuGeneratorOct(void); 
-    //Generator& getCpuGenerator128(void); 
+    Generator* getCpuGenerator128(void); 
 
     const CpuInfo& getCpuInfo(void) const { return cpuInfo; }
 };

+ 2 - 0
libmandel/include/Types.h

@@ -3,6 +3,8 @@
 
 #include <cinttypes>
 #include <cmath>
+#include "Fixed.h"
+
 #ifdef WITH_BOOST
 #   include <boost/multiprecision/cpp_bin_float.hpp>
 #   if defined(__GNUC__) || defined(__INTEL_COMPILER)

+ 54 - 2
libmandel/src/CpuGenerators.cpp

@@ -24,12 +24,12 @@ namespace mnd
     template class CpuGenerator<double, mnd::NONE, true, false>;
     template class CpuGenerator<double, mnd::NONE, true, true>;
 
-    /*
+    
     template class CpuGenerator<Fixed128, mnd::NONE, false, false>;
     template class CpuGenerator<Fixed128, mnd::NONE, false, true>;
     template class CpuGenerator<Fixed128, mnd::NONE, true, false>;
     template class CpuGenerator<Fixed128, mnd::NONE, true, true>;
-    */
+    
 
 #ifdef WITH_BOOST
 #include <boost/multiprecision/cpp_bin_float.hpp>
@@ -87,6 +87,58 @@ void CpuGenerator<T, mnd::NONE, parallel, smooth>::generate(const mnd::MandelInf
 }
 
 
+#if defined(WITH_BOOST) || 1
+template<bool parallel, bool smooth>
+void CpuGenerator<Fixed128, mnd::NONE, parallel, smooth>::generate(const mnd::MandelInfo& info, float* data)
+{
+    using T = Fixed128;
+    const MandelViewport& view = info.view;
+
+    const auto fixedFromFloat = [] (const mnd::Float128& f) {
+        boost::multiprecision::int128_t frac = boost::multiprecision::int128_t(f * 4294967296.0 * 4294967296.0 * 4294967296.0);
+        std::vector<uint32_t> bits;
+        export_bits(frac, std::back_inserter(bits), 32);
+        bits.clear();
+        while (bits.size() < 4) bits.push_back(0);
+        return Fixed128{ bits[0], bits[1], bits[2], bits[3] };
+    };
+
+    if constexpr (parallel)
+        omp_set_num_threads(2 * omp_get_num_procs());
+#pragma omp parallel for if (parallel)
+    for (long j = 0; j < info.bHeight; j++) {
+        T y = fixedFromFloat(view.y + mnd::Real(j) * view.height / info.bHeight);
+        long i = 0;
+        for (i; i < info.bWidth; i++) {
+            T x = fixedFromFloat(view.x + mnd::Real(i) * view.width / info.bWidth);
+
+            T a = x;
+            T b = y;
+
+            int k = 0;
+            for (k = 0; k < info.maxIter; k++) {
+                T aa = a * a;
+                T bb = b * b;
+                T ab = a * b;
+                a = aa - bb + x;
+                b = ab + ab + y;
+                if (aa + bb > T(16)) {
+                    break;
+                }
+            }
+            if constexpr (smooth) {
+                if (k >= info.maxIter)
+                    data[i + j * info.bWidth] = info.maxIter;
+                else
+                    data[i + j * info.bWidth] = ((float) k) + 1 - ::logf(::logf(float(a * a + b * b)) / 2) / ::logf(2.0f);
+            }
+            else
+                data[i + j * info.bWidth] = k;
+        }
+    }
+}
+#endif // WITH_BOOST
+
 #ifdef WITH_MPFR
 template<unsigned int bits, bool parallel, bool smooth>
 void CpuGenerator<mnd::MpfrFloat<bits>, mnd::NONE, parallel, smooth>::generate(const mnd::MandelInfo& info, float* data)

+ 2 - 2
libmandel/src/Generators.cpp

@@ -19,8 +19,8 @@ AdaptiveGenerator::AdaptiveGenerator(Generator* floatGen, Generator* doubleGen)
 
 AdaptiveGenerator::AdaptiveGenerator(Generator* floatGen, Generator* doubleGen, Generator* quadGen)
 {
-    generators.push_back({ 0.0000001, floatGen });
-    generators.push_back({ 5.0e-16, doubleGen });
+    //generators.push_back({ 0.0000001, floatGen });
+    //generators.push_back({ 5.0e-16, doubleGen });
     generators.push_back({ 0.0, quadGen });
 }
 

+ 10 - 3
libmandel/src/Mandel.cpp

@@ -101,7 +101,6 @@ MandelContext::MandelContext(void) :
         cpuGeneratorDoubleSmooth = std::make_unique<CpuGenerator<double, mnd::NONE, true, true>>();
     }
 
-    //cpuGenerator128 = std::make_unique<CpuGenerator<Fixed128, mnd::NONE, true, false>>();
     //cpuGenerator128Smooth = std::make_unique<CpuGenerator<Fixed128>>();
     //cpuGeneratorFixedp = std::make_unique<CpuGenerator<fixed<1, 3>>>();
 
@@ -109,6 +108,8 @@ MandelContext::MandelContext(void) :
     cpuGeneratorQuad = std::make_unique<CpuGenerator<Float128, mnd::NONE, true, false>>();
     cpuGeneratorQuadSmooth = std::make_unique<CpuGenerator<Float128, mnd::NONE, true, true>>();
     cpuGeneratorOct = std::make_unique<CpuGenerator<Float256, mnd::NONE, true, false>>();
+    cpuGenerator128 = std::make_unique<CpuGenerator<Fixed128, mnd::NONE, true, false>>();
+    cpuGenerator128Smooth = std::make_unique<CpuGenerator<Fixed128, mnd::NONE, true, true>>();
 #endif // WITH_BOOST
 
     devices = createDevices();
@@ -141,8 +142,8 @@ MandelContext::MandelContext(void) :
         if (doubleGeneratorSmooth == nullptr)
             doubleGeneratorSmooth = cpuGeneratorDoubleSmooth.get();
 #ifdef WITH_BOOST
-        adaptiveGeneratorSmooth = std::make_unique<AdaptiveGenerator>(floatGeneratorSmooth, doubleGeneratorSmooth, cpuGeneratorQuadSmooth.get());
-        adaptiveGenerator = std::make_unique<AdaptiveGenerator>(floatGenerator, doubleGenerator, cpuGeneratorQuad.get());
+        adaptiveGeneratorSmooth = std::make_unique<AdaptiveGenerator>(floatGeneratorSmooth, doubleGeneratorSmooth, cpuGenerator128Smooth.get());
+        adaptiveGenerator = std::make_unique<AdaptiveGenerator>(floatGenerator, doubleGenerator, cpuGenerator128.get());
 #else
         adaptiveGeneratorSmooth = std::make_unique<AdaptiveGenerator>(floatGeneratorSmooth, doubleGeneratorSmooth);
         adaptiveGenerator = std::make_unique<AdaptiveGenerator>(floatGenerator, doubleGenerator);
@@ -260,3 +261,9 @@ Generator* MandelContext::getCpuGeneratorOct(void)
 {
     return cpuGeneratorOct.get();
 }
+
+
+Generator* MandelContext::getCpuGenerator128(void)
+{
+    return cpuGenerator128.get();
+}