From 746037d8fb33608224d6c2f17cbda91e5a328d3c Mon Sep 17 00:00:00 2001
From: psychocrypt <psychocryptHPC@gmail.com>
Date: Sun, 7 Oct 2018 10:05:57 +0200
Subject: [PATCH] OpenCL: fix definition range for unroll

fix #1870

- remove zero from the valod definition range for the loop unroll option
---
 xmrstak/backend/amd/config.tpl | 2 +-
 xmrstak/backend/amd/jconf.cpp  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xmrstak/backend/amd/config.tpl b/xmrstak/backend/amd/config.tpl
index b852a7e..c3da93a 100644
--- a/xmrstak/backend/amd/config.tpl
+++ b/xmrstak/backend/amd/config.tpl
@@ -15,7 +15,7 @@ R"===(// generated by XMRSTAK_VERSION
  * mem_chunk     - range 0 to 18: set the number of elements (16byte) per chunk
  *                 this value is only used if 'strided_index' == 2
  *                 element count is computed with the equation: 2 to the power of 'mem_chunk' e.g. 4 means a chunk of 16 elements(256byte)
- * unroll        - allow to control how often the POW main loop is unrolled; valid range [0;128) - for most OpenCL implementations it must be a power of two.
+ * unroll        - allow to control how often the POW main loop is unrolled; valid range [1;128) - for most OpenCL implementations it must be a power of two.
  * comp_mode     - Compatibility enable/disable the automatic guard around compute kernel which allows
  *                 to use a intensity which is not the multiple of the worksize.
  *                 If you set false and the intensity is not multiple of the worksize the miner can crash:
diff --git a/xmrstak/backend/amd/jconf.cpp b/xmrstak/backend/amd/jconf.cpp
index fab91d7..152f8ad 100644
--- a/xmrstak/backend/amd/jconf.cpp
+++ b/xmrstak/backend/amd/jconf.cpp
@@ -151,9 +151,9 @@ bool jconf::GetThreadConfig(size_t id, thd_cfg &cfg)
 
 	cfg.memChunk = (int)memChunk->GetInt64();
 
-	if(!unroll->IsUint64() || (int)unroll->GetInt64() >= 128)
+	if(!unroll->IsUint64() || (int)unroll->GetInt64() >= 128 || (int)unroll->GetInt64() == 0)
 	{
-		printer::inst()->print_msg(L0, "ERROR: unroll must be smaller than 128 and a power of two");
+		printer::inst()->print_msg(L0, "ERROR: unroll must be smaller than 128 and not zero");
 		return false;
 	}
 	cfg.unroll = (int)unroll->GetInt64();
-- 
GitLab