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>
29 #include "Kernels/aclKernelConfiguration.h"
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 
146 
151 
156 
161 
166 
167 
168  // Mathematical Functions
173 
178 
183 
188 
193 
198 
203  Element powI(Element a, unsigned int i);
204 
210 
216 
222 
228 
234 
240 
244 
251 
258 
264 
270 
274 
278 
282 
283 
287 
288 
289  // Synchronization Functions
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 
358 
359 
362  Element forLoop(Element initialization,
363  Element condition,
364  Element increase,
365  const std::vector<Element> & body);
366 
371 
372 
373  }
374 
375 
376  // RTTI functions
377 
379 
382 
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 
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 
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
Global array.
Definition: aclArray.h:37
ACL Kernel configuration class.
The class represents a matrix elements of Element.
The class represents several Element.
ExpressionContainer & operator<<(ExpressionContainer &ec, const std::vector< Element > &a)
puts a vector<Element> in ExpressionContainer
ExpressionContainer & operator<<(ExpressionContainer &ec, const ExpressionContainer &a)
puts a ExpressionContainer in ExpressionContainer
ExpressionContainer & operator<<(ExpressionContainer &ec, const MatrixOfElements &a)
puts a MatrixOfElements in ExpressionContainer
CommandQueue interface for cl_command_queue.
Definition: cl.hpp:5355
Element operator+=(Element e1, Element e2)
Element operatorAssignment(Element e1, Element e2)
Element operator-=(Element e1, Element e2)
Element operator/=(Element e1, Element e2)
Element operator*=(Element e1, Element e2)
Element operatorAssignmentSafe(Element e1, Element e2)
Element atomic_add(Element e1, Element e2)
Element atomic_xchg(Element e1, Element e2)
Element atomic_sub(Element e1, Element e2)
Element operator&&(Element e1, Element e2)
Element operator<=(Element e1, Element e2)
Element isNotEqual(Element e1, Element e2)
Element operator>=(Element e1, Element e2)
Element operator>(Element e1, Element e2)
Element operator<(Element e1, Element e2)
Element isEqual(Element e1, Element e2)
Element operator||(Element e1, Element e2)
Element forLoop(Element initialization, Element condition, Element increase, const std::vector< Element > &body)
Element select(Element e1, Element e2, Element e3)
Element ifElse(Element condition, const std::vector< Element > &thenBody, const std::vector< Element > &elseBody)
const Block offset(const Block &bl, int a=1)
const KernelConfiguration KERNEL_BASIC
Element nan(TypeID t)
Element exp(Element a)
Element max(Element a, Element b)
Element sign(Element a)
Element isnan(Element a)
Element log(Element e)
Element sqrt(Element e)
Element sin(Element e)
Element fabs(Element a)
Element mad(Element e1, Element e2, Element e3)
Element min(Element a, Element b)
Element floor(Element a)
Element abs_diff(Element a, Element b)
Element rsqrt(Element e)
Element copysign(Element a, Element b)
Element abs(Element a)
Element powI(Element a, unsigned int i)
Element cos(Element e)
Element log10(Element e)
Element operator+(Element e1, Element e2)
Element operator!(Element e)
Element operator-(Element e)
Element operator*(Element e1, Element e2)
Element operator%(Element e1, Element e2)
Element operator/(Element e1, Element e2)
void initData(Element a, Element initializationValue, const KernelConfiguration &kernelConfig=KERNEL_BASIC)
Element convert(const TypeID tName, Element e1, bool strong=true)
Element printfFunction(std::string args)
Element parse(const std::vector< std::pair< Element, std::string > > &elementNamePairs, const std::string &statement)
Element excerpt(Element source, Element filter)
Element syncCopy(Element source, Element destination, Element srcOffset, Element dstOffset, Element length)
Element barrier(std::string flags="CLK_LOCAL_MEM_FENCE")
Element any(Element e)
Corresponds to the openCL operation any.
Element all(Element e)
Corresponds to the openCL operation all.
Advanced Computational Language.
Definition: acl.h:41
ElementData generateElementArray(TypeID typeID, unsigned int size)
bool isConstant(Element e)
bool isMemBlock(Element e)
std::shared_ptr< cl::CommandQueue > CommandQueue
Definition: acl.h:51
Element generateElementLocalArray(TypeID typeID, unsigned int size)
bool isSingleValue(Element e)
The function returns true when the input is a single valued object e.g. aclConstatnt,...
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)
Element generateShiftedElement(Element, int offset)
TypeID
Definition: aclTypes.h:39
std::shared_ptr< MemBlock > ElementData
Definition: acl.h:47
void swapBuffers(std::shared_ptr< Array< T > >a, std::shared_ptr< Array< T > > b)
std::shared_ptr< ElementBase > Element
Definition: acl.h:49
std::ostream & operator<<(std::ostream &output, const std::vector< T > &vector)
Prints elements of the vector separated by space.
Definition: aslUtilities.h:173
The OpenCL C++ bindings are defined within this namespace.
Definition: acl.h:34