openacc运行问题



  • 写了一个很简单的二重循环,采用openacc加速

    
    #define WIDTH 1024
    #define HEIGHT 1024
    
    
    void timer_start(struct timeval *timev);
    void timer_end(double *sec,struct timeval *timev);
    
    
    int main() {
       struct timeval t1_start;
       double t1;
       int y,x;
       float image[HEIGHT][WIDTH];
    
     // FILE *fp=fopen("image.pgm","wb");  fprintf(fp,"P5\n%s\n%d %d\n%d\n","#comment",WIDTH,HEIGHT,MAX_COLOR);
    
      timer_start(&t1_start);
    #pragma acc parallel loop  copyout(image) 
      for(y=0;y<HEIGHT;y++) {
        for(x=0;x<WIDTH;x++) {
           image[y][x]= x+y;
        }
      }
      timer_end(&t1,&t1_start);
    
    
    
      printf("Time: %lf seconds.\n", t1);
      //fwrite((unsigned char*)image,sizeof(unsigned char),WIDTH*HEIGHT,fp);fclose(fp);
      return 0;
    }
    
    void timer_start(struct timeval *timev)
    {
        gettimeofday(timev, 0L);
    }
    
    void timer_end(double *sec,struct timeval *timev)
    {
        struct timeval t;
        gettimeofday(&t, 0L);
        *sec = 1.0*(t.tv_sec-timev->tv_sec) + 0.000001*(t.tv_usec-timev->tv_usec);
    }
    

    但是提交运行,有时候可以有时候不行

    [para080@psn010 test_mandelbrot]$ bsub -I -b  -q q_sw_expr -n 1 -cgsp 64  ./a.out
    Job <52832701> has been submitted to queue <q_sw_expr>
    waiting for dispatch ...
    dispatching ...
    Time: 0.000781 seconds.
    Job 52832701 has been finished.
    [para080@psn010 test_mandelbrot]$ bsub -I -b  -q q_sw_expr -n 1 -cgsp 64  ./a.out
    Job <52832702> has been submitted to queue <q_sw_expr>
    waiting for dispatch ...
    dispatching ...
    Time: 0.000807 seconds.
    
    Job 52832702 has been finished.
    [para080@psn010 test_mandelbrot]$ bsub -I -b  -q q_sw_expr -n 1 -cgsp 64  ./a.out
    Job <52832703> has been submitted to queue <q_sw_expr>
    waiting for dispatch ...
    dispatching ...
    [52832703 ## Fri Jun 11 09:03:33 2021] warning: node [12]: user's mpe task: tid= 0, pid= 9119, terminated by sig 11
    
    Job 52832703 has been finished. exit_code is 104
    [para080@psn010 test_mandelbrot]$ bsub -I -b  -q q_sw_expr -n 1 -cgsp 64  ./a.out
    Job <52832705> has been submitted to queue <q_sw_expr>
    waiting for dispatch ...
    dispatching ...
    [52832705 ## Fri Jun 11 09:04:06 2021] warning: node [12]: user's mpe task: tid= 0, pid= 9133, terminated by sig 11
    Job 52832705 has been finished. exit_code is 104
    [para080@psn010 test_mandelbrot]$ bsub -I -b  -q q_sw_expr -n 1 -cgsp 64  ./a.out
    Job <52832707> has been submitted to queue <q_sw_expr>
    waiting for dispatch ...
    dispatching ...
    Time: 0.000779 seconds.
    Job 52832707 has been finished.
    

    u如果哦将 image 定义为 double 就肯定不行


登录后回复