int th_id, nthreads;
#pragma omp parallel private(th_id)
{
th_id = omp_get_thread_num();
printf("Hello World from thread %d\n", th_id);
#pragma omp barrier
if ( th_id == 0 ) {
nthreads = omp_get_num_threads();
printf("There are %d threads\n",nthreads);
}
}
return EXIT_SUCCESS;
}
Trying again to compile the ATS example results in some gcc errors:
hello_dats.c:132:9: error: expected declaration specifiers before ‘#pragma’
#pragma omp parallel private(th_id)
^
hello_dats.c:133:1: error: expected identifier or ‘(’ before ‘{’ token
{
^
This is no surprise when we look at the code around the #pragma:
#pragma omp parallel private(th_id)
{
/*
/home/brand_000/ATS-Postiats/contrib/libats-bbarker/OpenMP/TEST/hello.dats: 543(line=32, offs=1) -- 5\
50(line=34, offs=3)
*/
}
#if(0)
ATSglobaldec()
atsvoid_t0ype
mainats_void_0() ;
#endif // end of [QUALIFIED]
//...
A closing brace is inserted. However, if we leave out the open brace in our C code, no braces at all (opening or closing) are inserted, and we only get the first error about "expected declaration specifiers" (though I don't think ultimately we could leave out the braces if we want the #pragma to work correctly.
A closer look seems to suggest that the inserted c code is not in the right place, which to be fair, the book did warn about the c code being placed in an arbitrary location.
Any suggestions on what to try next?