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
1fb71654
Commit
1fb71654
authored
Apr 22, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix C++17 build with OpenCL module enabled
parent
f9fed4ae
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
26 deletions
+41
-26
libcaf_opencl/examples/proper_matrix.cpp
libcaf_opencl/examples/proper_matrix.cpp
+11
-7
libcaf_opencl/examples/scan.cpp
libcaf_opencl/examples/scan.cpp
+18
-11
libcaf_opencl/test/opencl.cpp
libcaf_opencl/test/opencl.cpp
+12
-8
No files found.
libcaf_opencl/examples/proper_matrix.cpp
View file @
1fb71654
...
@@ -27,10 +27,14 @@
...
@@ -27,10 +27,14 @@
#include "caf/opencl/all.hpp"
#include "caf/opencl/all.hpp"
using
namespace
std
;
using
namespace
caf
;
using
namespace
caf
;
using
namespace
caf
::
opencl
;
using
namespace
caf
::
opencl
;
using
std
::
cout
;
using
std
::
endl
;
using
std
::
string
;
using
std
::
vector
;
using
caf
::
detail
::
limited_vector
;
using
caf
::
detail
::
limited_vector
;
namespace
{
namespace
{
...
@@ -111,11 +115,12 @@ private:
...
@@ -111,11 +115,12 @@ private:
template
<
size_t
Size
>
template
<
size_t
Size
>
string
to_string
(
const
square_matrix
<
Size
>&
m
)
{
string
to_string
(
const
square_matrix
<
Size
>&
m
)
{
ostringstream
oss
;
std
::
ostringstream
oss
;
oss
.
fill
(
' '
);
oss
.
fill
(
' '
);
for
(
size_t
row
=
0
;
row
<
Size
;
++
row
)
{
for
(
size_t
row
=
0
;
row
<
Size
;
++
row
)
{
for
(
size_t
column
=
0
;
column
<
Size
;
++
column
)
for
(
size_t
column
=
0
;
column
<
Size
;
++
column
)
oss
<<
fixed
<<
setprecision
(
2
)
<<
setw
(
9
)
<<
m
(
column
,
row
);
oss
<<
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
std
::
setw
(
9
)
<<
m
(
column
,
row
);
oss
<<
'\n'
;
oss
<<
'\n'
;
}
}
return
oss
.
str
();
return
oss
.
str
();
...
@@ -181,11 +186,10 @@ void multiplier(event_based_actor* self) {
...
@@ -181,11 +186,10 @@ void multiplier(event_based_actor* self) {
// send both matrices to the actor and
// send both matrices to the actor and
// wait for results in form of a matrix_type
// wait for results in form of a matrix_type
self
->
request
(
worker
,
chrono
::
seconds
(
5
),
move
(
m1
),
move
(
m2
)).
then
(
self
->
request
(
worker
,
std
::
chrono
::
seconds
(
5
),
std
::
move
(
m1
),
std
::
move
(
m2
))
[](
const
matrix_type
&
result
)
{
.
then
(
[](
const
matrix_type
&
result
)
{
cout
<<
"result:"
<<
endl
<<
to_string
(
result
);
cout
<<
"result:"
<<
endl
<<
to_string
(
result
);
}
});
);
}
}
int
main
()
{
int
main
()
{
...
...
libcaf_opencl/examples/scan.cpp
View file @
1fb71654
...
@@ -26,10 +26,15 @@
...
@@ -26,10 +26,15 @@
#include "caf/all.hpp"
#include "caf/all.hpp"
#include "caf/opencl/all.hpp"
#include "caf/opencl/all.hpp"
using
namespace
std
;
using
namespace
caf
;
using
namespace
caf
;
using
namespace
caf
::
opencl
;
using
namespace
caf
::
opencl
;
using
std
::
cerr
;
using
std
::
cout
;
using
std
::
endl
;
using
std
::
string
;
using
std
::
vector
;
using
caf
::
detail
::
limited_vector
;
using
caf
::
detail
::
limited_vector
;
namespace
{
namespace
{
...
@@ -166,8 +171,8 @@ kernel void phase_3(global uint* restrict data,
...
@@ -166,8 +171,8 @@ kernel void phase_3(global uint* restrict data,
}
// namespace
}
// namespace
template
<
class
T
,
class
E
=
caf
::
detail
::
enable_if_t
<
is_integral
<
T
>
::
value
>>
template
<
class
T
,
class
=
caf
::
detail
::
enable_if_t
<
std
::
is_integral
<
T
>
::
value
>>
T
round_up
(
T
numToRound
,
T
multiple
)
{
T
round_up
(
T
numToRound
,
T
multiple
)
{
return
((
numToRound
+
multiple
-
1
)
/
multiple
)
*
multiple
;
return
((
numToRound
+
multiple
-
1
)
/
multiple
)
*
multiple
;
}
}
...
@@ -180,9 +185,9 @@ int main() {
...
@@ -180,9 +185,9 @@ int main() {
<<
"' values."
<<
endl
;
<<
"' values."
<<
endl
;
// ---- create data ----
// ---- create data ----
uvec
values
(
problem_size
);
uvec
values
(
problem_size
);
random_device
rd
;
std
::
random_device
rd
;
mt19937
gen
(
rd
());
std
::
mt19937
gen
(
rd
());
uniform_int_distribution
<
uval
>
val_gen
(
0
,
1023
);
std
::
uniform_int_distribution
<
uval
>
val_gen
(
0
,
1023
);
std
::
generate
(
begin
(
values
),
end
(
values
),
[
&
]()
{
return
val_gen
(
gen
);
});
std
::
generate
(
begin
(
values
),
end
(
values
),
[
&
]()
{
return
val_gen
(
gen
);
});
// ---- find device ----
// ---- find device ----
auto
&
mngr
=
system
.
opencl_manager
();
auto
&
mngr
=
system
.
opencl_manager
();
...
@@ -205,7 +210,7 @@ int main() {
...
@@ -205,7 +210,7 @@ int main() {
}
}
{
{
// ---- general ----
// ---- general ----
auto
dev
=
move
(
*
opt
);
auto
dev
=
std
::
move
(
*
opt
);
auto
prog
=
mngr
.
create_program
(
kernel_source
,
""
,
dev
);
auto
prog
=
mngr
.
create_program
(
kernel_source
,
""
,
dev
);
scoped_actor
self
{
system
};
scoped_actor
self
{
system
};
// ---- config parameters ----
// ---- config parameters ----
...
@@ -243,7 +248,8 @@ int main() {
...
@@ -243,7 +248,8 @@ int main() {
return
msg
.
apply
([
&
](
uref
&
data
,
uref
&
incs
)
{
return
msg
.
apply
([
&
](
uref
&
data
,
uref
&
incs
)
{
auto
size
=
incs
.
size
();
auto
size
=
incs
.
size
();
range
=
nd_conf
(
size
);
range
=
nd_conf
(
size
);
return
make_message
(
move
(
data
),
move
(
incs
),
static_cast
<
uval
>
(
size
));
return
make_message
(
std
::
move
(
data
),
std
::
move
(
incs
),
static_cast
<
uval
>
(
size
));
});
});
},
},
in_out
<
uval
,
mref
,
mref
>
{},
in_out
<
uval
,
mref
,
mref
>
{},
...
@@ -256,7 +262,8 @@ int main() {
...
@@ -256,7 +262,8 @@ int main() {
return
msg
.
apply
([
&
](
uref
&
data
,
uref
&
incs
)
{
return
msg
.
apply
([
&
](
uref
&
data
,
uref
&
incs
)
{
auto
size
=
incs
.
size
();
auto
size
=
incs
.
size
();
range
=
nd_conf
(
size
);
range
=
nd_conf
(
size
);
return
make_message
(
move
(
data
),
move
(
incs
),
static_cast
<
uval
>
(
size
));
return
make_message
(
std
::
move
(
data
),
std
::
move
(
incs
),
static_cast
<
uval
>
(
size
));
});
});
},
},
in_out
<
uval
,
mref
,
val
>
{},
in_out
<
uval
,
mref
,
val
>
{},
...
@@ -273,8 +280,8 @@ int main() {
...
@@ -273,8 +280,8 @@ int main() {
cout
<<
" index | values | scan "
<<
endl
cout
<<
" index | values | scan "
<<
endl
<<
"-------+--------+--------"
<<
endl
;
<<
"-------+--------+--------"
<<
endl
;
for
(
size_t
i
=
0
;
i
<
problem_size
;
++
i
)
for
(
size_t
i
=
0
;
i
<
problem_size
;
++
i
)
cout
<<
s
etw
(
6
)
<<
i
<<
" | "
<<
setw
(
6
)
<<
values
[
i
]
<<
" | "
cout
<<
s
td
::
setw
(
6
)
<<
i
<<
" | "
<<
std
::
setw
(
6
)
<<
values
[
i
]
<<
setw
(
6
)
<<
results
[
i
]
<<
endl
;
<<
" | "
<<
std
::
setw
(
6
)
<<
results
[
i
]
<<
std
::
endl
;
}
}
);
);
}
}
...
...
libcaf_opencl/test/opencl.cpp
View file @
1fb71654
...
@@ -12,10 +12,14 @@
...
@@ -12,10 +12,14 @@
#include "caf/opencl/all.hpp"
#include "caf/opencl/all.hpp"
using
namespace
std
;
using
namespace
caf
;
using
namespace
caf
;
using
namespace
caf
::
opencl
;
using
namespace
caf
::
opencl
;
using
std
::
cout
;
using
std
::
endl
;
using
std
::
string
;
using
std
::
vector
;
using
caf
::
detail
::
tl_at
;
using
caf
::
detail
::
tl_at
;
using
caf
::
detail
::
tl_head
;
using
caf
::
detail
::
tl_head
;
using
caf
::
detail
::
type_list
;
using
caf
::
detail
::
type_list
;
...
@@ -292,7 +296,7 @@ void check_vector_results(const string& description,
...
@@ -292,7 +296,7 @@ void check_vector_results(const string& description,
cout
<<
"Size: "
<<
expected
.
size
()
<<
" vs. "
<<
result
.
size
()
<<
endl
;
cout
<<
"Size: "
<<
expected
.
size
()
<<
" vs. "
<<
result
.
size
()
<<
endl
;
cout
<<
"Differ at: "
<<
endl
;
cout
<<
"Differ at: "
<<
endl
;
bool
same
=
true
;
bool
same
=
true
;
for
(
size_t
i
=
0
;
i
<
min
(
expected
.
size
(),
result
.
size
());
++
i
)
{
for
(
size_t
i
=
0
;
i
<
std
::
min
(
expected
.
size
(),
result
.
size
());
++
i
)
{
if
(
expected
[
i
]
!=
result
[
i
])
{
if
(
expected
[
i
]
!=
result
[
i
])
{
cout
<<
"["
<<
i
<<
"] "
<<
expected
[
i
]
<<
" != "
<<
result
[
i
]
<<
endl
;
cout
<<
"["
<<
i
<<
"] "
<<
expected
[
i
]
<<
" != "
<<
result
[
i
]
<<
endl
;
same
=
false
;
same
=
false
;
...
@@ -405,7 +409,7 @@ void test_opencl(actor_system& sys) {
...
@@ -405,7 +409,7 @@ void test_opencl(actor_system& sys) {
"semicolon is missing)."
);
"semicolon is missing)."
);
try
{
try
{
/* auto expected_error = */
mngr
.
create_program
(
kernel_source_error
);
/* auto expected_error = */
mngr
.
create_program
(
kernel_source_error
);
}
catch
(
const
exception
&
exc
)
{
}
catch
(
const
std
::
exception
&
exc
)
{
CAF_MESSAGE
(
"got: "
<<
exc
.
what
());
CAF_MESSAGE
(
"got: "
<<
exc
.
what
());
}
}
#endif // CAF_NO_EXCEPTIONS
#endif // CAF_NO_EXCEPTIONS
...
@@ -423,7 +427,7 @@ void test_opencl(actor_system& sys) {
...
@@ -423,7 +427,7 @@ void test_opencl(actor_system& sys) {
);
);
// test for manuel return size selection (max workgroup size 1d)
// test for manuel return size selection (max workgroup size 1d)
auto
max_wg_size
=
min
(
dev
->
max_work_item_sizes
()[
0
],
size_t
{
512
});
auto
max_wg_size
=
std
::
min
(
dev
->
max_work_item_sizes
()[
0
],
size_t
{
512
});
auto
reduce_buffer_size
=
static_cast
<
size_t
>
(
max_wg_size
)
*
8
;
auto
reduce_buffer_size
=
static_cast
<
size_t
>
(
max_wg_size
)
*
8
;
auto
reduce_local_size
=
static_cast
<
size_t
>
(
max_wg_size
);
auto
reduce_local_size
=
static_cast
<
size_t
>
(
max_wg_size
);
auto
reduce_work_groups
=
reduce_buffer_size
/
reduce_local_size
;
auto
reduce_work_groups
=
reduce_buffer_size
/
reduce_local_size
;
...
@@ -731,7 +735,7 @@ void test_in_val_out_val(actor_system& sys) {
...
@@ -731,7 +735,7 @@ void test_in_val_out_val(actor_system& sys) {
},
others
>>
wrong_msg
);
},
others
>>
wrong_msg
);
// test for manuel return size selection (max workgroup size 1d)
// test for manuel return size selection (max workgroup size 1d)
auto
max_wg_size
=
min
(
dev
->
max_work_item_sizes
()[
0
],
size_t
{
512
});
auto
max_wg_size
=
std
::
min
(
dev
->
max_work_item_sizes
()[
0
],
size_t
{
512
});
auto
reduce_buffer_size
=
static_cast
<
size_t
>
(
max_wg_size
)
*
8
;
auto
reduce_buffer_size
=
static_cast
<
size_t
>
(
max_wg_size
)
*
8
;
auto
reduce_local_size
=
static_cast
<
size_t
>
(
max_wg_size
);
auto
reduce_local_size
=
static_cast
<
size_t
>
(
max_wg_size
);
auto
reduce_work_groups
=
reduce_buffer_size
/
reduce_local_size
;
auto
reduce_work_groups
=
reduce_buffer_size
/
reduce_local_size
;
...
@@ -801,7 +805,7 @@ void test_in_val_out_mref(actor_system& sys) {
...
@@ -801,7 +805,7 @@ void test_in_val_out_mref(actor_system& sys) {
" (kernel passed directly)"
,
res1
,
result
);
" (kernel passed directly)"
,
res1
,
result
);
},
others
>>
wrong_msg
);
},
others
>>
wrong_msg
);
// test for manuel return size selection (max workgroup size 1d)
// test for manuel return size selection (max workgroup size 1d)
auto
max_wg_size
=
min
(
dev
->
max_work_item_sizes
()[
0
],
size_t
{
512
});
auto
max_wg_size
=
std
::
min
(
dev
->
max_work_item_sizes
()[
0
],
size_t
{
512
});
auto
reduce_buffer_size
=
static_cast
<
size_t
>
(
max_wg_size
)
*
8
;
auto
reduce_buffer_size
=
static_cast
<
size_t
>
(
max_wg_size
)
*
8
;
auto
reduce_local_size
=
static_cast
<
size_t
>
(
max_wg_size
);
auto
reduce_local_size
=
static_cast
<
size_t
>
(
max_wg_size
);
auto
reduce_work_groups
=
reduce_buffer_size
/
reduce_local_size
;
auto
reduce_work_groups
=
reduce_buffer_size
/
reduce_local_size
;
...
@@ -858,7 +862,7 @@ void test_in_mref_out_val(actor_system& sys) {
...
@@ -858,7 +862,7 @@ void test_in_mref_out_val(actor_system& sys) {
" (kernel passed directly)"
,
res1
,
result
);
" (kernel passed directly)"
,
res1
,
result
);
},
others
>>
wrong_msg
);
},
others
>>
wrong_msg
);
// test for manuel return size selection (max workgroup size 1d)
// test for manuel return size selection (max workgroup size 1d)
auto
max_wg_size
=
min
(
dev
->
max_work_item_sizes
()[
0
],
size_t
{
512
});
auto
max_wg_size
=
std
::
min
(
dev
->
max_work_item_sizes
()[
0
],
size_t
{
512
});
auto
reduce_buffer_size
=
static_cast
<
size_t
>
(
max_wg_size
)
*
8
;
auto
reduce_buffer_size
=
static_cast
<
size_t
>
(
max_wg_size
)
*
8
;
auto
reduce_local_size
=
static_cast
<
size_t
>
(
max_wg_size
);
auto
reduce_local_size
=
static_cast
<
size_t
>
(
max_wg_size
);
auto
reduce_work_groups
=
reduce_buffer_size
/
reduce_local_size
;
auto
reduce_work_groups
=
reduce_buffer_size
/
reduce_local_size
;
...
@@ -917,7 +921,7 @@ void test_in_mref_out_mref(actor_system& sys) {
...
@@ -917,7 +921,7 @@ void test_in_mref_out_mref(actor_system& sys) {
" (kernel passed directly)"
,
res1
,
result
);
" (kernel passed directly)"
,
res1
,
result
);
},
others
>>
wrong_msg
);
},
others
>>
wrong_msg
);
// test for manuel return size selection (max workgroup size 1d)
// test for manuel return size selection (max workgroup size 1d)
auto
max_wg_size
=
min
(
dev
->
max_work_item_sizes
()[
0
],
size_t
{
512
});
auto
max_wg_size
=
std
::
min
(
dev
->
max_work_item_sizes
()[
0
],
size_t
{
512
});
auto
reduce_buffer_size
=
static_cast
<
size_t
>
(
max_wg_size
)
*
8
;
auto
reduce_buffer_size
=
static_cast
<
size_t
>
(
max_wg_size
)
*
8
;
auto
reduce_local_size
=
static_cast
<
size_t
>
(
max_wg_size
);
auto
reduce_local_size
=
static_cast
<
size_t
>
(
max_wg_size
);
auto
reduce_work_groups
=
reduce_buffer_size
/
reduce_local_size
;
auto
reduce_work_groups
=
reduce_buffer_size
/
reduce_local_size
;
...
...
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