#include "pvm3.h"
main() {
int cc, tid, msgtag;
char buf[100];
printf("i'm t%x\n", pvm_mytid());
cc = pvm_spawn("hello_child", (char**)0, 0, "", 1, &tid);
if (cc == 1) {
msgtag = 1;
pvm_recv(tid, msgtag);
pvm_upkstr(buf);
printf("from t%x: %s\n", tid, buf);
} else
printf("can't start hello_child\n");
pvm_exit();
}
#include "pvm3.h"
main() {
int ptid, msgtag;
char buf[100];
ptid = pvm_parent();
strcpy(buf, "hello, world from ");
gethostname(buf + strlen(buf), 64);
msgtag = 1;
pvm_initsend(PvmDataDefault);
pvm_pkstr(buf);
pvm_send(ptid, msgtag);
pvm_exit();
}
program OMP_PRINT
implicit none
#include "f_hpm.h"
integer :: myid, nthreads
integer :: OMP_GET_NUM_THREADS, OMP_GET_THREAD_NUM
call f_hpminit(0,"hpmfile")
!$OMP PARALLEL default(none) private(myid) &
!$OMP shared(nthreads)
! Determine the number of threads and their id
myid = OMP_GET_THREAD_NUM()
nthreads = OMP_GET_NUM_THREADS();
!$OMP BARRIER
call f_hpmtstart(1+myid,"printcounter")
print*,'myid = ', myid, ' nthreads ', nthreads
! Some actual work is done in parallel here
call f_hpmtstop(1+myid)
!$OMP END PARALLEL
call f_hpmterminate(0)
end program OMP_PRINT