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
f314c210
Commit
f314c210
authored
Jun 07, 2017
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename spawn_config to nd_range
parent
522e26e3
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
143 additions
and
143 deletions
+143
-143
libcaf_opencl/caf/opencl/arguments.hpp
libcaf_opencl/caf/opencl/arguments.hpp
+2
-2
libcaf_opencl/caf/opencl/command.hpp
libcaf_opencl/caf/opencl/command.hpp
+12
-12
libcaf_opencl/caf/opencl/detail/spawn_helper.hpp
libcaf_opencl/caf/opencl/detail/spawn_helper.hpp
+6
-6
libcaf_opencl/caf/opencl/manager.hpp
libcaf_opencl/caf/opencl/manager.hpp
+24
-24
libcaf_opencl/caf/opencl/nd_range.hpp
libcaf_opencl/caf/opencl/nd_range.hpp
+20
-20
libcaf_opencl/caf/opencl/opencl_actor.hpp
libcaf_opencl/caf/opencl/opencl_actor.hpp
+16
-16
libcaf_opencl/examples/proper_matrix.cpp
libcaf_opencl/examples/proper_matrix.cpp
+1
-1
libcaf_opencl/examples/scan.cpp
libcaf_opencl/examples/scan.cpp
+8
-8
libcaf_opencl/examples/simple_matrix.cpp
libcaf_opencl/examples/simple_matrix.cpp
+1
-1
libcaf_opencl/test/opencl.cpp
libcaf_opencl/test/opencl.cpp
+53
-53
No files found.
libcaf_opencl/caf/opencl/arguments.hpp
View file @
f314c210
...
...
@@ -54,7 +54,7 @@ struct dummy_size_calculator {
}
};
/// Mark an a spawn
_cl
template argument as input only
/// Mark an a spawn template argument as input only
template
<
class
Arg
,
class
Tag
=
val
>
struct
in
{
static_assert
(
std
::
is_same
<
Tag
,
val
>::
value
||
std
::
is_same
<
Tag
,
mref
>::
value
,
...
...
@@ -63,7 +63,7 @@ struct in {
using
arg_type
=
typename
std
::
decay
<
Arg
>::
type
;
};
/// Mark an a spawn
_cl
template argument as input and output
/// Mark an a spawn template argument as input and output
template
<
class
Arg
,
class
TagIn
=
val
,
class
TagOut
=
val
>
struct
in_out
{
static_assert
(
...
...
libcaf_opencl/caf/opencl/command.hpp
View file @
f314c210
...
...
@@ -37,7 +37,7 @@
#include "caf/opencl/arguments.hpp"
#include "caf/opencl/smart_ptr.hpp"
#include "caf/opencl/opencl_err.hpp"
#include "caf/opencl/
spawn_config
.hpp"
#include "caf/opencl/
nd_range
.hpp"
namespace
caf
{
namespace
opencl
{
...
...
@@ -60,7 +60,7 @@ public:
std
::
vector
<
size_t
>
lengths
,
message
msg
,
std
::
tuple
<
Ts
...
>
output_tuple
,
spawn_config
config
)
nd_range
range
)
:
lengths_
(
std
::
move
(
lengths
)),
promise_
(
std
::
move
(
promise
)),
cl_actor_
(
std
::
move
(
parent
)),
...
...
@@ -70,7 +70,7 @@ public:
scratch_buffers_
(
std
::
move
(
scratches
)),
results_
(
output_tuple
),
msg_
(
std
::
move
(
msg
)),
config_
(
std
::
move
(
config
))
{
range_
(
std
::
move
(
range
))
{
// nop
}
...
...
@@ -107,10 +107,10 @@ public:
mem_out_events_
.
emplace_back
();
cl_int
err
=
clEnqueueNDRangeKernel
(
parent
->
queue_
.
get
(),
parent
->
kernel_
.
get
(),
static_cast
<
unsigned
int
>
(
config
_
.
dimensions
().
size
()),
data_or_nullptr
(
config
_
.
offsets
()),
data_or_nullptr
(
config
_
.
dimensions
()),
data_or_nullptr
(
config
_
.
local_dimensions
()),
static_cast
<
unsigned
int
>
(
range
_
.
dimensions
().
size
()),
data_or_nullptr
(
range
_
.
offsets
()),
data_or_nullptr
(
range
_
.
dimensions
()),
data_or_nullptr
(
range
_
.
local_dimensions
()),
static_cast
<
unsigned
int
>
(
mem_in_events_
.
size
()),
(
mem_in_events_
.
empty
()
?
nullptr
:
mem_in_events_
.
data
()),
&
mem_out_events_
.
back
()
...
...
@@ -183,10 +183,10 @@ public:
cl_event
execution_event
;
cl_int
err
=
clEnqueueNDRangeKernel
(
parent
->
queue_
.
get
(),
parent
->
kernel_
.
get
(),
static_cast
<
cl_uint
>
(
config
_
.
dimensions
().
size
()),
data_or_nullptr
(
config
_
.
offsets
()),
data_or_nullptr
(
config
_
.
dimensions
()),
data_or_nullptr
(
config
_
.
local_dimensions
()),
static_cast
<
cl_uint
>
(
range
_
.
dimensions
().
size
()),
data_or_nullptr
(
range
_
.
offsets
()),
data_or_nullptr
(
range
_
.
dimensions
()),
data_or_nullptr
(
range
_
.
local_dimensions
()),
static_cast
<
unsigned
int
>
(
mem_in_events_
.
size
()),
(
mem_in_events_
.
empty
()
?
nullptr
:
mem_in_events_
.
data
()),
&
execution_event
...
...
@@ -274,7 +274,7 @@ private:
std
::
vector
<
cl_mem_ptr
>
scratch_buffers_
;
std
::
tuple
<
Ts
...
>
results_
;
message
msg_
;
// keeps the argument buffers alive for async copy to device
spawn_config
config
_
;
nd_range
range
_
;
};
}
// namespace opencl
...
...
libcaf_opencl/caf/opencl/detail/spawn_helper.hpp
View file @
f314c210
...
...
@@ -35,28 +35,28 @@ struct cl_spawn_helper {
using
map_out_fun
=
typename
impl
::
output_mapping
;
actor
operator
()(
actor_config
actor_cfg
,
const
opencl
::
program_ptr
p
,
const
char
*
fn
,
const
opencl
::
spawn_config
&
spawn_cfg
,
const
char
*
fn
,
const
opencl
::
nd_range
&
range
,
Ts
&&
...
xs
)
const
{
return
actor_cast
<
actor
>
(
impl
::
create
(
std
::
move
(
actor_cfg
),
p
,
fn
,
spawn_cfg
,
p
,
fn
,
range
,
map_in_fun
{},
map_out_fun
{},
std
::
move
(
xs
)...));
}
actor
operator
()(
actor_config
actor_cfg
,
const
opencl
::
program_ptr
p
,
const
char
*
fn
,
const
opencl
::
spawn_config
&
spawn_cfg
,
const
char
*
fn
,
const
opencl
::
nd_range
&
range
,
map_in_fun
map_input
,
Ts
&&
...
xs
)
const
{
return
actor_cast
<
actor
>
(
impl
::
create
(
std
::
move
(
actor_cfg
),
p
,
fn
,
spawn_cfg
,
p
,
fn
,
range
,
std
::
move
(
map_input
),
map_out_fun
{},
std
::
move
(
xs
)...));
}
actor
operator
()(
actor_config
actor_cfg
,
const
opencl
::
program_ptr
p
,
const
char
*
fn
,
const
opencl
::
spawn_config
&
spawn_cfg
,
const
char
*
fn
,
const
opencl
::
nd_range
&
range
,
map_in_fun
map_input
,
map_out_fun
map_output
,
Ts
&&
...
xs
)
const
{
return
actor_cast
<
actor
>
(
impl
::
create
(
std
::
move
(
actor_cfg
),
p
,
fn
,
spawn_cfg
,
p
,
fn
,
range
,
std
::
move
(
map_input
),
std
::
move
(
map_output
),
std
::
move
(
xs
)...));
...
...
libcaf_opencl/caf/opencl/manager.hpp
View file @
f314c210
...
...
@@ -113,9 +113,9 @@ public:
actor
>::
type
spawn
(
const
opencl
::
program_ptr
prog
,
const
char
*
fname
,
const
opencl
::
spawn_config
&
config
,
T
x
,
Ts
...
xs
)
{
const
opencl
::
nd_range
&
range
,
T
x
,
Ts
...
xs
)
{
detail
::
cl_spawn_helper
<
false
,
T
,
Ts
...
>
f
;
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
prog
,
fname
,
config
,
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
prog
,
fname
,
range
,
std
::
move
(
x
),
std
::
move
(
xs
)...);
}
...
...
@@ -130,10 +130,10 @@ public:
actor
>::
type
spawn
(
const
char
*
source
,
const
char
*
fname
,
const
opencl
::
spawn_config
&
config
,
T
x
,
Ts
...
xs
)
{
const
opencl
::
nd_range
&
range
,
T
x
,
Ts
...
xs
)
{
detail
::
cl_spawn_helper
<
false
,
T
,
Ts
...
>
f
;
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
create_program
(
source
),
fname
,
config
,
create_program
(
source
),
fname
,
range
,
std
::
move
(
x
),
std
::
move
(
xs
)...);
}
...
...
@@ -143,11 +143,11 @@ public:
/// `dims.empty()`, or `clCreateKernel` failed.
template
<
class
Fun
,
class
...
Ts
>
actor
spawn
(
const
opencl
::
program_ptr
prog
,
const
char
*
fname
,
const
opencl
::
spawn_config
&
config
,
const
opencl
::
nd_range
&
range
,
std
::
function
<
optional
<
message
>
(
message
&
)
>
map_args
,
Fun
map_result
,
Ts
...
xs
)
{
detail
::
cl_spawn_helper
<
false
,
Ts
...
>
f
;
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
prog
,
fname
,
config
,
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
prog
,
fname
,
range
,
std
::
move
(
map_args
),
std
::
move
(
map_result
),
std
::
forward
<
Ts
>
(
xs
)...);
}
...
...
@@ -159,12 +159,12 @@ public:
/// occured, or @p clCreateKernel failed.
template
<
class
Fun
,
class
...
Ts
>
actor
spawn
(
const
char
*
source
,
const
char
*
fname
,
const
opencl
::
spawn_config
&
config
,
const
opencl
::
nd_range
&
range
,
std
::
function
<
optional
<
message
>
(
message
&
)
>
map_args
,
Fun
map_result
,
Ts
...
xs
)
{
detail
::
cl_spawn_helper
<
false
,
Ts
...
>
f
;
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
create_program
(
source
),
fname
,
config
,
create_program
(
source
),
fname
,
range
,
std
::
move
(
map_args
),
std
::
move
(
map_result
),
std
::
forward
<
Ts
>
(
xs
)...);
}
...
...
@@ -181,11 +181,11 @@ public:
actor
>::
type
spawn
(
const
opencl
::
program_ptr
prog
,
const
char
*
fname
,
const
opencl
::
spawn_config
&
config
,
const
opencl
::
nd_range
&
range
,
std
::
function
<
optional
<
message
>
(
message
&
)
>
map_args
,
T
x
,
Ts
...
xs
)
{
detail
::
cl_spawn_helper
<
false
,
Ts
...
>
f
;
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
prog
,
fname
,
config
,
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
prog
,
fname
,
range
,
std
::
move
(
map_args
),
std
::
forward
<
T
>
(
x
),
std
::
forward
<
Ts
>
(
xs
)...);
}
...
...
@@ -200,12 +200,12 @@ public:
actor
>::
type
spawn
(
const
char
*
source
,
const
char
*
fname
,
const
opencl
::
spawn_config
&
config
,
const
opencl
::
nd_range
&
range
,
std
::
function
<
optional
<
message
>
(
message
&
)
>
map_args
,
T
x
,
Ts
...
xs
)
{
detail
::
cl_spawn_helper
<
false
,
Ts
...
>
f
;
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
create_program
(
source
),
fname
,
config
,
create_program
(
source
),
fname
,
range
,
std
::
move
(
map_args
),
std
::
forward
<
T
>
(
x
),
std
::
forward
<
Ts
>
(
xs
)...);
}
...
...
@@ -222,11 +222,11 @@ public:
actor
>::
type
spawn
(
const
opencl
::
program_ptr
prog
,
const
char
*
fname
,
const
opencl
::
spawn_config
&
config
,
std
::
function
<
optional
<
message
>
(
spawn_config
&
,
message
&
)
>
map_args
,
const
opencl
::
nd_range
&
range
,
std
::
function
<
optional
<
message
>
(
nd_range
&
,
message
&
)
>
map_args
,
Fun
map_result
,
Ts
...
xs
)
{
detail
::
cl_spawn_helper
<
true
,
Ts
...
>
f
;
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
prog
,
fname
,
config
,
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
prog
,
fname
,
range
,
std
::
move
(
map_args
),
std
::
move
(
map_result
),
std
::
forward
<
Ts
>
(
xs
)...);
}
...
...
@@ -242,12 +242,12 @@ public:
actor
>::
type
spawn
(
const
char
*
source
,
const
char
*
fname
,
const
opencl
::
spawn_config
&
config
,
std
::
function
<
optional
<
message
>
(
spawn_config
&
,
message
&
)
>
map_args
,
const
opencl
::
nd_range
&
range
,
std
::
function
<
optional
<
message
>
(
nd_range
&
,
message
&
)
>
map_args
,
Fun
map_result
,
Ts
...
xs
)
{
detail
::
cl_spawn_helper
<
true
,
Ts
...
>
f
;
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
create_program
(
source
),
fname
,
config
,
create_program
(
source
),
fname
,
range
,
std
::
move
(
map_args
),
std
::
move
(
map_result
),
std
::
forward
<
Ts
>
(
xs
)...);
}
...
...
@@ -262,11 +262,11 @@ public:
actor
>::
type
spawn
(
const
opencl
::
program_ptr
prog
,
const
char
*
fname
,
const
opencl
::
spawn_config
&
config
,
std
::
function
<
optional
<
message
>
(
spawn_config
&
,
message
&
)
>
map_args
,
const
opencl
::
nd_range
&
range
,
std
::
function
<
optional
<
message
>
(
nd_range
&
,
message
&
)
>
map_args
,
T
x
,
Ts
...
xs
)
{
detail
::
cl_spawn_helper
<
true
,
T
,
Ts
...
>
f
;
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
prog
,
fname
,
config
,
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
prog
,
fname
,
range
,
std
::
move
(
map_args
),
std
::
forward
<
T
>
(
x
),
std
::
forward
<
Ts
>
(
xs
)...);
}
...
...
@@ -281,12 +281,12 @@ public:
actor
>::
type
spawn
(
const
char
*
source
,
const
char
*
fname
,
const
opencl
::
spawn_config
&
config
,
std
::
function
<
optional
<
message
>
(
spawn_config
&
,
message
&
)
>
map_args
,
const
opencl
::
nd_range
&
range
,
std
::
function
<
optional
<
message
>
(
nd_range
&
,
message
&
)
>
map_args
,
T
x
,
Ts
...
xs
)
{
detail
::
cl_spawn_helper
<
true
,
T
,
Ts
...
>
f
;
return
f
(
actor_config
{
system_
.
dummy_execution_unit
()},
create_program
(
source
),
fname
,
config
,
create_program
(
source
),
fname
,
range
,
std
::
move
(
map_args
),
std
::
forward
<
T
>
(
x
),
std
::
forward
<
Ts
>
(
xs
)...);
}
...
...
libcaf_opencl/caf/opencl/
spawn_config
.hpp
→
libcaf_opencl/caf/opencl/
nd_range
.hpp
View file @
f314c210
...
...
@@ -17,39 +17,39 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_OPENCL_
SPAWN_CONFIG
_HPP
#define CAF_OPENCL_
SPAWN_CONFIG
_HPP
#ifndef CAF_OPENCL_
ND_RANGE
_HPP
#define CAF_OPENCL_
ND_RANGE
_HPP
#include "caf/opencl/global.hpp"
namespace
caf
{
namespace
opencl
{
class
spawn_config
{
class
nd_range
{
public:
spawn_config
(
const
opencl
::
dim_vec
&
dim
s
,
const
opencl
::
dim_vec
&
offset
=
{},
const
opencl
::
dim_vec
&
local_dim
s
=
{})
:
dims_
{
dims
},
offset_
{
offset
},
local_dims_
{
local_dims
}
{
nd_range
(
const
opencl
::
dim_vec
&
dimension
s
,
const
opencl
::
dim_vec
&
offsets
=
{},
const
opencl
::
dim_vec
&
local_dimension
s
=
{})
:
dims_
{
dim
ension
s
},
offset_
{
offset
s
},
local_dims_
{
local_dim
ension
s
}
{
// nop
}
spawn_config
(
opencl
::
dim_vec
&&
dim
s
,
opencl
::
dim_vec
&&
offset
=
{},
opencl
::
dim_vec
&&
local_dim
s
=
{})
:
dims_
{
std
::
move
(
dims
)},
offset_
{
std
::
move
(
offset
)},
local_dims_
{
std
::
move
(
local_dims
)}
{
nd_range
(
opencl
::
dim_vec
&&
dimension
s
,
opencl
::
dim_vec
&&
offsets
=
{},
opencl
::
dim_vec
&&
local_dimension
s
=
{})
:
dims_
{
std
::
move
(
dim
ension
s
)},
offset_
{
std
::
move
(
offset
s
)},
local_dims_
{
std
::
move
(
local_dim
ension
s
)}
{
// nop
}
spawn_config
(
const
spawn_config
&
)
=
default
;
spawn_config
(
spawn_config
&&
)
=
default
;
nd_range
(
const
nd_range
&
)
=
default
;
nd_range
(
nd_range
&&
)
=
default
;
spawn_config
&
operator
=
(
const
spawn_config
&
)
=
default
;
spawn_config
&
operator
=
(
spawn_config
&&
)
=
default
;
nd_range
&
operator
=
(
const
nd_range
&
)
=
default
;
nd_range
&
operator
=
(
nd_range
&&
)
=
default
;
const
opencl
::
dim_vec
&
dimensions
()
const
{
return
dims_
;
...
...
@@ -72,4 +72,4 @@ private:
}
// namespace opencl
}
// namespace caf
#endif // CAF_OPENCL_
SPAWN_CONFIG
_HPP
#endif // CAF_OPENCL_
ND_RANGE
_HPP
libcaf_opencl/caf/opencl/opencl_actor.hpp
View file @
f314c210
...
...
@@ -40,7 +40,7 @@
#include "caf/opencl/arguments.hpp"
#include "caf/opencl/smart_ptr.hpp"
#include "caf/opencl/opencl_err.hpp"
#include "caf/opencl/
spawn_config
.hpp"
#include "caf/opencl/
nd_range
.hpp"
namespace
caf
{
namespace
opencl
{
...
...
@@ -101,7 +101,7 @@ public:
using
input_types
=
typename
detail
::
tl_map
<
input_wrapped_types
,
extract_input_type
>::
type
;
using
input_mapping
=
typename
std
::
conditional
<
PassConfig
,
std
::
function
<
optional
<
message
>
(
spawn_config
&
,
message
&
)
>
,
std
::
function
<
optional
<
message
>
(
nd_range
&
,
message
&
)
>
,
std
::
function
<
optional
<
message
>
(
message
&
)
>
>::
type
;
...
...
@@ -127,16 +127,16 @@ public:
}
static
actor
create
(
actor_config
actor_conf
,
const
program_ptr
prog
,
const
char
*
kernel_name
,
const
spawn_config
&
spawn_conf
,
const
char
*
kernel_name
,
const
nd_range
&
range
,
input_mapping
map_args
,
output_mapping
map_result
,
Ts
&&
...
xs
)
{
if
(
spawn_conf
.
dimensions
().
empty
())
{
if
(
range
.
dimensions
().
empty
())
{
auto
str
=
"OpenCL kernel needs at least 1 global dimension."
;
CAF_LOG_ERROR
(
str
);
throw
std
::
runtime_error
(
str
);
}
auto
check_vec
=
[
&
](
const
dim_vec
&
vec
,
const
char
*
name
)
{
if
(
!
vec
.
empty
()
&&
vec
.
size
()
!=
spawn_conf
.
dimensions
().
size
())
{
if
(
!
vec
.
empty
()
&&
vec
.
size
()
!=
range
.
dimensions
().
size
())
{
std
::
ostringstream
oss
;
oss
<<
name
<<
" vector is not empty, but "
<<
"its size differs from global dimensions vector's size"
;
...
...
@@ -144,8 +144,8 @@ public:
throw
std
::
runtime_error
(
oss
.
str
());
}
};
check_vec
(
spawn_conf
.
offsets
(),
"offsets"
);
check_vec
(
spawn_conf
.
local_dimensions
(),
"local dimensions"
);
check_vec
(
range
.
offsets
(),
"offsets"
);
check_vec
(
range
.
local_dimensions
(),
"local dimensions"
);
auto
&
sys
=
actor_conf
.
host
->
system
();
auto
itr
=
prog
->
available_kernels_
.
find
(
kernel_name
);
if
(
itr
==
prog
->
available_kernels_
.
end
())
{
...
...
@@ -155,14 +155,14 @@ public:
false
);
return
make_actor
<
opencl_actor
,
actor
>
(
sys
.
next_actor_id
(),
sys
.
node
(),
&
sys
,
std
::
move
(
actor_conf
),
prog
,
kernel
,
spawn_conf
,
prog
,
kernel
,
range
,
std
::
move
(
map_args
),
std
::
move
(
map_result
),
std
::
forward_as_tuple
(
xs
...));
}
return
make_actor
<
opencl_actor
,
actor
>
(
sys
.
next_actor_id
(),
sys
.
node
(),
&
sys
,
std
::
move
(
actor_conf
),
prog
,
itr
->
second
,
spawn_conf
,
prog
,
itr
->
second
,
range
,
std
::
move
(
map_args
),
std
::
move
(
map_result
),
std
::
forward_as_tuple
(
xs
...));
...
...
@@ -203,7 +203,7 @@ public:
std
::
move
(
result_lengths
),
std
::
move
(
content
),
std
::
move
(
result
),
config
_
range
_
);
cmd
->
enqueue
();
}
...
...
@@ -223,7 +223,7 @@ public:
}
opencl_actor
(
actor_config
actor_conf
,
const
program_ptr
prog
,
cl_kernel_ptr
kernel
,
spawn_config
spawn_conf
,
cl_kernel_ptr
kernel
,
nd_range
range
,
input_mapping
map_args
,
output_mapping
map_result
,
std
::
tuple
<
Ts
...
>
xs
)
:
monitorable_actor
(
actor_conf
),
...
...
@@ -231,13 +231,13 @@ public:
program_
(
prog
->
program_
),
context_
(
prog
->
context_
),
queue_
(
prog
->
queue_
),
config_
(
std
::
move
(
spawn_conf
)),
range_
(
std
::
move
(
range
)),
map_args_
(
std
::
move
(
map_args
)),
map_results_
(
std
::
move
(
map_result
)),
kernel_signature_
(
std
::
move
(
xs
))
{
CAF_LOG_TRACE
(
CAF_ARG
(
this
->
id
()));
default_length_
=
std
::
accumulate
(
std
::
begin
(
config
_
.
dimensions
()),
std
::
end
(
config
_
.
dimensions
()),
default_length_
=
std
::
accumulate
(
std
::
begin
(
range
_
.
dimensions
()),
std
::
end
(
range
_
.
dimensions
()),
size_t
{
1
},
std
::
multiplies
<
size_t
>
{});
}
...
...
@@ -489,7 +489,7 @@ public:
template
<
bool
Q
=
PassConfig
>
typename
std
::
enable_if
<
Q
,
bool
>::
type
map_arguments
(
message
&
content
)
{
if
(
map_args_
)
{
auto
mapped
=
map_args_
(
config
_
,
content
);
auto
mapped
=
map_args_
(
range
_
,
content
);
if
(
!
mapped
)
{
CAF_LOG_ERROR
(
"Mapping argumentes failed."
);
return
false
;
...
...
@@ -503,7 +503,7 @@ public:
cl_program_ptr
program_
;
cl_context_ptr
context_
;
cl_command_queue_ptr
queue_
;
spawn_config
config
_
;
nd_range
range
_
;
input_mapping
map_args_
;
output_mapping
map_results_
;
std
::
tuple
<
Ts
...
>
kernel_signature_
;
...
...
libcaf_opencl/examples/proper_matrix.cpp
View file @
f314c210
...
...
@@ -176,7 +176,7 @@ void multiplier(event_based_actor* self) {
// arguments for global memory to be contained in vectors,
// the vector is omitted here.
auto
worker
=
mngr
.
spawn
(
kernel_source
,
kernel_name
,
spawn_config
{
dim_vec
{
matrix_size
,
matrix_size
}},
nd_range
{
dim_vec
{
matrix_size
,
matrix_size
}},
unbox_args
,
box_res
,
in
<
float
>
{},
in
<
float
>
{},
out
<
float
>
{});
...
...
libcaf_opencl/examples/scan.cpp
View file @
f314c210
...
...
@@ -227,22 +227,22 @@ int main() {
return
round_up
((
n
+
1
)
/
2
,
half_block
);
};
auto
nd_conf
=
[
half_block
,
get_size
](
size_t
dim
)
{
return
spawn_config
{
dim_vec
{
get_size
(
dim
)},
{},
dim_vec
{
half_block
}};
return
nd_range
{
dim_vec
{
get_size
(
dim
)},
{},
dim_vec
{
half_block
}};
};
auto
reduced_ref
=
[
&
](
const
uref
&
,
uval
n
)
{
// calculate number of groups from the group size from the values size
return
size_t
{
get_size
(
n
)
/
half_block
};
};
// default nd-range
auto
ndr
=
spawn_config
{
dim_vec
{
half_block
},
{},
dim_vec
{
half_block
}};
auto
ndr
=
nd_range
{
dim_vec
{
half_block
},
{},
dim_vec
{
half_block
}};
// ---- scan actors ----
auto
phase1
=
mngr
.
spawn
(
prog
,
kernel_name_1
,
ndr
,
[
nd_conf
](
spawn_config
&
conf
,
message
&
msg
)
->
optional
<
message
>
{
[
nd_conf
](
nd_range
&
range
,
message
&
msg
)
->
optional
<
message
>
{
return
msg
.
apply
([
&
](
uvec
&
vec
)
{
auto
size
=
vec
.
size
();
conf
=
nd_conf
(
size
);
range
=
nd_conf
(
size
);
return
make_message
(
std
::
move
(
vec
),
static_cast
<
uval
>
(
size
));
});
},
...
...
@@ -253,10 +253,10 @@ int main() {
);
auto
phase2
=
mngr
.
spawn
(
prog
,
kernel_name_2
,
ndr
,
[
nd_conf
](
spawn_config
&
conf
,
message
&
msg
)
->
optional
<
message
>
{
[
nd_conf
](
nd_range
&
range
,
message
&
msg
)
->
optional
<
message
>
{
return
msg
.
apply
([
&
](
uref
&
data
,
uref
&
incs
)
{
auto
size
=
incs
.
size
();
conf
=
nd_conf
(
size
);
range
=
nd_conf
(
size
);
return
make_message
(
move
(
data
),
move
(
incs
),
static_cast
<
uval
>
(
size
));
});
},
...
...
@@ -266,10 +266,10 @@ int main() {
);
auto
phase3
=
mngr
.
spawn
(
prog
,
kernel_name_3
,
ndr
,
[
nd_conf
](
spawn_config
&
conf
,
message
&
msg
)
->
optional
<
message
>
{
[
nd_conf
](
nd_range
&
range
,
message
&
msg
)
->
optional
<
message
>
{
return
msg
.
apply
([
&
](
uref
&
data
,
uref
&
incs
)
{
auto
size
=
incs
.
size
();
conf
=
nd_conf
(
size
);
range
=
nd_conf
(
size
);
return
make_message
(
move
(
data
),
move
(
incs
),
static_cast
<
uval
>
(
size
));
});
},
...
...
libcaf_opencl/examples/simple_matrix.cpp
View file @
f314c210
...
...
@@ -96,7 +96,7 @@ void multiplier(event_based_actor* self) {
// the vector type is omitted for brevity.
auto
worker
=
self
->
system
().
opencl_manager
().
spawn
(
kernel_source
,
kernel_name
,
spawn_config
{
dim_vec
{
matrix_size
,
matrix_size
}},
nd_range
{
dim_vec
{
matrix_size
,
matrix_size
}},
in
<
float
>
{},
in
<
float
>
{},
out
<
float
>
{}
);
// send both matrices to the actor and wait for a result
...
...
libcaf_opencl/test/opencl.cpp
View file @
f314c210
This diff is collapsed.
Click to expand it.
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