فهرست منبع

starting caching

Nicolas Winkler 4 سال پیش
والد
کامیت
10eecba916
4فایلهای تغییر یافته به همراه43 افزوده شده و 2 حذف شده
  1. 5 0
      libmandel/include/ClGenerators.h
  2. 10 2
      libmandel/include/Mandel.h
  3. 6 0
      libmandel/src/ClGenerators.cpp
  4. 22 0
      libmandel/src/Mandel.cpp

+ 5 - 0
libmandel/include/ClGenerators.h

@@ -6,6 +6,9 @@
 #include "Generators.h"
 #include "OpenClCode.h"
 
+#include <optional>
+#include <vector>
+
 #ifdef __APPLE__
 #define CL_TARGET_OPENCL_VERSION 120
 #define CL_HPP_TARGET_OPENCL_VERSION 120
@@ -59,6 +62,8 @@ public:
 
     virtual void generate(const MandelInfo& info, float* data) = 0;
     virtual mnd::MandelDevice* getDevice(void);
+
+    virtual std::optional<std::vector<char>> getBinary(void);
 };
 
 

+ 10 - 2
libmandel/include/Mandel.h

@@ -22,8 +22,6 @@ namespace asmjit { class JitRuntime{}; }
 #include "CpuGenerators.h"
 #include "Hardware.h"
 
-//#include "Fixedp.h"
-
 namespace mnd
 {
     class MandelContext;
@@ -32,6 +30,8 @@ namespace mnd
     struct ClDeviceWrapper;
 
     extern MandelContext initializeContext(void);
+
+    struct MandelContextCache;
 }
 
 
@@ -104,6 +104,14 @@ public:
     std::vector<MandelGenerator*> getCpuGenerators(mnd::Precision prec) const;
 
     const CpuInfo& getCpuInfo(void) const { return cpuInfo; }
+
+    void saveCache(const std::string& path) const;
+    static MandelContext initializeFromCache(const std::string& path);
+};
+
+
+struct mnd::MandelContextCache
+{
 };
 
 

+ 6 - 0
libmandel/src/ClGenerators.cpp

@@ -143,6 +143,12 @@ mnd::MandelDevice* ClGenerator::getDevice(void)
 }
 
 
+std::optional<std::vector<char>> ClGenerator::getBinary(void)
+{
+    return std::nullopt;
+}
+
+
 ClGeneratorFloat::ClGeneratorFloat(mnd::MandelDevice& device, const std::string& code) :
     ClGenerator{ device, code, mnd::Precision::FLOAT }
 {

+ 22 - 0
libmandel/src/Mandel.cpp

@@ -384,3 +384,25 @@ std::vector<MandelGenerator*> MandelContext::getCpuGenerators(mnd::Precision pre
 }
 
 
+void MandelContext::saveCache(const std::string& path) const
+{
+    MandelContextCache mcc;
+    for (const auto& device : devices) {
+        for (auto type : device->getSupportedTypes()) {
+            MandelGenerator* mg = device->getGenerator(type);
+            if (ClGenerator* clg = dynamic_cast<ClGenerator*>(mg)) {
+                auto maybeBinary = clg->getBinary();
+                if (maybeBinary.has_value()) {
+
+                }
+            }
+        }
+    }
+}
+
+
+MandelContext MandelContext::initializeFromCache(const std::string& path)
+{
+
+}
+