main
|
Last change
on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | /**********************************************************************
|
|---|
| 2 | C-DAC Tech Workshop : HeGaPa-2012
|
|---|
| 3 | July 16-20,2012
|
|---|
| 4 |
|
|---|
| 5 | Example 1 : Mpi-Omp_Hello_World.c
|
|---|
| 6 |
|
|---|
| 7 | Objective : MPI-OpenMP program to print "Hello World"
|
|---|
| 8 | This example demonstrates the use of
|
|---|
| 9 | MPI LIBRARY CALLS and OPENMP Directives
|
|---|
| 10 |
|
|---|
| 11 | Input : No Input is Required
|
|---|
| 12 |
|
|---|
| 13 | Output : Each thread created by each processor prints
|
|---|
| 14 | Hello World along with its threadid and procesor rank.
|
|---|
| 15 |
|
|---|
| 16 | Created : MAY-2012
|
|---|
| 17 |
|
|---|
| 18 | **********************************************************************/
|
|---|
| 19 |
|
|---|
| 20 | #include <stdio.h>
|
|---|
| 21 | #include <omp.h>
|
|---|
| 22 | #include "mpi.h"
|
|---|
| 23 |
|
|---|
| 24 | /* Main Program */
|
|---|
| 25 |
|
|---|
| 26 | int main(int argc, char **argv)
|
|---|
| 27 | {
|
|---|
| 28 | int Numprocs, MyRank, iam;
|
|---|
| 29 |
|
|---|
| 30 | /* MPI - Initialization */
|
|---|
| 31 |
|
|---|
| 32 | MPI_Init(&argc, &argv);
|
|---|
| 33 | MPI_Comm_rank(MPI_COMM_WORLD, &MyRank);
|
|---|
| 34 | MPI_Comm_size(MPI_COMM_WORLD, &Numprocs);
|
|---|
| 35 |
|
|---|
| 36 | /* OpenMP Parallel Directive */
|
|---|
| 37 | omp_set_num_threads(4);
|
|---|
| 38 | #pragma omp parallel private(iam)
|
|---|
| 39 | {
|
|---|
| 40 | iam = omp_get_thread_num();
|
|---|
| 41 | printf("Hello World is Printed By Process %d and Threadid %d\n", MyRank, iam);
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | /* MPI - Termination */
|
|---|
| 45 | MPI_Finalize();
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.