| 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 |
#ifndef ACLELEMENTBASE_H |
| 25 |
#define ACLELEMENTBASE_H |
| 26 |
|
| 27 |
#include "aclStdIncludes.h" |
| 28 |
//#include "aclHardware.h" |
| 29 |
#include "Kernels/aclKernelConfiguration.h" |
| 30 |
#include <memory> |
| 31 |
#include "aclTypes.h" |
| 32 |
|
| 33 |
namespace cl |
| 34 |
{ |
| 35 |
class CommandQueue; |
| 36 |
class Kernel; |
| 37 |
} |
| 38 |
|
| 39 |
namespace acl |
| 40 |
{ |
| 41 |
typedef std::shared_ptr<cl::CommandQueue> CommandQueue; |
| 42 |
|
| 43 |
// GLOBALS |
| 44 |
extern const std::string INDEX; |
| 45 |
extern const KernelConfiguration KERNEL_BASIC; |
| 46 |
|
| 47 |
using namespace std; |
| 48 |
|
| 49 |
class ElementBase |
| 50 |
{ |
| 51 |
protected: |
| 52 |
unsigned int size; |
| 53 |
TypeID typeID; |
| 54 |
CommandQueue queue; |
| 55 |
ElementBase(bool isWritable_, unsigned int size_, TypeID typeID_); |
| 56 |
public: |
| 57 |
const bool isWritable; |
| 58 |
virtual string str(const KernelConfiguration & kernelConfig = KERNEL_BASIC) const = 0; |
| 59 |
virtual string getName() const = 0; |
| 60 |
virtual string getAddressSpaceQualifier() const; |
| 61 |
unsigned int getSize() const; |
| 62 |
CommandQueue getQueue() const; |
| 63 |
TypeID getTypeID() const; |
| 64 |
virtual string getTypeSignature(const KernelConfiguration & kernelConfig = KERNEL_BASIC) const = 0; |
| 65 |
virtual string getLocalDeclaration(const KernelConfiguration & kernelConfig = KERNEL_BASIC) const = 0; |
| 66 |
/// Adds ElementBase to the kernel source either as an argument or as a local declaration |
| 67 |
virtual void addToKernelSource(vector<shared_ptr<ElementBase> > & arguments, |
| 68 |
vector<shared_ptr<ElementBase> > & localDeclarations) const = 0; |
| 69 |
|
| 70 |
virtual void setAsArgument(cl::Kernel & kernel, unsigned int argumentIndex) const = 0; |
| 71 |
virtual ~ElementBase(); |
| 72 |
}; |
| 73 |
|
| 74 |
typedef std::shared_ptr<ElementBase> Element; |
| 75 |
|
| 76 |
} // namespace acl |
| 77 |
#endif // ACLELEMENTBASE_H |