Commit 65d91329 by FritzFlorian

Allow the library instalation without building all targets.

parent 5c654597
Pipeline #1146 passed with stages
in 3 minutes 32 seconds
......@@ -3,6 +3,70 @@
[![pipeline status](http://lab.las3.de/gitlab/las3/development/scheduling/predictable_parallel_patterns/badges/master/pipeline.svg)](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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment