00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 """@package libspe2 interface"""
00031
00032 import ctrump
00033
00034 def spe_in_param_member(have_spe_output, param, name):
00035 if have_spe_output:
00036 return param.member('in').member(name)
00037 else:
00038 return param.member(name)
00039
00040 class LibSPE2:
00041 def __init__(self, builder):
00042 self.builder = builder
00043 self.spe_context_ptr_t = builder.incomplete_typedefed_name('spe_context_ptr_t')
00044
00045 self.spe_program_handle_t = builder.pointer_to(builder.incomplete_typedefed_name('spe_program_handle_t'))
00046 self.load_func_typespec = builder.func_type(builder.int_, [(self.spe_context_ptr_t,'spe'),
00047 (self.spe_program_handle_t,'program')])
00048
00049 uint_ptr_t = builder.pointer_to(builder.uint)
00050 void_ptr_t = builder.pointer_to(builder.void)
00051
00052 spe_stop_info_t = builder.incomplete_typedefed_name('spe_stop_info_t')
00053 stop_info_ptr_t = builder.pointer_to(spe_stop_info_t)
00054
00055 self.run_func_typespec = builder.func_type(builder.int_, [(self.spe_context_ptr_t, 'spe'),
00056 (void_ptr_t, 'argp')])
00057 self.run_func = builder.func('ctrump_runtime_spe_start', self.run_func_typespec)
00058
00059 self.wait_func_typespec = builder.func_type(builder.int_, [(self.spe_context_ptr_t, 'spe')])
00060
00061 self.fini = builder.func('ctrump_spe_fini')
00062 self.include = builder.include("ctrump-libspe2.h")
00063
00064 self.load_func = builder.func('ctrump_runtime_spe_program_load', self.load_func_typespec)
00065 self.wait_func = builder.func('ctrump_runtime_spe_wait', self.wait_func_typespec)
00066
00067
00068 def program_typespec(self):
00069 builder = self.builder
00070 typespec = builder.incomplete_typedefed_name('spe_program_handle_t')
00071 return typespec
00072
00073 def emit_load_func(self, spe_obj, program_obj):
00074 b = self.builder
00075 return self.load_func(spe_obj, b.addr(program_obj))
00076
00077 def emit_run_func(self, spe_obj, param):
00078 return self.run_func(spe_obj, param)
00079
00080 def emit_wait_func(self, spe_obj):
00081 return self.wait_func(spe_obj)
00082
00083 def emit_spe_end(self, have_spe_output, spe_id, is_last_spe, sync_buffer_ea):
00084 fini = self.builder.func('ctrump_spe_fini')
00085 return self.builder.return_(fini(spe_id, is_last_spe, sync_buffer_ea))
00086
00087 def emit_include(self):
00088 return self.include
00089
00090 def get_program_load_func(self):
00091 return self.emit_load_func
00092
00093 def get_run_func(self):
00094 return self.emit_run_func
00095
00096 def get_wait_func(self):
00097 return self.emit_wait_func
00098
00099 def get_spe_end_func(self):
00100 return self.emit_spe_end
00101
00102 def speobj_typespec(self):
00103 return self.spe_context_ptr_t
00104
00105 def create(builder):
00106 return LibSPE2(builder)