Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
4bbacd3f
Commit
4bbacd3f
authored
Apr 04, 2013
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
actor_facade's enqueue no longer throws exceptions
added create to actor_facade, constructor is now private
parent
624a2741
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
58 deletions
+71
-58
libcaf_opencl/cppa/opencl/actor_facade.hpp
libcaf_opencl/cppa/opencl/actor_facade.hpp
+58
-46
libcaf_opencl/cppa/opencl/command_dispatcher.hpp
libcaf_opencl/cppa/opencl/command_dispatcher.hpp
+13
-12
No files found.
libcaf_opencl/cppa/opencl/actor_facade.hpp
View file @
4bbacd3f
...
...
@@ -72,32 +72,44 @@ class actor_facade<Ret(Args...)> : public actor {
typedef
std
::
function
<
option
<
args_tuple
>
(
any_tuple
)
>
arg_mapping
;
typedef
std
::
function
<
any_tuple
(
Ret
&
)
>
result_mapping
;
actor_facade
(
command_dispatcher
*
dispatcher
,
const
program
&
prog
,
const
char
*
kernel_name
,
std
::
vector
<
size_t
>
global_dimensions
,
std
::
vector
<
size_t
>
global_offsets
,
std
::
vector
<
size_t
>
local_dimensions
,
arg_mapping
map_args
,
result_mapping
map_result
)
:
m_program
(
prog
.
m_program
)
,
m_context
(
prog
.
m_context
)
,
m_dispatcher
(
dispatcher
)
,
m_global_dimensions
(
std
::
move
(
global_dimensions
))
,
m_global_offsets
(
std
::
move
(
global_offsets
))
,
m_local_dimensions
(
std
::
move
(
local_dimensions
))
,
m_map_args
(
std
::
move
(
map_args
))
,
m_map_result
(
std
::
move
(
map_result
))
{
CPPA_LOG_TRACE
(
"new actor facde with ID "
<<
this
->
id
());
if
(
m_local_dimensions
.
size
()
>
3
||
m_global_dimensions
.
size
()
>
3
)
{
static
actor_facade
*
create
(
command_dispatcher
*
dispatcher
,
const
program
&
prog
,
const
char
*
kernel_name
,
std
::
vector
<
size_t
>
global_dimensions
,
std
::
vector
<
size_t
>
global_offsets
,
std
::
vector
<
size_t
>
local_dimensions
,
arg_mapping
map_args
,
result_mapping
map_result
)
{
if
(
local_dimensions
.
size
()
>
3
||
global_dimensions
.
size
()
>
3
||
global_dimensions
.
empty
())
{
std
::
ostringstream
oss
;
oss
<<
"OpenCL kernel allows a maximum of 3 dimensions"
" and needs at least 1 global dimension."
;
CPPA_LOG_ERROR
(
oss
.
str
());
throw
std
::
runtime_error
(
oss
.
str
());
}
cl_int
err
{
0
};
kernel_ptr
kernel
;
kernel
.
adopt
(
clCreateKernel
(
prog
.
m_program
.
get
(),
kernel_name
,
&
err
));
if
(
err
!=
CL_SUCCESS
)
{
std
::
ostringstream
oss
;
oss
<<
"Creating actor facade: a maximum of 3 dimensions allowed."
;
oss
<<
"clCreateKernel: '"
<<
get_opencl_error
(
err
)
<<
"'."
;
CPPA_LOG_ERROR
(
oss
.
str
());
throw
std
::
runtime_error
(
oss
.
str
());
}
init_kernel
(
m_program
.
get
(),
kernel_name
);
return
new
actor_facade
<
Ret
(
Args
...)
>
{
dispatcher
,
kernel
,
prog
,
std
::
move
(
global_dimensions
),
std
::
move
(
global_offsets
),
std
::
move
(
local_dimensions
),
std
::
move
(
map_args
),
std
::
move
(
map_result
)};
}
void
sync_enqueue
(
const
actor_ptr
&
sender
,
message_id
id
,
any_tuple
msg
)
{
...
...
@@ -115,29 +127,29 @@ class actor_facade<Ret(Args...)> : public actor {
private:
void
init_kernel
(
cl_program
program
,
const
char
*
kernel_name
)
{
cl_int
err
{
0
};
m_kernel
.
adopt
(
clCreateKernel
(
program
,
kernel_name
,
&
err
));
if
(
err
!=
CL_SUCCESS
)
{
std
::
ostringstream
oss
;
oss
<<
"clCreateKernel: '"
<<
get_opencl_error
(
err
)
<<
"'."
;
CPPA_LOG_ERROR
(
oss
.
str
());
throw
std
::
runtime_error
(
oss
.
str
());
}
actor_facade
(
command_dispatcher
*
dispatcher
,
kernel_ptr
kernel
,
const
program
&
prog
,
std
::
vector
<
size_t
>
global_dimensions
,
std
::
vector
<
size_t
>
global_offsets
,
std
::
vector
<
size_t
>
local_dimensions
,
arg_mapping
map_args
,
result_mapping
map_result
)
:
m_kernel
(
kernel
)
,
m_program
(
prog
.
m_program
)
,
m_context
(
prog
.
m_context
)
,
m_dispatcher
(
dispatcher
)
,
m_global_dimensions
(
std
::
move
(
global_dimensions
))
,
m_global_offsets
(
std
::
move
(
global_offsets
))
,
m_local_dimensions
(
std
::
move
(
local_dimensions
))
,
m_map_args
(
std
::
move
(
map_args
))
,
m_map_result
(
std
::
move
(
map_result
))
{
CPPA_LOG_TRACE
(
"new actor_facde with ID "
<<
this
->
id
());
}
template
<
long
...
Is
>
void
enqueue_impl
(
const
actor_ptr
&
sender
,
any_tuple
msg
,
message_id
id
,
util
::
int_list
<
Is
...
>
)
{
if
(
m_global_dimensions
.
empty
())
{
std
::
ostringstream
oss
;
oss
<<
"actor_facade::enqueue() global dimensions can't be empty!"
;
CPPA_LOG_ERROR
(
oss
.
str
());
throw
std
::
runtime_error
(
oss
.
str
());
}
auto
opt
=
m_map_args
(
msg
);
if
(
opt
)
{
response_handle
handle
{
this
,
sender
,
id
};
...
...
@@ -169,8 +181,8 @@ class actor_facade<Ret(Args...)> : public actor {
typedef
std
::
vector
<
mem_ptr
>
args_vec
;
program_ptr
m_program
;
kernel_ptr
m_kernel
;
program_ptr
m_program
;
context_ptr
m_context
;
command_dispatcher
*
m_dispatcher
;
std
::
vector
<
size_t
>
m_global_dimensions
;
...
...
@@ -194,7 +206,7 @@ class actor_facade<Ret(Args...)> : public actor {
<<
get_opencl_error
(
err
)
<<
"'."
;
CPPA_LOG_ERROR
(
oss
.
str
());
throw
std
::
runtime_error
(
oss
.
str
())
;
return
;
}
}
err
=
clSetKernelArg
(
kernel
,
...
...
@@ -207,7 +219,7 @@ class actor_facade<Ret(Args...)> : public actor {
<<
get_opencl_error
(
err
)
<<
"'."
;
CPPA_LOG_ERROR
(
oss
.
str
());
throw
std
::
runtime_error
(
oss
.
str
())
;
return
;
}
}
...
...
@@ -229,7 +241,7 @@ class actor_facade<Ret(Args...)> : public actor {
<<
get_opencl_error
(
err
)
<<
"'."
;
CPPA_LOG_ERROR
(
oss
.
str
());
throw
std
::
runtime_error
(
oss
.
str
())
;
return
;
}
else
{
mem_ptr
tmp
;
...
...
@@ -261,7 +273,7 @@ class actor_facade<Ret(Args...)> : public actor {
<<
get_opencl_error
(
err
)
<<
"'."
;
CPPA_LOG_ERROR
(
oss
.
str
());
throw
std
::
runtime_error
(
oss
.
str
())
;
return
;
}
else
{
mem_ptr
tmp
;
...
...
libcaf_opencl/cppa/opencl/command_dispatcher.hpp
View file @
4bbacd3f
...
...
@@ -91,14 +91,14 @@ class command_dispatcher {
std
::
function
<
option
<
cow_tuple
<
typename
util
::
rm_ref
<
Args
>::
type
...
>>
(
any_tuple
)
>
map_args
,
std
::
function
<
any_tuple
(
Ret
&
)
>
map_result
)
{
return
new
actor_facade
<
Ret
(
Args
...)
>
(
this
,
prog
,
kernel_name
,
std
::
move
(
global_dims
),
std
::
move
(
global_offs
),
std
::
move
(
local_dims
),
std
::
move
(
map_args
),
std
::
move
(
map_result
));
return
actor_facade
<
Ret
(
Args
...)
>::
create
(
this
,
prog
,
kernel_name
,
std
::
move
(
global_dims
),
std
::
move
(
global_offs
),
std
::
move
(
local_dims
),
std
::
move
(
map_args
),
std
::
move
(
map_result
));
}
template
<
typename
Ret
,
typename
...
Args
>
...
...
@@ -108,10 +108,11 @@ class command_dispatcher {
std
::
vector
<
size_t
>
global_offs
=
{},
std
::
vector
<
size_t
>
local_dims
=
{})
{
std
::
function
<
option
<
cow_tuple
<
typename
util
::
rm_ref
<
Args
>::
type
...
>>
(
any_tuple
)
>
f0
=
[]
(
any_tuple
msg
)
{
std
::
function
<
option
<
cow_tuple
<
typename
util
::
rm_ref
<
Args
>::
type
...
>>
(
any_tuple
)
>
map_args
=
[]
(
any_tuple
msg
)
{
return
tuple_cast
<
typename
util
::
rm_ref
<
Args
>::
type
...
>
(
msg
);
};
std
::
function
<
any_tuple
(
Ret
&
)
>
f1
=
[]
(
Ret
&
result
)
{
std
::
function
<
any_tuple
(
Ret
&
)
>
map_result
=
[]
(
Ret
&
result
)
{
return
make_any_tuple
(
std
::
move
(
result
));
};
return
this
->
spawn
<
Ret
,
Args
...
>
(
prog
,
...
...
@@ -119,8 +120,8 @@ class command_dispatcher {
std
::
move
(
global_dims
),
std
::
move
(
global_offs
),
std
::
move
(
local_dims
),
std
::
move
(
f0
),
std
::
move
(
f1
));
std
::
move
(
map_args
),
std
::
move
(
map_result
));
}
private:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment