Where is my flaw, regarding use of OpenMP critica

This is a discussion on Where is my flaw, regarding use of OpenMP critica within the C++ Programming forums, part of the General Programming Boards category; How does variable "not_findable" change from line 28 to 30, sometimes. Code: using namespace std; #include <vector> typedef size_t T; ...

  1. #1
    ass
    ass is offline
    Registered User
    Join Date
    Nov 2011
    Posts
    2

    Question Where is my flaw, regarding use of OpenMP critica

    How does variable "not_findable" change from line 28 to 30, sometimes.
    Code:
      using namespace std;
      #include <vector>
      typedef size_t T;
      #include <assert.h>    
      #include <omp.h>
      #include <iostream>
     
      void foo(T& F_count)
      {
        T I=0;
        bool not_findable=false;
        bool found=false;    
        #pragma omp parallel
        {
          bool finder=false;
          while(true)
          {
        {
          bool break_out;
          #pragma omp critica()
          {
            if(!not_findable)
            {
              if(!(I<F_count))
            not_findable=true;
              ++I;
            }
    cerr << not_findable << endl;
            break_out=not_findable;
    cerr << not_findable << endl;
          }
          if(break_out)
            break;
        }
        {
          #pragma omp critica()    
          {
            if(true && !found)
            {
              found=true;
              finder=true;
            }
          }
          if(found)
            break;
        }
          }
          #pragma omp barrier
          if(finder)
        --F_count;
        }
      }
     
    int main()
    {
      T F_count=0;
      for(T I_count=0;I_count<4;++I_count)
      {
        ++F_count;
        foo(F_count);
        assert(2<I_count    ||    0==F_count);
      }
      return 0;
    }
    # g++ -fopenmp a.cpp
    # false;while [ $? != 0 ]; do echo 4 | ./a.out; done

  2. #2
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426
    Code:
    #pragma omp critica()
    Sure you didn't leave out an "l"?
    Consider this post signed

  3. #3
    ass
    ass is offline
    Registered User
    Join Date
    Nov 2011
    Posts
    2

    Thumbs up [solved]

    Thank you bernt.
    Code:
    #pragma omp critical//()
    Seemed to fix it.

    I might have made the error of changing
    "critical()" -> "critica()"
    Since first one gives compile error.

    I seem to have a bad habit of not removing (), when not supplying any, parameters.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenMP question
    By oacikgoz in forum C++ Programming
    Replies: 0
    Last Post: 01-28-2009, 12:52 PM
  2. Design flaw in C++?
    By @nthony in forum C++ Programming
    Replies: 24
    Last Post: 10-20-2008, 08:47 PM
  3. Thoughts on OpenMP
    By abachler in forum C++ Programming
    Replies: 3
    Last Post: 02-04-2008, 04:25 PM
  4. openmp
    By l2u in forum Tech Board
    Replies: 0
    Last Post: 04-12-2007, 06:40 PM
  5. is this a design flaw
    By blight2c in forum C++ Programming
    Replies: 5
    Last Post: 03-20-2002, 12:33 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21