コード例 #1
0
ファイル: test_basic.py プロジェクト: sarats/KGen
def test_strace():

    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 os.path.exists(outdir):
        shutil.rmtree(outdir)
    os.makedirs(outdir)
    for filename in glob.glob(os.path.join(SRCDIR, '*')):
        shutil.copy(filename, outdir)

    # create a kgen command
    cmds = []
    cmds.append(KGEN_APP)
    if inc.has_section('compiler') and inc.has_option(
            'compiler', 'intel') and inc.get('compiler', 'intel'):
        cmds.extend(['--prerun', 'build="%(cmd)s",run="%(cmd)s",kernel_build="%(cmd)s",kernel_run="%(cmd)s"'%\
            {'cmd': inc.get('compiler', 'intel')}])
    cmds.append('--cmd-clean "cd %s; make -f Makefile.mpirun clean"' % outdir)
    cmds.append('--cmd-build "cd %s; make -f Makefile.mpirun build"' % outdir)
    cmds.append('--cmd-run "cd %s; make -f Makefile.mpirun run"' % outdir)
    cmds.append('--kernel-option FC=ifort')
    cmds.append('--outdir %s' % outdir)
    cmds.append('--source alias=/glade/scratch:/glade2/scratch2')
    cmds.append('--mpi enable')
    cmds.append('--openmp enable')
    cmds.append('-I %s' % outdir)
    cmds.append('%s/%s' % (outdir, CALLSITE))

    # run kgen
    print 'SHCMD: %s' % ' \\ \n'.join(cmds)
    out, err, retcode = run_shcmd(' '.join(cmds))

    print '\n******* STDOUT KGEN **********\n'
    print out
    print '\n******* STDERR KGEN **********\n'
    print err

    assert retcode == 0

    out, err, retcode = run_shcmd('cd %s/kernel; make' % outdir)

    print '\n******* STDOUT KERNEL **********\n'
    print out
    print '\n******* STDERR KERNEL **********\n'
    print err

    # check output
    if retcode == 0:
        outlines = out.split('\n')
        if any(line.find('Verification FAILED') >= 0 for line in outlines):
            assert False
        if not any(line.find('Verification PASSED') >= 0 for line in outlines):
            assert False

        assert True
    else:
        assert False
コード例 #2
0
ファイル: kgen.py プロジェクト: 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()
コード例 #3
0
ファイル: test_extends.py プロジェクト: sarats/KGen
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