/* hellosmp.c Fork a number of threads using #pragma omp parallel. Each thread gets it thread-id, then prints its thread-id and says hello. */ #include #include #include int main(int argc, char** argv) { int thread_id; //if the number of threads is not set, pragma omp parallel gives the //default //omp_set_num_threads(4); //#pragma omp parallel private(thread_id) num_threads(4) #pragma omp parallel private(thread_id) { thread_id = omp_get_thread_num(); printf("I am thread %d. Hello world!\n", thread_id); } return 0; }