Esempio n. 1
0
def do_polysel(parameters):
    name = parameters.myparams({"name": str}, ['tasks'])["name"]
    workdir = parameters.myparams({"workdir": str}, ['tasks'])["workdir"]
    result = {}
    if stage_required('polysel'):
        poly_start = time.time()
        polysel_offset = utils.slurm_cpu_time_start()
        p = polysel.Polysel(parameters)
        result['polyfile'] = p.run()
        poly_finish = time.time()
        result['duration'] = poly_finish - poly_start
        logger.info("\tPolysel in %s", utils.str_time(result['duration']))

        if parameters.myparams({"collect_cputime": [str]}, ['tasks', 'polyselect']).get("collect_cputime"):
            logger.info("--- Collecting polysel cumulative CPUTime ---")
            polysel_slurm_outfile = str(os.path.join(workdir, name + ".slurm_polysel"))
            result['cputime'] = utils.slurm_cpu_time_end(polysel_offset, polysel_slurm_outfile)
            logger.info("\tPolysel cumulative CPUTime %s" % utils.str_time(result['cputime']))
        else:
            result['cputime'] = 0
        
        checkpoint_stage('polysel', result)
    else:
        result = load_stage('polysel')

    return result
Esempio n. 2
0
def do_polysel(parameters):
    name = parameters.myparams({"name": str}, ['tasks'])["name"]
    workdir = parameters.myparams({"workdir": str}, ['tasks'])["workdir"]
    result = {}
    if stage_required('polysel'):
        poly_start = time.time()
        polysel_offset = utils.slurm_cpu_time_start()
        p = polysel.Polysel(parameters)
        result['polyfile'] = p.run()
        poly_finish = time.time()
        result['duration'] = poly_finish - poly_start
        logger.info("\tPolysel in %s", utils.str_time(result['duration']))

        if parameters.myparams({
                "collect_cputime": [str]
        }, ['tasks', 'polyselect']).get("collect_cputime"):
            logger.info("--- Collecting polysel cumulative CPUTime ---")
            polysel_slurm_outfile = str(
                os.path.join(workdir, name + ".slurm_polysel"))
            result['cputime'] = utils.slurm_cpu_time_end(
                polysel_offset, polysel_slurm_outfile)
            logger.info("\tPolysel cumulative CPUTime %s" %
                        utils.str_time(result['cputime']))
        else:
            result['cputime'] = 0

        checkpoint_stage('polysel', result)
    else:
        result = load_stage('polysel')

    return result
Esempio n. 3
0
def do_sieve(parameters, polysel_result):
    result = {}
    name = parameters.myparams({"name": str}, ['tasks'])["name"]
    workdir = parameters.myparams({"workdir": str}, ['tasks'])["workdir"]
    # msieve_filter is the last checkpointed stage in this block
    if stage_required('sieve'):
        sieve_start = time.time()
        sieving_offset = utils.slurm_cpu_time_start()
        s = sieving.Sieve(parameters, polysel_result['polyfile'])
        relation_files = s.run()
        result['relation_files'] = relation_files
        sieve_finish = time.time()
        result['duration'] = sieve_finish - sieve_start
        logger.info("\tSieving in %s", utils.str_time(result['duration']))

        if parameters.myparams({
                "collect_cputime": [str]
        }, ['tasks', 'sieve']).get("collect_cputime"):
            logger.info("--- Collecting sieving cumulative CPUTime ---")
            sieving_slurm_outfile = str(
                os.path.join(workdir, name + ".slurm_sieving"))
            result['cputime'] = utils.slurm_cpu_time_end(
                sieving_offset, sieving_slurm_outfile)
            logger.info("\tSieving cumulative CPUTime %s" %
                        utils.str_time(result['cputime']))
        else:
            result['cputime'] = 0

        relation_files_file = str(
            os.path.join(workdir, name + '.relation_files'))
        logger.info("Saving used relation files from this run to %s",
                    relation_files_file)
        with open(relation_files_file, 'w') as f:
            for line in relation_files:
                f.write(line + '\n')

        if s.completed_factorization:
            logger.info(
                "Completed factorization using trial division. Check log file for factors."
            )
            utils.update_checkpoint({'trail_division': True})

        checkpoint_stage('sieve', result)
    else:
        result = load_stage('sieve')

    post_sieve = parameters.myparams({
        'post_sieve': None
    }, ['commands']).get('post_sieve')
    if post_sieve != None:
        logger.info('Post-sieve command %s', post_sieve)
        utils.run_command(post_sieve, logger=logger)

    return result
Esempio n. 4
0
def do_sieve(parameters, polysel_result):
    result = {}
    name = parameters.myparams({"name": str}, ['tasks'])["name"]
    workdir = parameters.myparams({"workdir": str}, ['tasks'])["workdir"]
    # msieve_filter is the last checkpointed stage in this block
    if stage_required('sieve'):
        sieve_start = time.time()
        sieving_offset = utils.slurm_cpu_time_start()
        s = sieving.Sieve(parameters, polysel_result['polyfile'])
        relation_files = s.run()
        result['relation_files'] = relation_files
        sieve_finish = time.time()
        result['duration'] = sieve_finish - sieve_start
        logger.info("\tSieving in %s", utils.str_time(result['duration']))

        if parameters.myparams({"collect_cputime": [str]}, ['tasks', 'sieve']).get("collect_cputime"):
            logger.info("--- Collecting sieving cumulative CPUTime ---")
            sieving_slurm_outfile = str(os.path.join(workdir, name + ".slurm_sieving"))
            result['cputime'] = utils.slurm_cpu_time_end(sieving_offset, sieving_slurm_outfile)
            logger.info("\tSieving cumulative CPUTime %s" % utils.str_time(result['cputime']))
        else:
            result['cputime'] = 0

        relation_files_file = str(os.path.join(workdir, name + '.relation_files'))
        logger.info("Saving used relation files from this run to %s", relation_files_file)
        with open(relation_files_file, 'w') as f:
            for line in relation_files:
                f.write(line+'\n')

        if s.completed_factorization:
            logger.info("Completed factorization using trial division. Check log file for factors.")
            utils.update_checkpoint({
                'trail_division': True})

        checkpoint_stage('sieve', result)
    else:
        result = load_stage('sieve')

    post_sieve = parameters.myparams({'post_sieve': None}, ['commands']).get('post_sieve')
    if post_sieve != None:
        logger.info('Post-sieve command %s', post_sieve)
        utils.run_command(post_sieve, logger=logger)
    
    return result