ASL  0.1.7
Advanced Simulation Library
acl.h
Go to the documentation of this file.
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 ACL_H
25 #define ACL_H
26 
27 #include "aclStdIncludes.h"
28 #include <memory>
30 //#include "aclHardware.h"
31 #include "aclTypes.h"
32 
33 namespace cl
34 {
35  class CommandQueue;
36 }
37 
38 
40 namespace acl
41 {
42  class ExpressionContainer;
43  class VectorOfElements;
44  class MatrixOfElements;
45  class MemBlock;
46  class ElementBase;
47  template <class T> class Array;
48  typedef std::shared_ptr<MemBlock> ElementData;
49  typedef std::shared_ptr<ElementBase> Element;
50  extern const KernelConfiguration KERNEL_BASIC;
51  typedef std::shared_ptr<cl::CommandQueue> CommandQueue;
52 
53 
55  namespace elementOperators
56  {
57  // Math Operators
62 
67 
72 
77 
82 
87 
88 
89 
90  // Assignment Operators
95 
100 
105 
110 
115 
120 
121 
126 
131 
136 
141 
145  Element isEqual(Element e1, Element e2);
146 
151 
156 
161 
166 
167 
168  // Mathematical Functions
172  Element sin(Element e);
173 
177  Element cos(Element e);
178 
182  Element sqrt(Element e);
183 
187  Element rsqrt(Element e);
188 
192  Element log(Element e);
193 
197  Element log10(Element e);
198 
203  Element powI(Element a, unsigned int i);
204 
209  Element exp(Element a);
210 
215  Element fabs(Element a);
216 
221  Element abs(Element a);
222 
228 
233  Element floor(Element a);
234 
239  Element isnan(Element a);
240 
243  Element nan(TypeID t);
244 
251 
257  Element sign(Element a);
258 
263  Element min(Element a,Element b);
264 
269  Element max(Element a,Element b);
270 
274 
278 
282 
283 
286  Element mad(Element e1, Element e2, Element e3);
287 
288 
289  // Synchronization Functions
295  Element syncCopy(Element source,
296  Element destination,
297  Element srcOffset,
298  Element dstOffset,
299  Element length);
300 
301 
302 
308  Element barrier(std::string flags = "CLK_LOCAL_MEM_FENCE");
309 
310 
311 
312  // Special Purpose Functions
320  Element excerpt(Element source, Element filter);
321 
329  Element parse(const std::vector<std::pair<Element, std::string> > & elementNamePairs,
330  const std::string & statement);
331 
336  Element convert(const TypeID tName, Element e1, bool strong=true);
337 
340  Element printfFunction(std::string args);
341 
342 
346 
347 
350  Element ifElse(Element condition,
351  const std::vector<Element> & thenBody,
352  const std::vector<Element> & elseBody);
353 
354 
357  Element select(Element e1, Element e2, Element e3);
358 
359 
362  Element forLoop(Element initialization,
363  Element condition,
364  Element increase,
365  const std::vector<Element> & body);
366 
368  Element any(Element e);
370  Element all(Element e);
371 
372 
373  }
374 
375 
376  // RTTI functions
377 
378  bool isConstant(Element e);
379 
381  bool isSingleValue(Element e);
382 
383  bool isMemBlock(Element e);
384 
387  template <typename T> void copy(MemBlock &source, T* destination);
388 
391  template <typename T> void copy(T* source, MemBlock &destination);
392 
395  template <typename T> void copy(MemBlock &source, std::vector<T> &destination);
396 
399  template <typename T> void copy(std::vector<T> &source, MemBlock &destination);
400 
403  template <typename T> void copy(MemBlock &source, MemBlock &destination);
404 
407  template <typename T> void copy(Element source, std::vector<T> &destination);
408 
411  template <typename T> void copy(std::vector<T> &source, Element destination);
412 
415  template <typename T> void copy(Element source, T* destination);
416 
419  template <typename T> void copy(T* source, Element destination);
420 
422 
427  const std::vector<Element> & a);
428 
430 
434  std::vector<Element> & operator<<(std::vector<Element> & ec,
435  const std::vector<Element> & a);
436 
437 
439 
444  const MatrixOfElements & a);
445 
447 
452  const ExpressionContainer & a);
453 
456  void initData(Element a,
457  Element initializationValue,
458  const KernelConfiguration & kernelConfig = KERNEL_BASIC);
459 
461  Element generateSubElement(Element, unsigned int size, int offset);
462 
464  Element generateSubElement(Element, unsigned int size, int * offset);
465 
466  Element generateSubElement(Element, unsigned int size, Element offset);
467 
471 
472  template <typename T> void swapBuffers(std::shared_ptr<Array<T> >a,
473  std::shared_ptr<Array<T> > b);
474 
475 
477  unsigned int size);
479  unsigned int size,
480  CommandQueue queue_);
481 
482 
484  unsigned int size);
485 
486 } // namespace acl
487 #endif // ACL_H
Element abs_diff(Element a, Element b)
Element nan(TypeID t)
bool isConstant(Element e)
Advanced Computational Language.
Definition: acl.h:40
Element barrier(std::string flags="CLK_LOCAL_MEM_FENCE")
ElementData generateElementArray(TypeID typeID, unsigned int size)
The OpenCL C++ bindings are defined within this namespace.
Definition: acl.h:33
Element any(Element e)
Corresponds to the openCL operation any.
Element operator+(Element e1, Element e2)
Element isNotEqual(Element e1, Element e2)
Element sign(Element a)
Element log10(Element e)
Element all(Element e)
Corresponds to the openCL operation all.
bool isMemBlock(Element e)
Element operator+=(Element e1, Element e2)
std::shared_ptr< cl::CommandQueue > CommandQueue
Definition: acl.h:51
Element isnan(Element a)
Element floor(Element a)
Element abs(Element a)
Element operator>(Element e1, Element e2)
Element fabs(Element a)
Element max(Element a, Element b)
Element generateElementLocalArray(TypeID typeID, unsigned int size)
Element min(Element a, Element b)
Element ifElse(Element condition, const std::vector< Element > &thenBody, const std::vector< Element > &elseBody)
Element cos(Element e)
Element operatorAssignmentSafe(Element e1, Element e2)
Element operator/(Element e1, Element e2)
Element operator!(Element e)
Element operator-(Element e)
Element operator||(Element e1, Element e2)
The class represents a matrix elements of Element.
std::ostream & operator<<(std::ostream &output, const std::vector< T > &vector)
Prints elements of the vector separated by space.
Definition: aslUtilities.h:173
Element mad(Element e1, Element e2, Element e3)
std::shared_ptr< MemBlock > ElementData
Definition: acl.h:47
Element copysign(Element a, Element b)
Element operatorAssignment(Element e1, Element e2)
Element select(Element e1, Element e2, Element e3)
Element operator>=(Element e1, Element e2)
const Block offset(const Block &bl, int a=1)
Element atomic_add(Element e1, Element e2)
Element parse(const std::vector< std::pair< Element, std::string > > &elementNamePairs, const std::string &statement)
The class represents several Element.
Element atomic_xchg(Element e1, Element e2)
Element sqrt(Element e)
void swapBuffers(std::shared_ptr< Array< T > >a, std::shared_ptr< Array< T > > b)
Element atomic_sub(Element e1, Element e2)
ACL Kernel configuration class.
bool isSingleValue(Element e)
The function returns true when the input is a single valued object e.g. aclConstatnt,...
CommandQueue interface for cl_command_queue.
Definition: cl.hpp:5354
Element operator<(Element e1, Element e2)
Element operator&&(Element e1, Element e2)
Element log(Element e)
Element powI(Element a, unsigned int i)
Element operator/=(Element e1, Element e2)
std::shared_ptr< ElementBase > Element
Definition: acl.h:49
Element sin(Element e)
Element rsqrt(Element e)
Element forLoop(Element initialization, Element condition, Element increase, const std::vector< Element > &body)
Element printfFunction(std::string args)
Global array.
Definition: acl.h:47
Element generateShiftedElement(Element, int offset)
Element exp(Element a)
Element excerpt(Element source, Element filter)
TypeID
Definition: aclTypes.h:38
Element operator*=(Element e1, Element e2)
Element convert(const TypeID tName, Element e1, bool strong=true)
Element operator-=(Element e1, Element e2)
Element isEqual(Element e1, Element e2)
Element generateSubElement(Element, unsigned int size, int offset)
function creates subElement with given length and offset; offset is constant
void copy(MemBlock &source, T *destination)
void initData(Element a, Element initializationValue, const KernelConfiguration &kernelConfig=KERNEL_BASIC)
Element syncCopy(Element source, Element destination, Element srcOffset, Element dstOffset, Element length)
const KernelConfiguration KERNEL_BASIC
Element operator*(Element e1, Element e2)
Element operator%(Element e1, Element e2)
Element operator<=(Element e1, Element e2)