From 8d829b587e06dd658f5ee1af8ae24152157f59bd Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Tue, 28 Feb 2017 22:59:44 +0100 Subject: [PATCH] Reset OpenCL when settings change - previously, changing the OpenCL vendor (or turning it on/off) required a restart and this wasn't clear --- src/bitmessageqt/__init__.py | 1 + src/class_singleWorker.py | 5 +++++ src/openclpow.py | 7 ++++++- src/proofofwork.py | 3 +++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index ebcc351c..fc9b4d9a 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2444,6 +2444,7 @@ class MyForm(settingsmixin.SMainWindow): if self.settingsDialogInstance.ui.comboBoxOpenCL.currentText().toUtf8() != BMConfigParser().safeGet("bitmessagesettings", "opencl"): BMConfigParser().set('bitmessagesettings', 'opencl', str(self.settingsDialogInstance.ui.comboBoxOpenCL.currentText())) + queues.workerQueue.put(('resetPoW', '')) acceptableDifficultyChanged = False diff --git a/src/class_singleWorker.py b/src/class_singleWorker.py index 87034f7c..b45c4aca 100644 --- a/src/class_singleWorker.py +++ b/src/class_singleWorker.py @@ -120,6 +120,11 @@ class singleWorker(threading.Thread, StoppableThread): self.sendOutOrStoreMyV4Pubkey(data) except: pass + elif command == 'resetPoW': + try: + proofofwork.resetPoW() + except: + pass elif command == 'stopThread': self.busy = 0 return diff --git a/src/openclpow.py b/src/openclpow.py index 50de80ab..3153c6b6 100644 --- a/src/openclpow.py +++ b/src/openclpow.py @@ -26,7 +26,12 @@ except: libAvailable = False def initCL(): - global ctx, queue, program, enabledGpus, hash_dt + global ctx, queue, program, enabledGpus, hash_dt, vendors + gpus = [] + ctx = False + enabledGpus = [] + vendors = [] + hash_dt = None try: hash_dt = numpy.dtype([('target', numpy.uint64), ('v', numpy.str_, 73)]) try: diff --git a/src/proofofwork.py b/src/proofofwork.py index e20d6cff..493b8b0c 100644 --- a/src/proofofwork.py +++ b/src/proofofwork.py @@ -231,6 +231,9 @@ def run(target, initialHash): except: pass #fallback +def resetPoW(): + openclpow.initCL() + # init def init(): global bitmsglib, bso, bmpow