gem5/splash2/codes/apps/ocean/non_contiguous_partitions/laplacalc.C
Sanchayan Maity 2fcc51c2c1 Commit splash2 benchmark
While at it also add the libpthread static library amd m5op_x86
for matrix multiplication test code as well.

Note that the splash2 benchmark code does not comply with gem5
coding guidelines. Academic guys never seem to follow 80 columns
and no whitespace guideline :(.
2017-04-26 20:50:15 +05:30

69 lines
2.4 KiB
C

/*************************************************************************/
/* */
/* Copyright (c) 1994 Stanford University */
/* */
/* All rights reserved. */
/* */
/* Permission is given to use, copy, and modify this software for any */
/* non-commercial purpose as long as this copyright notice is not */
/* removed. All other uses, including redistribution in whole or in */
/* part, are forbidden without prior written permission. */
/* */
/* This software is provided with absolutely no warranty and no */
/* support. */
/* */
/*************************************************************************/
/* **************************************************************
end of subroutine jacobcalc
**************************************************************
performs the laplacian calculation for a subblock. */
#include <cmath>
#include <cstdio>
#include <ctime>
#include "decs.h"
void laplacalc(double x[IMAX][JMAX], double z[IMAX][JMAX], long firstrow, long lastrow, long firstcol, long lastcol, long numrows, long numcols)
{
long iindex;
long indexp1;
long indexm1;
long ip1;
long im1;
long i;
long j;
for (iindex=firstcol;iindex<=lastcol;iindex++) {
indexp1 = iindex+1;
indexm1 = iindex-1;
for (i=firstrow;i<=lastrow;i++) {
ip1 = i+1;
im1 = i-1;
z[i][iindex] = factlap*(x[ip1][iindex]+x[im1][iindex]+x[i][indexp1]+
x[i][indexm1]-4.*x[i][iindex]);
}
}
if (firstrow == 1) {
for (j=firstcol;j<=lastcol;j++) {
z[0][j] = 0.0;
}
}
if ((firstrow+numrows) == im-1) {
for (j=firstcol;j<=lastcol;j++) {
z[im-1][j] = 0.0;
}
}
if (firstcol == 1) {
for (j=firstrow;j<=lastrow;j++) {
z[j][0] = 0.0;
}
}
if ((firstcol+numcols) == jm-1) {
for (j=firstrow;j<=lastrow;j++) {
z[j][jm-1] = 0.0;
}
}
}