def chunky_odd_even_merge_sort(a): for i,j in enumerate(a): j.store_in_mem(i * j.sizeof()) l = 1 while l < len(a): l *= 2 k = 1 while k < l: k *= 2 def round(): for i in range(len(a)): a[i] = type(a[i]).load_mem(i * a[i].sizeof()) for i in range(len(a) / l): for j in range(l / k): base = i * l + j step = l / k if k == 2: a[base], a[base+step] = cond_swap(a[base], a[base+step]) else: b = a[base:base+k*step:step] for m in range(base + step, base + (k - 1) * step, 2 * step): a[m], a[m+step] = cond_swap(a[m], a[m+step]) for i in range(len(a)): a[i].store_in_mem(i * a[i].sizeof()) chunk = MPCThread(round, 'sort-%d-%d-%03x' % (l,k,random.randrange(256**3))) chunk.start() chunk.join() #round() for i in range(len(a)): a[i] = type(a[i]).load_mem(i * a[i].sizeof())
def on_first_call(self, wrapped_function): self.thread = MPCThread(wrapped_function, self.name, args=self.compile_args)