Skip to content

Commit 34a2323

Browse files
author
John Mora
committed
Full GPU only support\!\!\!, OpenGL disables CUDA
1 parent 0d8da4e commit 34a2323

File tree

4 files changed

+34
-16
lines changed

4 files changed

+34
-16
lines changed

cpyrit/cpyrit.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,15 @@ def __init__(self):
432432
self.cores = []
433433
self.CUDAs = []
434434
self.OpCL = []
435+
self.all = []
435436
self.cv = threading.Condition()
436437

437438
# CUDA
438-
if config.cfg['use_CUDA'] == 'true' and 'cpyrit._cpyrit_cuda' in sys.modules:
439+
if config.cfg['use_CUDA'] == 'true' and 'cpyrit._cpyrit_cuda' in sys.modules and config.cfg['use_OpenCL'] == 'false':
439440

440441
CUDA = cpyrit_cuda.listDevices()
441442

442-
for dev_idx, device in enumerate(CUDAs):
443+
for dev_idx, device in enumerate(CUDA):
443444
self.CUDAs.append(CUDACore(queue=self, dev_idx=dev_idx))
444445
CUDA -= 1
445446

@@ -463,6 +464,8 @@ def __init__(self):
463464
for i in xrange(util.ncpus):
464465
self.cores.append(CPUCore(queue=self))
465466

467+
468+
466469
#Network
467470
if config.cfg['rpc_server'] == 'true':
468471
for port in xrange(17935, 18000):
@@ -485,9 +488,18 @@ def __init__(self):
485488
self.ncore_uuid = None
486489
else:
487490
self.ncore_uuid = None
491+
488492

489-
def _check_cores(self):
490493
for core in self.cores:
494+
self.all.append(core)
495+
for OCL in self.OpCL:
496+
self.all.append(OCL)
497+
for CD in self.CUDAs:
498+
self.all.append(CD)
499+
500+
def _check_cores(self):
501+
all = []
502+
for core in self.all:
491503
if not core.shallStop and not core.isAlive():
492504
raise SystemError("The core '%s' has died unexpectedly" % core)
493505

@@ -518,13 +530,13 @@ def __exit__(self, exc_type, exc_val, exc_tb):
518530
self.shutdown()
519531

520532
def shutdown(self):
521-
for core in self.cores:
533+
for core in self.all:
522534
core.shallStop = True
523-
for core in self.cores:
535+
for core in self.all:
524536
core.shutdown()
525537

526538
def isAlive(self):
527-
return all(core.isAlive() for core in self.cores)
539+
return all(core.isAlive() for core in self.all)
528540

529541
def waitForSchedule(self, maxBufferSize):
530542
"""Block until less than the given number of passwords wait for being
@@ -538,7 +550,7 @@ def waitForSchedule(self, maxBufferSize):
538550

539551
def resetStatistics(self):
540552
"""Reset all cores' statistics"""
541-
for core in self.cores:
553+
for core in self.all:
542554
core.resetStatistics()
543555

544556
def getPeakPerformance(self):
@@ -548,7 +560,7 @@ def getPeakPerformance(self):
548560
with 100% occupancy. The real performance is lower if the caller
549561
fails to keep the pipeline filled.
550562
"""
551-
return sum([c.resCount / c.compTime for c in self.cores if c.compTime])
563+
return sum([c.resCount / c.compTime for c in self.all if c.compTime])
552564

553565
def enqueue(self, essid, passwords, block=True):
554566
"""Enqueue the given ESSID and iterable of passwords for processing.

cpyrit/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def _limit_ncpus():
8787
except ValueError:
8888
raise ValueError("Invalid 'limit_ncpus' in configuration")
8989
if limited_ncpus < 0:
90-
raise ValueError("Invalid 'limit_ncpus' in configuration")
90+
#raise ValueError("Invalid 'limit_ncpus' in configuration")
91+
return 0;
9192
if limited_ncpus > 0 and limited_ncpus < detected_ncpus:
9293
return limited_ncpus
9394
return detected_ncpus

pyrit_cli.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,20 +292,25 @@ def list_cores(self):
292292
pyrit list_cores
293293
"""
294294
with cpyrit.cpyrit.CPyrit() as cp:
295-
self.tell("The following cores seem available...")
295+
if int(cpyrit.config.cfg['limit_ncpus']) < 0:
296+
self.tell("CPUs disabled in config...")
297+
else:
298+
self.tell("The following cores seem available...")
296299
for i, core in enumerate(cp.cores):
297300
self.tell("#%i: '%s'" % (i + 1, core))
298-
if cpyrit.config.cfg['use_CUDA'] == 'true':
299-
if len(cp.CUDAs) != 0:
300-
self.tell("\nThe following CUDA GPUs seem aviable...")
301-
for i, CD in enumerate(cp.CUDAs):
302-
self.tell("#%i: '%s'" % (i + 1, CD))
303301

304302
if cpyrit.config.cfg['use_OpenCL'] == 'true':
303+
if cpyrit.config.cfg['use_CUDA'] == 'true':
304+
self.tell("\nWARNING: OpenCL disables CUDA!\n")
305305
if len(cp.OpCL) != 0:
306306
self.tell("\nThe following OpenCL GPUs seem aviable...")
307307
for i, OCL in enumerate(cp.OpCL):
308308
self.tell("#%i: '%s'" % (i + 1, OCL))
309+
elif cpyrit.config.cfg['use_OpenCL'] == 'false' and cpyrit.config.cfg['use_CUDA'] == 'true':
310+
if len(cp.CUDAs) != 0:
311+
self.tell("\nThe following CUDA GPUs seem aviable...")
312+
for i, CD in enumerate(cp.CUDAs):
313+
self.tell("#%i: '%s'" % (i + 1, CD))
309314
list_cores.cli_options = ((), ())
310315

311316
def list_essids(self, storage):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import sys
2727
import re
2828

29-
VERSION = '0.4.1-dev'
29+
VERSION = '0.4.6'
3030

3131
UnixCCompiler.src_extensions.append('.S')
3232

0 commit comments

Comments
 (0)