Skip to content

Commit c021566

Browse files
committed
Implement DisceretGen for double in Arm NEON
1 parent bd4366a commit c021566

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

EigenRand/Dists/Discrete.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,6 @@ namespace Eigen
692692
}
693693
}
694694

695-
// Vectorized packetOp for NEON is not supported
696-
#ifndef EIGEN_VECTORIZE_NEON
697695
template<typename Packet, typename Rng>
698696
EIGEN_STRONG_INLINE const Packet packetOp(Rng&& rng)
699697
{
@@ -778,7 +776,6 @@ namespace Eigen
778776
#endif
779777
}
780778
}
781-
#endif
782779
};
783780

784781
template<typename> class BinomialGen;
@@ -1946,16 +1943,6 @@ namespace Eigen
19461943
}
19471944
}
19481945

1949-
#ifdef EIGEN_VECTORIZE_NEON
1950-
namespace internal
1951-
{
1952-
template<typename _Scalar, typename Urng, bool _mutable>
1953-
struct functor_traits<scalar_rng_adaptor<Rand::DiscreteGen<_Scalar, double>, _Scalar, Urng, _mutable> >
1954-
{
1955-
enum { Cost = HugeCost, PacketAccess = 0, IsRepeatable = false };
1956-
};
1957-
}
1958-
#endif
19591946
}
19601947

19611948
#endif

EigenRand/arch/NEON/MorePacketMath.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,30 @@ namespace Eigen
307307
return vld1q_f32(t);
308308
}
309309

310+
template<>
311+
EIGEN_STRONG_INLINE Packet2d pgather<Packet4i>(const double* addr, const Packet4i& index, bool upperhalf)
312+
{
313+
int32_t u[4];
314+
vst1q_s32(u, index);
315+
double t[2];
316+
if (upperhalf)
317+
{
318+
t[0] = addr[u[2]];
319+
t[1] = addr[u[3]];
320+
}
321+
else
322+
{
323+
t[0] = addr[u[0]];
324+
t[1] = addr[u[1]];
325+
}
326+
return vld1q_f64(t);
327+
}
328+
329+
EIGEN_STRONG_INLINE Packet4i combine_low32(const Packet4i& a, const Packet4i& b)
330+
{
331+
return vuzp1q_s32(a, b);
332+
}
333+
310334
template<>
311335
EIGEN_STRONG_INLINE int pmovemask<Packet4f>(const Packet4f& a)
312336
{

0 commit comments

Comments
 (0)