#include #include #include int main (int argc, char *argv[]) { int nthreads, thread_id; int id, np; char processor_name[MPI_MAX_PROCESSOR_NAME]; int processor_name_len; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &np); MPI_Comm_rank(MPI_COMM_WORLD, &id); MPI_Get_processor_name(processor_name, &processor_name_len); #pragma omp parallel private(nthreads, thread_id) { thread_id = omp_get_thread_num(); printf("Hello World from thread %d, process %d of %d, hostname %s\n", thread_id, id, np, processor_name); if (thread_id == 0) { nthreads = omp_get_num_threads(); printf("Thread %d on process %d of %d reports: nthreads = %d\n", thread_id, id, np, nthreads); } } MPI_Finalize(); return 0; }