use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class TestConcurrent method main.
/**
* @param args
*/
public static void main(String[] args) {
int i;
long l;
System.out.println("Test concurrent access");
SysDevice sys = IOFactory.getFactory().getSysDevice();
if (sys.nrCpu == 1) {
System.out.println("Single core is implicit cache coherent");
System.exit(0);
}
TestConcurrent tc = new TestConcurrent();
// test r/w/r
i = tc.a;
// force a cache state change
i = 123456789;
tc.a = 123;
i = tc.a;
if (i != 123) {
System.out.println("Error in r/w/r on field");
}
l = tc.lo;
// force a cache state change
i = 123456789;
tc.lo = 456;
l = tc.lo;
if (l != 456) {
System.out.println("Error in r/w/r on long field");
}
// set runnable
Startup.setRunnable(tc, 0);
// set some default values
volStaticInt = 123;
volStaticLong = -1;
tc.a = 11;
tc.b = 22;
tc.volInt = 1;
tc.volLong = 1L;
// get it into the cache
i = tc.volInt;
// start the other CPU(s)
sys.signal = 1;
while (tc.volInt == 1) {
;
}
System.out.println("Volatile read ok");
// get tc.a into the cache
synchronized (tc) {
i = tc.a;
}
tc.volInt = 3;
while (i == 11) {
synchronized (tc) {
i = tc.a;
}
}
System.out.println("Test finished ok");
}
use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class EjipBenchCMP method main.
public static void main(String[] args) {
// Initialization for benchmarking
int start = 0;
int stop = 0;
int time = 0;
init();
SysDevice sys = IOFactory.getFactory().getSysDevice();
int nrCpu = Runtime.getRuntime().availableProcessors();
System.out.println("Ejip benchmark");
// our work list
Runnable[] work = new Runnable[] { // first one (or more) can printout
new Runnable() {
public void run() {
ipLink.run();
}
}, new Runnable() {
public void run() {
resultServer();
}
}, new Runnable() {
public void run() {
request();
}
}, new Runnable() {
public void run() {
macServer();
}
}, // more heavy tasks at the end
new Runnable() {
public void run() {
net.run();
}
} };
Runner[] runner = Runner.distributeWorklist(work, nrCpu);
for (int i = 0; i < nrCpu - 1; i++) {
Startup.setRunnable(runner[i + 1], i);
}
received = 0;
System.out.println("Start");
// Start of measurement
// Start of all other CPUs
sys.signal = 1;
start = (int) System.currentTimeMillis();
runner[0].run();
// End of measurement
stop = (int) System.currentTimeMillis();
time = stop - start;
System.out.println("TimeSpent: " + time);
}
use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class HelloCMP 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();
for (int i = 0; i < sys.nrCpu - 1; ++i) {
Runnable r = new HelloCMP(i + 1);
Startup.setRunnable(r, i);
}
// start the other CPUs
sys.signal = 1;
// print their messages
for (; ; ) {
int size = msg.size();
if (size != 0) {
StringBuffer sb = (StringBuffer) msg.remove(0);
System.out.println(sb);
}
}
}
use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class LiftBenchCMP method main.
public static void main(String[] args) {
// Initialization for benchmarking
int start = 0;
int stop = 0;
int time = 0;
System.out.println("Lift Benchmark:");
SysDevice sys = IOFactory.getFactory().getSysDevice();
bm_array = new BenchMark[sys.nrCpu];
loop_array = new int[sys.nrCpu];
// Calculates the number of loops for each CPU
int rest = cnt % sys.nrCpu;
for (int j = 0; j < sys.nrCpu; j++) {
if (rest != 0) {
loop_array[j] = cnt / sys.nrCpu + 1;
rest--;
} else
loop_array[j] = cnt / sys.nrCpu;
}
bm_array[0] = new BenchLift();
for (int i = 0; i < sys.nrCpu - 1; i++) {
bm_array[i + 1] = new BenchLift();
Runnable r = new LiftBenchCMP(i + 1, loop_array[i + 1], bm_array[i + 1]);
Startup.setRunnable(r, i);
}
// Insert for comparison with single CPU performance
//loop_array[0]=cnt;
// Start of measurement
start = LowLevel.timeMillis();
// Start of all other CPUs
sys.signal = 1;
// Start of CPU0
bm_array[0].test(loop_array[0]);
while (true) {
synchronized (lock) {
if (signal == sys.nrCpu - 1)
break;
}
}
// End of measurement
stop = LowLevel.timeMillis();
System.out.println("StartTime: " + start);
System.out.println("StopTime: " + stop);
time = stop - start;
System.out.println("TimeSpent: " + time);
for (int i = 0; i < sys.nrCpu; ++i) {
System.out.println("CPU " + i + " calculated " + loop_array[i] + " loops");
}
}
use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class LiftBenchCMP_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:");
SysDevice sys = IOFactory.getFactory().getSysDevice();
bm_array = new BenchMark[sys.nrCpu];
loop_array = new int[sys.nrCpu];
// Calculates the number of loops for each CPU
int rest = cnt % sys.nrCpu;
for (int j = 0; j < sys.nrCpu; j++) {
if (rest != 0) {
loop_array[j] = cnt / sys.nrCpu + 1;
rest--;
} else
loop_array[j] = cnt / sys.nrCpu;
}
bm_array[0] = new BenchLift();
for (int i = 0; i < sys.nrCpu - 1; i++) {
bm_array[i + 1] = new BenchLift();
Runnable r = new LiftBenchCMP_RamCounter(i + 1, loop_array[i + 1], bm_array[i + 1]);
Startup.setRunnable(r, i);
}
// Startpoint of measuring
count0 = sys.deadLine;
//us0 = sys.uscntTimer;
// Clockcycles
us0 = Native.rdMem(Const.IO_CNT);
// Start of CPU0
bm_array[0].test(loop_array[0]);
// Start of all other CPUs
sys.signal = 1;
while (true) {
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();
}
Aggregations