Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

KIT308 Multicore Architecture and Programming

Assignment 3 — OpenCL

Aims of the assignment

The purpose of this assignment is to give you experience at writing a program using OpenCL programming techniques. This assignment will give you an opportunity to demonstrate your understanding of:

setting up OpenCL structures;

passing memory from the CPU to the GPU;

creating memory formats that work across devices; and

the translation of C/C++ code to OpenCL code.

Due Date

11:55pm Friday 14th of October (Week 13 of Semester)

Late assignments will only be accepted in exceptional circumstances and provided that the proper procedures have been followed (see the  School Office or this link for details) assignments which are submitted late without good reason will be subject to mark penalties if they are accepted at all (see the School office or this link for details on this as well).

Forms to request extensions of time to submit assignments are available from the Discipline of ICT office. Requests must be accompanied by suitable documentation and should be submitted before the assignment due date .

Assignment Submission

Your assignment is to be submitted electronically via MyLO and should contain:

A .zip (or .rar) containing a Visual Studio Solution containing a project for each attempted stage of the assignment (in the format provided in the downloadable materials provided below).

A document containing:

A table of timing information comparing the original provided base code times against the Stage 4 OpenCL implementation on each

scene file .

An analysis of the above timing data .

You do not need to (and shouldn't) submit executables, temporary object files, or images. In particular, you must delete the " .vs"

directory before submission as it just Visual Studio temporary files and 100s of MBs. Do not however delete the "Scenes" folder or the "Outputs" folder (but do delete the images within this one).

Marking

This assignment will be marked out of 100. The following is the breakdown of marks:

Task/Topic

1. OpenCL Setup and Data Transfer

CPU-side

Correct OpenCL setup and kernel creation

Well thought out and correct OpenCL buffers and kernel arguments for representing scene data

Correct creation of two-dimensional kernel job

Correct memory management (i.e. freeing resources)

Inclusion of (helpful) error handling

Correct alignment of datastructures

GPU-side

Correct declaration of equivalent OpenCL types and datastructures (for primitives, sceneobjects, etc.)

Output (via printf) that verifies that the scene has been correctly transferred (for full marks, this information should only print once per execution)

Correctly fills output buffer with colour

Correctly calculates the number of samples that have been rendered

NOTE: this will require you to update the same memory location multiple times from the GPU, which might involve some research in to how to do this correctly it's ok to skip this step and continue to Stage 2 if it proves difficult

2. Basic Rendering

OpenCL implementation of renderer that colours spheres red, boxes green, and planes blue (and everything else black) — i.e. no lighting, material application, reflection, refraction, or shadowing, etc.

NOTE: this stage should ignore the -samples command-line argument, i.e. no supersampling, each pixel should only be sampled once

Correctly handles all scenes

3. Rendering with Lighting

OpenCL implementation of renderer with correct lighting for spheres, planes, and boxes but no shadows or complex materials (and also no supersampling)

Correctly handles all scenes

4. Full Rendering

OpenCL implementation of renderer with correct lighting, shadowing, complex materials, reflection, refraction, and

supersampling

Correctly handles all scenes

5. Rendering Large/Complex Images

OpenCL implementation (with all features of Stage 4) that renders all the Stage 5 tests by splitting up the render job into multiple smaller parts (i.e. like Stage 2 or 3 of assignment 1)

Added a command-line option to be able to control the size of the individual OpenCL jobs / parts

(e.g. -blockSize or -chunkSize)

Documentation

Outputs showing timing information for Stage 4 on all applicable scene files

Analysis of data (comparison between Stage 4 execution times and single-threaded, multi-threaded, and SIMD versions of the code)

Penalties

Failure to comply with submission instructions (eg. no cover sheet, incorrect submission of files, abnormal solution/project structure, etc.)

Poor programming style (eg. insufficient / poor comments, poor variable names, poor indenting, obfuscated code without documentation, compiler warnings, etc.)

Lateness (-5% per day, up to -50% for up to 10 days, - 100% after 10 days)


Programming Style

This assignment is not focussed on programming style (although it is concerned with efficient code), but you should endeavour to follow good programming practices. You should, for example:

comment your code;

use sensible variables names;

use correct and consistent indenting; and

internally document (with comments) any notable design decisions.

[NOTE: any examples in the provided assignment materials that don't live up to the above criteria, should be considered to be deliberate examples of what not to do and are provided to aid your learning ;P]