Mercurial > hg > Members > tatsuki > Alice
changeset 159:6f89183a3f19 working
add check Class
author | sugi |
---|---|
date | Wed, 12 Dec 2012 00:19:03 +0900 |
parents | 3151fd83d3e4 |
children | e5837e1d242f |
files | src/alice/test/codesegment/local/bitonicsort/EvenPhase.java src/alice/test/codesegment/local/bitonicsort/MakeData.java src/alice/test/codesegment/local/bitonicsort/OddPhase.java src/alice/test/codesegment/local/bitonicsort/SetTask.java src/alice/test/codesegment/local/bitonicsort/ShowData.java |
diffstat | 5 files changed, 95 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/test/codesegment/local/bitonicsort/EvenPhase.java Tue Dec 11 21:01:36 2012 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/EvenPhase.java Wed Dec 12 00:19:03 2012 +0900 @@ -43,10 +43,15 @@ 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;} + //System.out.println("count is " +count); + if (info2==null){ DataList list = info1.asClass(DataList.class); + if (count > sort_count){ + check(list.table); + ods.update("local", "array"+info.range, list); + return; + } 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"); @@ -54,6 +59,14 @@ } else { DataList list1 = info1.asClass(DataList.class); DataList list2 = info2.asClass(DataList.class); + if (count > sort_count){ + List<Integer> list = new LinkedList<Integer>(); + list.addAll(list1.table); + list.addAll(list2.table); + check(list); + ods.update("local", "array"+info.range, new DataList(list)); + return; + } int block_num = info3.asInteger(); list2.table = quickSort(list1.table,list2.table); @@ -77,6 +90,15 @@ } ods.update("local", info6.key, count+1); } + public void check(List<Integer> numbers){ + for (int i=0 ;i+1<numbers.size();i++){ + if (numbers.get(i)>numbers.get(i+1)){ + System.out.println("MISS "+ numbers.get(i)+" > "+numbers.get(i+1)); + return; + } + } + //System.out.println(numbers); + } public List<Integer> quickSort(List<Integer> numbers){ if (numbers.size() < 1)
--- a/src/alice/test/codesegment/local/bitonicsort/MakeData.java Tue Dec 11 21:01:36 2012 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/MakeData.java Wed Dec 12 00:19:03 2012 +0900 @@ -23,9 +23,12 @@ int size = conf.getLength(); for (int i = 0;i<size;i++){ Random rnd = new Random(); - //DataInfo info = new DataInfo(rnd.nextInt(Integer.MAX_VALUE),i); list.table.add(rnd.nextInt(Integer.MAX_VALUE)); } + /* + for (int i = 16;i>0;i--){ + list.table.add(i); + }*/ ods.update("local", "list", list); }
--- a/src/alice/test/codesegment/local/bitonicsort/OddPhase.java Tue Dec 11 21:01:36 2012 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/OddPhase.java Wed Dec 12 00:19:03 2012 +0900 @@ -44,10 +44,14 @@ 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;} + //System.out.println("count is " +count); if (info2==null){ DataList list = info1.asClass(DataList.class); + if (count > sort_count){ + //check(list.table); + ods.update("local", "array"+info.range, list); + return; + } list.table = quickSort(list.table); if (!info.lastFlag){ /* @@ -77,6 +81,14 @@ } else { DataList list1 = info1.asClass(DataList.class); DataList list2 = info2.asClass(DataList.class); + if (count > sort_count){ + List<Integer> list = new LinkedList<Integer>(); + list.addAll(list1.table); + list.addAll(list2.table); + //check(list); + ods.update("local", "array"+info.range, new DataList(list)); + return; + } list2.table = quickSort(list1.table,list2.table); ods.put("local", info.range+"f", @@ -94,6 +106,15 @@ } ods.update("local", info6.key, count+1); } + public void check(List<Integer> numbers){ + for (int i=0 ;i+1<numbers.size();i++){ + if (numbers.get(i)>numbers.get(i+1)){ + System.out.println("MISS "+ numbers.get(i)+" > "+numbers.get(i+1)); + return; + } + } + //System.out.println(numbers); + } public List<Integer> quickSort(List<Integer> numbers){ if (numbers.size() < 1)
--- a/src/alice/test/codesegment/local/bitonicsort/SetTask.java Tue Dec 11 21:01:36 2012 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/SetTask.java Wed Dec 12 00:19:03 2012 +0900 @@ -22,7 +22,7 @@ // sort完了に必要な回数 int sort_count = conf.getSplitNum(); - ods.put("local", "sort_count", sort_count); + ods.put("local", "sort_count", sort_count*2); // 1つのタスクでsortするdata数 int block_num = (conf.getLength() + conf.getSplitNum() - 1 ) / sort_count; ods.put("local", "block_num", block_num); @@ -43,10 +43,9 @@ ods.update("local", key+i, list.createDataList(i*block_num, last_block_num)); ods.update("local", "count"+i, 0); new OddPhase("range"+i,key+i,0,"count"+i); - + System.out.println(i); + new ShowData(i); } - ods.put("local", "count", sort_count); - }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/codesegment/local/bitonicsort/ShowData.java Wed Dec 12 00:19:03 2012 +0900 @@ -0,0 +1,41 @@ +package alice.test.codesegment.local.bitonicsort; + +import java.util.LinkedList; +import java.util.List; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class ShowData extends CodeSegment{ + + private Receiver[] info = new Receiver[10]; + int cnt; + public ShowData(int cnt) { + this.cnt = cnt; + for (int i=0;i<cnt;i++){ + info[i] = ids.create(CommandType.PEEK); + info[i].setKey("local", "array"+i,1); + } + } + + @Override + public void run() { + + List<Integer> list = new LinkedList<Integer>(); + for (int i=0;i<cnt;i++){ + list.addAll(info[i].asClass(DataList.class).table); + } + for (int i=0 ;i+1<list.size();i++){ + if (list.get(i)>list.get(i+1)){ + System.out.println("MISS "+ list.get(i)+" > "+list.get(i+1)); + return; + } + } + System.out.println("OK"); + System.out.println(list); + + } + + +}