Skip to content

Commit cc19a82

Browse files
committed
Temperature / temperature_last arrays now declared in the C file, like in FORTRAN. Therefore obsolete comment about temperature and temperature_last declared in a util file removed.
1 parent 8d44b37 commit cc19a82

File tree

15 files changed

+48
-33
lines changed

15 files changed

+48
-33
lines changed

src/C/hybrid_cpu.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515

1616
/**
1717
* @brief Runs the experiment.
18-
* @details The variables "temperature" and "temperature_last" are two arrays of doubles declared in util.h.
1918
* @pre The macro 'ROWS' contains the number of rows (excluding boundaries) per MPI process. It is a define passed as a compilation flag, see makefile.
2019
* @pre The macro 'COLUMNS' contains the number of columns (excluding boundaries). It is a define passed as a compilation flag, see makefile.
2120
**/
2221
int main(int argc, char *argv[])
2322
{
23+
// Temperature grid.
24+
double temperature[ROWS+2][COLUMNS+2];
25+
// Temperature grid from last iteration
26+
double temperature_last[ROWS+2][COLUMNS+2];
27+
// Current iteration.
2428
int iteration = 0;
2529
// Temperature change for our MPI process
2630
double dt;
@@ -61,7 +65,7 @@ int main(int argc, char *argv[])
6165
}
6266

6367
// Initialise temperatures and temperature_last including boundary conditions
64-
initialise_temperatures();
68+
initialise_temperatures(temperature, temperature_last);
6569

6670
///////////////////////////////////
6771
// -- Code from here is timed -- //
@@ -144,7 +148,7 @@ int main(int argc, char *argv[])
144148
{
145149
if(my_rank == comm_size - 1)
146150
{
147-
track_progress(iteration);
151+
track_progress(iteration, temperature);
148152
}
149153
}
150154
}

src/C/hybrid_gpu.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515

1616
/**
1717
* @brief Runs the experiment.
18-
* @details The variables "temperature" and "temperature_last" are two arrays of doubles declared in util.h.
1918
* @pre The macro 'ROWS' contains the number of rows (excluding boundaries) per MPI process. It is a define passed as a compilation flag, see makefile.
2019
* @pre The macro 'COLUMNS' contains the number of columns (excluding boundaries). It is a define passed as a compilation flag, see makefile.
2120
**/
2221
int main(int argc, char *argv[])
2322
{
23+
// Temperature grid.
24+
double temperature[ROWS+2][COLUMNS+2];
25+
// Temperature grid from last iteration
26+
double temperature_last[ROWS+2][COLUMNS+2];
27+
// Current iteration.
2428
int iteration = 0;
2529
// Temperature change for our MPI process
2630
double dt;
@@ -60,7 +64,7 @@ int main(int argc, char *argv[])
6064
}
6165

6266
// Initialise temperatures and temperature_last including boundary conditions
63-
initialise_temperatures();
67+
initialise_temperatures(temperature, temperature_last);
6468

6569
///////////////////////////////////
6670
// -- Code from here is timed -- //
@@ -147,7 +151,7 @@ int main(int argc, char *argv[])
147151
{
148152
if(my_rank == comm_size - 1)
149153
{
150-
track_progress(iteration);
154+
track_progress(iteration, temperature);
151155
}
152156
}
153157
}

src/C/mpi.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515

1616
/**
1717
* @brief Runs the experiment.
18-
* @details The variables "temperature" and "temperature_last" are two arrays of doubles declared in util.h.
1918
* @pre The macro 'ROWS' contains the number of rows (excluding boundaries) per MPI process. It is a define passed as a compilation flag, see makefile.
2019
* @pre The macro 'COLUMNS' contains the number of columns (excluding boundaries). It is a define passed as a compilation flag, see makefile.
2120
**/
2221
int main(int argc, char *argv[])
2322
{
23+
// Temperature grid.
24+
double temperature[ROWS+2][COLUMNS+2];
25+
// Temperature grid from last iteration
26+
double temperature_last[ROWS+2][COLUMNS+2];
27+
// Current iteration
2428
int iteration = 0;
2529
// Temperature change for our MPI process
2630
double dt;
@@ -55,7 +59,7 @@ int main(int argc, char *argv[])
5559
}
5660

5761
// Initialise temperatures and temperature_last including boundary conditions
58-
initialise_temperatures();
62+
initialise_temperatures(temperature, temperature_last);
5963

6064
///////////////////////////////////
6165
// -- Code from here is timed -- //
@@ -136,7 +140,7 @@ int main(int argc, char *argv[])
136140
{
137141
if(my_rank == comm_size - 1)
138142
{
139-
track_progress(iteration);
143+
track_progress(iteration, temperature);
140144
}
141145
}
142146
}

src/C/openacc.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
/**
1414
* @brief Runs the experiment.
15-
* @details The variables "temperature" and "temperature_last" are two arrays of doubles declared in util.h.
1615
* @pre The macro 'ROWS' contains the number of rows (excluding boundaries). It is a define passed as a compilation flag, see makefile.
1716
* @pre The macro 'COLUMNS' contains the number of columns (excluding boundaries). It is a define passed as a compilation flag, see makefile.
1817
**/
@@ -22,13 +21,17 @@ int main(int argc, char *argv[])
2221
(void)argc;
2322
// We indicate that we are not going to use argv.
2423
(void)argv;
24+
// Temperature grid.
25+
double temperature[ROWS+2][COLUMNS+2];
26+
// Temperature grid from last iteration
27+
double temperature_last[ROWS+2][COLUMNS+2];
2528
// Current iteration.
2629
unsigned int iteration = 0;
2730
// Largest change in temperature.
2831
double dt = 100;
2932

3033
// Initialise temperatures and temperature_last including boundary conditions
31-
initialise_temperatures();
34+
initialise_temperatures(temperature, temperature_last);
3235

3336
///////////////////////////////////
3437
// -- Code from here is timed -- //
@@ -73,7 +76,7 @@ int main(int argc, char *argv[])
7376
if((iteration % PRINT_FREQUENCY) == 0)
7477
{
7578
#pragma acc update host(temperature)
76-
track_progress(iteration);
79+
track_progress(iteration, temperature);
7780
}
7881
}
7982
}

src/C/openmp.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
/**
1616
* @brief Runs the experiment.
17-
* @details The variables "temperature" and "temperature_last" are two arrays of doubles declared in util.h.
1817
* @pre The macro 'ROWS' contains the number of rows (excluding boundaries). It is a define passed as a compilation flag, see makefile.
1918
* @pre The macro 'COLUMNS' contains the number of columns (excluding boundaries). It is a define passed as a compilation flag, see makefile.
2019
**/
@@ -24,13 +23,17 @@ int main(int argc, char *argv[])
2423
(void)argc;
2524
// We indicate that we are not going to use argv.
2625
(void)argv;
26+
// Temperature grid.
27+
double temperature[ROWS+2][COLUMNS+2];
28+
// Temperature grid from last iteration
29+
double temperature_last[ROWS+2][COLUMNS+2];
2730
// Current iteration.
2831
unsigned int iteration = 0;
2932
// Largest change in temperature.
3033
double dt = 100;
3134

3235
// Initialise temperatures and temperature_last including boundary conditions
33-
initialise_temperatures();
36+
initialise_temperatures(temperature, temperature_last);
3437

3538
///////////////////////////////////
3639
// -- Code from here is timed -- //
@@ -80,7 +83,7 @@ int main(int argc, char *argv[])
8083
// Periodically print test values
8184
if((iteration % PRINT_FREQUENCY) == 0)
8285
{
83-
track_progress(iteration);
86+
track_progress(iteration, temperature);
8487
}
8588
}
8689

src/C/serial.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
/**
1414
* @brief Runs the experiment.
15-
* @details The variables "temperature" and "temperature_last" are two arrays of doubles declared in util.h.
1615
* @pre The macro 'ROWS' contains the number of rows (excluding boundaries). It is a define passed as a compilation flag, see makefile.
1716
* @pre The macro 'COLUMNS' contains the number of columns (excluding boundaries). It is a define passed as a compilation flag, see makefile.
1817
**/
@@ -22,13 +21,17 @@ int main(int argc, char *argv[])
2221
(void)argc;
2322
// We indicate that we are not going to use argv.
2423
(void)argv;
24+
// Temperature grid.
25+
double temperature[ROWS+2][COLUMNS+2];
26+
// Temperature grid from last iteration
27+
double temperature_last[ROWS+2][COLUMNS+2];
2528
// Current iteration.
2629
unsigned int iteration = 0;
2730
// Largest change in temperature.
2831
double dt = 100;
2932

3033
// Initialise temperatures and temperature_last including boundary conditions
31-
initialise_temperatures();
34+
initialise_temperatures(temperature, temperature_last);
3235

3336
///////////////////////////////////
3437
// -- Code from here is timed -- //
@@ -68,7 +71,7 @@ int main(int argc, char *argv[])
6871
// Periodically print test values
6972
if((iteration % PRINT_FREQUENCY) == 0)
7073
{
71-
track_progress(iteration);
74+
track_progress(iteration, temperature);
7275
}
7376
}
7477

src/C/util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <mpi.h>
1212
#endif
1313

14-
void initialise_temperatures()
14+
void initialise_temperatures(double temperature[ROWS+2][COLUMNS+2], double temperature_last[ROWS+2][COLUMNS+2])
1515
{
1616
//////////////////////////////////////
1717
// Previous iteration temperatures //
@@ -98,7 +98,7 @@ void initialise_temperatures()
9898
#endif
9999
}
100100

101-
void track_progress(int iteration)
101+
void track_progress(int iteration, double temperature[ROWS+2][COLUMNS+2])
102102
{
103103
int number_of_cells = 6;
104104
if(iteration == 100)

src/C/util.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
/// Number of iterations between two summary printings
1414
#define PRINT_FREQUENCY 100
1515

16-
/// Temperature grid.
17-
double temperature[ROWS+2][COLUMNS+2];
18-
/// Temperature grid from last iteration
19-
double temperature_last[ROWS+2][COLUMNS+2];
2016
/// Time taken during the entire simulation, in seconds
2117
double timer_simulation;
2218

@@ -25,13 +21,14 @@ double timer_simulation;
2521
* @details Initialises the arrays temperature and temperature_last with the original temperature grid.
2622
* @note This function must NOT be altered in ANY WAY.
2723
**/
28-
void initialise_temperatures();
24+
void initialise_temperatures(double temperature[ROWS+2][COLUMNS+2], double temperature_last[ROWS+2][COLUMNS+2]);
2925
/**
3026
* @brief Prints information used for tracking.
3127
* @param[in] iter The iteration at which printing progress.
28+
* @param[in] temperature The 2D array that contains the current iteration temperatures.
3229
* @note This function must NOT be altered in ANY WAY.
3330
**/
34-
void track_progress(int iter);
31+
void track_progress(int iter, double temperature[ROWS+2][COLUMNS+2]);
3532
/**
3633
* @brief Prints the time needed to complete the simulation as well as debugging information.
3734
* @details In addition to printing the total simulation time, it also prints the iteration at which convergence was reached as well as the last temperature delta observed. The first one is to evaluate performance while the last two help check program correctness.
@@ -56,4 +53,4 @@ void start_timer(double* timer);
5653
**/
5754
void stop_timer(double* timer);
5855

59-
#endif
56+
#endif

src/FORTRAN/hybrid_cpu.F90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
!> @author Ludovic Capelli
66

77
!> @brief Runs the experiment.
8-
!> @details The variables "temperature" and "temperature_last" are two arrays of doubles declared in util.h.
98
!> @pre The macro 'ROWS' contains the number of rows (excluding boundaries). It is a define passed as a compilation flag, see makefile.
109
!> @pre The macro 'COLUMNS' contains the number of columns (excluding boundaries) per MPI process. It is a define passed as a compilation flag, see makefile.
1110
PROGRAM serial

src/FORTRAN/hybrid_gpu.F90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
!> @author Ludovic Capelli
66

77
!> @brief Runs the experiment.
8-
!> @details The variables "temperature" and "temperature_last" are two arrays of doubles declared in util.h.
98
!> @pre The macro 'ROWS' contains the number of rows (excluding boundaries). It is a define passed as a compilation flag, see makefile.
109
!> @pre The macro 'COLUMNS' contains the number of columns (excluding boundaries) per MPI process. It is a define passed as a compilation flag, see makefile.
1110
PROGRAM serial

src/FORTRAN/mpi.F90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
!> @author Ludovic Capelli
66

77
!> @brief Runs the experiment.
8-
!> @details The variables "temperature" and "temperature_last" are two arrays of doubles declared in util.h.
98
!> @pre The macro 'ROWS' contains the number of rows (excluding boundaries). It is a define passed as a compilation flag, see makefile.
109
!> @pre The macro 'COLUMNS' contains the number of columns (excluding boundaries) per MPI process. It is a define passed as a compilation flag, see makefile.
1110
PROGRAM serial

src/FORTRAN/openacc.F90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
!> @author Ludovic Capelli
66

77
!> @brief Runs the experiment.
8-
!> @details The variables "temperature" and "temperature_last" are two arrays of doubles declared in util.h.
98
!> @pre The macro 'ROWS' contains the number of rows (excluding boundaries). It is a define passed as a compilation flag, see makefile.
109
!> @pre The macro 'COLUMNS' contains the number of columns (excluding boundaries). It is a define passed as a compilation flag, see makefile.
1110
PROGRAM serial

src/FORTRAN/openmp.F90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
!> @author Ludovic Capelli
66

77
!> @brief Runs the experiment.
8-
!> @details The variables "temperature" and "temperature_last" are two arrays of doubles declared in util.h.
98
!> @pre The macro 'ROWS' contains the number of rows (excluding boundaries). It is a define passed as a compilation flag, see makefile.
109
!> @pre The macro 'COLUMNS' contains the number of columns (excluding boundaries). It is a define passed as a compilation flag, see makefile.
1110
PROGRAM serial

src/FORTRAN/serial.F90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
!> @author Ludovic Capelli
66

77
!> @brief Runs the experiment.
8-
!> @details The variables "temperature" and "temperature_last" are two arrays of doubles declared in util.h.
98
!> @pre The macro 'ROWS' contains the number of rows (excluding boundaries). It is a define passed as a compilation flag, see makefile.
109
!> @pre The macro 'COLUMNS' contains the number of columns (excluding boundaries). It is a define passed as a compilation flag, see makefile.
1110
PROGRAM serial

src/FORTRAN/util.F90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ MODULE util
1616
CONTAINS
1717
!> @brief Initialises the temperatures.
1818
!> @details Initialises the arrays temperature and temperature_last with the original temperature grid.
19+
!> @param[out] temperature The 2D array that contains the current iteration temperatures.
20+
!> @param[out] temperature_last The 2D array that contains the last iteration temperatures.
1921
!> @note This function must NOT be altered in ANY WAY.
2022
SUBROUTINE initialise_temperatures(temperature, temperature_last)
2123
IMPLICIT NONE
@@ -92,6 +94,7 @@ END SUBROUTINE initialise_temperatures
9294

9395
!> @brief Prints information used for tracking.
9496
!> @param[in] iter The iteration at which printing progress.
97+
!> @param[in] temperature The 2D array that contains the current iteration temperatures.
9598
!> @note This function must NOT be altered in ANY WAY.
9699
SUBROUTINE track_progress(iter, temperature)
97100
IMPLICIT NONE

0 commit comments

Comments
 (0)