use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class HashtableBenchCMP_RamCounter method main.
public static void main(String[] args) {
// Initialization for Ram access counter
int count0 = 0;
int count1 = 0;
int us0 = 0;
int us1 = 0;
int count_result = 0;
int us_result = 0;
System.out.println("Bandwidth:");
// Initialize the data Array
String string = new String("Test");
data = new DataClass[max];
for (int i = 0; i < max; i++) {
data[i] = new DataClass(new Integer(i), string + i);
}
htable = new Hashtable(max);
SysDevice sys = IOFactory.getFactory().getSysDevice();
// Calculates the bounds for each CPU
low_array = new int[sys.nrCpu];
high_array = new int[sys.nrCpu];
int rest = max % sys.nrCpu;
int div = max / sys.nrCpu;
for (int j = 0; j < sys.nrCpu; j++) {
if (j == 0) {
low_array[j] = j * div;
if (rest != 0) {
high_array[j] = (j + 1) * div;
rest--;
} else {
high_array[j] = (j + 1) * div - 1;
}
} else {
low_array[j] = high_array[j - 1] + 1;
if (rest != 0) {
high_array[j] = high_array[j - 1] + div + 1;
rest--;
} else {
high_array[j] = high_array[j - 1] + div;
}
}
}
for (int i = 0; i < sys.nrCpu - 1; i++) {
Runnable r = new HashtableBenchCMP_RamCounter(i + 1, low_array[i + 1], high_array[i + 1], htable);
Startup.setRunnable(r, i);
}
// Startpoint of measuring
count0 = sys.deadLine;
//us0 = sys.uscntTimer;
// Clockcycles
us0 = Native.rdMem(Const.IO_CNT);
// Start of all other CPUs
sys.signal = 1;
// Fill Hashtable
for (int j = low_array[0]; j < (high_array[0]); j++) {
if (htable.containsKey(data[j].key)) {
} else {
htable.put(data[j].key, data[j].value);
}
}
// Read Table
for (int i = low_array[0]; i < high_array[0]; i++) {
if (htable.contains(data[i].value)) {
data[i].value = (String) htable.get(data[i].key);
}
}
// Delete Hashtable
for (int i = low_array[0]; i < (high_array[0]); i++) {
if (htable.containsKey(data[i].key)) {
htable.remove(data[i].key);
}
}
while (true) {
util.Timer.usleep(500);
synchronized (lock) {
if (signal == sys.nrCpu - 1)
break;
}
}
// End of measurement
// Clockcycles
us1 = Native.rdMem(Const.IO_CNT);
count1 = sys.deadLine;
count_result = count1 - count0;
us_result = us1 - us0;
LowLevel.msg("RAM Accesses:", count_result);
LowLevel.lf();
LowLevel.msg("Time us:", us_result);
LowLevel.lf();
LowLevel.msg("in %:", count_result / (us_result / 100));
LowLevel.lf();
}
use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class RtHWMethTestCMP method main.
/**
* @param args
*/
public static void main(String[] args) {
failure = false;
test_count = new int[NR_METHODS + 1];
error = "no error";
System.out.println("Beginning test...");
Random rng = new Random();
int i;
SysDevice sys = IOFactory.getFactory().getSysDevice();
// the test threads are created here
for (i = 1; i <= NR_METHODS; ++i) {
int max = MAX_PERIOD - MIN_PERIOD;
int period = rng.nextInt() % max;
if (period < 0)
period = -period;
period += MIN_PERIOD;
RtHWMethTestCMP th = new RtHWMethTestCMP(1 + ((i - 1) / sys.nrCpu), period, i);
th.setProcessor((i - 1) % sys.nrCpu);
}
// the reporter thread (highest priority) is created here
RtHWMethTestCMP reporter = new RtHWMethTestCMP(NR_METHODS, 500000, 0);
reporter.setProcessor(0);
// then the main() method just starts the mission
System.out.println("Start mission");
RtThread.startMission();
System.out.println("Mission started");
}
use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class RtHelloCMP method main.
/**
* @param args
*/
public static void main(String[] args) {
msg = new Vector();
System.out.println("Hello World from CPU 0");
SysDevice sys = IOFactory.getFactory().getSysDevice();
System.out.println("Nur of CPUs: " + sys.nrCpu);
for (int i = 0; i < NR_THREADS; ++i) {
RtHelloCMP th = new RtHelloCMP(1, 1000 * 1000);
th.id = i;
th.setProcessor(i % sys.nrCpu);
}
System.out.println("Start mission");
// start mission and other CPUs
RtThread.startMission();
System.out.println("Mission started");
// print their messages
for (; ; ) {
RtThread.sleepMs(5);
int size = msg.size();
if (size != 0) {
StringBuffer sb = (StringBuffer) msg.remove(0);
// converts StringBuffer to a String and creates garbage
for (int i = 0; i < sb.length(); ++i) {
System.out.print(sb.charAt(i));
}
}
}
}
use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class ArrayIssue method measure.
static void measure() {
if (MEASURE)
ts = Native.rdMem(Const.IO_CNT);
SysDevice sys = IOFactory.getFactory().getSysDevice();
sys.wd = 1;
a[0] = 0;
if (MEASURE)
te = Native.rdMem(Const.IO_CNT);
}
use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class Measure method lowLevel.
public static void lowLevel() {
SysDevice sys = IOFactory.getFactory().getSysDevice();
int[] a = new int[1];
// A 0.1s interval in multiple of the TDMA round plus 1
int shift = CLOCK_FREQ / 10 / (TDMA_LENGTH) * TDMA_LENGTH + 1;
// get measurement overhead
int time = Native.rd(Const.IO_CNT);
time = Native.rd(Const.IO_CNT) - time;
int off = time;
int start = sys.cntInt + shift;
for (int i = 0; i < 3 * TDMA_LENGTH; ++i) {
sys.deadLine = start;
time = Native.rd(Const.IO_CNT);
a[0] = 1;
time = Native.rd(Const.IO_CNT) - time;
System.out.println(time - off);
start += shift;
}
}
Aggregations