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

KIT308 Multicore Architecture and Programming

Assignment 2 — SIMD

Aims of the assignment

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

the where there is one there is many approach (WTIOTIM);

structures of arrays;

the use of SIMD for calculation; and

the translation of conditional statements into SIMD.

Due Date

11:55pm Friday 23th of September (Week 10 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 single-threaded code (from assignment 1), the provided base code times, and the

Stage 1, 2, 3, 4, and 5 SIMD implementation on each scene file (all running with the maximum threads natively supported by your CPU).

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"

diretory 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 (NOTE: there are 110 marks available, but it's only possible to receive a maximum of 100). NOTE: if   your code for a particular stage does not correctly produce the expected output images, you will only be able to receive a maximum of half marks for that stage see below for more details.

The following is the breakdown of marks:

Task/Topic

1. Conversion of Distance Calculation to Where There is One there is Many (WTIOTIM)

Correct implementation of WTIOTIM approach to distance function (in Distance.h) to calculate distance to nearest object — i.e. manually inline sphereDist, planeDist, and boxDist (from DFPrimitives.h)

Correct implementation of WTIOTIM approach to distanceAndIndex function i.e. as above, but also manually inline min function (from DFPrimitives.h)

Calculation of distance to centre point of any object handled before the switch statement (requires understanding the union used for the SceneObject datastructure)

2. Conversion of Scene Objects to SoA

Correct declarations of data structures for SoA SIMD form of Scene Object container data (don't delete the AoS versions), and SoA SIMD form of data uses minimal (sensible) amount of memory

Correct code to convert AoS container to dynamically declared SoA structures (conversion should happen after the scene has been loaded)

Correct conversion of distance and distanceAndIndex to use SoA copy of Scene Objects

3. AVX SIMD Conversion of Distance Calculation

A. SIMD Conversion of distance function

Correct and efficient (e.g. no use of if-statements, for-loops, or scalar code) calculation of distances to spheres, planes, and boxes, and correct declaration of loop constants before loop

Correct and efficient (e.g. no use of switch-statements, if-statements, or scalar code) selection of the correct distance given the object type

Correct and efficient (e.g. no use of if-statements, for-loops, or scalar code) calculation of final (scalar) minimum

Correct handling of object list length not being divisible by 8

B. SIMD Conversion of distanceAndIndex function

Correct and efficient (e.g. no use of if-statements, for-loops, or scalar code) calculation of index (corresponding to current minimums)

Correct (i.e. corresponding to scalar minimum) and efficient (e.g. no use of if-statements, for-loops, or scalar code) calculation of final (scalar) object index

4. AVX SIMD Conversion of Rendering

Correct and efficient SIMD conversion of renderSection to calculate 8 values at a time

Correct and efficient SIMD conversion of traceRay to have SIMD arguments (and return values), and it should calculate 8 values at a time

Correct and efficient SIMD conversion of marchRay to have SIMD arguments (and return values), and it should calculate 8 values at a time

Correct and efficient SIMD conversion of distanceAndIndex to have SIMD arguments (and return values), and it should calculate 8 values at a time

5. AVX SIMD Conversion of Lighting

Correct and efficient SIMD conversion of calculateIntersectionResponse, calculateNormal, and distance to calculate 8 values at a time

Correct and efficient SIMD conversion of applyLighting to calculate 8 values at a time

Correct and efficient SIMD conversion of applySpecular, applySoftShadow, and applyAmbientOcclusion to calculate 8 values at a time

Correct and efficient SIMD conversion of applyDiffuse, applyCheckerboard, applyCircles, and applyWood to calculate 8 values at a time

Documentation

Outputs showing timing information for the base assignment code and Stages 1 – 5 (with the maximum threads natively supported by your CPU) on all applicable scene files

Analysis of data (comparisons across the base code and Stages 1 – 5)

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 (-20% for up to 24 hours, -50% for up to 7 days, - 100% after 7 days)

Failure to use the techniques outlined in this unit's lectures and tutorials, resulting in a wildly different solution, using un-     taught libraries (eg. an external library for SIMD, etc.), un-taught techniques, or a vastly different rendering implementation


Marking and Correct Images

As SIMD code is very very difficult to debug as grows exponentially harder as the amount of it grows there will be limited opportunity in the marking process to determine where exactly mistakes have been made, and even less chance of being able to provide fixes to those mistakes.

As a result, if your code for a stage does not produce the expected image, then you will only be eligible for half marks for that stage of the assignment.

In order to work within this constraint, you should attempt translations into SIMD in very small steps (i.e. a single line at a time, or even a partial line at a time). The lectures and live-coding sessions will demonstrate this approach to SIMD translation. You will likely receive more marks for a  partially complete SIMD translation than a fully complete translation that doesn't work 100%.

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]