Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mpi-lab-exercises
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pdc-summer-school
mpi-lab-exercises
Commits
972c7bb7
Commit
972c7bb7
authored
Sep 6, 2018
by
Xin Li
Browse files
Options
Downloads
Patches
Plain Diff
formatted C code in lab1
parent
c356c06e
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
lab1/game_of_life-serial.c
+23
-23
23 additions, 23 deletions
lab1/game_of_life-serial.c
lab1/hello_mpi.c
+9
-7
9 additions, 7 deletions
lab1/hello_mpi.c
lab1/parallel_search-serial.c
+3
-3
3 additions, 3 deletions
lab1/parallel_search-serial.c
lab1/pi_serial.c
+30
-31
30 additions, 31 deletions
lab1/pi_serial.c
with
65 additions
and
64 deletions
lab1/game_of_life-serial.c
+
23
−
23
View file @
972c7bb7
...
@@ -16,8 +16,8 @@ serial version
...
@@ -16,8 +16,8 @@ serial version
#define NSTEPS 500
/* number of time steps */
#define NSTEPS 500
/* number of time steps */
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
int
i
,
j
,
n
,
im
,
ip
,
jm
,
jp
,
ni
,
nj
,
nsum
,
isum
;
int
i
,
j
,
n
,
im
,
ip
,
jm
,
jp
,
ni
,
nj
,
nsum
,
isum
;
int
**
old
,
**
new
;
int
**
old
,
**
new
;
float
x
;
float
x
;
...
...
This diff is collapsed.
Click to expand it.
lab1/hello_mpi.c
+
9
−
7
View file @
972c7bb7
#include
<stdio.h>
#include
<stdio.h>
#include
<mpi.h>
#include
<mpi.h>
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
int
myrank
,
size
;
int
myrank
,
size
;
MPI_Init
(
&
argc
,
&
argv
);
MPI_Init
(
&
argc
,
&
argv
);
...
@@ -11,4 +11,6 @@ int main (int argc, char *argv[]) {
...
@@ -11,4 +11,6 @@ int main (int argc, char *argv[]) {
printf
(
"Processor %d of %d: Hello World!
\n
"
,
myrank
,
size
);
printf
(
"Processor %d of %d: Hello World!
\n
"
,
myrank
,
size
);
MPI_Finalize
();
MPI_Finalize
();
return
0
;
}
}
This diff is collapsed.
Click to expand it.
lab1/parallel_search-serial.c
+
3
−
3
View file @
972c7bb7
#include
<stdio.h>
#include
<stdio.h>
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
const
int
N
=
300
;
const
int
N
=
300
;
int
i
,
target
;
int
i
,
target
;
int
b
[
N
];
int
b
[
N
];
...
@@ -31,4 +32,3 @@ int main (int argc, char *argv[]) {
...
@@ -31,4 +32,3 @@ int main (int argc, char *argv[]) {
return
0
;
return
0
;
}
}
This diff is collapsed.
Click to expand it.
lab1/pi_serial.c
+
30
−
31
View file @
972c7bb7
...
@@ -7,8 +7,8 @@ double dboard (int darts);
...
@@ -7,8 +7,8 @@ double dboard (int darts);
#define ROUNDS 10
/* number of times "darts" is iterated */
#define ROUNDS 10
/* number of times "darts" is iterated */
#define MASTER 0
/* task ID of master task */
#define MASTER 0
/* task ID of master task */
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
double
homepi
,
/* value of pi calculated by current task */
double
homepi
,
/* value of pi calculated by current task */
pi
,
/* average of pi after "darts" is thrown */
pi
,
/* average of pi after "darts" is thrown */
avepi
,
/* average pi value for all iterations */
avepi
,
/* average pi value for all iterations */
...
@@ -16,7 +16,6 @@ double homepi, /* value of pi calculated by current task */
...
@@ -16,7 +16,6 @@ double homepi, /* value of pi calculated by current task */
pisum
;
/* sum of workers pi values */
pisum
;
/* sum of workers pi values */
int
i
,
n
;
int
i
,
n
;
srandom
(
0
);
srandom
(
0
);
avepi
=
0
;
avepi
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment