view src/main/java/alice/test/codesegment/local/bitonicsort/SetTask.java @ 547:e91a574b69de dispose

remove index
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Tue, 18 Aug 2015 16:15:17 +0900
parents 15eeb439830c
children
line wrap: on
line source

package alice.test.codesegment.local.bitonicsort;

import alice.codesegment.CodeSegment;
import alice.datasegment.CommandType;
import alice.datasegment.Receiver;

public class SetTask extends CodeSegment {
    public static long t;
    private Receiver info1 = ids.create(CommandType.PEEK);
    private Receiver info2 = ids.create(CommandType.TAKE);

    SetTask(){
        info1.setKey("sortconf", this);
        info2.setKey("list", this);
    }

    @Override
    public void run() {
        SortConfig conf = info1.asClass(SortConfig.class);
        DataList list = info2.asClass(DataList.class);

        int sort_count = conf.getSplitNum()*2;
        ods.put("sort_count", sort_count*2);

        int block_num = (conf.getLength() + sort_count- 1) / sort_count;
        ods.put("block_num", block_num);

        System.out.println("sort start");
        t = System.currentTimeMillis();
        {
            int i;
            for (i = 0; i < sort_count / 2; i++) {
                // anonymous datasegmaents should be used.
                ods.put(SetInfo.range[i], new RangeInfo(i,i==(sort_count/2)-1));
                ods.update(SetInfo.array[i*2], list.createDataList(i*2*block_num, block_num));
                ods.update(SetInfo.array[i*2+1], list.createDataList((i*2+1)*block_num, block_num));
                ods.update(SetInfo.count[i], 0);
                new SortPhase(SetInfo.range[i],SetInfo.array[i*2],SetInfo.array[i*2+1],0,SetInfo.count[i]);

            }
        }
        new ShowData(sort_count, sort_count);

    }

}