]> OCCT Git - occt-copy.git/commitdiff
0024238: Made some changes to work with static aligned array
authorazv <artem.zhidkov@opencascade.com>
Wed, 27 Nov 2013 05:59:18 +0000 (09:59 +0400)
committerazv <artem.zhidkov@opencascade.com>
Wed, 27 Nov 2013 05:59:18 +0000 (09:59 +0400)
src/BSplSLib/BSplSLib.cxx
src/NCollection/FILES
src/NCollection/NCollection_AlignedLocalArray.hxx [new file with mode: 0644]
src/PLib/PLib.cdl

index 0775da830e71909ae9d27194e33da8847243ec1b..6bd2d3cce09fc059b77a5b07a43b6f3e31de9388 100755 (executable)
@@ -36,7 +36,7 @@
 #include <Standard_NotImplemented.hxx>
 #include <Standard_ConstructionError.hxx>
 #include <math_Matrix.hxx>
-#include <NCollection_AlignAllocator.hxx>
+#include <NCollection_AlignedLocalArray.hxx>
 
 // for null derivatives
 static Standard_Real BSplSLib_zero[3] = {0.0, 0.0, 0.0};
@@ -2102,7 +2102,8 @@ void  BSplSLib::CacheD0(
     dimension = 4 * (VDegree + 1);
   }
 
-  Standard_Real* locpoles = (Standard_Real*) NCollection_AlignAllocator::Allocate(dimension*sizeof(Standard_Real), DATA_ALIGNMENT);
+  NCollection_AlignedLocalArray<Standard_Real> locpoles(dimension);
+//  Standard_Real* locpoles = (Standard_Real*) NCollection_AlignAllocator::Allocate(dimension*sizeof(Standard_Real), DATA_ALIGNMENT);
 
   PLib::NoDerivativeEvalPolynomial(new_parameter[0],
           max_degree,
@@ -2133,7 +2134,7 @@ void  BSplSLib::CacheD0(
     myPoint[2] = local_pole_and_weight[2];
   }
 
-  NCollection_AlignAllocator::Free(locpoles);
+//  NCollection_AlignAllocator::Free(locpoles);
 }
 
 
@@ -2203,7 +2204,8 @@ void  BSplSLib::CacheD1(
     my_vec_max = (Standard_Real *) &aVecU;
   }
 
-  Standard_Real* locpoles = (Standard_Real*) NCollection_AlignAllocator::Allocate(2*dimension*sizeof(Standard_Real), DATA_ALIGNMENT);
+  NCollection_AlignedLocalArray<Standard_Real> locpoles(2*dimension);
+//  Standard_Real* locpoles = (Standard_Real*) NCollection_AlignAllocator::Allocate(2*dimension*sizeof(Standard_Real), DATA_ALIGNMENT);
 
   PLib::EvalPolynomialWithAlignedData(new_parameter[0],
           1,
@@ -2252,7 +2254,7 @@ void  BSplSLib::CacheD1(
     }
   }
 
-  NCollection_AlignAllocator::Free(locpoles);
+//  NCollection_AlignAllocator::Free(locpoles);
 }
 
 
@@ -2339,7 +2341,8 @@ void  BSplSLib::CacheD2(
     my_vec_max_max = (Standard_Real *) &aVecUU;
   }
 
-  Standard_Real* locpoles = (Standard_Real*) NCollection_AlignAllocator::Allocate(3*dimension*sizeof(Standard_Real), DATA_ALIGNMENT);
+  NCollection_AlignedLocalArray<Standard_Real> locpoles(3*dimension);
+//  Standard_Real* locpoles = (Standard_Real*) NCollection_AlignAllocator::Allocate(3*dimension*sizeof(Standard_Real), DATA_ALIGNMENT);
 
   //
   // initialize in case min or max degree are less than 2
@@ -2425,7 +2428,7 @@ void  BSplSLib::CacheD2(
     }
   }
 
-  NCollection_AlignAllocator::Free(locpoles);
+//  NCollection_AlignAllocator::Free(locpoles);
 }
 
 //=======================================================================
index 2ecd6d92a3415b0ca9313d12775346b50b7f742a..e91bb56712ede6310266b230bd3c9a8c032511cb 100755 (executable)
@@ -7,6 +7,7 @@ NCollection_IncAllocator.cxx
 NCollection_HeapAllocator.hxx
 NCollection_HeapAllocator.cxx
 NCollection_StdAllocator.hxx
+NCollection_AlignAllocator.cxx
 NCollection_AlignAllocator.hxx
 
 NCollection_ListNode.hxx
@@ -75,6 +76,7 @@ NCollection_UtfString.hxx
 NCollection_UtfString.lxx
 NCollection_String.hxx
 
+NCollection_AlignedLocalArray.hxx
 NCollection_LocalArray.hxx
 NCollection_SparseArray.hxx
 NCollection_SparseArrayBase.hxx
diff --git a/src/NCollection/NCollection_AlignedLocalArray.hxx b/src/NCollection/NCollection_AlignedLocalArray.hxx
new file mode 100644 (file)
index 0000000..0268c86
--- /dev/null
@@ -0,0 +1,85 @@
+// Created on: 2009-09-23
+// Copyright (c) 2009-2012 OPEN CASCADE SAS
+//
+// The content of this file is subject to the Open CASCADE Technology Public
+// License Version 6.5 (the "License"). You may not use the content of this file
+// except in compliance with the License. Please obtain a copy of the License
+// at http://www.opencascade.org and read it completely before using this file.
+//
+// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
+// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+//
+// The Original Code and all software distributed under the License is
+// distributed on an "AS IS" basis, without warranty of any kind, and the
+// Initial Developer hereby disclaims all such warranties, including without
+// limitation, any warranties of merchantability, fitness for a particular
+// purpose or non-infringement. Please see the License for the specific terms
+// and conditions governing the rights and limitations under the License.
+
+
+#ifndef _NCollection_AlignedLocalArray_HeaderFile
+#define _NCollection_AlignedLocalArray_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_TypeDef.hxx>
+
+#include <NCollection_AlignAllocator.hxx>
+
+//! Auxiliary class optimizing creation of aligned array buffer 
+//! (using stack allocation for small arrays).
+template<class theItem> class NCollection_AlignedLocalArray
+{
+public:
+
+  // 1K * sizeof (theItem)
+  static const size_t MAX_ARRAY_SIZE = 1024;
+
+  NCollection_AlignedLocalArray (const size_t theSize)
+  : myPtr (myBuffer)
+  {
+    Allocate(theSize);
+  }
+
+  NCollection_AlignedLocalArray ()
+  : myPtr (myBuffer) {}
+
+  virtual ~NCollection_AlignedLocalArray()
+  {
+    Deallocate();
+  }
+
+  void Allocate (const size_t theSize)
+  {
+    Deallocate();
+    if (theSize > MAX_ARRAY_SIZE)
+      myPtr = (theItem*) NCollection_AlignAllocator::Allocate(theSize * sizeof(theItem), DATA_ALIGNMENT);
+    else
+      myPtr = myBuffer;
+  }
+
+  operator theItem*() const
+  {
+    return myPtr;
+  }
+
+private:
+
+  NCollection_AlignedLocalArray (const NCollection_AlignedLocalArray& );
+  NCollection_AlignedLocalArray& operator= (const NCollection_AlignedLocalArray& );
+
+protected:
+
+  void Deallocate()
+  {
+    if (myPtr != myBuffer)
+      NCollection_AlignAllocator::Free(*(Standard_Address*)&myPtr);
+  }
+
+protected:
+
+  MEMALIGN(theItem,  myBuffer[MAX_ARRAY_SIZE]);
+  MEMALIGN(theItem*, myPtr);
+
+};
+
+#endif // _NCollection_AlignedLocalArray_HeaderFile
index ca190f6558d5f065cef38df32a480587a1c905d2..e74ebdcbba4183ea8fb0c40e9ee261ced7d51b3a 100755 (executable)
@@ -174,6 +174,13 @@ is
                    Dimension         : Integer ;
                    PolynomialCoeff   : in out Real ;
                    Results           : in out Real) ;
+     ---Purpose: Makes the same as EvalPolynomial but with data aligned for support of SSE
+     EvalPolynomialWithAlignedData(U  : Real;
+                   DerivativeOrder   : Integer ;
+                   Degree            : Integer ;
+                   Dimension         : Integer ;
+                   PolynomialCoeff   : in out Real ;
+                   Results           : in out Real) ;
                     
       ---Purpose: Performs Horner method with synthethic division
       --          for derivatives