parallel processing - OpenMP tasking - way of preventing a specific thread from executing tasks? -
i creating several tasks in openmp, reason tasks executed same thread. code has following pattern:
#pragma omp parallel num_threads(n_threads) #pragma omp single while(!found){ /.... operations k, e, y, dist, u, step #pragma omp task firstprivate(k, e, y, dist, u, step) process(k, e, y, dist, u, step, h, out); }
is there way of forcing openmp runtime system assign tasks threads 1 creates task?
thanks
edit:
void process(int a[]){ printf("thread %d processing\n", omp_get_thread_num()); /* heavy operations (used sleep simulate them)*/ sleep(10); } int main(){ int a[10]; int i, j; #pragma omp parallel num_threads(4) { #pragma omp single { (j = 0; j < 10; j++) { /* compute */ (i = 0; < 10; i++) { a[i] += 1; } #pragma omp task firstprivate(a) process(a); } printf("thread %d finished preprocessing\n", omp_get_thread_num()); } } }
output:
thread 1 processing thread 1 processing thread 1 processing thread 1 processing thread 1 processing thread 1 processing thread 1 processing thread 1 processing thread 1 processing thread 1 processing thread 1 finished preprocessing
isn't same question in other post (task scheduling points of openmp tasks)
the answer 1 here is: no, cannot control how openmp implementation assigns tasks openmp threads of parallel team.
may suggest post piece of code compiles? easier check why code not behave think should behave.
with example code added op, here's behavior on machine:
$> gcc -fopenmp omp.c $> ./a.out thread 0 finished preprocessing thread 0 processing thread 3 processing thread 2 processing thread 1 processing thread 0 processing thread 3 processing thread 2 processing thread 1 processing thread 0 processing thread 3 processing $> gcc --version gcc (suse linux) 4.7.2 20130108 [gcc-4_7-branch revision 195012] copyright (c) 2012 free software foundation, inc. free software; see source copying conditions. there no warranty; not merchantability or fitness particular purpose. $> icc -openmp omp.c $> ./a.out thread 0 finished preprocessing thread 0 processing thread 3 processing thread 2 processing thread 1 processing thread 0 processing thread 3 processing thread 2 processing thread 1 processing thread 0 processing thread 3 processing mklemm-mobl2-vm:~/tmp [0]> icc -v intel(r) c intel(r) 64 compiler xe applications running on intel(r) 64, version 14.0.1.106 build 20131008 copyright (c) 1985-2013 intel corporation. rights reserved.
what compiler using?
cheers, -michael
Comments
Post a Comment