| 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 "../aclUtilities.h" |
| 25 |
#include "../../aslUtilities.h" |
| 26 |
#include "aclElementExcerpt.h" |
| 27 |
|
| 28 |
using namespace asl; |
| 29 |
|
| 30 |
namespace acl |
| 31 |
{ |
| 32 |
|
| 33 |
ElementExcerpt::ElementExcerpt(Element source_, Element filter_): |
| 34 |
ElementBase(source_->isWritable, filter_->getSize(), source_->getTypeID()) |
| 35 |
{ |
| 36 |
if (onSameDevice(source_, filter_)) |
| 37 |
{ |
| 38 |
source = source_; |
| 39 |
filter = filter_; |
| 40 |
|
| 41 |
// filter->getQueue().get() can be 0, |
| 42 |
// and source->getQueue().get() should not be 0 |
| 43 |
// (but even if it is 0 the statement bellow is correct; |
| 44 |
// the excerpt() operator will do nothing however in such a case). |
| 45 |
queue = source->getQueue(); |
| 46 |
} |
| 47 |
else |
| 48 |
{ |
| 49 |
errorMessage("ElementExcerpt::ElementExcerpt() - elements reside on different devices"); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
string ElementExcerpt::str(const KernelConfiguration & kernelConfig) const |
| 55 |
{ |
| 56 |
string s = source->str(kernelConfig); |
| 57 |
size_t found = s.find(INDEX); |
| 58 |
|
| 59 |
int filterSize(filter->str(kernelConfig).size()); |
| 60 |
while (found != string::npos) |
| 61 |
{ |
| 62 |
s.replace(found, INDEX.size(), filter->str(kernelConfig)); |
| 63 |
found = s.find(INDEX, found + filterSize); |
| 64 |
} |
| 65 |
|
| 66 |
return s; |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
void ElementExcerpt::addToKernelSource(vector<Element> & arguments, |
| 71 |
vector<Element> & localDeclarations) const |
| 72 |
{ |
| 73 |
addElementToKernelSource(source, arguments, localDeclarations); |
| 74 |
addElementToKernelSource(filter, arguments, localDeclarations); |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
void ElementExcerpt::setAsArgument(cl::Kernel & kernel, unsigned int argumentIndex) const |
| 79 |
{ |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
string ElementExcerpt::getName() const |
| 84 |
{ |
| 85 |
return ""; |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
string ElementExcerpt::getTypeSignature(const KernelConfiguration & kernelConfig) const |
| 90 |
{ |
| 91 |
return ""; |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
string ElementExcerpt::getLocalDeclaration(const KernelConfiguration & kernelConfig) const |
| 96 |
{ |
| 97 |
return ""; |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
} // namespace acl |