Vector now only accepts one type of allocator, the default allocator
This commit is contained in:
parent
1cbeb1c963
commit
099e85cfb1
|
@ -1,51 +0,0 @@
|
||||||
/*------------------------------- phasicFlow ---------------------------------
|
|
||||||
O C enter of
|
|
||||||
O O E ngineering and
|
|
||||||
O O M ultiscale modeling of
|
|
||||||
OOOOOOO F luid flow
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
Copyright (C): www.cemf.ir
|
|
||||||
email: hamid.r.norouzi AT gmail.com
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
Licence:
|
|
||||||
This file is part of phasicFlow code. It is a free software for simulating
|
|
||||||
granular and multiphase flows. You can redistribute it and/or modify it under
|
|
||||||
the terms of GNU General Public License v3 or any other later versions.
|
|
||||||
|
|
||||||
phasicFlow is distributed to help others in their research in the field of
|
|
||||||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
|
||||||
void
|
|
||||||
insertSetElementH(
|
|
||||||
ViewType1D<T, properties...>& view,
|
|
||||||
hostViewType1D<label>& selected,
|
|
||||||
T val
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
|
||||||
void
|
|
||||||
insertSetElementH(
|
|
||||||
ViewType1D<T, properties...>& view,
|
|
||||||
hostViewType1D<label>& selected,
|
|
||||||
hostViewType1D<T>& vals
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
|
||||||
void
|
|
||||||
insertSetElementD(
|
|
||||||
ViewType1D<T, properties...>& view,
|
|
||||||
deviceViewType1D<label>& selected,
|
|
||||||
T val
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
|
||||||
void
|
|
||||||
insertSetElementD(
|
|
||||||
ViewType1D<T, properties...>& view,
|
|
||||||
deviceViewType1D<label>& selected,
|
|
||||||
deviceViewType1D<T>& vals
|
|
||||||
);
|
|
|
@ -1,229 +0,0 @@
|
||||||
/*------------------------------- phasicFlow ---------------------------------
|
|
||||||
O C enter of
|
|
||||||
O O E ngineering and
|
|
||||||
O O M ultiscale modeling of
|
|
||||||
OOOOOOO F luid flow
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
Copyright (C): www.cemf.ir
|
|
||||||
email: hamid.r.norouzi AT gmail.com
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
Licence:
|
|
||||||
This file is part of phasicFlow code. It is a free software for simulating
|
|
||||||
granular and multiphase flows. You can redistribute it and/or modify it under
|
|
||||||
the terms of GNU General Public License v3 or any other later versions.
|
|
||||||
|
|
||||||
phasicFlow is distributed to help others in their research in the field of
|
|
||||||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef __baseAlgorithms_hpp__
|
|
||||||
#define __baseAlgorithms_hpp__
|
|
||||||
|
|
||||||
#include "KokkosUtilities.hpp"
|
|
||||||
#include "numericConstants.hpp"
|
|
||||||
|
|
||||||
inline const size_t sizeToSerial__ = 64;
|
|
||||||
|
|
||||||
namespace pFlow
|
|
||||||
{
|
|
||||||
|
|
||||||
// counts the number of elements that matches val
|
|
||||||
// the execution space is selected based on the View::execution_spcae
|
|
||||||
/*template<typename T, typename... properties>
|
|
||||||
INLINE_FUNCTION_H
|
|
||||||
size_t count(
|
|
||||||
const ViewType1D<T, properties...>& view,
|
|
||||||
size_t start,
|
|
||||||
size_t end,
|
|
||||||
const T& val
|
|
||||||
)
|
|
||||||
{
|
|
||||||
|
|
||||||
auto RP = Kokkos::RangePolicy<
|
|
||||||
Kokkos::IndexType<size_t>,
|
|
||||||
typename ViewType1D<T, properties...>::execution_space >(start, end);
|
|
||||||
|
|
||||||
size_t totalNum=0;
|
|
||||||
Kokkos::parallel_reduce(
|
|
||||||
"baseAlgorithms-count",
|
|
||||||
RP,
|
|
||||||
LAMBDA_HD(label i, size_t & valueToUpdate){
|
|
||||||
if( equal(view[i], val) ) valueToUpdate += 1;
|
|
||||||
}, totalNum );
|
|
||||||
|
|
||||||
return totalNum;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
|
||||||
INLINE_FUNCTION_H T
|
|
||||||
min(const ViewType1D<T, properties...>& view, size_t start, size_t end)
|
|
||||||
{
|
|
||||||
T minValue = largestPositive<T>();
|
|
||||||
|
|
||||||
auto RP = Kokkos::RangePolicy<
|
|
||||||
Kokkos::IndexType<size_t>,
|
|
||||||
typename ViewType1D<T, properties...>::execution_space>(start, end);
|
|
||||||
|
|
||||||
Kokkos::parallel_reduce(
|
|
||||||
"baseAlgorithms-min",
|
|
||||||
RP,
|
|
||||||
LAMBDA_HD(label i, T & valueToUpdate) {
|
|
||||||
valueToUpdate = min(view[i], valueToUpdate);
|
|
||||||
},
|
|
||||||
Kokkos ::Min<T>(minValue)
|
|
||||||
);
|
|
||||||
return minValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
|
||||||
INLINE_FUNCTION_H T
|
|
||||||
max(const ViewType1D<T, properties...>& view, size_t start, size_t end)
|
|
||||||
{
|
|
||||||
T maxValue = largestNegative<T>();
|
|
||||||
|
|
||||||
auto RP = Kokkos::RangePolicy<
|
|
||||||
Kokkos::IndexType<size_t>,
|
|
||||||
typename ViewType1D<T, properties...>::execution_space>(start, end);
|
|
||||||
|
|
||||||
Kokkos::parallel_reduce(
|
|
||||||
"baseAlgorithms-max",
|
|
||||||
RP,
|
|
||||||
LAMBDA_HD(label i, T & valueToUpdate) {
|
|
||||||
valueToUpdate = max(view[i], valueToUpdate);
|
|
||||||
},
|
|
||||||
Kokkos::Max<T>(maxValue)
|
|
||||||
);
|
|
||||||
return maxValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
|
||||||
INLINE_FUNCTION_H T
|
|
||||||
min_serial(const ViewType1D<T, properties...>& view, size_t start, size_t end)
|
|
||||||
{
|
|
||||||
T minValue = largestPositive<T>();
|
|
||||||
for (label i = start; i < end; ++i)
|
|
||||||
{
|
|
||||||
minValue = min(minValue, view[i]);
|
|
||||||
}
|
|
||||||
return minValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
|
||||||
INLINE_FUNCTION_H T
|
|
||||||
max_serial(const ViewType1D<T, properties...>& view, size_t start, size_t end)
|
|
||||||
{
|
|
||||||
T maxValue = largestNegative<T>();
|
|
||||||
for (label i = start; i < end; ++i)
|
|
||||||
{
|
|
||||||
maxValue = max(maxValue, view[i]);
|
|
||||||
}
|
|
||||||
return maxValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename UnaryFunction, typename T, typename... properties>
|
|
||||||
void
|
|
||||||
apply_to_each(
|
|
||||||
const ViewType1D<T, properties...>& view,
|
|
||||||
size_t start,
|
|
||||||
size_t end,
|
|
||||||
UnaryFunction func
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto RP = Kokkos::RangePolicy<
|
|
||||||
Kokkos::IndexType<size_t>,
|
|
||||||
typename ViewType1D<T, properties...>::execution_space>(start, end);
|
|
||||||
|
|
||||||
Kokkos::parallel_for(
|
|
||||||
"baseAlgorithms-for_each", RP, LAMBDA_HD(label i) { view[i] = func(i); }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
|
||||||
void
|
|
||||||
insertSetElementH(
|
|
||||||
ViewType1D<T, properties...>& view,
|
|
||||||
hostViewType1D<label>& selected,
|
|
||||||
T val
|
|
||||||
)
|
|
||||||
{
|
|
||||||
for (auto i = 0; i < selected.size(); ++i)
|
|
||||||
{
|
|
||||||
view[selected[i]] = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
|
||||||
void
|
|
||||||
insertSetElementH(
|
|
||||||
ViewType1D<T, properties...>& view,
|
|
||||||
hostViewType1D<label>& selected,
|
|
||||||
hostViewType1D<T>& vals
|
|
||||||
)
|
|
||||||
{
|
|
||||||
for (auto i = 0; i < selected.size(); ++i)
|
|
||||||
{
|
|
||||||
view[selected[i]] = static_cast<const T&>(vals[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
|
||||||
void
|
|
||||||
insertSetElementD(
|
|
||||||
ViewType1D<T, properties...>& view,
|
|
||||||
deviceViewType1D<label>& selected,
|
|
||||||
T val
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto RP = Kokkos::RangePolicy<
|
|
||||||
Kokkos::IndexType<size_t>,
|
|
||||||
typename ViewType1D<T, properties...>::execution_space>(
|
|
||||||
0, selected.size()
|
|
||||||
);
|
|
||||||
|
|
||||||
Kokkos::parallel_for(
|
|
||||||
"baseAlgorithms-insertSetElementD",
|
|
||||||
RP,
|
|
||||||
LAMBDA_D(size_t i) { view[selected[i]] = val; }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
|
||||||
void
|
|
||||||
insertSetElementD(
|
|
||||||
ViewType1D<T, properties...>& view,
|
|
||||||
deviceViewType1D<label>& selected,
|
|
||||||
deviceViewType1D<T>& vals
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto RP = Kokkos::RangePolicy<
|
|
||||||
Kokkos::IndexType<size_t>,
|
|
||||||
typename ViewType1D<T, properties...>::execution_space>(
|
|
||||||
0, selected.size()
|
|
||||||
);
|
|
||||||
|
|
||||||
Kokkos::parallel_for(
|
|
||||||
"baseAlgorithms-insertSetElementD",
|
|
||||||
RP,
|
|
||||||
LAMBDA_D(size_t i) { view[selected[i]] = vals[i]; }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
|
||||||
void
|
|
||||||
fill(
|
|
||||||
ViewType3D<T, properties...>& view,
|
|
||||||
range range1,
|
|
||||||
range range2,
|
|
||||||
range range3,
|
|
||||||
T val
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto subV = Kokkos::subview(view, range1, range2, range3);
|
|
||||||
Kokkos::deep_copy(subV, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __VectorSingleMath_hpp__
|
|
|
@ -52,7 +52,7 @@ class Vector;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T, typename Allocator = vecAllocator<T> >
|
template<typename T, typename Allocator = std::allocator<T> >
|
||||||
class Vector
|
class Vector
|
||||||
:
|
:
|
||||||
public std::vector<T, Allocator>
|
public std::vector<T, Allocator>
|
||||||
|
|
|
@ -35,19 +35,6 @@ namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
class noConstructAllocator
|
|
||||||
: public std::allocator<T>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using std::allocator<T>::allocator;
|
|
||||||
|
|
||||||
template <class U, class... Args> void construct(U*, Args&&...) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
using vecAllocator = std::allocator<T>;
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline
|
inline
|
||||||
span<T> makeSpan(std::vector<T>& container)
|
span<T> makeSpan(std::vector<T>& container)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,113 +0,0 @@
|
||||||
/*------------------------------- phasicFlow ---------------------------------
|
|
||||||
O C enter of
|
|
||||||
O O E ngineering and
|
|
||||||
O O M ultiscale modeling of
|
|
||||||
OOOOOOO F luid flow
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
Copyright (C): www.cemf.ir
|
|
||||||
email: hamid.r.norouzi AT gmail.com
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
Licence:
|
|
||||||
This file is part of phasicFlow code. It is a free software for simulating
|
|
||||||
granular and multiphase flows. You can redistribute it and/or modify it under
|
|
||||||
the terms of GNU General Public License v3 or any other later versions.
|
|
||||||
|
|
||||||
phasicFlow is distributed to help others in their research in the field of
|
|
||||||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef __VectorDualMath_hpp__
|
|
||||||
#define __VectorDualMath_hpp__
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "baseAlgorithms.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace pFlow
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// - select the side (HostSide or DeviceSide)
|
|
||||||
template<typename side, typename T, typename MemorySpace>
|
|
||||||
INLINE_FUNCTION_H
|
|
||||||
int64 count(const VectorDual<T,MemorySpace>& vec, const T& val)
|
|
||||||
{
|
|
||||||
if constexpr (std::is_same<side,HostSide>::value)
|
|
||||||
{
|
|
||||||
return count( vec.hostViewAll(), static_cast<size_t>(0), vec.size(), val);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return count( vec.deviceViewAll(), static_cast<size_t>(0), vec.size(), val);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// default to device side
|
|
||||||
template<typename T, typename MemorySpace>
|
|
||||||
INLINE_FUNCTION_H
|
|
||||||
int64 count(const VectorDual<T,MemorySpace>& vec, const T& val)
|
|
||||||
{
|
|
||||||
return count<DeviceSide>( vec, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename side, typename T, typename MemorySpace>
|
|
||||||
INLINE_FUNCTION_H
|
|
||||||
int64 min(const VectorDual<T,MemorySpace>& vec)
|
|
||||||
{
|
|
||||||
if constexpr (std::is_same<side,HostSide>::value)
|
|
||||||
{
|
|
||||||
return min( vec.hostViewAll(), static_cast<size_t>(0), vec.size());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return min( vec.deviceViewAll(), static_cast<size_t>(0), vec.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// default to device side
|
|
||||||
template<typename T, typename MemorySpace>
|
|
||||||
INLINE_FUNCTION_H
|
|
||||||
int64 min(const VectorDual<T,MemorySpace>& vec)
|
|
||||||
{
|
|
||||||
return min<DeviceSide>( vec);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename side, typename T, typename MemorySpace>
|
|
||||||
INLINE_FUNCTION_H
|
|
||||||
int64 max(const VectorDual<T,MemorySpace>& vec)
|
|
||||||
{
|
|
||||||
if constexpr (std::is_same<side,HostSide>::value)
|
|
||||||
{
|
|
||||||
return max( vec.hostViewAll(), static_cast<size_t>(0), vec.size());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return max( vec.deviceViewAll(), static_cast<size_t>(0), vec.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// default to device side
|
|
||||||
template<typename T, typename MemorySpace>
|
|
||||||
INLINE_FUNCTION_H
|
|
||||||
int64 max(const VectorDual<T,MemorySpace>& vec)
|
|
||||||
{
|
|
||||||
return max<DeviceSide>( vec);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // pFlow
|
|
||||||
|
|
||||||
|
|
||||||
#endif // __VectorSingleMath_hpp__
|
|
|
@ -1,52 +0,0 @@
|
||||||
/*------------------------------- phasicFlow ---------------------------------
|
|
||||||
O C enter of
|
|
||||||
O O E ngineering and
|
|
||||||
O O M ultiscale modeling of
|
|
||||||
OOOOOOO F luid flow
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
Copyright (C): www.cemf.ir
|
|
||||||
email: hamid.r.norouzi AT gmail.com
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
Licence:
|
|
||||||
This file is part of phasicFlow code. It is a free software for simulating
|
|
||||||
granular and multiphase flows. You can redistribute it and/or modify it under
|
|
||||||
the terms of GNU General Public License v3 or any other later versions.
|
|
||||||
|
|
||||||
phasicFlow is distributed to help others in their research in the field of
|
|
||||||
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef __VectorDuals_hpp__
|
|
||||||
#define __VectorDuals_hpp__
|
|
||||||
|
|
||||||
|
|
||||||
#include "types.hpp"
|
|
||||||
#include "VectorDual.hpp"
|
|
||||||
|
|
||||||
namespace pFlow
|
|
||||||
{
|
|
||||||
|
|
||||||
using int8Vector_HD = VectorDual<int8>;
|
|
||||||
|
|
||||||
using int16Vector_HD = VectorDual<int16>;
|
|
||||||
|
|
||||||
using int32Vector_HD = VectorDual<int32>;
|
|
||||||
|
|
||||||
using int64Vector_HD = VectorDual<int64>;
|
|
||||||
|
|
||||||
using uint32Vector_HD = VectorDual<uint32>;
|
|
||||||
|
|
||||||
using labelVector_HD = VectorDual<label>;
|
|
||||||
|
|
||||||
using realVector_HD = VectorDual<real>;
|
|
||||||
|
|
||||||
using realx3Vector_HD = VectorDual<realx3>;
|
|
||||||
|
|
||||||
using realx3x3Vector_HD = VectorDual<realx3x3>;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue