345
|
1 package alice.test.codesegment.local.bitonicsort;
|
|
2
|
|
3 import alice.codesegment.CodeSegment;
|
|
4 import alice.datasegment.CommandType;
|
|
5 import alice.datasegment.Receiver;
|
|
6
|
|
7 public class SetTask extends CodeSegment {
|
|
8 public static long t;
|
|
9 private Receiver info1 = ids.create(CommandType.PEEK);
|
|
10 private Receiver info2 = ids.create(CommandType.TAKE);
|
|
11
|
|
12 SetTask(){
|
|
13 info1.setKey("sortconf");
|
|
14 info2.setKey("list");
|
|
15 }
|
|
16
|
|
17 @Override
|
|
18 public void run() {
|
|
19 SortConfig conf = info1.asClass(SortConfig.class);
|
|
20 DataList list = info2.asClass(DataList.class);
|
|
21
|
|
22 int sort_count = conf.getSplitNum()*2;
|
|
23 ods.put("sort_count", sort_count*2);
|
|
24
|
|
25 int block_num = (conf.getLength() + sort_count- 1) / sort_count;
|
|
26 ods.put("block_num", block_num);
|
|
27
|
|
28 System.out.println("sort start");
|
|
29 t = System.currentTimeMillis();
|
|
30 {
|
|
31 int i;
|
|
32 for (i = 0; i < sort_count / 2; i++) {
|
|
33 // anonymous datasegmaents should be used.
|
|
34 ods.put(SetInfo.range[i], new RangeInfo(i,i==(sort_count/2)-1));
|
|
35 ods.update(SetInfo.array[i*2], list.createDataList(i*2*block_num, block_num));
|
|
36 ods.update(SetInfo.array[i*2+1], list.createDataList((i*2+1)*block_num, block_num));
|
|
37 ods.update(SetInfo.count[i], 0);
|
|
38 new SortPhase(SetInfo.range[i],SetInfo.array[i*2],SetInfo.array[i*2+1],0,SetInfo.count[i]);
|
|
39
|
|
40 }
|
|
41 new ShowData(i*2, sort_count);
|
|
42
|
|
43 }
|
|
44
|
|
45
|
|
46 }
|
|
47
|
|
48 }
|