Mercurial > hg > Members > tatsuki > Alice
changeset 158:3151fd83d3e4 working
might work
author | sugi |
---|---|
date | Tue, 11 Dec 2012 21:01:36 +0900 |
parents | 12c8be670e0f |
children | 6f89183a3f19 |
files | src/alice/test/codesegment/local/bitonicsort/EvenPhase.java src/alice/test/codesegment/local/bitonicsort/OddPhase.java src/alice/test/codesegment/local/bitonicsort/SetTask.java |
diffstat | 3 files changed, 65 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/test/codesegment/local/bitonicsort/EvenPhase.java Tue Dec 11 19:58:47 2012 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/EvenPhase.java Tue Dec 11 21:01:36 2012 +0900 @@ -13,35 +13,44 @@ private Receiver info2; // Array2 private Receiver info3 = ids.create(CommandType.PEEK); // block_num private Receiver info4 = ids.create(CommandType.PEEK); // last_block_num - //private Receiver info5 = ids.create(CommandType.PEEK); // sort_count - //private Receiver info6 = ids.create(CommandType.PEEK); // count + private Receiver info5 = ids.create(CommandType.PEEK); // sort_count + private Receiver info6 = ids.create(CommandType.TAKE); // count - public EvenPhase(String key0 ,String key1){ + public EvenPhase(String key0 ,String key1 ,int index,String key6){ info0.setKey(key0); info1 = ids.create(CommandType.TAKE); - info1.setKey("local",key1); + info1.setKey("local",key1,index); info3.setKey("block_num"); info4.setKey("last_block_num"); + info5.setKey("sort_count"); + info6.setKey(key6); } - public EvenPhase(String key0,String key1,String key2){ + public EvenPhase(String key0,String key1,String key2,int index,String key6){ info0.setKey(key0); info1 = ids.create(CommandType.TAKE); - info1.setKey("local",key1); + info1.setKey("local",key1,index); info2 = ids.create(CommandType.TAKE); - info2.setKey("local",key2); + info2.setKey("local",key2,index); info3.setKey("block_num"); info4.setKey("last_block_num"); + info5.setKey("sort_count"); + info6.setKey(key6); } @Override public void run() { RangeInfo info = info0.asClass(RangeInfo.class); + int sort_count = info5.asInteger(); + int count = info6.asInteger(); + System.out.println("count is" +count); + if (count > sort_count){return;} if (info2==null){ DataList list = info1.asClass(DataList.class); - ods.update("local", info.range+"b", list); - System.out.println("next Odd "+info.range+" "+info.range+"b"+" "+(info.range+1)+"f"); - new OddPhase(info0.key,info.range+"b",(info.range+1)+"f"); + ods.put("local", info.range+"f", "dummy"); + ods.put("local", info.range+"b", list); + //System.out.println("next Odd "+info.range+" "+info.range+"b"+" "+(info.range+1)+"f"); + new OddPhase(info0.key,info.range+"b",(info.range+1)+"f",count,info6.key); } else { DataList list1 = info1.asClass(DataList.class); DataList list2 = info2.asClass(DataList.class); @@ -49,24 +58,24 @@ list2.table = quickSort(list1.table,list2.table); if (!info.lastFlag){ - ods.update("local", info.range+"f", + ods.put("local", info.range+"f", list2.createDataList(0, block_num/2)); - ods.update("local", info.range+"b", + ods.put("local", info.range+"b", list2.createDataList(block_num/2, block_num/2)); - System.out.println("next Odd "+info.range+" "+ info.range+"b"+" "+(info.range+1)+"f"); - new OddPhase(info0.key,info.range+"b",(info.range+1)+"f"); + //System.out.println("next Odd "+info.range+" "+ info.range+"b"+" "+(info.range+1)+"f"); + new OddPhase(info0.key,info.range+"b",(info.range+1)+"f",count,info6.key); } else { int last_block_num = info4.asInteger(); - ods.update("local", info.range+"f", + ods.put("local", info.range+"f", list2.createDataList(0, block_num/2)); - ods.update("local", info.range+"b", + ods.put("local", info.range+"b", list2.createDataList(block_num/2, last_block_num)); - System.out.println("next Odd "+info.range+" "+ info.range+"b"); - new OddPhase(info0.key ,info.range+"b"); + //System.out.println("next Odd "+info.range+" "+ info.range+"b"); + new OddPhase(info0.key ,info.range+"b",count,info6.key); } } - + ods.update("local", info6.key, count+1); } public List<Integer> quickSort(List<Integer> numbers){
--- a/src/alice/test/codesegment/local/bitonicsort/OddPhase.java Tue Dec 11 19:58:47 2012 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/OddPhase.java Tue Dec 11 21:01:36 2012 +0900 @@ -13,31 +13,39 @@ private Receiver info2; // Array2 private Receiver info3 = ids.create(CommandType.PEEK); // block_num private Receiver info4 = ids.create(CommandType.PEEK); // last_block_num - //private Receiver info5 = ids.create(CommandType.PEEK); // sort_count - //private Receiver info6 = ids.create(CommandType.PEEK); // count + private Receiver info5 = ids.create(CommandType.PEEK); // sort_count + private Receiver info6 = ids.create(CommandType.TAKE); // count - public OddPhase(String key0,String key1){ + public OddPhase(String key0 ,String key1 ,int index,String key6){ info0.setKey(key0); info1 = ids.create(CommandType.TAKE); - info1.setKey("local",key1); + info1.setKey("local",key1,index); info3.setKey("block_num"); info4.setKey("last_block_num"); + info5.setKey("sort_count"); + info6.setKey(key6); } - public OddPhase(String key0,String key1,String key2){ + public OddPhase(String key0,String key1,String key2,int index,String key6){ info0.setKey(key0); info1 = ids.create(CommandType.TAKE); - info1.setKey("local",key1); + info1.setKey("local",key1,index); info2 = ids.create(CommandType.TAKE); - info2.setKey("local",key2); + info2.setKey("local",key2,index); info3.setKey("block_num"); info4.setKey("last_block_num"); + info5.setKey("sort_count"); + info6.setKey(key6); } @Override public void run() { RangeInfo info = info0.asClass(RangeInfo.class); int block_num = info3.asInteger(); + int sort_count = info5.asInteger(); + int count = info6.asInteger(); + System.out.println("count is" +count); + if (count > sort_count){return;} if (info2==null){ DataList list = info1.asClass(DataList.class); list.table = quickSort(list.table); @@ -47,22 +55,23 @@ * ソートしている最中にlistを2つ作った方がいいかも。 */ - ods.update("local", info.range+"f", + ods.put("local", info.range+"f", list.createDataList(0, block_num/2)); - ods.update("local", info.range+"b", + ods.put("local", info.range+"b", list.createDataList(block_num/2, block_num/2)); if (info.range==0){ //System.out.println("next Even "+info.range+" "+info.range+"f"); - new EvenPhase(info0.key,info.range+"f"); + new EvenPhase(info0.key,info.range+"f",count,info6.key); } else { //System.out.println("next Even "+info.range+" "+ (info.range-1)+"b"+" "+(info.range)+"f"); - new EvenPhase(info0.key,(info.range-1)+"b",info.range+"f"); + new EvenPhase(info0.key,(info.range-1)+"b",info.range+"f",count,info6.key); } } else { - ods.update("local", info.range+"f",list); - System.out.println("next Even "+info.range+" "+ (info.range-1)+"b"+" "+(info.range)+"f"); - new EvenPhase(info0.key,(info.range-1)+"b",info.range+"f"); + ods.put("local", info.range+"f",list); + ods.put("local", info.range+"b","dummy"); + //System.out.println("next Even "+info.range+" "+ (info.range-1)+"b"+" "+(info.range)+"f"); + new EvenPhase(info0.key,(info.range-1)+"b",info.range+"f",count,info6.key); } } else { @@ -70,20 +79,20 @@ DataList list2 = info2.asClass(DataList.class); list2.table = quickSort(list1.table,list2.table); - ods.update("local", info.range+"f", + ods.put("local", info.range+"f", list2.createDataList(0, block_num/2)); - ods.update("local", info.range+"b", + ods.put("local", info.range+"b", list2.createDataList(block_num/2, block_num/2)); if (info.range==0){ - System.out.println("next Even2b "+info.range+" "+ info.range+"f"); - new EvenPhase(info0.key,info.range+"f"); + //System.out.println("next Even2b "+info.range+" "+ info.range+"f"); + new EvenPhase(info0.key,info.range+"f",count,info6.key); } else { - System.out.println("next Even2b "+info.range+" "+ (info.range-1)+"b"+" "+info.range+"f"); - new EvenPhase(info0.key,(info.range-1)+"b",info.range+"f"); + //System.out.println("next Even2b "+info.range+" "+ (info.range-1)+"b"+" "+info.range+"f"); + new EvenPhase(info0.key,(info.range-1)+"b",info.range+"f",count,info6.key); } } - + ods.update("local", info6.key, count+1); } public List<Integer> quickSort(List<Integer> numbers){
--- a/src/alice/test/codesegment/local/bitonicsort/SetTask.java Tue Dec 11 19:58:47 2012 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/SetTask.java Tue Dec 11 21:01:36 2012 +0900 @@ -34,15 +34,19 @@ for (i = 0;i< conf.getSplitNum()-1; i++){ ods.put("local", "range"+i, new RangeInfo(i,false)); ods.update("local", key+i, list.createDataList(i*block_num, block_num)); - new OddPhase("range"+i,key+i); + ods.update("local", "count"+i, 0); + new OddPhase("range"+i,key+i,0,"count"+i); } // 最後のblockは端数 ods.put("local", "range"+i, new RangeInfo(i,true)); ods.update("local", key+i, list.createDataList(i*block_num, last_block_num)); - new OddPhase("range"+i,key+i); + ods.update("local", "count"+i, 0); + new OddPhase("range"+i,key+i,0,"count"+i); + } - ods.update("local", "count", sort_count-1); + ods.put("local", "count", sort_count); + }