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
65d91329
authored
6 years ago
by
FritzFlorian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow the library instalation without building all targets.
parent
5c654597
Pipeline
#1146
passed with stages
in 3 minutes 32 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
0 deletions
+71
-0
README.md
+64
-0
lib/pls/CMakeLists.txt
+7
-0
No files found.
README.md
View file @
65d91329
...
...
@@ -3,6 +3,70 @@
[

](http://lab.las3.de/gitlab/las3/development/scheduling/predictable_parallel_patterns/commits/master)
## Getting Started
This section will give a brief introduction on how to get a minimal
project setup that uses the PLS library.
### Installation
Clone the repository and open a terminal session in its folder.
Create a build folder using
`mkdir cmake-build-release`
and switch into it
`cd cmake-build-release`
.
Setup the cmake project using
`cmake ../ -DCMAKE_BUILD_TYPE=RELEASE`
,
then install it as a system wide dependency using
`sudo make install.pls`
.
At this point the library is installed on your system.
To use it simply add it to your existing cmake project using
`find_package(pls REQUIRED)`
and then link it to your project
using
`target_link_libraries(your_target pls::pls)`
.
### Basic Usage
```
c++
#include <pls/pls.h>
#include <iostream>
long
fib
(
long
n
);
int
main
()
{
// All memory needed by the scheduler can be allocated in advance either on stack or using malloc.
const
unsigned
int
num_threads
=
8
;
const
unsigned
int
memory_per_thread
=
2
<<
14
;
static
pls
::
static_scheduler_memory
<
num_threads
,
memory_per_thread
>
memory
;
// Create the scheduler instance (starts a thread pool).
pls
::
scheduler
scheduler
{
&
memory
,
num_threads
};
// Wake up the thread pool and perform work.
scheduler
.
perform_work
([
&
]
{
long
result
=
fib
(
20
);
std
::
cout
<<
"fib(20)="
<<
result
<<
std
::
endl
;
});
// At this point the thread pool sleeps.
// This can for example be used for periodic work.
}
long
fib
(
long
n
)
{
if
(
n
==
0
)
{
return
0
;
}
if
(
n
==
1
)
{
return
1
;
}
// Example for the high level API.
// Will run both functions in parallel as seperate tasks.
int
left
,
right
;
pls
::
invoke_parallel
(
[
&
]
{
left
=
fib
(
n
-
1
);
},
[
&
]
{
right
=
fib
(
n
-
2
);
}
);
return
left
+
right
;
}
```
## Project Structure
...
...
This diff is collapsed.
Click to expand it.
lib/pls/CMakeLists.txt
View file @
65d91329
...
...
@@ -70,6 +70,13 @@ INSTALl(
FILES pls-config.cmake
DESTINATION lib/pls
)
# ...add a custom target that will only build the library when istalling.
# This can allow us to speed up the installation on embedded devices.
ADD_CUSTOM_TARGET
(
install.pls
${
CMAKE_COMMAND
}
-DBUILD_TYPE=
${
CMAKE_BUILD_TYPE
}
-P
${
CMAKE_BINARY_DIR
}
/cmake_install.cmake
)
ADD_DEPENDENCIES
(
install.pls pls
)
# Enable warnings/tidy code checking from our compiler
target_compile_options
(
pls PRIVATE
...
...
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