| 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 "aclOperatorTernary.h" |
| 25 |
#include "../aclUtilities.h" |
| 26 |
#include <algorithm> |
| 27 |
|
| 28 |
using namespace std; |
| 29 |
using namespace asl; |
| 30 |
|
| 31 |
namespace acl |
| 32 |
{ |
| 33 |
|
| 34 |
OperatorTernary::OperatorTernary(Element a1, Element a2, Element a3): |
| 35 |
// first operand dictates the typeID of the ternary operator |
| 36 |
ElementBase(false, 0, a1->getTypeID()) |
| 37 |
{ |
| 38 |
// if three elements have the same size or size of at least one of them is 0 |
| 39 |
if (compatible(a1,a2) && compatible(a2,a3) && compatible(a1,a3)) |
| 40 |
{ |
| 41 |
size = max(max(a1->getSize(), a2->getSize()), a3->getSize()); |
| 42 |
|
| 43 |
if (a1->getQueue().get() != 0) |
| 44 |
queue = a1->getQueue(); |
| 45 |
else |
| 46 |
if (a2->getQueue().get() != 0) |
| 47 |
queue = a2->getQueue(); |
| 48 |
else |
| 49 |
queue = a3->getQueue(); |
| 50 |
|
| 51 |
e1 = a1; |
| 52 |
e2 = a2; |
| 53 |
e3 = a3; |
| 54 |
} |
| 55 |
else |
| 56 |
{ |
| 57 |
errorMessage("Operands of ternary operator are incompatible. \ |
| 58 |
Either they reside on different devices or their sizes do not match: " |
| 59 |
+ numToStr(a1->getSize()) + " and " |
| 60 |
+ numToStr(a2->getSize()) + " and " |
| 61 |
+ numToStr(a3->getSize())); |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
void OperatorTernary::addToKernelSource(vector<Element> & arguments, |
| 67 |
vector<Element> & localDeclarations) const |
| 68 |
{ |
| 69 |
addElementToKernelSource(e1, arguments, localDeclarations); |
| 70 |
addElementToKernelSource(e2, arguments, localDeclarations); |
| 71 |
addElementToKernelSource(e3, arguments, localDeclarations); |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
void OperatorTernary::setAsArgument(cl::Kernel & kernel, unsigned int argumentIndex) const |
| 76 |
{ |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
string OperatorTernary::getName() const |
| 81 |
{ |
| 82 |
return ""; |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
string OperatorTernary::getTypeSignature(const KernelConfiguration & kernelConfig) const |
| 87 |
{ |
| 88 |
return ""; |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
string OperatorTernary::getLocalDeclaration(const KernelConfiguration & kernelConfig) const |
| 93 |
{ |
| 94 |
return ""; |
| 95 |
} |
| 96 |
|
| 97 |
} // namespace acl |