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
4469bcd3
authored
Apr 17, 2020
by
FritzFlorian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-Commit: Fix: correct install script and readme for continuation style.
parent
ec10685a
Pipeline
#1439
passed with stages
in 3 minutes 21 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
106 additions
and
62 deletions
+106
-62
CMakeLists.txt
+8
-0
README.md
+42
-39
app/context_switch/deboost.context/CMakeLists.txt
+0
-3
app/playground/main.cpp
+37
-1
lib/context_switcher/CMakeLists.txt
+16
-4
lib/context_switcher/context_switcher-config.cmake
+1
-1
lib/pls/CMakeLists.txt
+0
-14
lib/pls/pls-config.cmake
+2
-0
No files found.
CMakeLists.txt
View file @
4469bcd3
...
@@ -35,6 +35,14 @@ add_subdirectory(extern/benchmark_runner)
...
@@ -35,6 +35,14 @@ add_subdirectory(extern/benchmark_runner)
add_subdirectory
(
lib/context_switcher
)
add_subdirectory
(
lib/context_switcher
)
add_subdirectory
(
lib/pls
)
add_subdirectory
(
lib/pls
)
# ...add a custom target that will only build the library when installing.
# 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 context_switcher pls
)
# Include examples
# Include examples
add_subdirectory
(
app/playground
)
add_subdirectory
(
app/playground
)
add_subdirectory
(
app/benchmark_fft
)
add_subdirectory
(
app/benchmark_fft
)
...
...
README.md
View file @
4469bcd3
...
@@ -9,16 +9,16 @@
...
@@ -9,16 +9,16 @@
This section will give a brief introduction on how to get a minimal
This section will give a brief introduction on how to get a minimal
project setup that uses the PLS library.
project setup that uses the PLS library.
Further
[
general notes
](
NOTES.md
)
and
[
performance notes
](
PERFORMANCE.md
)
can be found in
Further
[
general notes
](
NOTES.md
)
and
[
performance notes
](
PERFORMANCE
-v2
.md
)
can be found in
their respective files.
their respective files.
Further notes on
[
performance
](
PERFORMANCE.md
)
and general
[
notes
](
NOTES.md
)
on the development progress can be found in
the linked documents.
### Installation
### Installation
PLS has no external dependencies. To compile and install it you
only need cmake and a recent C++ 17 compatible compiler.
Care might be required on not explicitly supported systems
(currently we support Linux x86 and ARMv7).
Clone the repository and open a terminal session in its folder.
Clone the repository and open a terminal session in its folder.
Create a build folder using
`mkdir cmake-build-release`
Create a build folder using
`mkdir cmake-build-release`
and switch into it
`cd cmake-build-release`
.
and switch into it
`cd cmake-build-release`
.
...
@@ -36,54 +36,57 @@ using `target_link_libraries(your_target pls::pls)`.
...
@@ -36,54 +36,57 @@ using `target_link_libraries(your_target pls::pls)`.
#include <pls/pls.h>
#include <pls/pls.h>
#include <iostream>
#include <iostream>
// Static memory allocation (see execution trees for how to configure)
static
const
int
MAX_NUM_TASKS
=
32
;
static
const
int
MAX_STACK_SIZE
=
4096
;
static
const
int
NUM_THREADS
=
8
;
long
fib
(
long
n
);
long
fib
(
long
n
);
int
main
()
{
int
main
()
{
// All memory needed by the scheduler can be allocated in advance either on stack or using malloc.
// Create a scheduler with the static amount of resources.
const
unsigned
int
num_threads
=
8
;
// All memory and system resources are allocated here.
const
unsigned
int
memory_per_thread
=
2
<<
14
;
pls
::
scheduler
scheduler
{
NUM_THREADS
,
MAX_NUM_TASKS
,
MAX_STACK_SIZE
};
static
pls
::
static_scheduler_memory
<
num_threads
,
memory_per_thread
>
memory
;
// Wake up the thread pool and perform work.
// Create the scheduler instance (starts a thread pool).
scheduler
.
perform_work
([
&
]
{
pls
::
scheduler
scheduler
{
&
memory
,
num_threads
};
long
result
=
fib
(
20
);
std
::
cout
<<
"fib(20)="
<<
result
<<
std
::
endl
;
// Wake up the thread pool and perform work.
});
scheduler
.
perform_work
([
&
]
{
// At this point the thread pool sleeps.
long
result
=
fib
(
20
);
// This can for example be used for periodic work.
std
::
cout
<<
"fib(20)="
<<
result
<<
std
::
endl
;
});
// The scheduler is destroyed at the end of the scope
// At this point the thread pool sleeps.
// This can for example be used for periodic work.
}
}
long
fib
(
long
n
)
{
long
fib
(
long
n
)
{
if
(
n
==
0
)
{
if
(
n
<=
1
)
{
return
0
;
return
n
;
}
}
if
(
n
==
1
)
{
return
1
;
// Example for the high level API.
}
// Will run both functions in parallel as separate tasks.
int
a
,
b
;
// Example for the high level API.
pls
::
invoke
(
// Will run both functions in parallel as seperate tasks.
[
&
a
,
n
]
{
a
=
fib
(
n
-
1
);
},
int
left
,
right
;
[
&
b
,
n
]
{
b
=
fib
(
n
-
2
);
}
pls
::
invoke_parallel
(
);
[
&
]
{
left
=
fib
(
n
-
1
);
},
return
a
+
b
;
[
&
]
{
right
=
fib
(
n
-
2
);
}
);
return
left
+
right
;
}
}
```
```
### Execution Trees and Static Resource Allocation
TODO: For the static memory allocation you need to find the maximum required resources.
## Project Structure
## Project Structure
The project uses
[
CMAKE
](
https://cmake.org/
)
as it's build system,
The project uses
[
CMAKE
](
https://cmake.org/
)
as it's build system,
the recommended IDE is either a simple text editor or
[
CLion
](
https://www.jetbrains.com/clion/
)
.
the recommended IDE is either a simple text editor or
[
CLion
](
https://www.jetbrains.com/clion/
)
.
We divide the project into sub-targets to separate for the library
We divide the project into sub-targets to separate for the library
itself, testing and example code. The library itself can be found in
itself, testing and example code. The library itself can be found in
`lib/pls`
, t
esting related code is in
`test`
, example and playground
`lib/pls`
, t
he context switching implementation in
`lib/context_switcher`
,
apps are in
`app`
.
testing related code is in
`test`
, example and playground/benchmark
apps are in
`app`
.
### Buiding
### Buiding
...
...
app/context_switch/deboost.context/CMakeLists.txt
View file @
4469bcd3
...
@@ -74,6 +74,3 @@ target_include_directories(fcontext
...
@@ -74,6 +74,3 @@ target_include_directories(fcontext
set_property
(
TARGET fcontext PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE
)
set_property
(
TARGET fcontext PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE
)
set_target_properties
(
fcontext PROPERTIES FOLDER Deps
${
IOS_GENERAL_PROPERTIES
}
)
set_target_properties
(
fcontext PROPERTIES FOLDER Deps
${
IOS_GENERAL_PROPERTIES
}
)
install
(
TARGETS fcontext DESTINATION lib
)
install
(
FILES
${
HEADER
}
DESTINATION include/fcontext
)
app/playground/main.cpp
View file @
4469bcd3
#include <pls/pls.h>
#include <iostream>
// Static memory allocation (see execution trees for how to configure)
static
const
int
MAX_NUM_TASKS
=
32
;
static
const
int
MAX_STACK_SIZE
=
4096
;
static
const
int
NUM_THREADS
=
8
;
long
fib
(
long
n
);
int
main
()
{
int
main
()
{
// Create a scheduler with the static amount of resources.
// All memory and system resources are allocated here.
pls
::
scheduler
scheduler
{
NUM_THREADS
,
MAX_NUM_TASKS
,
MAX_STACK_SIZE
};
// 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.
// The scheduler is destroyed at the end of the scope
}
long
fib
(
long
n
)
{
if
(
n
<=
1
)
{
return
n
;
}
return
0
;
// Example for the high level API.
// Will run both functions in parallel as separate tasks.
int
a
,
b
;
pls
::
invoke
(
[
&
a
,
n
]
{
a
=
fib
(
n
-
1
);
},
[
&
b
,
n
]
{
b
=
fib
(
n
-
2
);
}
);
return
a
+
b
;
}
}
lib/context_switcher/CMakeLists.txt
View file @
4469bcd3
...
@@ -64,19 +64,31 @@ target_include_directories(context_switcher
...
@@ -64,19 +64,31 @@ target_include_directories(context_switcher
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/include>
$<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/include>
PRIVATE
PRIVATE
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
# TODO: Set this up when we require private headers
)
)
# Installation on the system (we pack the context switcher with pls for now...)
# Rules for installing the library on a system
# ...binaries
INSTALL
(
TARGETS context_switcher
INSTALL
(
TARGETS context_switcher
EXPORT
pls
-targets
EXPORT
context_switcher
-targets
LIBRARY DESTINATION lib/context_switcher
LIBRARY DESTINATION lib/context_switcher
ARCHIVE DESTINATION lib/context_switcher
ARCHIVE DESTINATION lib/context_switcher
)
)
# ...all headers in `include`
# ...all headers in `include`
INSTALL
(
INSTALL
(
DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/
pls
DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
/include/
context_switcher
DESTINATION include
DESTINATION include
FILES_MATCHING PATTERN
"*.h*"
FILES_MATCHING PATTERN
"*.h*"
)
)
# ...allow our project to be a cmake dependency
install
(
EXPORT context_switcher-targets
FILE context_switcherTargets.cmake
NAMESPACE context_switcher::
DESTINATION lib/context_switcher
)
INSTALl
(
FILES context_switcher-config.cmake
DESTINATION lib/context_switcher
)
lib/context_switcher/context_switcher-config.cmake
View file @
4469bcd3
get_filename_component
(
SELF_DIR
"
${
CMAKE_CURRENT_LIST_FILE
}
"
PATH
)
get_filename_component
(
SELF_DIR
"
${
CMAKE_CURRENT_LIST_FILE
}
"
PATH
)
include
(
${
SELF_DIR
}
/
pls
Targets.cmake
)
include
(
${
SELF_DIR
}
/
context_switcher
Targets.cmake
)
lib/pls/CMakeLists.txt
View file @
4469bcd3
...
@@ -53,13 +53,6 @@ target_include_directories(pls
...
@@ -53,13 +53,6 @@ target_include_directories(pls
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
# TODO: Set this up when we require private headers
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
# TODO: Set this up when we require private headers
)
)
# Enable warnings/tidy code checking from our compiler
target_compile_options
(
pls PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall>
$<$<CXX_COMPILER_ID:MSVC>:
-W4>
)
# Rules for installing the library on a system
# Rules for installing the library on a system
# ...binaries
# ...binaries
INSTALL
(
TARGETS pls
INSTALL
(
TARGETS pls
...
@@ -84,10 +77,3 @@ INSTALl(
...
@@ -84,10 +77,3 @@ INSTALl(
FILES pls-config.cmake
FILES pls-config.cmake
DESTINATION lib/pls
DESTINATION lib/pls
)
)
# ...add a custom target that will only build the library when installing.
# 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 context_switcher pls
)
lib/pls/pls-config.cmake
View file @
4469bcd3
find_package
(
context_switcher REQUIRED
)
get_filename_component
(
SELF_DIR
"
${
CMAKE_CURRENT_LIST_FILE
}
"
PATH
)
get_filename_component
(
SELF_DIR
"
${
CMAKE_CURRENT_LIST_FILE
}
"
PATH
)
include
(
${
SELF_DIR
}
/plsTargets.cmake
)
include
(
${
SELF_DIR
}
/plsTargets.cmake
)
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