-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add trisolv to examples/ Signed-off-by: Uday Reddy <udayreddy@gmail.com>
- Loading branch information
1 parent
4b4bfdb
commit 7eb7340
Showing
5 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
*.par.c | ||
*.tiled.c | ||
*.cloog | ||
*.pluto.c | ||
out_* | ||
tiled | ||
orig | ||
par | ||
opt | ||
orig_par |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
SRC= trisolv | ||
|
||
PLCFLAGS = #--unroll | ||
TILEFLAGS = #--l2tile | ||
|
||
include ../common.mk | ||
|
||
$(SRC).par2d.c: | ||
$(PLC) $(SRC).c --tile --parallel --multipipe $(TILEFLAGS) $(PLCFLAGS) | ||
|
||
par2d: $(SRC).par2d.c decls.h util.h | ||
$(CC) $(OPT_FLAGS) -openmp -lm $(SRC).par2d.c -o par2d | ||
|
||
par2d_test: $(SRC).par2d.c decls.h util.h | ||
$(CC) $(OPT_FLAGS) -openmp -lm $(SRC).par2d.c -o par2d_test -DTEST | ||
|
||
ptest: tiled_test par2d_test par_test | ||
./tiled_test 2> out_tiled | ||
export OMP_NUM_THREADS=4 | ||
./par_test 2> out_par4 | ||
diff -q out_tiled out_par4 | ||
export OMP_NUM_THREADS=4; ./par2d_test 2> out_par2d | ||
diff -q out_tiled out_par2d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#define NMAX 3000 | ||
|
||
static double B[NMAX][NMAX], L[NMAX][NMAX]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <math.h> | ||
#include <sys/time.h> | ||
|
||
#include "decls.h" | ||
#include "util.h" | ||
|
||
void trisolv(long N) | ||
{ | ||
long i,j,k; | ||
|
||
#pragma scop | ||
for (i=0;i<=N-1;i++) { | ||
for (j=0;j<=N-1;j++) { | ||
for (k=0;k<=j-1;k++) { | ||
B[j][i]=B[j][i]-L[j][k]*B[k][i]; //S1 ; | ||
|
||
} | ||
B[j][i]=B[j][i]/L[j][j]; // S2 ; | ||
} // for j | ||
} // for i | ||
#pragma endscop | ||
} | ||
|
||
|
||
int main() | ||
{ | ||
long N=NMAX; | ||
int i,j; | ||
double t_start, t_end; | ||
|
||
IF_TIME(t_start = rtclock()); | ||
trisolv(N); | ||
IF_TIME(t_end = rtclock()); | ||
IF_TIME(fprintf(stderr, "%0.6lfs\n", t_end - t_start)); | ||
|
||
if (fopen(".test", "r")) { | ||
for (i = 0; i < N; i++) { | ||
for (j = 0; j < N; j++) { | ||
fprintf(stdout, "%lf ", B[i][j]); | ||
} | ||
fprintf(stdout, "\n"); | ||
} | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <unistd.h> | ||
#include <sys/time.h> | ||
|
||
#ifdef TIME | ||
#define IF_TIME(foo) foo; | ||
#else | ||
#define IF_TIME(foo) | ||
#endif | ||
|
||
void init_array() | ||
{ | ||
int i, j; | ||
|
||
for (i = 0; i < NMAX; i++) { | ||
for (j = 0; j < NMAX; j++) { | ||
B[i][j] = i+j; | ||
L[i][j] = (i+j+3.45) *i*j*0.5; | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
double rtclock() | ||
{ | ||
struct timezone Tzp; | ||
struct timeval Tp; | ||
int stat; | ||
stat = gettimeofday (&Tp, &Tzp); | ||
if (stat != 0) printf("Error return from gettimeofday: %d",stat); | ||
return(Tp.tv_sec + Tp.tv_usec*1.0e-6); | ||
} |