Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1321 - in trunk: Core Core/Util Engine/ImageTraversers


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1321 - in trunk: Core Core/Util Engine/ImageTraversers
  • Date: Mon, 2 Apr 2007 15:23:40 -0600 (MDT)

Author: bigler
Date: Mon Apr  2 15:23:39 2007
New Revision: 1321

Added:
   trunk/Core/Util/AlignedAllocator.cc
   trunk/Core/Util/AlignedAllocator.h
Modified:
   trunk/Core/CMakeLists.txt
   trunk/Engine/ImageTraversers/DeadlineImageTraverser.cc
Log:

Core/CMakeLists.txt
Core/Util/AlignedAllocator.cc
Core/Util/AlignedAllocator.h

  Added AlignedAllocator that helps with classes that need 16 byte
  aligned addresses when allocated with new.

Engine/ImageTraversers/DeadlineImageTraverser.cc

  Fixed typo for argument parsing.


Modified: trunk/Core/CMakeLists.txt
==============================================================================
--- trunk/Core/CMakeLists.txt   (original)
+++ trunk/Core/CMakeLists.txt   Mon Apr  2 15:23:39 2007
@@ -54,6 +54,8 @@
      Math/SSEDefs.cc
      )
 SET (CORE_SOURCES ${CORE_SOURCES}
+     Util/AlignedAllocator.h
+     Util/AlignedAllocator.cc
      Util/Args.h
      Util/Args.cc
      Util/CPUTime.h

Added: trunk/Core/Util/AlignedAllocator.cc
==============================================================================
--- (empty file)
+++ trunk/Core/Util/AlignedAllocator.cc Mon Apr  2 15:23:39 2007
@@ -0,0 +1,61 @@
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005-2006
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
+#include <Core/Util/AlignedAllocator.h>
+
+#include <stdlib.h>
+#include <errno.h>
+
+// Helper function to get back an aligned memory address
+void* Manta::allocateAligned(size_t size, size_t alignment)
+{
+  void* memptr;
+  int return_code = posix_memalign(&memptr, alignment, size);
+  switch (return_code) {
+  case 0:
+    return memptr;
+    break;
+  case EINVAL:
+    // Throw an exception?
+    break;
+  case ENOMEM:
+    // Throw an exception?
+    break;
+  }
+  return 0;
+}
+
+// Deallocate the aligned memory.
+void  Manta::deallocateAligned(void* mem)
+{
+  if (mem)
+    free(mem);
+}
+
+
+

Added: trunk/Core/Util/AlignedAllocator.h
==============================================================================
--- (empty file)
+++ trunk/Core/Util/AlignedAllocator.h  Mon Apr  2 15:23:39 2007
@@ -0,0 +1,61 @@
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005-2006
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef _CORE_UTIL_ALIGNCLASS__H
+#define _CORE_UTIL_ALIGNCLASS__H
+
+#include <stddef.h> // for size_t definition
+#include <SCIRun/Core/Util/Assert.h>
+
+namespace Manta {
+
+  // Helper function to get back an aligned memory address
+  void* allocateAligned(size_t size, size_t alignment);
+  // Deallocate the aligned memory.
+  void  deallocateAligned(void* mem);
+
+  // Inherit from this class if you want to be able to call new and
+  // delete on an object.
+  template<class ParentT, size_t Alignment = 16>
+  class AlignedAllocator {
+  public:
+    void * operator new (size_t size)
+    {
+      ASSERT(size == sizeof (ParentT));
+      return allocateAligned(size, Alignment);
+    }
+    void operator delete (void * mem)
+    {
+      deallocateAligned(mem);
+    }
+  };
+
+}  // end namespace Manta
+
+#endif
+

Modified: trunk/Engine/ImageTraversers/DeadlineImageTraverser.cc
==============================================================================
--- trunk/Engine/ImageTraversers/DeadlineImageTraverser.cc      (original)
+++ trunk/Engine/ImageTraversers/DeadlineImageTraverser.cc      Mon Apr  2 
15:23:39 2007
@@ -97,7 +97,7 @@
         priority = LuminanceVariance;
       else
         throw IllegalArgument("DeadlineImageTraverser -priority, bad 
priority", i, args);
-    } else if("-refinmentRatio"){
+    } else if(arg == "-refinmentRatio"){
       if(!getResolutionArg(i, args, xrefinementRatio, yrefinementRatio))
         throw IllegalArgument("DeadlineImageTraverser -refinement", i, args);
     } else {




  • [MANTA] r1321 - in trunk: Core Core/Util Engine/ImageTraversers, bigler, 04/02/2007

Archive powered by MHonArc 2.6.16.

Top of page