#include #include #include #include #define NAMELENGTH 256 main () { char hostname[NAMELENGTH]; int nthreads, tid; /* Fork a team of threads with each thread having a private tid variable */ #pragma offload target(mic) gethostname(hostname,NAMELENGTH); #pragma offload target (mic) #pragma omp parallel private(tid) { /* Obtain and print thread id */ tid = omp_get_thread_num(); printf("Hello World from thread = %d\n", tid); /* Only master thread does this */ if (tid == 0) { nthreads = omp_get_num_threads(); printf("Number of threads = %d, running on %s\n", nthreads,hostname); } } /* All threads join master thread and terminate */ }