void ompClassifyToClusteres(Point* points, Cluster* clusteres, int
numOfPoints, int numOfClusteres, int myid) {
int i, j;
Cluster closestCluster;
double closestDistance;
double tempDistance;
omp_set_num_threads(OMP_NUM_OF_THREADS);
#pragma omp parallel private(j)
{
#pragma omp for
for (i = 0; i < numOfPoints; i++) {
closestCluster = clusteres[0];
closestDistance = distanceFromClusterCenter(points[i], closestCluster);
for (j = 1; j <= numOfClusteres; j++) {
tempDistance = distanceFromClusterCenter(points[i], clusteres[j]);
if (tempDistance < closestDistance) {
closestCluster = clusteres[j];
closestDistance = tempDistance;
}
}
points[i].clusterId = closestCluster.id;
}
}
printPoints(points, numOfPoints);
}
Output: !(output
Im trying to classify points to clusteres for K-MEANS algorithm. So im getting this output (dont notice the checks) in one execution and the right results in the second execution and goes on.. I tried to put some varibales in private but it didnt work. Ill just say that this 3 points need to classify to cluster 0 and im guessing theres a race or something but i cant figure it out.