#include #include #include void main(int argc, char **argv ) { char host[80]; int procs,i,a,b,c,t,m; WSADATA WsaDat; if (WSAStartup(MAKEWORD(1, 1), &WsaDat) != 0) printf("WSA Initialization failed."); if (gethostname(host,sizeof(host)) == SOCKET_ERROR) { printf("ERROR getting hostname\n"); exit(0); } printf("Hello from %s\n", host); //Determine the number of physical processors procs = omp_get_num_procs(); printf("%s has %d processors\n",host,procs); //Determine how many threads // may be set by OMP_NUM_THREADS environment variable printf("OMP_NUM_THREADS = %d\n",omp_get_max_threads()); printf("OMP_DYNAMIC = "); if (!omp_get_dynamic()) { printf("FALSE\n"); //Set the number of threads printf("Setting NUM_THREADS = %d\n",procs * atoi(argv[1])); omp_set_num_threads(procs * atoi(argv[1])); } else printf("TRUE\n"); //Determine Maximum number of threads that can be created printf("Maximum number of threads = %d\n",omp_get_max_threads()); #pragma omp parallel printf("Hello from thread id %d\n",omp_get_thread_num()); }