Ejemplo n.º 1
0
    def __call__(self, *args, **kwargs):
        import compiler.xmlvisitor as xmlVst 
        import pycomp
        dirname = self.fn.__name__
        #rc = pycomp.run(dirname, *args);
        rc = -1;

        #if kernel has not been compiled,
        #compile it again
        if(rc == -1):
            vst = xmlVst.xmlvisitor(args,self.get_globals())
            vst.visit(self.get_ast())
            self.xmlstr = vst.xmlstr
            # Save input and output matrices to files
            import os
            try:
                os.mkdir(dirname)
            except OSError:
                pass
            fname = dirname + '/' + dirname + '.xml'
            fout = open(fname, 'w')
            fout.write(self.xmlstr)
            fout.close()
            pycomp.setOpts(True,True,True,False,True,16);
            pycomp.func(dirname, self.xmlstr);
            pycomp.run(dirname, *args);
Ejemplo n.º 2
0
    def __call__(self, *args, **kwargs):
        import compiler.xmlvisitor as xmlVst 
        vst = xmlVst.xmlvisitor(args)
        vst.visit(self.get_ast())
        self.xmlstr = vst.xmlstr
	# Save input and output matrices to files
	import os
	dirname = self.fn.__name__
	try:
		os.mkdir(dirname)
	except OSError:
		pass

	for argnum in range(0,len(args)):
		fname = dirname + '/input_' + str(argnum) + '.bin'
		fout = open(fname, 'w')
		args[argnum].tofile(fout)
		fout.close()

	self.fn(*args)

	for argnum in range(0,len(args)):
		fname = dirname + '/output_' + str(argnum) + '.bin'
		fout = open(fname, 'w')
		args[argnum].tofile(fout)
		fout.close()

	fname = dirname + '/' + dirname + '.xml'
	fout = open(fname, 'w')
	fout.write(self.xmlstr)
	fout.close()