ICC fails for this program since labels have conflicting names. The body of a parallel for loop defines a label that is already defined.
using ParallelAccelerator
@acc function kmeans(X, centroids, dim, numPoint, numCenter, iterNum)
for l in 1:iterNum
dist = [ Float64[sqrt(sum((X[:,i].-centroids[:,j]).^2)) for j in 1:numCenter] for i in 1:numPoint]
labels = Int[indmin(dist[i]) for i in 1:numPoint]
centroids = Float64[ (centroids[j,i]+sum(X[j,labels.==i]))/sum(labels.==i) for j in 1:dim, i in 1:numCenter]
end
return centroids
end
function main()
dim = 2
numPoint = 1000
numCenter = 5
iterNum = 10
X = rand(dim, numPoint)
centroids = rand(dim, numCenter)
centroids_out = kmeans(X, centroids, dim, numPoint, numCenter, iterNum)
println(centroids_out)
end
main()
ICC fails for this program since labels have conflicting names. The body of a parallel for loop defines a label that is already defined.