Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
las3_pub
/
predictable_parallel_patterns
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4c626a86
authored
5 years ago
by
FritzFlorian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add high level bindings for spawn/sync.
parent
e2de954a
Pipeline
#1425
failed with stages
in 31 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
5 deletions
+26
-5
lib/pls/include/pls/pls.h
+2
-2
test/patterns_test.cpp
+23
-0
test/scheduling_tests.cpp
+1
-3
No files found.
lib/pls/include/pls/pls.h
View file @
4c626a86
...
...
@@ -13,10 +13,10 @@ namespace pls {
// 'basic' for-join APIs
using
internal
::
scheduling
::
scheduler
;
template
<
typename
Function
>
void
spawn
(
Function
&&
function
)
{
static
void
spawn
(
Function
&&
function
)
{
scheduler
::
spawn
(
std
::
forward
<
Function
>
(
function
));
}
void
sync
()
{
static
void
sync
()
{
scheduler
::
sync
();
}
...
...
This diff is collapsed.
Click to expand it.
test/patterns_test.cpp
View file @
4c626a86
...
...
@@ -7,6 +7,29 @@
constexpr
int
MAX_NUM_TASKS
=
32
;
constexpr
int
MAX_STACK_SIZE
=
1024
*
8
;
TEST_CASE
(
"spawn/sync invoke calls correctly"
,
"[algorithms/invoke.h]"
)
{
pls
::
scheduler
scheduler
{
3
,
MAX_NUM_TASKS
,
MAX_STACK_SIZE
};
std
::
atomic
<
int
>
num_run
{
0
};
scheduler
.
perform_work
([
&
]
{
pls
::
spawn
([
&
]
{
num_run
++
;
while
(
num_run
<
3
);
});
pls
::
spawn
([
&
]
{
while
(
num_run
<
1
);
num_run
++
;
while
(
num_run
<
3
);
});
pls
::
spawn
([
&
]
{
while
(
num_run
<
2
);
num_run
++
;
});
pls
::
sync
();
REQUIRE
(
num_run
==
3
);
});
}
TEST_CASE
(
"parallel invoke calls correctly"
,
"[algorithms/invoke.h]"
)
{
pls
::
scheduler
scheduler
{
3
,
MAX_NUM_TASKS
,
MAX_STACK_SIZE
};
...
...
This diff is collapsed.
Click to expand it.
test/scheduling_tests.cpp
View file @
4c626a86
#include <catch.hpp>
#include <vector>
#include <atomic>
#include "pls/internal/scheduling/traded_cas_field.h"
#include "pls/internal/scheduling/task.h"
#include "pls/internal/scheduling/external_trading_deque.h"
#include "pls/
internal/scheduling/scheduler
.h"
#include "pls/
pls
.h"
using
namespace
pls
::
internal
::
scheduling
;
...
...
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