无法编译#pragma omp任务依赖

时间:2015-11-16 01:15:01

标签: c dependencies task openmp

当我使用gcc

编译此代码时
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <pthread.h>
#include <stdbool.h>
#include <string.h>
#include <omp.h>

long result=0;

void foo() {
#pragma omp parallel 
    { 


    #pragma omp for schedule(dynamic,3) 
    for (long i = 0; i < 10; i++){
      #pragma omp task shared(result) depend(in:result) depend(out:result)
      {
          result++;
      }
      #pragma omp task depend(in: result)
          result++;
      }

   #pragma omp taskwait
   printf("result = %ld\n", result);
    }
}

int main(int argc, char *argv[]) {
   foo();
  printf("result = %ld\n", result);
}`

出现此消息

  

test_task_name.c:在函数'foo'中:

     

test_task_name.c:18:34:错误:在'depend'之前预期'#pragma omp'子句     #pragma omp task shared(result)depend(in:result)depend(out:result)                                     ^

     

test_task_name.c:21:19:错误:在'depend'之前预期'#pragma omp'子句     #pragma omp task depend(in:result)

我使用此Make文件编译我的OpenMP应用程序:

.SUFFIXES: -gomp  -gasm
CC = gcc
OPENMP     = -fopenmp
CFLAGS   = -Wall -O -std=c99 -march=native -I.

.c-gasm:
     $(CC) $(CFLAGS) $(OPENMP) -c -S $< -o $@

.c-gomp: 
    $(CC) $(CFLAGS) $(OPENMP) $< -o $@

0 个答案:

没有答案