New POW calculation module #1284
|
@ -47,12 +47,12 @@ class WorkProver(threading.Thread):
|
||||||
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.availableSolvers["fast"] = fastsolver.FastSolver(codePath)
|
self.availableSolvers["fast"] = fastsolver.FastSolver(codePath)
|
||||||
except:
|
except fastsolver.FastSolverError:
|
||||||
pass is the dangerous statement, please log it or please write a print statement atleast... pass is the dangerous statement, please log it or please write a print statement atleast...
parallelism = self.solver.parallelism if self.solver else 0 parallelism = self.solver.parallelism if self.solver else 0
if not name and not self.solverName if not name and not self.solverName
logging is required for this functionality. logging is required for this functionality.
if not self.solver if not self.solver
if not name if not name
doc string required here doc string required here
docstring here docstring here
pep8 validation pep8 validation
docstring here please docstring here please
if not self.tasks if not self.tasks
pep8 validation pep8 validation
@PeterSurda , I think we need optimization here. @PeterSurda , I think we need optimization here.
`self.availableSolvers` is visible to the outside code, so it can log or print if `fast` is missing. It should show a message in GUI status bar like the current code does.
It's less readable. It's less readable.
It calls the It calls the `self.statusUpdated` callback and the outside code should log this and display in the GUI.
if not name and not self.solverName: if not name and not self.solverName:
pass
if self.solver: if self.solver:
….
if name: if name:
….
undefined name 'GPUSolverError' undefined name 'GPUSolverError'
pass is the dangerous statement, please log it or please write a print statement atleast... pass is the dangerous statement, please log it or please write a print statement atleast...
parallelism = self.solver.parallelism if self.solver else 0 parallelism = self.solver.parallelism if self.solver else 0
if not name and not self.solverName if not name and not self.solverName
logging is required for this functionality. logging is required for this functionality.
if not self.solver if not self.solver
if not name if not name
doc string required here doc string required here
docstring here docstring here
pep8 validation pep8 validation
docstring here please docstring here please
if not self.tasks if not self.tasks
pep8 validation pep8 validation
@PeterSurda , I think we need optimization here. @PeterSurda , I think we need optimization here.
`self.availableSolvers` is visible to the outside code, so it can log or print if `fast` is missing. It should show a message in GUI status bar like the current code does.
It's less readable. It's less readable.
It calls the It calls the `self.statusUpdated` callback and the outside code should log this and display in the GUI.
if not name and not self.solverName: if not name and not self.solverName:
pass
if self.solver: if self.solver:
….
if name: if name:
….
undefined name 'GPUSolverError' undefined name 'GPUSolverError'
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.availableSolvers["gpu"] = gpusolver.GPUSolver(codePath, GPUVendors)
|
self.availableSolvers["gpu"] = gpusolver.GPUSolver(codePath, GPUVendors)
|
||||||
except:
|
except gpusolver.GPUSolverError:
|
||||||
pass is the dangerous statement, please log it or please write a print statement atleast... pass is the dangerous statement, please log it or please write a print statement atleast...
parallelism = self.solver.parallelism if self.solver else 0 parallelism = self.solver.parallelism if self.solver else 0
if not name and not self.solverName if not name and not self.solverName
logging is required for this functionality. logging is required for this functionality.
if not self.solver if not self.solver
if not name if not name
doc string required here doc string required here
docstring here docstring here
pep8 validation pep8 validation
docstring here please docstring here please
if not self.tasks if not self.tasks
pep8 validation pep8 validation
@PeterSurda , I think we need optimization here. @PeterSurda , I think we need optimization here.
`self.availableSolvers` is visible to the outside code, so it can log or print if `fast` is missing. It should show a message in GUI status bar like the current code does.
It's less readable. It's less readable.
It calls the It calls the `self.statusUpdated` callback and the outside code should log this and display in the GUI.
if not name and not self.solverName: if not name and not self.solverName:
pass
if self.solver: if self.solver:
….
if name: if name:
….
undefined name 'GPUSolverError' undefined name 'GPUSolverError'
pass is the dangerous statement, please log it or please write a print statement atleast... pass is the dangerous statement, please log it or please write a print statement atleast...
parallelism = self.solver.parallelism if self.solver else 0 parallelism = self.solver.parallelism if self.solver else 0
if not name and not self.solverName if not name and not self.solverName
logging is required for this functionality. logging is required for this functionality.
if not self.solver if not self.solver
if not name if not name
doc string required here doc string required here
docstring here docstring here
pep8 validation pep8 validation
docstring here please docstring here please
if not self.tasks if not self.tasks
pep8 validation pep8 validation
@PeterSurda , I think we need optimization here. @PeterSurda , I think we need optimization here.
`self.availableSolvers` is visible to the outside code, so it can log or print if `fast` is missing. It should show a message in GUI status bar like the current code does.
It's less readable. It's less readable.
It calls the It calls the `self.statusUpdated` callback and the outside code should log this and display in the GUI.
if not name and not self.solverName: if not name and not self.solverName:
pass
if self.solver: if self.solver:
….
if name: if name:
….
undefined name 'GPUSolverError' undefined name 'GPUSolverError'
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
pass is the dangerous statement, please log it or please write a print statement atleast... pass is the dangerous statement, please log it or please write a print statement atleast...
pass is the dangerous statement, please log it or please write a print statement atleast... pass is the dangerous statement, please log it or please write a print statement atleast...
parallelism = self.solver.parallelism if self.solver else 0 parallelism = self.solver.parallelism if self.solver else 0
parallelism = self.solver.parallelism if self.solver else 0 parallelism = self.solver.parallelism if self.solver else 0
if not name and not self.solverName if not name and not self.solverName
if not name and not self.solverName if not name and not self.solverName
logging is required for this functionality. logging is required for this functionality.
logging is required for this functionality. logging is required for this functionality.
if not self.solver if not self.solver
if not self.solver if not self.solver
if not name if not name
if not name if not name
doc string required here doc string required here
doc string required here doc string required here
docstring here docstring here
docstring here docstring here
pep8 validation pep8 validation
pep8 validation pep8 validation
docstring here please docstring here please
docstring here please docstring here please
if not self.tasks if not self.tasks
if not self.tasks if not self.tasks
pep8 validation pep8 validation
pep8 validation pep8 validation
@PeterSurda , I think we need optimization here. @PeterSurda , I think we need optimization here.
@PeterSurda , I think we need optimization here. @PeterSurda , I think we need optimization here.
`self.availableSolvers` is visible to the outside code, so it can log or print if `fast` is missing. It should show a message in GUI status bar like the current code does.
`self.availableSolvers` is visible to the outside code, so it can log or print if `fast` is missing. It should show a message in GUI status bar like the current code does.
It's less readable. It's less readable.
It's less readable. It's less readable.
It calls the It calls the `self.statusUpdated` callback and the outside code should log this and display in the GUI.
It calls the It calls the `self.statusUpdated` callback and the outside code should log this and display in the GUI.
if not name and not self.solverName: if not name and not self.solverName:
pass
if not name and not self.solverName: if not name and not self.solverName:
pass
if self.solver: if self.solver:
….
if self.solver: if self.solver:
….
if name: if name:
….
if name: if name:
….
undefined name 'GPUSolverError' undefined name 'GPUSolverError'
undefined name 'GPUSolverError' undefined name 'GPUSolverError'
|
|
@ -4,6 +4,9 @@ import platform
|
||||||
doc type required here doc type required here
doc type required here doc type required here
documentation required here documentation required here
documentation required here documentation required here
|
|||||||
import subprocess
|
import subprocess
|
||||||
import ctypes
|
import ctypes
|
||||||
please write all the imports in alphabetic order please write all the imports in alphabetic order
|
|||||||
|
|
||||||
|
class FastSolverError(Exception):
|
||||||
doc type required here doc type required here
documentation required here documentation required here
|
|||||||
|
pass
|
||||||
doc type required here doc type required here
documentation required here documentation required here
|
|||||||
|
|
||||||
doc type required here doc type required here
documentation required here documentation required here
|
|||||||
def loadFastSolver(codePath):
|
def loadFastSolver(codePath):
|
||||||
if hasattr(sys, "winver"):
|
if hasattr(sys, "winver"):
|
||||||
suffix = "-32"
|
suffix = "-32"
|
||||||
|
@ -13,7 +16,10 @@ def loadFastSolver(codePath):
|
||||||
doc type required here doc type required here
doc type required here doc type required here
documentation required here documentation required here
documentation required here documentation required here
|
|||||||
|
|
||||||
pep8 validation pep8 validation
|
|||||||
path = os.path.join(codePath, "fastsolver/libfastsolver{}.dll".format(suffix))
|
path = os.path.join(codePath, "fastsolver/libfastsolver{}.dll".format(suffix))
|
||||||
|
|
||||||
return ctypes.WinDLL(path)
|
try:
|
||||||
doc type required here doc type required here
documentation required here documentation required here
doc type required here doc type required here
documentation required here documentation required here
|
|||||||
|
return ctypes.WinDLL(path)
|
||||||
doc type required here doc type required here
documentation required here documentation required here
|
|||||||
|
except:
|
||||||
doc type required here doc type required here
documentation required here documentation required here
|
|||||||
|
raise FastSolverError()
|
||||||
doc type required here doc type required here
documentation required here documentation required here
|
|||||||
|
|
||||||
makePath = os.path.join(codePath, "fastsolver")
|
makePath = os.path.join(codePath, "fastsolver")
|
||||||
path = os.path.join(codePath, "fastsolver/libfastsolver.so")
|
path = os.path.join(codePath, "fastsolver/libfastsolver.so")
|
||||||
|
@ -21,12 +27,15 @@ def loadFastSolver(codePath):
|
||||||
doc type required here doc type required here
doc type required here doc type required here
documentation required here documentation required here
documentation required here documentation required here
|
|||||||
try:
|
try:
|
||||||
return ctypes.CDLL(path)
|
return ctypes.CDLL(path)
|
||||||
except:
|
except:
|
||||||
if not hasattr(sys, "frozen"):
|
if hasattr(sys, "frozen"):
|
||||||
doc type required here doc type required here
documentation required here documentation required here
doc type required here doc type required here
documentation required here documentation required here
|
|||||||
|
raise FastSolverError()
|
||||||
doc type required here doc type required here
documentation required here documentation required here
|
|||||||
|
|
||||||
doc type required here doc type required here
documentation required here documentation required here
|
|||||||
|
try:
|
||||||
doc type required here doc type required here
documentation required here documentation required here
|
|||||||
subprocess.call(["make", "-C", makePath])
|
subprocess.call(["make", "-C", makePath])
|
||||||
|
|
||||||
return ctypes.CDLL(path)
|
return ctypes.CDLL(path)
|
||||||
else:
|
except:
|
||||||
doc type required here doc type required here
documentation required here documentation required here
doc type required here doc type required here
documentation required here documentation required here
|
|||||||
raise Exception()
|
raise FastSolverError()
|
||||||
doc type required here doc type required here
documentation required here documentation required here
doc type required here doc type required here
documentation required here documentation required here
|
|||||||
|
|
||||||
class FastSolver(object):
|
class FastSolver(object):
|
||||||
def __init__(self, codePath):
|
def __init__(self, codePath):
|
||||||
|
|
||||||
doc type required here doc type required here
doc type required here doc type required here
documentation required here documentation required here
documentation required here documentation required here
|
|
@ -14,8 +14,11 @@ class GPUSolver(object):
|
||||||
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
|
|||||||
def __init__(self, codePath, vendors = None):
|
def __init__(self, codePath, vendors = None):
|
||||||
global pyopencl, numpy
|
global pyopencl, numpy
|
||||||
|
|
||||||
import pyopencl
|
try:
|
||||||
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
|
|||||||
import numpy
|
import pyopencl
|
||||||
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
|
|||||||
|
import numpy
|
||||||
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
|
|||||||
|
except ImportError:
|
||||||
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
|
|||||||
|
raise GPUSolverError()
|
||||||
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
|
|||||||
|
|
||||||
device = None
|
device = None
|
||||||
|
|
||||||
|
@ -30,7 +33,7 @@ class GPUSolver(object):
|
||||||
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
|
|||||||
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise Exception()
|
raise GPUSolverError()
|
||||||
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
|
|||||||
|
|
||||||
context = pyopencl.Context(devices = [device])
|
context = pyopencl.Context(devices = [device])
|
||||||
|
|
||||||
|
|
||||||
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
Could you please comment #1283 and maybe change the import order too if you agree? Could you please comment #1283 and maybe change the import order too if you agree?
|
pass is the dangerous statement, please log it or please write a print statement atleast...
pass is the dangerous statement, please log it or please write a print statement atleast...
parallelism = self.solver.parallelism if self.solver else 0
parallelism = self.solver.parallelism if self.solver else 0
if not name and not self.solverName
if not name and not self.solverName
logging is required for this functionality.
logging is required for this functionality.
if not self.solver
if not self.solver
if not name
if not name
doc string required here
doc string required here
docstring here
docstring here
pep8 validation
pep8 validation
docstring here please
docstring here please
if not self.tasks
if not self.tasks
pep8 validation
pep8 validation
@PeterSurda , I think we need optimization here.
@PeterSurda , I think we need optimization here.
self.availableSolvers
is visible to the outside code, so it can log or print iffast
is missing. It should show a message in GUI status bar like the current code does.self.availableSolvers
is visible to the outside code, so it can log or print iffast
is missing. It should show a message in GUI status bar like the current code does.It's less readable.
It's less readable.
It calls the
self.statusUpdated
callback and the outside code should log this and display in the GUI.It calls the
self.statusUpdated
callback and the outside code should log this and display in the GUI.if not name and not self.solverName:
pass
if not name and not self.solverName:
pass
if self.solver:
….
if self.solver:
….
if name:
….
if name:
….
undefined name 'GPUSolverError'
undefined name 'GPUSolverError'