|
@@ -6,6 +6,7 @@
|
|
|
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
|
// obtain one at http://mozilla.org/MPL/2.0/.
|
|
// obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
#include "cumsum.h"
|
|
#include "cumsum.h"
|
|
|
|
|
+#include "parallel_for.h"
|
|
|
#include <numeric>
|
|
#include <numeric>
|
|
|
#include <iostream>
|
|
#include <iostream>
|
|
|
|
|
|
|
@@ -42,8 +43,7 @@ IGL_INLINE void igl::cumsum(
|
|
|
{
|
|
{
|
|
|
Y.row(0).setConstant(0);
|
|
Y.row(0).setConstant(0);
|
|
|
}
|
|
}
|
|
|
-#pragma omp parallel for
|
|
|
|
|
- for(Eigen::Index o = 0;o<num_outer;o++)
|
|
|
|
|
|
|
+ parallel_for(num_outer,[&](const int o)
|
|
|
{
|
|
{
|
|
|
typename DerivedX::Scalar sum = 0;
|
|
typename DerivedX::Scalar sum = 0;
|
|
|
for(Eigen::Index i = 0;i<num_inner;i++)
|
|
for(Eigen::Index i = 0;i<num_inner;i++)
|
|
@@ -52,7 +52,7 @@ IGL_INLINE void igl::cumsum(
|
|
|
const Eigen::Index yi = zero_prefix?i+1:i;
|
|
const Eigen::Index yi = zero_prefix?i+1:i;
|
|
|
Y(yi,o) = sum;
|
|
Y(yi,o) = sum;
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ },1000);
|
|
|
}else
|
|
}else
|
|
|
{
|
|
{
|
|
|
if(zero_prefix)
|
|
if(zero_prefix)
|
|
@@ -62,10 +62,7 @@ IGL_INLINE void igl::cumsum(
|
|
|
for(Eigen::Index i = 0;i<num_inner;i++)
|
|
for(Eigen::Index i = 0;i<num_inner;i++)
|
|
|
{
|
|
{
|
|
|
const Eigen::Index yi = zero_prefix?i+1:i;
|
|
const Eigen::Index yi = zero_prefix?i+1:i;
|
|
|
- // Notice that it is *not* OK to put this above the inner loop
|
|
|
|
|
- // Though here it doesn't seem to pay off...
|
|
|
|
|
-//#pragma omp parallel for
|
|
|
|
|
- for(Eigen::Index o = 0;o<num_outer;o++)
|
|
|
|
|
|
|
+ parallel_for(num_outer,[&](const int o)
|
|
|
{
|
|
{
|
|
|
if(i == 0)
|
|
if(i == 0)
|
|
|
{
|
|
{
|
|
@@ -74,7 +71,7 @@ IGL_INLINE void igl::cumsum(
|
|
|
{
|
|
{
|
|
|
Y(o,yi) = Y(o,yi-1) + X(o,i);
|
|
Y(o,yi) = Y(o,yi-1) + X(o,i);
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ },1000);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -98,4 +95,4 @@ template void igl::cumsum<class Eigen::Matrix<unsigned __int64, -1, 1, 0, -1, 1>
|
|
|
template void igl::cumsum<class Eigen::Matrix<unsigned __int64, 2, 1, 0, 2, 1>, class Eigen::Matrix<unsigned __int64, 2, 1, 0, 2, 1>>(class Eigen::MatrixBase<class Eigen::Matrix<unsigned __int64, 2, 1, 0, 2, 1>> const &, int, class Eigen::PlainObjectBase<class Eigen::Matrix<unsigned __int64, 2, 1, 0, 2, 1>> &);
|
|
template void igl::cumsum<class Eigen::Matrix<unsigned __int64, 2, 1, 0, 2, 1>, class Eigen::Matrix<unsigned __int64, 2, 1, 0, 2, 1>>(class Eigen::MatrixBase<class Eigen::Matrix<unsigned __int64, 2, 1, 0, 2, 1>> const &, int, class Eigen::PlainObjectBase<class Eigen::Matrix<unsigned __int64, 2, 1, 0, 2, 1>> &);
|
|
|
template void igl::cumsum<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1> >(class Eigen::MatrixBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1> > const&, int, class Eigen::PlainObjectBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1> >&);
|
|
template void igl::cumsum<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1> >(class Eigen::MatrixBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1> > const&, int, class Eigen::PlainObjectBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1> >&);
|
|
|
#endif
|
|
#endif
|
|
|
-#endif
|
|
|
|
|
|
|
+#endif
|