syntax error when adding omp parallel for

General OpenMP discussion

syntax error when adding omp parallel for

Postby armstrhu » Thu Apr 17, 2014 10:41 am

Hello,
I am having a strange error I cannot track down, I have the code below...

Code: Select all
void archive(const path &paths, const int &today, const int& nprocs)
{
    const std::string log_basepath(paths.LogBaseDir()+"\\" );
    const std::string archive_basepath(".\\"+paths.ArchiveDir()+"\\" );

    std::vector<std::string> log_dir;
    log_dir.resize(3);
    log_dir[0] = paths.STX()+"\\"+paths.LogsDir()+"\\";
    log_dir[1] = paths.T1()+"\\"+paths.LogsDir()+"\\";
    log_dir[2] = paths.T2()+"\\"+paths.LogsDir()+"\\";

    time_t now = time(NULL); //time in seconds from Jan 1 1970
    struct tm *t = localtime(&now);

    //this filter to remove things generated today will be applied if today==1
    std::stringstream ss;
    ss << std::setfill('0') << std::setw(4) << t->tm_year+1900 << std::setw(2) << t->tm_mon+1 << std::setw(2) << t->tm_mday;
    const boost::regex my_filter( ".*_"+ss.str()+"\\d{6,6}.*" );

    for (unsigned int m=0; m<3; ++m)
    {
        boost::filesystem::directory_iterator end_itr; // Default ctor yields past-the-end

        for( boost::filesystem::directory_iterator i( log_basepath+log_dir[m] ); i != end_itr; ++i )
        {
             // do stuff ...
        }
   }



And that compiles fine, when I try to parallelize the inner loop,
Code: Select all
  // ...
    for (unsigned int m=0; m<3; ++m)
    {
        boost::filesystem::directory_iterator end_itr; // Default ctor yields past-the-end

        #pragma omp parallel for schedule(static,1) num_threads(nprocs) default(shared)
        for( boost::filesystem::directory_iterator i( log_basepath+log_dir[m] ); i != end_itr; ++i )
        {
             // do stuff ...
        }
     }


I get a compiler error stating

main.cpp|406|error C2061: syntax error : identifier 'log_basepath'
main.cpp|406|error C2059: syntax error : ';'

line 406 corresponds to the
Code: Select all
for( boost::filesystem::directory_iterator i( log_basepath+log_dir[m] ); i != end_itr; ++i )


right below the #pragma omp parallel for. Any ideas on why this is happening? thanks
armstrhu
 
Posts: 9
Joined: Mon Apr 14, 2014 10:56 am

Re: syntax error when adding omp parallel for

Postby armstrhu » Thu Apr 17, 2014 10:52 am

Think I figured it out...I'm using the visual c++ compiler which only has openmp 2.0 which doesn't support iterators.
armstrhu
 
Posts: 9
Joined: Mon Apr 14, 2014 10:56 am


Return to Using OpenMP

Who is online

Users browsing this forum: Google [Bot] and 2 guests