瀏覽代碼

sequential and parallel now share lists

master
mortie 7 年之前
父節點
當前提交
f45688a75c
共有 4 個文件被更改,包括 17 次插入20 次删除
  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 查看文件

} }


NPunkter17 points = new NPunkter17(Integer.parseInt(args[0])); 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); Timer tseq = run(seq, null);
run(par, tseq); run(par, tseq);
} }


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

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

+ 4
- 10
inf2440/hw4/Oblig4.java 查看文件

NPunkter17 points; NPunkter17 points;
String name = "Oblig4"; 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(); coHull = new IntList();
} }


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

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

+ 2
- 2
inf2440/hw4/Parallel.java 查看文件

Runtime.getRuntime().availableProcessors(), Runtime.getRuntime().availableProcessors(),
16); 16);


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



+ 2
- 2
inf2440/hw4/Sequential.java 查看文件

class Sequential extends Oblig4 { class Sequential extends Oblig4 {


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



Loading…
取消
儲存