Text archives Help
- From: arobison@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1501 - trunk/Interface
- Date: Wed, 18 Jul 2007 17:57:45 -0600 (MDT)
Author: arobison
Date: Wed Jul 18 17:57:45 2007
New Revision: 1501
Modified:
trunk/Interface/RandomNumberGenerator.cc
trunk/Interface/RandomNumberGenerator.h
Log:
Fixed for Macs.
Modified: trunk/Interface/RandomNumberGenerator.cc
==============================================================================
--- trunk/Interface/RandomNumberGenerator.cc (original)
+++ trunk/Interface/RandomNumberGenerator.cc Wed Jul 18 17:57:45 2007
@@ -1,5 +1,4 @@
#include <Interface/RandomNumberGenerator.h>
-#include <Core/Exceptions/InternalError.h>
namespace Manta {
@@ -11,49 +10,10 @@
return nextFloat();
}
- void RandomNumberGenerator::nextPacket(Packet<float>& results, RayPacket&
rays) {
-#ifdef MANTA_SSE
- Packet<unsigned int> uints;
- nextIntPacket(uints, rays);
- for (int i = 0; i < Packet<float>::MaxSize; i+= 4) {
-#if 0
- _mm_store_ps(&results.data[i],
-
_mm_mul_ps(_mm_cvtepi32_ps(_mm_load_si128((__m128i*)&uints.data[i])),
- _mm_set1_ps((float)(1./4294967296.))));
-#else
- // Mask out the top bit (since that's a signed number) but divide by
2/4294967296 instead
- static const float scale_float = 4.65661e-10f;
- _mm_store_ps(&results.data[i],
-
_mm_mul_ps(_mm_cvtepi32_ps(_mm_srli_epi32(_mm_load_si128((__m128i*)&uints.data[i]),
1)),
- _mm_set1_ps(scale_float)));
-#if 0
- // Sanity check for RNGs.
- for (int c = 0; c < 4; c++) {
- if (results.data[i + c] < 0.f || results.data[i + c] >= 1.f) {
- throw SCIRun::InternalError("RNG generated number out of range
[0,1).", __FILE__, __LINE__);
- }
- }
-#endif
-
-#endif
- }
-#else
- for (int i = 0; i < Packet<float>::MaxSize; i++) {
- results.set(i, nextFloat());
- }
-#endif
- }
-
template<>
double RandomNumberGenerator::next<double>()
{
return nextDouble();
- }
-
- void RandomNumberGenerator::nextPacket(Packet<double>& results, RayPacket&
rays) {
- for (int i = 0; i < Packet<double>::MaxSize; i++) {
- results.set(i, nextDouble());
- }
}
} // end namespace Manta
Modified: trunk/Interface/RandomNumberGenerator.h
==============================================================================
--- trunk/Interface/RandomNumberGenerator.h (original)
+++ trunk/Interface/RandomNumberGenerator.h Wed Jul 18 17:57:45 2007
@@ -35,6 +35,7 @@
#include <MantaSSE.h>
#include <Interface/Packet.h>
#include <Interface/RayPacket.h>
+#include <Core/Exceptions/InternalError.h>
namespace Manta {
class RandomNumberGenerator {
@@ -59,8 +60,45 @@
template<class T>
T next() { return 0; }
- virtual void nextPacket(Packet<float>& results, RayPacket& rays);
- virtual void nextPacket(Packet<double>& results, RayPacket& rays);
+ void RandomNumberGenerator::nextPacket(Packet<float>& results,
RayPacket& rays) {
+#ifdef MANTA_SSE
+ Packet<unsigned int> uints;
+ nextIntPacket(uints, rays);
+ for (int i = 0; i < Packet<float>::MaxSize; i+= 4) {
+#if 0
+ _mm_store_ps(&results.data[i],
+
_mm_mul_ps(_mm_cvtepi32_ps(_mm_load_si128((__m128i*)&uints.data[i])),
+ _mm_set1_ps((float)(1./4294967296.))));
+#else
+ // Mask out the top bit (since that's a signed number) but divide by
2/4294967296 instead
+ static const float scale_float = 4.65661e-10f;
+ _mm_store_ps(&results.data[i],
+
_mm_mul_ps(_mm_cvtepi32_ps(_mm_srli_epi32(_mm_load_si128((__m128i*)&uints.data[i]),
1)),
+ _mm_set1_ps(scale_float)));
+#if 0
+ // Sanity check for RNGs.
+ for (int c = 0; c < 4; c++) {
+ if (results.data[i + c] < 0.f || results.data[i + c] >= 1.f) {
+ throw SCIRun::InternalError("RNG generated number out of range
[0,1).", __FILE__, __LINE__);
+ }
+ }
+#endif
+
+#endif
+ }
+#else
+ for (int i = 0; i < Packet<float>::MaxSize; i++) {
+ results.set(i, nextFloat());
+ }
+#endif
+ }
+
+ void RandomNumberGenerator::nextPacket(Packet<double>& results,
RayPacket& rays) {
+ for (int i = 0; i < Packet<double>::MaxSize; i++) {
+ results.set(i, nextDouble());
+ }
+ }
+
virtual double nextDouble() {
return ( (double)nextInt() * (1./4294967296.) );
- [MANTA] r1501 - trunk/Interface, arobison, 07/18/2007
Archive powered by MHonArc 2.6.16.