From ae758f589a07e9a25ab0410615ba5f7ac8b9fb0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Wed, 8 Jan 2020 00:00:01 +0000 Subject: [PATCH] boost: start --- README.adoc | 26 +++++++++++++++++++++++--- build | 1 + common.py | 5 +++++ userland/libs/boost/bimap.cpp | 35 +++++++++++++++++++++++++++++++++++ userland/libs/boost/build | 1 + userland/libs/boost/test | 1 + 6 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 userland/libs/boost/bimap.cpp create mode 120000 userland/libs/boost/build create mode 120000 userland/libs/boost/test diff --git a/README.adoc b/README.adoc index 63eb272..f328abe 100644 --- a/README.adoc +++ b/README.adoc @@ -1074,7 +1074,7 @@ cd userland/c ./test .... -As mentioned at <>, tests under link:userland/libs[] require certain optional libraries to be installed, and are not built or tested by default. +As mentioned at <>, tests under link:userland/libs[] require certain optional libraries to be installed, and are not built or tested by default. You can install those libraries with: @@ -3737,10 +3737,10 @@ This script skips a manually configured list of tests, notably: * tests that depend on a full running kernel and cannot be run in user mode simulation, e.g. those that rely on kernel modules * tests that require user interaction -* tests that take perceptible ammounts of time +* tests that take perceptible amounts of time * known bugs we didn't have time to fix ;-) -Tests under link:userland/libs/[] depend on certain libraries being available on the target, e.g. <> for link:userland/libs/openblas[]. They are not run by default, but can be enabled with `--package` and `--package-all`. +Tests under link:userland/libs/[] are only run if `--package` or `--package-all` are given as described at <>. The gem5 tests require building statically with build id `static`, see also: xref:gem5-syscall-emulation-mode[xrefstyle=full]. TODO automate this better. @@ -14807,6 +14807,14 @@ TODO also consider the following: * http://www.cs.virginia.edu/stream/ref.html STREAM memory bandwidth benchmarks. * https://github.com/kozyraki/stamp transactional memory benchmarks +==== Boost + +https://en.wikipedia.org/wiki/Boost_(C%2B%2B_libraries) + +link:userland/libs/boost[] + +* link:userland/libs/boost/bimap.cpp[] + ==== Dhrystone https://en.wikipedia.org/wiki/Dhrystone @@ -15100,6 +15108,18 @@ Don't forget to explicitly rebuild PARSEC with: You may also want to test if your patches are still functionally correct inside of QEMU first, which is a faster emulator. * sell your soul, and compile natively inside the guest. We won't do this, not only because it is evil, but also because Buildroot explicitly does not support it: https://buildroot.org/downloads/manual/manual.html#faq-no-compiler-on-target ARM employees have been known to do this: https://github.com/arm-university/arm-gem5-rsk/blob/aa3b51b175a0f3b6e75c9c856092ae0c8f2a7cdc/parsec_patches/qemu-patch.diff +[[userland-libs-directory]] +==== userland/libs directory + +Tests under link:userland/libs[] require certain optional libraries to be installed on the target, and are not built or tested by default, you must enable them with either: + +.... +--package +--package-all +.... + +See for example <>. + === Userland content bibliography * The Linux Programming Interface by Michael Kerrisk https://www.amazon.co.uk/Linux-Programming-Interface-System-Handbook/dp/1593272200 Lots of open source POSIX examples: https://github.com/cirosantilli/linux-programming-interface-kerrisk diff --git a/build b/build index 12a3ff2..9338805 100755 --- a/build +++ b/build @@ -383,6 +383,7 @@ so looping over all of them would waste time. 'userland-host': _Component( self._build_file('build-userland-in-tree'), apt_get_pkgs={ + 'libboost-all-dev', 'libdrm-dev', 'libeigen3-dev', 'libopenblas-dev', diff --git a/common.py b/common.py index ab419ca..80728f5 100644 --- a/common.py +++ b/common.py @@ -1716,6 +1716,11 @@ https://cirosantilli.com/linux-kernel-module-cheat#gem5-debug-build else: eigen_root = self.env['buildroot_staging_dir'] packages = { + 'boost': { + # Header only, no pkg-config package. + 'cc_flags': [], + 'cc_flags_after': [], + }, 'eigen': { # TODO: was failing with: # fatal error: Eigen/Dense: No such file or directory as of diff --git a/userland/libs/boost/bimap.cpp b/userland/libs/boost/bimap.cpp new file mode 100644 index 0000000..f6ff4af --- /dev/null +++ b/userland/libs/boost/bimap.cpp @@ -0,0 +1,35 @@ +// https://cirosantilli.com/linux-kernel-module-cheat#boost +// +// Example adapted from: https://stackoverflow.com/questions/12174997/boostbimap-equivalent-of-bidirectional-multimap/12175238#12175238 + +#include + +#include +#include +#include + +namespace bimaps = boost::bimaps; + +int main() +{ + typedef boost::bimap, bimaps::set_of> bimap_t; + typedef bimap_t::value_type value_type; + bimap_t bimap; + bimap.insert(value_type(1, 1)); + bimap.insert(value_type(1, 2)); + bimap.insert(value_type(2, 2)); + auto& left = bimap.left; + auto it = left.find(1); + std::cout << "LEFT" << std::endl; + for (; it != left.end(); ++it) + { + std::cout << it->first << " " << it->second << std::endl; + } + auto& right = bimap.right; + auto r_it = right.find(2); + std::cout << "RIGHT" << std::endl; + for (; r_it != right.end(); ++r_it) + { + std::cout << r_it->first << " " << r_it->second << std::endl; + } +} diff --git a/userland/libs/boost/build b/userland/libs/boost/build new file mode 120000 index 0000000..ab18017 --- /dev/null +++ b/userland/libs/boost/build @@ -0,0 +1 @@ +../build \ No newline at end of file diff --git a/userland/libs/boost/test b/userland/libs/boost/test new file mode 120000 index 0000000..419df4f --- /dev/null +++ b/userland/libs/boost/test @@ -0,0 +1 @@ +../test \ No newline at end of file