Browse Source

sequential and parallel now share lists

master
mortie 7 years ago
parent
commit
f45688a75c
4 changed files with 17 additions and 20 deletions
  1. 9
    6
      inf2440/hw4/Main.java
  2. 4
    10
      inf2440/hw4/Oblig4.java
  3. 2
    2
      inf2440/hw4/Parallel.java
  4. 2
    2
      inf2440/hw4/Sequential.java

+ 9
- 6
inf2440/hw4/Main.java View File

@@ -6,8 +6,15 @@ class Main {
}

NPunkter17 points = new NPunkter17(Integer.parseInt(args[0]));
Oblig4 seq = new Sequential(points);
Oblig4 par = new Parallel(points);
int[] x = new int[points.n];
int[] y = new int[points.n];

System.out.println("Filling...");
points.fyllArrayer(x, y);
System.out.println("Done.");

Oblig4 seq = new Sequential(x, y, points.n);
Oblig4 par = new Parallel(x, y, points.n);

Timer tseq = run(seq, null);
run(par, tseq);
@@ -17,10 +24,6 @@ class Main {
}

static Timer run(Oblig4 o, Timer base) {
System.out.println(o.name+": filling...");
o.fill();
System.out.println("Done.");

Timer t = new Timer().start();
o.solve();
t.end();

+ 4
- 10
inf2440/hw4/Oblig4.java View File

@@ -10,19 +10,13 @@ abstract class Oblig4 {
NPunkter17 points;
String name = "Oblig4";

Oblig4(NPunkter17 points) {
this.points = points;
n = points.n;
x = new int[n];
y = new int[n];
Oblig4(int[] x, int[] y, int n) {
this.x = x;
this.y = y;
this.n = n;
coHull = new IntList();
}

// Fill x and y arrays
void fill() {
points.fyllArrayer(x, y);
}

// This method should be overwritten by each implementation.
// It's responsible for filling in MAX_X, MAX_Y, and coHull
abstract void solve();

+ 2
- 2
inf2440/hw4/Parallel.java View File

@@ -3,8 +3,8 @@ class Parallel extends Oblig4 {
Runtime.getRuntime().availableProcessors(),
16);

Parallel(NPunkter17 points) {
super(points);
Parallel(int[] x, int[] y, int n) {
super(x, y, n);
name = "Parallel";
}


+ 2
- 2
inf2440/hw4/Sequential.java View File

@@ -1,7 +1,7 @@
class Sequential extends Oblig4 {

Sequential(NPunkter17 points) {
super(points);
Sequential(int[] x, int[] y, int n) {
super(x, y, n);
name = "Sequential";
}


Loading…
Cancel
Save