ソースを参照

trying to remove avx instructions from build

Nicolas Winkler 5 年 前
コミット
b792d05474
3 ファイル変更27 行追加6 行削除
  1. 16 0
      libmandel/include/Types.h
  2. 10 5
      libmandel/src/CpuGeneratorsAVX.cpp
  3. 1 1
      libmandel/src/Types.cpp

+ 16 - 0
libmandel/include/Types.h

@@ -22,6 +22,8 @@
 #include <qd/dd_real.h>
 #include <qd/qd_real.h>
 
+#include "LightDoubleDouble.h"
+
 namespace mnd
 {
 
@@ -120,12 +122,26 @@ namespace mnd
     }
 
     template<>
+    inline LightDoubleDouble convert<LightDoubleDouble, Real>(const Real& x)
+    {
+        double upper = static_cast<double>(x);
+        double lower = static_cast<double>(x - upper);
+        return { upper, lower };
+    }
+
+    template<>
     inline float convert<float, DoubleDouble>(const DoubleDouble& x)
     {
         return float(x.x[0] + x.x[1]);
     }
 
     template<>
+    inline float convert<float, LightDoubleDouble>(const LightDoubleDouble& x)
+    {
+        return float(x[0] + x[1]);
+    }
+
+    template<>
     inline QuadDouble convert<QuadDouble, Real>(const Real& x)
     {
         std::string s = x.str();

+ 10 - 5
libmandel/src/CpuGeneratorsAVX.cpp

@@ -1,4 +1,5 @@
 #include "CpuGenerators.h"
+#include "LightDoubleDouble.h"
 
 #include <immintrin.h>
 #include <omp.h>
@@ -379,6 +380,10 @@ struct AvxDoubleDouble
         x{ a, b }
     {}
 
+    inline AvxDoubleDouble(double a, double b) :
+        x{ _mm256_set1_pd(a), _mm256_set1_pd(b) }
+    {}
+
 
     inline AvxDoubleDouble operator + (const AvxDoubleDouble& sm) const
     {
@@ -412,7 +417,7 @@ void CpuGenerator<mnd::DoubleDouble, mnd::X86_AVX, parallel>::generate(const mnd
 {
     const MandelViewport& view = info.view;
 
-    using T = DoubleDouble;
+    using T = LightDoubleDouble;
 
     T viewx = mnd::convert<T>(view.x);
     T viewy = mnd::convert<T>(view.y);
@@ -422,8 +427,8 @@ void CpuGenerator<mnd::DoubleDouble, mnd::X86_AVX, parallel>::generate(const mnd
 
     T jX = mnd::convert<T>(info.juliaX);
     T jY = mnd::convert<T>(info.juliaY);
-    AvxDoubleDouble juliaX = { __m256d{ jX.x[0], jX.x[0], jX.x[0], jX.x[0] }, __m256d{ jX.x[1], jX.x[1], jX.x[1], jX.x[1] } };
-    AvxDoubleDouble juliaY = { __m256d{ jY.x[0], jY.x[0], jY.x[0], jY.x[0] }, __m256d{ jY.x[1], jY.x[1], jY.x[1], jY.x[1] } };
+    AvxDoubleDouble juliaX = { jX[0], jX[1] };
+    AvxDoubleDouble juliaY = { jY[0], jY[1] };
 
     if constexpr(parallel)
         omp_set_num_threads(omp_get_num_procs());
@@ -440,11 +445,11 @@ void CpuGenerator<mnd::DoubleDouble, mnd::X86_AVX, parallel>::generate(const mnd
             T x4 = x3 + wpp;
 
             __m256d x0s = {
-                x1.x[0], x2.x[0], x3.x[0], x4.x[0],
+                x1[0], x2[0], x3[0], x4[0],
             };
 
             __m256d x1s = {
-                x1.x[1], x2.x[1], x3.x[1], x4.x[1],
+                x1[1], x2[1], x3[1], x4[1],
             };
 
             AvxDoubleDouble xs{ x0s, x1s };

+ 1 - 1
libmandel/src/Types.cpp

@@ -15,7 +15,7 @@ namespace mnd
         if (num == Real(0.0)) {
             return "0";
         }
-        int exponent = std::floor(static_cast<float>(mnd::log(num)) / ::logf(10.000001));
+        int exponent = int(std::floor(static_cast<float>(mnd::log(num)) / ::logf(10.000001f)));
         float fac = static_cast<float>(num / mnd::pow(Real(10), Real(exponent)));
         std::stringstream ss;
         ss.precision(3);