def _generate_lib_specific_args(self): self._components['LIB_ARG_DECLS'] = [ cgen.Const(cgen.Value(host.int32_str, '_NUM_THREADS')), cgen.Const(cgen.Value(host.int32_str, '_N_START')), cgen.Const(cgen.Value(host.int32_str, '_N_LOCAL')), cgen.Const(cgen.Value(host.int32_str, '_LIST_OFFSET')), cgen.Const( cgen.Pointer( cgen.Value( host.int32_str, Restrict(self._cc.restrict_keyword, '_CELL_LIST')))), cgen.Const( cgen.Pointer( cgen.Value(host.int32_str, Restrict(self._cc.restrict_keyword, '_CRL')), )), cgen.Const( cgen.Pointer( cgen.Value(host.int32_str, Restrict(self._cc.restrict_keyword, '_CCC')), )), cgen.Const( cgen.Pointer( cgen.Value(host.int32_str, Restrict(self._cc.restrict_keyword, '_OFFSET')), )), cgen.Pointer( cgen.Pointer( cgen.Value(host.int32_str, Restrict(self._cc.restrict_keyword, '_JSTORE')), )), self.loop_timer.get_cpp_arguments_ast() ]
def _generate_lib_specific_args(self): self._components['LIB_ARG_DECLS'] = [ cgen.Const(cgen.Value(host.int64_str, '_NUM_THREADS')), cgen.Const(cgen.Value(host.int64_str, '_N_LOCAL')), cgen.Const(cgen.Value(host.int64_str, '_STRIDE')), cgen.Const( cgen.Pointer( cgen.Value(host.int64_str, Restrict(self._cc.restrict_keyword, '_NN')))), cgen.Const( cgen.Pointer( cgen.Value(host.int64_str, Restrict(self._cc.restrict_keyword, '_NLIST')), )), self.loop_timer.get_cpp_arguments_ast() ]
def _generate_kernel_arg_decls(self): _kernel_arg_decls = [] _kernel_lib_arg_decls = [] _kernel_structs = cgen.Module( [cgen.Comment('#### Structs generated per ParticleDat ####')]) if self._kernel.static_args is not None: for i, dat in enumerate(self._kernel.static_args.items()): arg = cgen.Const(cgen.Value(host.ctypes_map[dat[1]], dat[0])) _kernel_arg_decls.append(arg) _kernel_lib_arg_decls.append(arg) for i, dat in enumerate(self._dat_dict.items()): assert type(dat[1]) is tuple, "Access descriptors not found" obj = dat[1][0] mode = dat[1][1] symbol = dat[0] kernel_lib_arg = cgen.Pointer( cgen.Value(host.ctypes_map[obj.dtype], Restrict(self._cc.restrict_keyword, symbol))) if issubclass(type(obj), data.GlobalArrayClassic): kernel_lib_arg = cgen.Pointer(kernel_lib_arg) gen = self._components['PARTICLE_DAT_C'][symbol] _kernel_arg_decls.append(gen.kernel_arg_decl) elif issubclass(type(obj), host._Array): gen = self._components['PARTICLE_DAT_C'][symbol] _kernel_arg_decls.append(gen.kernel_arg_decl) if mode.write is True: assert issubclass(type(obj), data.GlobalArrayClassic), \ "global array must be a thread safe type for \ write access. Type is:" + str(type(obj)) elif issubclass(type(dat[1][0]), host.Matrix): gen = self._components['PARTICLE_DAT_C'][symbol] _kernel_structs.append(gen.header) _kernel_arg_decls.append(gen.kernel_arg_decl[0]) _kernel_arg_decls.append(gen.kernel_arg_decl[1]) if not dat[1][1].write: kernel_lib_arg = cgen.Const(kernel_lib_arg) _kernel_lib_arg_decls.append(kernel_lib_arg) self._components['KERNEL_ARG_DECLS'] = _kernel_arg_decls self._components['KERNEL_LIB_ARG_DECLS'] = _kernel_lib_arg_decls self._components['KERNEL_STRUCT_TYPEDEFS'] = _kernel_structs
def _generate_lib_specific_args(self): cp = self._components ncx = cp['N_CELL_X'] ncy = cp['N_CELL_Y'] ncz = cp['N_CELL_Z'] npad = cp['N_CELL_PAD'] nloc = cp['N_LOCAL'] exec_count = cp['EXEC_COUNT'] self._components['LIB_ARG_DECLS'] = [ cgen.Const(cgen.Value(host.int32_str, '_NUM_THREADS')), cgen.Const(cgen.Value(host.int64_str, ncx)), cgen.Const(cgen.Value(host.int64_str, ncy)), cgen.Const(cgen.Value(host.int64_str, ncz)), cgen.Const(cgen.Value(host.int64_str, npad)), cgen.Const(cgen.Value(host.int32_str, nloc)), cgen.Const(cgen.Value(host.int32_str, '_LIST_OFFSET')), cgen.Const( cgen.Pointer( cgen.Value( host.int32_str, Restrict(self._cc.restrict_keyword, '_CELL_LIST')))), cgen.Const( cgen.Pointer( cgen.Value(host.int32_str, Restrict(self._cc.restrict_keyword, '_CRL')), )), cgen.Const( cgen.Pointer( cgen.Value(host.int32_str, Restrict(self._cc.restrict_keyword, '_CCC')), )), cgen.Const( cgen.Pointer( cgen.Value(host.int32_str, Restrict(self._cc.restrict_keyword, '_OFFSET')), )), cgen.Pointer( cgen.Pointer( cgen.Value(host.int32_str, Restrict(self._cc.restrict_keyword, '_JSTORE')), )), cgen.Pointer( cgen.Pointer( cgen.Value( host.uint8_str, Restrict(self._cc.restrict_keyword, '_GATHER_SPACE')), )), cgen.Const(cgen.Value(host.int64_str, self._components['CCC_MAX'])), cgen.Pointer(cgen.Value(host.int64_str, exec_count)), self.loop_timer.get_cpp_arguments_ast() ]
def _generate_kernel_arg_decls(self): _kernel_arg_decls = [] _kernel_lib_arg_decls = [] _kernel_structs = cgen.Module([ cgen.Comment('#### Structs generated per ParticleDat ####') ]) if self._kernel.static_args is not None: for i, dat in enumerate(self._kernel.static_args.items()): arg = cgen.Const(cgen.Value(host.ctypes_map[dat[1]], dat[0])) _kernel_arg_decls.append(arg) _kernel_lib_arg_decls.append(arg) for i, dat in enumerate(self._dat_dict.items()): assert type(dat[1]) is tuple, "Access descriptors not found" obj = dat[1][0] mode = dat[1][1] symbol = dat[0] kernel_lib_arg = cgen.Pointer(cgen.Value(host.ctypes_map[obj.dtype], Restrict(self._cc.restrict_keyword, symbol)) ) if issubclass(type(obj), data.GlobalArrayClassic): kernel_lib_arg = cgen.Pointer(kernel_lib_arg) if issubclass(type(obj), host._Array): kernel_arg = cgen.Pointer(cgen.Value(host.ctypes_map[obj.dtype], Restrict(self._cc.restrict_keyword, symbol)) ) if not mode.write: kernel_arg = cgen.Const(kernel_arg) _kernel_arg_decls.append(kernel_arg) if mode.write is True: assert issubclass(type(obj), data.GlobalArrayClassic),\ "global array must be a thread safe type for \ write access. Type is:" + str(type(obj)) elif issubclass(type(dat[1][0]), host.Matrix): # MAKE STRUCT TYPE dtype = dat[1][0].dtype ti = cgen.Pointer(cgen.Value(ctypes_map(dtype), Restrict(self._cc.restrict_keyword,'i'))) tj = cgen.Pointer(cgen.Value(ctypes_map(dtype), Restrict(self._cc.restrict_keyword,'j'))) if not dat[1][1].write: ti = cgen.Const(ti) tj = cgen.Const(tj) typename = '_'+dat[0]+'_t' _kernel_structs.append(cgen.Typedef(cgen.Struct('', [ti,tj], typename))) # MAKE STRUCT ARG _kernel_arg_decls.append(cgen.Value(typename, dat[0])) if not dat[1][1].write: kernel_lib_arg = cgen.Const(kernel_lib_arg) _kernel_lib_arg_decls.append(kernel_lib_arg) self._components['KERNEL_ARG_DECLS'] = _kernel_arg_decls self._components['KERNEL_LIB_ARG_DECLS'] = _kernel_lib_arg_decls self._components['KERNEL_STRUCT_TYPEDEFS'] = _kernel_structs