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.5 KB
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 | /**********************************************************************
|
|---|
| 5 | C-DAC Tech Workshop : hyPACK-2013
|
|---|
| 6 | Oct 15-18,2013
|
|---|
| 7 |
|
|---|
| 8 | Example 1.1 : Mpi-Pthreads-Helloworld.C
|
|---|
| 9 |
|
|---|
| 10 | Objective : Write An Mpi-Pthreads Program To Print Hello World!
|
|---|
| 11 |
|
|---|
| 12 | Demonstrates Use Of:
|
|---|
| 13 | Pthread_Create()
|
|---|
| 14 | Pthread_Join()
|
|---|
| 15 | Mpi_Init
|
|---|
| 16 | Mpi_Comm_Rank
|
|---|
| 17 | Mpi_Comm_Size
|
|---|
| 18 | Mpi_Finalize
|
|---|
| 19 |
|
|---|
| 20 | Input : None.
|
|---|
| 21 |
|
|---|
| 22 | Output : Hello World From Thread: Thread No. On Process:
|
|---|
| 23 | Process No.
|
|---|
| 24 |
|
|---|
| 25 | Created : MAY-2013
|
|---|
| 26 |
|
|---|
| 27 | E-Mail : hpcfte@cdac.in
|
|---|
| 28 |
|
|---|
| 29 | ************************************************************************/
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 | /* A Simple Hello World In Mpi-Pthreads. */
|
|---|
| 33 |
|
|---|
| 34 | #include <pthread.h>
|
|---|
| 35 | #include "mpi.h"
|
|---|
| 36 | #include <stdio.h>
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | int Myrank, Numprocs;
|
|---|
| 40 |
|
|---|
| 41 | void * Work(int Myid)
|
|---|
| 42 | {
|
|---|
| 43 | printf(" Hello World! From Thread:%d On Process: %d. \n", Myid, Myrank);
|
|---|
| 44 | return NULL;
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | void main(int Argc, char *Argv[])
|
|---|
| 48 | {
|
|---|
| 49 | pthread_t Thread1, Thread2;
|
|---|
| 50 |
|
|---|
| 51 | MPI_Status Status;
|
|---|
| 52 |
|
|---|
| 53 | /* Initialize Mpi Environment. */
|
|---|
| 54 |
|
|---|
| 55 | MPI_Init(&Argc, &Argv);
|
|---|
| 56 | MPI_Comm_size(MPI_COMM_WORLD, &Numprocs);
|
|---|
| 57 | MPI_Comm_rank(MPI_COMM_WORLD, &Myrank);
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 | pthread_create(&Thread1, NULL, (void *(*) (void *)) Work, (void *) 1);
|
|---|
| 61 |
|
|---|
| 62 | pthread_create(&Thread2, NULL, (void *(*) (void *)) Work, (void *) 2);
|
|---|
| 63 |
|
|---|
| 64 | pthread_join(Thread1, NULL);
|
|---|
| 65 | pthread_join(Thread2, NULL);
|
|---|
| 66 |
|
|---|
| 67 | MPI_Finalize();
|
|---|
| 68 |
|
|---|
| 69 | return;
|
|---|
| 70 |
|
|---|
| 71 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.