gpt4 book ai didi

c++ - openmp collapse with inner loop reduction

转载 作者:行者123 更新时间:2023-12-04 08:10:21 25 4
gpt4 key购买 nike

<分区>

我正在尝试使用 #pragma omp simd 对嵌套循环进行矢量化处理,但内部循环有所减少。有什么办法吗?

  #pragma omp simd collapse(2) reduction(+:total[i])
for (int i=0; i<N; i++){
for (int j=0; j<N; j++){

float distance = sqrt(
(x[i][0]-x[j][0]) * (x[i][0]-x[j][0]) +
(x[i][1]-x[j][1]) * (x[i][1]-x[j][1]) +
(x[i][2]-x[j][2]) * (x[i][2]-x[j][2])
);

total[i] += distance;
}
}

目前,它只是在编译时给出了这个错误:

error: identifier "i" is undefined
#pragma omp simd collapse(2) reduction(+:total[i])
^

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com