Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
721be58d
Commit
721be58d
authored
May 26, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ModSim ass4 taddeus: Source code cleanup.
parent
965539d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
modsim/ass4_taddeus/ring/ring.c
modsim/ass4_taddeus/ring/ring.c
+9
-5
No files found.
modsim/ass4_taddeus/ring/ring.c
View file @
721be58d
...
@@ -4,14 +4,15 @@
...
@@ -4,14 +4,15 @@
//#define DEBUG
//#define DEBUG
#define LOOP 100
#define LOOP 100
// Number of different message sizes
#define STRIDE 10000
#define STRIDE 10000
// Difference between the message sizes
#define REPEAT 7
#define REPEAT 7
// Number of times to repeat a measurement
const
int
data_size
=
LOOP
*
STRIDE
;
const
int
data_size
=
LOOP
*
STRIDE
;
/*
/*
* The master task measures the time between the sending and receiving of data.
* The master task initiates the transport of data and waits for it to come
* back. The time between sending and receiving is measured and printed.
*/
*/
void
master
(
int
tasks
)
{
void
master
(
int
tasks
)
{
double
*
received
=
malloc
(
data_size
*
sizeof
(
double
)),
double
*
received
=
malloc
(
data_size
*
sizeof
(
double
)),
...
@@ -22,7 +23,7 @@ void master(int tasks) {
...
@@ -22,7 +23,7 @@ void master(int tasks) {
// generate data to send
// generate data to send
for
(
i
=
0
;
i
<
data_size
;
i
++
)
for
(
i
=
0
;
i
<
data_size
;
i
++
)
sent
[
i
]
=
(
float
)
i
;
sent
[
i
]
=
(
double
)
i
;
// Increase the message length with a fixed STRIDE
// Increase the message length with a fixed STRIDE
for
(
size
=
STRIDE
;
size
<=
data_size
;
size
+=
STRIDE
)
{
for
(
size
=
STRIDE
;
size
<=
data_size
;
size
+=
STRIDE
)
{
...
@@ -89,6 +90,7 @@ void slave(int tasks, int rank) {
...
@@ -89,6 +90,7 @@ void slave(int tasks, int rank) {
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
int
tasks
,
rank
,
error
;
int
tasks
,
rank
,
error
;
// Initialize adnd setup MPI
if
(
(
error
=
MPI_Init
(
&
argc
,
&
argv
))
!=
MPI_SUCCESS
)
{
if
(
(
error
=
MPI_Init
(
&
argc
,
&
argv
))
!=
MPI_SUCCESS
)
{
printf
(
"MPI_init failed (error %d)
\n
"
,
error
);
printf
(
"MPI_init failed (error %d)
\n
"
,
error
);
MPI_Abort
(
MPI_COMM_WORLD
,
error
);
MPI_Abort
(
MPI_COMM_WORLD
,
error
);
...
@@ -98,11 +100,13 @@ int main(int argc, char **argv) {
...
@@ -98,11 +100,13 @@ int main(int argc, char **argv) {
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
tasks
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
tasks
);
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
rank
);
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
rank
);
// Execute the measurements
if
(
!
rank
)
if
(
!
rank
)
master
(
tasks
);
master
(
tasks
);
else
else
slave
(
tasks
,
rank
);
slave
(
tasks
,
rank
);
// Finalize mPI
MPI_Finalize
();
MPI_Finalize
();
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
...
...
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