Difference between revisions of "Parallel Raytracer Assignment"

From CSE231 Wiki
Jump to navigation Jump to search
Line 62: Line 62:
 
Hang onto the sectionSize in an instance variable.  You will need it.
 
Hang onto the sectionSize in an instance variable.  You will need it.
  
===sectionsCreator===
+
===sectionSize===
{{Sequential|Function<RayTraceContext, List<Section>> sectionsCreator()}}
+
{{Sequential|int sectionSize()}}
  
Return the sectionsCreator you stored in an instance variable.
+
Return the sectionSize you stored in an instance variable.
  
 
===rayTrace===
 
===rayTrace===

Revision as of 17:51, 27 April 2023

Code To Investigate

RayTraceContext

public interface RayTraceContext {
	int width();

	int height();

	void mark(int xMin, int yMin, int xMaxExclusive, int yMaxExclusive);

	void markAndRender(int xMin, int yMin, int xMaxExclusive, int yMaxExclusive);
}

Scheduler

public interface Scheduler {
	void void_fork(Runnable runnable);
}

Section

public final class Section {
	private final int xMin;
	private final int yMin;
	private final int xMaxExclusive;
	private final int yMaxExclusive;

	public Section(int xMin, int yMin, int xMaxExclusive, int yMaxExclusive) {
		this.xMin = xMin;
		this.yMin = yMin;
		this.xMaxExclusive = xMaxExclusive;
		this.yMaxExclusive = yMaxExclusive;
	}

	public int xMin() {
		return xMin;
	}

	public int yMin() {
		return yMin;
	}

	public int xMaxExclusive() {
		return xMaxExclusive;
	}

	public int yMaxExclusive() {
		return yMaxExclusive;
	}
}

Code To Implement

SplitFourWayRayTracer

class: SplitFourWayRayTracer.java Java.png
methods: rayTrace
package: raytrace.exercise
source folder: student/src/main/java

rayTrace

method: public void rayTrace(RayTraceContext context, Scheduler scheduler) Parallel.svg (parallel implementation required)

LoopRayTracer

class: LoopRayTracer.java Java.png
methods: constructor
sectionsCreator
rayTrace
package: raytrace.exercise
source folder: student/src/main/java

constructor

method: public LoopRayTracer(int sectionSize Sequential.svg (sequential implementation only)

Hang onto the sectionSize in an instance variable. You will need it.

sectionSize

method: int sectionSize() Sequential.svg (sequential implementation only)

Return the sectionSize you stored in an instance variable.

rayTrace

method: public void rayTrace(RayTraceContext context, Scheduler scheduler) Parallel.svg (parallel implementation required)

Use the sectionsCreator to create a list of Sections.

List<Section> sections = sectionsCreator.apply(context); 

Then create a markAndRender task for each section.

DivideAndConquerRayTracer

class: DivideAndConquerRayTracer.java Java.png
methods: constructor
thresholdPredicate
rayTraceKernel
package: raytrace.exercise
source folder: student/src/main/java

constructor

method: public DivideAndConquerRayTracer(BiPredicate<Integer, Integer> thresholdPredicate) Sequential.svg (sequential implementation only)

Hang onto the thresholdPredicate in an instance variable. You will need it.

thresholdPredicate determines the threshold for division. If thresholdPredicate.test() is true, then the section is still large enough for more division of work.

thresholdPredicate

method: public BiPredicate<Integer, Integer> thresholdPredicate() Sequential.svg (sequential implementation only)

Return the thresholdPredicate you stored in an instance variable.

rayTrace

method: public void rayTrace(RayTraceContext context, Scheduler scheduler) Parallel.svg (parallel implementation required)

Checking Your Solution

Visualization

class: RayTracerViz.java VIZ
package: raytrace.viz
source folder: student/src/main/java

Correctness

class: _ParallelRayTracerTestSuite.java Junit.png
package: raytrace.exercise
source folder: testing/src/test/java