Skip to content

Commit 2c4fd16

Browse files
authored
Update kohonen_som_topology.c
fix: add OpenMP parallel region for proper loop parallelization
1 parent e5dad3f commit 2c4fd16

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

‎machine_learning/kohonen_som_topology.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ double kohonen_update_weights(const double *X, struct kohonen_array_3d *W,
239239
double d_min = 0.f;
240240

241241
#ifdef _OPENMP
242-
#pragma omp for
242+
#pragma omp parallel for
243243
#endif
244244
// step 1: for each 2D output point
245245
for (x = 0; x < num_out; x++)
@@ -271,9 +271,7 @@ double kohonen_update_weights(const double *X, struct kohonen_array_3d *W,
271271

272272
// step 3b: update the weights of nodes in the
273273
// neighborhood
274-
#ifdef _OPENMP
275-
#pragma omp for
276-
#endif
274+
277275
for (x = from_x; x < to_x; x++)
278276
{
279277
for (y = from_y; y < to_y; y++)
@@ -306,7 +304,7 @@ double kohonen_update_weights(const double *X, struct kohonen_array_3d *W,
306304
*
307305
* \param[in] X data set
308306
* \param[in,out] W weights matrix
309-
* \param[in] num_samples number of output points
307+
* \param[in] num_samples number of input samples
310308
* \param[in] num_features number of features per input sample
311309
* \param[in] num_out number of output points
312310
* \param[in] alpha_min terminal value of alpha

0 commit comments

Comments
 (0)