Page MenuHomec4science

algorithm_test.c
No OneTemporary

File Metadata

Created
Thu, Nov 7, 19:56

algorithm_test.c

/*
============================================================================
Filename : algorithm.c
Author : Your names go here
SCIPER : Your SCIPER numbers
============================================================================
*/
#include <math.h>
#define INPUT(I,J) input[(I)*length+(J)]
#define OUTPUT(I,J) output[(I)*length+(J)]
void simulate(double *input, double *output, int threads, int length, int iterations)
{
double *temp;
omp_set_num_threads(threads);
const int iT = 1;
const int jT = 1;
#pragma omp parallel
{
for(int n=0; n < iterations; n++)
{
#pragma omp for collapse(2)
for(int ii=1; ii<length-1; ii+=iT)
{
for(int jj=1; jj<length-1; jj+=jT)
{
for(int i=ii; i<ii+iT; i++)
{
for(int j=jj; j<jj+jT; j++)
{
if ( ((i == length/2-1) || (i== length/2)) && ((j == length/2-1) || (j == length/2)) )
continue;
if((i<length-1)&&(j<length-1))
{
OUTPUT(i,j) = (INPUT(i-1,j-1) + INPUT(i-1,j) + INPUT(i-1,j+1) + INPUT(i,j-1) + INPUT(i,j) + INPUT(i,j+1) + INPUT(i+1,j-1) + INPUT(i+1,j) + INPUT(i+1,j+1))/9;
}
}
}
}
}
temp = input;
input = output;
output = temp;
}
}
}

Event Timeline