CSE-746 2024 Home Assignment #2


Your task is to write an OpenACC version of the serial code ~syam/CSE746/Assignment2/heat_cube_eps.c (available on both graham and cedar clusters). This code solves a heated cube problem on a 512^3 mesh using a simple finite difference method. Initially the cube's temperature is 0 everywhere, except for the central hot cell which is the heat source (temperature is maintained at 1). The cube's boundaries are heat sinks (temperature is maintained at 0). One hundred iterations are performed, driving the system towards an asymptotic solution. (For true convergence many more steps would be required.) At each iteration, the maximum deviation (eps) of the cell's temperature from the prior iteration is derived (a reduction operation), and printed to stdout. At each iteration, two identical finite difference steps are performed: first computing future array B from current array A, then vice versa. This is done to improve the efficiency of the code (minimise the amount of data copying).

Your OpenACC solution should keep all the features of the serial code - use two separate arrays (A and B), and compute and print the maximum eps at each iteration. Make sure the OpenACC result (eps value at the end) matches that of the serial version. You should get a well performing code using only the following OpenACC directives:

- data directive

- parallel directive

- loop directive

Compiling instructions are given in the header of the serial code. On P100 GPU (graham), you are expected to achieve a speedup of 55x or more. You should put comments inside your code explaining what you are doing.

Marks will be taken off for code bugs (some or all the results are wrong), for insufficient commenting in the code, for poor performance. It must be your own work and you are responsible for adhering to the Senate Policy Statement on Academic Ethics.

Due date: Monday March 11 before midnight , send me the solution through email, to syam@physics.mcmaster.ca . Late submissions will have their mark reduced by 10% every day.

This assignment is worth 20 percent of the course grade.