From 87357352c9db1b94289afbfce017ed9a0bd89dcc Mon Sep 17 00:00:00 2001
From: psychocrypt <psychocrypt@users.noreply.github.com>
Date: Sun, 24 Sep 2017 21:44:03 +0200
Subject: [PATCH] simplify templates

---
 backend/amd/autoAdjust.hpp      | 2 --
 backend/amd/config.tpl          | 7 ++++++-
 backend/cpu/autoAdjust.hpp      | 3 ---
 backend/cpu/autoAdjustHwloc.hpp | 2 --
 backend/cpu/config.tpl          | 3 +++
 backend/nvidia/autoAdjust.hpp   | 2 --
 backend/nvidia/config.tpl       | 3 +++
 7 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/backend/amd/autoAdjust.hpp b/backend/amd/autoAdjust.hpp
index fd9ea94..de67456 100644
--- a/backend/amd/autoAdjust.hpp
+++ b/backend/amd/autoAdjust.hpp
@@ -80,7 +80,6 @@ private:
 		configTpl.set( std::string(tpl) );
 
 		std::string conf;
-		conf += std::string("\"gpu_threads_conf\" :\n[\n");
         int i = 0;
         for(auto& ctx : devVec)
         {
@@ -97,7 +96,6 @@ private:
                 "  },\n";
             ++i;
         }
-		conf += std::string("],\n\n");
 
 		configTpl.replace("PLATFORMINDEX",std::to_string(platformIndex));
 		configTpl.replace("NUMGPUS",std::to_string(devVec.size()));
diff --git a/backend/amd/config.tpl b/backend/amd/config.tpl
index 6d08730..b8b6dc4 100644
--- a/backend/amd/config.tpl
+++ b/backend/amd/config.tpl
@@ -11,10 +11,15 @@ R"===(
  *  intensity    - Number of parallel GPU threads (nothing to do with CPU threads)
  *   worksize    - Number of local GPU threads (nothing to do with CPU threads)
  * affine_to_cpu - This will affine the thread to a CPU. This can make a GPU miner play along nicer with a CPU miner.
+ * "gpu_threads_conf" :
+ * [
+ *	{ "index" : 0, "intensity" : 1000, "worksize" : 8, "affine_to_cpu" : false },
+ * ],
  */
 
-
+"gpu_threads_conf" : [
 GPUCONFIG
+],
 
 /*
  * Platform index. This will be 0 unless you have different OpenCL platform - eg. AMD and Intel.
diff --git a/backend/cpu/autoAdjust.hpp b/backend/cpu/autoAdjust.hpp
index 67a2142..e7f35a9 100644
--- a/backend/cpu/autoAdjust.hpp
+++ b/backend/cpu/autoAdjust.hpp
@@ -44,7 +44,6 @@ public:
 		configTpl.set( std::string(tpl) );
 
 		std::string conf;
-		conf += std::string("\"cpu_threads_conf\" :\n[\n");
 
 		if(!detectL3Size() || L3KB_size < 1024 || L3KB_size > 102400)
 		{
@@ -96,8 +95,6 @@ public:
 			}
 		}
 
-		conf += std::string("],\n\n");
-
 		configTpl.replace("CPUCONFIG",conf);
 		configTpl.write("cpu.txt");
 		printer::inst()->print_msg(L0, "CPU configuration stored in file '%s'", "cpu.txt");
diff --git a/backend/cpu/autoAdjustHwloc.hpp b/backend/cpu/autoAdjustHwloc.hpp
index 968aac7..161aa5c 100644
--- a/backend/cpu/autoAdjustHwloc.hpp
+++ b/backend/cpu/autoAdjustHwloc.hpp
@@ -42,7 +42,6 @@ public:
 		;
 		configTpl.set( std::string(tpl) );
 
-		conf += std::string("\"cpu_threads_conf\" :\n[\n");
 		try
 		{
 			std::vector<hwloc_obj_t> tlcs;
@@ -73,7 +72,6 @@ public:
 			conf += std::string("    { \"low_power_mode\" : false, \"no_prefetch\" : true, \"affine_to_cpu\" : false },\n");
 			printer::inst()->print_msg(L0, "Autoconf FAILED: %s. Create config for a single thread.", err.what());
 		}
-		conf += std::string("],\n\n");
 
 		configTpl.replace("CPUCONFIG",conf);
 		configTpl.write("cpu.txt");
diff --git a/backend/cpu/config.tpl b/backend/cpu/config.tpl
index 43c1cb8..7d57340 100644
--- a/backend/cpu/config.tpl
+++ b/backend/cpu/config.tpl
@@ -24,7 +24,10 @@ R"===(
  * ],
  */
 
+"cpu_threads_conf" :
+[
 CPUCONFIG
+],
 
 /*
  * LARGE PAGE SUPPORT
diff --git a/backend/nvidia/autoAdjust.hpp b/backend/nvidia/autoAdjust.hpp
index be9b53d..41599b7 100644
--- a/backend/nvidia/autoAdjust.hpp
+++ b/backend/nvidia/autoAdjust.hpp
@@ -86,7 +86,6 @@ private:
 		configTpl.set( std::string(tpl) );
 
 		std::string conf;
-		conf += std::string("\"gpu_threads_conf\" :\n[\n");
         int i = 0;
         for(auto& ctx : nvidCtxVec)
         {
@@ -98,7 +97,6 @@ private:
                 "  },\n";
             ++i;
         }
-		conf += std::string("],\n\n");
 
 		configTpl.replace("GPUCONFIG",conf);
 		configTpl.write("nvidia.txt");
diff --git a/backend/nvidia/config.tpl b/backend/nvidia/config.tpl
index bf7a614..99dc023 100644
--- a/backend/nvidia/config.tpl
+++ b/backend/nvidia/config.tpl
@@ -20,6 +20,9 @@ R"===(
  * ],
  */
 
+"gpu_threads_conf" :
+[
 GPUCONFIG
+],
 
 )==="
-- 
GitLab