IntelLabs / ParallelAccelerator.jl

The ParallelAccelerator package, part of the High Performance Scripting project at Intel Labs
BSD 2-Clause "Simplified" License
294 stars 32 forks source link

Conflict in label numbers #77

Closed ehsantn closed 8 years ago

ehsantn commented 8 years ago

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()
ehsantn commented 8 years ago

I mean control flow labels not the variable name here :)