def test_counts(): init_threads(-1,-1) for slice in xrange(5): with Log.scope('counting slice %d'%slice): sections = sections_t(slice,all_boards_sections(slice,8)) good_counts = meaningless_counts(all_boards(slice,1)) good_nodes = sum(product(section_shape(s)) for s in sections.sections) for key in 0,1,17: with Log.scope('partition key %d'%key): partition = random_partition_t(key,1,sections) if key else simple_partition_t(1,sections,False) store = compacting_store_t(estimate_block_heap_size(partition,0)) blocks = meaningless_block_store(partition,0,0,store) Log.write('blocks = %d, correct = %d'%(blocks.total_nodes,good_nodes)) assert blocks.total_nodes==good_nodes bad_counts = sum_section_counts(sections.sections,blocks.section_counts) Log.write('bad counts = %s\ngood counts = %s'%(bad_counts,good_counts)) assert all(bad_counts==good_counts)
def test_partition(): random.seed(56565656) init_threads(-1,-1) slices = [] for slice in xrange(7): # Grab half the sections of this slice sections = all_boards_sections(slice,8) random.shuffle(sections) slices.append(sections_t(slice,sections[:(len(sections)+1)//2])) for sections in descendent_sections([[4,4],[4,4],[4,5],[5,4]],35): if len(sections.sections): slices.append(sections) for sections in slices: for ranks in 1,2,3,5: for key in 0,1,17: with Log.scope('partition test: slice %d, ranks %d, key %d'%(sections.slice,ranks,key)): partition = random_partition_t(key,ranks,sections) if key else simple_partition_t(ranks,sections,False) partition_test(partition)