In OpenMP: bug (?) when using task and shared together

Tal, Ido ital@mail.ucsd.edu
Mon Oct 4 23:58:00 GMT 2010


Sorry, my bad. The shared variable is on the stack, so I had to add a taskwait at the end (code follows). A warning would have been nice...

--- start c code ---
void recurse(int levelsToGo)
{

    if ( levelsToGo == 0 )
    {
        printf("*");
    }
    else
    {
        #pragma omp task shared(levelsToGo)
        {
            recurse(levelsToGo-1);
        }

        #pragma omp task shared(levelsToGo)
        {
            recurse(levelsToGo-1);
        }

        #pragma omp taskwait

    }
}
--- end c code ---



More information about the Gcc-help mailing list