Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sbalzarini Lab
S
Software
P
Parallel Computing
OpenFPM
openfpm_data
Commits
0ab602dd
Commit
0ab602dd
authored
Nov 12, 2017
by
incardon
Browse files
extending to layout aware function
parent
f7ca1bc2
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/Grid/Encap.hpp
View file @
0ab602dd
...
...
@@ -518,7 +518,7 @@ public:
* \return The reference of the data
*
*/
template
<
unsigned
int
p
>
const
typename
type_gpu_prop
<
p
,
typename
memory_traits_inte
<
T
>::
type
>::
type
::
reference
get
()
const
template
<
unsigned
int
p
>
typename
type_gpu_prop
<
p
,
typename
memory_traits_inte
<
T
>::
type
>::
type
::
reference
get
()
const
{
return
boost
::
fusion
::
at_c
<
p
>
(
data
).
mem_r
->
operator
[](
k
);
}
...
...
src/Grid/grid_base_implementation.hpp
View file @
0ab602dd
...
...
@@ -448,7 +448,8 @@ public:
* \return the const reference of the element
*
*/
template
<
unsigned
int
p
,
typename
r_type
=
decltype
(
mem_get
<
p
,
layout_base
<
T
>,
layout
,
grid_sm
<
dim
,
T
>
,
grid_key_dx
<
dim
>>::
get
(
data_
,
g1
,
grid_key_dx
<
dim
>
()))
>
inline
const
r_type
get
(
const
grid_key_dx
<
dim
>
&
v1
)
const
template
<
unsigned
int
p
,
typename
r_type
=
decltype
(
mem_get
<
p
,
layout_base
<
T
>,
layout
,
grid_sm
<
dim
,
T
>
,
grid_key_dx
<
dim
>>::
get
(
data_
,
g1
,
grid_key_dx
<
dim
>
()))
>
inline
const
r_type
get
(
const
grid_key_dx
<
dim
>
&
v1
)
const
{
#ifdef SE_CLASS2
check_valid
(
this
,
8
);
...
...
src/Space/Shape/Point_operators_functions.hpp
View file @
0ab602dd
...
...
@@ -388,6 +388,7 @@ norm2(const Point<dim,T> & va)
return
exp_sum
;
}
/*! \brief General distance formula
*
*
...
...
@@ -397,6 +398,7 @@ template <typename T, typename P> auto distance(T exp1, P exp2) -> decltype(norm
return
norm
(
exp1
-
exp2
);
}
///// Here we define point operator functions
CREATE_ARG_FUNC
(
std
::
abs
,
abs
,
POINT_ABS
)
...
...
src/Vector/map_vector.hpp
View file @
0ab602dd
...
...
@@ -101,7 +101,7 @@ namespace openfpm
size_t
v_size
;
//! 1-D static grid
grid_cpu
<
1
,
T
,
Memory
,
layout
>
base
;
grid_cpu
<
1
,
T
,
Memory
,
typename
layout_base
<
T
>::
type
>
base
;
/*! \brief If the argument is zero return 1 otherwise return the argument
*
...
...
@@ -149,7 +149,7 @@ namespace openfpm
//! Object container for T, it is the return type of get_o it return a object type trough
// you can access all the properties of T
typedef
typename
grid_cpu
<
1
,
T
,
Memory
,
layout
>::
container
container
;
typedef
typename
grid_cpu
<
1
,
T
,
Memory
,
typename
layout_base
<
T
>::
type
>::
container
container
;
//! Type of the value the vector is storing
typedef
T
value_type
;
...
...
@@ -298,7 +298,7 @@ namespace openfpm
*
*
*/
void
add
(
const
typename
grid_cpu
<
1
,
T
,
Memory
,
layout
>::
container
&
v
)
void
add
(
const
typename
grid_cpu
<
1
,
T
,
Memory
,
typename
layout_base
<
T
>::
type
>::
container
&
v
)
{
#ifdef SE_CLASS2
check_valid
(
this
,
8
);
...
...
@@ -433,8 +433,13 @@ namespace openfpm
* \param start index from where to start the merging
*
*/
template
<
template
<
typename
,
typename
>
class
op
,
typename
S
,
typename
M
,
typename
gp
,
unsigned
int
...
args
>
void
merge_prp_v
(
const
vector
<
S
,
M
,
typename
layout_base
<
S
>::
type
,
layout_base
,
gp
,
OPENFPM_NATIVE
>
&
v
,
template
<
template
<
typename
,
typename
>
class
op
,
typename
S
,
typename
M
,
typename
gp
,
template
<
typename
>
class
layout_base2
,
unsigned
int
...
args
>
void
merge_prp_v
(
const
vector
<
S
,
M
,
typename
layout_base2
<
S
>::
type
,
layout_base2
,
gp
,
OPENFPM_NATIVE
>
&
v
,
const
openfpm
::
vector
<
aggregate
<
size_t
,
size_t
>>
&
opart
)
{
#ifdef SE_CLASS2
...
...
@@ -530,7 +535,13 @@ namespace openfpm
* \param v source vector
*
*/
template
<
typename
S
,
typename
M
,
typename
gp
,
unsigned
int
impl
,
unsigned
int
...
args
>
void
add_prp
(
const
vector
<
S
,
M
,
typename
layout_base
<
S
>::
type
,
layout_base
,
gp
,
impl
>
&
v
)
template
<
typename
S
,
typename
M
,
typename
gp
,
unsigned
int
impl
,
template
<
typename
>
class
layout_base2
,
unsigned
int
...
args
>
void
add_prp
(
const
vector
<
S
,
M
,
typename
layout_base2
<
S
>::
type
,
layout_base2
,
gp
,
impl
>
&
v
)
{
#ifdef SE_CLASS2
check_valid
(
this
,
8
);
...
...
@@ -722,7 +733,7 @@ namespace openfpm
*
*/
inline
const
typename
grid_cpu
<
1
,
T
,
Memory
,
layout
>::
container
get_o
(
size_t
id
)
const
inline
const
typename
grid_cpu
<
1
,
T
,
Memory
,
typename
layout_base
<
T
>::
type
>::
container
get_o
(
size_t
id
)
const
{
#ifdef SE_CLASS2
check_valid
(
this
,
8
);
...
...
@@ -741,7 +752,7 @@ namespace openfpm
*
*/
inline
const
typename
grid_cpu
<
1
,
T
,
Memory
,
layout
>::
container
last
()
const
inline
const
typename
grid_cpu
<
1
,
T
,
Memory
,
typename
layout_base
<
T
>::
type
>::
container
last
()
const
{
#ifdef SE_CLASS2
check_valid
(
this
,
8
);
...
...
@@ -781,7 +792,7 @@ namespace openfpm
*
*/
inline
typename
grid_cpu
<
1
,
T
,
Memory
,
layout
>::
container
last
()
inline
typename
grid_cpu
<
1
,
T
,
Memory
,
typename
layout_base
<
T
>::
type
>::
container
last
()
{
#ifdef SE_CLASS2
check_valid
(
this
,
8
);
...
...
@@ -873,7 +884,7 @@ namespace openfpm
* \param obj object (encapsulated)
*
*/
void
set
(
size_t
id
,
const
typename
grid_cpu
<
1
,
T
,
Memory
,
layout
>::
container
&
obj
)
void
set
(
size_t
id
,
const
typename
grid_cpu
<
1
,
T
,
Memory
,
typename
layout_base
<
T
>::
type
>::
container
&
obj
)
{
#ifdef SE_CLASS2
check_valid
(
this
,
8
);
...
...
src/Vector/map_vector_std.hpp
View file @
0ab602dd
...
...
@@ -354,7 +354,13 @@ public:
* \param v source vector
*
*/
template
<
typename
S
,
typename
M
,
typename
gp
,
unsigned
int
impl
,
unsigned
int
...
args
>
void
add_prp
(
const
vector
<
S
,
M
,
typename
memory_traits_lin
<
S
>::
type
,
memory_traits_lin
,
gp
,
impl
>
&
v
)
template
<
typename
S
,
typename
M
,
typename
gp
,
unsigned
int
impl
,
template
<
typename
>
class
layout_base
,
unsigned
int
...
args
>
void
add_prp
(
const
vector
<
S
,
M
,
typename
layout_base
<
S
>::
type
,
layout_base
,
gp
,
impl
>
&
v
)
{
#ifdef SE_CLASS2
check_valid
(
this
,
8
);
...
...
src/Vector/vector_unit_tests.hpp
View file @
0ab602dd
...
...
@@ -237,7 +237,7 @@ template <typename vector> void test_vector_clear()
BOOST_REQUIRE_EQUAL
(
v1
.
size
(),
V_REM_PUSH
);
}
template
<
typename
vector
>
void
test_vector_add_test_case
()
template
<
typename
vector
,
template
<
typename
>
class
layout_base
>
void
test_vector_add_test_case
()
{
// create two vector
vector
v1
;
...
...
@@ -277,7 +277,7 @@ template <typename vector> void test_vector_add_test_case()
// Duplicate the vector
vector
v2
=
v1
.
duplicate
();
v1
.
template
add_prp
<
Point_test
<
float
>,
HeapMemory
,
typename
openfpm
::
grow_policy_double
,
OPENFPM_NATIVE
,
P
::
x
,
P
::
y
,
P
::
z
,
P
::
s
,
P
::
v
,
P
::
t
>
(
v2
);
v1
.
template
add_prp
<
Point_test
<
float
>,
HeapMemory
,
typename
openfpm
::
grow_policy_double
,
OPENFPM_NATIVE
,
layout_base
,
P
::
x
,
P
::
y
,
P
::
z
,
P
::
s
,
P
::
v
,
P
::
t
>
(
v2
);
for
(
size_t
i
=
0
;
i
<
FIRST_PUSH
;
i
++
)
{
...
...
@@ -420,7 +420,7 @@ template <typename vector> void test_vector_load_and_save_check()
BOOST_AUTO_TEST_CASE
(
vector_iterator_test
)
{
test_iterator
<
openfpm
::
vector
<
Point_test
<
float
>>
>
();
test_iterator
<
openfpm
::
vector
<
Point_test
<
float
>
,
HeapMemory
,
memory_traits_inte
<
Point_test
<
float
>>::
type
>
>
();
test_iterator
<
openfpm
::
vector
<
Point_test
<
float
>
,
HeapMemory
,
memory_traits_inte
<
Point_test
<
float
>>::
type
,
memory_traits_inte
>
>
();
}
// Test the openfpm vector
...
...
@@ -430,7 +430,7 @@ BOOST_AUTO_TEST_CASE( vector_use)
std
::
cout
<<
"Vector unit test start"
<<
"
\n
"
;
test_vector_use
<
openfpm
::
vector
<
Point_test
<
float
>>>
();
test_vector_use
<
openfpm
::
vector
<
Point_test
<
float
>
,
HeapMemory
,
memory_traits_inte
<
Point_test
<
float
>>::
type
>
>
();
test_vector_use
<
openfpm
::
vector
<
Point_test
<
float
>
,
HeapMemory
,
memory_traits_inte
<
Point_test
<
float
>>::
type
,
memory_traits_inte
>
>
();
std
::
cout
<<
"Vector unit test end"
<<
"
\n
"
;
}
...
...
@@ -460,8 +460,8 @@ BOOST_AUTO_TEST_CASE(vector_clear )
BOOST_AUTO_TEST_CASE
(
vector_add_test_case
)
{
test_vector_add_test_case
<
openfpm
::
vector
<
Point_test
<
float
>>>
();
test_vector_add_test_case
<
openfpm
::
vector
<
Point_test
<
float
>
,
HeapMemory
,
memory_traits_inte
<
Point_test
<
float
>>::
type
,
memory_traits_inte
>
>
();
test_vector_add_test_case
<
openfpm
::
vector
<
Point_test
<
float
>>
,
memory_traits_lin
>
();
test_vector_add_test_case
<
openfpm
::
vector
<
Point_test
<
float
>
,
HeapMemory
,
memory_traits_inte
<
Point_test
<
float
>>::
type
,
memory_traits_inte
>
,
memory_traits_inte
>
();
}
BOOST_AUTO_TEST_CASE
(
vector_copy_and_compare
)
...
...
src/util/copy_compare/meta_copy.hpp
View file @
0ab602dd
...
...
@@ -110,6 +110,44 @@ struct meta_copy_d<Tsrc[N1],Tdst>
}
};
//! Partial specialization for N=1 1D-Array
template
<
typename
Tsrc
,
typename
Tdst
,
size_t
N1
>
struct
meta_copy_d
<
Tsrc
,
Tdst
[
N1
]
>
{
/*! \brief copy and object from src to dst
*
* \param src source object to copy
* \param dst destination object
*
*/
static
inline
void
meta_copy_d_
(
const
Tsrc
&
src
,
Tdst
dst
[
N1
])
{
for
(
size_t
i1
=
0
;
i1
<
N1
;
i1
++
)
{
copy_general
<
Tdst
>
(
static_cast
<
const
Tdst
&>
(
src
[
i1
]),
dst
[
i1
]);
}
}
};
//! Partial specialization for N=1 1D-Array
template
<
typename
Tsrc
,
typename
Tdst
,
size_t
N1
>
struct
meta_copy_d
<
Tsrc
[
N1
],
Tdst
[
N1
]
>
{
/*! \brief copy and object from src to dst
*
* \param src source object to copy
* \param dst destination object
*
*/
static
inline
void
meta_copy_d_
(
const
Tsrc
src
[
N1
],
Tdst
dst
[
N1
])
{
for
(
size_t
i1
=
0
;
i1
<
N1
;
i1
++
)
{
copy_general
<
Tsrc
>
(
src
[
i1
],
dst
[
i1
]);
}
}
};
//! Partial specialization for N=2 2D-Array
template
<
typename
T
,
size_t
N1
,
size_t
N2
>
struct
meta_copy
<
T
[
N1
][
N2
]
>
...
...
@@ -154,6 +192,52 @@ struct meta_copy_d<Tsrc[N1][N2],Tdst>
}
};
//! Partial specialization for N=2 2D-Array
template
<
typename
Tsrc
,
typename
Tdst
,
size_t
N1
,
size_t
N2
>
struct
meta_copy_d
<
Tsrc
,
Tdst
[
N1
][
N2
]
>
{
/*! \brief copy and object from src to dst
*
* \param src source object to copy
* \param dst destination object
*
*/
static
inline
void
meta_copy_d_
(
const
Tsrc
&
src
,
Tdst
dst
[
N1
][
N2
])
{
for
(
size_t
i1
=
0
;
i1
<
N1
;
i1
++
)
{
for
(
size_t
i2
=
0
;
i2
<
N2
;
i2
++
)
{
copy_general
<
Tdst
>
(
static_cast
<
const
Tdst
&>
(
src
[
i1
][
i2
]),
dst
[
i1
][
i2
]);
}
}
}
};
//! Partial specialization for N=1 1D-Array
template
<
typename
Tsrc
,
typename
Tdst
,
size_t
N1
,
size_t
N2
>
struct
meta_copy_d
<
Tsrc
[
N1
][
N2
],
Tdst
[
N1
][
N2
]
>
{
/*! \brief copy and object from src to dst
*
* \param src source object to copy
* \param dst destination object
*
*/
static
inline
void
meta_copy_d_
(
const
Tsrc
src
[
N1
][
N2
],
Tdst
dst
[
N1
][
N2
])
{
for
(
size_t
i1
=
0
;
i1
<
N1
;
i1
++
)
{
for
(
size_t
i2
=
0
;
i2
<
N2
;
i2
++
)
{
copy_general
<
Tsrc
>
(
src
[
i1
][
i2
],
dst
[
i1
][
i2
]);
}
}
}
};
//! Partial specialization for N=3
template
<
typename
T
,
size_t
N1
,
size_t
N2
,
size_t
N3
>
struct
meta_copy
<
T
[
N1
][
N2
][
N3
]
>
...
...
@@ -556,4 +640,88 @@ struct meta_copy_op<op,T[N1][N2][N3]>
}
};
template
<
template
<
typename
,
typename
>
class
op
,
typename
Tsrc
,
typename
Tdst
>
struct
meta_copy_op_d
{
/*! \brief Meta-copy applying an operation
*
* \param src source object
* \param dst destination object
*
*/
static
inline
void
meta_copy_op_d_
(
const
Tsrc
&
src
,
Tdst
&
dst
)
{
copy_general_op
<
op
,
Tsrc
>
(
src
,
dst
);
}
/*! \brief Meta-copy applying an operation
*
* \param src source object
* \param dst destination object
*
*/
static
inline
void
meta_copy_op_d_
(
const
Tsrc
&
src
,
Tdst
&&
dst
)
{
copy_general_op
<
op
,
Tsrc
>
(
src
,
dst
);
}
};
//! Partial specialization for N=1 1D-Array
template
<
template
<
typename
,
typename
>
class
op
,
typename
Tsrc
,
typename
Tdst
,
size_t
N1
>
struct
meta_copy_op_d
<
op
,
Tsrc
[
N1
],
Tdst
>
{
/*! \brief copy and object from src to dst
*
* \param src source object to copy
* \param dst destination object
*
*/
static
inline
void
meta_copy_op_d_
(
const
Tsrc
src
[
N1
],
Tdst
&&
dst
)
{
for
(
size_t
i1
=
0
;
i1
<
N1
;
i1
++
)
{
copy_general_op
<
op
,
Tsrc
>
(
src
[
i1
],
static_cast
<
Tsrc
&>
(
dst
[
i1
]));
}
}
};
//! Partial specialization for N=1 1D-Array
template
<
template
<
typename
,
typename
>
class
op
,
typename
Tsrc
,
typename
Tdst
,
size_t
N1
>
struct
meta_copy_op_d
<
op
,
Tsrc
,
Tdst
[
N1
]
>
{
/*! \brief copy and object from src to dst
*
* \param src source object to copy
* \param dst destination object
*
*/
static
inline
void
meta_copy_op_d_
(
const
Tsrc
&
src
,
Tdst
dst
[
N1
])
{
for
(
size_t
i1
=
0
;
i1
<
N1
;
i1
++
)
{
copy_general_op
<
op
,
Tdst
>
(
static_cast
<
const
Tdst
&>
(
src
[
i1
]),
dst
[
i1
]);
}
}
};
//! Partial specialization for N=1 1D-Array
template
<
template
<
typename
,
typename
>
class
op
,
typename
Tsrc
,
typename
Tdst
,
size_t
N1
>
struct
meta_copy_op_d
<
op
,
Tsrc
[
N1
],
Tdst
[
N1
]
>
{
/*! \brief copy and object from src to dst
*
* \param src source object to copy
* \param dst destination object
*
*/
static
inline
void
meta_copy_op_d_
(
const
Tsrc
src
[
N1
],
Tdst
dst
[
N1
])
{
for
(
size_t
i1
=
0
;
i1
<
N1
;
i1
++
)
{
copy_general_op
<
op
,
Tdst
>
(
src
[
i1
],
dst
[
i1
]);
}
}
};
#endif
src/util/object_s_di.hpp
View file @
0ab602dd
...
...
@@ -67,9 +67,10 @@ struct object_s_di_e
void
operator
()(
T
&
t
)
{
// Remove the reference from the type to copy
typedef
typename
boost
::
remove_reference
<
decltype
(
dst
.
template
get
<
boost
::
mpl
::
at
<
v_prp
,
boost
::
mpl
::
int_
<
T
::
value
>
>::
type
::
value
>
())
>::
type
copy_rtype
;
typedef
typename
boost
::
remove_reference
<
decltype
(
dst
.
template
get
<
boost
::
mpl
::
at
<
v_prp
,
boost
::
mpl
::
int_
<
T
::
value
>
>::
type
::
value
>
())
>::
type
copy_dtype
;
typedef
typename
std
::
remove_reference
<
decltype
(
src
.
template
get
<
T
::
value
>())
>::
type
copy_stype
;
meta_copy
<
copy_
r
type
>::
meta_copy_
(
src
.
template
get
<
T
::
value
>(),
dst
.
template
get
<
boost
::
mpl
::
at
<
v_prp
,
boost
::
mpl
::
int_
<
T
::
value
>
>::
type
::
value
>
());
meta_copy
_d
<
copy_
stype
,
copy_d
type
>::
meta_copy_
d_
(
src
.
template
get
<
T
::
value
>(),
dst
.
template
get
<
boost
::
mpl
::
at
<
v_prp
,
boost
::
mpl
::
int_
<
T
::
value
>
>::
type
::
value
>
());
}
};
...
...
@@ -127,9 +128,10 @@ struct object_s_di_e_op
void
operator
()(
T
&
t
)
{
// Remove the reference from the type to copy
typedef
typename
boost
::
remove_reference
<
decltype
(
dst
.
template
get
<
boost
::
mpl
::
at
<
v_prp
,
boost
::
mpl
::
int_
<
T
::
value
>
>::
type
::
value
>
())
>::
type
copy_rtype
;
typedef
typename
boost
::
remove_reference
<
decltype
(
dst
.
template
get
<
boost
::
mpl
::
at
<
v_prp
,
boost
::
mpl
::
int_
<
T
::
value
>
>::
type
::
value
>
())
>::
type
copy_dtype
;
typedef
typename
std
::
remove_reference
<
decltype
(
src
.
template
get
<
T
::
value
>())
>::
type
copy_stype
;
meta_copy_op
<
op
,
copy_
r
type
>::
meta_copy_op_
(
src
.
template
get
<
T
::
value
>(),
dst
.
template
get
<
boost
::
mpl
::
at
<
v_prp
,
boost
::
mpl
::
int_
<
T
::
value
>
>::
type
::
value
>
());
meta_copy_op
_d
<
op
,
copy_
stype
,
copy_d
type
>::
meta_copy_op_
d_
(
src
.
template
get
<
T
::
value
>(),
dst
.
template
get
<
boost
::
mpl
::
at
<
v_prp
,
boost
::
mpl
::
int_
<
T
::
value
>
>::
type
::
value
>
());
}
};
...
...
src/util/object_si_d.hpp
View file @
0ab602dd
...
...
@@ -26,13 +26,13 @@
template
<
typename
v_src
,
typename
v_dst
,
int
...
prp
>
struct
object_si_d_e
{
// Convert the packed properties into an MPL vector
//
!
Convert the packed properties into an MPL vector
typedef
typename
to_boost_vmpl
<
prp
...
>::
type
v_prp
;
// Source object
//
!
Source object
const
v_src
&
src
;
// Destination object
//
!
Destination object
v_dst
&
dst
;
/*! \brief Constructor
...
...
@@ -50,9 +50,10 @@ struct object_si_d_e
template
<
typename
T
>
void
operator
()(
T
&
t
)
{
typedef
typename
boost
::
mpl
::
at
<
typename
v_dst
::
type
,
typename
boost
::
mpl
::
int_
<
T
::
value
>>::
type
ctype
;
typedef
typename
boost
::
mpl
::
at
<
typename
v_dst
::
type
,
typename
boost
::
mpl
::
int_
<
T
::
value
>>::
type
dtype
;
typedef
decltype
(
src
.
template
get
<
boost
::
mpl
::
at
<
v_prp
,
boost
::
mpl
::
int_
<
T
::
value
>
>::
type
::
value
>
())
stype
;
meta_copy
<
c
type
>::
meta_copy_
(
src
.
template
get
<
boost
::
mpl
::
at
<
v_prp
,
boost
::
mpl
::
int_
<
T
::
value
>
>::
type
::
value
>
(),
dst
.
template
get
<
T
::
value
>());
meta_copy
_d
<
stype
,
d
type
>::
meta_copy_
d_
(
src
.
template
get
<
boost
::
mpl
::
at
<
v_prp
,
boost
::
mpl
::
int_
<
T
::
value
>
>::
type
::
value
>
(),
dst
.
template
get
<
T
::
value
>());
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment