复杂访问大概是,数组元素访问编号不是循环变量,而是由循环变量计算后得到。
这只是一个警告,如果你确定访问没有问题,就不管它
L
laser2000 发布的帖子
-
RE: OpenACC的entire子句
查看中间代码
void slave_entire_6(void *argv) { int acc_cp_0_size; int acc_cp_1_size; acc_cp_0_size = 64 * 1 * 4; acc_cp_1_size = 256; acc_corenum = acc_get_num_threads(); acc_myid = acc_get_thread_num(); acc_check_ldm(0 + sizeof(_ldm_B) + sizeof(_ldm_i) + sizeof(_ldm_j) + sizeof(acc_data_ret) + sizeof(_ldm_A)); acc_ret = acc_sync_pe_m2l_nostride_copy(_ldm_A,A,acc_cp_0_size); { for (acc_blockindex_i0_0 = acc_myid * 1; acc_blockindex_i0_0 <= 127; acc_blockindex_i0_0 += 1 * acc_corenum) { for (_ldm_i = 0; _ldm_i <= 0; _ldm_i += 1) { for (_ldm_j = 0; _ldm_j <= 63; _ldm_j += 1) { _ldm_B[_ldm_i][_ldm_j] = _ldm_A[_ldm_j] + (_ldm_i + acc_blockindex_i0_0); } } _swacc_ret = acc_sync_pe_l2m_nostride_copy(&B[acc_blockindex_i0_0][0],_ldm_B[0],acc_cp_1_size); } } }
注意
acc_ret = acc_sync_pe_m2l_nostride_copy(_ldm_A,A,acc_cp_0_size);
这就是完全拷贝 A -
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 就肯定不行