Skip to content
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
0390a96
[Change] default_heterogeneous and Neura Script
MeowMJ Jul 10, 2025
15bfb0f
[UPDATE] default_heterogeneous
MeowMJ Jul 10, 2025
3b2080e
[UPDATE] default_heterogeneous
MeowMJ Jul 10, 2025
5176aa0
[UPDATE] DFG.cpp
MeowMJ Jul 10, 2025
8a7071d
Tan helps with the new bug. Merge branch 'master' of https://github.c…
MeowMJ Jul 17, 2025
cbad764
[UPDATE] NeuraDemo.py, relu+histogram.c
MeowMJ Jul 22, 2025
889654f
[UPDATE] NeuraDemo and output
MeowMJ Jul 24, 2025
84416b8
[UODATE] NeuraDemo.py
MeowMJ Aug 1, 2025
e7fd994
[UPDATE]python script
MeowMJ Aug 14, 2025
137ad86
[UPDATE] all
MeowMJ Aug 28, 2025
b4e4d8c
[DELETE] unnessarsy
MeowMJ Oct 4, 2025
6c54efc
[UPDATE] expandable python demo
MeowMJ Oct 27, 2025
0b15e22
[slove one conflict]
MeowMJ Oct 27, 2025
797f153
[ADD] workflow for tools/expandable
MeowMJ Nov 2, 2025
1598845
[UPDATE] workflow for tools/expandable
MeowMJ Nov 2, 2025
571ef5c
[UPDATE] expandable mapping
MeowMJ Nov 5, 2025
9fbf220
[UPDATE] workflow for tools/expandable
MeowMJ Nov 5, 2025
0fbf202
[UPDATE] workflow for tools/expandable
MeowMJ Nov 5, 2025
432cc6a
[UPDATE] add python env in workflow
MeowMJ Nov 5, 2025
120f845
[UPDATE] add python env in workflow
MeowMJ Nov 5, 2025
daf3029
[UPDATE] add python env in workflow
MeowMJ Nov 5, 2025
6a75fb5
[UPDATE] add python env in workflow
MeowMJ Nov 5, 2025
7dab033
[UPDATE] add python env in workflow
MeowMJ Nov 5, 2025
93e807b
[REMOVE] not relavant thing
MeowMJ Nov 5, 2025
6605a75
[ADD] needed space in CGRA.cpp
MeowMJ Nov 7, 2025
7893b65
[UPDATE] scheduler.py and visualization.py
MeowMJ Nov 7, 2025
80505c9
Delete tools/expandable/tmp directory
MeowMJ Nov 7, 2025
c8cf535
[UPDATE] python script
MeowMJ Nov 17, 2025
6ab3823
[SOLVE] merge conflict
MeowMJ Nov 18, 2025
a1cc3cf
Merge branch 'master' of https://github.com/MeowMJ/CGRA-Mapper
MeowMJ Nov 18, 2025
2c78e86
[DELETE] json and update visualization.py
MeowMJ Nov 19, 2025
a50499b
[FIX] error in scheduler.py
MeowMJ Nov 19, 2025
6a63273
[FIX] missing module
MeowMJ Nov 19, 2025
7f6d2ad
[UPDATE] demo.sh
MeowMJ Nov 20, 2025
db9ad8c
[UPDATE] fig condig
MeowMJ Nov 20, 2025
c7fe250
[UPDATE] schedule hete
MeowMJ Nov 21, 2025
b3cbb1b
[TRY] fix git action bug
MeowMJ Nov 26, 2025
9b67f2f
[TRY] fix git action bug
MeowMJ Nov 26, 2025
96c2427
[TRY] fix git action bug
MeowMJ Nov 26, 2025
5227b4f
[TRY] fix git action bug
MeowMJ Nov 26, 2025
27292da
[TRY] fix git action bug
MeowMJ Nov 26, 2025
d34c480
[TRY] fix git action bug
MeowMJ Nov 26, 2025
4da85fb
[TRY] fix git action bug
MeowMJ Nov 26, 2025
5ccaebb
[TRY] fix git action bug
MeowMJ Nov 26, 2025
128f2e4
[UPDATE] Fig drawing
MeowMJ Dec 9, 2025
9a0b855
[DEBUG] mismatched coloum
MeowMJ Dec 9, 2025
e7b96af
[UPDATE] Fig drawing
MeowMJ Dec 9, 2025
2d6fecf
[DEBUG] mismatched coloum
MeowMJ Dec 9, 2025
04657c0
[UPDATE] final version of python demo
MeowMJ Dec 9, 2025
a167a56
[UPDATE] comment the print sentence
MeowMJ Dec 10, 2025
8de59c8
[UPDATE] document name
MeowMJ Dec 10, 2025
c31bd19
[UPDATE] shorten CI/CD time
MeowMJ Dec 10, 2025
e96323f
[UPDATE] shorten CI/CD time
MeowMJ Dec 10, 2025
157f917
[UPDATE] file structure
MeowMJ Dec 11, 2025
23cd249
[UPDATE] baseline remove hete
MeowMJ Dec 11, 2025
0c858db
[UPDATE] readme
MeowMJ Dec 11, 2025
6a5c05e
[UPDATE] demo testme true
MeowMJ Dec 11, 2025
cb5665b
[UPDATE] english comment
MeowMJ Dec 11, 2025
785c335
[UPDATE] english comment
MeowMJ Dec 11, 2025
86d11a7
[UPDATE] TEST CI/CD
MeowMJ Dec 11, 2025
83d3ff7
Merge branch 'master' of https://github.com/tancheng/CGRA-Mapper
MeowMJ Dec 13, 2025
9572c2e
[MERGE] conflict
MeowMJ Dec 13, 2025
976ce4a
[UPDATE] fusionStrategy
MeowMJ Dec 13, 2025
efe04cb
[UPDATE] visualizer
MeowMJ Dec 14, 2025
ea98d16
[REMOVE] visualizer_copy
MeowMJ Dec 14, 2025
4e1570a
[UPDATE] add label in figs
MeowMJ Dec 14, 2025
8ba2ee0
[UPDATE] relu+histogram
MeowMJ Dec 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ jobs:
sudo apt-get -y install llvm-12 llvm-12-dev llvm-12-tools clang-12
sudo apt-get -y install build-essential

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.7.16'

- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
pip install eventlet pandas matplotlib

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
Expand Down Expand Up @@ -105,3 +115,8 @@ jobs:
sh compile.sh
sh run.sh
sh verify.sh

- name: Test expandable automatic script
working-directory: ${{github.workspace}}/tools/expandable
run: |
./demo.sh
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ build*/
*.ll
*.dot
*.bc
.vscode/
.venv/
9 changes: 7 additions & 2 deletions src/DFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ DFG::DFG(Function& t_F, list<Loop*>* t_loops, bool t_targetFunction,
bool needsCycleCalculation = false;
for (auto strategy : *t_fusionStrategy) {
if (strategy == "default_heterogeneous") {
combineMulAdd("CoT");
combinePhiAdd("BrT");
combine("phi", "add", "Ctrl");
combine("phi", "fadd", "Ctrl");
combine("fcmp", "select", "Ctrl");
combine("icmp", "select", "Ctrl");
combine("icmp", "br", "Ctrl");
combine("fcmp", "br", "Ctrl");
tuneForPattern();
needsCycleCalculation = true;
}
else if (strategy == "nonlinear") {
Expand Down
9 changes: 8 additions & 1 deletion src/Mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,13 @@ void Mapper::showUtilization(CGRA* t_cgra, DFG* t_dfg, int t_II,
total_active_tiles += 1;
}
float avg_tile_overall_utilization = 0.0;
float max_tile_overall_utilization = 0.0;
float avg_tile_fu_utilization = 0.0;
float avg_tile_xbar_utilization = 0.0;
for (int tile = 0; tile < t_cgra->getFUCount(); ++tile) {
if (max_tile_overall_utilization < tile_overall_utilization[tile]) {
max_tile_overall_utilization = tile_overall_utilization[tile];
}
avg_tile_overall_utilization += tile_overall_utilization[tile];
avg_tile_fu_utilization += tile_fu_utilization[tile];
avg_tile_xbar_utilization += tile_xbar_utilization[tile];
Expand All @@ -674,8 +678,10 @@ void Mapper::showUtilization(CGRA* t_cgra, DFG* t_dfg, int t_II,
avg_tile_overall_utilization /= total_active_tiles;
avg_tile_fu_utilization /= total_active_tiles;
avg_tile_xbar_utilization /= total_active_tiles;
//max_tile_overall_utilization /= total_active_tiles;

cout << "tile avg fu utilization: " << avg_tile_fu_utilization*100 << "%; avg xbar utilization: " << avg_tile_xbar_utilization*100 << "%; avg overall utilization: " << avg_tile_overall_utilization*100 << "%" << endl;
cout << "tile avg fu utilization: " << avg_tile_fu_utilization*100 << "%; avg xbar utilization: " << avg_tile_xbar_utilization*100 << "%; avg overall utilization: " << avg_tile_overall_utilization*t_II*100 << "%" << endl;
cout << "max overall utilization: " << max_tile_overall_utilization*t_II*100 << "%" << endl;

// Collects the histogram of tiles' utilization.
// Histogram for the number of tiles that have utilization of 0%.
Expand Down Expand Up @@ -1006,6 +1012,7 @@ void Mapper::showSchedule(CGRA* t_cgra, DFG* t_dfg, int t_II,
cout<<"[Mapping II: "<<t_II<<"]"<<endl;

if (t_parameterizableCGRA) {
// TODO: make it clean
jsonTilesLinks["tiles"] = jsonTiles;
jsonTilesLinks["links"] = jsonLinks;
json jsonMap(jsonTilesLinks);
Expand Down
5 changes: 3 additions & 2 deletions test/compile.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
clang-12 -emit-llvm -fno-unroll-loops -O3 -o kernel.bc -c kernel.cpp
#llvm-dis fir.bc -o fir.ll
clang-12 -emit-llvm -fno-unroll-loops -O0 -o kernel.bc -c kernel.cpp
llvm-dis-12 kernel.bc -o O0kernel.ll
#clang-12 -emit-llvm -fno-unroll-loops -mllvm -force-vector-width=4 -O3 -o kernel.bc -c ./_matmul/src/matmul.c
3 changes: 1 addition & 2 deletions test/dot.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
dot -Tpng _Z6kernelPfS_S_.dot -o kernel.png

dot -Tpng _Z6kernelPfS_S_.dot -o kernel.png
Empty file modified test/inter_edge/compile.sh
100644 → 100755
Empty file.
Empty file modified test/inter_edge/dot.sh
100644 → 100755
Empty file.
Empty file modified test/inter_edge/rebuild.sh
100644 → 100755
Empty file.
Empty file modified test/inter_edge/run.sh
100644 → 100755
Empty file.
Empty file modified test/inter_edge/verify.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion test/kernels/conv/conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int kernel(int ni, int nj, int nk,
for (x = 0; x < total; x++) {
i = x / NJ;
j = x % NJ;
out += A[i][j] * B[i][j];
out += A [i][j] * B[i][j];
}

/*
Expand Down
22 changes: 11 additions & 11 deletions test/kernels/latnrm/latnrm.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ void kernel(float input, float *output, float coefficient[16],
top = input;
q_coef = coefficient[0];
// #pragma clang loop unroll_count(4)
for (i = 0; i < ORDER; i++) {
k_coef = coefficient[2*i];
left = top;
right = internal_state[i];
internal_state[i] = bottom;
top = q_coef * left - k_coef * right;
bottom = q_coef * right + k_coef * left;
q_coef = coefficient[2*i+1];
}
internal_state[i++] = bottom;
internal_state[i] = top;
// for (i = 0; i < ORDER; i++) {
// k_coef = coefficient[2*i];
// left = top;
// right = internal_state[i];
// internal_state[i] = bottom;
// top = q_coef * left - k_coef * right;
// bottom = q_coef * right + k_coef * left;
// q_coef = coefficient[2*i+1];
// }
// internal_state[i++] = bottom;
// internal_state[i] = top;

sum = internal_state[1] * q_coef;

Expand Down
6 changes: 3 additions & 3 deletions test/kernels/mvt/mvt.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ void kernel(int n,
{
int i, j;

#pragma scop
#pragma clang loop unroll_count(1)
// #pragma scop
// #pragma clang loop unroll_count(1)
for (j = 0; j < N; j++) {
// #pragma clang loop unroll_count(1) vectorize(disable)
//#pragma clang loop unroll_count(1) vectorize_width(4)
Expand All @@ -88,7 +88,7 @@ void kernel(int n,
x2[i] = x2[i] + A[j][i] * y_2[j];
}
}
#pragma endscop
// #pragma endscop
}


Expand Down
4 changes: 4 additions & 0 deletions test/kernels/relu+histogram/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
clang-12 -emit-llvm -O3 -fno-unroll-loops -o kernel.bc -c relu.c
llvm-dis-12 kernel.bc -o kernel.ll
opt-12 --loop-unroll --unroll-count=4 kernel.bc -o kernel_unroll.bc
llvm-dis-12 kernel_unroll.bc -o kernel_unroll.ll
19 changes: 19 additions & 0 deletions test/kernels/relu+histogram/param.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"kernel" : "kernel",
"targetFunction" : false,
"targetNested" : false,
"targetLoopsID" : [1],
"doCGRAMapping" : false,
"row" : 4,
"column" : 4,
"diagonalVectorization" : true,
"fusionStrategy" : [],
"isTrimmedDemo" : true,
"heuristicMapping" : false,
"bypassConstraint" : 4,
"isStaticElasticCGRA" : false,
"precisionAware" : false,
"ctrlMemConstraint" : 200,
"regConstraint" : 8
}

217 changes: 217 additions & 0 deletions test/kernels/relu+histogram/polybench.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
/*
* Polybench header for instrumentation.
*
* Programs must be compiled with `-I utilities utilities/polybench.c'
*
* Optionally, one can define:
*
* -DPOLYBENCH_TIME, to report the execution time,
* OR (exclusive):
* -DPOLYBENCH_PAPI, to use PAPI H/W counters (defined in polybench.c)
*
*
* See README or utilities/polybench.c for additional options.
*
*/
#ifndef POLYBENCH_H
# define POLYBENCH_H

# include <stdlib.h>

/* Array padding. By default, none is used. */
# ifndef POLYBENCH_PADDING_FACTOR
/* default: */
# define POLYBENCH_PADDING_FACTOR 0
# endif


/* C99 arrays in function prototype. By default, do not use. */
# ifdef POLYBENCH_USE_C99_PROTO
# define POLYBENCH_C99_SELECT(x,y) y
# else
/* default: */
# define POLYBENCH_C99_SELECT(x,y) x
# endif


/* Scalar loop bounds in SCoPs. By default, use parametric loop bounds. */
# ifdef POLYBENCH_USE_SCALAR_LB
# define POLYBENCH_LOOP_BOUND(x,y) x
# else
/* default: */
# define POLYBENCH_LOOP_BOUND(x,y) y
# endif

/* Use the 'restrict' keyword to declare that the different arrays do not
* alias. By default, we do not use it as it is only supported in C99 and
* even here several compilers do not properly get it.
*/
# ifdef POLYBENCH_USE_RESTRICT
# define POLYBENCH_RESTRICT restrict
# else
/* default: */
# define POLYBENCH_RESTRICT
# endif

/* Macros to reference an array. Generic for heap and stack arrays
(C99). Each array dimensionality has his own macro, to be used at
declaration or as a function argument.
Example:
int b[x] => POLYBENCH_1D_ARRAY(b, x)
int A[N][N] => POLYBENCH_2D_ARRAY(A, N, N)
*/
# ifndef POLYBENCH_STACK_ARRAYS
# define POLYBENCH_ARRAY(x) *x
# define POLYBENCH_FREE_ARRAY(x) free((void*)x);
# define POLYBENCH_DECL_VAR(x) (*x)
# else
# define POLYBENCH_ARRAY(x) x
# define POLYBENCH_FREE_ARRAY(x)
# define POLYBENCH_DECL_VAR(x) x
# endif
/* Macros for using arrays in the function prototypes. */
# define POLYBENCH_1D(var, dim1,ddim1) var[POLYBENCH_RESTRICT POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR]
# define POLYBENCH_2D(var, dim1, dim2, ddim1, ddim2) var[POLYBENCH_RESTRICT POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR]
# define POLYBENCH_3D(var, dim1, dim2, dim3, ddim1, ddim2, ddim3) var[POLYBENCH_RESTRICT POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim3,ddim3) + POLYBENCH_PADDING_FACTOR]
# define POLYBENCH_4D(var, dim1, dim2, dim3, dim4, ddim1, ddim2, ddim3, ddim4) var[POLYBENCH_RESTRICT POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim3,ddim3) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim4,ddim4) + POLYBENCH_PADDING_FACTOR]
# define POLYBENCH_5D(var, dim1, dim2, dim3, dim4, dim5, ddim1, ddim2, ddim3, ddim4, ddim5) var[POLYBENCH_RESTRICT POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim3,ddim3) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim4,ddim4) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim5,ddim5) + POLYBENCH_PADDING_FACTOR]
/* Macros for using arrays within the functions. */
# define POLYBENCH_1D_F(var, dim1,ddim1) var[POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR]
# define POLYBENCH_2D_F(var, dim1, dim2, ddim1, ddim2) var[POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR]
# define POLYBENCH_3D_F(var, dim1, dim2, dim3, ddim1, ddim2, ddim3) var[POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim3,ddim3) + POLYBENCH_PADDING_FACTOR]
# define POLYBENCH_4D_F(var, dim1, dim2, dim3, dim4, ddim1, ddim2, ddim3, ddim4) var[POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim3,ddim3) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim4,ddim4) + POLYBENCH_PADDING_FACTOR]
# define POLYBENCH_5D_F(var, dim1, dim2, dim3, dim4, dim5, ddim1, ddim2, ddim3, ddim4, ddim5) var[POLYBENCH_C99_SELECT(dim1,ddim1) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim2,ddim2) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim3,ddim3) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim4,ddim4) + POLYBENCH_PADDING_FACTOR][POLYBENCH_C99_SELECT(dim5,ddim5) + POLYBENCH_PADDING_FACTOR]


/* Macros to allocate heap arrays.
Example:
polybench_alloc_2d_array(N, M, double) => allocates N x M x sizeof(double)
and returns a pointer to the 2d array
*/
# define POLYBENCH_ALLOC_1D_ARRAY(n1, type) \
(type(*)[n1 + POLYBENCH_PADDING_FACTOR])polybench_alloc_data (n1 + POLYBENCH_PADDING_FACTOR, sizeof(type))
# define POLYBENCH_ALLOC_2D_ARRAY(n1, n2, type) \
(type(*)[n1 + POLYBENCH_PADDING_FACTOR][n2 + POLYBENCH_PADDING_FACTOR])polybench_alloc_data ((n1 + POLYBENCH_PADDING_FACTOR) * (n2 + POLYBENCH_PADDING_FACTOR), sizeof(type))
# define POLYBENCH_ALLOC_3D_ARRAY(n1, n2, n3, type) \
(type(*)[n1 + POLYBENCH_PADDING_FACTOR][n2 + POLYBENCH_PADDING_FACTOR][n3 + POLYBENCH_PADDING_FACTOR])polybench_alloc_data ((n1 + POLYBENCH_PADDING_FACTOR) * (n2 + POLYBENCH_PADDING_FACTOR) * (n3 + POLYBENCH_PADDING_FACTOR), sizeof(type))
# define POLYBENCH_ALLOC_4D_ARRAY(n1, n2, n3, n4, type) \
(type(*)[n1 + POLYBENCH_PADDING_FACTOR][n2 + POLYBENCH_PADDING_FACTOR][n3 + POLYBENCH_PADDING_FACTOR][n4 + POLYBENCH_PADDING_FACTOR])polybench_alloc_data ((n1 + POLYBENCH_PADDING_FACTOR) * (n2 + POLYBENCH_PADDING_FACTOR) * (n3 + POLYBENCH_PADDING_FACTOR) * (n4 + POLYBENCH_PADDING_FACTOR), sizeof(type))
# define POLYBENCH_ALLOC_5D_ARRAY(n1, n2, n3, n4, n5, type) \
(type(*)[n1 + POLYBENCH_PADDING_FACTOR][n2 + POLYBENCH_PADDING_FACTOR][n3 + POLYBENCH_PADDING_FACTOR][n4 + POLYBENCH_PADDING_FACTOR][n5 + POLYBENCH_PADDING_FACTOR])polybench_alloc_data ((n1 + POLYBENCH_PADDING_FACTOR) * (n2 + POLYBENCH_PADDING_FACTOR) * (n3 + POLYBENCH_PADDING_FACTOR) * (n4 + POLYBENCH_PADDING_FACTOR) * (n5 + POLYBENCH_PADDING_FACTOR), sizeof(type))

/* Macros for array declaration. */
# ifndef POLYBENCH_STACK_ARRAYS
# define POLYBENCH_1D_ARRAY_DECL(var, type, dim1, ddim1) \
type POLYBENCH_1D_F(POLYBENCH_DECL_VAR(var), dim1, ddim1); \
var = POLYBENCH_ALLOC_1D_ARRAY(POLYBENCH_C99_SELECT(dim1, ddim1), type);
# define POLYBENCH_2D_ARRAY_DECL(var, type, dim1, dim2, ddim1, ddim2) \
type POLYBENCH_2D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, ddim1, ddim2); \
var = POLYBENCH_ALLOC_2D_ARRAY(POLYBENCH_C99_SELECT(dim1, ddim1), POLYBENCH_C99_SELECT(dim2, ddim2), type);
# define POLYBENCH_3D_ARRAY_DECL(var, type, dim1, dim2, dim3, ddim1, ddim2, ddim3) \
type POLYBENCH_3D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, dim3, ddim1, ddim2, ddim3); \
var = POLYBENCH_ALLOC_3D_ARRAY(POLYBENCH_C99_SELECT(dim1, ddim1), POLYBENCH_C99_SELECT(dim2, ddim2), POLYBENCH_C99_SELECT(dim3, ddim3), type);
# define POLYBENCH_4D_ARRAY_DECL(var, type, dim1, dim2, dim3, dim4, ddim1, ddim2, ddim3, ddim4) \
type POLYBENCH_4D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, dim3, dim4, ddim1, ddim2, ddim3, ddim4); \
var = POLYBENCH_ALLOC_4D_ARRAY(POLYBENCH_C99_SELECT(dim1, ddim1), POLYBENCH_C99_SELECT(dim2, ddim2), POLYBENCH_C99_SELECT(dim3, ddim3), POLYBENCH_C99_SELECT(dim4, ddim4), type);
# define POLYBENCH_5D_ARRAY_DECL(var, type, dim1, dim2, dim3, dim4, dim5, ddim1, ddim2, ddim3, ddim4, ddim5) \
type POLYBENCH_5D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, dim3, dim4, dim5, ddim1, ddim2, ddim3, ddim4, ddim5); \
var = POLYBENCH_ALLOC_5D_ARRAY(POLYBENCH_C99_SELECT(dim1, ddim1), POLYBENCH_C99_SELECT(dim2, ddim2), POLYBENCH_C99_SELECT(dim3, ddim3), POLYBENCH_C99_SELECT(dim4, ddim4), POLYBENCH_C99_SELECT(dim5, ddim5), type);
# else
# define POLYBENCH_1D_ARRAY_DECL(var, type, dim1, ddim1) \
type POLYBENCH_1D_F(POLYBENCH_DECL_VAR(var), dim1, ddim1);
# define POLYBENCH_2D_ARRAY_DECL(var, type, dim1, dim2, ddim1, ddim2) \
type POLYBENCH_2D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, ddim1, ddim2);
# define POLYBENCH_3D_ARRAY_DECL(var, type, dim1, dim2, dim3, ddim1, ddim2, ddim3) \
type POLYBENCH_3D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, dim3, ddim1, ddim2, ddim3);
# define POLYBENCH_4D_ARRAY_DECL(var, type, dim1, dim2, dim3, dim4, ddim1, ddim2, ddim3, ddim4) \
type POLYBENCH_4D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, dim3, dim4, ddim1, ddim2, ddim3, ddim4);
# define POLYBENCH_5D_ARRAY_DECL(var, type, dim1, dim2, dim3, dim4, dim5, ddim1, ddim2, ddim3, ddim4, ddim5) \
type POLYBENCH_5D_F(POLYBENCH_DECL_VAR(var), dim1, dim2, dim3, dim4, dim5, ddim1, ddim2, ddim3, ddim4, ddim5);
# endif


/* Dead-code elimination macros. Use argc/argv for the run-time check. */
# ifndef POLYBENCH_DUMP_ARRAYS
# define POLYBENCH_DCE_ONLY_CODE if (argc > 42 && ! strcmp(argv[0], ""))
# else
# define POLYBENCH_DCE_ONLY_CODE
# endif

#define POLYBENCH_DUMP_TARGET stderr
#define POLYBENCH_DUMP_START fprintf(POLYBENCH_DUMP_TARGET, "==BEGIN DUMP_ARRAYS==\n")
#define POLYBENCH_DUMP_FINISH fprintf(POLYBENCH_DUMP_TARGET, "==END DUMP_ARRAYS==\n")
#define POLYBENCH_DUMP_BEGIN(s) fprintf(POLYBENCH_DUMP_TARGET, "begin dump: %s", s)
#define POLYBENCH_DUMP_END(s) fprintf(POLYBENCH_DUMP_TARGET, "\nend dump: %s\n", s)

# define polybench_prevent_dce(func) \
POLYBENCH_DCE_ONLY_CODE \
func


/* Performance-related instrumentation. See polybench.c */
# define polybench_start_instruments
# define polybench_stop_instruments
# define polybench_print_instruments


/* PAPI support. */
# ifdef POLYBENCH_PAPI
extern const unsigned int polybench_papi_eventlist[];
# undef polybench_start_instruments
# undef polybench_stop_instruments
# undef polybench_print_instruments
# define polybench_set_papi_thread_report(x) \
polybench_papi_counters_threadid = x;
# define polybench_start_instruments \
polybench_prepare_instruments(); \
polybench_papi_init(); \
int evid; \
for (evid = 0; polybench_papi_eventlist[evid] != 0; evid++) \
{ \
if (polybench_papi_start_counter(evid)) \
continue; \

# define polybench_stop_instruments \
polybench_papi_stop_counter(evid); \
} \
polybench_papi_close(); \

# define polybench_print_instruments polybench_papi_print();
# endif


/* Timing support. */
# if defined(POLYBENCH_TIME) || defined(POLYBENCH_GFLOPS)
# undef polybench_start_instruments
# undef polybench_stop_instruments
# undef polybench_print_instruments
# define polybench_start_instruments polybench_timer_start();
# define polybench_stop_instruments polybench_timer_stop();
# define polybench_print_instruments polybench_timer_print();
extern double polybench_program_total_flops;
extern void polybench_timer_start();
extern void polybench_timer_stop();
extern void polybench_timer_print();
# endif

/* Function declaration. */
# ifdef POLYBENCH_TIME
extern void polybench_timer_start();
extern void polybench_timer_stop();
extern void polybench_timer_print();
# endif

# ifdef POLYBENCH_PAPI
extern void polybench_prepare_instruments();
extern int polybench_papi_start_counter(int evid);
extern void polybench_papi_stop_counter(int evid);
extern void polybench_papi_init();
extern void polybench_papi_close();
extern void polybench_papi_print();
# endif

/* Function prototypes. */
extern void* polybench_alloc_data(unsigned long long int n, int elt_size);


#endif /* !POLYBENCH_H */
Loading
Loading