def compile(self, code): code = convert_to_float_if_needed(code) path = os.path.expanduser( os.path.join('~', '.pysph', 'source', get_platform_dir())) if not os.path.exists(path): os.makedirs(path) fname = os.path.join(path, 'generated.cl') with open(fname, 'w') as fp: fp.write(code) print("OpenCL code written to %s" % fname) code = code.encode('ascii') if sys.version_info.major < 3 else code self.program = cl.Program(self._ctx, code).build(options=['-w']) return self.program
def compile(self, code): # Note, we do not add carray or particle_array as nnps_base would # have been rebuilt anyway if they changed. root = expanduser(join('~', '.pypsh', 'source', get_platform_dir())) depends = ["pysph.base.nnps_base"] # Add pysph/base directory to inc_dirs for including spatial_hash.h # for SpatialHashNNPS extra_inc_dirs = [join(dirname(dirname(realpath(__file__))), 'base')] self._ext_mod = ExtModule( code, verbose=True, root=root, depends=depends, extra_inc_dirs=extra_inc_dirs ) self._module = self._ext_mod.load() return self._module