Skip to content

Commit 8dbb081

Browse files
use temporary accumulator started from zero for more precision (#3318)
1 parent 947f8c6 commit 8dbb081

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cpp/daal/src/algorithms/kmeans/kmeans_lloyd_impl.i

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ Status TaskKMeansLloyd<algorithmFPType, cpu>::addNTToTaskThreadedCSR(const Numer
302302
SpBlasInst<algorithmFPType, cpu>::xxcsrmm(&transa, &_n, &_c, &_p, &alpha, matdescra, data, (DAAL_INT *)colIdx, (DAAL_INT *)rowIdx, inClusters,
303303
&_p, &beta, x_clusters, &_n);
304304

305-
size_t csrCursor = 0;
305+
algorithmFPType goal = 0;
306+
size_t csrCursor = 0;
306307
for (size_t i = 0; i < blockSize; i++)
307308
{
308309
algorithmFPType minGoalVal = clustersSq[0] - x_clusters[i];
@@ -329,7 +330,7 @@ Status TaskKMeansLloyd<algorithmFPType, cpu>::addNTToTaskThreadedCSR(const Numer
329330

330331
kmeansInsertCandidate(tt, minGoalVal, k * blockSizeDefault + i);
331332

332-
*trg += minGoalVal;
333+
goal += minGoalVal;
333334

334335
cS0[minIdx]++;
335336

@@ -339,6 +340,7 @@ Status TaskKMeansLloyd<algorithmFPType, cpu>::addNTToTaskThreadedCSR(const Numer
339340
assignments[i] = (int)minIdx;
340341
}
341342
}
343+
*trg += goal;
342344
});
343345
return safeStat.detach();
344346
}

0 commit comments

Comments
 (0)