Exemplo n.º 1
0
Arquivo: kgen.py Projeto: sarats/KGen
def main():

    Config.parse()

    # compflag
    compflag = CompFlag()
    compflag.run()

    Config.process_include_option()
    Config.collect_mpi_params()

    # parse code
    parser = Parser()
    parser.run()

    # init plugins
    init_plugins([KERNEL_ID_0])

    # create model directory
    model_realpath = os.path.realpath(
        '%s/%s' % (Config.path['outdir'], Config.path['model']))
    if not os.path.exists(model_realpath):
        os.makedirs(model_realpath)
    if not os.path.exists('%s/__data__' % model_realpath):
        os.makedirs('%s/__data__' % model_realpath)
    if not os.path.exists('%s/__data__/__resource__' % model_realpath):
        os.makedirs('%s/__data__/__resource__' % model_realpath)

    # model-coverage
    if not Config.model['types']['code']['enabled']:
        logger.info('Disabled code coverage.')
    else:
        cover = Coverage()
        cover.run()

    # model-etime
    if not Config.model['types']['etime']['enabled']:
        logger.info('Disabled elapsedtime.')
    else:
        etime = ElapsedTime()
        etime.run()

    # model-papi
    if not Config.model['types']['papi']['enabled']:
        logger.info('Disabled papi.')
    else:
        papi = PapiCounter()
        papi.run()

    if len(Config.invocation['triples']) == 0:
        Config.invocation['triples'].append(
            (('0', '0'), ('0', '0'), ('1', '1')))

    # extract
    ext = Extractor()
    ext.run()
Exemplo n.º 2
0
def extractor():
    inc = Config.find_machine()

    relpath = os.path.relpath(CURDIR, start=ROOTDIR) 
    outdir = '%s/%s'%(os.path.expandvars(inc.get('variable', 'work_directory')), \
        '%s_%s'%(relpath.replace('/', '_'), os.path.basename(__file__)[:-3]))
    if not os.path.exists(outdir):
        os.makedirs(outdir)
    for filename in glob.glob(os.path.join(SRCDIR, '*')):
        shutil.copy(filename, outdir)

    args = []
    if inc.has_section('compiler') and inc.has_option('compiler', 'gnu') and inc.get('compiler', 'gnu'):
        args.extend(['--prerun', 'build="%(cmd)s",run="%(cmd)s",kernel_build="%(cmd)s",kernel_run="%(cmd)s"'%\
            {'cmd': inc.get('compiler', 'gnu')}])
    args.extend(['--cmd-clean', 'cd %s; make clean'%outdir])
    args.extend(['--cmd-build', 'cd %s; make build'%outdir])
    args.extend(['--cmd-run', 'cd %s; make run'%outdir])
    args.extend(['--kernel-option', 'FC=gfortran'])
    args.extend(['--invocation', '0:0:0'])
    args.extend(['--outdir', outdir])
    args.extend(['-I', outdir])
    args.extend(['%s/%s'%(outdir, CALLSITE)])
    Config.parse(args)
    #args.extend(['--debug', 'printvar=types_mod:exttypevar'])

    #args.extend(['--invocation', '0:0:0'])

    Config.process_include_option()
    Config.collect_mpi_params()


    parser = Parser()
    parser.run()

    init_plugins([KERNEL_ID_0])

    ext = Extractor()

    yield ext