Exemplo n.º 1
0
parser = OptionParser()
parser.add_option("-v",
                  "--verbose",
                  action="store_true",
                  dest="verbose",
                  default=False,
                  help="print the SIR")

(options, args) = parser.parse_args()

# Print the SIR to stdout only in verbose mode
if options.verbose:
    T = textwrap.TextWrapper(initial_indent=' ' * 1,
                             width=120,
                             subsequent_indent=' ' * 1)
    des = sir_printer.SIRPrinter()

    for stencil in hir.stencils:
        des.visit_stencil(stencil)

# serialize the hir to pass it to the compiler
hirstr = hir.SerializeToString()

# create the options to control the compiler
dawn.dawnOptionsCreate.restype = c_void_p
options = dawn.dawnOptionsCreate()

# we set the backend of the compiler to cuda
dawn.dawnOptionsEntryCreateString.restype = c_void_p
dawn.dawnOptionsEntryCreateString.argtypes = [ctypes.c_char_p]
backend = dawn.dawnOptionsEntryCreateString("c++-naive-ico".encode('utf-8'))
Exemplo n.º 2
0
PARSER = OptionParser()
PARSER.add_option("-v",
                  "--verbose",
                  action="store_true",
                  dest="verbose",
                  default=False,
                  help="print the SIR")

(OPTIONS, _) = PARSER.parse_args()

# Print the SIR to stdout only in verbose mode
if OPTIONS.verbose:
    T = textwrap.TextWrapper(initial_indent=' ' * 1,
                             width=120,
                             subsequent_indent=' ' * 1)
    DES = sir_printer.SIRPrinter()

    for stencil in hir.stencils:
        DES.visit_stencil(stencil)

# serialize the hir to pass it to the compiler
HIR_STR = hir.SerializeToString()

# create the options to control the compiler
DAWN_OPTIONS = DAWN.dawnOptionsCreate()
# we set the backend of the compiler to cuda
BACKEND = DAWN.dawnOptionsEntryCreateString("cuda".encode('utf-8'))
DAWN.dawnOptionsSet(DAWN_OPTIONS, "Backend".encode('utf-8'), BACKEND)

# call the compiler that generates a translation unit
TRANS_UNIT = DAWN.dawnCompile(HIR_STR, len(HIR_STR), DAWN_OPTIONS)