我的简单OpenMP程序中的奇怪错误(使用C)

时间:2014-12-12 08:08:07

标签: c recursion openmp

我在尝试编译C程序时遇到此错误:

omptest.c: In function ‘int ack(int, int)’:
omptest.c:13:23: error: invalid form of ‘#pragma omp atomic’ before ‘;’ token
   ans = ack(m-1,1);}
                   ^
omptest.c:18:31: error: invalid form of ‘#pragma omp atomic’ before ‘;’ token
   ans = ack(m-1, ack(m,n-1));

我不知道如何发生此错误。这是我的计划:

#include <stdio.h>
#include <omp.h>

int ack(int m, int n)
{
  int ans;
  if (m == 0)
    ans = n+1;
  else if (n == 0)
    #pragma omp task
    {
      #pragma omp atomic
      ans = ack(m-1,1);}
  else
  #pragma omp task
  {
    #pragma omp atomic
    ans = ack(m-1, ack(m,n-1));}
  #pragma omp taskwait
  return (ans);
}

int main(int argc, char const *argv[])
{
  int i,j;

  for (i=1; i<6; i++)
    for (j=0;j<6; j++)
      printf("ackerman (%d,%d) is: %d\n",i,j, ack(i,j));
  return 0;
}

0 个答案:

没有答案
相关问题