Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hello_world
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
support
hello_world
Commits
71c896d0
Commit
71c896d0
authored
6 years ago
by
acloirec
Browse files
Options
Downloads
Patches
Plain Diff
modify program for output readability
parent
198871bd
No related branches found
Branches containing commit
No related tags found
1 merge request
!2
Release
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/hello_hybrid_bis.c
+48
-0
48 additions, 0 deletions
src/hello_hybrid_bis.c
with
48 additions
and
0 deletions
src/hello_hybrid_bis.c
0 → 100644
+
48
−
0
View file @
71c896d0
#include
<omp.h>
#include
<stdio.h>
#include
<mpi.h>
#include
<stdlib.h>
#include
<sys/unistd.h>
int
main
(
int
argc
,
char
**
argv
)
{
int
mpiRank
,
mpiSize
;
char
hostname
[
128
];
int
nthreads
,
tid
,
cpuid
;
int
i
,
j
=
0
;
MPI_Init
(
&
argc
,
&
argv
);
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
mpiRank
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
mpiSize
);
gethostname
(
hostname
,
sizeof
hostname
);
#pragma omp parallel
{
nthreads
=
omp_get_num_threads
();
}
if
(
mpiRank
==
0
)
printf
(
"Run executed using %d MPI processes, with %d threads per process
\n
"
,
mpiSize
,
nthreads
);
for
(
i
=
0
;
i
<
mpiSize
;
i
++
)
{
MPI_Barrier
(
MPI_COMM_WORLD
);
if
(
i
==
mpiRank
)
{
printf
(
"%s: MPI n° %d -> cpuid %d
\n
"
,
hostname
,
mpiRank
,
sched_getcpu
());
#pragma omp parallel private(tid, nthreads, cpuid) shared(i)
{
tid
=
omp_get_thread_num
();
nthreads
=
omp_get_num_threads
();
cpuid
=
sched_getcpu
();
while
(
j
<
tid
){
#pragma omp flush(j)
}
printf
(
"
\t
thread n° %d -> cpuid %d on MPI n° %d on %s
\n
"
,
tid
,
cpuid
,
mpiRank
,
hostname
);
j
++
;
#pragma omp flush(j)
}
}
}
MPI_Finalize
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
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