#include <omp.h>
#include <stdio.h>
int main (int argc, char *argv[])
{
#pragma omp parallel
{
printf ("Hello world! I'm thread %d out of %d threads.\n",
omp_get_thread_num(), omp_get_num_threads());
}
return 0;
}
This code simply creates a team of threads (according to the environment variable OMP_NUM_THREADS
- and if not defined will create one per logical core on the system) and each thread will identify itself besides printing the typical Hello world message.