ASL
0.1.7
Advanced Simulation Library
Toggle main menu visibility
Loading...
Searching...
No Matches
src
acl
DataTypes
aclMemBlock.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 ACLMEMBLOCK_H
25
#define ACLMEMBLOCK_H
26
27
#include "
../aclStdIncludes.h
"
28
#include "
../aclElementBase.h
"
29
#include "
../aclUtilities.h
"
30
#include <
aslUtilities.h
>
31
#include "
../aclHardware.h
"
32
33
34
// using namespace asl;
35
// using shared_ptr;
36
namespace
acl
37
{
38
39
class
MemBlock
:
public
ElementBase
40
{
41
protected
:
42
shared_ptr<cl::Buffer>
buffer
;
//< pointer in gpu
43
weak_ptr<void>
region
;
44
MemBlock
();
45
MemBlock
(
unsigned
int
size
,
TypeID
typeID
,
CommandQueue
queue_);
46
MemBlock
(
unsigned
int
size
,
TypeID
typeID
,
char
*initArray,
CommandQueue
queue_);
47
virtual
void
swapBuffers
(
MemBlock
& a);
48
public
:
49
virtual
cl::Buffer
&
getBuffer
();
50
shared_ptr<void>
map
();
51
friend
inline
void
swapBuffers
(
MemBlock
& a,
MemBlock
& b);
52
};
53
54
typedef
shared_ptr<MemBlock>
ElementData
;
55
inline
void
swapBuffers
(
MemBlock
& a,
MemBlock
& b);
56
57
58
template
<
typename
T>
inline
std::shared_ptr<T>
map
(
ElementData
m);
59
60
// --------------------Implementation -----------------------
61
62
inline
void
swapBuffers
(
MemBlock
& a,
MemBlock
& b)
63
{
64
a.
swapBuffers
(b);
65
}
66
67
68
template
<
typename
T>
inline
std::shared_ptr<T>
map
(
ElementData
m)
69
{
70
if
(m->
getTypeID
() !=
typeToTypeID<T>
())
71
asl::errorMessage
(
"map: there is attempt to cast pointer with type "
+
72
typeToStr<T>
() +
73
" for an element with type "
+
74
TYPE
[m->
getTypeID
()]);
75
return
std::shared_ptr<T> (m->
map
(),(T*)m->
map
().get());
76
}
77
}
// namespace acl
78
79
#endif
// ACLVECTOR_H
aclElementBase.h
aclHardware.h
aclStdIncludes.h
aclUtilities.h
aslUtilities.h
useful common utilities
acl::ElementBase::getTypeID
TypeID getTypeID() const
acl::ElementBase::ElementBase
ElementBase(bool isWritable_, unsigned int size_, TypeID typeID_)
acl::ElementBase::typeID
TypeID typeID
Definition
aclElementBase.h:53
acl::ElementBase::size
unsigned int size
Definition
aclElementBase.h:52
acl::MemBlock
Definition
aclMemBlock.h:40
acl::MemBlock::getBuffer
virtual cl::Buffer & getBuffer()
acl::MemBlock::map
shared_ptr< void > map()
acl::MemBlock::swapBuffers
virtual void swapBuffers(MemBlock &a)
acl::MemBlock::MemBlock
MemBlock()
acl::MemBlock::buffer
shared_ptr< cl::Buffer > buffer
Definition
aclMemBlock.h:42
acl::MemBlock::MemBlock
MemBlock(unsigned int size, TypeID typeID, CommandQueue queue_)
acl::MemBlock::MemBlock
MemBlock(unsigned int size, TypeID typeID, char *initArray, CommandQueue queue_)
acl::MemBlock::region
weak_ptr< void > region
Definition
aclMemBlock.h:43
cl::Buffer
Class interface for Buffer Memory Objects.
Definition
cl.hpp:3018
asl::errorMessage
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
acl
Advanced Computational Language.
Definition
acl.h:41
acl::CommandQueue
std::shared_ptr< cl::CommandQueue > CommandQueue
Definition
acl.h:51
acl::typeToTypeID
constexpr const TypeID typeToTypeID()
acl::map
std::shared_ptr< T > map(ElementData m)
Definition
aclMemBlock.h:68
acl::TypeID
TypeID
Definition
aclTypes.h:39
acl::typeToStr
const std::string & typeToStr()
acl::ElementData
std::shared_ptr< MemBlock > ElementData
Definition
acl.h:48
acl::TYPE
const std::vector< std::string > TYPE
acl::swapBuffers
void swapBuffers(std::shared_ptr< Array< T > >a, std::shared_ptr< Array< T > > b)
Generated by
1.17.0