示例#1
0
def build_tools_tree():
    """ Builds the tests AST for both pi.c and pi.cu 
    
    """
    template_code = '''
    int main() {
        int f = 0;
        int i = 0;
        i = 7;
    }
    '''
    new_ast = parse_source(template_code, "Tool test 1")
#    # Transform the C ast into the internal representation
#    new_ast = AstToIR(Writer = OmpWriter).transform(ast)
#    template_code = """
#        int main() {
#            int f = 0;
#            f = 7;
#        }
#    """
#    declarations = AstToIR(Writer = OmpWriter).transform(parse_source(template_code, "Tool test 2")).ext[-1].body.decls
#    from Tools.Tree import InsertTool, ReplaceTool, RemoveTool
#    InsertTool(subtree = declarations, position = "begin").apply(new_ast.ext[-1].body, 'decls')

    Dump.save(TREE_PATH + '/insert_tool_tree', new_ast)
示例#2
0
def build_jacobi_tree():
     """ Builds the tests AST for both pi.c and pi.cu 
      
     """
     # Pi
     template_code = open(CODE_PATH + '/jacobi.c', 'r').read()
     ast = parse_source(template_code, 'pi_test')
     Dump.save(TREE_PATH + '/jacobi_tree', ast)
     # CUDA version
     new_ast = AstToIR(Writer = CUDAWriter).transform(ast)
     tmp = CM_OmpParallel().apply_all(new_ast)
     Dump.save(TREE_PATH + '/jacobicu_tree', tmp)
示例#3
0
def build_mandel_tree():
     """ Builds the tests AST for both mandel.c and mandel.cu 
      
     """
#     [CODE_PATH, TREE_PATH] = getPath(
     # Mandel
     template_code = open(CODE_PATH + '/mandel.c', 'r').read()
     ast = parse_source(template_code, 'mandel_test')
     Dump.save(TREE_PATH + '/mandel_tree', ast)
     tmp = AstToIR(Writer = CUDAWriter).transform(ast)
     # CUDA version
     new_ast = CM_OmpParallelFor().apply_all(tmp) 
     Dump.save(TREE_PATH + '/mandelcu_tree', new_ast)
示例#4
0
文件: basic.py 项目: zhiichen/llcomp
def build_test_trees():
     template_code = """ 
                int main (int a) {
                    printf(" Hello World!");
                }
          """
     ast = parse_source(template_code, 'helloWorld_test')
     Dump.save('Backends/C/tests/trees/helloWorld_tree', ast)
     template_code = """ 
int main()
{
     int i;
     int sum[10];

     for (i = 0; i <= 10; i++) {
    sum[i] = i;
     }

     #pragma omp parallel for reduction(+ : sum)
     for (i = 0; i <= 10; i++) {
    sum[i] = i;
     }

}
          """
     ast = parse_source(template_code, 'pragma_test')
     Dump.save('Backends/C/tests/trees/pragma_tree', ast)

     template_code = open('Backends/C/tests/codes/jacobi_big.c', 'r').read()
     ast = parse_source(template_code, 'jacobi_c')
     Dump.save('Backends/C/tests/trees/jacobi_tree', ast)