Search in sources :

Example 1 with SysDevice

use of com.jopdesign.io.SysDevice in project jop by jop-devel.

the class TestLocalChannels method main.

/**
	 * @param args
	 */
public static void main(String[] args) {
    msg = new Vector();
    // TODO Auto-generated method stub
    System.out.println("Hello CSP world from processor 0.");
    SysDevice sys = IOFactory.getFactory().getSysDevice();
    Runnable r = new TestLocalChannels(1);
    Startup.setRunnable(r, 0);
    // start the other CPUs
    sys.signal = 1;
    // set the WD LED for the simulation
    sys.wd = 1;
    // an In channels requires an Out end for sending ACK
    InPort c_in = new InPort(2, messages);
    OutPort ack = new OutPortLocal(1, messages);
    Channel ch = new Channel(ack, c_in);
    int[] inbuf;
    System.out.println("P0 to receive.");
    RtThread.sleepMs(10);
    int size = msg.size();
    if (size != 0) {
        StringBuffer sb = (StringBuffer) msg.remove(0);
        System.out.println(sb);
    }
    inbuf = ch.receive();
    System.out.println("received " + inbuf[0] + ", " + inbuf[1] + ", " + inbuf[2]);
    System.out.println("P0 done.");
}
Also used : SysDevice(com.jopdesign.io.SysDevice) Vector(java.util.Vector)

Example 2 with SysDevice

use of com.jopdesign.io.SysDevice in project jop by jop-devel.

the class AES method main.

public static void main(String[] args) {
    SysDevice sys = IOFactory.getFactory().getSysDevice();
    AES aes = new AES();
    // Initialization for benchmarking
    int start = 0;
    int stop = 0;
    int time = 0;
    System.out.println("AES Benchmark");
    int nrCpu = Runtime.getRuntime().availableProcessors();
    if (nrCpu < 4) {
        throw new Error("Not enogh CPUs");
    }
    // ni must be translated from proc index to NoC address!
    Startup.setRunnable(aes.source, 0);
    Startup.setRunnable(aes.enc, 1);
    Startup.setRunnable(aes.dec, 2);
    aes.reset(1000);
    // start the other CPUs
    System.out.println("starting cpus.");
    sys.signal = 1;
    start = (int) System.currentTimeMillis();
    aes.sink.run();
    // End of measurement
    stop = (int) System.currentTimeMillis();
    System.out.println("StartTime: " + start);
    System.out.println("StopTime: " + stop);
    time = stop - start;
    System.out.println("TimeSpent: " + time);
    System.out.println("Result = " + aes.sink.ok);
}
Also used : SysDevice(com.jopdesign.io.SysDevice)

Example 3 with SysDevice

use of com.jopdesign.io.SysDevice in project jop by jop-devel.

the class BenchCsp method main.

/**
	 * @param args
	 */
public static void main(String[] args) {
    msg = new Vector();
    System.out.println("Hello CSP World from CPU 0");
    SysDevice sys = IOFactory.getFactory().getSysDevice();
    Runnable r = new BenchCsp(1);
    Startup.setRunnable(r, 0);
    // Startup.setRunnable(new BenchCspNew(2), 1);
    // start the other CPUs
    sys.signal = 1;
    // set the WD LED for the simulation
    sys.wd = 1;
    int start, end, off;
    start = sys.cntInt;
    end = sys.cntInt;
    off = end - start;
    // receive n words via CSP, 1-word packets
    start = sys.cntInt;
    for (int i = 0; i < CNT; ++i) {
        while (!((Native.rd(NoC.NOC_REG_STATUS) & NoC.NOC_MASK_RCV) != 0)) ;
        int val = Native.rd(NoC.NOC_REG_RCVDATA);
        //int src = Native.rd(NoC.NOC_REG_RCVSRC);
        // aka writeReset();
        Native.wr(0, NoC.NOC_REG_RCVRESET);
    //System.out.print(" Received ");
    //System.out.print(val);
    //System.out.print(" from ");
    //System.out.print(src);
    }
    end = sys.cntInt;
    System.out.println("Communication via HW CSP, many 1-word packets");
    System.out.println(CNT + " words received in " + (end - start - off) + " cycles");
    // receive n words via CSP, n-word packet
    start = sys.cntInt;
    while (!((Native.rd(NoC.NOC_REG_STATUS) & NoC.NOC_MASK_RCV) != 0)) ;
    for (int i = 0; i < CNT; ++i) {
        int val = Native.rd(NoC.NOC_REG_RCVDATA);
    // System.out.print(" Received ");
    // System.out.print(val);
    }
    // aka writeReset();
    Native.wr(0, NoC.NOC_REG_RCVRESET);
    end = sys.cntInt;
    System.out.println("Communication via HW CSP, one N-word packet");
    System.out.println(CNT + " words received in " + (end - start - off) + " cycles");
    // receive n words via shared memory
    start = sys.cntInt;
    // start the other copy thread
    startCopy = true;
    while (!endCopy) {
        ;
    }
    for (int i = 0; i < 100; ++i) {
        int val = buffer[i];
    // System.out.print(" Received ");
    // System.out.print(val);
    }
    end = sys.cntInt;
    System.out.println("Communication via shared memory");
    System.out.println(CNT + " words received in " + (end - start - off) + " cycles");
}
Also used : SysDevice(com.jopdesign.io.SysDevice) Vector(java.util.Vector)

Example 4 with SysDevice

use of com.jopdesign.io.SysDevice in project jop by jop-devel.

the class EratosthenesCsp3 method main.

/**
		 * @param args
		 */
public static void main(String[] args) {
    // Initialization for benchmarking 
    int start = 0;
    int stop = 0;
    int time = 0;
    System.out.println("Eratosthenes Sieve, v3, SPM");
    SysDevice sys = IOFactory.getFactory().getSysDevice();
    int nrCpu = Runtime.getRuntime().availableProcessors();
    for (int i = 0; i < nrCpu; i++) {
        int ni = i + 1;
        if (ni == nrCpu)
            ni = 0;
        System.out.println(cpuIndex2NoCAddress(ni));
        RtThread rtt = new EratosthenesCsp3(i, cpuIndex2NoCAddress(ni));
        rtt.setProcessor(i);
    }
    System.out.println("starting cpus.");
    // start threads and other cpus
    RtThread.startMission();
    // give threads time to setup their memory
    // RtThread.sleepMs(100);
    // using clock cycles instead
    // (int) System.currentTimeMillis();
    start = sys.cntInt;
    // let them run
    go = true;
    // wait for finish
    while (true) {
        synchronized (lock) {
            if (// nrCpu) // just the first needs to finish!
            endCalculation == 1)
                break;
        }
    }
    // End of measurement
    // (int) System.currentTimeMillis();
    stop = sys.cntInt;
    System.out.println("StartTime: " + start);
    System.out.println("StopTime: " + stop);
    time = stop - start;
    System.out.println("TimeSpent: " + time);
}
Also used : RtThread(joprt.RtThread) SysDevice(com.jopdesign.io.SysDevice)

Example 5 with SysDevice

use of com.jopdesign.io.SysDevice in project jop by jop-devel.

the class EratosthenesCsp4 method main.

/**
		 * @param args
		 */
public static void main(String[] args) {
    // Initialization for benchmarking 
    int start = 0;
    int stop = 0;
    int time = 0;
    System.out.println("Eratosthenes Sieve, v4, shared memory");
    SysDevice sys = IOFactory.getFactory().getSysDevice();
    int nrCpu = Runtime.getRuntime().availableProcessors();
    wrCPU = new boolean[nrCpu];
    lvlCPU = new int[nrCpu];
    candidateCPU = new int[nrCpu];
    for (int i = 0; i < nrCpu; i++) {
        int ni = i + 1;
        if (ni == nrCpu)
            ni = 0;
        RtThread rtt = new EratosthenesCsp4(i, ni);
        rtt.setProcessor(i);
        wrCPU[i] = false;
    }
    System.out.println("starting cpus.");
    // start threads and other cpus
    RtThread.startMission();
    // give threads time to setup their memory
    RtThread.sleepMs(100);
    // using clock cycles instead
    // (int) System.currentTimeMillis();
    start = sys.cntInt;
    // let them run
    go = true;
    // wait for finish
    while (true) {
        synchronized (lock) {
            if (// nrCpu) // just the first needs to finish!
            endCalculation == 1)
                break;
        }
    }
    // End of measurement
    // (int) System.currentTimeMillis();
    stop = sys.cntInt;
    System.out.println("StartTime: " + start);
    System.out.println("StopTime: " + stop);
    time = stop - start;
    System.out.println("TimeSpent: " + time);
}
Also used : RtThread(joprt.RtThread) SysDevice(com.jopdesign.io.SysDevice)

Aggregations

SysDevice (com.jopdesign.io.SysDevice)30 Vector (java.util.Vector)5 Hashtable (java.util.Hashtable)2 BenchLift (jbe.BenchLift)2 RtThread (joprt.RtThread)2 OutPort (com.jopdesign.io.OutPort)1 RetryException (com.jopdesign.sys.RetryException)1 Random (java.util.Random)1 AbortException (rttm.AbortException)1