openacc struct in loop和if-statement

时间:2016-08-15 16:23:22

标签: loops struct openacc pgi

我有以下代码:

#pragma acc data present(listOfPolygons1, listOfPolygons2, polygon1, polygon2) copy(listOfBoolean[0:numOfPolygonsPair])
#pragma acc parallel loop
    // do point-in-polygon in this nested loop
    for (i=0; i<polygonCount1; i++){

        polygon1 = listOfPolygons1[i];

        for (j=0; j<polygonCount2; j++){

            polygon2 = listOfPolygons2[j];

            idx = polygonCount2 * i + j;

            if (listOfBoolean[idx]==0){
                // don't even have an intersection
                continue;
            } else {
                // do point-in-polygon test

                for (k=0; k<polygon2.num_vertices; k++){  // line 139

                }

            }
        }
    }

&#34; polygon1&#34;和&#34; polygon2&#34;结构。
&#34; listOfPolygons1&#34;和&#34; listOfPolygons2&#34;是带有&#34; polygon1&#34;列表的结构数组;和&#34; polygon2&#34;相应地,
&#34; listOfBoolean&#34;是一个int
数组 两个&#34; listOfPolygons1&#34;和&#34; listOfPolygon2&#34;被深度复制到加速器并在之前的循环中成功使用(代码未在此处显示)

代码可以编译但运行时会产生以下错误消息:

call to cuEventSynchronize returned error 716: Misaligned address

我的观察
问题似乎在第139行。 当我使用&#34; k&lt; polygon2.num_vertices&#34;时,它产生了我提到的错误。
但是,如果我改变这一行:

 for (k=0; k<listOfPolygons2[j].num_vertices; k++) // not using struct "polygon2"

(更新1)或此:

for (k=0; k<polygon1.num_vertices; k++) // use polygon1.num_vertices instead

程序可以编译并成功运行

为什么会这样,我怎样才能使用struct&#34; polygon2&#34;这里吗?

0 个答案:

没有答案