Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1519 - trunk/Core/Math


Chronological Thread 
  • From: brownlee@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1519 - trunk/Core/Math
  • Date: Fri, 20 Jul 2007 02:30:31 -0600 (MDT)

Author: brownlee
Date: Fri Jul 20 02:30:31 2007
New Revision: 1519

Modified:
   trunk/Core/Math/CheapRNG.h
Log:
reverting CheapRNG.h after accidental commit

Modified: trunk/Core/Math/CheapRNG.h
==============================================================================
--- trunk/Core/Math/CheapRNG.h  (original)
+++ trunk/Core/Math/CheapRNG.h  Fri Jul 20 02:30:31 2007
@@ -53,8 +53,10 @@
 // properties of integer multiplication.
 
 // For the Real type
-#include <MantaTypes.h> 
+#include <MantaTypes.h>
 #include <Interface/RandomNumberGenerator.h>
+#include <MantaSSE.h>
+#include <Core/Math/SSEDefs.h>
 #include <Core/Util/AlignedAllocator.h>
 
 namespace Manta {
@@ -67,22 +69,49 @@
     // members.
     typedef unsigned int uint32;
   protected:
-    
+
     char padding0 [128];
     uint32 val;
+#ifdef MANTA_SSE
+    __m128i val_sse;
+#endif
     char padding1 [128];
   public:
     // Your seed value is up to the fates.  You should call seed.
     CheapRNG() {}
     static void create(RandomNumberGenerator*& rng ) { rng = new CheapRNG(); 
}
-      
+
     virtual void seed(unsigned int seed_val) {
       val = seed_val;
+#ifdef MANTA_SSE
+      // TODO(boulos): Find a better way to seed this.  Normally you
+      // could just call nextInt() but all that will do for this RNG
+      // is make the sequences out of sync by one iteration... So you
+      // want offsets.
+      val_sse = _mm_set_epi32(seed_val,
+                              seed_val + 1,
+                              seed_val,
+                              seed_val + 1);
+#endif
     }
 
     virtual unsigned int nextInt() {
       val = 1664525*val + 1013904223;
       return val;
+    }
+
+    virtual void nextIntPacket(Packet<unsigned int>& results) {
+#ifdef MANTA_SSE
+      for (int i = 0; i < Packet<unsigned int>::MaxSize; i+=4) {
+        val_sse = _mm_add_epi32(_mm_set_epi32(2531011, 10395331, 13737667, 
1),
+                                _mm_mullo_epi32(val_sse, 
_mm_set_epi32(214013, 17405, 214013, 69069)));
+        _mm_store_si128((__m128i*)&results.data[i], val_sse);
+      }
+#else
+      for (int i = 0; i < Packet<unsigned int>::MaxSize; i++) {
+        results.set(i, nextInt());
+      }
+#endif
     }
   }; // end class CheapRNG
 




  • [MANTA] r1519 - trunk/Core/Math, brownlee, 07/20/2007

Archive powered by MHonArc 2.6.16.

Top of page