Commit 2f05c417 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

removed const_cast in operations/product and norm

parent 371a9508
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
// alignement specification // alignement specification
// ------------------------ // ------------------------
#define ALIGNED(type,name,N) type name[N] __attribute__ ((aligned(CACHE_LINE))) #define ALIGNED(type,name,N) type name[N] __attribute__ ((aligned(CACHE_LINE)))
#define ASSUME_ALIGNED(var) __builtin_assume_aligned(var, CACHE_LINE)
typedef double aligned_double __attribute__ ((aligned(CACHE_LINE))); typedef double aligned_double __attribute__ ((aligned(CACHE_LINE)));
typedef float aligned_float __attribute__ ((aligned(CACHE_LINE))); typedef float aligned_float __attribute__ ((aligned(CACHE_LINE)));
typedef int aligned_int __attribute__ ((aligned(CACHE_LINE))); typedef int aligned_int __attribute__ ((aligned(CACHE_LINE)));
......
...@@ -35,12 +35,18 @@ ...@@ -35,12 +35,18 @@
// ------------------------ // ------------------------
#ifndef ALIGNED #ifndef ALIGNED
#define ALIGNED(type,name,N) type name[N] #define ALIGNED(type,name,N) type name[N]
#define ASSUME_ALIGNED(var) var
typedef double aligned_double; typedef double aligned_double;
typedef float aligned_float; typedef float aligned_float;
typedef int aligned_int; typedef int aligned_int;
typedef size_t aligned_size_t; typedef size_t aligned_size_t;
#define ALIGNED_ALLOC(type,size,alignment) new type[size] #endif
#define ALIGNED_FREE(addr) delete [] addr
#ifndef ALIGNED_ALLOC
// define aligned_malloc and aligned_free somewhere else, before using the macros
#define ALIGNED_ALLOC(type,size,alignment) (type*)aligned_malloc(size*sizeof(type), alignment)
#define ALIGNED_FREE(ptr) aligned_free(ptr)
#endif #endif
// some compiler attributes // some compiler attributes
......
...@@ -32,16 +32,13 @@ ...@@ -32,16 +32,13 @@
// alignement specification // alignement specification
// ------------------------ // ------------------------
#define ALIGNED(type,name,N) type name[N] __attribute__ ((aligned(CACHE_LINE))) #define ALIGNED(type,name,N) type name[N] __attribute__ ((aligned(CACHE_LINE)))
#define ASSUME_ALIGNED(var) __builtin_assume_aligned(var, CACHE_LINE)
typedef double aligned_double __attribute__ ((aligned(CACHE_LINE))); typedef double aligned_double __attribute__ ((aligned(CACHE_LINE)));
typedef float aligned_float __attribute__ ((aligned(CACHE_LINE))); typedef float aligned_float __attribute__ ((aligned(CACHE_LINE)));
typedef int aligned_int __attribute__ ((aligned(CACHE_LINE))); typedef int aligned_int __attribute__ ((aligned(CACHE_LINE)));
typedef size_t aligned_size_t __attribute__ ((aligned(CACHE_LINE))); typedef size_t aligned_size_t __attribute__ ((aligned(CACHE_LINE)));
#include <stdlib.h>
#define ALIGNED_ALLOC(type,size,alignment) (type*)memalign(alignment, size*sizeof(type))
inline void aligned_free( void* p ) { void* p1 = ((void**)p)[-1]; free( p1 ); }
#define ALIGNED_FREE(ptr) aligned_free(ptr)
// some compiler attributes // some compiler attributes
// ------------------------ // ------------------------
#define NOINLINE __attribute__ ((noinline)) #define NOINLINE __attribute__ ((noinline))
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
// alignement specification // alignement specification
// ------------------------ // ------------------------
#define ALIGNED(type,name,N) __declspec(align(CACHE_LINE)) type name[N] #define ALIGNED(type,name,N) __declspec(align(CACHE_LINE)) type name[N]
#define ASSUME_ALIGNED(var) var; __assume_aligned(var, CACHE_LINE)
typedef __declspec(align(CACHE_LINE)) double aligned_double; typedef __declspec(align(CACHE_LINE)) double aligned_double;
typedef __declspec(align(CACHE_LINE)) float aligned_float; typedef __declspec(align(CACHE_LINE)) float aligned_float;
typedef __declspec(align(CACHE_LINE)) int aligned_int; typedef __declspec(align(CACHE_LINE)) int aligned_int;
......
...@@ -59,7 +59,7 @@ namespace AMDiS ...@@ -59,7 +59,7 @@ namespace AMDiS
using namespace mtl::vector; using namespace mtl::vector;
typedef parameters<mtl::col_major, non_fixed::dimension, false, size_type> param; typedef parameters<mtl::col_major, non_fixed::dimension, false, size_type> param;
mtl::dense_vector<value_type, param> tmp(AMDiS::size(v), const_cast<value_type*>(v.begin())); mtl::dense_vector<const value_type, param> tmp(AMDiS::size(v), value_typev.begin());
return mtl::two_norm(tmp); return mtl::two_norm(tmp);
} }
...@@ -110,7 +110,7 @@ namespace AMDiS ...@@ -110,7 +110,7 @@ namespace AMDiS
using namespace mtl::vector; using namespace mtl::vector;
typedef parameters<mtl::col_major, non_fixed::dimension, false, size_type> param; typedef parameters<mtl::col_major, non_fixed::dimension, false, size_type> param;
mtl::dense_vector<value_type, param> tmp(AMDiS::size(v), const_cast<value_type*>(v.begin())); mtl::dense_vector<const value_type, param> tmp(AMDiS::size(v), v.begin());
return mtl::vector::one_norm(tmp); return mtl::vector::one_norm(tmp);
} }
......
...@@ -64,8 +64,8 @@ namespace AMDiS ...@@ -64,8 +64,8 @@ namespace AMDiS
using namespace mtl::vector; using namespace mtl::vector;
typedef parameters<mtl::col_major, non_fixed::dimension, false, size_type1> param1; typedef parameters<mtl::col_major, non_fixed::dimension, false, size_type1> param1;
typedef parameters<mtl::col_major, non_fixed::dimension, false, size_type2> param2; typedef parameters<mtl::col_major, non_fixed::dimension, false, size_type2> param2;
mtl::dense_vector<value_type1, param1> tmp1(AMDiS::size(v1), const_cast<value_type1*>(v1.begin())); mtl::dense_vector<const value_type1, param1> tmp1(AMDiS::size(v1), v1.begin());
mtl::dense_vector<value_type2, param2> tmp2(AMDiS::size(v2), const_cast<value_type2*>(v2.begin())); mtl::dense_vector<const value_type2, param2> tmp2(AMDiS::size(v2), v2.begin());
return mtl::dot(tmp1, tmp2); return mtl::dot(tmp1, tmp2);
} }
......
...@@ -44,13 +44,16 @@ namespace AMDiS ...@@ -44,13 +44,16 @@ namespace AMDiS
// introduce some shortcuts for boost::mpl // introduce some shortcuts for boost::mpl
// --------------------------------------- // ---------------------------------------
using boost::mpl::bool_;
using boost::mpl::true_; using boost::mpl::true_;
using boost::mpl::false_; using boost::mpl::false_;
using boost::mpl::and_; using boost::mpl::and_;
using boost::mpl::or_; using boost::mpl::or_;
using boost::enable_if; using boost::enable_if;
using boost::enable_if_c;
using boost::disable_if; using boost::disable_if;
using boost::disable_if_c;
namespace traits namespace traits
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment