Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pp-heatmap
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Björn Fischer
pp-heatmap
Commits
b3eedfc5
Commit
b3eedfc5
authored
Dec 30, 2015
by
Björn Fischer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor first init part
parent
184196c8
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
137 deletions
+41
-137
Matrix.txt
Matrix.txt
+14
-66
args.c
args.c
+1
-1
proj
proj
+0
-0
proj.c
proj.c
+10
-59
project.h
project.h
+16
-11
No files found.
Matrix.txt
View file @
b3eedfc5
8
8
4
4
0.0000000000
0.1428571429
0.2857142857
0.4285714286
0.5714285714
0.7142857143
0.8571428571
0.3333333333
0.6666666667
1.0000000000
0.1428571429
0.0000182857
0.0000182857
0.0000274286
0.0000365714
0.0000457143
0.0001097143
0.8571428571
0.3333333333
0.0000106667
0.0000213333
0.6666666667
0.2857142857
0.0000182857
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000457143
0.7142857143
0.4285714286
0.0000274286
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000365714
0.5714285714
0.5714285714
0.0000365714
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000274286
0.4285714286
0.7142857143
0.0000457143
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000182857
0.2857142857
0.8571428571
0.0001097143
0.0000457143
0.0000365714
0.0000274286
0.0000182857
0.0000182857
0.1428571429
0.6666666667
0.0000213333
0.0000106667
0.3333333333
1.0000000000
0.8571428571
0.7142857143
0.5714285714
0.4285714286
0.2857142857
0.1428571429
0.6666666667
0.3333333333
0.0000000000
args.c
View file @
b3eedfc5
...
...
@@ -3,7 +3,7 @@
#include <stdlib.h>
#include <math.h>
void
process_a
rgs
(
int
argc
,
char
**
argv
,
int
*
m
,
int
*
n
,
double
*
eps
,
double
*
delta_t
)
{
void
Process_A
rgs
(
int
argc
,
char
**
argv
,
int
*
m
,
int
*
n
,
double
*
eps
,
double
*
delta_t
)
{
if
((
argc
<
3
)
||
(
argc
>
5
))
{
fprintf
(
stderr
,
"Usage: heat <m> <n> [<epsilon> [delta_t]]!
\n\n
"
);
fprintf
(
stderr
,
" <m> -- X-Size of matrix
\n
"
);
...
...
proj
View file @
b3eedfc5
No preview for this file type
proj.c
View file @
b3eedfc5
...
...
@@ -17,15 +17,18 @@ int main(int argc, char **argv)
{
MPI_Init
(
&
argc
,
&
argv
);
int
m
,
n
;
double
**
root_field
;
double
**
partial_field
;
double
**
root_field
;
// complete field owned by root
double
**
partial_field
;
// partial field where process works on
double
start
,
end
;
t_process_info
pi
;
t_process_info
*
infos
;
int
pro_per_dim
[
2
];
int
cell_per_pro
[
2
];
MPI_Comm
cart_comm
;
Create_MPI_Type_t_process_info
(
&
MPI_process_info
);
process_a
rgs
(
argc
,
argv
,
&
m
,
&
n
,
&
eps
,
&
delta_t
);
Process_A
rgs
(
argc
,
argv
,
&
m
,
&
n
,
&
eps
,
&
delta_t
);
int
rank
,
num_p
;
if
(
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
rank
))
{
...
...
@@ -33,11 +36,6 @@ int main(int argc, char **argv)
exit
(
1
);
}
if
(
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
num_p
))
{
fprintf
(
stderr
,
"Cannot fetch size of cluster
\n
"
);
exit
(
1
);
}
if
(
rank
==
0
)
{
root_field
=
New_Matrix
(
m
,
n
);
if
(
root_field
==
NULL
)
{
...
...
@@ -46,59 +44,12 @@ int main(int argc, char **argv)
}
}
if
(
rank
==
0
)
{
printf
(
"number of processes: %d
\n
"
,
num_p
);
}
int
pro_per_dim
[
2
];
float
temp_f
,
temp_g
;
temp_g
=
sqrt
((
float
)(
num_p
*
m
)
/
n
);
temp_f
=
num_p
/
temp_g
;
temp_g
=
floor
(
temp_g
);
temp_f
=
floor
(
temp_f
);
pro_per_dim
[
0
]
=
(
int
)
temp_f
;
pro_per_dim
[
1
]
=
(
int
)
temp_g
;
// optimize cart cluster
Optimize_Cart_Cluster
(
m
,
n
,
MPI_COMM_WORLD
,
rank
,
pro_per_dim
,
cell_per_pro
);
int
m_per_pro
,
n_per_pro
;
m_per_pro
=
ceil
(
m
/
(
float
)
pro_per_dim
[
1
]);
n_per_pro
=
ceil
(
n
/
(
float
)
pro_per_dim
[
0
]);
if
(
rank
==
0
)
{
printf
(
"dim0: %d dim1: %d
\n
"
,
pro_per_dim
[
0
],
pro_per_dim
[
1
]);
printf
(
"size per pro: %dx%d
\n
"
,
m_per_pro
,
n_per_pro
);
}
cart_comm
=
Create_MPI_Cart_Cluster
(
MPI_COMM_WORLD
,
rank
,
pro_per_dim
);
int
periods
[]
=
{
0
,
0
};
// edges are not connected
MPI_Comm
cart_comm
;
if
(
MPI_Cart_create
(
MPI_COMM_WORLD
,
2
,
pro_per_dim
,
periods
,
0
,
&
cart_comm
))
{
fprintf
(
stderr
,
"Cannot create topology
\n
"
);
exit
(
1
);
}
if
(
cart_comm
==
MPI_COMM_NULL
)
{
printf
(
"process %d not in use. exiting...
\n
"
,
rank
);
MPI_Finalize
();
exit
(
0
);
}
int
coord
[
2
];
if
(
MPI_Cart_coords
(
cart_comm
,
rank
,
2
,
coord
))
{
fprintf
(
stderr
,
"Cannot get coordinates
\n
"
);
exit
(
1
);
}
// calculate own field using coord
pi
.
start_m
=
coord
[
0
]
*
m_per_pro
;
pi
.
end_m
=
(
coord
[
0
]
+
1
)
*
m_per_pro
-
1
;
pi
.
start_n
=
coord
[
1
]
*
n_per_pro
;
pi
.
end_n
=
(
coord
[
1
]
+
1
)
*
n_per_pro
-
1
;
if
(
pi
.
end_m
>
m
-
1
)
{
pi
.
end_m
=
m
-
1
;
}
if
(
pi
.
end_n
>
n
-
1
)
{
pi
.
end_n
=
n
-
1
;
}
pi
.
coord0
=
coord
[
0
];
pi
.
coord1
=
coord
[
1
];
pi
.
rank
=
rank
;
pi
=
Calculate_Process_Info
(
cart_comm
,
rank
,
m
,
n
,
cell_per_pro
);
int
matrix_size
[
2
];
matrix_size
[
0
]
=
pi
.
end_m
-
pi
.
start_m
+
3
;
...
...
project.h
View file @
b3eedfc5
#include <mpi.h>
typedef
struct
{
int
rank
;
int
coord0
;
int
coord1
;
int
start_m
;
// first tile to process in X-axis
int
start_n
;
// first tile to process in Y-axis
int
end_m
;
// last tile to process in X-axis
int
end_n
;
// last tile to process in Y-axis
}
t_process_info
;
// matrix.c
double
**
New_Matrix
(
int
m
,
int
n
);
void
Delete_Matrix
(
double
**
matrix
);
...
...
@@ -9,19 +19,14 @@ void Insert_Matrix(double **a, int a_dim0, int a_dim1, int pos_dim0, int pos_dim
void
Insert_Array_In_Matrix
(
double
**
a
,
int
a_dim0
,
int
a_dim1
,
int
pos_dim0
,
int
pos_dim1
,
double
*
b
,
int
b_dim0
,
int
b_dim1
,
int
offset_top
,
int
offset_right
,
int
offset_bottom
,
int
offset_left
);
// args.c
void
process_a
rgs
(
int
argc
,
char
**
argv
,
int
*
m
,
int
*
n
,
double
*
eps
,
double
*
delta_t
);
void
Process_A
rgs
(
int
argc
,
char
**
argv
,
int
*
m
,
int
*
n
,
double
*
eps
,
double
*
delta_t
);
// mpi_util.c
void
Create_MPI_Type_t_process_info
(
MPI_Datatype
*
datatype
);
//
// cart.c
void
Optimize_Cart_Cluster
(
int
dim0_size
,
int
dim1_size
,
MPI_Comm
comm
,
int
rank
,
int
*
pro_per_dim
,
int
*
cell_per_pro
);
MPI_Comm
Create_MPI_Cart_Cluster
(
MPI_Comm
comm
,
int
rank
,
int
*
pro_per_dim
);
typedef
struct
{
int
rank
;
int
coord0
;
int
coord1
;
int
start_m
;
// first tile to process in X-axis
int
start_n
;
// first tile to process in Y-axis
int
end_m
;
// last tile to process in X-axis
int
end_n
;
// last tile to process in Y-axis
}
t_process_info
;
\ No newline at end of file
// pi.c
t_process_info
Calculate_Process_Info
(
MPI_Comm
cart_comm
,
int
rank
,
int
dim0_size
,
int
dim1_size
,
int
*
cell_per_pro
);
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment