| 1 |
/* |
| 2 |
* Advanced Simulation Library <http://asl.org.il> |
| 3 |
* |
| 4 |
* Copyright 2015 Avtech Scientific <http://avtechscientific.com> |
| 5 |
* |
| 6 |
* |
| 7 |
* This file is part of Advanced Simulation Library (ASL). |
| 8 |
* |
| 9 |
* ASL is free software: you can redistribute it and/or modify it |
| 10 |
* under the terms of the GNU Affero General Public License as |
| 11 |
* published by the Free Software Foundation, version 3 of the License. |
| 12 |
* |
| 13 |
* ASL is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Affero General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Affero General Public License |
| 19 |
* along with ASL. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
|
| 24 |
#include "aslGenerators.h" |
| 25 |
#include "acl/aclGenerators.h" |
| 26 |
#include "acl/aclMath/aclMathAlg.h" |
| 27 |
#include <data/aslDataWithGhostNodes.h> |
| 28 |
#include "acl/aclHardware.h" |
| 29 |
|
| 30 |
#include "acl/aclTypesList.h" |
| 31 |
|
| 32 |
|
| 33 |
namespace asl |
| 34 |
{ |
| 35 |
|
| 36 |
SPDataWrapperACL generateDataContainer_SP(const Block &b, const acl::VectorOfElements & a) |
| 37 |
{ |
| 38 |
auto aa(std::make_shared<DataWrapperACL>(b)); |
| 39 |
aa->setContainer (a); |
| 40 |
return aa; |
| 41 |
} |
| 42 |
|
| 43 |
SPDataWithGhostNodesACL generateDataContainer_SP(const Block &b, const acl::VectorOfElements & a, unsigned int gN) |
| 44 |
{ |
| 45 |
auto aa(std::make_shared<DataWithGhostNodesACL>(b,gN)); |
| 46 |
aa->setContainer (a); |
| 47 |
return aa; |
| 48 |
} |
| 49 |
|
| 50 |
SPDataWithGhostNodesACLData generateDataContainerACL_SP(const Block &b, |
| 51 |
acl::TypeID t, |
| 52 |
unsigned int n, |
| 53 |
unsigned int gN, |
| 54 |
acl::CommandQueue queue) |
| 55 |
{ |
| 56 |
auto a(std::make_shared<DataWithGhostNodesACLData>(b,gN)); |
| 57 |
a->setContainer(acl::generateVEData(productOfElements(a->getBlock().getSize()), |
| 58 |
t, |
| 59 |
n, |
| 60 |
queue |
| 61 |
)); |
| 62 |
return a; |
| 63 |
} |
| 64 |
|
| 65 |
SPDataWithGhostNodesACLData generateDataContainerACL_SP(const Block &b, |
| 66 |
acl::TypeID t, |
| 67 |
unsigned int n, |
| 68 |
unsigned int gN) |
| 69 |
{ |
| 70 |
return generateDataContainerACL_SP(b, t, n, gN, acl::hardware.defaultQueue); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
SPAbstractDataWithGhostNodes generateDCFullSafe(SPAbstractDataWithGhostNodes d) |
| 75 |
{ |
| 76 |
auto & b(d->getBlock()); |
| 77 |
|
| 78 |
auto a(std::make_shared<DataWithGhostNodesACL>(b,0)); |
| 79 |
a->setContainer(acl::generateVEOutOfBoundarySafe(d->getEContainer())); |
| 80 |
|
| 81 |
return a; |
| 82 |
} |
| 83 |
|
| 84 |
SPAbstractDataWithGhostNodes generateDCFullSafe(SPAbstractDataWithGhostNodes d, double outVal) |
| 85 |
{ |
| 86 |
auto & b(d->getBlock()); |
| 87 |
|
| 88 |
auto a(std::make_shared<DataWithGhostNodesACL>(b,0)); |
| 89 |
a->setContainer(acl::generateVEOutOfBoundarySafe(d->getEContainer(), |
| 90 |
acl::generateVEConstant(outVal))); |
| 91 |
|
| 92 |
return a; |
| 93 |
} |
| 94 |
|
| 95 |
template <typename T> SPDataWrapperACLData |
| 96 |
generateDataContainerACL_SP(const Block &b, unsigned int n) |
| 97 |
{ |
| 98 |
auto a(std::make_shared<DataWrapperACLData>(b)); |
| 99 |
a->setContainer(acl::generateVEData<T>(productOfElements(b.getSize()),n)); |
| 100 |
return a; |
| 101 |
} |
| 102 |
|
| 103 |
#define BOOST_TT_rep_expression(r, data, t) \ |
| 104 |
template SPDataWrapperACLData generateDataContainerACL_SP<t>(const Block &b, unsigned int n); |
| 105 |
BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types) |
| 106 |
#undef BOOST_TT_rep_expression |
| 107 |
|
| 108 |
template <typename T> SPDataWithGhostNodesACLData |
| 109 |
generateDataContainerACL_SP(const Block &b, |
| 110 |
unsigned int n, |
| 111 |
unsigned int gN, |
| 112 |
acl::CommandQueue queue) |
| 113 |
{ |
| 114 |
auto a(std::make_shared<DataWithGhostNodesACLData>(b,gN)); |
| 115 |
a->setContainer(acl::VectorOfElementsData(n, |
| 116 |
productOfElements(a->getBlock().getSize()), |
| 117 |
T(0), |
| 118 |
queue)); |
| 119 |
return a; |
| 120 |
} |
| 121 |
|
| 122 |
#define BOOST_TT_rep_expression(r, data, t) \ |
| 123 |
template SPDataWithGhostNodesACLData generateDataContainerACL_SP<t>(const Block &b, unsigned int n, unsigned int gN, acl::CommandQueue queue); |
| 124 |
BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types) |
| 125 |
#undef BOOST_TT_rep_expression |
| 126 |
|
| 127 |
template <typename T> SPDataWithGhostNodesACLData |
| 128 |
generateDataContainerACL_SP(const Block &b, |
| 129 |
unsigned int n, |
| 130 |
unsigned int gN) |
| 131 |
{ |
| 132 |
return generateDataContainerACL_SP<T>(b, n, gN, acl::hardware.defaultQueue); |
| 133 |
} |
| 134 |
|
| 135 |
#define BOOST_TT_rep_expression(r, data, t) \ |
| 136 |
template SPDataWithGhostNodesACLData generateDataContainerACL_SP<t>(const Block &b, unsigned int n, unsigned int gN); |
| 137 |
BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types) |
| 138 |
#undef BOOST_TT_rep_expression |
| 139 |
|
| 140 |
template <typename T> SPDataWithGhostNodesACL |
| 141 |
generateDataContainerConst_SP(const Block &b,T a, unsigned int gN) |
| 142 |
{ |
| 143 |
auto aa(std::make_shared<DataWithGhostNodesACL>(b,gN)); |
| 144 |
aa->setContainer(acl::generateVEConstant(a)); |
| 145 |
return aa; |
| 146 |
} |
| 147 |
|
| 148 |
#define BOOST_TT_rep_expression(r, data, t) \ |
| 149 |
template SPDataWithGhostNodesACL generateDataContainerConst_SP(const Block &b,t a, unsigned int gN); |
| 150 |
BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types) |
| 151 |
#undef BOOST_TT_rep_expression |
| 152 |
#define BOOST_TT_rep_expression(r, data, t) \ |
| 153 |
template SPDataWithGhostNodesACL generateDataContainerConst_SP(const Block &b, AVec<t> a, unsigned int gN); |
| 154 |
BOOST_PP_SEQ_FOR_EACH(BOOST_TT_rep_expression, ~, BOOST_TT_acl_types) |
| 155 |
#undef BOOST_TT_rep_expression |
| 156 |
|
| 157 |
|
| 158 |
} // namespace asl |