README.md 11.5 KB
Newer Older
Tobias Schuele committed
1
Embedded Multicore Building Blocks (EMB²)
2 3 4 5
=========================================


Overview
6
--------
7

Tobias Schuele committed
8 9
The Embedded Multicore Building Blocks (EMB²) are an easy to use yet powerful
and efficient C/C++ library for the development of parallel applications. EMB²
10 11 12 13 14 15 16 17
has been specifically designed for embedded systems and the typical
requirements that accompany them, such as real-time capability and constraints
on memory consumption. As a major advantage, low-level operations are hidden
in the library which relieves software developers from the burden of thread
management and synchronization. This not only improves productivity of
parallel software development, but also results in increased reliability and
performance of the applications.

Tobias Schuele committed
18
EMB² is independent of the hardware architecture (x86, ARM, ...) and runs on
19 20 21 22 23
various platforms, from small devices to large systems containing numerous
processor cores. It builds on MTAPI, a standardized programming interface for
leveraging task parallelism in embedded systems containing symmetric or
asymmetric multicore processors. A core feature of MTAPI is low-overhead
scheduling of fine-grained tasks among the available cores during runtime.
Tobias Schuele committed
24
Unlike existing libraries, EMB² supports task priorities, which allows the
25 26 27 28
creation of soft real-time systems. Additionally, the scheduling strategy can
be optimized for non-functional requirements such as minimal latency and
fairness.

Tobias Schuele committed
29
Besides the task scheduler, EMB² provides basic parallel algorithms, concurrent
30 31 32 33 34 35 36 37 38 39 40
data structures, and skeletons for implementing stream processing
applications. These building blocks are largely implemented in a non-blocking
fashion, thus preventing frequently encountered pitfalls like lock contention,
deadlocks, and priority inversion. As another advantage in real-time systems,
the algorithms and data structures give certain progress guarantees. For
example, wait-free data structures guarantee system-wide progress which means
that every operation completes within a finite number of steps independently
of any other concurrent operations on the same data structure.


Community and Contact
41
---------------------
42

Tobias Schuele committed
43 44
Project home:
  - https://github.com/siemens/embb
45

Tobias Schuele committed
46 47 48
Git:
  - https://github.com/siemens/embb.git (HTTP)
  - git@github.com:siemens/embb.git (SSH)
49

Tobias Schuele committed
50 51 52
Mailing lists:
  - embb-announcements@googlegroups.com (announcements)
  - embb-dev@googlegroups.com (development)
53

Tobias Schuele committed
54 55 56
Subscription:
  - https://groups.google.com/forum/#!forum/embb-announcements/join
  - https://groups.google.com/forum/#!forum/embb-dev/join
57

Tobias Schuele committed
58 59 60
Contact:
  - embb.info@gmail.com or
  - tobias.schuele@siemens.com
61 62 63


License
64
-------
65

Tobias Schuele committed
66
See the file "COPYING.md" in the project's root directory.
67 68 69


Requirements
70
------------
71 72 73 74 75 76 77 78

This project is based on the standards C99 (for C code) and C++03 (for C++
code) to be usable on a wide range of target systems. It has been tested on
the following OS/compiler/architecture combinations:

  - Linux (Ubuntu 12.10) / GCC 4.8.1 / x86, x86_64
  - Linux (Ubuntu 14.04) / GCC 4.8.2 / ARMv7
  - Windows
Tobias Schuele committed
79
    * MSVC 12.0.21005.1 REL / x86, x86_64
80 81 82 83
    * MSVC 11.0.50727.42 VSLRSTAGE / x86, x86_64

Other compilers and operating systems may be supported without any changes to
the source code. The project includes unit tests that can be used to find out
Tobias Schuele committed
84
whether a system not officially supported is suitable to run EMB². If there is
85 86 87 88 89
a requirement to support a system on which the unit tests do not pass, please
contact us: embb-dev@googlegroups.com.


Directory Structure
90
-------------------
91

Tobias Schuele committed
92
EMB² is a technology stack consisting of various building blocks. For some of
93 94
them, there exist C and C++ versions, others are only implemented in C++. The
directory names are postfixed with either "_cpp" or "_c" for  the C++ and C
Tobias Schuele committed
95
versions, respectively. Currently, EMB² contains the following components:
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

  - base: base_c, base_cpp
  - mtapi: mtapi_c, mtapi_cpp
  - algorithms: algorithms_cpp
  - dataflow: dataflow_cpp
  - containers: containers_cpp

Each component consists of an include, a src, and a test subfolder that contain
the header files, source files, and unit tests, respectively.

Component base_c contains abstractions for threading, synchronization, atomic
operations, and other functionalities. As the name indicates, the code is
implemented in C. Component base_cpp is mainly a C++ wrapper around the base_c
functionalities. Component mtapi_c is a task scheduler written in C and
mtapi_cpp a C++ wrapper for the scheduler. Component algorithms_cpp provides
high-level constructs for typical parallelization task in C++, and
dataflow_cpp generic skeletons for the development of parallel stream-based
applications. Finally, component containers_cpp provides containers, i.e.,
data structures for storing object in an organized and thread-safe way.


Build and Installation
118
----------------------
119

120 121 122 123
Note: It is recommended to build from a packaged release file and not from a
snapshot of the repository in order to get the documentation and the examples
out-of-the box.

Tobias Schuele committed
124
EMB² is built using CMake (version 2.8.9 or higher). CMake is a build file
125 126 127 128 129 130 131
generator which allows to abstract from the concrete build tools. To generate
and invoke the platform-specific build files, open a shell (on Windows, use
the Visual Studio developer shell to have the correct environment variables)
and change to the project's root directory. Create a subdirectory, where you
want to build the library, e.g., "build". Change to that subdirectory. It is
assumed that the project's root directory is now the parent directory.

132
### 1. Generation of native build files
133 134 135 136 137 138 139 140 141 142 143 144

Choose an appropriate build file generator for your system.

  - For Linux, GCC, x86/x86_64/ARM:       "Unix Makefiles"
  - For Windows, MSVC of VS 2013, x86:    "Visual Studio 12"
  - For Windows, MSVC of VS 2013, x86_64: "Visual Studio 12 Win64"
  - For Windows, MSVC of VS 2012, x86:    "Visual Studio 11"
  - For Windows, MSVC of VS 2012, x86_64: "Visual Studio 11 Win64"

A list of all available generators can be displayed by typing "cmake" without
any options. The build files can be generated using the following command:

Roger Meier committed
145
    cmake -G <generator> .. [OPTIONS]
146 147 148 149 150 151 152

Note that on Linux, the architecture (32/64 bit) cannot be selected by the
generator. However, the build mode (Release/Debug) can be specified using the
option -DCMAKE_BUILD_TYPE=[Release|Debug]. If no build mode is given on Linux,
the default (Release) is used. The Visual Studio generators create build files
for both modes (the selection is done at build time).

Tobias Schuele committed
153
EMB² can be built with and without C++ exception handling, which has to be
154
specified on build file generation. When exceptions are turned off, an error
Tobias Schuele committed
155
message is emitted and the program aborts in case of an exception within EMB².
156 157
To disable exceptions, add the option -DUSE_EXCEPTIONS=OFF.

Tobias Schuele committed
158
The tutorial of EMB² comes with example source files in doc/examples/. These
159 160 161 162 163 164 165 166
can be built with the other source files using CMake option -DBUILD_EXAMPLES=ON
in the generation step. Note, however, that the examples use C++11 features and
require a corresponding compiler.

Now you can generate the build files as shown by the following examples.

For a Linux Debug build with exception handling, type

Roger Meier committed
167
    cmake -G "Unix Makefiles" .. -DCMAKE_BUILD_TYPE=Debug
168 169 170

For a Windows build (VS 2013, x86) without exception handling, type

Roger Meier committed
171
    cmake -G "Visual Studio 12" .. -DUSE_EXCEPTIONS=OFF
172 173 174 175

Note that "Visual Studio 12" refers to the version number of Visual Studio and
not to the year in which it was released (2013).

176
### 2. Compiling and linking
177 178 179 180 181 182 183

As the next step, you can compile the library using the generated build files.
On Linux, the build mode (Release|Debug) is already given in the build files,
whereas on Windows, it has to be specified now.

For a Linux build, type

Roger Meier committed
184
    cmake --build .
185 186 187

For a Windows Release build, type

Roger Meier committed
188
    cmake --build . --config Release
189

190
### 3. Running the tests
191

Tobias Schuele committed
192
To check whether EMB² was compiled correctly, run the tests. The test
193 194 195 196
executables are contained in the subfolder "binaries".

On Linux, type

Roger Meier committed
197
    binaries/run_tests.sh
198 199 200

On Windows, type

Roger Meier committed
201
    binaries\run_tests.bat
202

Tobias Schuele committed
203
If no error message occurs, EMB² is working fine.
204

205
### 4. Installation
206 207 208

The default installation path on Linux is

Roger Meier committed
209
    /usr/local/
210 211 212

and on Windows

Roger Meier committed
213
    C:\Program Files\embb-X.Y.Z\ or C:\Program Files (x86)\embb-X.Y.Z
214 215 216 217 218

depending on the target architecture.

If you want a different installation path, you can change it now by typing

Roger Meier committed
219
    cmake -DINSTALL_PREFIX=YourCustomPath ..
220 221 222 223 224

The option "-DINSTALL_PREFIX=YourCustomPath" can also be given in Step 1.

To install the files, use the command

Roger Meier committed
225
    cmake --build . --target install
226 227 228 229 230 231 232

which copies the contents of the "install" folder to the "bin", "lib", and
"include" folders in the installation path. For the default paths, the
installation has to be run with administrator / root privileges.


Using the Library
233
-----------------
234

Tobias Schuele committed
235
To use EMB², the include files have to be made available during compilation of
236 237
your application and the libraries have to be added during linking.

238
### 1. Using C++
239

Tobias Schuele committed
240
If you want to use the C++ functionalities of EMB², you have to link the
241 242 243
following libraries (names will be different on Windows and on Linux) in the
given order:

Roger Meier committed
244 245
    embb_base, embb_base_cpp, embb_mtapi_c, embb_mtapi_cpp, embb_containers_cpp,
    embb_algorithms_cpp, embb_dataflow_cpp
246 247 248

The C++ header files can be included as follows:

Roger Meier committed
249 250 251 252
    #include<embb/mtapi/mtapi.h>
    #include<embb/base/base.h>
    #include<embb/containers/containers.h>
    #include<embb/dataflow/dataflow.h>
253

254
### 2. Using C
255 256 257

The following libraries have to be linked in the given order:

Roger Meier committed
258
    embb_base_c, mtapi_c
259 260 261

The C header files can be included as follows:

Roger Meier committed
262 263
    #include<embb/mtapi/c/mtapi.h>  or  #include<mtapi.h>
    #include<embb/base/c/base.h>
264 265 266


Documentation
267
-------------
268

Tobias Schuele committed
269
EMB² comes with a tutorial, example programs, and an HTML reference
270 271 272 273 274
documentation describing the APIs, which can be found in the "doc" folder.
The root document of the HTML reference is "doc/reference/index.html".


Code Quality
275
------------
276

Tobias Schuele committed
277
For the C++ parts of EMB², we respect most rules of the "Google C++ Style
278 279 280 281 282 283 284 285 286
Guide" which are checked using the cpplint tool. However, we ignore some
rules, as they are not applicable or yield false results for this project.
For example, we respect the include order of the Google Style Guide, but use
<> instead of "" for project includes, which confuses the cpplint tool.
Moreover, we do not tolerate compiler warnings and regularly check the source
code using Cppcheck, a static analysis tool for C++.


Known Bugs and Limitations
287
--------------------------
288

Tobias Schuele committed
289 290
- The MTAPI implementation is currently limited to homogeneous systems.
  Support for heterogeneous systems will be added in the near future.
Tobias Schuele committed
291
- For memory management reasons, the number of threads EMB² can deal with
Tobias Schuele committed
292 293 294
  is bounded by a predefined but modifiable constant (see functions
  embb_thread_get_max_count() / embb_thread_set_max_count() and class
  embb::base::Thread).
Tobias Schuele committed
295

296

297
Development and Contribution
298
----------------------------
299 300 301 302 303 304

The EMB² team welcomes all kinds of contributions, preferably as pull requests
or patches via the development mailing lists (see above). If possible, please
refer to a current snapshot of the development branch.


305
Links
306
-----
307 308 309 310 311 312 313

  - Multicore Association:
    http://www.multicore-association.org
  - MTAPI:
    http://www.multicore-association.org/workgroup/mtapi.php
  - CMake:
    http://www.cmake.org/
Tobias Schuele committed
314
  - Google C++ Style Guide:
315 316 317 318 319
    http://google-styleguide.googlecode.com/svn/trunk/cppguide.html
  - cpplint:
    http://google-styleguide.googlecode.com/svn/trunk/cpplint/
  - Cppcheck:
    http://cppcheck.sourceforge.net/