Source

benchmark_rnn / wscript

Full commit
top = '.'
out = 'build'


def configure(ctx):
    # check compilers
    compiler_list = []
    for com in ['gcc', 'icc', 'opencc']:
        try:
            ctx.find_program(com)
            compiler_list.append(com)
        except:
            ctx.to_log('cannot find %s (ignoring)')
    ctx.env.COMPILER_LIST = compiler_list


def build(bld):
    # target list
    trg_list = ['rnn_ca1d', 'rnn_ca2d', 'rnn_opt0', 'rnn_opt1',
                'rnn_opt2', 'rnn_opt3', 'rnn_opt4']
    # compiler-specific flags
    default_flags = dict(
        gcc = ['-lm', '-ftree-vectorizer-verbose=1'],
        icc = ['-vec-report1'],
        opencc = ['-lm'],
        )
    # target-specific flags
    std99 = dict(gcc=['-std=c99'], icc=['-restrict'], opencc=['-std=c99'])
    trg_flags = dict(rnn_opt3=std99, rnn_opt4=std99)

    for com in bld.env.COMPILER_LIST:
        flags_list = [['-O3']]  # , ['-O2']
        if com == 'gcc':
            flags_list += [['-O3', '-ffast-math']]
        elif com == 'opencc':
            flags_list += [['-Ofast'], ['-Ofast', '-ipa']]

        for flags in flags_list:
            allflags = default_flags[com] + flags
            for trg in trg_list:
                allflagsstr = ' '.join(
                    allflags + trg_flags.get(trg, {}).get(com, []))
                flagsname = ''.join(flags)
                bld(rule='%s %s ${SRC} -o ${TGT}' % (com, allflagsstr),
                    source='%s.c' % trg,
                    target='%s-%s%s' % (trg, com, flagsname))