def hfload_test(hash_clock, cycles):
    import random
    import sys
    import time

    from hf.load import hf
    from hf.load import talkusb
    from hf.load.routines import simple

    if MOC:
        expected_hash_rate = hash_clock * 1000000000 * 0.745
        #return expected_hash_rate * 1.1 # success
        return expected_hash_rate * 0.75 # fail

    talkusb.talkusb(hf.INIT, None, 0);

    def printmsg(msg):
        print(msg)

    # pass in "lambda *a, **k: None" for print fn
    HRT = simple.SimpleRoutine(talkusb.talkusb, hash_clock, printmsg, deterministic=True)
    if not HRT.n_cycles(cycles):
        print("ALERT: test failed to complete.  Measured hash rate so far is '%d'." % HRT.get_hashrate())
        return 0

    return HRT.get_hashrate()
def main(args):
    global running

    # init talkusb
    talkusb.talkusb(hf.INIT, None, 0)

    def printmsg(msg):
        print(msg)

    # init the test
    test = simple.SimpleRoutine(talkusb.talkusb,
                                args.clockrate,
                                printer=printmsg,
                                deterministic=args.deterministic)

    # thread
    thread = threading.Thread(target=monitor, args={test})
    running = True
    #thread.daemon = True
    thread.start()

    # run the test
    rslt = True
    while rslt:
        rslt = test.one_cycle()

    running = False

    print("All done!")
Example #3
0
def hfload_test(hash_clock, cycles):
    import random
    import sys
    import time

    from hf.load import hf
    from hf.load import talkusb
    from hf.load.routines import simple

    if MOC:
        expected_hash_rate = hash_clock * 1000000000 * 0.745
        #return expected_hash_rate * 1.1 # success
        return expected_hash_rate * 0.75  # fail

    talkusb.talkusb(hf.INIT, None, 0)

    def printmsg(msg):
        print(msg)

    # pass in "lambda *a, **k: None" for print fn
    HRT = simple.SimpleRoutine(talkusb.talkusb,
                               hash_clock,
                               printmsg,
                               deterministic=True)
    if not HRT.n_cycles(cycles):
        print(
            "ALERT: test failed to complete.  Measured hash rate so far is '%d'."
            % HRT.get_hashrate())
        return 0

    return HRT.get_hashrate()
  def run(self, ui, dev, option):
    talkusb.talkusb(hf.INIT, None, 0)
    self.test = thermal.ThermalRoutine(talkusb.talkusb, option, ui.log, deterministic=True)
    ui.prompt_show("Running option "+str(option)+". Press board 'RESET' or ctrl+c to end.")
    ui.current_round.clockrate = option
    rslt = True

    self.run_stats = [ [{'die':x, 'frq':option, 'vlt':vlt, 'sm':None, 'em':None, 's':False, 'c':False} for vlt in VLTS] for x in range(4)]

    # thread
    thread = threading.Thread(target=self.monitor_temp, args={ui})
    self.running = True
    #thread.daemon = True
    thread.start()
    # run
    while rslt:
      rslt = self.test.one_cycle()
      if self.req_stop is True:
        self.test.end()
        rslt = False
    #####self.record()
    # cycle loop complete
    self.running = False
    # wait for board to reset
    time.sleep(3)
Example #5
0
def main(args):
  global running

  def printmsg(msg):
    print(msg)

  # init talkusb
  talkusb.talkusb(hf.INIT, None, 0)

  # init the test
  test = simple.SimpleRoutine(talkusb.talkusb, args.clockrate, printer=printmsg, deterministic=args.deterministic)

  # debug stream
  dthread = threading.Thread(target=debugstream, args={printmsg})
  #dthread.daemon = True
  running = True
  dthread.start()

  # thread
  thread = threading.Thread(target=monitor, args={test})
  #thread.daemon = True
  running = True
  thread.start()

  # run the test
  rslt = True
  while rslt:
    rslt = test.one_cycle()

  running = False

  print("All done!")
Example #6
0
  def run(self, ui, dev, clockrate):
    talkusb.talkusb(hf.INIT, None, 0);
    self.test = throttled.ThrottledRoutine(talkusb.talkusb, clockrate, ui.log, deterministic=False)
    ui.prompt_show("Running at "+str(clockrate)+"MHz. Press board 'RESET' or ctrl+c to end.")
    self.cr = ui.current_round
    self.cr.clockrate = clockrate
    # run soak with temperature monitor
    self.getting_warm = False
    self.throttle = 50
    rslt = True

    # thread
    thread = threading.Thread(target=self.monitor_temp, args={ui})
    self.running = True
    #thread.daemon = True
    thread.start()

    # run
    while rslt:
      if self.getting_warm is False:
        self.throttle -= 1
        if self.throttle < 0:
          self.throttle = 0
      else:
        # getting warm
        self.throttle = 50
        self.getting_warm = False
      rslt = self.test.one_cycle(self.throttle)
    #if rslt is -2:
    #  self.run(ui, dev, clockrate)
    # cycle loop complete
    #ui.prompt_enter("Round Complete. Check temperature.")
    self.running = False
 def set(self, ui):
   ui.prompt_show("Updating Die Settings")
   talkusb.talkusb(hf.INIT, None, 0)
   setter = settings.SettingsRoutine(talkusb.talkusb, 1, ui.log)
   for x in range(4):
     frq = self.frequency[x]
     vlt = self.voltage[x]
     if frq is None or vlt is None:
       return None
     else:
       setter.setup(x, frq, vlt)
   # run
   rslt = True
   while rslt:
     rslt = setter.one_cycle()
   # wait for settings to be applied
   time.sleep(3)
Example #8
0
 def set(self, ui):
   ui.prompt_show("Updating Die Settings")
   talkusb.talkusb(hf.INIT, None, 0)
   setter = settings.SettingsRoutine(talkusb.talkusb, 1, ui.log)
   for x in range(4):
     frq = self.frequency[x]
     vlt = self.voltage[x]
     if frq is None or vlt is None:
       return None
     else:
       setter.setup(x, frq, vlt)
   # run
   rslt = True
   while rslt:
     rslt = setter.one_cycle()
   # wait for settings to be applied
   time.sleep(3)
Example #9
0
    def run(self, ui, dev, option):
        talkusb.talkusb(hf.INIT, None, 0)
        self.test = thermal.ThermalRoutine(talkusb.talkusb,
                                           1,
                                           ui.log,
                                           deterministic=True)
        ui.prompt_show("Running option " + str(option) +
                       ". Press board 'RESET' or ctrl+c to end.")
        ui.next_round()
        self.cr = ui.current_round
        self.cr.clockrate = option
        rslt = True

        # thread
        thread = threading.Thread(target=self.monitor_temp, args={ui})
        self.running = True
        #thread.daemon = True
        thread.start()
        # run
        while rslt:
            rslt = self.test.one_cycle()
            if self.req_stop is True:
                self.test.end()
                rslt = False
        # record current voltage and frequency
        for x in range(4):
            if self.test.dies[x] is not None:
                die = self.test.dies[x]
                if die['voltage'] is not None:
                    self.voltage[x] = die['voltage']
                if die['frequency'] is not None:
                    self.frequency[x] = die['frequency']
        # write logfile
        with open(self.csvfilename, 'a') as csvfile:
            csvwriter = csv.DictWriter(csvfile, fn, extrasaction='ignore')
            for x in range(4):
                if self.test.dies[x] is not None:
                    die = self.test.dies[x]
                    csvwriter.writerow(die)
        #if rslt is -2:
        #  self.run(ui, dev, clockrate)
        # cycle loop complete
        #ui.prompt_enter("Round Complete. Check temperature.")
        self.running = False
        # wait for board to reset
        time.sleep(3)
Example #10
0
  def run(self, ui, dev, option):
    talkusb.talkusb(hf.INIT, None, 0)
    self.test = thermal.ThermalRoutine(talkusb.talkusb, 1, ui.log, deterministic=True)
    ui.prompt_show("Running option "+str(option)+". Press board 'RESET' or ctrl+c to end.")
    ui.next_round()
    self.cr = ui.current_round
    self.cr.clockrate = option
    rslt = True

    # thread
    thread = threading.Thread(target=self.monitor_temp, args={ui})
    self.running = True
    #thread.daemon = True
    thread.start()
    # run
    while rslt:
      rslt = self.test.one_cycle()
      if self.req_stop is True:
        self.test.end()
        rslt = False
    # record current voltage and frequency
    for x in range(4):
      if self.test.dies[x] is not None:
        die = self.test.dies[x]
        if die['voltage'] is not None:
          self.voltage[x] = die['voltage']
        if die['frequency'] is not None:
          self.frequency[x] = die['frequency']
    # write logfile
    with open(self.csvfilename, 'a') as csvfile:
      csvwriter = csv.DictWriter(csvfile, fn, extrasaction='ignore')
      for x in range(4):
        if self.test.dies[x] is not None:
          die = self.test.dies[x]
          csvwriter.writerow(die)
    #if rslt is -2:
    #  self.run(ui, dev, clockrate)
    # cycle loop complete
    #ui.prompt_enter("Round Complete. Check temperature.")
    self.running = False
    # wait for board to reset
    time.sleep(3)
Example #11
0
    def run(self, ui, dev, option):
        talkusb.talkusb(hf.INIT, None, 0)
        self.test = thermal.ThermalRoutine(talkusb.talkusb,
                                           option,
                                           ui.log,
                                           deterministic=True)
        ui.prompt_show("Running option " + str(option) +
                       ". Press board 'RESET' or ctrl+c to end.")
        ui.current_round.clockrate = option
        rslt = True

        self.run_stats = [[{
            'die': x,
            'frq': option,
            'vlt': vlt,
            'sm': None,
            'em': None,
            's': False,
            'c': False
        } for vlt in VLTS] for x in range(4)]

        # thread
        thread = threading.Thread(target=self.monitor_temp, args={ui})
        self.running = True
        #thread.daemon = True
        thread.start()
        # run
        while rslt:
            rslt = self.test.one_cycle()
            if self.req_stop is True:
                self.test.end()
                rslt = False
        #####self.record()
        # cycle loop complete
        self.running = False
        # wait for board to reset
        time.sleep(3)
Example #12
0
def mine(args, job_registry, workers):
    time.sleep(1)

    # authorize worker
    worker_name = args.custom_user
    worker_password = args.custom_password
    workers.authorize(worker_name, worker_password)

    # init talkusb
    talkusb.talkusb(hf.INIT, None, 0)

    def printer(msg):
        print(msg)

    # init the test
    test = restart.RestartRoutine(talkusb.talkusb, args.clockrate, printer)

    def get_job(die, core):
        job = job_registry.getwork()
        job['previous block hash'] = hf.reverse_every_four_bytes(
            job['previous block hash'])
        job['merkle tree root'] = hf.reverse_every_four_bytes(
            job['merkle tree root'])
        job['bits'] = hf.bebytes_to_int(job['bits'])
        return job

    test.get_job = get_job

    valid_nonce_queue = deque([])

    def is_valid_nonce(job, nonce):
        # check nonce
        zerobits, regen_hash_expanded = hf.check_nonce_work(job, nonce)
        if (zerobits >= 39):  #if (zerobits >= job_registry.difficulty):
            job['previous block hash'] = hf.reverse_every_four_bytes(
                job['previous block hash'])
            job['merkle tree root'] = hf.reverse_every_four_bytes(
                job['merkle tree root'])
            #job['bits'] = hf.int_to_bebytes(job['bits'], 4)
            #job_registry.submit(job, nonce, worker_name)
            valid_nonce_queue.append((job, nonce, worker_name))
        return (zerobits >= test.search_difficulty)

    test.is_valid_nonce = is_valid_nonce

    def submit(job_registry):
        while running:
            time.sleep(0.1)
            if len(valid_nonce_queue):
                job, nonce, worker_name = valid_nonce_queue.popleft()
                job_registry.submit(job, nonce, worker_name)

    # submit thread
    submit_thread = threading.Thread(target=submit, args={job_registry})
    #submit_thread.daemon = True
    submit_thread.start()

    def monitor(test):
        while running:
            time.sleep(4)
            test.report_hashrate()
            time.sleep(4)
            test.report_errors()

    # thread
    thread = threading.Thread(target=monitor, args={test})
    #thread.daemon = True
    thread.start()

    # run the test
    rslt = True
    while (rslt and running):
        rslt = test.one_cycle()

    #running = False
    print("All done!")
Example #13
0
def mine(args, job_registry, workers):
  time.sleep(1)

  # authorize worker
  worker_name     = args.custom_user
  worker_password = args.custom_password
  workers.authorize(worker_name, worker_password)

  # init talkusb
  talkusb.talkusb(hf.INIT, None, 0)

  def printer(msg):
    print(msg)

  # init the test
  test = restart.RestartRoutine(talkusb.talkusb, args.clockrate, printer)

  def get_job(die, core):
    job = job_registry.getwork()
    job['previous block hash'] = hf.reverse_every_four_bytes(job['previous block hash'])
    job['merkle tree root']    = hf.reverse_every_four_bytes(job['merkle tree root'])
    job['bits'] = hf.bebytes_to_int(job['bits'])
    return job

  test.get_job = get_job
  
  valid_nonce_queue = deque([])
  def is_valid_nonce(job, nonce):
    # check nonce
    zerobits, regen_hash_expanded = hf.check_nonce_work(job, nonce)
    if (zerobits >= 39): #if (zerobits >= job_registry.difficulty):
      job['previous block hash'] = hf.reverse_every_four_bytes(job['previous block hash'])
      job['merkle tree root']    = hf.reverse_every_four_bytes(job['merkle tree root'])
      #job['bits'] = hf.int_to_bebytes(job['bits'], 4)
      #job_registry.submit(job, nonce, worker_name)
      valid_nonce_queue.append( (job, nonce, worker_name) )
    return (zerobits >= test.search_difficulty)

  test.is_valid_nonce = is_valid_nonce

  def submit(job_registry):
    while running:
      time.sleep(0.1)
      if len(valid_nonce_queue):
        job, nonce, worker_name = valid_nonce_queue.popleft()
        job_registry.submit(job, nonce, worker_name)

  # submit thread
  submit_thread = threading.Thread(target=submit, args={job_registry})
  #submit_thread.daemon = True
  submit_thread.start()

  def monitor(test):
    while running:
      time.sleep(4)
      test.report_hashrate()
      time.sleep(4)
      test.report_errors()

  # thread
  thread = threading.Thread(target=monitor, args={test})
  #thread.daemon = True
  thread.start()

  # run the test
  rslt = True
  while (rslt and running):
    rslt = test.one_cycle()

  #running = False
  print("All done!")
 def start(self, ui, dev):
   talkusb.talkusb(hf.INIT, None, 0);
   self.test(ui, dev)
   self.confirm(ui)
   ui.prompt_enter("Check Die Settings on Left")
Example #15
0
 def start(self, ui, dev):
   talkusb.talkusb(hf.INIT, None, 0);
   self.test(ui, dev)
Example #16
0
 def start(self, ui, dev):
     talkusb.talkusb(hf.INIT, None, 0)
     self.test(ui, dev)
     self.confirm(ui)
     ui.prompt_enter("Check Die Settings on Left")