Browse Source

made compatible to linux

Nicolas Winkler 6 năm trước cách đây
mục cha
commit
ef339a1923
6 tập tin đã thay đổi với 23 bổ sung16 xóa
  1. 8 4
      Almond.pro
  2. 1 0
      Fixed.h
  3. 5 4
      Generators.h
  4. 3 3
      MandelWidget.cpp
  5. 1 0
      QueueManager.cpp
  6. 5 5
      benchmarkdialog.cpp

+ 8 - 4
Almond.pro

@@ -23,6 +23,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
 
 CONFIG += c++17
+@CONFIG += debug_and_release@
 
 SOURCES += \
         Almond.cpp \
@@ -59,12 +60,15 @@ qnx: target.path = /tmp/$${TARGET}/bin
 else: unix:!android: target.path = /opt/$${TARGET}/bin
 !isEmpty(target.path): INSTALLS += target
 
-LIBS += -lopengl32
+win32:LIBS += -lopengl32
+else:LIBS += -lOpenGL
+
 win32:QMAKE_CXXFLAGS+= -openmp
 else:unix:QMAKE_CXXFLAGS+= -fopenmp
 win32:QMAKE_LFLAGS +=  -openmp
 else:unix:QMAKE_LFLAGS+= -fopenmp
 LIBS += -fopenmp
+LIBS += -lm
 
 QMAKE_CXXFLAGS += -mavx
 
@@ -78,10 +82,10 @@ DEPENDPATH += $$PWD/../libs/ffmpeg-4.1.1-win32-dev/include
 
 win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../../Program Files (x86)/AMD APP SDK/3.0/lib/x86/' -lOpenCL
 else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../../../Program Files (x86)/AMD APP SDK/3.0/lib/x86/' -lOpenCL
-else:unix: LIBS += -L$$PWD/'../../../../../Program Files (x86)/AMD APP SDK/3.0/lib/x86/' -lOpenCL
+else:unix: LIBS += -lOpenCL
 
-INCLUDEPATH += $$PWD/'../../../../../Program Files (x86)/AMD APP SDK/3.0/include'
-DEPENDPATH += $$PWD/'../../../../../Program Files (x86)/AMD APP SDK/3.0/include'
+win32:INCLUDEPATH += $$PWD/'../../../../../Program Files (x86)/AMD APP SDK/3.0/include'
+win32:DEPENDPATH += $$PWD/'../../../../../Program Files (x86)/AMD APP SDK/3.0/include'
 
 win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../libs/ffmpeg-4.1.1-win32-dev/lib/ -lavformat
 else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../libs/ffmpeg-4.1.1-win32-dev/lib/ -lavformat

+ 1 - 0
Fixed.h

@@ -1,6 +1,7 @@
 #pragma once
 
 #include <cinttypes>
+#include <cmath>
 
 struct Fixed128
 {

+ 5 - 4
Generators.h

@@ -5,6 +5,7 @@
 #include "QueueManager.h"
 #include "GenericMandelbrot.h"
 #include <omp.h>
+#include <cmath>
 #include <future>
 #include <cstdlib>
 
@@ -62,7 +63,7 @@ public:
 
 
 template<>
-Bitmap<float> CpuGenerator<double>::generateRaw(const MandelInfo& info)
+inline Bitmap<float> CpuGenerator<double>::generateRaw(const MandelInfo& info)
 {
     using T = double;
     const MandelViewport& view = info.view;
@@ -106,7 +107,7 @@ Bitmap<float> CpuGenerator<double>::generateRaw(const MandelInfo& info)
             }
             double data[8];
             void* aligned = data;
-            unsigned int length = sizeof data;
+            ::size_t length = sizeof data;
             std::align(32, 4 * sizeof(double), aligned, length);
             double* ftRes = static_cast<double*>(aligned);
             _mm256_store_pd(ftRes, counter);
@@ -120,7 +121,7 @@ Bitmap<float> CpuGenerator<double>::generateRaw(const MandelInfo& info)
 
 
 template<>
-Bitmap<float> CpuGenerator<float>::generateRaw(const MandelInfo& info)
+inline Bitmap<float> CpuGenerator<float>::generateRaw(const MandelInfo& info)
 {
     using T = float;
     const MandelViewport& view = info.view;
@@ -167,7 +168,7 @@ Bitmap<float> CpuGenerator<float>::generateRaw(const MandelInfo& info)
             }
             float data[16];
             void* aligned = data;
-            unsigned int length = sizeof data;
+            ::size_t length = sizeof data;
             std::align(32, 8 * sizeof(float), aligned, length);
             float* ftRes = static_cast<float*>(aligned);
             _mm256_store_ps(ftRes, counter);

+ 3 - 3
MandelWidget.cpp

@@ -106,10 +106,10 @@ void MandelWidget::paintGL(void)
     mi.bHeight = height; //ql.geometry().height();
     mi.maxIter = 5000;
     mi.view = viewport;
-    auto bitmap = mg.generate(mi);
-    /*Bitmap<RGBColor> bitmap(1000, 1000);
+    //auto bitmap = mg.generate(mi);
+    Bitmap<RGBColor> bitmap(1000, 1000);
     for (int i = 0; i < 1000 * 1000; i++)
-        bitmap.pixels[i] = RGBColor{5, uint8_t((i % 1000) ^ (i / 1000)), 50};*/
+        bitmap.pixels[i] = RGBColor{5, uint8_t((i % 1000) ^ (i / 1000)), 50};
     tex = std::make_unique<Texture>(bitmap);
 
     glViewport(0, 0, width, height);

+ 1 - 0
QueueManager.cpp

@@ -1,4 +1,5 @@
 #include "QueueManager.h"
+#include <cmath>
 
 void MandelViewport::adjustAspectRatio(double nwidth, double nheight)
 {

+ 5 - 5
benchmarkdialog.cpp

@@ -15,9 +15,9 @@ MandelViewport BenchmarkDialog::benchViewport(void) const
 double BenchmarkDialog::measureMips(const std::function<Bitmap<float>()>& bench) const
 {
     using namespace std::chrono;
-    time_point before = high_resolution_clock::now();
+    auto before = high_resolution_clock::now();
     auto bitmap = bench();
-    time_point after = high_resolution_clock::now();
+    auto after = high_resolution_clock::now();
 
     long long sum = 0;
     for (int i = 0; i < bitmap.width * bitmap.height; i++) {
@@ -49,7 +49,7 @@ void BenchmarkDialog::on_run_clicked()
     CpuGenerator<float> cpgf;
     ClGenerator clg;
 
-    ui.tableWidget->setItem(1, 0, new QTableWidgetItem(benchmarkResult(cpg, 2500, 5000)));
-    ui.tableWidget->setItem(0, 0, new QTableWidgetItem(benchmarkResult(cpgf, 2500, 5000)));
-    ui.tableWidget->setItem(0, 1, new QTableWidgetItem(benchmarkResult(clg, 4000, 8000)));
+    ui.tableWidget->setItem(1, 0, new QTableWidgetItem(benchmarkResult(cpg, 1000, 5000)));
+    ui.tableWidget->setItem(0, 0, new QTableWidgetItem(benchmarkResult(cpgf, 1000, 5000)));
+    ui.tableWidget->setItem(0, 1, new QTableWidgetItem(benchmarkResult(clg, 2000, 8000)));
 }