--- /srv/reproducible-results/rbuild-debian/r-b-build.NX3Wnjgj/b1/dune-common_2.10.0-5_amd64.changes +++ /srv/reproducible-results/rbuild-debian/r-b-build.NX3Wnjgj/b2/dune-common_2.10.0-5_amd64.changes ├── Files │ @@ -1,4 +1,4 @@ │ │ acdd346b378f4bf47378b6aa3ff7a008 521884 debug optional libdune-common-dev-dbgsym_2.10.0-5_amd64.deb │ 62dea58fc4074c941853a74a81af43da 411720 libdevel optional libdune-common-dev_2.10.0-5_amd64.deb │ - b7af810a905b854a8448dd2eb5bfcf49 3176364 doc optional libdune-common-doc_2.10.0-5_all.deb │ + c40f6b3439678b516d623f5e124cb642 3178848 doc optional libdune-common-doc_2.10.0-5_all.deb ├── libdune-common-doc_2.10.0-5_all.deb │ ├── file list │ │ @@ -1,3 +1,3 @@ │ │ -rw-r--r-- 0 0 0 4 2025-09-15 05:59:28.000000 debian-binary │ │ --rw-r--r-- 0 0 0 28156 2025-09-15 05:59:28.000000 control.tar.xz │ │ --rw-r--r-- 0 0 0 3148016 2025-09-15 05:59:28.000000 data.tar.xz │ │ +-rw-r--r-- 0 0 0 28184 2025-09-15 05:59:28.000000 control.tar.xz │ │ +-rw-r--r-- 0 0 0 3150472 2025-09-15 05:59:28.000000 data.tar.xz │ ├── control.tar.xz │ │ ├── control.tar │ │ │ ├── ./control │ │ │ │ @@ -1,13 +1,13 @@ │ │ │ │ Package: libdune-common-doc │ │ │ │ Source: dune-common │ │ │ │ Version: 2.10.0-5 │ │ │ │ Architecture: all │ │ │ │ Maintainer: Debian Science Maintainers │ │ │ │ -Installed-Size: 23531 │ │ │ │ +Installed-Size: 23530 │ │ │ │ Depends: libjs-sphinxdoc (>= 8.2) │ │ │ │ Built-Using: doxygen (= 1.9.8+ds-2.1) │ │ │ │ Section: doc │ │ │ │ Priority: optional │ │ │ │ Multi-Arch: foreign │ │ │ │ Homepage: https://www.dune-project.org/ │ │ │ │ Description: toolbox for solving PDEs -- basic classes (documentation) │ │ │ ├── ./md5sums │ │ │ │ ├── ./md5sums │ │ │ │ │┄ Files differ │ │ │ │ ├── line order │ │ │ │ │ @@ -20,23 +20,22 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/changelog.gz │ │ │ │ │ usr/share/doc/libdune-common-doc/copyright │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00002.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00008.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00008_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00011.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00011_source.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00014.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00014_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00017.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00017_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00020.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00020_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00023.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00023_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00026.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00026_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00029.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00029_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00032.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00032_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00035.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00035_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00038.html │ │ │ │ │ @@ -50,14 +49,15 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00050.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00050_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00053.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00053_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00056.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00056_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00059.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00059_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00062.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00062_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00065.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00065_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00068.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00068_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00071.html │ │ │ │ │ @@ -69,21 +69,22 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00080.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00080_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00083.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00083_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00086.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00086_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00089.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00089_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00092.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00092_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00095.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00095_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00098.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00098_source.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00101.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00101_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00104.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00104_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00107.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00107_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00110.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00110_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00113.html │ │ │ │ │ @@ -107,22 +108,22 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00140.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00140_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00143.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00143_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00146.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00146_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00149.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00149_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00152.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00152_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00155.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00155_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00158.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00158_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00161.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00161_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00164.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00164_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00167.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00167_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00170.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00170_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00173.html │ │ │ │ │ @@ -130,65 +131,67 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00176.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00176_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00179.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00179_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00182.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00182_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00185.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00185_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00188.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00188_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00191.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00191_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00194.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00194_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00197.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00197_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00200.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00200_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00203.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00203_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00206.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00206_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00209.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00209_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00212.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00212_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00215.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00215_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00218.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00218_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00221.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00221_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00224.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00224_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00227.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00227_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00230.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00230_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00233.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00233_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00236.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00236_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00239.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00239_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00242.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00242_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00245.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00245_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00248.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00248_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00251.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00251_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00254.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00254_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00257.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00257_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00260.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00260_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00263.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00263_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00266.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00266_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00269.html │ │ │ │ │ +usr/share/doc/libdune-common-doc/doxygen/a00269_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00272.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00272_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00275.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00275_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00278.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00278_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00281.html │ │ │ │ │ @@ -217,15 +220,14 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00314_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00317.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00320.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00320_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00323.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00323_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00326.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00326_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00329.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00329_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00332.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00332_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00335.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00335_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00338.html │ │ │ │ │ @@ -253,15 +255,14 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00371.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00371_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00374.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00374_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00377.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00377_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00380.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00380_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00383.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00383_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00386.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00386_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00389.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00389_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00392.html │ │ │ │ │ @@ -269,15 +270,14 @@ │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00395.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00395_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00398.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00398_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00401.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00401_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00404.html │ │ │ │ │ -usr/share/doc/libdune-common-doc/doxygen/a00404_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00407.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00407_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00410.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00410_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00413.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00413_source.html │ │ │ │ │ usr/share/doc/libdune-common-doc/doxygen/a00416.html │ ├── data.tar.xz │ │ ├── data.tar │ │ │ ├── file list │ │ │ │ @@ -26,282 +26,282 @@ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 2825 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/buildsystem/html/search.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 11208 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/buildsystem/html/searchindex.js │ │ │ │ -rw-r--r-- 0 root (0) root (0) 2498 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/changelog.Debian.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 10768 2024-10-04 18:52:15.000000 ./usr/share/doc/libdune-common-doc/changelog.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 9815 2023-01-12 15:06:30.000000 ./usr/share/doc/libdune-common-doc/copyright │ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 3044 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00002.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5325 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00008.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 22981 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00008_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5346 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00011.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33491 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00011_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4393 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00014.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7511 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00014_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7355 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00017.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9907 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00017_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6818 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00020.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 100135 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00020_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7123 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00023.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 23204 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00023_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4978 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00026.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5766 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00029.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 16720 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00029_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5114 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00032.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9510 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00032_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5246 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00035.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9924 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00035_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7591 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00038.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 138694 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00038_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6031 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00041.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 51849 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00041_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6914 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00044.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 47730 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00044_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8504 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00047.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 45745 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00047_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 19994 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00050.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 180715 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00050_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13224 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00053.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 179116 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00053_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11466 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00056.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 291478 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00056_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 23464 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00059.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8765 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00062.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 72000 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00062_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9111 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00065.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 53122 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00065_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7456 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00068.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33695 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00068_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6490 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00071.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 34021 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00071_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3471 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00074.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10170 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00074_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11615 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00077.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 103142 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00077_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6676 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00080.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 58446 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00080_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3648 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00083.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4981 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00083_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6822 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00086.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 40313 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00086_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6611 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00089.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 19944 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00089_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5637 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00092.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33707 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00092_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3657 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00095.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4978 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00095_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9140 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00098.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 173678 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00098_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8730 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00104.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 61448 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00104_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5204 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00107.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 29990 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00107_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7264 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00110.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14137 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00110_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8195 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00113.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 144459 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00113_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13584 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00116.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 94213 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00116_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9498 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00119.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 250587 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00119_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5081 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00122.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7897 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00122_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6585 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00125.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 44036 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00125_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7344 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00128.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 18649 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00128_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 21360 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00131.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 122172 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00131_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5653 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00134.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7232 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00134_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11653 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00137.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 55283 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00137_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7720 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00140.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10467 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00140_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3371 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00143.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7706 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00143_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9720 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00146.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 240953 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00146_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3898 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00149.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14827 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00152.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 23435 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00152_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 21234 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00155.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 71204 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00155_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 24717 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00158.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 122775 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00158_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10744 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00161.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 109175 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00161_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8169 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00164.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 63827 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00164_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14004 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00167.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 86151 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00167_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3817 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00170.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6524 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00170_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5324 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00173.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10218 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00173_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3371 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00176.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 88030 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00176_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 24240 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00179.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 39035 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00179_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4654 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00182.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7264 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00182_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8438 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00185.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3383 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00188.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 51919 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00188_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6855 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00191.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 112076 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00191_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7782 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00194.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 12395 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00194_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8835 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00197.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10531 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00197_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5979 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00200.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 21113 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00200_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6383 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00203.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 16095 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00203_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4958 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00206.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6603 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00206_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5602 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00209.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9345 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00209_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7773 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00212.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 22676 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00212_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4365 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00215.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5135 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00215_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14994 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00218.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 142940 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00218_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9164 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00221.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8322 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00224.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 40739 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00224_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8833 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00227.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 15784 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00227_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5213 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00230.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 15231 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00230_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4309 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00233.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17896 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00233_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14429 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00236.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 51306 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00236_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6286 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00239.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 21544 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00239_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4910 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00242.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13604 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00245.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 28674 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00245_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8193 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00248.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 41652 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00248_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3948 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00251.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4992 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00254.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 31443 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00254_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4124 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00257.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6157 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00260.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 19958 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00260_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3365 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00263.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10369 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00263_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6186 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00266.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17740 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00266_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4127 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00269.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 26302 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00272.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 62033 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00272_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5604 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00275.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9237 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00275_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5274 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00278.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11329 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00278_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17901 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00281.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 167128 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00281_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6661 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00284.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 52850 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00284_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7918 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00287.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 127860 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00287_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17881 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00290.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 79928 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00290_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10468 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00293.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33173 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00293_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5059 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00296.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 23627 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00296_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5048 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00299.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 23174 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00299_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3473 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00302.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14821 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00302_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3471 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00305.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9186 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00305_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 20534 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00308.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 80039 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00308_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6555 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00311.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 18101 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00311_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 17515 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00314.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 45457 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00314_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6924 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00317.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5355 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00320.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 41537 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00320_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5042 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00323.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6949 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00323_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10990 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00326.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 22882 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00326_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5621 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00329.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7109 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00329_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6780 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00332.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8262 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00332_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 30299 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00335.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 192703 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00335_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4767 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00338.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14347 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00338_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 12793 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00341.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 124302 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00341_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5124 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00344.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 29705 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00344_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 22052 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00347.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 46229 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00347_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7493 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00350.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 31465 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00350_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6806 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00353.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 12869 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00353_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 60433 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00356.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 122588 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00356_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5660 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00359.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 39763 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00359_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13246 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00362.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 83988 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00362_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6400 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00365.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 151816 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00365_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13174 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00368.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 35626 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00368_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5881 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00371.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13121 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00371_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5662 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00374.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 50072 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00374_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 12424 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00377.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 91584 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00377_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5397 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00380.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14949 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00380_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5441 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00383.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9255 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00383_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6997 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00386.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 54427 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00386_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5664 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00389.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 39917 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00389_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6381 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00392.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 10393 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00392_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 4899 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00395.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13459 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00395_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 39912 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00398.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14840 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00398_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 8689 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00401.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 15574 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00401_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 16770 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00404.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 48541 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00404_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 9860 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00407.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 20795 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00407_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 81299 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00410.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 145525 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00410_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 13870 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00413.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 20197 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00413_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 33482 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00416.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 357624 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00416_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 24038 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00419.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 42062 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00419_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 6712 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00422.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 11002 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00422_source.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 7194 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00425.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 151467 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00425_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9860 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00008.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 20795 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00008_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13870 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00011.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 20197 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00011_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 24038 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00017.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 42062 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00017_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6712 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00020.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11002 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00020_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3817 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00023.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6524 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00023_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 81299 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00026.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 145525 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00026_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33482 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00029.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 357624 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00029_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14004 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00032.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 86151 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00032_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13604 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00035.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 28674 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00035_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5979 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00038.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 21113 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00038_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4992 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00041.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 31443 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00041_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6383 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00044.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 16095 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00044_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6555 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00047.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 18101 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00047_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5204 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00050.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 29990 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00050_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5324 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00053.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10218 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00053_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4958 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00056.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6603 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00056_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10468 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00059.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33173 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00059_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5274 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00062.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11329 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00062_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8835 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00065.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10531 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00065_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7355 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00068.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9907 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00068_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10744 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00071.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 109175 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00071_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 20534 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00074.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 80039 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00074_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5346 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00077.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33491 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00077_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 21360 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00080.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 122172 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00080_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8193 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00083.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 41652 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00083_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11653 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00086.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 55283 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00086_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8438 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00089.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 60433 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00092.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 122588 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00092_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5213 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00095.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 15231 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00095_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7918 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00098.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 127860 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00098_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3371 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00101.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 88030 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00101_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17881 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00104.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 79928 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00104_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9498 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00107.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 250587 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00107_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3365 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00110.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10369 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00110_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5246 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00113.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9924 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00113_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6818 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00116.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 100135 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00116_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13584 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00119.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 94213 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00119_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10990 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00122.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 22882 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00122_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14994 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00125.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 142940 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00125_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6855 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00128.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 112076 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00128_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6585 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00131.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 44036 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00131_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4767 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00134.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14347 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00134_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6286 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00137.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 21544 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00137_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3473 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00140.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14821 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00140_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3471 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00143.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9186 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00143_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5059 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00146.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 23627 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00146_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8195 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00149.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 144459 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00149_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14429 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00152.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 51306 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00152_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8833 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00155.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 15784 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00155_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6780 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00158.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8262 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00158_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3898 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00161.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17901 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00164.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 167128 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00164_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 39912 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00167.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14840 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00167_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5042 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00170.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6949 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00170_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4365 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00173.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5135 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00173_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6186 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00176.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17740 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00176_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7720 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00179.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10467 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00179_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 22052 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00182.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 46229 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00182_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3371 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00185.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7706 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00185_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5325 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00188.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 22981 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00188_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5766 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00191.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 16720 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00191_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5114 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00194.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9510 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00194_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4910 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00197.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4124 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00200.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4978 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00203.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5081 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00206.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7897 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00206_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7773 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00209.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 22676 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00209_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6806 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00212.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 12869 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00212_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3948 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00215.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5397 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00218.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14949 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00218_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5662 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00221.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 50072 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00221_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13246 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00224.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 83988 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00224_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6997 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00227.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 54427 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00227_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5881 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00230.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13121 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00230_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5660 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00233.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 39763 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00233_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13174 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00236.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 35626 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00236_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5664 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00239.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 39917 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00239_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5441 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00242.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9255 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00242_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 12424 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00245.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 91584 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00245_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6400 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00248.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 151816 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00248_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4899 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00251.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13459 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00251_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6381 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00254.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10393 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00254_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7782 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00257.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 12395 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00257_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5602 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00260.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9345 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00260_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4393 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00263.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7511 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00263_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 26302 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00266.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 62033 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00266_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 16770 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00269.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 48541 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00269_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 30299 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00272.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 192703 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00272_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8689 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00275.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 15574 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00275_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17515 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00278.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 45457 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00278_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7493 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00281.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 31465 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00281_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 12793 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00284.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 124302 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00284_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7264 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00287.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14137 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00287_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 24717 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00290.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 122775 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00290_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5653 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00293.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7232 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00293_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5355 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00296.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 41537 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00296_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4309 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00299.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 17896 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00299_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9720 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00302.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 240953 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00302_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8730 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00305.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 61448 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00305_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5048 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00308.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 23174 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00308_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 24240 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00311.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 39035 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00311_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4654 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00314.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7264 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00314_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4127 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00317.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6661 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00320.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 52850 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00320_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 21234 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00323.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 71204 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00323_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6924 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00326.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6157 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00329.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 19958 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00329_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5124 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00332.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 29705 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00332_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7194 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00335.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 151467 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00335_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5604 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00338.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9237 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00338_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6611 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00341.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 19944 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00341_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3657 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00344.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4978 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00344_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9111 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00347.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 53122 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00347_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3471 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00350.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 10170 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00350_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8765 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00353.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 72000 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00353_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11615 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00356.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 103142 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00356_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6914 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00359.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 47730 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00359_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6031 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00362.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 51849 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00362_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6490 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00365.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 34021 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00365_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7456 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00368.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33695 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00368_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 13224 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00371.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 179116 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00371_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5637 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00374.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 33707 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00374_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6676 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00377.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 58446 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00377_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 23464 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00380.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 11466 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00383.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 291478 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00383_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3648 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00386.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 4981 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00386_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9140 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00389.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 173678 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00389_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 19994 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00392.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 180715 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00392_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7591 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00395.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 138694 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00395_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 6822 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00398.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 40313 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00398_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8504 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00401.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 45745 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00401_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 9164 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00404.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8322 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00407.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 40739 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00407_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7344 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00410.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 18649 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00410_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3383 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00413.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 51919 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00413_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7123 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00416.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 23204 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00416_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 8169 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00419.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 63827 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00419_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14827 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00422.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 23435 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00422_source.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5621 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00425.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 7109 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00425_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5173 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00428.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 49335 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00428_source.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7896 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00431.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5292 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00432.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 262467 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00433.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 27946 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00433.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 39664 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/a00434.html │ │ │ │ @@ -1185,15 +1185,15 @@ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 2402 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_be46aaae597ce098e36afa8d6ef4f49b_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 4890 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_cf308425303dd5c426fac7b7f2967d96.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 1621 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_cf308425303dd5c426fac7b7f2967d96_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 49658 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_e151556194dc695299293609645e9437.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 11161 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_e151556194dc695299293609645e9437_dep.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 3668 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dir_e68e8157741866f444e17edd764ebbae.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 45631 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/doxygen.css │ │ │ │ --rw-r--r-- 0 root (0) root (0) 165920 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dune-common.tag.gz │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 165834 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dune-common.tag.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7704 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/dynsections.js │ │ │ │ -rw-r--r-- 0 root (0) root (0) 56072 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/files.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 1145 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/form_0.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 1167 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/form_0_dark.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 1153 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/form_1.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 403 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/form_10.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 422 2025-09-15 05:59:28.000000 ./usr/share/doc/libdune-common-doc/doxygen/form_10_dark.png │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00008.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: alignedallocator.hh File Reference │ │ │ │ +dune-common: io.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,44 +65,76 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
alignedallocator.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
│ │ │ │ │ │ │ │
│ │ │ │ -
#include "mallocallocator.hh"
│ │ │ │ -#include <cstdlib>
│ │ │ │ + │ │ │ │ +

IO interface of the SIMD abstraction. │ │ │ │ +More...

│ │ │ │ +
#include <ios>
│ │ │ │ #include <type_traits>
│ │ │ │ +#include <dune/common/rangeutilities.hh>
│ │ │ │ +#include <dune/common/simd/simd.hh>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::AlignedAllocator< T, Alignment >
 Allocators which guarantee alignment of the memory. More...
 
struct  Dune::AlignedAllocator< T, Alignment >::rebind< U >
class  Dune::SimdImpl::Inserter< T >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::SimdImpl
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

template<class V , class = std::enable_if_t<Simd::lanes<V>() != 1>>
Inserter< V > Dune::SimdImpl::io (const V &v)
 
template<class V , class = std::enable_if_t<Simd::lanes<V>() == 1>>
Simd::Scalar< V > Dune::SimdImpl::io (const V &v)
 
IO interface

Templates and functions in this group provide syntactic sugar for IO. They are implemented using the functionality from SimdInterfaceBase, and are not customizable by implementations.

│ │ │ │ +
template<class V >
auto Dune::Simd::vio (const V &v)
 construct a stream inserter
 
template<class V >
auto Dune::Simd::io (const V &v)
 construct a stream inserter
 
│ │ │ │ -
│ │ │ │ +

Detailed Description

│ │ │ │ +

IO interface of the SIMD abstraction.

│ │ │ │ +

This file provides IO interface functions of the SIMD abstraction layer.

│ │ │ │ +

This file is intended for direct inclusion by header making use of the IO interface.

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,24 +1,56 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -alignedallocator.hh File Reference │ │ │ │ │ -#include "mallocallocator.hh" │ │ │ │ │ -#include │ │ │ │ │ + * simd │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +io.hh File Reference │ │ │ │ │ +Common » Vectorization » Library_Developer's_Interface │ │ │ │ │ +IO interface of the SIMD abstraction. More... │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ - class   Dune::AlignedAllocator<_T,_Alignment_> │ │ │ │ │ -  Allocators which guarantee alignment of the memory. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::AlignedAllocator<_T,_Alignment_>::rebind<_U_> │ │ │ │ │ +class   Dune::SimdImpl::Inserter<_T_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ +namespace   Dune::SimdImpl │ │ │ │ │ +  │ │ │ │ │ +namespace   Dune::Simd │ │ │ │ │ +  Namespace for vectorization interface functions used by library │ │ │ │ │ + developers. │ │ │ │ │ +  │ │ │ │ │ +Functions │ │ │ │ │ +template() != 1>> │ │ │ │ │ + Inserter< V >  Dune::SimdImpl::io (const V &v) │ │ │ │ │ +  │ │ │ │ │ +template() == 1>> │ │ │ │ │ +Simd::Scalar< V >  Dune::SimdImpl::io (const V &v) │ │ │ │ │ +  │ │ │ │ │ +IO interface │ │ │ │ │ +Templates and functions in this group provide syntactic sugar for IO. They are │ │ │ │ │ +implemented using the functionality from SimdInterfaceBase, and are not │ │ │ │ │ +customizable by implementations. │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::vio (const V &v) │ │ │ │ │ +  construct a stream inserter │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::io (const V &v) │ │ │ │ │ +  construct a stream inserter │ │ │ │ │ +  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +IO interface of the SIMD abstraction. │ │ │ │ │ +This file provides IO interface functions of the SIMD abstraction layer. │ │ │ │ │ +This file is intended for direct inclusion by header making use of the IO │ │ │ │ │ +interface. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00008_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: alignedallocator.hh Source File │ │ │ │ +dune-common: io.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,127 +70,125 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
alignedallocator.hh
│ │ │ │ +
io.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ -
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ -
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_ALIGNED_ALLOCATOR_HH
│ │ │ │ -
6#define DUNE_ALIGNED_ALLOCATOR_HH
│ │ │ │ -
7
│ │ │ │ -
8#include "mallocallocator.hh"
│ │ │ │ -
9#include <cstdlib>
│ │ │ │ -
10#include <type_traits>
│ │ │ │ -
11
│ │ │ │ -
│ │ │ │ -
12namespace Dune
│ │ │ │ -
13{
│ │ │ │ -
14
│ │ │ │ -
22 template<class T, int Alignment = -1>
│ │ │ │ -
│ │ │ │ - │ │ │ │ +Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
3#ifndef DUNE_COMMON_SIMD_IO_HH
│ │ │ │ +
4#define DUNE_COMMON_SIMD_IO_HH
│ │ │ │ +
5
│ │ │ │ +
16#include <ios>
│ │ │ │ +
17#include <type_traits>
│ │ │ │ +
18
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
22
│ │ │ │ +
23namespace Dune {
│ │ │ │
24
│ │ │ │ -
25#if __APPLE__
│ │ │ │ +
│ │ │ │ +
25 namespace SimdImpl {
│ │ │ │
26
│ │ │ │ -
27 /*
│ │ │ │ -
28 * macOS has pretty draconian restrictions on the
│ │ │ │ -
29 * alignments that you may ask for: It has to be
│ │ │ │ -
30 *
│ │ │ │ -
31 * 1) a power of 2
│ │ │ │ -
32 * 2) at least as large as sizeof(void*)
│ │ │ │ -
33 *
│ │ │ │ -
34 * So here is a little constexpr function that calculates just that
│ │ │ │ -
35 * (together with the correct starting value for align fed in further down).
│ │ │ │ -
36 */
│ │ │ │ -
37 static constexpr int fixAlignment(int align)
│ │ │ │ -
38 {
│ │ │ │ -
39 return ((Alignment==-1) ? std::alignment_of<T>::value : Alignment) > align
│ │ │ │ -
40 ? fixAlignment(align << 1) : align;
│ │ │ │ -
41 }
│ │ │ │ -
42
│ │ │ │ -
43#else
│ │ │ │ -
44
│ │ │ │ -
45 /*
│ │ │ │ -
46 * Non-Apple platforms we just have to check whether an explicit alignment was
│ │ │ │ -
47 * restricted or fall back to the default alignment of T.
│ │ │ │ -
48 */
│ │ │ │ -
49 static constexpr int fixAlignment(int align)
│ │ │ │ -
50 {
│ │ │ │ -
51 return (Alignment==-1) ? std::alignment_of<T>::value : Alignment;
│ │ │ │ -
52 }
│ │ │ │ -
53
│ │ │ │ -
54#endif
│ │ │ │ +
27 template<class T>
│ │ │ │ +
│ │ │ │ +
28 class Inserter {
│ │ │ │ +
29 T value_;
│ │ │ │ +
30
│ │ │ │ +
31 public:
│ │ │ │ +
32 Inserter(const T &value) : value_(value) {}
│ │ │ │ +
33
│ │ │ │ +
34 template<class Stream,
│ │ │ │ +
35 class = std::enable_if_t<std::is_base_of<std::ios_base,
│ │ │ │ +
36 Stream>::value> >
│ │ │ │ +
│ │ │ │ +
37 friend Stream& operator<<(Stream &out, const Inserter &ins)
│ │ │ │ +
38 {
│ │ │ │ +
39 const char *sep = "<";
│ │ │ │ +
40 for(auto l : range(Simd::lanes(ins.value_)))
│ │ │ │ +
41 {
│ │ │ │ +
42 out << sep << autoCopy(Simd::lane(l, ins.value_));
│ │ │ │ +
43 sep = ", ";
│ │ │ │ +
44 }
│ │ │ │ +
45 out << '>';
│ │ │ │ +
46 return out;
│ │ │ │ +
47 }
│ │ │ │ +
│ │ │ │ +
48 };
│ │ │ │ +
│ │ │ │ +
49
│ │ │ │ +
50 template<class V, class = std::enable_if_t<Simd::lanes<V>() != 1> >
│ │ │ │ +
│ │ │ │ +
51 Inserter<V> io(const V &v)
│ │ │ │ +
52 {
│ │ │ │ +
53 return { v };
│ │ │ │ +
54 }
│ │ │ │ +
│ │ │ │
55
│ │ │ │ -
56 public:
│ │ │ │ - │ │ │ │ - │ │ │ │ -
│ │ │ │ -
59 template <class U> struct rebind {
│ │ │ │ - │ │ │ │ -
61 };
│ │ │ │ -
│ │ │ │ -
62
│ │ │ │ -
63 static constexpr int alignment = fixAlignment(sizeof(void*));
│ │ │ │ -
64
│ │ │ │ -
│ │ │ │ -
66 pointer allocate(size_type n, [[maybe_unused]] const void* hint = 0)
│ │ │ │ -
67 {
│ │ │ │ -
68 if (n > this->max_size())
│ │ │ │ -
69 throw std::bad_alloc();
│ │ │ │ -
70
│ │ │ │ -
71#if __APPLE__
│ │ │ │ -
72 // Apple is also restrictive regarding the allocation size.
│ │ │ │ -
73 // size must be at least the alignment size.
│ │ │ │ -
74 size_type size = n * sizeof(T) >= alignment ? n * sizeof(T) : alignment;
│ │ │ │ -
75#else
│ │ │ │ -
76 size_type size = n * sizeof(T);
│ │ │ │ -
77#endif
│ │ │ │ -
78
│ │ │ │ -
79 /*
│ │ │ │ -
80 * Everybody else gets the standard treatment.
│ │ │ │ -
81 */
│ │ │ │ -
82 pointer ret = static_cast<pointer>(std::aligned_alloc(alignment, size));
│ │ │ │ -
83 if (!ret)
│ │ │ │ -
84 throw std::bad_alloc();
│ │ │ │ -
85
│ │ │ │ -
86 return ret;
│ │ │ │ -
87 }
│ │ │ │ -
│ │ │ │ -
88 };
│ │ │ │ -
│ │ │ │ -
89
│ │ │ │ -
90}
│ │ │ │ -
│ │ │ │ -
91
│ │ │ │ -
92#endif // DUNE_ALIGNED_ALLOCATOR_HH
│ │ │ │ -
Allocators that use malloc/free.
│ │ │ │ +
56 template<class V, class = std::enable_if_t<Simd::lanes<V>() == 1> >
│ │ │ │ +
│ │ │ │ +
57 Simd::Scalar<V> io(const V &v)
│ │ │ │ +
58 {
│ │ │ │ +
59 return Simd::lane(0, v);
│ │ │ │ +
60 }
│ │ │ │ +
│ │ │ │ +
61
│ │ │ │ +
62 }
│ │ │ │ +
│ │ │ │ +
63
│ │ │ │ +
64 namespace Simd {
│ │ │ │ +
65
│ │ │ │ +
82
│ │ │ │ +
89 template<class V>
│ │ │ │ +
│ │ │ │ +
90 auto vio(const V &v)
│ │ │ │ +
91 {
│ │ │ │ +
92 return SimdImpl::Inserter<V>{ v };
│ │ │ │ +
93 }
│ │ │ │ +
│ │ │ │ +
94
│ │ │ │ +
96
│ │ │ │ +
105 template<class V>
│ │ │ │ +
│ │ │ │ +
106 auto io(const V &v)
│ │ │ │ +
107 {
│ │ │ │ +
108 return SimdImpl::io(v);
│ │ │ │ +
109 }
│ │ │ │ +
│ │ │ │ +
110
│ │ │ │ +
112
│ │ │ │ +
114
│ │ │ │ +
115 } // namespace Simd
│ │ │ │ +
116} // namespace Dune
│ │ │ │ +
117
│ │ │ │ +
118#endif // DUNE_COMMON_SIMD_IO_HH
│ │ │ │ +
Utilities for reduction like operations on ranges.
│ │ │ │ +
Traits for type conversions and type information.
│ │ │ │ +
static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
Definition rangeutilities.hh:312
│ │ │ │ +
constexpr AutonomousValue< T > autoCopy(T &&v)
Autonomous copy of an expression's value for use in auto type deduction.
Definition typetraits.hh:672
│ │ │ │ +
auto io(const V &v)
construct a stream inserter
Definition io.hh:106
│ │ │ │ +
auto vio(const V &v)
construct a stream inserter
Definition io.hh:90
│ │ │ │ +
constexpr std::size_t lanes()
Number of lanes in a SIMD type.
Definition simd/interface.hh:305
│ │ │ │ +
decltype(auto) lane(std::size_t l, V &&v)
Extract an element of a SIMD type.
Definition simd/interface.hh:324
│ │ │ │ +
typename Overloads::ScalarType< std::decay_t< V > >::type Scalar
Element type of some SIMD type.
Definition simd/interface.hh:235
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition integersequence.hh:75
│ │ │ │ -
Allocators which guarantee alignment of the memory.
Definition alignedallocator.hh:23
│ │ │ │ -
typename MallocAllocator< T >::size_type size_type
Definition alignedallocator.hh:58
│ │ │ │ -
pointer allocate(size_type n, const void *hint=0)
allocate n objects of type T
Definition alignedallocator.hh:66
│ │ │ │ -
typename MallocAllocator< T >::pointer pointer
Definition alignedallocator.hh:57
│ │ │ │ -
static constexpr int alignment
Definition alignedallocator.hh:63
│ │ │ │ -
Definition alignedallocator.hh:59
│ │ │ │ -
AlignedAllocator< U, Alignment > other
Definition alignedallocator.hh:60
│ │ │ │ -
Allocators implementation which simply calls malloc/free.
Definition mallocallocator.hh:24
│ │ │ │ -
T * pointer
Definition mallocallocator.hh:28
│ │ │ │ -
std::size_t size_type
Definition mallocallocator.hh:26
│ │ │ │ -
size_type max_size() const noexcept
max size for allocate
Definition mallocallocator.hh:74
│ │ │ │ +
Inserter< V > io(const V &v)
Definition io.hh:51
│ │ │ │ +
Definition io.hh:28
│ │ │ │ +
Inserter(const T &value)
Definition io.hh:32
│ │ │ │ +
friend Stream & operator<<(Stream &out, const Inserter &ins)
Definition io.hh:37
│ │ │ │ +
Include file for users of the SIMD abstraction layer.
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,140 +1,135 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -alignedallocator.hh │ │ │ │ │ + * simd │ │ │ │ │ +io.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ -2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ -3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_ALIGNED_ALLOCATOR_HH │ │ │ │ │ -6#define DUNE_ALIGNED_ALLOCATOR_HH │ │ │ │ │ -7 │ │ │ │ │ -8#include "mallocallocator.hh" │ │ │ │ │ -9#include │ │ │ │ │ -10#include │ │ │ │ │ -11 │ │ │ │ │ -12namespace Dune │ │ │ │ │ -13{ │ │ │ │ │ -14 │ │ │ │ │ -22 template │ │ │ │ │ -23 class AlignedAllocator : public MallocAllocator { │ │ │ │ │ +2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +3#ifndef DUNE_COMMON_SIMD_IO_HH │ │ │ │ │ +4#define DUNE_COMMON_SIMD_IO_HH │ │ │ │ │ +5 │ │ │ │ │ +16#include │ │ │ │ │ +17#include │ │ │ │ │ +18 │ │ │ │ │ +19#include │ │ │ │ │ +20#include │ │ │ │ │ +21#include │ │ │ │ │ +22 │ │ │ │ │ +23namespace Dune { │ │ │ │ │ 24 │ │ │ │ │ -25#if __APPLE__ │ │ │ │ │ +25 namespace SimdImpl { │ │ │ │ │ 26 │ │ │ │ │ -27 /* │ │ │ │ │ -28 * macOS has pretty draconian restrictions on the │ │ │ │ │ -29 * alignments that you may ask for: It has to be │ │ │ │ │ -30 * │ │ │ │ │ -31 * 1) a power of 2 │ │ │ │ │ -32 * 2) at least as large as sizeof(void*) │ │ │ │ │ -33 * │ │ │ │ │ -34 * So here is a little constexpr function that calculates just that │ │ │ │ │ -35 * (together with the correct starting value for align fed in further down). │ │ │ │ │ -36 */ │ │ │ │ │ -37 static constexpr int fixAlignment(int align) │ │ │ │ │ +27 template │ │ │ │ │ +28 class Inserter { │ │ │ │ │ +29 T value_; │ │ │ │ │ +30 │ │ │ │ │ +31 public: │ │ │ │ │ +32 Inserter(const T &value) : value_(value) {} │ │ │ │ │ +33 │ │ │ │ │ +34 template::value> > │ │ │ │ │ +37 friend Stream& operator<<(Stream &out, const Inserter &ins) │ │ │ │ │ 38 { │ │ │ │ │ -39 return ((Alignment==-1) ? std::alignment_of::value : Alignment) > align │ │ │ │ │ -40 ? fixAlignment(align << 1) : align; │ │ │ │ │ -41 } │ │ │ │ │ -42 │ │ │ │ │ -43#else │ │ │ │ │ -44 │ │ │ │ │ -45 /* │ │ │ │ │ -46 * Non-Apple platforms we just have to check whether an explicit alignment │ │ │ │ │ -was │ │ │ │ │ -47 * restricted or fall back to the default alignment of T. │ │ │ │ │ -48 */ │ │ │ │ │ -49 static constexpr int fixAlignment(int align) │ │ │ │ │ -50 { │ │ │ │ │ -51 return (Alignment==-1) ? std::alignment_of::value : Alignment; │ │ │ │ │ -52 } │ │ │ │ │ -53 │ │ │ │ │ -54#endif │ │ │ │ │ +39 const char *sep = "<"; │ │ │ │ │ +40 for(auto l : range(Simd::lanes(ins.value_))) │ │ │ │ │ +41 { │ │ │ │ │ +42 out << sep << autoCopy(Simd::lane(l, ins.value_)); │ │ │ │ │ +43 sep = ", "; │ │ │ │ │ +44 } │ │ │ │ │ +45 out << '>'; │ │ │ │ │ +46 return out; │ │ │ │ │ +47 } │ │ │ │ │ +48 }; │ │ │ │ │ +49 │ │ │ │ │ +50 template() != 1> > │ │ │ │ │ +51 Inserter io(const V &v) │ │ │ │ │ +52 { │ │ │ │ │ +53 return { v }; │ │ │ │ │ +54 } │ │ │ │ │ 55 │ │ │ │ │ -56 public: │ │ │ │ │ -57 using pointer = typename MallocAllocator::pointer; │ │ │ │ │ -58 using size_type = typename MallocAllocator::size_type; │ │ │ │ │ -59 template struct rebind { │ │ │ │ │ -60 typedef AlignedAllocator other; │ │ │ │ │ -61 }; │ │ │ │ │ -62 │ │ │ │ │ -63 static constexpr int alignment = fixAlignment(sizeof(void*)); │ │ │ │ │ -64 │ │ │ │ │ -66 pointer allocate(size_type n, [[maybe_unused]] const void* hint = 0) │ │ │ │ │ -67 { │ │ │ │ │ -68 if (n > this->max_size()) │ │ │ │ │ -69 throw std::bad_alloc(); │ │ │ │ │ -70 │ │ │ │ │ -71#if __APPLE__ │ │ │ │ │ -72 // Apple is also restrictive regarding the allocation size. │ │ │ │ │ -73 // size must be at least the alignment size. │ │ │ │ │ -74 size_type size = n * sizeof(T) >= alignment ? n * sizeof(T) : alignment; │ │ │ │ │ -75#else │ │ │ │ │ -76 size_type size = n * sizeof(T); │ │ │ │ │ -77#endif │ │ │ │ │ -78 │ │ │ │ │ -79 /* │ │ │ │ │ -80 * Everybody else gets the standard treatment. │ │ │ │ │ -81 */ │ │ │ │ │ -82 pointer ret = static_cast(std::aligned_alloc(alignment, size)); │ │ │ │ │ -83 if (!ret) │ │ │ │ │ -84 throw std::bad_alloc(); │ │ │ │ │ -85 │ │ │ │ │ -86 return ret; │ │ │ │ │ -87 } │ │ │ │ │ -88 }; │ │ │ │ │ -89 │ │ │ │ │ -90} │ │ │ │ │ -91 │ │ │ │ │ -92#endif // DUNE_ALIGNED_ALLOCATOR_HH │ │ │ │ │ -mallocallocator.hh │ │ │ │ │ -Allocators that use malloc/free. │ │ │ │ │ +56 template() == 1> > │ │ │ │ │ +57 Simd::Scalar io(const V &v) │ │ │ │ │ +58 { │ │ │ │ │ +59 return Simd::lane(0, v); │ │ │ │ │ +60 } │ │ │ │ │ +61 │ │ │ │ │ +62 } │ │ │ │ │ +63 │ │ │ │ │ +64 namespace Simd { │ │ │ │ │ +65 │ │ │ │ │ +82 │ │ │ │ │ +89 template │ │ │ │ │ +90 auto vio(const V &v) │ │ │ │ │ +91 { │ │ │ │ │ +92 return SimdImpl::Inserter{ v }; │ │ │ │ │ +93 } │ │ │ │ │ +94 │ │ │ │ │ +96 │ │ │ │ │ +105 template │ │ │ │ │ +106 auto io(const V &v) │ │ │ │ │ +107 { │ │ │ │ │ +108 return SimdImpl::io(v); │ │ │ │ │ +109 } │ │ │ │ │ +110 │ │ │ │ │ +112 │ │ │ │ │ +114 │ │ │ │ │ +115 } // namespace Simd │ │ │ │ │ +116} // namespace Dune │ │ │ │ │ +117 │ │ │ │ │ +118#endif // DUNE_COMMON_SIMD_IO_HH │ │ │ │ │ +rangeutilities.hh │ │ │ │ │ +Utilities for reduction like operations on ranges. │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +Dune::range │ │ │ │ │ +static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ +>, std::integral_constant< T, to >) noexcept │ │ │ │ │ +Definition rangeutilities.hh:312 │ │ │ │ │ +Dune::autoCopy │ │ │ │ │ +constexpr AutonomousValue< T > autoCopy(T &&v) │ │ │ │ │ +Autonomous copy of an expression's value for use in auto type deduction. │ │ │ │ │ +Definition typetraits.hh:672 │ │ │ │ │ +Dune::Simd::io │ │ │ │ │ +auto io(const V &v) │ │ │ │ │ +construct a stream inserter │ │ │ │ │ +Definition io.hh:106 │ │ │ │ │ +Dune::Simd::vio │ │ │ │ │ +auto vio(const V &v) │ │ │ │ │ +construct a stream inserter │ │ │ │ │ +Definition io.hh:90 │ │ │ │ │ +Dune::Simd::lanes │ │ │ │ │ +constexpr std::size_t lanes() │ │ │ │ │ +Number of lanes in a SIMD type. │ │ │ │ │ +Definition simd/interface.hh:305 │ │ │ │ │ +Dune::Simd::lane │ │ │ │ │ +decltype(auto) lane(std::size_t l, V &&v) │ │ │ │ │ +Extract an element of a SIMD type. │ │ │ │ │ +Definition simd/interface.hh:324 │ │ │ │ │ +Dune::Simd::Scalar │ │ │ │ │ +typename Overloads::ScalarType< std::decay_t< V > >::type Scalar │ │ │ │ │ +Element type of some SIMD type. │ │ │ │ │ +Definition simd/interface.hh:235 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::size │ │ │ │ │ -constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std:: │ │ │ │ │ -integer_sequence< T, II... >) │ │ │ │ │ -Return the size of the sequence. │ │ │ │ │ -Definition integersequence.hh:75 │ │ │ │ │ -Dune::AlignedAllocator │ │ │ │ │ -Allocators which guarantee alignment of the memory. │ │ │ │ │ -Definition alignedallocator.hh:23 │ │ │ │ │ -Dune::AlignedAllocator::size_type │ │ │ │ │ -typename MallocAllocator< T >::size_type size_type │ │ │ │ │ -Definition alignedallocator.hh:58 │ │ │ │ │ -Dune::AlignedAllocator::allocate │ │ │ │ │ -pointer allocate(size_type n, const void *hint=0) │ │ │ │ │ -allocate n objects of type T │ │ │ │ │ -Definition alignedallocator.hh:66 │ │ │ │ │ -Dune::AlignedAllocator::pointer │ │ │ │ │ -typename MallocAllocator< T >::pointer pointer │ │ │ │ │ -Definition alignedallocator.hh:57 │ │ │ │ │ -Dune::AlignedAllocator::alignment │ │ │ │ │ -static constexpr int alignment │ │ │ │ │ -Definition alignedallocator.hh:63 │ │ │ │ │ -Dune::AlignedAllocator::rebind │ │ │ │ │ -Definition alignedallocator.hh:59 │ │ │ │ │ -Dune::AlignedAllocator::rebind::other │ │ │ │ │ -AlignedAllocator< U, Alignment > other │ │ │ │ │ -Definition alignedallocator.hh:60 │ │ │ │ │ -Dune::MallocAllocator │ │ │ │ │ -Allocators implementation which simply calls malloc/free. │ │ │ │ │ -Definition mallocallocator.hh:24 │ │ │ │ │ -Dune::MallocAllocator::pointer │ │ │ │ │ -T * pointer │ │ │ │ │ -Definition mallocallocator.hh:28 │ │ │ │ │ -Dune::MallocAllocator::size_type │ │ │ │ │ -std::size_t size_type │ │ │ │ │ -Definition mallocallocator.hh:26 │ │ │ │ │ -Dune::MallocAllocator::max_size │ │ │ │ │ -size_type max_size() const noexcept │ │ │ │ │ -max size for allocate │ │ │ │ │ -Definition mallocallocator.hh:74 │ │ │ │ │ +Dune::SimdImpl::io │ │ │ │ │ +Inserter< V > io(const V &v) │ │ │ │ │ +Definition io.hh:51 │ │ │ │ │ +Dune::SimdImpl::Inserter │ │ │ │ │ +Definition io.hh:28 │ │ │ │ │ +Dune::SimdImpl::Inserter::Inserter │ │ │ │ │ +Inserter(const T &value) │ │ │ │ │ +Definition io.hh:32 │ │ │ │ │ +Dune::SimdImpl::Inserter::operator<< │ │ │ │ │ +friend Stream & operator<<(Stream &out, const Inserter &ins) │ │ │ │ │ +Definition io.hh:37 │ │ │ │ │ +simd.hh │ │ │ │ │ +Include file for users of the SIMD abstraction layer. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00011.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: scalarmatrixview.hh File Reference │ │ │ │ +dune-common: standard.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,46 +65,86 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ +Classes | │ │ │ │ Namespaces
│ │ │ │ -
scalarmatrixview.hh File Reference
│ │ │ │ + │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

Implements a scalar matrix view wrapper around an existing scalar. │ │ │ │ +

SIMD abstractions for the standard built-in types. │ │ │ │ More...

│ │ │ │
#include <cstddef>
│ │ │ │ #include <type_traits>
│ │ │ │ -#include <ostream>
│ │ │ │ -#include <dune/common/boundschecking.hh>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ -#include <dune/common/matvectraits.hh>
│ │ │ │ -#include <dune/common/densematrix.hh>
│ │ │ │ -#include <dune/common/fmatrix.hh>
│ │ │ │ -#include <dune/common/scalarvectorview.hh>
│ │ │ │ +#include <utility>
│ │ │ │ +#include <dune/common/indices.hh>
│ │ │ │ +#include <dune/common/simd/base.hh>
│ │ │ │ +#include <dune/common/simd/defaults.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

struct  Dune::Simd::Overloads::ScalarType< V, class >
 should have a member type type More...
 
struct  Dune::Simd::Overloads::RebindType< S, class, class >
 should have a member type type More...
 
struct  Dune::Simd::Overloads::LaneCount< class, class >
 should be derived from a Dune::index_constant More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
 
namespace  Dune::Simd::Overloads
 Namespace for the overloads and specializations that make up a SIMD implementation.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

Specialized classes and overloaded functions
template<class V >
Dune::Simd::Overloads::lane (ADLTag< 2 >, std::size_t, V v)
 implements Simd::lane()
 
template<class V >
V & Dune::Simd::Overloads::lane (ADLTag< 3 >, std::size_t, V &v)
 
bool Dune::Simd::Overloads::anyTrue (ADLTag< 2 >, bool mask)
 implements Simd::anyTrue()
 
bool Dune::Simd::Overloads::allTrue (ADLTag< 2 >, bool mask)
 implements Simd::allTrue()
 
bool Dune::Simd::Overloads::anyFalse (ADLTag< 2 >, bool mask)
 implements Simd::anyFalse()
 
bool Dune::Simd::Overloads::allFalse (ADLTag< 2 >, bool mask)
 implements Simd::allFalse()
 
│ │ │ │

Detailed Description

│ │ │ │ -

Implements a scalar matrix view wrapper around an existing scalar.

│ │ │ │ +

SIMD abstractions for the standard built-in types.

│ │ │ │ +

This file should not normally be included by users of the SIMD abstraction (i.e. other Dune headers). Neither should it be included by the translation units passing built-in types to Dune headers that in turn support SIMD types through the SIMD abstraction. Dune-functionality always supports built-in types. Either because that functionality does not support SIMD types and so only supports built-in types, or if it does support SIMD types it must include <dune/common/simd/simd.hh>, which in turn includes this header.

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,28 +1,73 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces │ │ │ │ │ -scalarmatrixview.hh File Reference │ │ │ │ │ -Common » Dense_Matrix_and_Vector_Template_Library │ │ │ │ │ -Implements a scalar matrix view wrapper around an existing scalar. More... │ │ │ │ │ + * simd │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +standard.hh File Reference │ │ │ │ │ +Common » Vectorization » Application_Developer's_Interface » SIMD_Abstraction │ │ │ │ │ +Implementation_for_standard_types │ │ │ │ │ +SIMD abstractions for the standard built-in types. More... │ │ │ │ │ #include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ +Classes │ │ │ │ │ +struct   Dune::Simd::Overloads::ScalarType<_V,_class_> │ │ │ │ │ +  should have a member type type More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::Simd::Overloads::RebindType<_S,_class,_class_> │ │ │ │ │ +  should have a member type type More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::Simd::Overloads::LaneCount<_class,_class_> │ │ │ │ │ +  should be derived from a Dune::index_constant More... │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ +namespace   Dune::Simd │ │ │ │ │ +  Namespace for vectorization interface functions used by library │ │ │ │ │ + developers. │ │ │ │ │ +  │ │ │ │ │ +namespace   Dune::Simd::Overloads │ │ │ │ │ +  Namespace for the overloads and specializations that make up a SIMD │ │ │ │ │ + implementation. │ │ │ │ │ +  │ │ │ │ │ +Functions │ │ │ │ │ +Specialized classes and overloaded functions │ │ │ │ │ +template │ │ │ │ │ + V  Dune::Simd::Overloads::lane (ADLTag< 2 >, std::size_t, V v) │ │ │ │ │ +  implements Simd::lane() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + V &  Dune::Simd::Overloads::lane (ADLTag< 3 >, std::size_t, V &v) │ │ │ │ │ +  │ │ │ │ │ +bool  Dune::Simd::Overloads::anyTrue (ADLTag< 2 >, bool mask) │ │ │ │ │ +  implements Simd::anyTrue() │ │ │ │ │ +  │ │ │ │ │ +bool  Dune::Simd::Overloads::allTrue (ADLTag< 2 >, bool mask) │ │ │ │ │ +  implements Simd::allTrue() │ │ │ │ │ +  │ │ │ │ │ +bool  Dune::Simd::Overloads::anyFalse (ADLTag< 2 >, bool mask) │ │ │ │ │ +  implements Simd::anyFalse() │ │ │ │ │ +  │ │ │ │ │ +bool  Dune::Simd::Overloads::allFalse (ADLTag< 2 >, bool mask) │ │ │ │ │ +  implements Simd::allFalse() │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Implements a scalar matrix view wrapper around an existing scalar. │ │ │ │ │ +SIMD abstractions for the standard built-in types. │ │ │ │ │ +This file should not normally be included by users of the SIMD abstraction │ │ │ │ │ +(i.e. other Dune headers). Neither should it be included by the translation │ │ │ │ │ +units passing built-in types to Dune headers that in turn support SIMD types │ │ │ │ │ +through the SIMD abstraction. Dune-functionality always supports built-in │ │ │ │ │ +types. Either because that functionality does not support SIMD types and so │ │ │ │ │ +only supports built-in types, or if it does support SIMD types it must include │ │ │ │ │ +, which in turn includes this header. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00011_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: scalarmatrixview.hh Source File │ │ │ │ +dune-common: standard.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,202 +70,102 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
scalarmatrixview.hh
│ │ │ │ +
standard.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ -
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ -
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_SCALARMATRIXVIEW_HH
│ │ │ │ -
6#define DUNE_COMMON_SCALARMATRIXVIEW_HH
│ │ │ │ -
7
│ │ │ │ -
8#include <cstddef>
│ │ │ │ -
9#include <type_traits>
│ │ │ │ -
10#include <ostream>
│ │ │ │ -
11
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
18
│ │ │ │ -
19
│ │ │ │ -
20namespace Dune {
│ │ │ │ -
21
│ │ │ │ -
22namespace Impl {
│ │ │ │ +Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
3#ifndef DUNE_COMMON_SIMD_STANDARD_HH
│ │ │ │ +
4#define DUNE_COMMON_SIMD_STANDARD_HH
│ │ │ │ +
5
│ │ │ │ +
20#include <cstddef>
│ │ │ │ +
21#include <type_traits>
│ │ │ │ +
22#include <utility>
│ │ │ │
23
│ │ │ │ -
39 template<class K>
│ │ │ │ -
40 class ScalarMatrixView :
│ │ │ │ -
41 public DenseMatrix<ScalarMatrixView<K>>
│ │ │ │ -
42 {
│ │ │ │ -
43 ScalarVectorView<K> data_;
│ │ │ │ -
44 using Base = DenseMatrix<ScalarMatrixView<K>>;
│ │ │ │ -
45
│ │ │ │ -
46 template <class>
│ │ │ │ -
47 friend class ScalarMatrixView;
│ │ │ │ -
48 public:
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
27
│ │ │ │ +
45namespace Dune {
│ │ │ │ +
46 namespace Simd {
│ │ │ │ +
47
│ │ │ │ +
48 namespace Overloads {
│ │ │ │
49
│ │ │ │ -
50 //===== type definitions and constants
│ │ │ │ -
51
│ │ │ │ -
54 constexpr static int blocklevel = 1;
│ │ │ │ -
55
│ │ │ │ -
56 using size_type = typename Base::size_type;
│ │ │ │ -
57 using row_type = typename Base::row_type;
│ │ │ │ -
58 using row_reference = typename Base::row_reference;
│ │ │ │ - │ │ │ │ -
60
│ │ │ │ -
63 constexpr static int rows = 1;
│ │ │ │ -
66 constexpr static int cols = 1;
│ │ │ │ -
67
│ │ │ │ -
68 //===== constructors
│ │ │ │ -
71 constexpr ScalarMatrixView ()
│ │ │ │ -
72 : data_()
│ │ │ │ -
73 {}
│ │ │ │ -
74
│ │ │ │ -
76 ScalarMatrixView (K* p) :
│ │ │ │ -
77 data_(p)
│ │ │ │ -
78 {}
│ │ │ │ -
79
│ │ │ │ -
81 ScalarMatrixView (const ScalarMatrixView &other) :
│ │ │ │ -
82 Base(),
│ │ │ │ -
83 data_(other.data_)
│ │ │ │ -
84 {}
│ │ │ │ -
85
│ │ │ │ -
87 ScalarMatrixView (ScalarMatrixView &&other) :
│ │ │ │ -
88 Base(),
│ │ │ │ -
89 data_( other.data_ )
│ │ │ │ -
90 {}
│ │ │ │ +
56
│ │ │ │ +
59 template<class V, class>
│ │ │ │ +
60 struct ScalarType { using type = V; };
│ │ │ │ +
61
│ │ │ │ +
63
│ │ │ │ +
66 template<class S, class, class>
│ │ │ │ +
67 struct RebindType { using type = S; };
│ │ │ │ +
68
│ │ │ │ +
70
│ │ │ │ +
73 template<class, class>
│ │ │ │ +
74 struct LaneCount : public index_constant<1> { };
│ │ │ │ +
75
│ │ │ │ +
77
│ │ │ │ +
86 template<class V>
│ │ │ │ +
│ │ │ │ +
87 V lane(ADLTag<2>, std::size_t, V v)
│ │ │ │ +
88 {
│ │ │ │ +
89 return v;
│ │ │ │ +
90 }
│ │ │ │ +
│ │ │ │
91
│ │ │ │ -
93 ScalarMatrixView& operator= (const ScalarMatrixView& other)
│ │ │ │ -
94 {
│ │ │ │ -
95 data_ = other.data_;
│ │ │ │ -
96 return *this;
│ │ │ │ -
97 }
│ │ │ │ -
98
│ │ │ │ -
99 template<class KK>
│ │ │ │ -
100 ScalarMatrixView& operator= (const ScalarMatrixView<KK>& other)
│ │ │ │ -
101 {
│ │ │ │ -
102 data_ = other.data_;
│ │ │ │ -
103 return *this;
│ │ │ │ -
104 }
│ │ │ │ -
105
│ │ │ │ -
107 template<typename T,
│ │ │ │ -
108 std::enable_if_t<std::is_convertible<T, K>::value, int> = 0>
│ │ │ │ -
109 inline ScalarMatrixView& operator= (const T& k)
│ │ │ │ -
110 {
│ │ │ │ -
111 data_ = k;
│ │ │ │ -
112 return *this;
│ │ │ │ -
113 }
│ │ │ │ +
92 template<class V>
│ │ │ │ +
│ │ │ │ +
93 V &lane(ADLTag<3>, std::size_t, V &v)
│ │ │ │ +
94 {
│ │ │ │ +
95 return v;
│ │ │ │ +
96 }
│ │ │ │ +
│ │ │ │ +
97
│ │ │ │ +
98 // No Simd::cond() implementation, the overload for bool masks in the
│ │ │ │ +
99 // interface is sufficient
│ │ │ │ +
100
│ │ │ │ +
102 inline bool anyTrue(ADLTag<2>, bool mask) { return mask; }
│ │ │ │ +
103
│ │ │ │ +
105 inline bool allTrue(ADLTag<2>, bool mask) { return mask; }
│ │ │ │ +
106
│ │ │ │ +
108 inline bool anyFalse(ADLTag<2>, bool mask) { return !mask; }
│ │ │ │ +
109
│ │ │ │ +
111 inline bool allFalse(ADLTag<2>, bool mask) { return !mask; }
│ │ │ │ +
112
│ │ │ │
114
│ │ │ │ -
115 // make this thing a matrix
│ │ │ │ -
116 static constexpr size_type mat_rows() { return 1; }
│ │ │ │ -
117 static constexpr size_type mat_cols() { return 1; }
│ │ │ │ +
115 } // namespace Overloads
│ │ │ │ +
116 } // namespace Simd
│ │ │ │ +
117} // namespace Dune
│ │ │ │
118
│ │ │ │ -
119 row_reference mat_access ([[maybe_unused]] size_type i)
│ │ │ │ -
120 {
│ │ │ │ -
121 DUNE_ASSERT_BOUNDS(i == 0);
│ │ │ │ -
122 return data_;
│ │ │ │ -
123 }
│ │ │ │ -
124
│ │ │ │ -
125 const_row_reference mat_access ([[maybe_unused]] size_type i) const
│ │ │ │ -
126 {
│ │ │ │ -
127 DUNE_ASSERT_BOUNDS(i == 0);
│ │ │ │ -
128 return data_;
│ │ │ │ -
129 }
│ │ │ │ -
130 }; // class ScalarMatrixView
│ │ │ │ -
131
│ │ │ │ -
133 template<typename K>
│ │ │ │ -
134 std::ostream& operator<< (std::ostream& s, const ScalarMatrixView<K>& a)
│ │ │ │ -
135 {
│ │ │ │ -
136 s << a[0][0];
│ │ │ │ -
137 return s;
│ │ │ │ -
138 }
│ │ │ │ -
139
│ │ │ │ -
141 template<class T,
│ │ │ │ -
142 std::enable_if_t<IsNumber<T>::value, int> = 0>
│ │ │ │ -
143 auto asMatrix(T& t)
│ │ │ │ -
144 {
│ │ │ │ -
145 return ScalarMatrixView<T>{&t};
│ │ │ │ -
146 }
│ │ │ │ -
147
│ │ │ │ -
149 template<class T,
│ │ │ │ -
150 std::enable_if_t<IsNumber<T>::value, int> = 0>
│ │ │ │ -
151 auto asMatrix(const T& t)
│ │ │ │ -
152 {
│ │ │ │ -
153 return ScalarMatrixView<const T>{&t};
│ │ │ │ -
154 }
│ │ │ │ -
155
│ │ │ │ -
157 template<class T,
│ │ │ │ -
158 std::enable_if_t<not IsNumber<T>::value, int> = 0>
│ │ │ │ -
159 T& asMatrix(T& t)
│ │ │ │ -
160 {
│ │ │ │ -
161 return t;
│ │ │ │ -
162 }
│ │ │ │ -
163
│ │ │ │ -
165 template<class T,
│ │ │ │ -
166 std::enable_if_t<not IsNumber<T>::value, int> = 0>
│ │ │ │ -
167 const T& asMatrix(const T& t)
│ │ │ │ -
168 {
│ │ │ │ -
169 return t;
│ │ │ │ -
170 }
│ │ │ │ -
171
│ │ │ │ -
174} // end namespace Impl
│ │ │ │ -
175
│ │ │ │ -
176 template<class K>
│ │ │ │ -
177 struct FieldTraits<Impl::ScalarMatrixView<K>> : public FieldTraits<std::remove_const_t<K>> {};
│ │ │ │ -
178
│ │ │ │ -
179 template<class K>
│ │ │ │ -
180 struct DenseMatVecTraits<Impl::ScalarMatrixView<K>>
│ │ │ │ -
181 {
│ │ │ │ -
182 using derived_type = Impl::ScalarMatrixView<K>;
│ │ │ │ -
183 using row_type = Impl::ScalarVectorView<K>;
│ │ │ │ -
184 using row_reference = row_type&;
│ │ │ │ -
185 using const_row_reference = const row_type&;
│ │ │ │ -
186 using value_type = std::remove_const_t<K>;
│ │ │ │ -
187 using size_type = std::size_t;
│ │ │ │ -
188 };
│ │ │ │ -
189
│ │ │ │ -
190
│ │ │ │ -
191 template<class K>
│ │ │ │ -
192 struct AutonomousValueType<Impl::ScalarMatrixView<K>>
│ │ │ │ -
193 {
│ │ │ │ -
194 using type = FieldMatrix<std::remove_const_t<K>,1,1>;
│ │ │ │ -
195 };
│ │ │ │ -
196
│ │ │ │ -
197
│ │ │ │ -
198} // end namespace Dune
│ │ │ │ -
199
│ │ │ │ -
200#endif // DUNE_COMMON_SCALARMATRIXVIEW_HH
│ │ │ │ -
Implements a matrix constructed from a given type representing a field and a compile-time given numbe...
│ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ -
Macro for wrapping boundary checks.
│ │ │ │ -
Documentation of the traits classes you need to write for each implementation of DenseVector or Dense...
│ │ │ │ -
Implements a matrix constructed from a given type representing a field and compile-time given number ...
│ │ │ │ -
Implements a scalar vector view wrapper around an existing scalar.
│ │ │ │ -
#define DUNE_ASSERT_BOUNDS(cond)
If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
Definition boundschecking.hh:30
│ │ │ │ +
119#endif // DUNE_COMMON_SIMD_STANDARD_HH
│ │ │ │ +
Default implementations for SIMD Implementations.
│ │ │ │ +
Basic definitions for SIMD Implementations.
│ │ │ │ + │ │ │ │ +
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition indices.hh:29
│ │ │ │ +
Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v)
implements Simd::mask()
Definition defaults.hh:153
│ │ │ │ +
bool allFalse(ADLTag< 0 >, const Mask &mask)
implements Simd::allFalse()
Definition defaults.hh:124
│ │ │ │ +
bool allTrue(ADLTag< 0 >, const Mask &mask)
implements Simd::allTrue()
Definition defaults.hh:104
│ │ │ │ +
bool anyFalse(ADLTag< 0 >, const Mask &mask)
implements Simd::anyFalse()
Definition defaults.hh:114
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
constexpr size_type cols() const
number of columns
Definition densematrix.hh:715
│ │ │ │ -
constexpr size_type rows() const
number of rows
Definition densematrix.hh:709
│ │ │ │ -
static constexpr int blocklevel
The number of block levels we contain. This is the leaf, that is, 1.
Definition densematrix.hh:178
│ │ │ │ -
Traits::row_type row_type
The type used to represent a row (must fulfill the Dune::DenseVector interface)
Definition densematrix.hh:169
│ │ │ │ -
Traits::size_type size_type
The type used for the index access and size operation.
Definition densematrix.hh:166
│ │ │ │ -
Traits::const_row_reference const_row_reference
The type used to represent a reference to a constant row (usually const row_type &)
Definition densematrix.hh:175
│ │ │ │ -
Traits::row_reference row_reference
The type used to represent a reference to a row (usually row_type &)
Definition densematrix.hh:172
│ │ │ │ -
T type
Definition typetraits.hh:531
│ │ │ │ +
bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
Definition debugalign.hh:556
│ │ │ │ +
T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
Definition debugalign.hh:533
│ │ │ │ +
Tag used to force late-binding lookup in Dune::Simd::Overloads.
Definition base.hh:182
│ │ │ │ +
should have a member type type
Definition standard.hh:60
│ │ │ │ +
V type
Definition standard.hh:60
│ │ │ │ +
should have a member type type
Definition standard.hh:67
│ │ │ │ +
S type
Definition standard.hh:67
│ │ │ │ +
should be derived from a Dune::index_constant
Definition standard.hh:74
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,232 +1,124 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -scalarmatrixview.hh │ │ │ │ │ + * simd │ │ │ │ │ +standard.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ -2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ -3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_SCALARMATRIXVIEW_HH │ │ │ │ │ -6#define DUNE_COMMON_SCALARMATRIXVIEW_HH │ │ │ │ │ -7 │ │ │ │ │ -8#include │ │ │ │ │ -9#include │ │ │ │ │ -10#include │ │ │ │ │ -11 │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18 │ │ │ │ │ -19 │ │ │ │ │ -20namespace Dune { │ │ │ │ │ -21 │ │ │ │ │ -22namespace Impl { │ │ │ │ │ +2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +3#ifndef DUNE_COMMON_SIMD_STANDARD_HH │ │ │ │ │ +4#define DUNE_COMMON_SIMD_STANDARD_HH │ │ │ │ │ +5 │ │ │ │ │ +20#include │ │ │ │ │ +21#include │ │ │ │ │ +22#include │ │ │ │ │ 23 │ │ │ │ │ -39 template │ │ │ │ │ -40 class ScalarMatrixView : │ │ │ │ │ -41 public DenseMatrix> │ │ │ │ │ -42 { │ │ │ │ │ -43 ScalarVectorView data_; │ │ │ │ │ -44 using Base = DenseMatrix>; │ │ │ │ │ -45 │ │ │ │ │ -46 template │ │ │ │ │ -47 friend class ScalarMatrixView; │ │ │ │ │ -48 public: │ │ │ │ │ +24#include │ │ │ │ │ +25#include │ │ │ │ │ +26#include │ │ │ │ │ +27 │ │ │ │ │ +45namespace Dune { │ │ │ │ │ +46 namespace Simd { │ │ │ │ │ +47 │ │ │ │ │ +48 namespace Overloads { │ │ │ │ │ 49 │ │ │ │ │ -50 //===== type definitions and constants │ │ │ │ │ -51 │ │ │ │ │ -54 constexpr static int blocklevel = 1; │ │ │ │ │ -55 │ │ │ │ │ -56 using size_type = typename Base::size_type; │ │ │ │ │ -57 using row_type = typename Base::row_type; │ │ │ │ │ -58 using row_reference = typename Base::row_reference; │ │ │ │ │ -59 using const_row_reference = typename Base::const_row_reference; │ │ │ │ │ -60 │ │ │ │ │ -63 constexpr static int rows = 1; │ │ │ │ │ -66 constexpr static int cols = 1; │ │ │ │ │ -67 │ │ │ │ │ -68 //===== constructors │ │ │ │ │ -71 constexpr ScalarMatrixView () │ │ │ │ │ -72 : data_() │ │ │ │ │ -73 {} │ │ │ │ │ -74 │ │ │ │ │ -76 ScalarMatrixView (K* p) : │ │ │ │ │ -77 data_(p) │ │ │ │ │ -78 {} │ │ │ │ │ -79 │ │ │ │ │ -81 ScalarMatrixView (const ScalarMatrixView &other) : │ │ │ │ │ -82 Base(), │ │ │ │ │ -83 data_(other.data_) │ │ │ │ │ -84 {} │ │ │ │ │ -85 │ │ │ │ │ -87 ScalarMatrixView (ScalarMatrixView &&other) : │ │ │ │ │ -88 Base(), │ │ │ │ │ -89 data_( other.data_ ) │ │ │ │ │ -90 {} │ │ │ │ │ +56 │ │ │ │ │ +59 template │ │ │ │ │ +60 struct ScalarType { using type = V; }; │ │ │ │ │ +61 │ │ │ │ │ +63 │ │ │ │ │ +66 template │ │ │ │ │ +67 struct RebindType { using type = S; }; │ │ │ │ │ +68 │ │ │ │ │ +70 │ │ │ │ │ +73 template │ │ │ │ │ +74 struct LaneCount : public index_constant<1> { }; │ │ │ │ │ +75 │ │ │ │ │ +77 │ │ │ │ │ +86 template │ │ │ │ │ +87 V lane(ADLTag<2>, std::size_t, V v) │ │ │ │ │ +88 { │ │ │ │ │ +89 return v; │ │ │ │ │ +90 } │ │ │ │ │ 91 │ │ │ │ │ -93 ScalarMatrixView& operator= (const ScalarMatrixView& other) │ │ │ │ │ +92 template │ │ │ │ │ +93 V &lane(ADLTag<3>, std::size_t, V &v) │ │ │ │ │ 94 { │ │ │ │ │ -95 data_ = other.data_; │ │ │ │ │ -96 return *this; │ │ │ │ │ -97 } │ │ │ │ │ -98 │ │ │ │ │ -99 template │ │ │ │ │ -100 ScalarMatrixView& operator= (const ScalarMatrixView& other) │ │ │ │ │ -101 { │ │ │ │ │ -102 data_ = other.data_; │ │ │ │ │ -103 return *this; │ │ │ │ │ -104 } │ │ │ │ │ -105 │ │ │ │ │ -107 template::value, int> = 0> │ │ │ │ │ -109 inline ScalarMatrixView& operator= (const T& k) │ │ │ │ │ -110 { │ │ │ │ │ -111 data_ = k; │ │ │ │ │ -112 return *this; │ │ │ │ │ -113 } │ │ │ │ │ +95 return v; │ │ │ │ │ +96 } │ │ │ │ │ +97 │ │ │ │ │ +98 // No Simd::cond() implementation, the overload for bool masks in the │ │ │ │ │ +99 // interface is sufficient │ │ │ │ │ +100 │ │ │ │ │ +102 inline bool anyTrue(ADLTag<2>, bool mask) { return mask; } │ │ │ │ │ +103 │ │ │ │ │ +105 inline bool allTrue(ADLTag<2>, bool mask) { return mask; } │ │ │ │ │ +106 │ │ │ │ │ +108 inline bool anyFalse(ADLTag<2>, bool mask) { return !mask; } │ │ │ │ │ +109 │ │ │ │ │ +111 inline bool allFalse(ADLTag<2>, bool mask) { return !mask; } │ │ │ │ │ +112 │ │ │ │ │ 114 │ │ │ │ │ -115 // make this thing a matrix │ │ │ │ │ -116 static constexpr size_type mat_rows() { return 1; } │ │ │ │ │ -117 static constexpr size_type mat_cols() { return 1; } │ │ │ │ │ +115 } // namespace Overloads │ │ │ │ │ +116 } // namespace Simd │ │ │ │ │ +117} // namespace Dune │ │ │ │ │ 118 │ │ │ │ │ -119 row_reference mat_access ([[maybe_unused]] size_type i) │ │ │ │ │ -120 { │ │ │ │ │ -121 DUNE_ASSERT_BOUNDS(i == 0); │ │ │ │ │ -122 return data_; │ │ │ │ │ -123 } │ │ │ │ │ -124 │ │ │ │ │ -125 const_row_reference mat_access ([[maybe_unused]] size_type i) const │ │ │ │ │ -126 { │ │ │ │ │ -127 DUNE_ASSERT_BOUNDS(i == 0); │ │ │ │ │ -128 return data_; │ │ │ │ │ -129 } │ │ │ │ │ -130 }; // class ScalarMatrixView │ │ │ │ │ -131 │ │ │ │ │ -133 template │ │ │ │ │ -134 std::ostream& operator<< (std::ostream& s, const ScalarMatrixView& a) │ │ │ │ │ -135 { │ │ │ │ │ -136 s << a[0][0]; │ │ │ │ │ -137 return s; │ │ │ │ │ -138 } │ │ │ │ │ -139 │ │ │ │ │ -141 template::value, int> = 0> │ │ │ │ │ -143 auto asMatrix(T& t) │ │ │ │ │ -144 { │ │ │ │ │ -145 return ScalarMatrixView{&t}; │ │ │ │ │ -146 } │ │ │ │ │ -147 │ │ │ │ │ -149 template::value, int> = 0> │ │ │ │ │ -151 auto asMatrix(const T& t) │ │ │ │ │ -152 { │ │ │ │ │ -153 return ScalarMatrixView{&t}; │ │ │ │ │ -154 } │ │ │ │ │ -155 │ │ │ │ │ -157 template::value, int> = 0> │ │ │ │ │ -159 T& asMatrix(T& t) │ │ │ │ │ -160 { │ │ │ │ │ -161 return t; │ │ │ │ │ -162 } │ │ │ │ │ -163 │ │ │ │ │ -165 template::value, int> = 0> │ │ │ │ │ -167 const T& asMatrix(const T& t) │ │ │ │ │ -168 { │ │ │ │ │ -169 return t; │ │ │ │ │ -170 } │ │ │ │ │ -171 │ │ │ │ │ -174} // end namespace Impl │ │ │ │ │ -175 │ │ │ │ │ -176 template │ │ │ │ │ -177 struct FieldTraits> : public FieldTraits> {}; │ │ │ │ │ -178 │ │ │ │ │ -179 template │ │ │ │ │ -180 struct DenseMatVecTraits> │ │ │ │ │ -181 { │ │ │ │ │ -182 using derived_type = Impl::ScalarMatrixView; │ │ │ │ │ -183 using row_type = Impl::ScalarVectorView; │ │ │ │ │ -184 using row_reference = row_type&; │ │ │ │ │ -185 using const_row_reference = const row_type&; │ │ │ │ │ -186 using value_type = std::remove_const_t; │ │ │ │ │ -187 using size_type = std::size_t; │ │ │ │ │ -188 }; │ │ │ │ │ -189 │ │ │ │ │ -190 │ │ │ │ │ -191 template │ │ │ │ │ -192 struct AutonomousValueType> │ │ │ │ │ -193 { │ │ │ │ │ -194 using type = FieldMatrix,1,1>; │ │ │ │ │ -195 }; │ │ │ │ │ -196 │ │ │ │ │ -197 │ │ │ │ │ -198} // end namespace Dune │ │ │ │ │ -199 │ │ │ │ │ -200#endif // DUNE_COMMON_SCALARMATRIXVIEW_HH │ │ │ │ │ -densematrix.hh │ │ │ │ │ -Implements a matrix constructed from a given type representing a field and a │ │ │ │ │ -compile-time given numbe... │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -boundschecking.hh │ │ │ │ │ -Macro for wrapping boundary checks. │ │ │ │ │ -matvectraits.hh │ │ │ │ │ -Documentation of the traits classes you need to write for each implementation │ │ │ │ │ -of DenseVector or Dense... │ │ │ │ │ -fmatrix.hh │ │ │ │ │ -Implements a matrix constructed from a given type representing a field and │ │ │ │ │ -compile-time given number ... │ │ │ │ │ -scalarvectorview.hh │ │ │ │ │ -Implements a scalar vector view wrapper around an existing scalar. │ │ │ │ │ -DUNE_ASSERT_BOUNDS │ │ │ │ │ -#define DUNE_ASSERT_BOUNDS(cond) │ │ │ │ │ -If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do │ │ │ │ │ -nothing. │ │ │ │ │ -Definition boundschecking.hh:30 │ │ │ │ │ +119#endif // DUNE_COMMON_SIMD_STANDARD_HH │ │ │ │ │ +defaults.hh │ │ │ │ │ +Default implementations for SIMD Implementations. │ │ │ │ │ +base.hh │ │ │ │ │ +Basic definitions for SIMD Implementations. │ │ │ │ │ +indices.hh │ │ │ │ │ +Dune::index_constant │ │ │ │ │ +std::integral_constant< std::size_t, i > index_constant │ │ │ │ │ +An index constant with value i. │ │ │ │ │ +Definition indices.hh:29 │ │ │ │ │ +Dune::Simd::Overloads::mask │ │ │ │ │ +Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v) │ │ │ │ │ +implements Simd::mask() │ │ │ │ │ +Definition defaults.hh:153 │ │ │ │ │ +Dune::Simd::Overloads::allFalse │ │ │ │ │ +bool allFalse(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ +implements Simd::allFalse() │ │ │ │ │ +Definition defaults.hh:124 │ │ │ │ │ +Dune::Simd::Overloads::allTrue │ │ │ │ │ +bool allTrue(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ +implements Simd::allTrue() │ │ │ │ │ +Definition defaults.hh:104 │ │ │ │ │ +Dune::Simd::Overloads::anyFalse │ │ │ │ │ +bool anyFalse(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ +implements Simd::anyFalse() │ │ │ │ │ +Definition defaults.hh:114 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::cols │ │ │ │ │ -constexpr size_type cols() const │ │ │ │ │ -number of columns │ │ │ │ │ -Definition densematrix.hh:715 │ │ │ │ │ -Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::rows │ │ │ │ │ -constexpr size_type rows() const │ │ │ │ │ -number of rows │ │ │ │ │ -Definition densematrix.hh:709 │ │ │ │ │ -Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::blocklevel │ │ │ │ │ -static constexpr int blocklevel │ │ │ │ │ -The number of block levels we contain. This is the leaf, that is, 1. │ │ │ │ │ -Definition densematrix.hh:178 │ │ │ │ │ -Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::row_type │ │ │ │ │ -Traits::row_type row_type │ │ │ │ │ -The type used to represent a row (must fulfill the Dune::DenseVector interface) │ │ │ │ │ -Definition densematrix.hh:169 │ │ │ │ │ -Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::size_type │ │ │ │ │ -Traits::size_type size_type │ │ │ │ │ -The type used for the index access and size operation. │ │ │ │ │ -Definition densematrix.hh:166 │ │ │ │ │ -Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::const_row_reference │ │ │ │ │ -Traits::const_row_reference const_row_reference │ │ │ │ │ -The type used to represent a reference to a constant row (usually const row_ │ │ │ │ │ -type &) │ │ │ │ │ -Definition densematrix.hh:175 │ │ │ │ │ -Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::row_reference │ │ │ │ │ -Traits::row_reference row_reference │ │ │ │ │ -The type used to represent a reference to a row (usually row_type &) │ │ │ │ │ -Definition densematrix.hh:172 │ │ │ │ │ -Dune::AutonomousValueType::type │ │ │ │ │ -T type │ │ │ │ │ -Definition typetraits.hh:531 │ │ │ │ │ +Dune::Simd::Overloads::anyTrue │ │ │ │ │ +bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask) │ │ │ │ │ +Definition debugalign.hh:556 │ │ │ │ │ +Dune::Simd::Overloads::lane │ │ │ │ │ +T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ +Definition debugalign.hh:533 │ │ │ │ │ +Dune::Simd::Overloads::ADLTag │ │ │ │ │ +Tag used to force late-binding lookup in Dune::Simd::Overloads. │ │ │ │ │ +Definition base.hh:182 │ │ │ │ │ +Dune::Simd::Overloads::ScalarType │ │ │ │ │ +should have a member type type │ │ │ │ │ +Definition standard.hh:60 │ │ │ │ │ +Dune::Simd::Overloads::ScalarType::type │ │ │ │ │ +V type │ │ │ │ │ +Definition standard.hh:60 │ │ │ │ │ +Dune::Simd::Overloads::RebindType │ │ │ │ │ +should have a member type type │ │ │ │ │ +Definition standard.hh:67 │ │ │ │ │ +Dune::Simd::Overloads::RebindType::type │ │ │ │ │ +S type │ │ │ │ │ +Definition standard.hh:67 │ │ │ │ │ +Dune::Simd::Overloads::LaneCount │ │ │ │ │ +should be derived from a Dune::index_constant │ │ │ │ │ +Definition standard.hh:74 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00017.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: stdthread.hh File Reference │ │ │ │ +dune-common: defaults.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,69 +65,127 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Namespaces | │ │ │ │ -Macros | │ │ │ │ -Functions
│ │ │ │ -
stdthread.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ + │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ +

Default implementations for SIMD Implementations. │ │ │ │ +More...

│ │ │ │ +
#include <algorithm>
│ │ │ │ +#include <cstddef>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <dune/common/rangeutilities.hh>
│ │ │ │ +#include <dune/common/simd/base.hh>
│ │ │ │ +#include <dune/common/simd/interface.hh>
│ │ │ │ +#include <dune/common/typelist.hh>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │ +
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ -Macros

#define DUNE_ASSERT_CALL_ONCE()    ::Dune::assertCallOnce(__FILE__, __LINE__, __func__)
 Make sure call_once() works and provide a helpful error message otherwise.
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
 
namespace  Dune::Simd::Overloads
 Namespace for the overloads and specializations that make up a SIMD implementation.
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

void Dune::doAssertCallOnce (const char *file, int line, const char *function)
 
void Dune::assertCallOnce (const char *file=nullptr, int line=-1, const char *function=nullptr)
 Make sure call_once() works and provide a helpful error message otherwise.
 
Overloadable and default functions

This group contains functions that you, as an abstraction developer, must implement. All functions that are deleted must be provided, functions that have a default implementation may be left unimplemented if the default behaviour is satisfactory.

│ │ │ │ +
template<class V >
decltype(auto) Dune::Simd::Overloads::lane (ADLTag< 0 >, std::size_t l, V v)=delete
 implements Simd::lane()
 
template<class V >
constexpr V Dune::Simd::Overloads::implCast (ADLTag< 0 >, MetaType< V >, const V &u)
 implements Simd::implCast<V>(V)
 
template<class V , class U >
constexpr V Dune::Simd::Overloads::implCast (ADLTag< 0 >, MetaType< V >, const U &u)
 implements Simd::implCast<V>(U)
 
template<class V , class S >
auto Dune::Simd::Overloads::broadcast (ADLTag< 0 >, MetaType< V >, S s)
 implements Simd::broadcast<V>()
 
template<class V >
Dune::Simd::Overloads::cond (ADLTag< 0 >, const Mask< V > &mask, const V &ifTrue, const V &ifFalse)=delete
 implements Simd::cond()
 
template<class V >
auto Dune::Simd::Overloads::max (ADLTag< 0 >, const V &v1, const V &v2)
 implements binary Simd::max()
 
template<class V >
auto Dune::Simd::Overloads::min (ADLTag< 0 >, const V &v1, const V &v2)
 implements binary Simd::min()
 
template<class Mask >
bool Dune::Simd::Overloads::anyTrue (ADLTag< 0 >, const Mask &mask)=delete
 implements Simd::anyTrue()
 
template<class Mask >
bool Dune::Simd::Overloads::allTrue (ADLTag< 0 >, const Mask &mask)
 implements Simd::allTrue()
 
template<class Mask >
bool Dune::Simd::Overloads::anyFalse (ADLTag< 0 >, const Mask &mask)
 implements Simd::anyFalse()
 
template<class Mask >
bool Dune::Simd::Overloads::allFalse (ADLTag< 0 >, const Mask &mask)
 implements Simd::allFalse()
 
template<class V >
auto Dune::Simd::Overloads::max (ADLTag< 0 >, const V &v)
 implements Simd::maxValue()
 
template<class V >
auto Dune::Simd::Overloads::min (ADLTag< 0 >, const V &v)
 implements Simd::minValue()
 
template<class V >
Mask< V > Dune::Simd::Overloads::mask (ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v)
 implements Simd::mask()
 
template<class V >
auto Dune::Simd::Overloads::mask (ADLTag< 0, !std::is_same< V, Mask< V > >::value >, const V &v)
 implements Simd::mask()
 
template<class V1 , class V2 >
auto Dune::Simd::Overloads::maskOr (ADLTag< 0 >, const V1 &v1, const V2 &v2)
 implements Simd::maskOr()
 
template<class V1 , class V2 >
auto Dune::Simd::Overloads::maskAnd (ADLTag< 0 >, const V1 &v1, const V2 &v2)
 implements Simd::maskAnd()
 
│ │ │ │ -

Macro Definition Documentation

│ │ │ │ - │ │ │ │ -

◆ DUNE_ASSERT_CALL_ONCE

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define DUNE_ASSERT_CALL_ONCE()    ::Dune::assertCallOnce(__FILE__, __LINE__, __func__)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

Make sure call_once() works and provide a helpful error message otherwise.

│ │ │ │ -

This calls assertCallOnce() and automatically provides information about the caller in the error message.

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ +

Detailed Description

│ │ │ │ +

Default implementations for SIMD Implementations.

│ │ │ │ +

This file provides default overloads for SIMD implementation functions, and deleted placeholders where there are no default implementations.

│ │ │ │ +

This file should never be included by users of the SIMD abstraction. Include <dune/common/simd/simd.hh> instead.

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,36 +1,126 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Macros | Functions │ │ │ │ │ -stdthread.hh File Reference │ │ │ │ │ + * simd │ │ │ │ │ +Namespaces │ │ │ │ │ +defaults.hh File Reference │ │ │ │ │ +Common » Vectorization » Abstraction_Developer's_Interface │ │ │ │ │ +Default implementations for SIMD Implementations. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Macros │ │ │ │ │ -#define  DUNE_ASSERT_CALL_ONCE()    ::Dune::assertCallOnce(__FILE__, __LINE__, │ │ │ │ │ - __func__) │ │ │ │ │ -  Make sure call_once() works and provide a helpful error message │ │ │ │ │ - otherwise. │ │ │ │ │ +namespace   Dune::Simd │ │ │ │ │ +  Namespace for vectorization interface functions used by library │ │ │ │ │ + developers. │ │ │ │ │ +  │ │ │ │ │ +namespace   Dune::Simd::Overloads │ │ │ │ │ +  Namespace for the overloads and specializations that make up a SIMD │ │ │ │ │ + implementation. │ │ │ │ │   │ │ │ │ │ Functions │ │ │ │ │ -void  Dune::doAssertCallOnce (const char *file, int line, const char *function) │ │ │ │ │ +Overloadable and default functions │ │ │ │ │ +This group contains functions that you, as an abstraction developer, must │ │ │ │ │ +implement. All functions that are deleted must be provided, functions that have │ │ │ │ │ +a default implementation may be left unimplemented if the default behaviour is │ │ │ │ │ +satisfactory. │ │ │ │ │ +template │ │ │ │ │ +decltype(auto)  Dune::Simd::Overloads::lane (ADLTag< 0 >, std::size_t l, V │ │ │ │ │ + v)=delete │ │ │ │ │ +  implements Simd::lane() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr V  Dune::Simd::Overloads::implCast (ADLTag< 0 >, MetaType< V >, │ │ │ │ │ + const V &u) │ │ │ │ │ +  implements Simd::implCast(V) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr V  Dune::Simd::Overloads::implCast (ADLTag< 0 >, MetaType< V >, │ │ │ │ │ + const U &u) │ │ │ │ │ +  implements Simd::implCast(U) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::Overloads::broadcast (ADLTag< 0 >, MetaType< V >, S │ │ │ │ │ + s) │ │ │ │ │ +  implements Simd::broadcast() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + V  Dune::Simd::Overloads::cond (ADLTag< 0 >, const Mask< V > │ │ │ │ │ + &mask, const V &ifTrue, const V &ifFalse)=delete │ │ │ │ │ +  implements Simd::cond() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::Overloads::max (ADLTag< 0 >, const V &v1, const V │ │ │ │ │ + &v2) │ │ │ │ │ +  implements binary Simd::max() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::Overloads::min (ADLTag< 0 >, const V &v1, const V │ │ │ │ │ + &v2) │ │ │ │ │ +  implements binary Simd::min() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool  Dune::Simd::Overloads::anyTrue (ADLTag< 0 >, const Mask │ │ │ │ │ + &mask)=delete │ │ │ │ │ +  implements Simd::anyTrue() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool  Dune::Simd::Overloads::allTrue (ADLTag< 0 >, const Mask &mask) │ │ │ │ │ +  implements Simd::allTrue() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool  Dune::Simd::Overloads::anyFalse (ADLTag< 0 >, const Mask &mask) │ │ │ │ │ +  implements Simd::anyFalse() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool  Dune::Simd::Overloads::allFalse (ADLTag< 0 >, const Mask &mask) │ │ │ │ │ +  implements Simd::allFalse() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::Overloads::max (ADLTag< 0 >, const V &v) │ │ │ │ │ +  implements Simd::maxValue() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::Overloads::min (ADLTag< 0 >, const V &v) │ │ │ │ │ +  implements Simd::minValue() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + Mask< V >  Dune::Simd::Overloads::mask (ADLTag< 0, std::is_same< V, Mask< │ │ │ │ │ + V > >::value >, const V &v) │ │ │ │ │ +  implements Simd::mask() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::Overloads::mask (ADLTag< 0, !std::is_same< V, Mask< │ │ │ │ │ + V > >::value >, const V &v) │ │ │ │ │ +  implements Simd::mask() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::Overloads::maskOr (ADLTag< 0 >, const V1 &v1, const │ │ │ │ │ + V2 &v2) │ │ │ │ │ +  implements Simd::maskOr() │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::Overloads::maskAnd (ADLTag< 0 >, const V1 &v1, │ │ │ │ │ + const V2 &v2) │ │ │ │ │ +  implements Simd::maskAnd() │ │ │ │ │   │ │ │ │ │ -void  Dune::assertCallOnce (const char *file=nullptr, int line=-1, const char │ │ │ │ │ - *function=nullptr) │ │ │ │ │ -  Make sure call_once() works and provide a helpful error message │ │ │ │ │ - otherwise. │ │ │ │ │ -  │ │ │ │ │ -***** Macro Definition Documentation ***** │ │ │ │ │ -***** ◆ DUNE_ASSERT_CALL_ONCE ***** │ │ │ │ │ -#define DUNE_ASSERT_CALL_ONCE ( )     ::Dune::assertCallOnce(__FILE__, __LINE_ │ │ │ │ │ - _, __func__) │ │ │ │ │ -Make sure call_once() works and provide a helpful error message otherwise. │ │ │ │ │ -This calls assertCallOnce() and automatically provides information about the │ │ │ │ │ -caller in the error message. │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Default implementations for SIMD Implementations. │ │ │ │ │ +This file provides default overloads for SIMD implementation functions, and │ │ │ │ │ +deleted placeholders where there are no default implementations. │ │ │ │ │ +This file should never be included by users of the SIMD abstraction. Include │ │ │ │ │ + instead. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00017_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: stdthread.hh Source File │ │ │ │ +dune-common: defaults.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,58 +70,215 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
stdthread.hh
│ │ │ │ +
defaults.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ -
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ -
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
3#ifndef DUNE_COMMON_SIMD_DEFAULTS_HH
│ │ │ │ +
4#define DUNE_COMMON_SIMD_DEFAULTS_HH
│ │ │ │
5
│ │ │ │ -
6#ifndef DUNE_COMMON_STDTHREAD_HH
│ │ │ │ -
7#define DUNE_COMMON_STDTHREAD_HH
│ │ │ │ -
8
│ │ │ │ -
9namespace Dune
│ │ │ │ -
10{
│ │ │ │ -
11
│ │ │ │ -
12 // used internally by assertCallOnce for the actual check
│ │ │ │ -
13 void doAssertCallOnce(const char *file, int line, const char *function);
│ │ │ │ -
14
│ │ │ │ -
17
│ │ │ │ -
│ │ │ │ -
35 inline void assertCallOnce(const char *file = nullptr, int line = -1,
│ │ │ │ -
36 const char *function = nullptr)
│ │ │ │ -
37 {
│ │ │ │ -
38 // make sure to call this only the first time this function is invoked
│ │ │ │ -
39 [[maybe_unused]] static const bool works
│ │ │ │ -
40 = (doAssertCallOnce(file, line, function), true);
│ │ │ │ -
41 }
│ │ │ │ -
│ │ │ │ -
42
│ │ │ │ -
45
│ │ │ │ -
│ │ │ │ -
49#define DUNE_ASSERT_CALL_ONCE() \
│ │ │ │ -
50 ::Dune::assertCallOnce(__FILE__, __LINE__, __func__)
│ │ │ │ -
│ │ │ │ -
51
│ │ │ │ -
52} // namespace Dune
│ │ │ │ -
53
│ │ │ │ -
54#endif // DUNE_COMMON_STDTHREAD_HH
│ │ │ │ +
17#include <algorithm>
│ │ │ │ +
18#include <cstddef>
│ │ │ │ +
19#include <type_traits>
│ │ │ │ +
20
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
26
│ │ │ │ +
27namespace Dune {
│ │ │ │ +
28 namespace Simd {
│ │ │ │ +
29 namespace Overloads {
│ │ │ │ +
30
│ │ │ │ +
47 template<class V>
│ │ │ │ +
48 decltype(auto) lane(ADLTag<0>, std::size_t l, V v) = delete;
│ │ │ │ +
49
│ │ │ │ +
51 template<class V>
│ │ │ │ +
│ │ │ │ +
52 constexpr V implCast(ADLTag<0>, MetaType<V>, const V &u)
│ │ │ │ +
53 {
│ │ │ │ +
54 return u;
│ │ │ │ +
55 }
│ │ │ │ +
│ │ │ │ +
56
│ │ │ │ +
58 template<class V, class U>
│ │ │ │ +
│ │ │ │ +
59 constexpr V implCast(ADLTag<0>, MetaType<V>, const U &u)
│ │ │ │ +
60 {
│ │ │ │ +
61 V result(Simd::Scalar<V>(0));
│ │ │ │ +
62 for(auto l : range(Simd::lanes(u)))
│ │ │ │ +
63 Simd::lane(l, result) = Simd::lane(l, u);
│ │ │ │ +
64 return result;
│ │ │ │ +
65 }
│ │ │ │ +
│ │ │ │ +
66
│ │ │ │ +
68 template<class V, class S>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
70 {
│ │ │ │ +
71 return V(Simd::Scalar<V>(s));
│ │ │ │ +
72 }
│ │ │ │ +
│ │ │ │ +
73
│ │ │ │ +
75 template<class V>
│ │ │ │ + │ │ │ │ +
77 const V &ifTrue, const V &ifFalse) = delete;
│ │ │ │ +
78
│ │ │ │ +
80 template<class V>
│ │ │ │ +
│ │ │ │ +
81 auto max(ADLTag<0>, const V &v1, const V &v2)
│ │ │ │ +
82 {
│ │ │ │ +
83 using std::max;
│ │ │ │ +
84 return max(v1, v2);
│ │ │ │ +
85 }
│ │ │ │ +
│ │ │ │ +
86
│ │ │ │ +
88 template<class V>
│ │ │ │ +
│ │ │ │ +
89 auto min(ADLTag<0>, const V &v1, const V &v2)
│ │ │ │ +
90 {
│ │ │ │ +
91 using std::min;
│ │ │ │ +
92 return min(v1, v2);
│ │ │ │ +
93 }
│ │ │ │ +
│ │ │ │ +
94
│ │ │ │ +
96 template<class Mask>
│ │ │ │ +
97 bool anyTrue(ADLTag<0>, const Mask &mask) = delete;
│ │ │ │ +
98
│ │ │ │ +
100
│ │ │ │ +
103 template<class Mask>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
105 {
│ │ │ │ +
106 return !Dune::Simd::anyTrue(!mask);
│ │ │ │ +
107 }
│ │ │ │ +
│ │ │ │ +
108
│ │ │ │ +
110
│ │ │ │ +
113 template<class Mask>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
115 {
│ │ │ │ +
116 return Dune::Simd::anyTrue(!mask);
│ │ │ │ +
117 }
│ │ │ │ +
│ │ │ │ +
118
│ │ │ │ +
120
│ │ │ │ +
123 template<class Mask>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
125 {
│ │ │ │ +
126 return !Dune::Simd::anyTrue(mask);
│ │ │ │ +
127 }
│ │ │ │ +
│ │ │ │ +
128
│ │ │ │ +
130 template<class V>
│ │ │ │ +
│ │ │ │ +
131 auto max(ADLTag<0>, const V &v)
│ │ │ │ +
132 {
│ │ │ │ +
133 Scalar<V> m = Simd::lane(0, v);
│ │ │ │ +
134 for(std::size_t l = 1; l < Simd::lanes(v); ++l)
│ │ │ │ +
135 if(m < Simd::lane(l, v))
│ │ │ │ +
136 m = Simd::lane(l, v);
│ │ │ │ +
137 return m;
│ │ │ │ +
138 }
│ │ │ │ +
│ │ │ │ +
139
│ │ │ │ +
141 template<class V>
│ │ │ │ +
│ │ │ │ +
142 auto min(ADLTag<0>, const V &v)
│ │ │ │ +
143 {
│ │ │ │ +
144 Scalar<V> m = Simd::lane(0, v);
│ │ │ │ +
145 for(std::size_t l = 1; l < Simd::lanes(v); ++l)
│ │ │ │ +
146 if(Simd::lane(l, v) < m)
│ │ │ │ +
147 m = Simd::lane(l, v);
│ │ │ │ +
148 return m;
│ │ │ │ +
149 }
│ │ │ │ +
│ │ │ │ +
150
│ │ │ │ +
152 template<class V>
│ │ │ │ +
│ │ │ │ +
153 Mask<V> mask(ADLTag<0, std::is_same<V, Mask<V> >::value>,
│ │ │ │ +
154 const V &v)
│ │ │ │ +
155 {
│ │ │ │ +
156 return v;
│ │ │ │ +
157 }
│ │ │ │ +
│ │ │ │ +
158
│ │ │ │ +
160 template<class V>
│ │ │ │ +
│ │ │ │ +
161 auto mask(ADLTag<0, !std::is_same<V, Mask<V> >::value>,
│ │ │ │ +
162 const V &v)
│ │ │ │ +
163 {
│ │ │ │ +
164 using Copy = AutonomousValue<V>; // just in case we are handed a proxy
│ │ │ │ +
165 return v != Copy(Scalar<Copy>(0));
│ │ │ │ +
166 }
│ │ │ │ +
│ │ │ │ +
167
│ │ │ │ +
169 template<class V1, class V2>
│ │ │ │ +
│ │ │ │ +
170 auto maskOr(ADLTag<0>, const V1 &v1, const V2 &v2)
│ │ │ │ +
171 {
│ │ │ │ +
172 return Simd::mask(v1) || Simd::mask(v2);
│ │ │ │ +
173 }
│ │ │ │ +
│ │ │ │ +
174
│ │ │ │ +
176 template<class V1, class V2>
│ │ │ │ +
│ │ │ │ +
177 auto maskAnd(ADLTag<0>, const V1 &v1, const V2 &v2)
│ │ │ │ +
178 {
│ │ │ │ +
179 return Simd::mask(v1) && Simd::mask(v2);
│ │ │ │ +
180 }
│ │ │ │ +
│ │ │ │ +
181
│ │ │ │ +
184 } // namespace Overloads
│ │ │ │ +
185 } // namespace Simd
│ │ │ │ +
186} // namespace Dune
│ │ │ │ +
187
│ │ │ │ +
188#endif // DUNE_COMMON_SIMD_DEFAULTS_HH
│ │ │ │ +
Basic definitions for SIMD Implementations.
│ │ │ │ + │ │ │ │ +
Utilities for reduction like operations on ranges.
│ │ │ │ +
Traits for type conversions and type information.
│ │ │ │ +
static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
Definition rangeutilities.hh:312
│ │ │ │ +
typename AutonomousValueType< T >::type AutonomousValue
Type free of internal references that T can be converted to.
Definition typetraits.hh:588
│ │ │ │ +
bool anyTrue(const Mask &mask)
Whether any entry is true
Definition simd/interface.hh:429
│ │ │ │ +
auto mask(const V &v)
Convert to mask, analogue of bool(s) for scalars.
Definition simd/interface.hh:489
│ │ │ │ +
constexpr std::size_t lanes()
Number of lanes in a SIMD type.
Definition simd/interface.hh:305
│ │ │ │ +
decltype(auto) lane(std::size_t l, V &&v)
Extract an element of a SIMD type.
Definition simd/interface.hh:324
│ │ │ │ +
Rebind< bool, V > Mask
Mask type type of some SIMD type.
Definition simd/interface.hh:289
│ │ │ │ +
typename Overloads::ScalarType< std::decay_t< V > >::type Scalar
Element type of some SIMD type.
Definition simd/interface.hh:235
│ │ │ │ +
Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v)
implements Simd::mask()
Definition defaults.hh:153
│ │ │ │ +
constexpr V implCast(ADLTag< 0 >, MetaType< V >, const V &u)
implements Simd::implCast<V>(V)
Definition defaults.hh:52
│ │ │ │ +
bool allFalse(ADLTag< 0 >, const Mask &mask)
implements Simd::allFalse()
Definition defaults.hh:124
│ │ │ │ +
bool allTrue(ADLTag< 0 >, const Mask &mask)
implements Simd::allTrue()
Definition defaults.hh:104
│ │ │ │ +
auto maskAnd(ADLTag< 0 >, const V1 &v1, const V2 &v2)
implements Simd::maskAnd()
Definition defaults.hh:177
│ │ │ │ +
auto maskOr(ADLTag< 0 >, const V1 &v1, const V2 &v2)
implements Simd::maskOr()
Definition defaults.hh:170
│ │ │ │ +
bool anyFalse(ADLTag< 0 >, const Mask &mask)
implements Simd::anyFalse()
Definition defaults.hh:114
│ │ │ │ +
auto min(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::min()
Definition defaults.hh:89
│ │ │ │ +
auto broadcast(ADLTag< 0 >, MetaType< V >, S s)
implements Simd::broadcast<V>()
Definition defaults.hh:69
│ │ │ │ +
auto max(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::max()
Definition defaults.hh:81
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
void assertCallOnce(const char *file=nullptr, int line=-1, const char *function=nullptr)
Make sure call_once() works and provide a helpful error message otherwise.
Definition stdthread.hh:35
│ │ │ │ -
void doAssertCallOnce(const char *file, int line, const char *function)
Definition stdthread.cc:38
│ │ │ │ +
bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
Definition debugalign.hh:556
│ │ │ │ +
const AlignedNumber< T, align > & cond(ADLTag< 5 >, AlignedNumber< bool, align > mask, const AlignedNumber< T, align > &ifTrue, const AlignedNumber< T, align > &ifFalse)
Definition debugalign.hh:548
│ │ │ │ +
T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
Definition debugalign.hh:533
│ │ │ │ +
Tag used to force late-binding lookup in Dune::Simd::Overloads.
Definition base.hh:182
│ │ │ │ +
A type that refers to another type.
Definition typelist.hh:33
│ │ │ │ +
User interface of the SIMD abstraction.
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,52 +1,250 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -stdthread.hh │ │ │ │ │ + * simd │ │ │ │ │ +defaults.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ -2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ -3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +3#ifndef DUNE_COMMON_SIMD_DEFAULTS_HH │ │ │ │ │ +4#define DUNE_COMMON_SIMD_DEFAULTS_HH │ │ │ │ │ 5 │ │ │ │ │ -6#ifndef DUNE_COMMON_STDTHREAD_HH │ │ │ │ │ -7#define DUNE_COMMON_STDTHREAD_HH │ │ │ │ │ -8 │ │ │ │ │ -9namespace Dune │ │ │ │ │ -10{ │ │ │ │ │ -11 │ │ │ │ │ -12 // used internally by assertCallOnce for the actual check │ │ │ │ │ -13 void doAssertCallOnce(const char *file, int line, const char *function); │ │ │ │ │ -14 │ │ │ │ │ -17 │ │ │ │ │ -35 inline void assertCallOnce(const char *file = nullptr, int line = -1, │ │ │ │ │ -36 const char *function = nullptr) │ │ │ │ │ -37 { │ │ │ │ │ -38 // make sure to call this only the first time this function is invoked │ │ │ │ │ -39 [[maybe_unused]] static const bool works │ │ │ │ │ -40 = (doAssertCallOnce(file, line, function), true); │ │ │ │ │ -41 } │ │ │ │ │ -42 │ │ │ │ │ -45 │ │ │ │ │ -49#define DUNE_ASSERT_CALL_ONCE() \ │ │ │ │ │ -50 ::Dune::assertCallOnce(__FILE__, __LINE__, __func__) │ │ │ │ │ -51 │ │ │ │ │ -52} // namespace Dune │ │ │ │ │ -53 │ │ │ │ │ -54#endif // DUNE_COMMON_STDTHREAD_HH │ │ │ │ │ +17#include │ │ │ │ │ +18#include │ │ │ │ │ +19#include │ │ │ │ │ +20 │ │ │ │ │ +21#include │ │ │ │ │ +22#include │ │ │ │ │ +23#include │ │ │ │ │ +24#include │ │ │ │ │ +25#include │ │ │ │ │ +26 │ │ │ │ │ +27namespace Dune { │ │ │ │ │ +28 namespace Simd { │ │ │ │ │ +29 namespace Overloads { │ │ │ │ │ +30 │ │ │ │ │ +47 template │ │ │ │ │ +48 decltype(auto) lane(ADLTag<0>, std::size_t l, V v) = delete; │ │ │ │ │ +49 │ │ │ │ │ +51 template │ │ │ │ │ +52 constexpr V implCast(ADLTag<0>, MetaType, const V &u) │ │ │ │ │ +53 { │ │ │ │ │ +54 return u; │ │ │ │ │ +55 } │ │ │ │ │ +56 │ │ │ │ │ +58 template │ │ │ │ │ +59 constexpr V implCast(ADLTag<0>, MetaType, const U &u) │ │ │ │ │ +60 { │ │ │ │ │ +61 V result(Simd::Scalar(0)); │ │ │ │ │ +62 for(auto l : range(Simd::lanes(u))) │ │ │ │ │ +63 Simd::lane(l, result) = Simd::lane(l, u); │ │ │ │ │ +64 return result; │ │ │ │ │ +65 } │ │ │ │ │ +66 │ │ │ │ │ +68 template │ │ │ │ │ +69 auto broadcast(ADLTag<0>, MetaType, S s) │ │ │ │ │ +70 { │ │ │ │ │ +71 return V(Simd::Scalar(s)); │ │ │ │ │ +72 } │ │ │ │ │ +73 │ │ │ │ │ +75 template │ │ │ │ │ +76 V cond(ADLTag<0>, const Mask &mask, │ │ │ │ │ +77 const V &ifTrue, const V &ifFalse) = delete; │ │ │ │ │ +78 │ │ │ │ │ +80 template │ │ │ │ │ +81 auto max(ADLTag<0>, const V &v1, const V &v2) │ │ │ │ │ +82 { │ │ │ │ │ +83 using std::max; │ │ │ │ │ +84 return max(v1, v2); │ │ │ │ │ +85 } │ │ │ │ │ +86 │ │ │ │ │ +88 template │ │ │ │ │ +89 auto min(ADLTag<0>, const V &v1, const V &v2) │ │ │ │ │ +90 { │ │ │ │ │ +91 using std::min; │ │ │ │ │ +92 return min(v1, v2); │ │ │ │ │ +93 } │ │ │ │ │ +94 │ │ │ │ │ +96 template │ │ │ │ │ +97 bool anyTrue(ADLTag<0>, const Mask &mask) = delete; │ │ │ │ │ +98 │ │ │ │ │ +100 │ │ │ │ │ +103 template │ │ │ │ │ +104 bool allTrue(ADLTag<0>, const Mask &mask) │ │ │ │ │ +105 { │ │ │ │ │ +106 return !Dune::Simd::anyTrue(!mask); │ │ │ │ │ +107 } │ │ │ │ │ +108 │ │ │ │ │ +110 │ │ │ │ │ +113 template │ │ │ │ │ +114 bool anyFalse(ADLTag<0>, const Mask &mask) │ │ │ │ │ +115 { │ │ │ │ │ +116 return Dune::Simd::anyTrue(!mask); │ │ │ │ │ +117 } │ │ │ │ │ +118 │ │ │ │ │ +120 │ │ │ │ │ +123 template │ │ │ │ │ +124 bool allFalse(ADLTag<0>, const Mask &mask) │ │ │ │ │ +125 { │ │ │ │ │ +126 return !Dune::Simd::anyTrue(mask); │ │ │ │ │ +127 } │ │ │ │ │ +128 │ │ │ │ │ +130 template │ │ │ │ │ +131 auto max(ADLTag<0>, const V &v) │ │ │ │ │ +132 { │ │ │ │ │ +133 Scalar m = Simd::lane(0, v); │ │ │ │ │ +134 for(std::size_t l = 1; l < Simd::lanes(v); ++l) │ │ │ │ │ +135 if(m < Simd::lane(l, v)) │ │ │ │ │ +136 m = Simd::lane(l, v); │ │ │ │ │ +137 return m; │ │ │ │ │ +138 } │ │ │ │ │ +139 │ │ │ │ │ +141 template │ │ │ │ │ +142 auto min(ADLTag<0>, const V &v) │ │ │ │ │ +143 { │ │ │ │ │ +144 Scalar m = Simd::lane(0, v); │ │ │ │ │ +145 for(std::size_t l = 1; l < Simd::lanes(v); ++l) │ │ │ │ │ +146 if(Simd::lane(l, v) < m) │ │ │ │ │ +147 m = Simd::lane(l, v); │ │ │ │ │ +148 return m; │ │ │ │ │ +149 } │ │ │ │ │ +150 │ │ │ │ │ +152 template │ │ │ │ │ +153 Mask mask(ADLTag<0, std::is_same >::value>, │ │ │ │ │ +154 const V &v) │ │ │ │ │ +155 { │ │ │ │ │ +156 return v; │ │ │ │ │ +157 } │ │ │ │ │ +158 │ │ │ │ │ +160 template │ │ │ │ │ +161 auto mask(ADLTag<0, !std::is_same >::value>, │ │ │ │ │ +162 const V &v) │ │ │ │ │ +163 { │ │ │ │ │ +164 using Copy = AutonomousValue; // just in case we are handed a proxy │ │ │ │ │ +165 return v != Copy(Scalar(0)); │ │ │ │ │ +166 } │ │ │ │ │ +167 │ │ │ │ │ +169 template │ │ │ │ │ +170 auto maskOr(ADLTag<0>, const V1 &v1, const V2 &v2) │ │ │ │ │ +171 { │ │ │ │ │ +172 return Simd::mask(v1) || Simd::mask(v2); │ │ │ │ │ +173 } │ │ │ │ │ +174 │ │ │ │ │ +176 template │ │ │ │ │ +177 auto maskAnd(ADLTag<0>, const V1 &v1, const V2 &v2) │ │ │ │ │ +178 { │ │ │ │ │ +179 return Simd::mask(v1) && Simd::mask(v2); │ │ │ │ │ +180 } │ │ │ │ │ +181 │ │ │ │ │ +184 } // namespace Overloads │ │ │ │ │ +185 } // namespace Simd │ │ │ │ │ +186} // namespace Dune │ │ │ │ │ +187 │ │ │ │ │ +188#endif // DUNE_COMMON_SIMD_DEFAULTS_HH │ │ │ │ │ +base.hh │ │ │ │ │ +Basic definitions for SIMD Implementations. │ │ │ │ │ +typelist.hh │ │ │ │ │ +rangeutilities.hh │ │ │ │ │ +Utilities for reduction like operations on ranges. │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +Dune::range │ │ │ │ │ +static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ +>, std::integral_constant< T, to >) noexcept │ │ │ │ │ +Definition rangeutilities.hh:312 │ │ │ │ │ +Dune::AutonomousValue │ │ │ │ │ +typename AutonomousValueType< T >::type AutonomousValue │ │ │ │ │ +Type free of internal references that T can be converted to. │ │ │ │ │ +Definition typetraits.hh:588 │ │ │ │ │ +Dune::Simd::anyTrue │ │ │ │ │ +bool anyTrue(const Mask &mask) │ │ │ │ │ +Whether any entry is true │ │ │ │ │ +Definition simd/interface.hh:429 │ │ │ │ │ +Dune::Simd::mask │ │ │ │ │ +auto mask(const V &v) │ │ │ │ │ +Convert to mask, analogue of bool(s) for scalars. │ │ │ │ │ +Definition simd/interface.hh:489 │ │ │ │ │ +Dune::Simd::lanes │ │ │ │ │ +constexpr std::size_t lanes() │ │ │ │ │ +Number of lanes in a SIMD type. │ │ │ │ │ +Definition simd/interface.hh:305 │ │ │ │ │ +Dune::Simd::lane │ │ │ │ │ +decltype(auto) lane(std::size_t l, V &&v) │ │ │ │ │ +Extract an element of a SIMD type. │ │ │ │ │ +Definition simd/interface.hh:324 │ │ │ │ │ +Dune::Simd::Mask │ │ │ │ │ +Rebind< bool, V > Mask │ │ │ │ │ +Mask type type of some SIMD type. │ │ │ │ │ +Definition simd/interface.hh:289 │ │ │ │ │ +Dune::Simd::Scalar │ │ │ │ │ +typename Overloads::ScalarType< std::decay_t< V > >::type Scalar │ │ │ │ │ +Element type of some SIMD type. │ │ │ │ │ +Definition simd/interface.hh:235 │ │ │ │ │ +Dune::Simd::Overloads::mask │ │ │ │ │ +Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v) │ │ │ │ │ +implements Simd::mask() │ │ │ │ │ +Definition defaults.hh:153 │ │ │ │ │ +Dune::Simd::Overloads::implCast │ │ │ │ │ +constexpr V implCast(ADLTag< 0 >, MetaType< V >, const V &u) │ │ │ │ │ +implements Simd::implCast(V) │ │ │ │ │ +Definition defaults.hh:52 │ │ │ │ │ +Dune::Simd::Overloads::allFalse │ │ │ │ │ +bool allFalse(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ +implements Simd::allFalse() │ │ │ │ │ +Definition defaults.hh:124 │ │ │ │ │ +Dune::Simd::Overloads::allTrue │ │ │ │ │ +bool allTrue(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ +implements Simd::allTrue() │ │ │ │ │ +Definition defaults.hh:104 │ │ │ │ │ +Dune::Simd::Overloads::maskAnd │ │ │ │ │ +auto maskAnd(ADLTag< 0 >, const V1 &v1, const V2 &v2) │ │ │ │ │ +implements Simd::maskAnd() │ │ │ │ │ +Definition defaults.hh:177 │ │ │ │ │ +Dune::Simd::Overloads::maskOr │ │ │ │ │ +auto maskOr(ADLTag< 0 >, const V1 &v1, const V2 &v2) │ │ │ │ │ +implements Simd::maskOr() │ │ │ │ │ +Definition defaults.hh:170 │ │ │ │ │ +Dune::Simd::Overloads::anyFalse │ │ │ │ │ +bool anyFalse(ADLTag< 0 >, const Mask &mask) │ │ │ │ │ +implements Simd::anyFalse() │ │ │ │ │ +Definition defaults.hh:114 │ │ │ │ │ +Dune::Simd::Overloads::min │ │ │ │ │ +auto min(ADLTag< 0 >, const V &v1, const V &v2) │ │ │ │ │ +implements binary Simd::min() │ │ │ │ │ +Definition defaults.hh:89 │ │ │ │ │ +Dune::Simd::Overloads::broadcast │ │ │ │ │ +auto broadcast(ADLTag< 0 >, MetaType< V >, S s) │ │ │ │ │ +implements Simd::broadcast() │ │ │ │ │ +Definition defaults.hh:69 │ │ │ │ │ +Dune::Simd::Overloads::max │ │ │ │ │ +auto max(ADLTag< 0 >, const V &v1, const V &v2) │ │ │ │ │ +implements binary Simd::max() │ │ │ │ │ +Definition defaults.hh:81 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::assertCallOnce │ │ │ │ │ -void assertCallOnce(const char *file=nullptr, int line=-1, const char │ │ │ │ │ -*function=nullptr) │ │ │ │ │ -Make sure call_once() works and provide a helpful error message otherwise. │ │ │ │ │ -Definition stdthread.hh:35 │ │ │ │ │ -Dune::doAssertCallOnce │ │ │ │ │ -void doAssertCallOnce(const char *file, int line, const char *function) │ │ │ │ │ -Definition stdthread.cc:38 │ │ │ │ │ +Dune::Simd::Overloads::anyTrue │ │ │ │ │ +bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask) │ │ │ │ │ +Definition debugalign.hh:556 │ │ │ │ │ +Dune::Simd::Overloads::cond │ │ │ │ │ +const AlignedNumber< T, align > & cond(ADLTag< 5 >, AlignedNumber< bool, align │ │ │ │ │ +> mask, const AlignedNumber< T, align > &ifTrue, const AlignedNumber< T, align │ │ │ │ │ +> &ifFalse) │ │ │ │ │ +Definition debugalign.hh:548 │ │ │ │ │ +Dune::Simd::Overloads::lane │ │ │ │ │ +T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ +Definition debugalign.hh:533 │ │ │ │ │ +Dune::Simd::Overloads::ADLTag │ │ │ │ │ +Tag used to force late-binding lookup in Dune::Simd::Overloads. │ │ │ │ │ +Definition base.hh:182 │ │ │ │ │ +Dune::MetaType │ │ │ │ │ +A type that refers to another type. │ │ │ │ │ +Definition typelist.hh:33 │ │ │ │ │ +interface.hh │ │ │ │ │ +User interface of the SIMD abstraction. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00020.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: reservedvector.hh File Reference │ │ │ │ +dune-common: base.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,77 +65,53 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Macros
│ │ │ │ -
reservedvector.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ + │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

An stl-compliant random-access container which stores everything on the stack. │ │ │ │ +

Basic definitions for SIMD Implementations. │ │ │ │ More...

│ │ │ │ -
#include <algorithm>
│ │ │ │ -#include <array>
│ │ │ │ -#include <cassert>
│ │ │ │ -#include <iostream>
│ │ │ │ -#include <iterator>
│ │ │ │ -#include <cstddef>
│ │ │ │ -#include <initializer_list>
│ │ │ │ -#include <dune/common/hash.hh>
│ │ │ │ -
│ │ │ │ + │ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::ReservedVector< T, n >
 A Vector class with statically reserved memory. More...
struct  Dune::Simd::Overloads::ADLTag< i >
 
struct  Dune::Simd::Overloads::ADLTag< 0 >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ -Macros

#define CHECKSIZE(X)   {}
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
 
namespace  Dune::Simd::Overloads
 Namespace for the overloads and specializations that make up a SIMD implementation.
 
│ │ │ │

Detailed Description

│ │ │ │ -

An stl-compliant random-access container which stores everything on the stack.

│ │ │ │ -

Macro Definition Documentation

│ │ │ │ - │ │ │ │ -

◆ CHECKSIZE

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define CHECKSIZE( X)   {}
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ +

Basic definitions for SIMD Implementations.

│ │ │ │ +

This file provides basic definitions and template declarations that are used to write SIMD abstraction layers.

│ │ │ │ +

This file should never be included by users of the SIMD abstraction. Include <dune/common/simd/simd.hh> instead.

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,37 +1,37 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Macros │ │ │ │ │ -reservedvector.hh File Reference │ │ │ │ │ -An stl-compliant random-access container which stores everything on the stack. │ │ │ │ │ -More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ + * simd │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +base.hh File Reference │ │ │ │ │ +Common » Vectorization » Abstraction_Developer's_Interface │ │ │ │ │ +Basic definitions for SIMD Implementations. More... │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::ReservedVector<_T,_n_> │ │ │ │ │ -  A Vector class with statically reserved memory. More... │ │ │ │ │ +struct   Dune::Simd::Overloads::ADLTag<_i_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::Simd::Overloads::ADLTag<_0_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Macros │ │ │ │ │ -#define  CHECKSIZE(X)   {} │ │ │ │ │ +namespace   Dune::Simd │ │ │ │ │ +  Namespace for vectorization interface functions used by library │ │ │ │ │ + developers. │ │ │ │ │ +  │ │ │ │ │ +namespace   Dune::Simd::Overloads │ │ │ │ │ +  Namespace for the overloads and specializations that make up a SIMD │ │ │ │ │ + implementation. │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -An stl-compliant random-access container which stores everything on the stack. │ │ │ │ │ -***** Macro Definition Documentation ***** │ │ │ │ │ -***** ◆ CHECKSIZE ***** │ │ │ │ │ -#define CHECKSIZE (   X )    {} │ │ │ │ │ +Basic definitions for SIMD Implementations. │ │ │ │ │ +This file provides basic definitions and template declarations that are used to │ │ │ │ │ +write SIMD abstraction layers. │ │ │ │ │ +This file should never be included by users of the SIMD abstraction. Include │ │ │ │ │ + instead. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00020_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: reservedvector.hh Source File │ │ │ │ +dune-common: base.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,532 +70,66 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
reservedvector.hh
│ │ │ │ +
base.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ -
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ -
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_RESERVEDVECTOR_HH
│ │ │ │ -
6#define DUNE_COMMON_RESERVEDVECTOR_HH
│ │ │ │ -
7
│ │ │ │ -
12#include <algorithm>
│ │ │ │ -
13#include <array>
│ │ │ │ -
14#include <cassert>
│ │ │ │ -
15#include <iostream>
│ │ │ │ -
16#include <iterator>
│ │ │ │ -
17#include <cstddef>
│ │ │ │ -
18#include <initializer_list>
│ │ │ │ -
19
│ │ │ │ -
20#include <dune/common/hash.hh>
│ │ │ │ -
21
│ │ │ │ -
22#ifdef CHECK_RESERVEDVECTOR
│ │ │ │ -
23#define CHECKSIZE(X) assert(X)
│ │ │ │ -
24#else
│ │ │ │ -
25#define CHECKSIZE(X) {}
│ │ │ │ -
26#endif
│ │ │ │ -
27
│ │ │ │ -
28namespace Dune
│ │ │ │ -
29{
│ │ │ │ -
45 template<class T, int n>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
47 {
│ │ │ │ -
48 using storage_type = std::array<T,n>;
│ │ │ │ -
49
│ │ │ │ -
50 public:
│ │ │ │ -
51
│ │ │ │ -
55 typedef typename storage_type::value_type value_type;
│ │ │ │ -
57 typedef typename storage_type::pointer pointer;
│ │ │ │ -
59 typedef typename storage_type::const_pointer const_pointer;
│ │ │ │ -
61 typedef typename storage_type::reference reference;
│ │ │ │ -
63 typedef typename storage_type::const_reference const_reference;
│ │ │ │ -
65 typedef typename storage_type::size_type size_type;
│ │ │ │ -
67 typedef typename storage_type::difference_type difference_type;
│ │ │ │ -
69 typedef typename storage_type::iterator iterator;
│ │ │ │ -
71 typedef typename storage_type::const_iterator const_iterator;
│ │ │ │ -
73 typedef std::reverse_iterator<iterator> reverse_iterator;
│ │ │ │ -
75 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
│ │ │ │ -
76
│ │ │ │ -
│ │ │ │ -
82 constexpr ReservedVector()
│ │ │ │ -
83 noexcept(std::is_nothrow_default_constructible_v<value_type>)
│ │ │ │ -
84 : storage_()
│ │ │ │ -
85 , size_(0)
│ │ │ │ -
86 {}
│ │ │ │ -
│ │ │ │ -
87
│ │ │ │ -
│ │ │ │ -
89 explicit constexpr ReservedVector(size_type count)
│ │ │ │ -
90 noexcept(std::is_nothrow_default_constructible_v<value_type>)
│ │ │ │ -
91 : storage_()
│ │ │ │ -
92 , size_(count)
│ │ │ │ -
93 {
│ │ │ │ -
94 assert(count <= n);
│ │ │ │ -
95 }
│ │ │ │ -
│ │ │ │ -
96
│ │ │ │ -
│ │ │ │ -
98 constexpr ReservedVector(size_type count, const value_type& value)
│ │ │ │ -
99 noexcept(std::is_nothrow_copy_assignable_v<value_type> &&
│ │ │ │ -
100 noexcept(ReservedVector(count)))
│ │ │ │ -
101 : ReservedVector(count)
│ │ │ │ -
102 {
│ │ │ │ -
103 for (size_type i=0; i<count; ++i)
│ │ │ │ -
104 storage_[i] = value;
│ │ │ │ -
105 }
│ │ │ │ -
│ │ │ │ -
106
│ │ │ │ -
108 template<class InputIt,
│ │ │ │ -
109 std::enable_if_t<std::is_convertible_v<typename std::iterator_traits<InputIt>::value_type, value_type>, int> = 0>
│ │ │ │ -
│ │ │ │ -
110 constexpr ReservedVector(InputIt first, InputIt last)
│ │ │ │ -
111 noexcept(std::is_nothrow_copy_assignable_v<value_type> &&
│ │ │ │ -
112 noexcept(ReservedVector()))
│ │ │ │ - │ │ │ │ -
114 {
│ │ │ │ -
115 for (size_type i=0; i<n && first!=last; ++i,++size_)
│ │ │ │ -
116 storage_[i] = *first++;
│ │ │ │ -
117 assert(first == last);
│ │ │ │ -
118 }
│ │ │ │ -
│ │ │ │ -
119
│ │ │ │ -
│ │ │ │ -
121 constexpr ReservedVector(std::initializer_list<value_type> const& l)
│ │ │ │ -
122 noexcept(std::is_nothrow_copy_assignable_v<value_type> &&
│ │ │ │ -
123 noexcept(ReservedVector(l.begin(),l.end())))
│ │ │ │ -
124 : ReservedVector(l.begin(),l.end())
│ │ │ │ -
125 {}
│ │ │ │ -
│ │ │ │ -
126
│ │ │ │ -
│ │ │ │ -
132 constexpr bool operator== (const ReservedVector& that) const noexcept
│ │ │ │ -
133 {
│ │ │ │ -
134 if (size() != that.size())
│ │ │ │ -
135 return false;
│ │ │ │ -
136 for (size_type i=0; i<size(); ++i)
│ │ │ │ -
137 if (!(storage_[i]==that.storage_[i]))
│ │ │ │ -
138 return false;
│ │ │ │ -
139 return true;
│ │ │ │ -
140 }
│ │ │ │ -
│ │ │ │ -
141
│ │ │ │ -
│ │ │ │ -
143 constexpr bool operator!= (const ReservedVector& that) const noexcept
│ │ │ │ -
144 {
│ │ │ │ -
145 return !(*this == that);
│ │ │ │ -
146 }
│ │ │ │ -
│ │ │ │ -
147
│ │ │ │ -
│ │ │ │ -
149 constexpr bool operator< (const ReservedVector& that) const noexcept
│ │ │ │ -
150 {
│ │ │ │ -
151 for (size_type i=0; i<std::min(size(),that.size()); ++i) {
│ │ │ │ -
152 if (storage_[i] < that.storage_[i]) return true;
│ │ │ │ -
153 if (that.storage_[i] < storage_[i]) return false;
│ │ │ │ -
154 }
│ │ │ │ -
155 return size() < that.size();
│ │ │ │ -
156 }
│ │ │ │ -
│ │ │ │ -
157
│ │ │ │ -
│ │ │ │ -
159 constexpr bool operator> (const ReservedVector& that) const noexcept
│ │ │ │ -
160 {
│ │ │ │ -
161 return that < *this;
│ │ │ │ -
162 }
│ │ │ │ -
│ │ │ │ -
163
│ │ │ │ -
│ │ │ │ -
165 constexpr bool operator<= (const ReservedVector& that) const noexcept
│ │ │ │ -
166 {
│ │ │ │ -
167 return !(*this > that);
│ │ │ │ -
168 }
│ │ │ │ -
│ │ │ │ -
169
│ │ │ │ -
│ │ │ │ -
171 constexpr bool operator>= (const ReservedVector& that) const noexcept
│ │ │ │ -
172 {
│ │ │ │ -
173 return !(*this < that);
│ │ │ │ -
174 }
│ │ │ │ -
│ │ │ │ -
175
│ │ │ │ -
│ │ │ │ -
181 constexpr void clear() noexcept
│ │ │ │ -
182 {
│ │ │ │ -
183 size_ = 0;
│ │ │ │ -
184 }
│ │ │ │ -
│ │ │ │ -
185
│ │ │ │ -
│ │ │ │ -
187 constexpr void resize(size_type s) noexcept
│ │ │ │ -
188 {
│ │ │ │ -
189 CHECKSIZE(s<=n);
│ │ │ │ -
190 size_ = s;
│ │ │ │ -
191 }
│ │ │ │ -
│ │ │ │ -
192
│ │ │ │ -
│ │ │ │ -
194 constexpr void push_back(const value_type& t)
│ │ │ │ -
195 noexcept(std::is_nothrow_copy_assignable_v<value_type>)
│ │ │ │ -
196 {
│ │ │ │ -
197 CHECKSIZE(size_<n);
│ │ │ │ -
198 storage_[size_++] = t;
│ │ │ │ -
199 }
│ │ │ │ -
│ │ │ │ -
200
│ │ │ │ -
│ │ │ │ -
202 constexpr void push_back(value_type&& t)
│ │ │ │ -
203 noexcept(std::is_nothrow_move_assignable_v<value_type>)
│ │ │ │ -
204 {
│ │ │ │ -
205 CHECKSIZE(size_<n);
│ │ │ │ -
206 storage_[size_++] = std::move(t);
│ │ │ │ -
207 }
│ │ │ │ -
│ │ │ │ -
208
│ │ │ │ -
210 template<class... Args>
│ │ │ │ -
│ │ │ │ -
211 reference emplace_back(Args&&... args)
│ │ │ │ -
212 noexcept(std::is_nothrow_constructible_v<value_type,decltype(args)...>)
│ │ │ │ -
213 {
│ │ │ │ -
214 CHECKSIZE(size_<n);
│ │ │ │ -
215 value_type* p = &storage_[size_++];
│ │ │ │ -
216 // first destroy any previously (default) constructed element at that location
│ │ │ │ -
217 p->~value_type();
│ │ │ │ -
218 // construct the value_type in place
│ │ │ │ -
219 // NOTE: This is not an integral constant expression.
│ │ │ │ -
220 // With c++20 we could use std::construct_at
│ │ │ │ -
221 ::new (const_cast<void*>(static_cast<const volatile void*>(p)))
│ │ │ │ -
222 value_type(std::forward<Args>(args)...);
│ │ │ │ -
223 return *p;
│ │ │ │ -
224 }
│ │ │ │ -
│ │ │ │ -
225
│ │ │ │ -
│ │ │ │ -
227 constexpr void pop_back() noexcept
│ │ │ │ -
228 {
│ │ │ │ -
229 if (! empty()) size_--;
│ │ │ │ -
230 }
│ │ │ │ -
│ │ │ │ -
231
│ │ │ │ -
│ │ │ │ -
237 constexpr iterator begin() noexcept
│ │ │ │ -
238 {
│ │ │ │ -
239 return storage_.begin();
│ │ │ │ -
240 }
│ │ │ │ -
│ │ │ │ -
241
│ │ │ │ -
│ │ │ │ -
243 constexpr const_iterator begin() const noexcept
│ │ │ │ -
244 {
│ │ │ │ -
245 return storage_.begin();
│ │ │ │ -
246 }
│ │ │ │ -
│ │ │ │ -
247
│ │ │ │ -
│ │ │ │ -
249 constexpr const_iterator cbegin() const noexcept
│ │ │ │ -
250 {
│ │ │ │ -
251 return storage_.cbegin();
│ │ │ │ -
252 }
│ │ │ │ -
│ │ │ │ -
253
│ │ │ │ -
│ │ │ │ -
255 constexpr reverse_iterator rbegin() noexcept
│ │ │ │ -
256 {
│ │ │ │ -
257 return reverse_iterator{begin()+size()};
│ │ │ │ -
258 }
│ │ │ │ -
│ │ │ │ -
259
│ │ │ │ -
│ │ │ │ -
261 constexpr const_reverse_iterator rbegin() const noexcept
│ │ │ │ -
262 {
│ │ │ │ - │ │ │ │ -
264 }
│ │ │ │ -
│ │ │ │ -
265
│ │ │ │ -
│ │ │ │ -
267 constexpr const_reverse_iterator crbegin() const noexcept
│ │ │ │ -
268 {
│ │ │ │ - │ │ │ │ -
270 }
│ │ │ │ -
│ │ │ │ -
271
│ │ │ │ -
│ │ │ │ -
273 constexpr iterator end() noexcept
│ │ │ │ -
274 {
│ │ │ │ -
275 return storage_.begin()+size();
│ │ │ │ -
276 }
│ │ │ │ -
│ │ │ │ -
277
│ │ │ │ -
│ │ │ │ -
279 constexpr const_iterator end() const noexcept
│ │ │ │ -
280 {
│ │ │ │ -
281 return storage_.begin()+size();
│ │ │ │ -
282 }
│ │ │ │ -
│ │ │ │ -
283
│ │ │ │ -
│ │ │ │ -
285 constexpr const_iterator cend() const noexcept
│ │ │ │ -
286 {
│ │ │ │ -
287 return storage_.cbegin()+size();
│ │ │ │ -
288 }
│ │ │ │ -
│ │ │ │ -
289
│ │ │ │ -
│ │ │ │ -
291 constexpr reverse_iterator rend() noexcept
│ │ │ │ -
292 {
│ │ │ │ -
293 return reverse_iterator{begin()};
│ │ │ │ -
294 }
│ │ │ │ -
│ │ │ │ -
295
│ │ │ │ -
│ │ │ │ -
297 constexpr const_reverse_iterator rend() const noexcept
│ │ │ │ -
298 {
│ │ │ │ - │ │ │ │ -
300 }
│ │ │ │ -
│ │ │ │ -
301
│ │ │ │ -
│ │ │ │ -
303 constexpr const_reverse_iterator crend() const noexcept
│ │ │ │ -
304 {
│ │ │ │ - │ │ │ │ -
306 }
│ │ │ │ -
│ │ │ │ -
307
│ │ │ │ -
│ │ │ │ -
313 constexpr reference at(size_type i)
│ │ │ │ -
314 {
│ │ │ │ -
315 if (!(i < size()))
│ │ │ │ -
316 throw std::out_of_range("Index out of range");
│ │ │ │ -
317 return storage_[i];
│ │ │ │ -
318 }
│ │ │ │ -
│ │ │ │ -
319
│ │ │ │ -
│ │ │ │ -
321 constexpr const_reference at(size_type i) const
│ │ │ │ -
322 {
│ │ │ │ -
323 if (!(i < size()))
│ │ │ │ -
324 throw std::out_of_range("Index out of range");
│ │ │ │ -
325 return storage_[i];
│ │ │ │ -
326 }
│ │ │ │ -
│ │ │ │ -
327
│ │ │ │ -
│ │ │ │ -
329 constexpr reference operator[] (size_type i) noexcept
│ │ │ │ -
330 {
│ │ │ │ -
331 CHECKSIZE(size_>i);
│ │ │ │ -
332 return storage_[i];
│ │ │ │ -
333 }
│ │ │ │ -
│ │ │ │ -
334
│ │ │ │ -
│ │ │ │ -
336 constexpr const_reference operator[] (size_type i) const noexcept
│ │ │ │ -
337 {
│ │ │ │ -
338 CHECKSIZE(size_>i);
│ │ │ │ -
339 return storage_[i];
│ │ │ │ -
340 }
│ │ │ │ -
│ │ │ │ -
341
│ │ │ │ -
│ │ │ │ -
343 constexpr reference front() noexcept
│ │ │ │ -
344 {
│ │ │ │ -
345 CHECKSIZE(size_>0);
│ │ │ │ -
346 return storage_[0];
│ │ │ │ -
347 }
│ │ │ │ -
│ │ │ │ -
348
│ │ │ │ -
│ │ │ │ -
350 constexpr const_reference front() const noexcept
│ │ │ │ -
351 {
│ │ │ │ -
352 CHECKSIZE(size_>0);
│ │ │ │ -
353 return storage_[0];
│ │ │ │ -
354 }
│ │ │ │ -
│ │ │ │ -
355
│ │ │ │ -
│ │ │ │ -
357 constexpr reference back() noexcept
│ │ │ │ -
358 {
│ │ │ │ -
359 CHECKSIZE(size_>0);
│ │ │ │ -
360 return storage_[size_-1];
│ │ │ │ -
361 }
│ │ │ │ -
│ │ │ │ -
362
│ │ │ │ -
│ │ │ │ -
364 constexpr const_reference back() const noexcept
│ │ │ │ -
365 {
│ │ │ │ -
366 CHECKSIZE(size_>0);
│ │ │ │ -
367 return storage_[size_-1];
│ │ │ │ -
368 }
│ │ │ │ -
│ │ │ │ -
369
│ │ │ │ -
│ │ │ │ -
371 constexpr pointer data() noexcept
│ │ │ │ -
372 {
│ │ │ │ -
373 return storage_.data();
│ │ │ │ -
374 }
│ │ │ │ -
│ │ │ │ -
375
│ │ │ │ -
│ │ │ │ -
377 constexpr const_pointer data() const noexcept
│ │ │ │ -
378 {
│ │ │ │ -
379 return storage_.data();
│ │ │ │ -
380 }
│ │ │ │ -
│ │ │ │ -
381
│ │ │ │ -
│ │ │ │ -
387 constexpr size_type size() const noexcept
│ │ │ │ -
388 {
│ │ │ │ -
389 return size_;
│ │ │ │ -
390 }
│ │ │ │ -
│ │ │ │ -
391
│ │ │ │ -
│ │ │ │ -
393 constexpr bool empty() const noexcept
│ │ │ │ -
394 {
│ │ │ │ -
395 return size_==0;
│ │ │ │ -
396 }
│ │ │ │ -
│ │ │ │ -
397
│ │ │ │ -
│ │ │ │ -
399 static constexpr size_type capacity() noexcept
│ │ │ │ -
400 {
│ │ │ │ -
401 return n;
│ │ │ │ -
402 }
│ │ │ │ -
│ │ │ │ -
403
│ │ │ │ -
│ │ │ │ -
405 static constexpr size_type max_size() noexcept
│ │ │ │ -
406 {
│ │ │ │ -
407 return n;
│ │ │ │ -
408 }
│ │ │ │ -
│ │ │ │ -
409
│ │ │ │ -
│ │ │ │ -
415 constexpr void fill(const value_type& value)
│ │ │ │ -
416 noexcept(std::is_nothrow_copy_assignable_v<value_type>)
│ │ │ │ -
417 {
│ │ │ │ -
418 for (size_type i=0; i<size(); ++i)
│ │ │ │ -
419 storage_[i] = value;
│ │ │ │ -
420 }
│ │ │ │ -
│ │ │ │ -
421
│ │ │ │ -
│ │ │ │ -
423 void swap(ReservedVector& other)
│ │ │ │ -
424 noexcept(std::is_nothrow_swappable_v<value_type>)
│ │ │ │ -
425 {
│ │ │ │ -
426 using std::swap;
│ │ │ │ -
427 swap(storage_, other.storage_);
│ │ │ │ -
428 swap(size_, other.size_);
│ │ │ │ -
429 }
│ │ │ │ -
│ │ │ │ -
430
│ │ │ │ -
│ │ │ │ -
434 friend std::ostream& operator<< (std::ostream& s, const ReservedVector& v)
│ │ │ │ -
435 {
│ │ │ │ -
436 for (size_type i=0; i<v.size(); i++)
│ │ │ │ -
437 s << v[i] << " ";
│ │ │ │ -
438 return s;
│ │ │ │ -
439 }
│ │ │ │ -
│ │ │ │ -
440
│ │ │ │ -
│ │ │ │ -
441 inline friend std::size_t hash_value(const ReservedVector& v) noexcept
│ │ │ │ -
442 {
│ │ │ │ -
443 return hash_range(v.storage_.data(),v.storage_.data()+v.size_);
│ │ │ │ -
444 }
│ │ │ │ -
│ │ │ │ -
445
│ │ │ │ -
446 private:
│ │ │ │ -
447 storage_type storage_;
│ │ │ │ -
448 size_type size_;
│ │ │ │ -
449 };
│ │ │ │ -
│ │ │ │ -
450
│ │ │ │ -
451}
│ │ │ │ -
452
│ │ │ │ - │ │ │ │ -
454
│ │ │ │ -
455#undef CHECKSIZE
│ │ │ │ -
456
│ │ │ │ -
457#endif // DUNE_COMMON_RESERVEDVECTOR_HH
│ │ │ │ -
#define CHECKSIZE(X)
Definition reservedvector.hh:25
│ │ │ │ -
Support for calculating hash values of objects.
│ │ │ │ -
#define DUNE_DEFINE_HASH(template_args, type)
Defines the required struct specialization to make type hashable via Dune::hash.
Definition hash.hh:100
│ │ │ │ -
#define DUNE_HASH_TYPE(...)
Wrapper macro for the type to be hashed in DUNE_DEFINE_HASH.
Definition hash.hh:117
│ │ │ │ -
#define DUNE_HASH_TEMPLATE_ARGS(...)
Wrapper macro for the template arguments in DUNE_DEFINE_HASH.
Definition hash.hh:109
│ │ │ │ -
STL namespace.
│ │ │ │ +Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
3#ifndef DUNE_COMMON_SIMD_BASE_HH
│ │ │ │ +
4#define DUNE_COMMON_SIMD_BASE_HH
│ │ │ │ +
5
│ │ │ │ +
92namespace Dune {
│ │ │ │ +
93 namespace Simd {
│ │ │ │ +
94
│ │ │ │ +
97
│ │ │ │ +
112 namespace Overloads {
│ │ │ │ +
113
│ │ │ │ +
116
│ │ │ │ +
118
│ │ │ │ +
181 template<unsigned i, bool = true>
│ │ │ │ +
182 struct ADLTag;
│ │ │ │ +
183
│ │ │ │ +
184 template<unsigned i>
│ │ │ │ +
185 struct ADLTag<i> : ADLTag<i-1> {};
│ │ │ │ +
186
│ │ │ │ +
187 template<>
│ │ │ │ +
188 struct ADLTag<0> {};
│ │ │ │ +
189
│ │ │ │ +
191
│ │ │ │ +
195 template<class V, class SFINAETag = void>
│ │ │ │ +
196 struct ScalarType;
│ │ │ │ +
197
│ │ │ │ +
199
│ │ │ │ +
203 template<class S, class V, class SFINAETag = void>
│ │ │ │ +
204 struct RebindType;
│ │ │ │ +
205
│ │ │ │ +
207
│ │ │ │ +
211 template<class V, class SFINAETag = void>
│ │ │ │ +
212 struct LaneCount;
│ │ │ │ +
213
│ │ │ │ +
215
│ │ │ │ +
216 } // namespace Overloads
│ │ │ │ +
217 } // namespace Simd
│ │ │ │ +
218} // namespace Dune
│ │ │ │ +
219
│ │ │ │ +
220#endif // DUNE_COMMON_SIMD_BASE_HH
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
std::size_t hash_range(It first, It last)
Hashes all elements in the range [first,last) and returns the combined hash.
Definition hash.hh:322
│ │ │ │ -
A Vector class with statically reserved memory.
Definition reservedvector.hh:47
│ │ │ │ -
constexpr const_reference front() const noexcept
Returns const reference to first element of vector.
Definition reservedvector.hh:350
│ │ │ │ -
constexpr const_reverse_iterator crend() const noexcept
Returns a const reverse-iterator pointing to the begin of the vector.
Definition reservedvector.hh:303
│ │ │ │ -
constexpr ReservedVector(size_type count) noexcept(std::is_nothrow_default_constructible_v< value_type >)
Constructs the vector with count elements that will be default-initialized.
Definition reservedvector.hh:89
│ │ │ │ -
constexpr void fill(const value_type &value) noexcept(std::is_nothrow_copy_assignable_v< value_type >)
Fill the container with the value.
Definition reservedvector.hh:415
│ │ │ │ -
storage_type::pointer pointer
Pointer to T.
Definition reservedvector.hh:57
│ │ │ │ -
constexpr reverse_iterator rbegin() noexcept
Returns a const reverse-iterator pointing to the end of the vector.
Definition reservedvector.hh:255
│ │ │ │ -
constexpr bool operator<=(const ReservedVector &that) const noexcept
Lexicographically compares the values in the vector this with that
Definition reservedvector.hh:165
│ │ │ │ -
constexpr bool operator>(const ReservedVector &that) const noexcept
Lexicographically compares the values in the vector this with that
Definition reservedvector.hh:159
│ │ │ │ -
constexpr const_reverse_iterator rend() const noexcept
Returns a const reverse-iterator pointing to the begin of the vector.
Definition reservedvector.hh:297
│ │ │ │ -
static constexpr size_type max_size() noexcept
Returns the maximum length of the vector.
Definition reservedvector.hh:405
│ │ │ │ -
constexpr const_reference at(size_type i) const
Returns a const reference to the i'th element.
Definition reservedvector.hh:321
│ │ │ │ -
std::reverse_iterator< iterator > reverse_iterator
Reverse iterator.
Definition reservedvector.hh:73
│ │ │ │ -
constexpr iterator end() noexcept
Returns an iterator pointing to the end of the vector.
Definition reservedvector.hh:273
│ │ │ │ -
constexpr bool operator<(const ReservedVector &that) const noexcept
Lexicographically compares the values in the vector this with that
Definition reservedvector.hh:149
│ │ │ │ -
constexpr size_type size() const noexcept
Returns number of elements in the vector.
Definition reservedvector.hh:387
│ │ │ │ -
constexpr bool empty() const noexcept
Returns true if vector has no elements.
Definition reservedvector.hh:393
│ │ │ │ -
constexpr iterator begin() noexcept
Returns a iterator pointing to the beginning of the vector.
Definition reservedvector.hh:237
│ │ │ │ -
constexpr void push_back(const value_type &t) noexcept(std::is_nothrow_copy_assignable_v< value_type >)
Appends an element to the end of a vector, up to the maximum size n, O(1) time.
Definition reservedvector.hh:194
│ │ │ │ -
constexpr reverse_iterator rend() noexcept
Returns a const reverse-iterator pointing to the begin of the vector.
Definition reservedvector.hh:291
│ │ │ │ -
storage_type::iterator iterator
Iterator used to iterate through a vector.
Definition reservedvector.hh:69
│ │ │ │ -
constexpr const_iterator cbegin() const noexcept
Returns a const_iterator pointing to the beginning of the vector.
Definition reservedvector.hh:249
│ │ │ │ -
std::reverse_iterator< const_iterator > const_reverse_iterator
Const reverse iterator.
Definition reservedvector.hh:75
│ │ │ │ -
constexpr pointer data() noexcept
Returns pointer to the underlying memory.
Definition reservedvector.hh:371
│ │ │ │ -
constexpr const_reference back() const noexcept
Returns const reference to last element of vector.
Definition reservedvector.hh:364
│ │ │ │ -
friend std::ostream & operator<<(std::ostream &s, const ReservedVector &v)
Send ReservedVector to an output stream.
Definition reservedvector.hh:434
│ │ │ │ -
constexpr bool operator==(const ReservedVector &that) const noexcept
Compares the values in the vector this with that for equality.
Definition reservedvector.hh:132
│ │ │ │ -
constexpr void pop_back() noexcept
Erases the last element of the vector, O(1) time.
Definition reservedvector.hh:227
│ │ │ │ -
friend std::size_t hash_value(const ReservedVector &v) noexcept
Definition reservedvector.hh:441
│ │ │ │ -
storage_type::difference_type difference_type
A signed integral type.
Definition reservedvector.hh:67
│ │ │ │ -
constexpr const_iterator end() const noexcept
Returns a const_iterator pointing to the end of the vector.
Definition reservedvector.hh:279
│ │ │ │ -
constexpr void clear() noexcept
Erases all elements.
Definition reservedvector.hh:181
│ │ │ │ -
constexpr ReservedVector() noexcept(std::is_nothrow_default_constructible_v< value_type >)
Constructs an empty vector.
Definition reservedvector.hh:82
│ │ │ │ -
storage_type::const_iterator const_iterator
Const iterator used to iterate through a vector.
Definition reservedvector.hh:71
│ │ │ │ -
reference emplace_back(Args &&... args) noexcept(std::is_nothrow_constructible_v< value_type, decltype(args)... >)
Appends an element to the end of a vector by constructing it in place.
Definition reservedvector.hh:211
│ │ │ │ -
storage_type::size_type size_type
An unsigned integral type.
Definition reservedvector.hh:65
│ │ │ │ -
constexpr bool operator>=(const ReservedVector &that) const noexcept
Lexicographically compares the values in the vector this with that
Definition reservedvector.hh:171
│ │ │ │ -
storage_type::const_reference const_reference
Const reference to T.
Definition reservedvector.hh:63
│ │ │ │ -
void swap(ReservedVector &other) noexcept(std::is_nothrow_swappable_v< value_type >)
Swap the content with another vector.
Definition reservedvector.hh:423
│ │ │ │ -
constexpr ReservedVector(InputIt first, InputIt last) noexcept(std::is_nothrow_copy_assignable_v< value_type > &&noexcept(ReservedVector()))
Constructs the vector from an iterator range [first,last)
Definition reservedvector.hh:110
│ │ │ │ -
constexpr const_pointer data() const noexcept
Returns const pointer to the underlying memory.
Definition reservedvector.hh:377
│ │ │ │ -
constexpr reference at(size_type i)
Returns reference to the i'th element.
Definition reservedvector.hh:313
│ │ │ │ -
constexpr const_iterator cend() const noexcept
Returns a const_iterator pointing to the end of the vector.
Definition reservedvector.hh:285
│ │ │ │ -
constexpr reference back() noexcept
Returns reference to last element of vector.
Definition reservedvector.hh:357
│ │ │ │ -
constexpr const_reverse_iterator rbegin() const noexcept
Returns a const reverse-iterator pointing to the end of the vector.
Definition reservedvector.hh:261
│ │ │ │ -
storage_type::value_type value_type
The type of object, T, stored in the vector.
Definition reservedvector.hh:55
│ │ │ │ -
constexpr const_iterator begin() const noexcept
Returns a const_iterator pointing to the beginning of the vector.
Definition reservedvector.hh:243
│ │ │ │ -
constexpr ReservedVector(size_type count, const value_type &value) noexcept(std::is_nothrow_copy_assignable_v< value_type > &&noexcept(ReservedVector(count)))
Constructs the vector with count copies of elements with value value.
Definition reservedvector.hh:98
│ │ │ │ -
constexpr reference operator[](size_type i) noexcept
Returns reference to the i'th element.
Definition reservedvector.hh:329
│ │ │ │ -
constexpr reference front() noexcept
Returns reference to first element of vector.
Definition reservedvector.hh:343
│ │ │ │ -
storage_type::const_pointer const_pointer
Const pointer to T.
Definition reservedvector.hh:59
│ │ │ │ -
constexpr ReservedVector(std::initializer_list< value_type > const &l) noexcept(std::is_nothrow_copy_assignable_v< value_type > &&noexcept(ReservedVector(l.begin(), l.end())))
Constructs the vector from an initializer list.
Definition reservedvector.hh:121
│ │ │ │ -
constexpr bool operator!=(const ReservedVector &that) const noexcept
Compares the values in the vector this with that for not equality.
Definition reservedvector.hh:143
│ │ │ │ -
constexpr void resize(size_type s) noexcept
Specifies a new size for the vector.
Definition reservedvector.hh:187
│ │ │ │ -
static constexpr size_type capacity() noexcept
Returns current capacity (allocated memory) of the vector.
Definition reservedvector.hh:399
│ │ │ │ -
storage_type::reference reference
Reference to T.
Definition reservedvector.hh:61
│ │ │ │ -
constexpr const_reverse_iterator crbegin() const noexcept
Returns a const reverse-iterator pointing to the end of the vector.
Definition reservedvector.hh:267
│ │ │ │ -
constexpr void push_back(value_type &&t) noexcept(std::is_nothrow_move_assignable_v< value_type >)
Appends an element to the end of a vector by moving the value, up to the maximum size n,...
Definition reservedvector.hh:202
│ │ │ │ +
Tag used to force late-binding lookup in Dune::Simd::Overloads.
Definition base.hh:182
│ │ │ │ +
should have a member type type
Definition standard.hh:60
│ │ │ │ +
should have a member type type
Definition standard.hh:67
│ │ │ │ +
should be derived from a Dune::index_constant
Definition standard.hh:74
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,633 +1,67 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -reservedvector.hh │ │ │ │ │ + * simd │ │ │ │ │ +base.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ -2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ -3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_RESERVEDVECTOR_HH │ │ │ │ │ -6#define DUNE_COMMON_RESERVEDVECTOR_HH │ │ │ │ │ -7 │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18#include │ │ │ │ │ -19 │ │ │ │ │ -20#include │ │ │ │ │ -21 │ │ │ │ │ -22#ifdef CHECK_RESERVEDVECTOR │ │ │ │ │ -23#define CHECKSIZE(X) assert(X) │ │ │ │ │ -24#else │ │ │ │ │ -25#define CHECKSIZE(X) {} │ │ │ │ │ -26#endif │ │ │ │ │ -27 │ │ │ │ │ -28namespace Dune │ │ │ │ │ -29{ │ │ │ │ │ -45 template │ │ │ │ │ -46 class ReservedVector │ │ │ │ │ -47 { │ │ │ │ │ -48 using storage_type = std::array; │ │ │ │ │ -49 │ │ │ │ │ -50 public: │ │ │ │ │ -51 │ │ │ │ │ -55 typedef typename storage_type::value_type value_type; │ │ │ │ │ -57 typedef typename storage_type::pointer pointer; │ │ │ │ │ -59 typedef typename storage_type::const_pointer const_pointer; │ │ │ │ │ -61 typedef typename storage_type::reference reference; │ │ │ │ │ -63 typedef typename storage_type::const_reference const_reference; │ │ │ │ │ -65 typedef typename storage_type::size_type size_type; │ │ │ │ │ -67 typedef typename storage_type::difference_type difference_type; │ │ │ │ │ -69 typedef typename storage_type::iterator iterator; │ │ │ │ │ -71 typedef typename storage_type::const_iterator const_iterator; │ │ │ │ │ -73 typedef std::reverse_iterator reverse_iterator; │ │ │ │ │ -75 typedef std::reverse_iterator const_reverse_iterator; │ │ │ │ │ -76 │ │ │ │ │ -82 constexpr ReservedVector() │ │ │ │ │ -83 noexcept(std::is_nothrow_default_constructible_v) │ │ │ │ │ -84 : storage_() │ │ │ │ │ -85 , size_(0) │ │ │ │ │ -86 {} │ │ │ │ │ -87 │ │ │ │ │ -89 explicit constexpr ReservedVector(size_type count) │ │ │ │ │ -90 noexcept(std::is_nothrow_default_constructible_v) │ │ │ │ │ -91 : storage_() │ │ │ │ │ -92 , size_(count) │ │ │ │ │ -93 { │ │ │ │ │ -94 assert(count <= n); │ │ │ │ │ -95 } │ │ │ │ │ -96 │ │ │ │ │ -98 constexpr ReservedVector(size_type count, const value_type& value) │ │ │ │ │ -99 noexcept(std::is_nothrow_copy_assignable_v && │ │ │ │ │ -100 noexcept(ReservedVector(count))) │ │ │ │ │ -101 : ReservedVector(count) │ │ │ │ │ -102 { │ │ │ │ │ -103 for (size_type i=0; i::value_type, value_type>, int> = 0> │ │ │ │ │ -110 constexpr ReservedVector(InputIt first, InputIt last) │ │ │ │ │ -111 noexcept(std::is_nothrow_copy_assignable_v && │ │ │ │ │ -112 noexcept(ReservedVector())) │ │ │ │ │ -113 : ReservedVector() │ │ │ │ │ -114 { │ │ │ │ │ -115 for (size_type i=0; i const& l) │ │ │ │ │ -122 noexcept(std::is_nothrow_copy_assignable_v && │ │ │ │ │ -123 noexcept(ReservedVector(l.begin(),l.end()))) │ │ │ │ │ -124 : ReservedVector(l.begin(),l.end()) │ │ │ │ │ -125 {} │ │ │ │ │ -126 │ │ │ │ │ -132 constexpr bool operator==_(const ReservedVector& that) const noexcept │ │ │ │ │ -133 { │ │ │ │ │ -134 if (size() != that.size()) │ │ │ │ │ -135 return false; │ │ │ │ │ -136 for (size_type i=0; i_(const ReservedVector& that) const noexcept │ │ │ │ │ -160 { │ │ │ │ │ -161 return that < *this; │ │ │ │ │ -162 } │ │ │ │ │ -163 │ │ │ │ │ -165 constexpr bool operator<=_(const ReservedVector& that) const noexcept │ │ │ │ │ -166 { │ │ │ │ │ -167 return !(*this > that); │ │ │ │ │ -168 } │ │ │ │ │ -169 │ │ │ │ │ -171 constexpr bool operator>=_(const ReservedVector& that) const noexcept │ │ │ │ │ -172 { │ │ │ │ │ -173 return !(*this < that); │ │ │ │ │ -174 } │ │ │ │ │ -175 │ │ │ │ │ -181 constexpr void clear() noexcept │ │ │ │ │ -182 { │ │ │ │ │ -183 size_ = 0; │ │ │ │ │ -184 } │ │ │ │ │ -185 │ │ │ │ │ -187 constexpr void resize(size_type s) noexcept │ │ │ │ │ -188 { │ │ │ │ │ -189 CHECKSIZE(s<=n); │ │ │ │ │ -190 size_ = s; │ │ │ │ │ -191 } │ │ │ │ │ -192 │ │ │ │ │ -194 constexpr void push_back(const value_type& t) │ │ │ │ │ -195 noexcept(std::is_nothrow_copy_assignable_v) │ │ │ │ │ -196 { │ │ │ │ │ -197 CHECKSIZE(size_) │ │ │ │ │ -204 { │ │ │ │ │ -205 CHECKSIZE(size_ │ │ │ │ │ -211 reference emplace_back(Args&&... args) │ │ │ │ │ -212 noexcept(std::is_nothrow_constructible_v) │ │ │ │ │ -213 { │ │ │ │ │ -214 CHECKSIZE(size_~value_type(); │ │ │ │ │ -218 // construct the value_type in place │ │ │ │ │ -219 // NOTE: This is not an integral constant expression. │ │ │ │ │ -220 // With c++20 we could use std::construct_at │ │ │ │ │ -221 ::new (const_cast(static_cast(p))) │ │ │ │ │ -222 value_type(std::forward(args)...); │ │ │ │ │ -223 return *p; │ │ │ │ │ -224 } │ │ │ │ │ -225 │ │ │ │ │ -227 constexpr void pop_back() noexcept │ │ │ │ │ -228 { │ │ │ │ │ -229 if (! empty()) size_--; │ │ │ │ │ -230 } │ │ │ │ │ -231 │ │ │ │ │ -237 constexpr iterator begin() noexcept │ │ │ │ │ -238 { │ │ │ │ │ -239 return storage_.begin(); │ │ │ │ │ -240 } │ │ │ │ │ -241 │ │ │ │ │ -243 constexpr const_iterator begin() const noexcept │ │ │ │ │ -244 { │ │ │ │ │ -245 return storage_.begin(); │ │ │ │ │ -246 } │ │ │ │ │ -247 │ │ │ │ │ -249 constexpr const_iterator cbegin() const noexcept │ │ │ │ │ -250 { │ │ │ │ │ -251 return storage_.cbegin(); │ │ │ │ │ -252 } │ │ │ │ │ -253 │ │ │ │ │ -255 constexpr reverse_iterator rbegin() noexcept │ │ │ │ │ -256 { │ │ │ │ │ -257 return reverse_iterator{begin()+size()}; │ │ │ │ │ -258 } │ │ │ │ │ -259 │ │ │ │ │ -261 constexpr const_reverse_iterator rbegin() const noexcept │ │ │ │ │ -262 { │ │ │ │ │ -263 return const_reverse_iterator{begin()+size()}; │ │ │ │ │ -264 } │ │ │ │ │ -265 │ │ │ │ │ -267 constexpr const_reverse_iterator crbegin() const noexcept │ │ │ │ │ -268 { │ │ │ │ │ -269 return const_reverse_iterator{begin()+size()}; │ │ │ │ │ -270 } │ │ │ │ │ -271 │ │ │ │ │ -273 constexpr iterator end() noexcept │ │ │ │ │ -274 { │ │ │ │ │ -275 return storage_.begin()+size(); │ │ │ │ │ -276 } │ │ │ │ │ -277 │ │ │ │ │ -279 constexpr const_iterator end() const noexcept │ │ │ │ │ -280 { │ │ │ │ │ -281 return storage_.begin()+size(); │ │ │ │ │ -282 } │ │ │ │ │ -283 │ │ │ │ │ -285 constexpr const_iterator cend() const noexcept │ │ │ │ │ -286 { │ │ │ │ │ -287 return storage_.cbegin()+size(); │ │ │ │ │ -288 } │ │ │ │ │ -289 │ │ │ │ │ -291 constexpr reverse_iterator rend() noexcept │ │ │ │ │ -292 { │ │ │ │ │ -293 return reverse_iterator{begin()}; │ │ │ │ │ -294 } │ │ │ │ │ -295 │ │ │ │ │ -297 constexpr const_reverse_iterator rend() const noexcept │ │ │ │ │ -298 { │ │ │ │ │ -299 return const_reverse_iterator{begin()}; │ │ │ │ │ -300 } │ │ │ │ │ -301 │ │ │ │ │ -303 constexpr const_reverse_iterator crend() const noexcept │ │ │ │ │ -304 { │ │ │ │ │ -305 return const_reverse_iterator{begin()}; │ │ │ │ │ -306 } │ │ │ │ │ -307 │ │ │ │ │ -313 constexpr reference at(size_type i) │ │ │ │ │ -314 { │ │ │ │ │ -315 if (!(i < size())) │ │ │ │ │ -316 throw std::out_of_range("Index out of range"); │ │ │ │ │ -317 return storage_[i]; │ │ │ │ │ -318 } │ │ │ │ │ -319 │ │ │ │ │ -321 constexpr const_reference at(size_type i) const │ │ │ │ │ -322 { │ │ │ │ │ -323 if (!(i < size())) │ │ │ │ │ -324 throw std::out_of_range("Index out of range"); │ │ │ │ │ -325 return storage_[i]; │ │ │ │ │ -326 } │ │ │ │ │ -327 │ │ │ │ │ -329 constexpr reference operator[]_(size_type i) noexcept │ │ │ │ │ -330 { │ │ │ │ │ -331 CHECKSIZE(size_>i); │ │ │ │ │ -332 return storage_[i]; │ │ │ │ │ -333 } │ │ │ │ │ -334 │ │ │ │ │ -336 constexpr const_reference operator[]_(size_type i) const noexcept │ │ │ │ │ -337 { │ │ │ │ │ -338 CHECKSIZE(size_>i); │ │ │ │ │ -339 return storage_[i]; │ │ │ │ │ -340 } │ │ │ │ │ -341 │ │ │ │ │ -343 constexpr reference front() noexcept │ │ │ │ │ -344 { │ │ │ │ │ -345 CHECKSIZE(size_>0); │ │ │ │ │ -346 return storage_[0]; │ │ │ │ │ -347 } │ │ │ │ │ -348 │ │ │ │ │ -350 constexpr const_reference front() const noexcept │ │ │ │ │ -351 { │ │ │ │ │ -352 CHECKSIZE(size_>0); │ │ │ │ │ -353 return storage_[0]; │ │ │ │ │ -354 } │ │ │ │ │ -355 │ │ │ │ │ -357 constexpr reference back() noexcept │ │ │ │ │ -358 { │ │ │ │ │ -359 CHECKSIZE(size_>0); │ │ │ │ │ -360 return storage_[size_-1]; │ │ │ │ │ -361 } │ │ │ │ │ -362 │ │ │ │ │ -364 constexpr const_reference back() const noexcept │ │ │ │ │ -365 { │ │ │ │ │ -366 CHECKSIZE(size_>0); │ │ │ │ │ -367 return storage_[size_-1]; │ │ │ │ │ -368 } │ │ │ │ │ -369 │ │ │ │ │ -371 constexpr pointer data() noexcept │ │ │ │ │ -372 { │ │ │ │ │ -373 return storage_.data(); │ │ │ │ │ -374 } │ │ │ │ │ -375 │ │ │ │ │ -377 constexpr const_pointer data() const noexcept │ │ │ │ │ -378 { │ │ │ │ │ -379 return storage_.data(); │ │ │ │ │ -380 } │ │ │ │ │ -381 │ │ │ │ │ -387 constexpr size_type size() const noexcept │ │ │ │ │ -388 { │ │ │ │ │ -389 return size_; │ │ │ │ │ -390 } │ │ │ │ │ -391 │ │ │ │ │ -393 constexpr bool empty() const noexcept │ │ │ │ │ -394 { │ │ │ │ │ -395 return size_==0; │ │ │ │ │ -396 } │ │ │ │ │ -397 │ │ │ │ │ -399 static constexpr size_type capacity() noexcept │ │ │ │ │ -400 { │ │ │ │ │ -401 return n; │ │ │ │ │ -402 } │ │ │ │ │ -403 │ │ │ │ │ -405 static constexpr size_type max_size() noexcept │ │ │ │ │ -406 { │ │ │ │ │ -407 return n; │ │ │ │ │ -408 } │ │ │ │ │ -409 │ │ │ │ │ -415 constexpr void fill(const value_type& value) │ │ │ │ │ -416 noexcept(std::is_nothrow_copy_assignable_v) │ │ │ │ │ -417 { │ │ │ │ │ -418 for (size_type i=0; i) │ │ │ │ │ -425 { │ │ │ │ │ -426 using std::swap; │ │ │ │ │ -427 swap(storage_, other.storage_); │ │ │ │ │ -428 swap(size_, other.size_); │ │ │ │ │ -429 } │ │ │ │ │ -430 │ │ │ │ │ -434 friend std::ostream& operator<<_(std::ostream& s, const ReservedVector& v) │ │ │ │ │ -435 { │ │ │ │ │ -436 for (size_type i=0; i)) │ │ │ │ │ -454 │ │ │ │ │ -455#undef CHECKSIZE │ │ │ │ │ -456 │ │ │ │ │ -457#endif // DUNE_COMMON_RESERVEDVECTOR_HH │ │ │ │ │ -CHECKSIZE │ │ │ │ │ -#define CHECKSIZE(X) │ │ │ │ │ -Definition reservedvector.hh:25 │ │ │ │ │ -hash.hh │ │ │ │ │ -Support for calculating hash values of objects. │ │ │ │ │ -DUNE_DEFINE_HASH │ │ │ │ │ -#define DUNE_DEFINE_HASH(template_args, type) │ │ │ │ │ -Defines the required struct specialization to make type hashable via Dune:: │ │ │ │ │ -hash. │ │ │ │ │ -Definition hash.hh:100 │ │ │ │ │ -DUNE_HASH_TYPE │ │ │ │ │ -#define DUNE_HASH_TYPE(...) │ │ │ │ │ -Wrapper macro for the type to be hashed in DUNE_DEFINE_HASH. │ │ │ │ │ -Definition hash.hh:117 │ │ │ │ │ -DUNE_HASH_TEMPLATE_ARGS │ │ │ │ │ -#define DUNE_HASH_TEMPLATE_ARGS(...) │ │ │ │ │ -Wrapper macro for the template arguments in DUNE_DEFINE_HASH. │ │ │ │ │ -Definition hash.hh:109 │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ +2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +3#ifndef DUNE_COMMON_SIMD_BASE_HH │ │ │ │ │ +4#define DUNE_COMMON_SIMD_BASE_HH │ │ │ │ │ +5 │ │ │ │ │ +92namespace Dune { │ │ │ │ │ +93 namespace Simd { │ │ │ │ │ +94 │ │ │ │ │ +97 │ │ │ │ │ +112 namespace Overloads { │ │ │ │ │ +113 │ │ │ │ │ +116 │ │ │ │ │ +118 │ │ │ │ │ +181 template │ │ │ │ │ +182 struct ADLTag; │ │ │ │ │ +183 │ │ │ │ │ +184 template │ │ │ │ │ +185 struct ADLTag : ADLTag {}; │ │ │ │ │ +186 │ │ │ │ │ +187 template<> │ │ │ │ │ +188 struct ADLTag<0> {}; │ │ │ │ │ +189 │ │ │ │ │ +191 │ │ │ │ │ +195 template │ │ │ │ │ +196 struct ScalarType; │ │ │ │ │ +197 │ │ │ │ │ +199 │ │ │ │ │ +203 template │ │ │ │ │ +204 struct RebindType; │ │ │ │ │ +205 │ │ │ │ │ +207 │ │ │ │ │ +211 template │ │ │ │ │ +212 struct LaneCount; │ │ │ │ │ +213 │ │ │ │ │ +215 │ │ │ │ │ +216 } // namespace Overloads │ │ │ │ │ +217 } // namespace Simd │ │ │ │ │ +218} // namespace Dune │ │ │ │ │ +219 │ │ │ │ │ +220#endif // DUNE_COMMON_SIMD_BASE_HH │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::hash_range │ │ │ │ │ -std::size_t hash_range(It first, It last) │ │ │ │ │ -Hashes all elements in the range [first,last) and returns the combined hash. │ │ │ │ │ -Definition hash.hh:322 │ │ │ │ │ -Dune::ReservedVector │ │ │ │ │ -A Vector class with statically reserved memory. │ │ │ │ │ -Definition reservedvector.hh:47 │ │ │ │ │ -Dune::ReservedVector::front │ │ │ │ │ -constexpr const_reference front() const noexcept │ │ │ │ │ -Returns const reference to first element of vector. │ │ │ │ │ -Definition reservedvector.hh:350 │ │ │ │ │ -Dune::ReservedVector::crend │ │ │ │ │ -constexpr const_reverse_iterator crend() const noexcept │ │ │ │ │ -Returns a const reverse-iterator pointing to the begin of the vector. │ │ │ │ │ -Definition reservedvector.hh:303 │ │ │ │ │ -Dune::ReservedVector::ReservedVector │ │ │ │ │ -constexpr ReservedVector(size_type count) noexcept(std::is_nothrow_default_ │ │ │ │ │ -constructible_v< value_type >) │ │ │ │ │ -Constructs the vector with count elements that will be default-initialized. │ │ │ │ │ -Definition reservedvector.hh:89 │ │ │ │ │ -Dune::ReservedVector::fill │ │ │ │ │ -constexpr void fill(const value_type &value) noexcept(std::is_nothrow_copy_ │ │ │ │ │ -assignable_v< value_type >) │ │ │ │ │ -Fill the container with the value. │ │ │ │ │ -Definition reservedvector.hh:415 │ │ │ │ │ -Dune::ReservedVector::pointer │ │ │ │ │ -storage_type::pointer pointer │ │ │ │ │ -Pointer to T. │ │ │ │ │ -Definition reservedvector.hh:57 │ │ │ │ │ -Dune::ReservedVector::rbegin │ │ │ │ │ -constexpr reverse_iterator rbegin() noexcept │ │ │ │ │ -Returns a const reverse-iterator pointing to the end of the vector. │ │ │ │ │ -Definition reservedvector.hh:255 │ │ │ │ │ -Dune::ReservedVector::operator<= │ │ │ │ │ -constexpr bool operator<=(const ReservedVector &that) const noexcept │ │ │ │ │ -Lexicographically compares the values in the vector this with that │ │ │ │ │ -Definition reservedvector.hh:165 │ │ │ │ │ -Dune::ReservedVector::operator> │ │ │ │ │ -constexpr bool operator>(const ReservedVector &that) const noexcept │ │ │ │ │ -Lexicographically compares the values in the vector this with that │ │ │ │ │ -Definition reservedvector.hh:159 │ │ │ │ │ -Dune::ReservedVector::rend │ │ │ │ │ -constexpr const_reverse_iterator rend() const noexcept │ │ │ │ │ -Returns a const reverse-iterator pointing to the begin of the vector. │ │ │ │ │ -Definition reservedvector.hh:297 │ │ │ │ │ -Dune::ReservedVector::max_size │ │ │ │ │ -static constexpr size_type max_size() noexcept │ │ │ │ │ -Returns the maximum length of the vector. │ │ │ │ │ -Definition reservedvector.hh:405 │ │ │ │ │ -Dune::ReservedVector::at │ │ │ │ │ -constexpr const_reference at(size_type i) const │ │ │ │ │ -Returns a const reference to the i'th element. │ │ │ │ │ -Definition reservedvector.hh:321 │ │ │ │ │ -Dune::ReservedVector::reverse_iterator │ │ │ │ │ -std::reverse_iterator< iterator > reverse_iterator │ │ │ │ │ -Reverse iterator. │ │ │ │ │ -Definition reservedvector.hh:73 │ │ │ │ │ -Dune::ReservedVector::end │ │ │ │ │ -constexpr iterator end() noexcept │ │ │ │ │ -Returns an iterator pointing to the end of the vector. │ │ │ │ │ -Definition reservedvector.hh:273 │ │ │ │ │ -Dune::ReservedVector::operator< │ │ │ │ │ -constexpr bool operator<(const ReservedVector &that) const noexcept │ │ │ │ │ -Lexicographically compares the values in the vector this with that │ │ │ │ │ -Definition reservedvector.hh:149 │ │ │ │ │ -Dune::ReservedVector::size │ │ │ │ │ -constexpr size_type size() const noexcept │ │ │ │ │ -Returns number of elements in the vector. │ │ │ │ │ -Definition reservedvector.hh:387 │ │ │ │ │ -Dune::ReservedVector::empty │ │ │ │ │ -constexpr bool empty() const noexcept │ │ │ │ │ -Returns true if vector has no elements. │ │ │ │ │ -Definition reservedvector.hh:393 │ │ │ │ │ -Dune::ReservedVector::begin │ │ │ │ │ -constexpr iterator begin() noexcept │ │ │ │ │ -Returns a iterator pointing to the beginning of the vector. │ │ │ │ │ -Definition reservedvector.hh:237 │ │ │ │ │ -Dune::ReservedVector::push_back │ │ │ │ │ -constexpr void push_back(const value_type &t) noexcept(std::is_nothrow_copy_ │ │ │ │ │ -assignable_v< value_type >) │ │ │ │ │ -Appends an element to the end of a vector, up to the maximum size n, O(1) time. │ │ │ │ │ -Definition reservedvector.hh:194 │ │ │ │ │ -Dune::ReservedVector::rend │ │ │ │ │ -constexpr reverse_iterator rend() noexcept │ │ │ │ │ -Returns a const reverse-iterator pointing to the begin of the vector. │ │ │ │ │ -Definition reservedvector.hh:291 │ │ │ │ │ -Dune::ReservedVector::iterator │ │ │ │ │ -storage_type::iterator iterator │ │ │ │ │ -Iterator used to iterate through a vector. │ │ │ │ │ -Definition reservedvector.hh:69 │ │ │ │ │ -Dune::ReservedVector::cbegin │ │ │ │ │ -constexpr const_iterator cbegin() const noexcept │ │ │ │ │ -Returns a const_iterator pointing to the beginning of the vector. │ │ │ │ │ -Definition reservedvector.hh:249 │ │ │ │ │ -Dune::ReservedVector::const_reverse_iterator │ │ │ │ │ -std::reverse_iterator< const_iterator > const_reverse_iterator │ │ │ │ │ -Const reverse iterator. │ │ │ │ │ -Definition reservedvector.hh:75 │ │ │ │ │ -Dune::ReservedVector::data │ │ │ │ │ -constexpr pointer data() noexcept │ │ │ │ │ -Returns pointer to the underlying memory. │ │ │ │ │ -Definition reservedvector.hh:371 │ │ │ │ │ -Dune::ReservedVector::back │ │ │ │ │ -constexpr const_reference back() const noexcept │ │ │ │ │ -Returns const reference to last element of vector. │ │ │ │ │ -Definition reservedvector.hh:364 │ │ │ │ │ -Dune::ReservedVector::operator<< │ │ │ │ │ -friend std::ostream & operator<<(std::ostream &s, const ReservedVector &v) │ │ │ │ │ -Send ReservedVector to an output stream. │ │ │ │ │ -Definition reservedvector.hh:434 │ │ │ │ │ -Dune::ReservedVector::operator== │ │ │ │ │ -constexpr bool operator==(const ReservedVector &that) const noexcept │ │ │ │ │ -Compares the values in the vector this with that for equality. │ │ │ │ │ -Definition reservedvector.hh:132 │ │ │ │ │ -Dune::ReservedVector::pop_back │ │ │ │ │ -constexpr void pop_back() noexcept │ │ │ │ │ -Erases the last element of the vector, O(1) time. │ │ │ │ │ -Definition reservedvector.hh:227 │ │ │ │ │ -Dune::ReservedVector::hash_value │ │ │ │ │ -friend std::size_t hash_value(const ReservedVector &v) noexcept │ │ │ │ │ -Definition reservedvector.hh:441 │ │ │ │ │ -Dune::ReservedVector::difference_type │ │ │ │ │ -storage_type::difference_type difference_type │ │ │ │ │ -A signed integral type. │ │ │ │ │ -Definition reservedvector.hh:67 │ │ │ │ │ -Dune::ReservedVector::end │ │ │ │ │ -constexpr const_iterator end() const noexcept │ │ │ │ │ -Returns a const_iterator pointing to the end of the vector. │ │ │ │ │ -Definition reservedvector.hh:279 │ │ │ │ │ -Dune::ReservedVector::clear │ │ │ │ │ -constexpr void clear() noexcept │ │ │ │ │ -Erases all elements. │ │ │ │ │ -Definition reservedvector.hh:181 │ │ │ │ │ -Dune::ReservedVector::ReservedVector │ │ │ │ │ -constexpr ReservedVector() noexcept(std::is_nothrow_default_constructible_v< │ │ │ │ │ -value_type >) │ │ │ │ │ -Constructs an empty vector. │ │ │ │ │ -Definition reservedvector.hh:82 │ │ │ │ │ -Dune::ReservedVector::const_iterator │ │ │ │ │ -storage_type::const_iterator const_iterator │ │ │ │ │ -Const iterator used to iterate through a vector. │ │ │ │ │ -Definition reservedvector.hh:71 │ │ │ │ │ -Dune::ReservedVector::emplace_back │ │ │ │ │ -reference emplace_back(Args &&... args) noexcept(std::is_nothrow_constructible_ │ │ │ │ │ -v< value_type, decltype(args)... >) │ │ │ │ │ -Appends an element to the end of a vector by constructing it in place. │ │ │ │ │ -Definition reservedvector.hh:211 │ │ │ │ │ -Dune::ReservedVector::size_type │ │ │ │ │ -storage_type::size_type size_type │ │ │ │ │ -An unsigned integral type. │ │ │ │ │ -Definition reservedvector.hh:65 │ │ │ │ │ -Dune::ReservedVector::operator>= │ │ │ │ │ -constexpr bool operator>=(const ReservedVector &that) const noexcept │ │ │ │ │ -Lexicographically compares the values in the vector this with that │ │ │ │ │ -Definition reservedvector.hh:171 │ │ │ │ │ -Dune::ReservedVector::const_reference │ │ │ │ │ -storage_type::const_reference const_reference │ │ │ │ │ -Const reference to T. │ │ │ │ │ -Definition reservedvector.hh:63 │ │ │ │ │ -Dune::ReservedVector::swap │ │ │ │ │ -void swap(ReservedVector &other) noexcept(std::is_nothrow_swappable_v< value_ │ │ │ │ │ -type >) │ │ │ │ │ -Swap the content with another vector. │ │ │ │ │ -Definition reservedvector.hh:423 │ │ │ │ │ -Dune::ReservedVector::ReservedVector │ │ │ │ │ -constexpr ReservedVector(InputIt first, InputIt last) noexcept(std::is_nothrow_ │ │ │ │ │ -copy_assignable_v< value_type > &&noexcept(ReservedVector())) │ │ │ │ │ -Constructs the vector from an iterator range [first,last) │ │ │ │ │ -Definition reservedvector.hh:110 │ │ │ │ │ -Dune::ReservedVector::data │ │ │ │ │ -constexpr const_pointer data() const noexcept │ │ │ │ │ -Returns const pointer to the underlying memory. │ │ │ │ │ -Definition reservedvector.hh:377 │ │ │ │ │ -Dune::ReservedVector::at │ │ │ │ │ -constexpr reference at(size_type i) │ │ │ │ │ -Returns reference to the i'th element. │ │ │ │ │ -Definition reservedvector.hh:313 │ │ │ │ │ -Dune::ReservedVector::cend │ │ │ │ │ -constexpr const_iterator cend() const noexcept │ │ │ │ │ -Returns a const_iterator pointing to the end of the vector. │ │ │ │ │ -Definition reservedvector.hh:285 │ │ │ │ │ -Dune::ReservedVector::back │ │ │ │ │ -constexpr reference back() noexcept │ │ │ │ │ -Returns reference to last element of vector. │ │ │ │ │ -Definition reservedvector.hh:357 │ │ │ │ │ -Dune::ReservedVector::rbegin │ │ │ │ │ -constexpr const_reverse_iterator rbegin() const noexcept │ │ │ │ │ -Returns a const reverse-iterator pointing to the end of the vector. │ │ │ │ │ -Definition reservedvector.hh:261 │ │ │ │ │ -Dune::ReservedVector::value_type │ │ │ │ │ -storage_type::value_type value_type │ │ │ │ │ -The type of object, T, stored in the vector. │ │ │ │ │ -Definition reservedvector.hh:55 │ │ │ │ │ -Dune::ReservedVector::begin │ │ │ │ │ -constexpr const_iterator begin() const noexcept │ │ │ │ │ -Returns a const_iterator pointing to the beginning of the vector. │ │ │ │ │ -Definition reservedvector.hh:243 │ │ │ │ │ -Dune::ReservedVector::ReservedVector │ │ │ │ │ -constexpr ReservedVector(size_type count, const value_type &value) noexcept │ │ │ │ │ -(std::is_nothrow_copy_assignable_v< value_type > &&noexcept(ReservedVector │ │ │ │ │ -(count))) │ │ │ │ │ -Constructs the vector with count copies of elements with value value. │ │ │ │ │ -Definition reservedvector.hh:98 │ │ │ │ │ -Dune::ReservedVector::operator[] │ │ │ │ │ -constexpr reference operator[](size_type i) noexcept │ │ │ │ │ -Returns reference to the i'th element. │ │ │ │ │ -Definition reservedvector.hh:329 │ │ │ │ │ -Dune::ReservedVector::front │ │ │ │ │ -constexpr reference front() noexcept │ │ │ │ │ -Returns reference to first element of vector. │ │ │ │ │ -Definition reservedvector.hh:343 │ │ │ │ │ -Dune::ReservedVector::const_pointer │ │ │ │ │ -storage_type::const_pointer const_pointer │ │ │ │ │ -Const pointer to T. │ │ │ │ │ -Definition reservedvector.hh:59 │ │ │ │ │ -Dune::ReservedVector::ReservedVector │ │ │ │ │ -constexpr ReservedVector(std::initializer_list< value_type > const &l) noexcept │ │ │ │ │ -(std::is_nothrow_copy_assignable_v< value_type > &&noexcept(ReservedVector │ │ │ │ │ -(l.begin(), l.end()))) │ │ │ │ │ -Constructs the vector from an initializer list. │ │ │ │ │ -Definition reservedvector.hh:121 │ │ │ │ │ -Dune::ReservedVector::operator!= │ │ │ │ │ -constexpr bool operator!=(const ReservedVector &that) const noexcept │ │ │ │ │ -Compares the values in the vector this with that for not equality. │ │ │ │ │ -Definition reservedvector.hh:143 │ │ │ │ │ -Dune::ReservedVector::resize │ │ │ │ │ -constexpr void resize(size_type s) noexcept │ │ │ │ │ -Specifies a new size for the vector. │ │ │ │ │ -Definition reservedvector.hh:187 │ │ │ │ │ -Dune::ReservedVector::capacity │ │ │ │ │ -static constexpr size_type capacity() noexcept │ │ │ │ │ -Returns current capacity (allocated memory) of the vector. │ │ │ │ │ -Definition reservedvector.hh:399 │ │ │ │ │ -Dune::ReservedVector::reference │ │ │ │ │ -storage_type::reference reference │ │ │ │ │ -Reference to T. │ │ │ │ │ -Definition reservedvector.hh:61 │ │ │ │ │ -Dune::ReservedVector::crbegin │ │ │ │ │ -constexpr const_reverse_iterator crbegin() const noexcept │ │ │ │ │ -Returns a const reverse-iterator pointing to the end of the vector. │ │ │ │ │ -Definition reservedvector.hh:267 │ │ │ │ │ -Dune::ReservedVector::push_back │ │ │ │ │ -constexpr void push_back(value_type &&t) noexcept(std::is_nothrow_move_ │ │ │ │ │ -assignable_v< value_type >) │ │ │ │ │ -Appends an element to the end of a vector by moving the value, up to the │ │ │ │ │ -maximum size n,... │ │ │ │ │ -Definition reservedvector.hh:202 │ │ │ │ │ +Dune::Simd::Overloads::ADLTag │ │ │ │ │ +Tag used to force late-binding lookup in Dune::Simd::Overloads. │ │ │ │ │ +Definition base.hh:182 │ │ │ │ │ +Dune::Simd::Overloads::ScalarType │ │ │ │ │ +should have a member type type │ │ │ │ │ +Definition standard.hh:60 │ │ │ │ │ +Dune::Simd::Overloads::RebindType │ │ │ │ │ +should have a member type type │ │ │ │ │ +Definition standard.hh:67 │ │ │ │ │ +Dune::Simd::Overloads::LaneCount │ │ │ │ │ +should be derived from a Dune::index_constant │ │ │ │ │ +Definition standard.hh:74 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00023.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: gmpfield.hh File Reference │ │ │ │ +dune-common: vc.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -69,56 +69,25 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
│ │ │ │ -Classes | │ │ │ │ -Namespaces
│ │ │ │ -
gmpfield.hh File Reference
│ │ │ │ +
vc.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

Wrapper for the GNU multiprecision (GMP) library. │ │ │ │ +

Compatibility header for including <Vc/Vc> │ │ │ │ More...

│ │ │ │ -
#include <iostream>
│ │ │ │ -#include <string>
│ │ │ │ -#include <type_traits>
│ │ │ │ -#include <gmpxx.h>
│ │ │ │ -#include <dune/common/promotiontraits.hh>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ -
│ │ │ │ + │ │ │ │

Go to the source code of this file.

│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

class  Dune::GMPField< precision >
 Number class for high precision floating point number using the GMP library mpf_class implementation. More...
 
struct  Dune::IsNumber< GMPField< precision > >
 
struct  Dune::PromotionTraits< GMPField< precision1 >, GMPField< precision2 > >
 
struct  Dune::PromotionTraits< GMPField< precision >, GMPField< precision > >
 
struct  Dune::PromotionTraits< GMPField< precision >, T >
 
struct  Dune::PromotionTraits< T, GMPField< precision > >
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │

Detailed Description

│ │ │ │ -

Wrapper for the GNU multiprecision (GMP) library.

│ │ │ │ +

Compatibility header for including <Vc/Vc>

│ │ │ │ +

Certain versions (1.3.2) of Vc (https://github.com/VcDevel/Vc) have a problem with certain compiler versions (g++ 7.2.0) in c++17 mode, see #88.

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,40 +1,15 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -gmpfield.hh File Reference │ │ │ │ │ -Wrapper for the GNU multiprecision (GMP) library. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +vc.hh File Reference │ │ │ │ │ +Compatibility header for including More... │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ -Classes │ │ │ │ │ - class   Dune::GMPField<_precision_> │ │ │ │ │ -  Number class for high precision floating point number using the GMP │ │ │ │ │ - library mpf_class implementation. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::IsNumber<_GMPField<_precision_>_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::PromotionTraits<_GMPField<_precision1_>,_GMPField<_precision2_> │ │ │ │ │ - > │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::PromotionTraits<_GMPField<_precision_>,_GMPField<_precision_>_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::PromotionTraits<_GMPField<_precision_>,_T_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::PromotionTraits<_T,_GMPField<_precision_>_> │ │ │ │ │ -  │ │ │ │ │ -Namespaces │ │ │ │ │ -namespace   Dune │ │ │ │ │ -  Dune namespace. │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Wrapper for the GNU multiprecision (GMP) library. │ │ │ │ │ +Compatibility header for including │ │ │ │ │ +Certain versions (1.3.2) of Vc (https://github.com/VcDevel/Vc) have a problem │ │ │ │ │ +with certain compiler versions (g++ 7.2.0) in c++17 mode, see #88. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00023_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: gmpfield.hh Source File │ │ │ │ +dune-common: vc.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,141 +74,38 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
gmpfield.hh
│ │ │ │ +
vc.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ -
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ -
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_GMPFIELD_HH
│ │ │ │ -
6#define DUNE_GMPFIELD_HH
│ │ │ │ -
7
│ │ │ │ -
12#include <iostream>
│ │ │ │ -
13#include <string>
│ │ │ │ -
14#include <type_traits>
│ │ │ │ -
15
│ │ │ │ -
16#if HAVE_GMP || DOXYGEN
│ │ │ │ -
17
│ │ │ │ -
18#include <gmpxx.h>
│ │ │ │ +Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
3#ifndef DUNE_COMMON_VC_HH
│ │ │ │ +
4#define DUNE_COMMON_VC_HH
│ │ │ │ +
5
│ │ │ │ +
15#if HAVE_VC
│ │ │ │ +
16
│ │ │ │ +
17// include Vc's macro definitions
│ │ │ │ +
18#include <Vc/global.h>
│ │ │ │
19
│ │ │ │ - │ │ │ │ - │ │ │ │ -
22
│ │ │ │ -
23namespace Dune
│ │ │ │ -
24{
│ │ │ │ -
25
│ │ │ │ -
30 template< unsigned int precision >
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
32 : public mpf_class
│ │ │ │ -
33 {
│ │ │ │ -
34 typedef mpf_class Base;
│ │ │ │ -
35
│ │ │ │ -
36 public:
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
39 : Base(0,precision)
│ │ │ │ -
40 {}
│ │ │ │ -
│ │ │ │ -
41
│ │ │ │ -
│ │ │ │ -
45 GMPField ( const char* str )
│ │ │ │ -
46 : Base(str,precision)
│ │ │ │ -
47 {}
│ │ │ │ -
│ │ │ │ -
48
│ │ │ │ -
│ │ │ │ -
52 GMPField ( const std::string& str )
│ │ │ │ -
53 : Base(str,precision)
│ │ │ │ -
54 {}
│ │ │ │ -
│ │ │ │ -
55
│ │ │ │ -
58 template< class T,
│ │ │ │ -
59 typename EnableIf = typename std::enable_if<
│ │ │ │ -
60 std::is_convertible<T, mpf_class>::value>::type
│ │ │ │ -
61 >
│ │ │ │ -
│ │ │ │ -
62 GMPField ( const T &v )
│ │ │ │ -
63 : Base( v,precision )
│ │ │ │ -
64 {}
│ │ │ │ -
│ │ │ │ -
65
│ │ │ │ -
66 // type conversion operators
│ │ │ │ -
│ │ │ │ -
67 operator double () const
│ │ │ │ -
68 {
│ │ │ │ -
69 return this->get_d();
│ │ │ │ -
70 }
│ │ │ │ -
│ │ │ │ -
71
│ │ │ │ -
72 };
│ │ │ │ -
│ │ │ │ -
73
│ │ │ │ -
74 template <unsigned int precision>
│ │ │ │ -
│ │ │ │ -
75 struct IsNumber<GMPField<precision>>
│ │ │ │ -
76 : public std::integral_constant<bool, true> {
│ │ │ │ -
77 };
│ │ │ │ -
│ │ │ │ -
78
│ │ │ │ -
79 template< unsigned int precision1, unsigned int precision2 >
│ │ │ │ -
│ │ │ │ -
80 struct PromotionTraits<GMPField<precision1>, GMPField<precision2>>
│ │ │ │ -
81 {
│ │ │ │ -
82 typedef GMPField<(precision1 > precision2 ? precision1 : precision2)> PromotedType;
│ │ │ │ -
83 };
│ │ │ │ -
│ │ │ │ -
84
│ │ │ │ -
85 template< unsigned int precision >
│ │ │ │ -
│ │ │ │ -
86 struct PromotionTraits<GMPField<precision>,GMPField<precision>>
│ │ │ │ -
87 {
│ │ │ │ - │ │ │ │ -
89 };
│ │ │ │ -
│ │ │ │ -
90
│ │ │ │ -
91 template< unsigned int precision, class T >
│ │ │ │ -
│ │ │ │ -
92 struct PromotionTraits<GMPField<precision>, T>
│ │ │ │ -
93 {
│ │ │ │ - │ │ │ │ -
95 };
│ │ │ │ -
│ │ │ │ -
96
│ │ │ │ -
97 template< class T, unsigned int precision >
│ │ │ │ -
│ │ │ │ -
98 struct PromotionTraits<T, GMPField<precision>>
│ │ │ │ -
99 {
│ │ │ │ - │ │ │ │ -
101 };
│ │ │ │ -
│ │ │ │ -
102}
│ │ │ │ -
103
│ │ │ │ -
104#endif // HAVE_GMP
│ │ │ │ -
105
│ │ │ │ -
106#endif // #ifndef DUNE_GMPFIELD_HH
│ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ -
Compute type of the result of an arithmetic operation involving two different number types.
│ │ │ │ -
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
Definition typetraits.hh:194
│ │ │ │ -
Number class for high precision floating point number using the GMP library mpf_class implementation.
Definition gmpfield.hh:33
│ │ │ │ -
GMPField(const T &v)
initialize from a compatible scalar type
Definition gmpfield.hh:62
│ │ │ │ -
GMPField()
Definition gmpfield.hh:38
│ │ │ │ -
GMPField(const std::string &str)
initialize from a string
Definition gmpfield.hh:52
│ │ │ │ -
GMPField(const char *str)
initialize from a string
Definition gmpfield.hh:45
│ │ │ │ -
GMPField< precision > PromotedType
Definition gmpfield.hh:88
│ │ │ │ -
GMPField< precision > PromotedType
Definition gmpfield.hh:94
│ │ │ │ -
GMPField< precision > PromotedType
Definition gmpfield.hh:100
│ │ │ │ -
Compute type of the result of an arithmetic operation involving two different number types.
Definition promotiontraits.hh:27
│ │ │ │ +
20// undefine the macro that signals C++17 support, if set
│ │ │ │ +
21#ifdef Vc_CXX17
│ │ │ │ +
22#undef Vc_CXX17
│ │ │ │ +
23#endif
│ │ │ │ +
24
│ │ │ │ +
25// include the rest of Vc
│ │ │ │ +
26#include <Vc/Vc>
│ │ │ │ +
27
│ │ │ │ +
28#endif // HAVE_VC
│ │ │ │ +
29
│ │ │ │ +
30#endif // DUNE_COMMON_VC_HH
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,146 +1,32 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -gmpfield.hh │ │ │ │ │ +vc.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ -2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ -3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_GMPFIELD_HH │ │ │ │ │ -6#define DUNE_GMPFIELD_HH │ │ │ │ │ -7 │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15 │ │ │ │ │ -16#if HAVE_GMP || DOXYGEN │ │ │ │ │ -17 │ │ │ │ │ -18#include │ │ │ │ │ +2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +3#ifndef DUNE_COMMON_VC_HH │ │ │ │ │ +4#define DUNE_COMMON_VC_HH │ │ │ │ │ +5 │ │ │ │ │ +15#if HAVE_VC │ │ │ │ │ +16 │ │ │ │ │ +17// include Vc's macro definitions │ │ │ │ │ +18#include │ │ │ │ │ 19 │ │ │ │ │ -20#include │ │ │ │ │ -21#include │ │ │ │ │ -22 │ │ │ │ │ -23namespace Dune │ │ │ │ │ -24{ │ │ │ │ │ -25 │ │ │ │ │ -30 template< unsigned int precision > │ │ │ │ │ -31 class GMPField │ │ │ │ │ -32 : public mpf_class │ │ │ │ │ -33 { │ │ │ │ │ -34 typedef mpf_class Base; │ │ │ │ │ -35 │ │ │ │ │ -36 public: │ │ │ │ │ -38 GMPField () │ │ │ │ │ -39 : Base(0,precision) │ │ │ │ │ -40 {} │ │ │ │ │ -41 │ │ │ │ │ -45 GMPField ( const char* str ) │ │ │ │ │ -46 : Base(str,precision) │ │ │ │ │ -47 {} │ │ │ │ │ -48 │ │ │ │ │ -52 GMPField ( const std::string& str ) │ │ │ │ │ -53 : Base(str,precision) │ │ │ │ │ -54 {} │ │ │ │ │ -55 │ │ │ │ │ -58 template< class T, │ │ │ │ │ -59 typename EnableIf = typename std::enable_if< │ │ │ │ │ -60 std::is_convertible::value>::type │ │ │ │ │ -61 > │ │ │ │ │ -62 GMPField ( const T &v ) │ │ │ │ │ -63 : Base( v,precision ) │ │ │ │ │ -64 {} │ │ │ │ │ -65 │ │ │ │ │ -66 // type conversion operators │ │ │ │ │ -67 operator double () const │ │ │ │ │ -68 { │ │ │ │ │ -69 return this->get_d(); │ │ │ │ │ -70 } │ │ │ │ │ -71 │ │ │ │ │ -72 }; │ │ │ │ │ -73 │ │ │ │ │ -74 template │ │ │ │ │ -75 struct IsNumber> │ │ │ │ │ -76 : public std::integral_constant { │ │ │ │ │ -77 }; │ │ │ │ │ -78 │ │ │ │ │ -79 template< unsigned int precision1, unsigned int precision2 > │ │ │ │ │ -80 struct PromotionTraits, GMPField> │ │ │ │ │ -81 { │ │ │ │ │ -82 typedef GMPField<(precision1 > precision2 ? precision1 : precision2)> │ │ │ │ │ -PromotedType; │ │ │ │ │ -83 }; │ │ │ │ │ -84 │ │ │ │ │ -85 template< unsigned int precision > │ │ │ │ │ -86 struct PromotionTraits,GMPField> │ │ │ │ │ -87 { │ │ │ │ │ -88 typedef GMPField PromotedType; │ │ │ │ │ -89 }; │ │ │ │ │ -90 │ │ │ │ │ -91 template< unsigned int precision, class T > │ │ │ │ │ -92 struct PromotionTraits, T> │ │ │ │ │ -93 { │ │ │ │ │ -94 typedef GMPField PromotedType; │ │ │ │ │ -95 }; │ │ │ │ │ -96 │ │ │ │ │ -97 template< class T, unsigned int precision > │ │ │ │ │ -98 struct PromotionTraits> │ │ │ │ │ -99 { │ │ │ │ │ -100 typedef GMPField PromotedType; │ │ │ │ │ -101 }; │ │ │ │ │ -102} │ │ │ │ │ -103 │ │ │ │ │ -104#endif // HAVE_GMP │ │ │ │ │ -105 │ │ │ │ │ -106#endif // #ifndef DUNE_GMPFIELD_HH │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -promotiontraits.hh │ │ │ │ │ -Compute type of the result of an arithmetic operation involving two different │ │ │ │ │ -number types. │ │ │ │ │ -Dune │ │ │ │ │ -Dune namespace. │ │ │ │ │ -Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::IsNumber │ │ │ │ │ -Whether this type acts as a scalar in the context of (hierarchically blocked) │ │ │ │ │ -containers. │ │ │ │ │ -Definition typetraits.hh:194 │ │ │ │ │ -Dune::GMPField │ │ │ │ │ -Number class for high precision floating point number using the GMP library │ │ │ │ │ -mpf_class implementation. │ │ │ │ │ -Definition gmpfield.hh:33 │ │ │ │ │ -Dune::GMPField::GMPField │ │ │ │ │ -GMPField(const T &v) │ │ │ │ │ -initialize from a compatible scalar type │ │ │ │ │ -Definition gmpfield.hh:62 │ │ │ │ │ -Dune::GMPField::GMPField │ │ │ │ │ -GMPField() │ │ │ │ │ -Definition gmpfield.hh:38 │ │ │ │ │ -Dune::GMPField::GMPField │ │ │ │ │ -GMPField(const std::string &str) │ │ │ │ │ -initialize from a string │ │ │ │ │ -Definition gmpfield.hh:52 │ │ │ │ │ -Dune::GMPField::GMPField │ │ │ │ │ -GMPField(const char *str) │ │ │ │ │ -initialize from a string │ │ │ │ │ -Definition gmpfield.hh:45 │ │ │ │ │ -Dune::PromotionTraits<_GMPField<_precision_>,_GMPField<_precision_>_>:: │ │ │ │ │ -PromotedType │ │ │ │ │ -GMPField< precision > PromotedType │ │ │ │ │ -Definition gmpfield.hh:88 │ │ │ │ │ -Dune::PromotionTraits<_GMPField<_precision_>,_T_>::PromotedType │ │ │ │ │ -GMPField< precision > PromotedType │ │ │ │ │ -Definition gmpfield.hh:94 │ │ │ │ │ -Dune::PromotionTraits<_T,_GMPField<_precision_>_>::PromotedType │ │ │ │ │ -GMPField< precision > PromotedType │ │ │ │ │ -Definition gmpfield.hh:100 │ │ │ │ │ -Dune::PromotionTraits │ │ │ │ │ -Compute type of the result of an arithmetic operation involving two different │ │ │ │ │ -number types. │ │ │ │ │ -Definition promotiontraits.hh:27 │ │ │ │ │ +20// undefine the macro that signals C++17 support, if set │ │ │ │ │ +21#ifdef Vc_CXX17 │ │ │ │ │ +22#undef Vc_CXX17 │ │ │ │ │ +23#endif │ │ │ │ │ +24 │ │ │ │ │ +25// include the rest of Vc │ │ │ │ │ +26#include │ │ │ │ │ +27 │ │ │ │ │ +28#endif // HAVE_VC │ │ │ │ │ +29 │ │ │ │ │ +30#endif // DUNE_COMMON_VC_HH │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00026.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: stdthread.cc File Reference │ │ │ │ +dune-common: loop.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,41 +65,681 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ +Classes | │ │ │ │ Namespaces | │ │ │ │ +Macros | │ │ │ │ Functions
│ │ │ │ -
stdthread.cc File Reference
│ │ │ │ +
loop.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <cstdlib>
│ │ │ │ -#include <iostream>
│ │ │ │ -#include <mutex>
│ │ │ │ +
#include <array>
│ │ │ │ +#include <cmath>
│ │ │ │ +#include <cstddef>
│ │ │ │ +#include <cstdlib>
│ │ │ │ +#include <cstdint>
│ │ │ │ #include <ostream>
│ │ │ │ -#include <dune/common/stdthread.hh>
│ │ │ │ -
│ │ │ │ +#include <dune/common/math.hh>
│ │ │ │ +#include <dune/common/simd/simd.hh>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │ + │ │ │ │ +

Go to the source code of this file.

│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

class  Dune::LoopSIMD< T, S, A >
 
struct  Dune::Simd::Overloads::ScalarType< LoopSIMD< T, S, A > >
 
struct  Dune::Simd::Overloads::RebindType< U, LoopSIMD< T, S, A > >
 
struct  Dune::Simd::Overloads::LaneCount< LoopSIMD< T, S, A > >
 
struct  Dune::IsNumber< LoopSIMD< T, S, A > >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
 
namespace  Dune::Simd::Overloads
 Namespace for the overloads and specializations that make up a SIMD implementation.
 
namespace  Dune::MathOverloads
 namespace for customization of math functions with Dune-Semantics
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Macros

#define DUNE_PRAGMA_OMP_SIMD
 
#define DUNE_SIMD_LOOP_PREFIX_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_UNARY_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_POSTFIX_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_ASSIGNMENT_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_BINARY_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_BITSHIFT_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_COMPARISON_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_BOOLEAN_OP(SYMBOL)
 
#define DUNE_SIMD_LOOP_CMATH_UNARY_OP(expr)
 
#define DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN(expr, returnType)
 
#define DUNE_SIMD_LOOP_STD_UNARY_OP(expr)
 
#define DUNE_SIMD_LOOP_STD_BINARY_OP(expr)
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

void Dune::doAssertCallOnce (const char *file, int line, const char *function)
 
 Dune::DUNE_SIMD_LOOP_BINARY_OP (+)
 
 Dune::DUNE_SIMD_LOOP_BINARY_OP (-)
 
DUNE_SIMD_LOOP_BINARY_OP * Dune::DUNE_SIMD_LOOP_BINARY_OP (/);DUNE_SIMD_LOOP_BINARY_OP(%
 
DUNE_SIMD_LOOP_BINARY_OP & Dune::DUNE_SIMD_LOOP_BINARY_OP (|);DUNE_SIMD_LOOP_BINARY_OP(^
 
 Dune::DUNE_SIMD_LOOP_BITSHIFT_OP (<<)
 
 Dune::DUNE_SIMD_LOOP_BITSHIFT_OP (> >)
 
 Dune::DUNE_SIMD_LOOP_COMPARISON_OP (<)
 
 Dune::DUNE_SIMD_LOOP_COMPARISON_OP (<=)
 
 Dune::DUNE_SIMD_LOOP_COMPARISON_OP (>=)
 
 Dune::DUNE_SIMD_LOOP_COMPARISON_OP (!=)
 
DUNE_SIMD_LOOP_BOOLEAN_OP && Dune::DUNE_SIMD_LOOP_BOOLEAN_OP (||);template< class T, std::size_t S, std::size_t A > std::ostream &operator<<(std::ostream &os, const LoopSIMD< T, S, A > &v
 
template<class T , std::size_t S, std::size_t A>
auto Dune::Simd::Overloads::lane (ADLTag< 5 >, std::size_t l, LoopSIMD< T, S, A > &&v) -> decltype(std::move(Simd::lane(l%lanes< T >(), v[l/lanes< T >()])))
 
template<class T , std::size_t S, std::size_t A>
auto Dune::Simd::Overloads::lane (ADLTag< 5 >, std::size_t l, const LoopSIMD< T, S, A > &v) -> decltype(Simd::lane(l%lanes< T >(), v[l/lanes< T >()]))
 
template<class T , std::size_t S, std::size_t A>
auto Dune::Simd::Overloads::lane (ADLTag< 5 >, std::size_t l, LoopSIMD< T, S, A > &v) -> decltype(Simd::lane(l%lanes< T >(), v[l/lanes< T >()]))
 
template<class T , std::size_t S, std::size_t AM, std::size_t AD>
auto Dune::Simd::Overloads::cond (ADLTag< 5 >, Simd::Mask< LoopSIMD< T, S, AM > > mask, LoopSIMD< T, S, AD > ifTrue, LoopSIMD< T, S, AD > ifFalse)
 
template<class M , class T , std::size_t S, std::size_t A>
auto Dune::Simd::Overloads::cond (ADLTag< 5, std::is_same< bool, Simd::Scalar< M > >::value &&Simd::lanes< M >()==Simd::lanes< LoopSIMD< T, S, A > >()>, M mask, LoopSIMD< T, S, A > ifTrue, LoopSIMD< T, S, A > ifFalse)
 
template<class M , std::size_t S, std::size_t A>
bool Dune::Simd::Overloads::anyTrue (ADLTag< 5 >, LoopSIMD< M, S, A > mask)
 
template<class M , std::size_t S, std::size_t A>
bool Dune::Simd::Overloads::allTrue (ADLTag< 5 >, LoopSIMD< M, S, A > mask)
 
template<class M , std::size_t S, std::size_t A>
bool Dune::Simd::Overloads::anyFalse (ADLTag< 5 >, LoopSIMD< M, S, A > mask)
 
template<class M , std::size_t S, std::size_t A>
bool Dune::Simd::Overloads::allFalse (ADLTag< 5 >, LoopSIMD< M, S, A > mask)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cos)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sin)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tan)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (acos)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (asin)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (atan)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cosh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sinh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tanh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (acosh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (asinh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (atanh)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (exp)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log10)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (exp2)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (expm1)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (ilogb, int)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log1p)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log2)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (logb)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sqrt)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cbrt)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (erf)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (erfc)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tgamma)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (lgamma)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (ceil)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (floor)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (trunc)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (round)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (lround, long)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (llround, long long)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (rint)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (lrint, long)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN (llrint, long long)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (nearbyint)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (fabs)
 
 Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (abs)
 
 Dune::DUNE_SIMD_LOOP_STD_UNARY_OP (real)
 
 Dune::DUNE_SIMD_LOOP_STD_UNARY_OP (imag)
 
 Dune::DUNE_SIMD_LOOP_STD_BINARY_OP (max)
 
 Dune::DUNE_SIMD_LOOP_STD_BINARY_OP (min)
 
template<class T , std::size_t S, std::size_t A>
auto Dune::MathOverloads::isNaN (const LoopSIMD< T, S, A > &v, PriorityTag< 3 >, ADLTag)
 
template<class T , std::size_t S, std::size_t A>
auto Dune::MathOverloads::isInf (const LoopSIMD< T, S, A > &v, PriorityTag< 3 >, ADLTag)
 
template<class T , std::size_t S, std::size_t A>
auto Dune::MathOverloads::isFinite (const LoopSIMD< T, S, A > &v, PriorityTag< 3 >, ADLTag)
 
│ │ │ │ +

Macro Definition Documentation

│ │ │ │ + │ │ │ │ +

◆ DUNE_PRAGMA_OMP_SIMD

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_PRAGMA_OMP_SIMD
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_LOOP_ASSIGNMENT_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_LOOP_ASSIGNMENT_OP( SYMBOL)
│ │ │ │ +
│ │ │ │ +Value:
auto operator SYMBOL(const Simd::Scalar<T> s) { \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
(*this)[i] SYMBOL s; \
│ │ │ │ +
} \
│ │ │ │ +
return *this; \
│ │ │ │ +
} \
│ │ │ │ +
\
│ │ │ │ +
auto operator SYMBOL(const LoopSIMD<T,S,A> &v) { \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
(*this)[i] SYMBOL v[i]; \
│ │ │ │ +
} \
│ │ │ │ +
return *this; \
│ │ │ │ +
} \
│ │ │ │ +
static_assert(true, "expecting ;")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_LOOP_BINARY_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_LOOP_BINARY_OP( SYMBOL)
│ │ │ │ +
│ │ │ │ +Value:
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ +
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const Simd::Scalar<T> s) { \
│ │ │ │ +
LoopSIMD<T,S,A> out; \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
out[i] = v[i] SYMBOL s; \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ +
auto operator SYMBOL(const Simd::Scalar<T> s, const LoopSIMD<T,S,A> &v) { \
│ │ │ │ +
LoopSIMD<T,S,A> out; \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
out[i] = s SYMBOL v[i]; \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ +
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
│ │ │ │ +
const LoopSIMD<T,S,A> &w) { \
│ │ │ │ +
LoopSIMD<T,S,A> out; \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
out[i] = v[i] SYMBOL w[i]; \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
static_assert(true, "expecting ;")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_LOOP_BITSHIFT_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_LOOP_BITSHIFT_OP( SYMBOL)
│ │ │ │ +
│ │ │ │ +Value:
template<class T, std::size_t S, std::size_t A, class U> \
│ │ │ │ +
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const U s) { \
│ │ │ │ +
LoopSIMD<T,S,A> out; \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
out[i] = v[i] SYMBOL s; \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
template<class T, std::size_t S, std::size_t A, class U, std::size_t AU> \
│ │ │ │ +
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
│ │ │ │ +
const LoopSIMD<U,S,AU> &w) { \
│ │ │ │ +
LoopSIMD<T,S,A> out; \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
out[i] = v[i] SYMBOL w[i]; \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
static_assert(true, "expecting ;")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_LOOP_BOOLEAN_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_LOOP_BOOLEAN_OP( SYMBOL)
│ │ │ │ +
│ │ │ │ +Value:
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ +
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const Simd::Scalar<T> s) { \
│ │ │ │ +
Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
out[i] = v[i] SYMBOL s; \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ +
auto operator SYMBOL(const Simd::Mask<T> s, const LoopSIMD<T,S,A> &v) { \
│ │ │ │ +
Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
out[i] = s SYMBOL v[i]; \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ +
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
│ │ │ │ +
const LoopSIMD<T,S,A> &w) { \
│ │ │ │ +
Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
out[i] = v[i] SYMBOL w[i]; \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
static_assert(true, "expecting ;")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_LOOP_CMATH_UNARY_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_LOOP_CMATH_UNARY_OP( expr)
│ │ │ │ +
│ │ │ │ +Value:
template<class T, std::size_t S, std::size_t A, typename Sfinae = \
│ │ │ │ +
typename std::enable_if_t<!std::is_integral<Simd::Scalar<T>>::value> > \
│ │ │ │ +
auto expr(const LoopSIMD<T,S,A> &v) { \
│ │ │ │ +
using std::expr; \
│ │ │ │ +
LoopSIMD<T,S,A> out; \
│ │ │ │ +
for(std::size_t i=0; i<S; i++) { \
│ │ │ │ +
out[i] = expr(v[i]); \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
static_assert(true, "expecting ;")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN( expr,
 returnType 
)
│ │ │ │ +
│ │ │ │ +Value:
template<class T, std::size_t S, std::size_t A, typename Sfinae = \
│ │ │ │ +
typename std::enable_if_t<!std::is_integral<Simd::Scalar<T>>::value> > \
│ │ │ │ +
auto expr(const LoopSIMD<T,S,A> &v) { \
│ │ │ │ +
using std::expr; \
│ │ │ │ +
LoopSIMD<returnType,S> out; \
│ │ │ │ +
for(std::size_t i=0; i<S; i++) { \
│ │ │ │ +
out[i] = expr(v[i]); \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
static_assert(true, "expecting ;")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_LOOP_COMPARISON_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_LOOP_COMPARISON_OP( SYMBOL)
│ │ │ │ +
│ │ │ │ +Value:
template<class T, std::size_t S, std::size_t A, class U> \
│ │ │ │ +
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, const U s) { \
│ │ │ │ +
Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
out[i] = v[i] SYMBOL s; \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ +
auto operator SYMBOL(const Simd::Scalar<T> s, const LoopSIMD<T,S,A> &v) { \
│ │ │ │ +
Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
out[i] = s SYMBOL v[i]; \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ +
auto operator SYMBOL(const LoopSIMD<T,S,A> &v, \
│ │ │ │ +
const LoopSIMD<T,S,A> &w) { \
│ │ │ │ +
Simd::Mask<LoopSIMD<T,S,A>> out; \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
out[i] = v[i] SYMBOL w[i]; \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
static_assert(true, "expecting ;")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_LOOP_POSTFIX_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_LOOP_POSTFIX_OP( SYMBOL)
│ │ │ │ +
│ │ │ │ +Value:
auto operator SYMBOL(int){ \
│ │ │ │ +
LoopSIMD<T,S,A> out = *this; \
│ │ │ │ +
SYMBOL(*this); \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
static_assert(true, "expecting ;")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_LOOP_PREFIX_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_LOOP_PREFIX_OP( SYMBOL)
│ │ │ │ +
│ │ │ │ +Value:
auto operator SYMBOL() { \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
SYMBOL(*this)[i]; \
│ │ │ │ +
} \
│ │ │ │ +
return *this; \
│ │ │ │ +
} \
│ │ │ │ +
static_assert(true, "expecting ;")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_LOOP_STD_BINARY_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_LOOP_STD_BINARY_OP( expr)
│ │ │ │ +
│ │ │ │ +Value:
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ +
auto expr(const LoopSIMD<T,S,A> &v, const LoopSIMD<T,S,A> &w) { \
│ │ │ │ +
using std::expr; \
│ │ │ │ +
LoopSIMD<T,S,A> out; \
│ │ │ │ +
for(std::size_t i=0; i<S; i++) { \
│ │ │ │ +
out[i] = expr(v[i],w[i]); \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
static_assert(true, "expecting ;")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_LOOP_STD_UNARY_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_LOOP_STD_UNARY_OP( expr)
│ │ │ │ +
│ │ │ │ +Value:
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ +
auto expr(const LoopSIMD<T,S,A> &v) { \
│ │ │ │ +
using std::expr; \
│ │ │ │ +
LoopSIMD<T,S,A> out; \
│ │ │ │ +
for(std::size_t i=0; i<S; i++) { \
│ │ │ │ +
out[i] = expr(v[i]); \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
\
│ │ │ │ +
template<class T, std::size_t S, std::size_t A> \
│ │ │ │ +
auto expr(const LoopSIMD<std::complex<T>,S,A> &v) { \
│ │ │ │ +
using std::expr; \
│ │ │ │ +
LoopSIMD<T,S,A> out; \
│ │ │ │ +
for(std::size_t i=0; i<S; i++) { \
│ │ │ │ +
out[i] = expr(v[i]); \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
static_assert(true, "expecting ;")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_LOOP_UNARY_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_LOOP_UNARY_OP( SYMBOL)
│ │ │ │ +
│ │ │ │ +Value:
auto operator SYMBOL() const { \
│ │ │ │ +
LoopSIMD<T,S,A> out; \
│ │ │ │ +
DUNE_PRAGMA_OMP_SIMD \
│ │ │ │ +
for(std::size_t i=0; i<S; i++){ \
│ │ │ │ +
out[i] = SYMBOL((*this)[i]); \
│ │ │ │ +
} \
│ │ │ │ +
return out; \
│ │ │ │ +
} \
│ │ │ │ +
static_assert(true, "expecting ;")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,22 +1,489 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -stdthread.cc File Reference │ │ │ │ │ + * simd │ │ │ │ │ +Classes | Namespaces | Macros | Functions │ │ │ │ │ +loop.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +Go_to_the_source_code_of_this_file. │ │ │ │ │ +Classes │ │ │ │ │ + class   Dune::LoopSIMD<_T,_S,_A_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::Simd::Overloads::ScalarType<_LoopSIMD<_T,_S,_A_>_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::Simd::Overloads::RebindType<_U,_LoopSIMD<_T,_S,_A_>_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::Simd::Overloads::LaneCount<_LoopSIMD<_T,_S,_A_>_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::IsNumber<_LoopSIMD<_T,_S,_A_>_> │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ +namespace   Dune::Simd │ │ │ │ │ +  Namespace for vectorization interface functions used by library │ │ │ │ │ + developers. │ │ │ │ │ +  │ │ │ │ │ +namespace   Dune::Simd::Overloads │ │ │ │ │ +  Namespace for the overloads and specializations that make up a SIMD │ │ │ │ │ + implementation. │ │ │ │ │ +  │ │ │ │ │ +namespace   Dune::MathOverloads │ │ │ │ │ +  namespace for customization of math functions with Dune-Semantics │ │ │ │ │ +  │ │ │ │ │ +Macros │ │ │ │ │ +#define  DUNE_PRAGMA_OMP_SIMD │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_LOOP_PREFIX_OP(SYMBOL) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_LOOP_UNARY_OP(SYMBOL) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_LOOP_POSTFIX_OP(SYMBOL) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_LOOP_ASSIGNMENT_OP(SYMBOL) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_LOOP_BINARY_OP(SYMBOL) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_LOOP_BITSHIFT_OP(SYMBOL) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_LOOP_COMPARISON_OP(SYMBOL) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_LOOP_BOOLEAN_OP(SYMBOL) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_LOOP_CMATH_UNARY_OP(expr) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN(expr, returnType) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_LOOP_STD_UNARY_OP(expr) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_LOOP_STD_BINARY_OP(expr) │ │ │ │ │ +  │ │ │ │ │ Functions │ │ │ │ │ -void  Dune::doAssertCallOnce (const char *file, int line, const char *function) │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_BINARY_OP (+) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_BINARY_OP (-) │ │ │ │ │ +  │ │ │ │ │ + DUNE_SIMD_LOOP_BINARY_OP *  Dune::DUNE_SIMD_LOOP_BINARY_OP (/);DUNE_SIMD_ │ │ │ │ │ + LOOP_BINARY_OP(% │ │ │ │ │ +  │ │ │ │ │ + DUNE_SIMD_LOOP_BINARY_OP &  Dune::DUNE_SIMD_LOOP_BINARY_OP (|);DUNE_SIMD_ │ │ │ │ │ + LOOP_BINARY_OP(^ │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_BITSHIFT_OP (<<) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_BITSHIFT_OP (> >) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_COMPARISON_OP (<) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_COMPARISON_OP (<=) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_COMPARISON_OP (>=) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_COMPARISON_OP (!=) │ │ │ │ │ +  │ │ │ │ │ +DUNE_SIMD_LOOP_BOOLEAN_OP &&  Dune::DUNE_SIMD_LOOP_BOOLEAN_OP (||);template< │ │ │ │ │ + class T, std::size_t S, std::size_t A > std:: │ │ │ │ │ + ostream &operator<<(std::ostream &os, const │ │ │ │ │ + LoopSIMD< T, S, A > &v │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::Overloads::lane (ADLTag< 5 >, std:: │ │ │ │ │ + size_t l, LoopSIMD< T, S, A > &&v) -> decltype │ │ │ │ │ + (std::move(Simd::lane(l%lanes< T >(), v[l/lanes< │ │ │ │ │ + T >()]))) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::Overloads::lane (ADLTag< 5 >, std:: │ │ │ │ │ + size_t l, const LoopSIMD< T, S, A > &v) - │ │ │ │ │ + > decltype(Simd::lane(l%lanes< T >(), v[l/lanes< │ │ │ │ │ + T >()])) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::Overloads::lane (ADLTag< 5 >, std:: │ │ │ │ │ + size_t l, LoopSIMD< T, S, A > &v) -> decltype │ │ │ │ │ + (Simd::lane(l%lanes< T >(), v[l/lanes< T >()])) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::Overloads::cond (ADLTag< 5 >, Simd:: │ │ │ │ │ + Mask< LoopSIMD< T, S, AM > > mask, LoopSIMD< T, │ │ │ │ │ + S, AD > ifTrue, LoopSIMD< T, S, AD > ifFalse) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::Simd::Overloads::cond (ADLTag< 5, std::is_ │ │ │ │ │ + same< bool, Simd::Scalar< M > >::value &&Simd:: │ │ │ │ │ + lanes< M >()==Simd::lanes< LoopSIMD< T, S, A > > │ │ │ │ │ + ()>, M mask, LoopSIMD< T, S, A > ifTrue, │ │ │ │ │ + LoopSIMD< T, S, A > ifFalse) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool  Dune::Simd::Overloads::anyTrue (ADLTag< 5 >, │ │ │ │ │ + LoopSIMD< M, S, A > mask) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool  Dune::Simd::Overloads::allTrue (ADLTag< 5 >, │ │ │ │ │ + LoopSIMD< M, S, A > mask) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool  Dune::Simd::Overloads::anyFalse (ADLTag< 5 >, │ │ │ │ │ + LoopSIMD< M, S, A > mask) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool  Dune::Simd::Overloads::allFalse (ADLTag< 5 >, │ │ │ │ │ + LoopSIMD< M, S, A > mask) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cos) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sin) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tan) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (acos) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (asin) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (atan) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cosh) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sinh) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tanh) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (acosh) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (asinh) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (atanh) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (exp) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log10) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (exp2) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (expm1) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN │ │ │ │ │ + (ilogb, int) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log1p) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (log2) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (logb) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (sqrt) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (cbrt) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (erf) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (erfc) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (tgamma) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (lgamma) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (ceil) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (floor) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (trunc) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (round) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN │ │ │ │ │ + (lround, long) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN │ │ │ │ │ + (llround, long long) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (rint) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN │ │ │ │ │ + (lrint, long) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP_WITH_RETURN │ │ │ │ │ + (llrint, long long) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (nearbyint) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (fabs) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_CMATH_UNARY_OP (abs) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_STD_UNARY_OP (real) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_STD_UNARY_OP (imag) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_STD_BINARY_OP (max) │ │ │ │ │ +  │ │ │ │ │ +   Dune::DUNE_SIMD_LOOP_STD_BINARY_OP (min) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::MathOverloads::isNaN (const LoopSIMD< T, S, │ │ │ │ │ + A > &v, PriorityTag< 3 >, ADLTag) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::MathOverloads::isInf (const LoopSIMD< T, S, │ │ │ │ │ + A > &v, PriorityTag< 3 >, ADLTag) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::MathOverloads::isFinite (const LoopSIMD< T, │ │ │ │ │ + S, A > &v, PriorityTag< 3 >, ADLTag) │ │ │ │ │   │ │ │ │ │ +***** Macro Definition Documentation ***** │ │ │ │ │ +***** ◆ DUNE_PRAGMA_OMP_SIMD ***** │ │ │ │ │ +#define DUNE_PRAGMA_OMP_SIMD │ │ │ │ │ +***** ◆ DUNE_SIMD_LOOP_ASSIGNMENT_OP ***** │ │ │ │ │ +#define DUNE_SIMD_LOOP_ASSIGNMENT_OP (   SYMBOL ) │ │ │ │ │ +Value: │ │ │ │ │ +auto operator SYMBOL(const Simd::Scalar s) { \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i &v) { \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i \ │ │ │ │ │ +auto operator SYMBOL(const LoopSIMD &v, const Simd::Scalar s) { \ │ │ │ │ │ +LoopSIMD out; \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i \ │ │ │ │ │ +auto operator SYMBOL(const Simd::Scalar s, const LoopSIMD &v) { \ │ │ │ │ │ +LoopSIMD out; \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i \ │ │ │ │ │ +auto operator SYMBOL(const LoopSIMD &v, \ │ │ │ │ │ +const LoopSIMD &w) { \ │ │ │ │ │ +LoopSIMD out; \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i \ │ │ │ │ │ +auto operator SYMBOL(const LoopSIMD &v, const U s) { \ │ │ │ │ │ +LoopSIMD out; \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i \ │ │ │ │ │ +auto operator SYMBOL(const LoopSIMD &v, \ │ │ │ │ │ +const LoopSIMD &w) { \ │ │ │ │ │ +LoopSIMD out; \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i \ │ │ │ │ │ +auto operator SYMBOL(const LoopSIMD &v, const Simd::Scalar s) { \ │ │ │ │ │ +Simd::Mask> out; \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i \ │ │ │ │ │ +auto operator SYMBOL(const Simd::Mask s, const LoopSIMD &v) { \ │ │ │ │ │ +Simd::Mask> out; \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i \ │ │ │ │ │ +auto operator SYMBOL(const LoopSIMD &v, \ │ │ │ │ │ +const LoopSIMD &w) { \ │ │ │ │ │ +Simd::Mask> out; \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i>::value> > \ │ │ │ │ │ +auto expr(const LoopSIMD &v) { \ │ │ │ │ │ +using std::expr; \ │ │ │ │ │ +LoopSIMD out; \ │ │ │ │ │ +for(std::size_t i=0; i>::value> > \ │ │ │ │ │ +auto expr(const LoopSIMD &v) { \ │ │ │ │ │ +using std::expr; \ │ │ │ │ │ +LoopSIMD out; \ │ │ │ │ │ +for(std::size_t i=0; i \ │ │ │ │ │ +auto operator SYMBOL(const LoopSIMD &v, const U s) { \ │ │ │ │ │ +Simd::Mask> out; \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i \ │ │ │ │ │ +auto operator SYMBOL(const Simd::Scalar s, const LoopSIMD &v) { \ │ │ │ │ │ +Simd::Mask> out; \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i \ │ │ │ │ │ +auto operator SYMBOL(const LoopSIMD &v, \ │ │ │ │ │ +const LoopSIMD &w) { \ │ │ │ │ │ +Simd::Mask> out; \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i out = *this; \ │ │ │ │ │ +SYMBOL(*this); \ │ │ │ │ │ +return out; \ │ │ │ │ │ +} \ │ │ │ │ │ +static_assert(true, "expecting ;") │ │ │ │ │ +***** ◆ DUNE_SIMD_LOOP_PREFIX_OP ***** │ │ │ │ │ +#define DUNE_SIMD_LOOP_PREFIX_OP (   SYMBOL ) │ │ │ │ │ +Value: │ │ │ │ │ +auto operator SYMBOL() { \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i \ │ │ │ │ │ +auto expr(const LoopSIMD &v, const LoopSIMD &w) { \ │ │ │ │ │ +using std::expr; \ │ │ │ │ │ +LoopSIMD out; \ │ │ │ │ │ +for(std::size_t i=0; i \ │ │ │ │ │ +auto expr(const LoopSIMD &v) { \ │ │ │ │ │ +using std::expr; \ │ │ │ │ │ +LoopSIMD out; \ │ │ │ │ │ +for(std::size_t i=0; i \ │ │ │ │ │ +auto expr(const LoopSIMD,S,A> &v) { \ │ │ │ │ │ +using std::expr; \ │ │ │ │ │ +LoopSIMD out; \ │ │ │ │ │ +for(std::size_t i=0; i out; \ │ │ │ │ │ +DUNE_PRAGMA_OMP_SIMD \ │ │ │ │ │ +for(std::size_t i=0; i │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: proxymemberaccess.hh File Reference │ │ │ │ +dune-common: test.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,47 +65,496 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ +Classes | │ │ │ │ Namespaces | │ │ │ │ -Functions
│ │ │ │ -
proxymemberaccess.hh File Reference
│ │ │ │ +Macros | │ │ │ │ +Typedefs
│ │ │ │ +
test.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

infrastructure for supporting operator->() on both references and proxies │ │ │ │ +

Common tests for simd abstraction implementations. │ │ │ │ More...

│ │ │ │ -
#include <type_traits>
│ │ │ │ +
#include <algorithm>
│ │ │ │ +#include <cstddef>
│ │ │ │ +#include <iostream>
│ │ │ │ +#include <sstream>
│ │ │ │ +#include <string>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <typeindex>
│ │ │ │ +#include <typeinfo>
│ │ │ │ +#include <unordered_set>
│ │ │ │ #include <utility>
│ │ │ │ +#include <dune/common/classname.hh>
│ │ │ │ +#include <dune/common/hybridutilities.hh>
│ │ │ │ +#include <dune/common/rangeutilities.hh>
│ │ │ │ +#include <dune/common/simd/io.hh>
│ │ │ │ +#include <dune/common/simd/loop.hh>
│ │ │ │ +#include <dune/common/simd/simd.hh>
│ │ │ │ +#include <dune/common/std/type_traits.hh>
│ │ │ │ +#include <dune/common/typelist.hh>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

struct  Dune::Simd::EndMark
 final element marker for RebindList More...
 
class  Dune::Simd::UnitTest
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ -Functions

template<typename T >
pointer_or_proxy_holder Dune::handle_proxy_member_access (T &&t)
 Transparent support for providing member access to both lvalues and rvalues (temporary proxies).
 

│ │ │ │ +Macros

#define DUNE_SIMD_CHECK(expr)    ((expr) ? void() : complain(__FILE__, __LINE__, __func__, #expr))
 
#define DUNE_SIMD_CHECK_OP(expr)
 
#define DUNE_SIMD_POSTFIX_OP(NAME, SYMBOL)
 
#define DUNE_SIMD_PREFIX_OP(NAME, SYMBOL)
 
#define DUNE_SIMD_OPNAME   (className<Op(V)>())
 
#define DUNE_SIMD_INFIX_OP(NAME, SYMBOL)
 
#define DUNE_SIMD_ASSIGN_OP(NAME, SYMBOL)
 
#define DUNE_SIMD_REPL_OP(NAME, REPLFN, SYMBOL)
 
#define DUNE_SIMD_OPNAME   (className<OpInfixComma(T1, T2)>())
 
#define DUNE_SIMD_OPNAME   (className<Op(V1, V2)>())
 
#define DUNE_SIMD_OPNAME   (className<Op(V1, T2)>())
 
#define DUNE_SIMD_OPNAME   (className<Op(V1, T2)>())
 
#define DUNE_SIMD_OPNAME   (className<Op(V1, P2)>())
 
#define DUNE_SIMD_DO(M1, M2, M3, V1, V2, V3, NAME)
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Typedefs

template<class... Types>
using Dune::Simd::RebindList = typename Impl::RemoveEnd< EndMark, TypeList< Types... > >::type
 A list of types with the final element removed.
 
template<class T >
using Dune::Simd::IsLoop = typename Impl::IsLoop< T >::type
 check whether a type is an instance of LoopSIMD
 
│ │ │ │

Detailed Description

│ │ │ │ -

infrastructure for supporting operator->() on both references and proxies

│ │ │ │ -
│ │ │ │ +

Common tests for simd abstraction implementations.

│ │ │ │ +

This file is an interface header and may be included without restrictions.

│ │ │ │ +

Macro Definition Documentation

│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_ASSIGN_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_ASSIGN_OP( NAME,
 SYMBOL 
)
│ │ │ │ +
│ │ │ │ +Value:
struct OpInfix##NAME \
│ │ │ │ +
{ \
│ │ │ │ +
template<class V1, class V2> \
│ │ │ │ +
decltype(auto) operator()(V1&& v1, V2&& v2) const \
│ │ │ │ +
{ \
│ │ │ │ +
return std::forward<V1>(v1) SYMBOL std::forward<V2>(v2); \
│ │ │ │ +
} \
│ │ │ │ +
template<class S1, class S2> \
│ │ │ │ +
auto scalar(S1& s1, S2&& s2) const \
│ │ │ │ +
-> decltype(s1 SYMBOL std::forward<S2>(s2)); \
│ │ │ │ +
}
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_CHECK

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_CHECK( expr)    ((expr) ? void() : complain(__FILE__, __LINE__, __func__, #expr))
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_CHECK_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_CHECK_OP( expr)
│ │ │ │ +
│ │ │ │ +Value:
((expr) ? void() : complain(__FILE__, __LINE__, __func__, \
│ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_OPNAME
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_DO

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_DO( M1,
 M2,
 M3,
 V1,
 V2,
 V3,
 NAME 
)
│ │ │ │ +
│ │ │ │ +Value:
checker(bool_constant<isMask ? do_##M1 : do_##V1>{}, \
│ │ │ │ +
bool_constant<isMask ? do_##M2 : do_##V2>{}, \
│ │ │ │ +
bool_constant<isMask ? do_##M3 : do_##V3>{}, \
│ │ │ │ +
Op##NAME{})
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_INFIX_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_INFIX_OP( NAME,
 SYMBOL 
)
│ │ │ │ +
│ │ │ │ +Value:
struct OpInfix##NAME \
│ │ │ │ +
{ \
│ │ │ │ +
template<class V1, class V2> \
│ │ │ │ +
decltype(auto) operator()(V1&& v1, V2&& v2) const \
│ │ │ │ +
{ \
│ │ │ │ +
return std::forward<V1>(v1) SYMBOL std::forward<V2>(v2); \
│ │ │ │ +
} \
│ │ │ │ +
template<class S1, class S2> \
│ │ │ │ +
auto scalar(S1&& s1, S2&& s2) const \
│ │ │ │ +
-> decltype(std::forward<S1>(s1) SYMBOL std::forward<S2>(s2)); \
│ │ │ │ +
}
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_OPNAME [1/6]

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_OPNAME   (className<Op(V)>())
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_OPNAME [2/6]

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_OPNAME   (className<OpInfixComma(T1, T2)>())
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_OPNAME [3/6]

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_OPNAME   (className<Op(V1, V2)>())
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_OPNAME [4/6]

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_OPNAME   (className<Op(V1, T2)>())
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_OPNAME [5/6]

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_OPNAME   (className<Op(V1, T2)>())
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_OPNAME [6/6]

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_OPNAME   (className<Op(V1, P2)>())
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_POSTFIX_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_POSTFIX_OP( NAME,
 SYMBOL 
)
│ │ │ │ +
│ │ │ │ +Value:
struct OpPostfix##NAME \
│ │ │ │ +
{ \
│ │ │ │ +
template<class V> \
│ │ │ │ +
auto operator()(V&& v) const \
│ │ │ │ +
-> decltype(std::forward<V>(v) SYMBOL) \
│ │ │ │ +
{ \
│ │ │ │ +
return std::forward<V>(v) SYMBOL; \
│ │ │ │ +
} \
│ │ │ │ +
}
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_PREFIX_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_PREFIX_OP( NAME,
 SYMBOL 
)
│ │ │ │ +
│ │ │ │ +Value:
struct OpPrefix##NAME \
│ │ │ │ +
{ \
│ │ │ │ +
template<class V> \
│ │ │ │ +
auto operator()(V&& v) const \
│ │ │ │ +
-> decltype(SYMBOL std::forward<V>(v)) \
│ │ │ │ +
{ \
│ │ │ │ +
return SYMBOL std::forward<V>(v); \
│ │ │ │ +
} \
│ │ │ │ +
}
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_SIMD_REPL_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_REPL_OP( NAME,
 REPLFN,
 SYMBOL 
)
│ │ │ │ +
│ │ │ │ +Value:
struct OpInfix##NAME \
│ │ │ │ +
{ \
│ │ │ │ +
template<class V1, class V2> \
│ │ │ │ +
decltype(auto) operator()(V1&& v1, V2&& v2) const \
│ │ │ │ +
{ \
│ │ │ │ +
return Simd::REPLFN(std::forward<V1>(v1), std::forward<V2>(v2)); \
│ │ │ │ +
} \
│ │ │ │ +
template<class S1, class S2> \
│ │ │ │ +
auto scalar(S1&& s1, S2&& s2) const \
│ │ │ │ +
-> decltype(std::forward<S1>(s1) SYMBOL std::forward<S2>(s2)); \
│ │ │ │ +
}
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,28 +1,203 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Namespaces | Functions │ │ │ │ │ -proxymemberaccess.hh File Reference │ │ │ │ │ -Common » Utilities » C++_utilities_and_backports │ │ │ │ │ -infrastructure for supporting operator->() on both references and proxies │ │ │ │ │ -More... │ │ │ │ │ + * simd │ │ │ │ │ +Classes | Namespaces | Macros | Typedefs │ │ │ │ │ +test.hh File Reference │ │ │ │ │ +Common tests for simd abstraction implementations. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ +Classes │ │ │ │ │ +struct   Dune::Simd::EndMark │ │ │ │ │ +  final element marker for RebindList More... │ │ │ │ │ +  │ │ │ │ │ + class   Dune::Simd::UnitTest │ │ │ │ │ +  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Functions │ │ │ │ │ -template │ │ │ │ │ -pointer_or_proxy_holder  Dune::handle_proxy_member_access (T &&t) │ │ │ │ │ -  Transparent support for providing member access to │ │ │ │ │ - both lvalues and rvalues (temporary proxies). │ │ │ │ │ +namespace   Dune::Simd │ │ │ │ │ +  Namespace for vectorization interface functions used by library │ │ │ │ │ + developers. │ │ │ │ │ +  │ │ │ │ │ +Macros │ │ │ │ │ +#define  DUNE_SIMD_CHECK(expr)    ((expr) ? void() : complain(__FILE__, __LINE_ │ │ │ │ │ + _, __func__, #expr)) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_CHECK_OP(expr) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_POSTFIX_OP(NAME, SYMBOL) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_PREFIX_OP(NAME, SYMBOL) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_INFIX_OP(NAME, SYMBOL) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_ASSIGN_OP(NAME, SYMBOL) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_REPL_OP(NAME, REPLFN, SYMBOL) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_SIMD_DO(M1, M2, M3, V1, V2, V3, NAME) │ │ │ │ │ +  │ │ │ │ │ +Typedefs │ │ │ │ │ +template │ │ │ │ │ +using  Dune::Simd::RebindList = typename Impl::RemoveEnd< EndMark, TypeList< │ │ │ │ │ + Types... > >::type │ │ │ │ │ +  A list of types with the final element removed. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +using  Dune::Simd::IsLoop = typename Impl::IsLoop< T >::type │ │ │ │ │ +  check whether a type is an instance of LoopSIMD │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -infrastructure for supporting operator->() on both references and proxies │ │ │ │ │ +Common tests for simd abstraction implementations. │ │ │ │ │ +This file is an interface header and may be included without restrictions. │ │ │ │ │ +***** Macro Definition Documentation ***** │ │ │ │ │ +***** ◆ DUNE_SIMD_ASSIGN_OP ***** │ │ │ │ │ +#define DUNE_SIMD_ASSIGN_OP (   NAME, │ │ │ │ │ +   SYMBOL  │ │ │ │ │ + ) │ │ │ │ │ +Value: │ │ │ │ │ +struct OpInfix##NAME \ │ │ │ │ │ +{ \ │ │ │ │ │ +template \ │ │ │ │ │ +decltype(auto) operator()(V1&& v1, V2&& v2) const \ │ │ │ │ │ +{ \ │ │ │ │ │ +return std::forward(v1) SYMBOL std::forward(v2); \ │ │ │ │ │ +} \ │ │ │ │ │ +template \ │ │ │ │ │ +auto scalar(S1& s1, S2&& s2) const \ │ │ │ │ │ +-> decltype(s1 SYMBOL std::forward(s2)); \ │ │ │ │ │ +} │ │ │ │ │ +***** ◆ DUNE_SIMD_CHECK ***** │ │ │ │ │ +#define DUNE_SIMD_CHECK (   expr )     ((expr) ? void() : complain(__FILE__, __ │ │ │ │ │ + LINE__, __func__, #expr)) │ │ │ │ │ +***** ◆ DUNE_SIMD_CHECK_OP ***** │ │ │ │ │ +#define DUNE_SIMD_CHECK_OP (   expr ) │ │ │ │ │ +Value: │ │ │ │ │ +((expr) ? void() : complain(__FILE__, __LINE__, __func__, \ │ │ │ │ │ +DUNE_SIMD_OPNAME, #expr)) │ │ │ │ │ +DUNE_SIMD_OPNAME │ │ │ │ │ +#define DUNE_SIMD_OPNAME │ │ │ │ │ +***** ◆ DUNE_SIMD_DO ***** │ │ │ │ │ +#define DUNE_SIMD_DO (   M1, │ │ │ │ │ +   M2, │ │ │ │ │ +   M3, │ │ │ │ │ +   V1, │ │ │ │ │ +   V2, │ │ │ │ │ +   V3, │ │ │ │ │ +   NAME  │ │ │ │ │ + ) │ │ │ │ │ +Value: │ │ │ │ │ +checker(bool_constant{}, \ │ │ │ │ │ +bool_constant{}, \ │ │ │ │ │ +bool_constant{}, \ │ │ │ │ │ +Op##NAME{}) │ │ │ │ │ +***** ◆ DUNE_SIMD_INFIX_OP ***** │ │ │ │ │ +#define DUNE_SIMD_INFIX_OP (   NAME, │ │ │ │ │ +   SYMBOL  │ │ │ │ │ + ) │ │ │ │ │ +Value: │ │ │ │ │ +struct OpInfix##NAME \ │ │ │ │ │ +{ \ │ │ │ │ │ +template \ │ │ │ │ │ +decltype(auto) operator()(V1&& v1, V2&& v2) const \ │ │ │ │ │ +{ \ │ │ │ │ │ +return std::forward(v1) SYMBOL std::forward(v2); \ │ │ │ │ │ +} \ │ │ │ │ │ +template \ │ │ │ │ │ +auto scalar(S1&& s1, S2&& s2) const \ │ │ │ │ │ +-> decltype(std::forward(s1) SYMBOL std::forward(s2)); \ │ │ │ │ │ +} │ │ │ │ │ +***** ◆ DUNE_SIMD_OPNAME [1/6] ***** │ │ │ │ │ +#define DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ +***** ◆ DUNE_SIMD_OPNAME [2/6] ***** │ │ │ │ │ +#define DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ +***** ◆ DUNE_SIMD_OPNAME [3/6] ***** │ │ │ │ │ +#define DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ +***** ◆ DUNE_SIMD_OPNAME [4/6] ***** │ │ │ │ │ +#define DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ +***** ◆ DUNE_SIMD_OPNAME [5/6] ***** │ │ │ │ │ +#define DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ +***** ◆ DUNE_SIMD_OPNAME [6/6] ***** │ │ │ │ │ +#define DUNE_SIMD_OPNAME   (className()) │ │ │ │ │ +***** ◆ DUNE_SIMD_POSTFIX_OP ***** │ │ │ │ │ +#define DUNE_SIMD_POSTFIX_OP (   NAME, │ │ │ │ │ +   SYMBOL  │ │ │ │ │ + ) │ │ │ │ │ +Value: │ │ │ │ │ +struct OpPostfix##NAME \ │ │ │ │ │ +{ \ │ │ │ │ │ +template \ │ │ │ │ │ +auto operator()(V&& v) const \ │ │ │ │ │ +-> decltype(std::forward(v) SYMBOL) \ │ │ │ │ │ +{ \ │ │ │ │ │ +return std::forward(v) SYMBOL; \ │ │ │ │ │ +} \ │ │ │ │ │ +} │ │ │ │ │ +***** ◆ DUNE_SIMD_PREFIX_OP ***** │ │ │ │ │ +#define DUNE_SIMD_PREFIX_OP (   NAME, │ │ │ │ │ +   SYMBOL  │ │ │ │ │ + ) │ │ │ │ │ +Value: │ │ │ │ │ +struct OpPrefix##NAME \ │ │ │ │ │ +{ \ │ │ │ │ │ +template \ │ │ │ │ │ +auto operator()(V&& v) const \ │ │ │ │ │ +-> decltype(SYMBOL std::forward(v)) \ │ │ │ │ │ +{ \ │ │ │ │ │ +return SYMBOL std::forward(v); \ │ │ │ │ │ +} \ │ │ │ │ │ +} │ │ │ │ │ +***** ◆ DUNE_SIMD_REPL_OP ***** │ │ │ │ │ +#define DUNE_SIMD_REPL_OP (   NAME, │ │ │ │ │ +   REPLFN, │ │ │ │ │ +   SYMBOL  │ │ │ │ │ + ) │ │ │ │ │ +Value: │ │ │ │ │ +struct OpInfix##NAME \ │ │ │ │ │ +{ \ │ │ │ │ │ +template \ │ │ │ │ │ +decltype(auto) operator()(V1&& v1, V2&& v2) const \ │ │ │ │ │ +{ \ │ │ │ │ │ +return Simd::REPLFN(std::forward(v1), std::forward(v2)); \ │ │ │ │ │ +} \ │ │ │ │ │ +template \ │ │ │ │ │ +auto scalar(S1&& s1, S2&& s2) const \ │ │ │ │ │ +-> decltype(std::forward(s1) SYMBOL std::forward(s2)); \ │ │ │ │ │ +} │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00029_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: proxymemberaccess.hh Source File │ │ │ │ +dune-common: test.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,111 +70,2027 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
proxymemberaccess.hh
│ │ │ │ +
test.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ -
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ -
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PROXYMEMBERACCESS_HH
│ │ │ │ -
6#define DUNE_COMMON_PROXYMEMBERACCESS_HH
│ │ │ │ -
7
│ │ │ │ -
14#include <type_traits>
│ │ │ │ -
15#include <utility>
│ │ │ │ -
16
│ │ │ │ -
17namespace Dune {
│ │ │ │ -
18
│ │ │ │ -
19 namespace Impl {
│ │ │ │ -
20
│ │ │ │ -
21 // helper struct to store a temporary / proxy
│ │ │ │ -
22 // for the duration of the member access
│ │ │ │ -
23 template<typename T>
│ │ │ │ -
24 struct member_access_proxy_holder
│ │ │ │ -
25 {
│ │ │ │ -
26
│ │ │ │ -
27 // only support moving the temporary into the holder object
│ │ │ │ -
28 member_access_proxy_holder(T&& t)
│ │ │ │ -
29 : _t(std::move(t))
│ │ │ │ -
30 {}
│ │ │ │ -
31
│ │ │ │ -
32 // The object is fundamentally a temporary, i.e. an rvalue,
│ │ │ │ -
33 //
│ │ │ │ -
34 const T* operator->() const
│ │ │ │ -
35 {
│ │ │ │ -
36 return &_t;
│ │ │ │ -
37 }
│ │ │ │ -
38
│ │ │ │ -
39 T _t;
│ │ │ │ -
40
│ │ │ │ -
41 };
│ │ │ │ -
42
│ │ │ │ -
43 } // end Impl namespace
│ │ │ │ -
44
│ │ │ │ +Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
3#ifndef DUNE_COMMON_SIMD_TEST_HH
│ │ │ │ +
4#define DUNE_COMMON_SIMD_TEST_HH
│ │ │ │ +
5
│ │ │ │ +
12#include <algorithm>
│ │ │ │ +
13#include <cstddef>
│ │ │ │ +
14#include <iostream>
│ │ │ │ +
15#include <sstream>
│ │ │ │ +
16#include <string>
│ │ │ │ +
17#include <type_traits>
│ │ │ │ +
18#include <typeindex>
│ │ │ │ +
19#include <typeinfo>
│ │ │ │ +
20#include <unordered_set>
│ │ │ │ +
21#include <utility>
│ │ │ │ +
22
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
32
│ │ │ │ +
33namespace Dune {
│ │ │ │ +
34 namespace Simd {
│ │ │ │ +
35
│ │ │ │ +
36 namespace Impl {
│ │ │ │ +
37
│ │ │ │ +
38 template<class T, class SFINAE = void>
│ │ │ │ +
39 struct LessThenComparable : std::false_type {};
│ │ │ │ +
40 template<class T>
│ │ │ │ +
41 struct LessThenComparable<T, std::void_t<decltype(std::declval<T>()
│ │ │ │ +
42 < std::declval<T>())> > :
│ │ │ │ +
43 std::true_type
│ │ │ │ +
44 {};
│ │ │ │
45
│ │ │ │ -
46#ifdef DOXYGEN
│ │ │ │ -
47
│ │ │ │ -
49
│ │ │ │ -
79 template<typename T>
│ │ │ │ -
80 pointer_or_proxy_holder
│ │ │ │ - │ │ │ │ -
82
│ │ │ │ -
83#else // DOXYGEN
│ │ │ │ +
46 template<class Dst, class Src>
│ │ │ │ +
47 struct CopyConstHelper
│ │ │ │ +
48 {
│ │ │ │ +
49 using type = Dst;
│ │ │ │ +
50 };
│ │ │ │ +
51 template<class Dst, class Src>
│ │ │ │ +
52 struct CopyConstHelper<Dst, const Src>
│ │ │ │ +
53 {
│ │ │ │ +
54 using type = std::add_const_t<Dst>;
│ │ │ │ +
55 };
│ │ │ │ +
56
│ │ │ │ +
57 template<class Dst, class Src>
│ │ │ │ +
58 struct CopyVolatileHelper
│ │ │ │ +
59 {
│ │ │ │ +
60 using type = Dst;
│ │ │ │ +
61 };
│ │ │ │ +
62 template<class Dst, class Src>
│ │ │ │ +
63 struct CopyVolatileHelper<Dst, volatile Src>
│ │ │ │ +
64 {
│ │ │ │ +
65 using type = std::add_volatile_t<Dst>;
│ │ │ │ +
66 };
│ │ │ │ +
67
│ │ │ │ +
68 template<class Dst, class Src>
│ │ │ │ +
69 struct CopyReferenceHelper
│ │ │ │ +
70 {
│ │ │ │ +
71 using type = Dst;
│ │ │ │ +
72 };
│ │ │ │ +
73 template<class Dst, class Src>
│ │ │ │ +
74 struct CopyReferenceHelper<Dst, Src&>
│ │ │ │ +
75 {
│ │ │ │ +
76 using type = std::add_lvalue_reference_t<Dst>;
│ │ │ │ +
77 };
│ │ │ │ +
78
│ │ │ │ +
79 template<class Dst, class Src>
│ │ │ │ +
80 struct CopyReferenceHelper<Dst, Src&&>
│ │ │ │ +
81 {
│ │ │ │ +
82 using type = std::add_rvalue_reference_t<Dst>;
│ │ │ │ +
83 };
│ │ │ │
84
│ │ │ │ -
85
│ │ │ │ -
86 // This version matches lvalues (the C++ type deduction rules state that
│ │ │ │ -
87 // the T&& signature deduces to a reference iff the argument is an lvalue).
│ │ │ │ -
88 // As the argument is an lvalue, we do not have to worry about its lifetime
│ │ │ │ -
89 // and can just return its address.
│ │ │ │ -
90 template<typename T>
│ │ │ │ -
91 inline typename std::enable_if<
│ │ │ │ -
92 std::is_lvalue_reference<T>::value,
│ │ │ │ -
93 typename std::add_pointer<
│ │ │ │ -
94 typename std::remove_reference<
│ │ │ │ -
95 T
│ │ │ │ -
96 >::type
│ │ │ │ -
97 >::type
│ │ │ │ -
98 >::type
│ │ │ │ - │ │ │ │ -
100 {
│ │ │ │ -
101 return &target;
│ │ │ │ -
102 }
│ │ │ │ -
103
│ │ │ │ -
104 // This version matches rvalues (the C++ type deduction rules state that
│ │ │ │ -
105 // the T&& signature deduces to a non-reference iff the argument is an rvalue).
│ │ │ │ -
106 // In this case, we have to capture the rvalue in a new object to make sure it
│ │ │ │ -
107 // is kept alive for the duration of the member access. For this purpose, we move
│ │ │ │ -
108 // it into a member_access_proxy_holder instance.
│ │ │ │ -
109 template<typename T>
│ │ │ │ -
110 inline typename std::enable_if<
│ │ │ │ -
111 !std::is_lvalue_reference<T>::value,
│ │ │ │ -
112 Impl::member_access_proxy_holder<T>
│ │ │ │ -
113 >::type
│ │ │ │ - │ │ │ │ -
115 {
│ │ │ │ -
116 return {std::forward<T>(target)};
│ │ │ │ -
117 }
│ │ │ │ +
85 template<class Dst, class Src>
│ │ │ │ +
86 using CopyRefQual = typename CopyReferenceHelper<
│ │ │ │ +
87 typename CopyVolatileHelper<
│ │ │ │ +
88 typename CopyConstHelper<
│ │ │ │ +
89 std::decay_t<Dst>,
│ │ │ │ +
90 std::remove_reference_t<Src>
│ │ │ │ +
91 >::type,
│ │ │ │ +
92 std::remove_reference_t<Src>
│ │ │ │ +
93 >::type,
│ │ │ │ +
94 Src
│ │ │ │ +
95 >::type;
│ │ │ │ +
96
│ │ │ │ +
97 template<class Mark, class Types,
│ │ │ │ +
98 class Indices =
│ │ │ │ +
99 std::make_index_sequence<TypeListSize<Types>::value - 1> >
│ │ │ │ +
100 struct RemoveEnd;
│ │ │ │ +
101 template<class Mark, class Types, std::size_t... I>
│ │ │ │ +
102 struct RemoveEnd<Mark, Types, std::index_sequence<I...>>
│ │ │ │ +
103 {
│ │ │ │ +
104 using Back = TypeListEntry_t<TypeListSize<Types>::value - 1, Types>;
│ │ │ │ +
105 static_assert(std::is_same<Mark, Back>::value,
│ │ │ │ +
106 "TypeList not terminated by proper EndMark");
│ │ │ │ +
107 using type = TypeList<TypeListEntry_t<I, Types>...>;
│ │ │ │ +
108 };
│ │ │ │ +
109
│ │ │ │ +
110 template<class T, class List, class = void>
│ │ │ │ +
111 struct TypeInList;
│ │ │ │ +
112
│ │ │ │ +
113 template<class T>
│ │ │ │ +
114 struct TypeInList<T, TypeList<> > : std::false_type {};
│ │ │ │ +
115
│ │ │ │ +
116 template<class T, class... Rest>
│ │ │ │ +
117 struct TypeInList<T, TypeList<T, Rest...> > : std::true_type {};
│ │ │ │
118
│ │ │ │ -
119#endif // DOXYGEN
│ │ │ │ -
120
│ │ │ │ -
121} // namespace Dune
│ │ │ │ -
122
│ │ │ │ -
123#endif // DUNE_COMMON_PROXYMEMBERACCESS_HH
│ │ │ │ -
pointer_or_proxy_holder handle_proxy_member_access(T &&t)
Transparent support for providing member access to both lvalues and rvalues (temporary proxies).
│ │ │ │ +
119 template<class T, class Head, class... Rest>
│ │ │ │ +
120 struct TypeInList<T, TypeList<Head, Rest...>,
│ │ │ │ +
121 std::enable_if_t<!std::is_same<T, Head>::value> > :
│ │ │ │ +
122 TypeInList<T, TypeList<Rest...> >::type
│ │ │ │ +
123 {};
│ │ │ │ +
124
│ │ │ │ +
125 template<class T>
│ │ │ │ +
126 struct IsLoop : std::false_type {};
│ │ │ │ +
127 template<class T, std::size_t S>
│ │ │ │ +
128 struct IsLoop<LoopSIMD<T, S> > : std::true_type {};
│ │ │ │ +
129
│ │ │ │ +
130 // used inside static_assert to trick the compiler into printing a list
│ │ │ │ +
131 // of types:
│ │ │ │ +
132 //
│ │ │ │ +
133 // static_assert(debugTypes<V>(Std::bool_constant<condition>{}), "msg");
│ │ │ │ +
134 //
│ │ │ │ +
135 // Should include what the type `V` expands to in the error message.
│ │ │ │ +
136 template<class...>
│ │ │ │ +
137 constexpr bool debugTypes(std::true_type) { return true; }
│ │ │ │ +
138 template<class... Types>
│ │ │ │ +
139 [[deprecated]]
│ │ │ │ +
140 constexpr bool debugTypes(std::false_type) { return false; }
│ │ │ │ +
141
│ │ │ │ +
142 } // namespace Impl
│ │ │ │ +
143
│ │ │ │ +
145 struct EndMark {};
│ │ │ │ +
147
│ │ │ │ +
156 template<class... Types>
│ │ │ │ + │ │ │ │ +
158 typename Impl::RemoveEnd<EndMark, TypeList<Types...> >::type;
│ │ │ │ +
159
│ │ │ │ +
161 template<class T>
│ │ │ │ +
162 using IsLoop = typename Impl::IsLoop<T>::type;
│ │ │ │ +
163
│ │ │ │ +
│ │ │ │ +
164 class UnitTest {
│ │ │ │ +
165 bool good_ = true;
│ │ │ │ +
166 std::ostream &log_ = std::cerr;
│ │ │ │ +
167 // records the types for which checks have started running to avoid
│ │ │ │ +
168 // infinite recursion
│ │ │ │ +
169 std::unordered_set<std::type_index> seen_;
│ │ │ │ +
170
│ │ │ │ +
172 //
│ │ │ │ +
173 // Helper functions
│ │ │ │ +
174 //
│ │ │ │ +
175
│ │ │ │ +
176 void complain(const char *file, int line, const char *func,
│ │ │ │ +
177 const char *expr);
│ │ │ │ +
178
│ │ │ │ +
179 void complain(const char *file, int line, const char *func,
│ │ │ │ +
180 const std::string &opname, const char *expr);
│ │ │ │ +
181
│ │ │ │ +
182 // This macro is defined only within this file, do not use anywhere
│ │ │ │ +
183 // else. Doing the actual printing in an external function dramatically
│ │ │ │ +
184 // reduces memory use during compilation. Defined in such a way that
│ │ │ │ +
185 // the call will only happen for failed checks.
│ │ │ │ +
│ │ │ │ +
186#define DUNE_SIMD_CHECK(expr) \
│ │ │ │ +
187 ((expr) ? void() : complain(__FILE__, __LINE__, __func__, #expr))
│ │ │ │ +
│ │ │ │ +
188
│ │ │ │ +
189 // the function using this macro must define a way to compute the
│ │ │ │ +
190 // operator name in DUNE_SIMD_OPNAME
│ │ │ │ +
│ │ │ │ +
191#define DUNE_SIMD_CHECK_OP(expr) \
│ │ │ │ +
192 ((expr) ? void() : complain(__FILE__, __LINE__, __func__, \
│ │ │ │ +
193 DUNE_SIMD_OPNAME, #expr))
│ │ │ │ +
│ │ │ │ +
194
│ │ │ │ +
195 // "cast" into a prvalue
│ │ │ │ +
196 template<class T>
│ │ │ │ +
197 static std::decay_t<T> prvalue(T &&t)
│ │ │ │ +
198 {
│ │ │ │ +
199 return std::forward<T>(t);
│ │ │ │ +
200 }
│ │ │ │ +
201
│ │ │ │ +
202 // whether the vector is 42 in all lanes
│ │ │ │ +
203 template<class V>
│ │ │ │ +
204 static bool is42(const V &v)
│ │ │ │ +
205 {
│ │ │ │ +
206 bool good = true;
│ │ │ │ +
207
│ │ │ │ +
208 for(std::size_t l = 0; l < lanes(v); ++l)
│ │ │ │ +
209 // need to cast in case we have a mask type
│ │ │ │ +
210 good &= (lane(l, v) == Scalar<V>(42));
│ │ │ │ +
211
│ │ │ │ +
212 return good;
│ │ │ │ +
213 }
│ │ │ │ +
214
│ │ │ │ +
215 // make a vector that contains the sequence { 1, 2, ... }
│ │ │ │ +
216 template<class V>
│ │ │ │ +
217 static V make123()
│ │ │ │ +
218 {
│ │ │ │ +
219 // initialize to avoid undefined behaviour if assigning to lane()
│ │ │ │ +
220 // involves lvalue-to-rvalue conversions, e.g. due to bitmask
│ │ │ │ +
221 // operations. Avoid using broadcast<V>() for initialization to avoid
│ │ │ │ +
222 // test interdependencies.
│ │ │ │ +
223 V vec(Scalar<V>(0));
│ │ │ │ +
224 for(std::size_t l = 0; l < lanes(vec); ++l)
│ │ │ │ +
225 lane(l, vec) = l + 1;
│ │ │ │ +
226 return vec;
│ │ │ │ +
227 }
│ │ │ │ +
228
│ │ │ │ +
229 // whether the vector contains the sequence { 1, 2, ... }
│ │ │ │ +
230 template<class V>
│ │ │ │ +
231 static bool is123(const V &v)
│ │ │ │ +
232 {
│ │ │ │ +
233 bool good = true;
│ │ │ │ +
234
│ │ │ │ +
235 for(std::size_t l = 0; l < lanes(v); ++l)
│ │ │ │ +
236 // need to cast in case we have a mask type
│ │ │ │ +
237 good &= (lane(l, v) == Scalar<V>(l+1));
│ │ │ │ +
238
│ │ │ │ +
239 return good;
│ │ │ │ +
240 }
│ │ │ │ +
241
│ │ │ │ +
242 template<class V>
│ │ │ │ +
243 static V leftVector()
│ │ │ │ +
244 {
│ │ │ │ +
245 // Avoid using broadcast<V>() for initialization to avoid test
│ │ │ │ +
246 // interdependencies.
│ │ │ │ +
247 V res(Scalar<V>(0));
│ │ │ │ +
248 for(std::size_t l = 0; l < lanes(res); ++l)
│ │ │ │ +
249 lane(l, res) = Scalar<V>(l+1);
│ │ │ │ +
250 return res;
│ │ │ │ +
251 }
│ │ │ │ +
252
│ │ │ │ +
253 template<class V>
│ │ │ │ +
254 static V rightVector()
│ │ │ │ +
255 {
│ │ │ │ +
256 // Avoid using broadcast<V>() for initialization to avoid test
│ │ │ │ +
257 // interdependencies.
│ │ │ │ +
258 V res(Scalar<V>(0));
│ │ │ │ +
259 for(std::size_t l = 0; l < lanes(res); ++l)
│ │ │ │ +
260 // do not exceed number of bits in char (for shifts)
│ │ │ │ +
261 // avoid 0 (for / and %)
│ │ │ │ +
262 lane(l, res) = Scalar<V>((l)%7+1);
│ │ │ │ +
263 return res;
│ │ │ │ +
264 }
│ │ │ │ +
265
│ │ │ │ +
266 template<class T>
│ │ │ │ +
267 static T leftScalar()
│ │ │ │ +
268 {
│ │ │ │ +
269 return T(42);
│ │ │ │ +
270 }
│ │ │ │ +
271
│ │ │ │ +
272 template<class T>
│ │ │ │ +
273 static T rightScalar()
│ │ │ │ +
274 {
│ │ │ │ +
275 // do not exceed number of bits in char (for shifts)
│ │ │ │ +
276 // avoid 0 (for / and %)
│ │ │ │ +
277 return T(5);
│ │ │ │ +
278 }
│ │ │ │ +
279
│ │ │ │ +
280 template<class Dst, class Src>
│ │ │ │ +
281 using CopyRefQual = Impl::CopyRefQual<Dst, Src>;
│ │ │ │ +
282
│ │ │ │ +
283 // test whether the Op supports the operation on scalars. We do not use
│ │ │ │ +
284 // `lane()` to obtain the scalars, because that might return a proxy
│ │ │ │ +
285 // object, and we are interested in what exactly the scalar type can do,
│ │ │ │ +
286 // no a proxy that might have more overloads than needed. In addition,
│ │ │ │ +
287 // `lane()` may not preserve `const` and reference qualifiers.
│ │ │ │ +
288 template<class Op, class... Vectors>
│ │ │ │ +
289 using ScalarResult =
│ │ │ │ +
290 decltype(std::declval<Op>().
│ │ │ │ +
291 scalar(std::declval<CopyRefQual<Scalar<Vectors>,
│ │ │ │ +
292 Vectors> >()...));
│ │ │ │ +
293
│ │ │ │ +
295 //
│ │ │ │ +
296 // Check associated types
│ │ │ │ +
297 //
│ │ │ │ +
298
│ │ │ │ +
299 template<class V>
│ │ │ │ +
300 void checkScalar()
│ │ │ │ +
301 {
│ │ │ │ +
302 // check that the type Scalar<V> exists
│ │ │ │ +
303 using T = Scalar<V>;
│ │ │ │ +
304
│ │ │ │ +
305 static_assert(std::is_same<T, std::decay_t<T> >::value, "Scalar types "
│ │ │ │ +
306 "must not be references, and must not include "
│ │ │ │ +
307 "cv-qualifiers");
│ │ │ │ +
308 [[maybe_unused]] T a{};
│ │ │ │ +
309 }
│ │ │ │ +
310
│ │ │ │ +
311 template<class V>
│ │ │ │ +
312 [[deprecated("Warning: please include bool in the Rebinds for "
│ │ │ │ +
313 "simd type V, as Masks are not checked otherwise.")]]
│ │ │ │ +
314 void warnMissingMaskRebind(std::true_type) {}
│ │ │ │ +
315 template<class V>
│ │ │ │ +
316 void warnMissingMaskRebind(std::false_type) {}
│ │ │ │ +
317
│ │ │ │ +
318 template<class V, class Rebinds, template<class> class RebindPrune,
│ │ │ │ +
319 template<class> class RebindAccept, class Recurse>
│ │ │ │ +
320 void checkRebindOf(Recurse recurse)
│ │ │ │ +
321 {
│ │ │ │ +
322 Hybrid::forEach(Rebinds{}, [this,recurse](auto target) {
│ │ │ │ +
323 using T = typename decltype(target)::type;
│ │ │ │ +
324
│ │ │ │ +
325 // check that the rebound type exists
│ │ │ │ +
326 using W = Rebind<T, V>;
│ │ │ │ +
327 log_ << "Type " << className<V>() << " rebound to "
│ │ │ │ +
328 << className<T>() << " is " << className<W>() << std::endl;
│ │ │ │ +
329
│ │ │ │ +
330 static_assert(std::is_same<W, std::decay_t<W> >::value, "Rebound "
│ │ │ │ +
331 "types must not be references, and must not include "
│ │ │ │ +
332 "cv-qualifiers");
│ │ │ │ +
333 static_assert(lanes<V>() == lanes<W>(), "Rebound types must have "
│ │ │ │ +
334 "the same number of lanes as the original vector "
│ │ │ │ +
335 "types");
│ │ │ │ +
336 static_assert(std::is_same<T, Scalar<W> >::value, "Rebound types "
│ │ │ │ +
337 "must have the bound-to scalar type");
│ │ │ │ +
338
│ │ │ │ +
339 if constexpr (RebindPrune<W>{}) {
│ │ │ │ +
340 log_ << "Pruning check of Simd type " << className<W>()
│ │ │ │ +
341 << std::endl;
│ │ │ │ +
342 }
│ │ │ │ +
343 else {
│ │ │ │ +
344 using Impl::debugTypes;
│ │ │ │ +
345 static_assert(debugTypes<T, V, W>(RebindAccept<W>{}),
│ │ │ │ +
346 "Rebind<T, V> is W, but that is not accepted "
│ │ │ │ +
347 "by RebindAccept");
│ │ │ │ +
348 recurse(MetaType<W>{});
│ │ │ │ +
349 }
│ │ │ │ +
350 });
│ │ │ │ +
351
│ │ │ │ +
352 static_assert(std::is_same<Rebind<Scalar<V>, V>, V>::value, "A type "
│ │ │ │ +
353 "rebound to its own scalar type must be the same type "
│ │ │ │ +
354 "as the original type");
│ │ │ │ +
355 static_assert(std::is_same<Rebind<bool, V>, Mask<V> >::value, "A type "
│ │ │ │ +
356 "rebound to bool must be the mask type for that type");
│ │ │ │ +
357
│ │ │ │ +
358 constexpr bool hasBool = Impl::TypeInList<bool, Rebinds>::value;
│ │ │ │ +
359 warnMissingMaskRebind<V>(Std::bool_constant<!hasBool>{});
│ │ │ │ +
360 }
│ │ │ │ +
361
│ │ │ │ +
363 //
│ │ │ │ +
364 // Fundamental checks
│ │ │ │ +
365 //
│ │ │ │ +
366
│ │ │ │ +
367 template<class V>
│ │ │ │ +
368 void checkLanes()
│ │ │ │ +
369 {
│ │ │ │ +
370 // check lanes
│ │ │ │ +
371 static_assert(std::is_same<std::size_t, decltype(lanes<V>())>::value,
│ │ │ │ +
372 "return type of lanes<V>() should be std::size_t");
│ │ │ │ +
373 static_assert(std::is_same<std::size_t, decltype(lanes(V{}))>::value,
│ │ │ │ +
374 "return type of lanes(V{}) should be std::size_t");
│ │ │ │ +
375
│ │ │ │ +
376 // the result of lanes<V>() must be constexpr
│ │ │ │ +
377 [[maybe_unused]] constexpr auto size = lanes<V>();
│ │ │ │ +
378 // but the result of lanes(vec) does not need to be constexpr
│ │ │ │ +
379 DUNE_SIMD_CHECK(lanes<V>() == lanes(V{}));
│ │ │ │ +
380 }
│ │ │ │ +
381
│ │ │ │ +
382 template<class V>
│ │ │ │ +
383 void checkDefaultConstruct()
│ │ │ │ +
384 {
│ │ │ │ +
385 { [[maybe_unused]] V vec; }
│ │ │ │ +
386 { [[maybe_unused]] V vec{}; }
│ │ │ │ +
387 { [[maybe_unused]] V vec = {}; }
│ │ │ │ +
388 }
│ │ │ │ +
389
│ │ │ │ +
390 template<class V>
│ │ │ │ +
391 void checkLane()
│ │ │ │ +
392 {
│ │ │ │ +
393 // Avoid using broadcast<V>() for initialization to avoid test
│ │ │ │ +
394 // interdependencies.
│ │ │ │ +
395 V vec(Scalar<V>(0));
│ │ │ │ +
396 // check lane() on mutable lvalues
│ │ │ │ +
397 for(std::size_t l = 0; l < lanes(vec); ++l)
│ │ │ │ +
398 lane(l, vec) = l + 1;
│ │ │ │ +
399 for(std::size_t l = 0; l < lanes(vec); ++l)
│ │ │ │ +
400 DUNE_SIMD_CHECK(lane(l, vec) == Scalar<V>(l + 1));
│ │ │ │ +
401 using MLRes = decltype(lane(0, vec));
│ │ │ │ +
402 static_assert(std::is_same<MLRes, Scalar<V>&>::value ||
│ │ │ │ +
403 std::is_same<MLRes, std::decay_t<MLRes> >::value,
│ │ │ │ +
404 "Result of lane() on a mutable lvalue vector must "
│ │ │ │ +
405 "either be a mutable reference to a scalar of that "
│ │ │ │ +
406 "vector or a proxy object (which itself may not be a "
│ │ │ │ +
407 "reference nor const).");
│ │ │ │ +
408
│ │ │ │ +
409 // check lane() on const lvalues
│ │ │ │ +
410 const V &vec2 = vec;
│ │ │ │ +
411 for(std::size_t l = 0; l < lanes(vec); ++l)
│ │ │ │ +
412 DUNE_SIMD_CHECK(lane(l, vec2) == Scalar<V>(l + 1));
│ │ │ │ +
413 using CLRes = decltype(lane(0, vec2));
│ │ │ │ +
414 static_assert(std::is_same<CLRes, const Scalar<V>&>::value ||
│ │ │ │ +
415 std::is_same<CLRes, std::decay_t<CLRes> >::value,
│ │ │ │ +
416 "Result of lane() on a const lvalue vector must "
│ │ │ │ +
417 "either be a const lvalue reference to a scalar of that "
│ │ │ │ +
418 "vector or a proxy object (which itself may not be a "
│ │ │ │ +
419 "reference nor const).");
│ │ │ │ +
420 static_assert(!std::is_assignable<CLRes, Scalar<V> >::value,
│ │ │ │ +
421 "Result of lane() on a const lvalue vector must not be "
│ │ │ │ +
422 "assignable from a scalar.");
│ │ │ │ +
423
│ │ │ │ +
424 // check lane() on rvalues
│ │ │ │ +
425 for(std::size_t l = 0; l < lanes(vec); ++l)
│ │ │ │ +
426 DUNE_SIMD_CHECK(lane(l, prvalue(vec)) == Scalar<V>(l + 1));
│ │ │ │ +
427 using RRes = decltype(lane(0, prvalue(vec)));
│ │ │ │ +
428 // TODO: do we really want to allow Scalar<V>&& here? If we allow it,
│ │ │ │ +
429 // then `auto &&res = lane(0, vec*vec);` creates a dangling reference,
│ │ │ │ +
430 // and the scalar (and even the vector types) are small enough to be
│ │ │ │ +
431 // passed in registers anyway. On the other hand, the only comparable
│ │ │ │ +
432 // accessor function in the standard library that I can think of is
│ │ │ │ +
433 // std::get(), and that does return an rvalue reference in this
│ │ │ │ +
434 // situation. However, that cannot assume anything about the size of
│ │ │ │ +
435 // the returned types.
│ │ │ │ +
436 static_assert(std::is_same<RRes, Scalar<V> >::value ||
│ │ │ │ +
437 std::is_same<RRes, Scalar<V>&&>::value,
│ │ │ │ +
438 "Result of lane() on a rvalue vector V must be "
│ │ │ │ +
439 "Scalar<V> or Scalar<V>&&.");
│ │ │ │ +
440 // Can't assert non-assignable, fails for any typical class,
│ │ │ │ +
441 // e.g. std::complex<>. Would need to return const Scalar<V> or const
│ │ │ │ +
442 // Scalar<V>&&, which would inhibit moving from the return value.
│ │ │ │ +
443 // static_assert(!std::is_assignable<RRes, Scalar<V> >::value,
│ │ │ │ +
444 // "Result of lane() on a rvalue vector must not be "
│ │ │ │ +
445 // "assignable from a scalar.");
│ │ │ │ +
446 }
│ │ │ │ +
447
│ │ │ │ +
448 // check non-default constructors
│ │ │ │ +
449 template<class V>
│ │ │ │ +
450 void checkCopyMoveConstruct()
│ │ │ │ +
451 {
│ │ │ │ +
452 // elided copy/move constructors
│ │ │ │ +
453 { V vec (make123<V>()); DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ +
454 { V vec = make123<V>() ; DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ +
455 { V vec {make123<V>()}; DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ +
456 { V vec = {make123<V>()}; DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ +
457
│ │ │ │ +
458 // copy constructors
│ │ │ │ +
459 { V ref(make123<V>()); V vec (ref);
│ │ │ │ +
460 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); }
│ │ │ │ +
461 { V ref(make123<V>()); V vec = ref ;
│ │ │ │ +
462 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); }
│ │ │ │ +
463 { V ref(make123<V>()); V vec {ref};
│ │ │ │ +
464 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); }
│ │ │ │ +
465 { V ref(make123<V>()); V vec = {ref};
│ │ │ │ +
466 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); }
│ │ │ │ +
467 { const V ref(make123<V>()); V vec (ref);
│ │ │ │ +
468 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ +
469 { const V ref(make123<V>()); V vec = ref ;
│ │ │ │ +
470 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ +
471 { const V ref(make123<V>()); V vec {ref};
│ │ │ │ +
472 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ +
473 { const V ref(make123<V>()); V vec = {ref};
│ │ │ │ +
474 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ +
475
│ │ │ │ +
476 // move constructors
│ │ │ │ +
477 { V ref(make123<V>()); V vec (std::move(ref));
│ │ │ │ +
478 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ +
479 { V ref(make123<V>()); V vec = std::move(ref) ;
│ │ │ │ +
480 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ +
481 { V ref(make123<V>()); V vec {std::move(ref)};
│ │ │ │ +
482 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ +
483 { V ref(make123<V>()); V vec = {std::move(ref)};
│ │ │ │ +
484 DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ +
485 }
│ │ │ │ +
486
│ │ │ │ +
487 template<class V>
│ │ │ │ +
488 void checkBroadcastVectorConstruct()
│ │ │ │ +
489 {
│ │ │ │ +
490 // broadcast copy constructors
│ │ │ │ +
491 { Scalar<V> ref = 42; V vec (ref);
│ │ │ │ +
492 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ +
493 { Scalar<V> ref = 42; V vec = ref ;
│ │ │ │ +
494 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ +
495 // { Scalar<V> ref = 42; V vec {ref};
│ │ │ │ +
496 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ +
497 // { Scalar<V> ref = 42; V vec = {ref};
│ │ │ │ +
498 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ +
499 { const Scalar<V> ref = 42; V vec (ref);
│ │ │ │ +
500 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
501 { const Scalar<V> ref = 42; V vec = ref ;
│ │ │ │ +
502 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
503 // { const Scalar<V> ref = 42; V vec {ref};
│ │ │ │ +
504 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
505 // { const Scalar<V> ref = 42; V vec = {ref};
│ │ │ │ +
506 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
507
│ │ │ │ +
508 // broadcast move constructors
│ │ │ │ +
509 { Scalar<V> ref = 42; V vec (std::move(ref));
│ │ │ │ +
510 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
511 { Scalar<V> ref = 42; V vec = std::move(ref) ;
│ │ │ │ +
512 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
513 // { Scalar<V> ref = 42; V vec {std::move(ref)};
│ │ │ │ +
514 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
515 // { Scalar<V> ref = 42; V vec = {std::move(ref)};
│ │ │ │ +
516 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
517 }
│ │ │ │ +
518
│ │ │ │ +
519 template<class V>
│ │ │ │ +
520 void checkBroadcastMaskConstruct()
│ │ │ │ +
521 {
│ │ │ │ +
522 // broadcast copy constructors
│ │ │ │ +
523 { Scalar<V> ref = 42; V vec (ref);
│ │ │ │ +
524 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ +
525 // { Scalar<V> ref = 42; V vec = ref ;
│ │ │ │ +
526 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ +
527 { Scalar<V> ref = 42; V vec {ref};
│ │ │ │ +
528 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ +
529 // { Scalar<V> ref = 42; V vec = {ref};
│ │ │ │ +
530 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ +
531 { const Scalar<V> ref = 42; V vec (ref);
│ │ │ │ +
532 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
533 // { const Scalar<V> ref = 42; V vec = ref ;
│ │ │ │ +
534 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
535 { const Scalar<V> ref = 42; V vec {ref};
│ │ │ │ +
536 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
537 // { const Scalar<V> ref = 42; V vec = {ref};
│ │ │ │ +
538 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
539
│ │ │ │ +
540 // broadcast move constructors
│ │ │ │ +
541 { Scalar<V> ref = 42; V vec (std::move(ref));
│ │ │ │ +
542 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
543 // { Scalar<V> ref = 42; V vec = std::move(ref) ;
│ │ │ │ +
544 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
545 { Scalar<V> ref = 42; V vec {std::move(ref)};
│ │ │ │ +
546 DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
547 // { Scalar<V> ref = 42; V vec = {std::move(ref)};
│ │ │ │ +
548 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
549 }
│ │ │ │ +
550
│ │ │ │ +
551 // check the implCast function
│ │ │ │ +
552 template<class FromV, class ToV>
│ │ │ │ +
553 void checkImplCast()
│ │ │ │ +
554 {
│ │ │ │ +
555 { // lvalue arg
│ │ │ │ +
556 FromV fromVec = make123<FromV>();
│ │ │ │ +
557 auto toVec = implCast<ToV>(fromVec);
│ │ │ │ +
558 static_assert(std::is_same<decltype(toVec), ToV>::value,
│ │ │ │ +
559 "Unexpected result type for implCast<ToV>(FromV&)");
│ │ │ │ +
560 DUNE_SIMD_CHECK(is123(fromVec));
│ │ │ │ +
561 DUNE_SIMD_CHECK(is123(toVec));
│ │ │ │ +
562 }
│ │ │ │ +
563
│ │ │ │ +
564 { // const lvalue arg
│ │ │ │ +
565 const FromV fromVec = make123<FromV>();
│ │ │ │ +
566 auto toVec = implCast<ToV>(fromVec);
│ │ │ │ +
567 static_assert(std::is_same<decltype(toVec), ToV>::value,
│ │ │ │ +
568 "Unexpected result type for implCast<ToV>(const "
│ │ │ │ +
569 "FromV&)");
│ │ │ │ +
570 DUNE_SIMD_CHECK(is123(toVec));
│ │ │ │ +
571 }
│ │ │ │ +
572
│ │ │ │ +
573 { // rvalue arg
│ │ │ │ +
574 auto toVec = implCast<ToV>(make123<FromV>());
│ │ │ │ +
575 static_assert(std::is_same<decltype(toVec), ToV>::value,
│ │ │ │ +
576 "Unexpected result type for implCast<ToV>(FromV&&)");
│ │ │ │ +
577 DUNE_SIMD_CHECK(is123(toVec));
│ │ │ │ +
578 }
│ │ │ │ +
579 }
│ │ │ │ +
580
│ │ │ │ +
581 // check the implCast function
│ │ │ │ +
582 template<class V>
│ │ │ │ +
583 void checkImplCast()
│ │ │ │ +
584 {
│ │ │ │ +
585 // check against LoopSIMD
│ │ │ │ +
586 using LoopV = Dune::LoopSIMD<Scalar<V>, lanes<V>()>;
│ │ │ │ +
587
│ │ │ │ +
588 checkImplCast<V, V>();
│ │ │ │ +
589 checkImplCast<V, LoopV>();
│ │ │ │ +
590 checkImplCast<LoopV, V>();
│ │ │ │ +
591 }
│ │ │ │ +
592
│ │ │ │ +
593 // check the broadcast function
│ │ │ │ +
594 template<class V>
│ │ │ │ +
595 void checkBroadcast()
│ │ │ │ +
596 {
│ │ │ │ +
597 // broadcast function
│ │ │ │ +
598 { // lvalue arg
│ │ │ │ +
599 Scalar<V> ref = 42;
│ │ │ │ +
600 auto vec = broadcast<V>(ref);
│ │ │ │ +
601 static_assert(std::is_same<decltype(vec), V>::value,
│ │ │ │ +
602 "Unexpected result type for broadcast<V>()");
│ │ │ │ +
603 DUNE_SIMD_CHECK(is42(vec));
│ │ │ │ +
604 DUNE_SIMD_CHECK(ref == Scalar<V>(42));
│ │ │ │ +
605 }
│ │ │ │ +
606
│ │ │ │ +
607 { // const lvalue arg
│ │ │ │ +
608 const Scalar<V> ref = 42;
│ │ │ │ +
609 auto vec = broadcast<V>(ref);
│ │ │ │ +
610 static_assert(std::is_same<decltype(vec), V>::value,
│ │ │ │ +
611 "Unexpected result type for broadcast<V>()");
│ │ │ │ +
612 DUNE_SIMD_CHECK(is42(vec));
│ │ │ │ +
613 }
│ │ │ │ +
614
│ │ │ │ +
615 { // rvalue arg
│ │ │ │ +
616 auto vec = broadcast<V>(Scalar<V>(42));
│ │ │ │ +
617 static_assert(std::is_same<decltype(vec), V>::value,
│ │ │ │ +
618 "Unexpected result type for broadcast<V>()");
│ │ │ │ +
619 DUNE_SIMD_CHECK(is42(vec));
│ │ │ │ +
620 }
│ │ │ │ +
621
│ │ │ │ +
622 { // int arg
│ │ │ │ +
623 auto vec = broadcast<V>(42);
│ │ │ │ +
624 static_assert(std::is_same<decltype(vec), V>::value,
│ │ │ │ +
625 "Unexpected result type for broadcast<V>()");
│ │ │ │ +
626 DUNE_SIMD_CHECK(is42(vec));
│ │ │ │ +
627 }
│ │ │ │ +
628
│ │ │ │ +
629 { // double arg
│ │ │ │ +
630 auto vec = broadcast<V>(42.0);
│ │ │ │ +
631 static_assert(std::is_same<decltype(vec), V>::value,
│ │ │ │ +
632 "Unexpected result type for broadcast<V>()");
│ │ │ │ +
633 DUNE_SIMD_CHECK(is42(vec));
│ │ │ │ +
634 }
│ │ │ │ +
635 }
│ │ │ │ +
636
│ │ │ │ +
637 template<class V>
│ │ │ │ +
638 void checkBracedAssign()
│ │ │ │ +
639 {
│ │ │ │ +
640 // copy assignment
│ │ │ │ +
641 { V ref = make123<V>(); V vec; vec = {ref};
│ │ │ │ +
642 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); }
│ │ │ │ +
643 { const V ref = make123<V>(); V vec; vec = {ref};
│ │ │ │ +
644 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); }
│ │ │ │ +
645
│ │ │ │ +
646 // move assignment
│ │ │ │ +
647 { V vec; vec = {make123<V>()}; DUNE_SIMD_CHECK(is123(vec)); }
│ │ │ │ +
648 }
│ │ │ │ +
649
│ │ │ │ +
650 template<class V>
│ │ │ │ +
651 void checkBracedBroadcastAssign()
│ │ │ │ +
652 {
│ │ │ │ +
653 // nothing works here
│ │ │ │ +
654 // // broadcast copy assignment
│ │ │ │ +
655 // { Scalar<V> ref = 42; V vec; vec = {ref};
│ │ │ │ +
656 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar<V>(42)); }
│ │ │ │ +
657 // { const Scalar<V> ref = 42; V vec; vec = {ref};
│ │ │ │ +
658 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
659
│ │ │ │ +
660 // // broadcast move assignment
│ │ │ │ +
661 // { Scalar<V> ref = 42; V vec; vec = {std::move(ref)};
│ │ │ │ +
662 // DUNE_SIMD_CHECK(is42(vec)); }
│ │ │ │ +
663 }
│ │ │ │ +
664
│ │ │ │ +
666 //
│ │ │ │ +
667 // checks for unary operators
│ │ │ │ +
668 //
│ │ │ │ +
669
│ │ │ │ +
│ │ │ │ +
670#define DUNE_SIMD_POSTFIX_OP(NAME, SYMBOL) \
│ │ │ │ +
671 struct OpPostfix##NAME \
│ │ │ │ +
672 { \
│ │ │ │ +
673 template<class V> \
│ │ │ │ +
674 auto operator()(V&& v) const \
│ │ │ │ +
675 -> decltype(std::forward<V>(v) SYMBOL) \
│ │ │ │ +
676 { \
│ │ │ │ +
677 return std::forward<V>(v) SYMBOL; \
│ │ │ │ +
678 } \
│ │ │ │ +
679 }
│ │ │ │ +
│ │ │ │ +
680
│ │ │ │ +
│ │ │ │ +
681#define DUNE_SIMD_PREFIX_OP(NAME, SYMBOL) \
│ │ │ │ +
682 struct OpPrefix##NAME \
│ │ │ │ +
683 { \
│ │ │ │ +
684 template<class V> \
│ │ │ │ +
685 auto operator()(V&& v) const \
│ │ │ │ +
686 -> decltype(SYMBOL std::forward<V>(v)) \
│ │ │ │ +
687 { \
│ │ │ │ +
688 return SYMBOL std::forward<V>(v); \
│ │ │ │ +
689 } \
│ │ │ │ +
690 }
│ │ │ │ +
│ │ │ │ +
691
│ │ │ │ +
692 DUNE_SIMD_POSTFIX_OP(Decrement, -- );
│ │ │ │ +
693 DUNE_SIMD_POSTFIX_OP(Increment, ++ );
│ │ │ │ +
694
│ │ │ │ +
695 DUNE_SIMD_PREFIX_OP (Decrement, -- );
│ │ │ │ +
696 DUNE_SIMD_PREFIX_OP (Increment, ++ );
│ │ │ │ +
697
│ │ │ │ +
698 DUNE_SIMD_PREFIX_OP (Plus, + );
│ │ │ │ +
699 DUNE_SIMD_PREFIX_OP (Minus, - );
│ │ │ │ +
700 DUNE_SIMD_PREFIX_OP (LogicNot, ! );
│ │ │ │ +
701 // Do not warn about ~ being applied to bool. (1) Yes, doing that is
│ │ │ │ +
702 // weird, but we do want to test the weird stuff too. (2) It avoids
│ │ │ │ +
703 // running into <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82040> on
│ │ │ │ +
704 // g++-7.0 through 7.2. Also, ignore -Wpragmas to not warn about an
│ │ │ │ +
705 // unknown -Wbool-operation on compilers that do not know that option.
│ │ │ │ +
706#pragma GCC diagnostic push
│ │ │ │ +
707#pragma GCC diagnostic ignored "-Wpragmas"
│ │ │ │ +
708#pragma GCC diagnostic ignored "-Wunknown-warning-option" // clang 6.0.1
│ │ │ │ +
709#pragma GCC diagnostic ignored "-Wbool-operation"
│ │ │ │ +
710 DUNE_SIMD_PREFIX_OP (BitNot, ~ );
│ │ │ │ +
711#pragma GCC diagnostic pop
│ │ │ │ +
712
│ │ │ │ +
713#undef DUNE_SIMD_POSTFIX_OP
│ │ │ │ +
714#undef DUNE_SIMD_PREFIX_OP
│ │ │ │ +
715
│ │ │ │ +
716 template<class V, class Op>
│ │ │ │ +
717 std::enable_if_t<
│ │ │ │ +
718 IsCallable<Op(decltype(lane(0, std::declval<V>())))>::value>
│ │ │ │ +
719 checkUnaryOpV(Op op)
│ │ │ │ +
720 {
│ │ │ │ +
721#define DUNE_SIMD_OPNAME (className<Op(V)>())
│ │ │ │ +
722 // arguments
│ │ │ │ +
723 auto val = leftVector<std::decay_t<V>>();
│ │ │ │ +
724
│ │ │ │ +
725 // copy the arguments in case V is a references
│ │ │ │ +
726 auto arg = val;
│ │ │ │ +
727 auto &&result = op(static_cast<V>(arg));
│ │ │ │ +
728 using T = Scalar<std::decay_t<decltype(result)> >;
│ │ │ │ +
729 for(std::size_t l = 0; l < lanes(val); ++l)
│ │ │ │ +
730 {
│ │ │ │ +
731 // `op` might promote the argument. This is a problem if the
│ │ │ │ +
732 // argument of the operation on the right of the `==` is
│ │ │ │ +
733 // e.g. `(unsigned short)1` and the operation is e.g. unary `-`.
│ │ │ │ +
734 // Then the argument is promoted to `int` before applying the
│ │ │ │ +
735 // negation, and the result is `(int)-1`. However, the left side of
│ │ │ │ +
736 // the `==` is still `(unsigned short)-1`, which typically is the
│ │ │ │ +
737 // same as `(unsigned short)65535`. The `==` promotes the left side
│ │ │ │ +
738 // before comparing, so that becomes `(int)65535`. It will then
│ │ │ │ +
739 // compare `(int)65535` and `(int)-1` and rightly declare them to be
│ │ │ │ +
740 // not equal.
│ │ │ │ +
741
│ │ │ │ +
742 // To work around this, we explicitly convert the right side of the
│ │ │ │ +
743 // `==` to the scalar type before comparing.
│ │ │ │ + │ │ │ │ +
745 (lane(l, result)
│ │ │ │ +
746 == static_cast<T>(op(lane(l, static_cast<V>(val)))));
│ │ │ │ +
747 }
│ │ │ │ +
748 // op might modify val, verify that any such modification also happens
│ │ │ │ +
749 // in the vector case
│ │ │ │ +
750 for(std::size_t l = 0; l < lanes<std::decay_t<V> >(); ++l)
│ │ │ │ +
751 DUNE_SIMD_CHECK_OP(lane(l, val) == lane(l, arg));
│ │ │ │ +
752#undef DUNE_SIMD_OPNAME
│ │ │ │ +
753 }
│ │ │ │ +
754
│ │ │ │ +
755 template<class V, class Op>
│ │ │ │ +
756 std::enable_if_t<
│ │ │ │ +
757 not IsCallable<Op(decltype(lane(0, std::declval<V>())))>::value>
│ │ │ │ +
758 checkUnaryOpV(Op op)
│ │ │ │ +
759 {
│ │ │ │ +
760 // log_ << "No " << className<Op(decltype(lane(0, std::declval<V>())))>()
│ │ │ │ +
761 // << std::endl
│ │ │ │ +
762 // << " ==> Not checking " << className<Op(V)>() << std::endl;
│ │ │ │ +
763 }
│ │ │ │ +
764
│ │ │ │ +
765 template<class V, class Op>
│ │ │ │ +
766 void checkUnaryOpsV(Op op)
│ │ │ │ +
767 {
│ │ │ │ +
768 checkUnaryOpV<V&>(op);
│ │ │ │ +
769 checkUnaryOpV<const V&>(op);
│ │ │ │ +
770 checkUnaryOpV<V&&>(op);
│ │ │ │ +
771 }
│ │ │ │ +
772
│ │ │ │ +
774 //
│ │ │ │ +
775 // checks for binary operators
│ │ │ │ +
776 //
│ │ │ │ +
777
│ │ │ │ +
778 // The operators contain an `operator()`, which will be invoked for both
│ │ │ │ +
779 // scalar and vector arguments. The function `scalar()` is used the
│ │ │ │ +
780 // test whether the scalar types support the operation (via
│ │ │ │ +
781 // `ScalarResult`). The difference is that `scalar()` should only ever
│ │ │ │ +
782 // receive `const`-ref-qualified version of `Scalar<V>`, while the
│ │ │ │ +
783 // `operator()` may also be called with proxies representing scalars.
│ │ │ │ +
│ │ │ │ +
784#define DUNE_SIMD_INFIX_OP(NAME, SYMBOL) \
│ │ │ │ +
785 struct OpInfix##NAME \
│ │ │ │ +
786 { \
│ │ │ │ +
787 template<class V1, class V2> \
│ │ │ │ +
788 decltype(auto) operator()(V1&& v1, V2&& v2) const \
│ │ │ │ +
789 { \
│ │ │ │ +
790 return std::forward<V1>(v1) SYMBOL std::forward<V2>(v2); \
│ │ │ │ +
791 } \
│ │ │ │ +
792 template<class S1, class S2> \
│ │ │ │ +
793 auto scalar(S1&& s1, S2&& s2) const \
│ │ │ │ +
794 -> decltype(std::forward<S1>(s1) SYMBOL std::forward<S2>(s2)); \
│ │ │ │ +
795 }
│ │ │ │ +
│ │ │ │ +
796
│ │ │ │ +
797 // for assign ops, accept only non-const lvalue arguments for scalars.
│ │ │ │ +
798 // This is needed for class scalars (e.g. std::complex) because
│ │ │ │ +
799 // non-const class rvalues are actually usually assignable. Though that
│ │ │ │ +
800 // assignment happens to a temporary, and thus is lost. Except that the
│ │ │ │ +
801 // tests would bind the result of the assignment to a reference. And
│ │ │ │ +
802 // because that result is returned from a function by reference, even
│ │ │ │ +
803 // though it is a temporary passed as an argument to that function,
│ │ │ │ +
804 // accessing the result later is undefined behaviour.
│ │ │ │ +
│ │ │ │ +
805#define DUNE_SIMD_ASSIGN_OP(NAME, SYMBOL) \
│ │ │ │ +
806 struct OpInfix##NAME \
│ │ │ │ +
807 { \
│ │ │ │ +
808 template<class V1, class V2> \
│ │ │ │ +
809 decltype(auto) operator()(V1&& v1, V2&& v2) const \
│ │ │ │ +
810 { \
│ │ │ │ +
811 return std::forward<V1>(v1) SYMBOL std::forward<V2>(v2); \
│ │ │ │ +
812 } \
│ │ │ │ +
813 template<class S1, class S2> \
│ │ │ │ +
814 auto scalar(S1& s1, S2&& s2) const \
│ │ │ │ +
815 -> decltype(s1 SYMBOL std::forward<S2>(s2)); \
│ │ │ │ +
816 }
│ │ │ │ +
│ │ │ │ +
817
│ │ │ │ +
│ │ │ │ +
818#define DUNE_SIMD_REPL_OP(NAME, REPLFN, SYMBOL) \
│ │ │ │ +
819 struct OpInfix##NAME \
│ │ │ │ +
820 { \
│ │ │ │ +
821 template<class V1, class V2> \
│ │ │ │ +
822 decltype(auto) operator()(V1&& v1, V2&& v2) const \
│ │ │ │ +
823 { \
│ │ │ │ +
824 return Simd::REPLFN(std::forward<V1>(v1), std::forward<V2>(v2)); \
│ │ │ │ +
825 } \
│ │ │ │ +
826 template<class S1, class S2> \
│ │ │ │ +
827 auto scalar(S1&& s1, S2&& s2) const \
│ │ │ │ +
828 -> decltype(std::forward<S1>(s1) SYMBOL std::forward<S2>(s2)); \
│ │ │ │ +
829 }
│ │ │ │ +
│ │ │ │ +
830
│ │ │ │ +
831 DUNE_SIMD_INFIX_OP(Mul, * );
│ │ │ │ +
832 DUNE_SIMD_INFIX_OP(Div, / );
│ │ │ │ +
833 DUNE_SIMD_INFIX_OP(Remainder, % );
│ │ │ │ +
834
│ │ │ │ +
835 DUNE_SIMD_INFIX_OP(Plus, + );
│ │ │ │ +
836 DUNE_SIMD_INFIX_OP(Minus, - );
│ │ │ │ +
837
│ │ │ │ +
838 DUNE_SIMD_INFIX_OP(LeftShift, << );
│ │ │ │ +
839 DUNE_SIMD_INFIX_OP(RightShift, >> );
│ │ │ │ +
840
│ │ │ │ +
841 DUNE_SIMD_INFIX_OP(Less, < );
│ │ │ │ +
842 DUNE_SIMD_INFIX_OP(Greater, > );
│ │ │ │ +
843 DUNE_SIMD_INFIX_OP(LessEqual, <= );
│ │ │ │ +
844 DUNE_SIMD_INFIX_OP(GreaterEqual, >= );
│ │ │ │ +
845
│ │ │ │ +
846 DUNE_SIMD_INFIX_OP(Equal, == );
│ │ │ │ +
847 DUNE_SIMD_INFIX_OP(NotEqual, != );
│ │ │ │ +
848
│ │ │ │ +
849 DUNE_SIMD_INFIX_OP(BitAnd, & );
│ │ │ │ +
850 DUNE_SIMD_INFIX_OP(BitXor, ^ );
│ │ │ │ +
851 DUNE_SIMD_INFIX_OP(BitOr, | );
│ │ │ │ +
852
│ │ │ │ +
853 // Those are not supported in any meaningful way by vectorclass
│ │ │ │ +
854 // We need to test replacement functions maskAnd() and maskOr() instead.
│ │ │ │ +
855 DUNE_SIMD_REPL_OP(LogicAnd, maskAnd, && );
│ │ │ │ +
856 DUNE_SIMD_REPL_OP(LogicOr, maskOr, || );
│ │ │ │ +
857
│ │ │ │ +
858 DUNE_SIMD_ASSIGN_OP(Assign, = );
│ │ │ │ +
859 DUNE_SIMD_ASSIGN_OP(AssignMul, *= );
│ │ │ │ +
860 DUNE_SIMD_ASSIGN_OP(AssignDiv, /= );
│ │ │ │ +
861 DUNE_SIMD_ASSIGN_OP(AssignRemainder, %= );
│ │ │ │ +
862 DUNE_SIMD_ASSIGN_OP(AssignPlus, += );
│ │ │ │ +
863 DUNE_SIMD_ASSIGN_OP(AssignMinus, -= );
│ │ │ │ +
864 DUNE_SIMD_ASSIGN_OP(AssignLeftShift, <<=);
│ │ │ │ +
865 DUNE_SIMD_ASSIGN_OP(AssignRightShift, >>=);
│ │ │ │ +
866 DUNE_SIMD_ASSIGN_OP(AssignAnd, &= );
│ │ │ │ +
867 DUNE_SIMD_ASSIGN_OP(AssignXor, ^= );
│ │ │ │ +
868 DUNE_SIMD_ASSIGN_OP(AssignOr, |= );
│ │ │ │ +
869
│ │ │ │ +
870#undef DUNE_SIMD_INFIX_OP
│ │ │ │ +
871#undef DUNE_SIMD_REPL_OP
│ │ │ │ +
872#undef DUNE_SIMD_ASSIGN_OP
│ │ │ │ +
873
│ │ │ │ +
874 // just used as a tag
│ │ │ │ +
875 struct OpInfixComma {};
│ │ │ │ +
876
│ │ │ │ +
877 template<class T1, class T2>
│ │ │ │ +
878 void checkCommaOp(const std::decay_t<T1> &val1,
│ │ │ │ +
879 const std::decay_t<T2> &val2)
│ │ │ │ +
880 {
│ │ │ │ +
881#define DUNE_SIMD_OPNAME (className<OpInfixComma(T1, T2)>())
│ │ │ │ +
882 static_assert(std::is_same<decltype((std::declval<T1>(),
│ │ │ │ +
883 std::declval<T2>())), T2>::value,
│ │ │ │ +
884 "Type and value category of the comma operator must "
│ │ │ │ +
885 "match that of the second operand");
│ │ │ │ +
886
│ │ │ │ +
887 // copy the arguments in case T1 or T2 are references
│ │ │ │ +
888 auto arg1 = val1;
│ │ │ │ +
889 auto arg2 = val2;
│ │ │ │ +
890 // Do not warn that the left side of the comma operator is unused.
│ │ │ │ +
891 // Seems to work for g++-4.9 and clang++-3.8. Appears to be harmless
│ │ │ │ +
892 // for icpc (14 and 17), and icpc does not seem to issue a warning
│ │ │ │ +
893 // anyway.
│ │ │ │ +
894#pragma GCC diagnostic push
│ │ │ │ +
895#pragma GCC diagnostic ignored "-Wunused-value"
│ │ │ │ +
896 auto &&result = (static_cast<T1>(arg1),
│ │ │ │ +
897 static_cast<T2>(arg2));
│ │ │ │ +
898#pragma GCC diagnostic pop
│ │ │ │ +
899 if(std::is_reference<T2>::value)
│ │ │ │ +
900 {
│ │ │ │ +
901 // comma should return the same object as the second argument for
│ │ │ │ +
902 // lvalues and xvalues
│ │ │ │ +
903 DUNE_SIMD_CHECK_OP(&result == &arg2);
│ │ │ │ +
904 // it should not modify any arguments
│ │ │ │ +
905 DUNE_SIMD_CHECK_OP(allTrue(val1 == arg1));
│ │ │ │ +
906 DUNE_SIMD_CHECK_OP(allTrue(val2 == arg2));
│ │ │ │ +
907 }
│ │ │ │ +
908 else
│ │ │ │ +
909 {
│ │ │ │ +
910 // comma should return the same value as the second argument for
│ │ │ │ +
911 // prvalues
│ │ │ │ +
912 DUNE_SIMD_CHECK_OP(allTrue(result == arg2));
│ │ │ │ +
913 // it should not modify any arguments
│ │ │ │ +
914 DUNE_SIMD_CHECK_OP(allTrue(val1 == arg1));
│ │ │ │ +
915 // second argument is a prvalue, any modifications happen to a
│ │ │ │ +
916 // temporary and we can't detect them
│ │ │ │ +
917 }
│ │ │ │ +
918#undef DUNE_SIMD_OPNAME
│ │ │ │ +
919 }
│ │ │ │ +
920
│ │ │ │ +
922 //
│ │ │ │ +
923 // checks for vector-vector binary operations
│ │ │ │ +
924 //
│ │ │ │ +
925
│ │ │ │ +
926 // We check the following candidate operation
│ │ │ │ +
927 //
│ │ │ │ +
928 // vopres = vop1 @ vop2
│ │ │ │ +
929 //
│ │ │ │ +
930 // against the reference operation
│ │ │ │ +
931 //
│ │ │ │ +
932 // arefres[l] = aref1[l] @ aref2[l] foreach l
│ │ │ │ +
933 //
│ │ │ │ +
934 // v... variables are simd-vectors and a... variables are arrays. The
│ │ │ │ +
935 // operation may modify the operands, but if is does the modification
│ │ │ │ +
936 // needs to happen in both the candidate and the reference.
│ │ │ │ +
937 //
│ │ │ │ +
938 // We do the following checks:
│ │ │ │ +
939 // 1. lanes(vopres) == lanes(vop1)
│ │ │ │ +
940 // 2. lane(l, vopres) == arefres[l] foreach l
│ │ │ │ +
941 // 3. lane(l, vop1) == aref1[l] foreach l
│ │ │ │ +
942 // 4. lane(l, vop2) == aref2[l] foreach l
│ │ │ │ +
943 template<class V1, class V2, class Op>
│ │ │ │ +
944 std::enable_if_t<Std::is_detected_v<ScalarResult, Op, V1, V2> >
│ │ │ │ +
945 checkBinaryOpVV(MetaType<V1>, MetaType<V2>, Op op)
│ │ │ │ +
946 {
│ │ │ │ +
947#define DUNE_SIMD_OPNAME (className<Op(V1, V2)>())
│ │ │ │ +
948 static_assert(std::is_same<std::decay_t<V1>, std::decay_t<V2> >::value,
│ │ │ │ +
949 "Internal testsystem error: called with two types that "
│ │ │ │ +
950 "don't decay to the same thing");
│ │ │ │ +
951
│ │ │ │ +
952 // reference arguments
│ │ │ │ +
953 auto vref1 = leftVector<std::decay_t<V1>>();
│ │ │ │ +
954 auto vref2 = rightVector<std::decay_t<V2>>();
│ │ │ │ +
955
│ │ │ │ +
956 // candidate arguments
│ │ │ │ +
957 auto vop1 = vref1;
│ │ │ │ +
958 auto vop2 = vref2;
│ │ │ │ +
959
│ │ │ │ +
960 // candidate operation
│ │ │ │ +
961 auto &&vopres = op(static_cast<V1>(vop1), static_cast<V2>(vop2));
│ │ │ │ +
962 using VR = decltype(vopres);
│ │ │ │ +
963
│ │ │ │ +
964 // check 1. lanes(vopres) == lanes(vop1)
│ │ │ │ +
965 static_assert(lanes<std::decay_t<VR> >() == lanes<std::decay_t<V1> >(),
│ │ │ │ +
966 "The result must have the same number of lanes as the "
│ │ │ │ +
967 "operands.");
│ │ │ │ +
968
│ │ │ │ +
969 // do the reference operation, and simultaneously
│ │ │ │ +
970 // check 2. lane(l, vopres) == arefres[l] foreach l
│ │ │ │ +
971 using T = Scalar<std::decay_t<VR> >;
│ │ │ │ +
972 for(auto l : range(lanes(vopres)))
│ │ │ │ +
973 {
│ │ │ │ +
974 // see the lengthy comment in `checkUnaryOpV()` as to why the
│ │ │ │ +
975 // `static_cast` around the `op()` is necessary
│ │ │ │ + │ │ │ │ +
977 (lane(l, vopres)
│ │ │ │ +
978 == static_cast<T>(op(lane(l, static_cast<V1>(vref1)),
│ │ │ │ +
979 lane(l, static_cast<V2>(vref2)))));
│ │ │ │ +
980 }
│ │ │ │ +
981
│ │ │ │ +
982 // check 3. lane(l, vop1) == aref1[l] foreach l
│ │ │ │ +
983 for(auto l : range(lanes(vop1)))
│ │ │ │ +
984 DUNE_SIMD_CHECK_OP(lane(l, vop1) == lane(l, vref1));
│ │ │ │ +
985
│ │ │ │ +
986 // check 4. lane(l, vop2) == aref2[l] foreach l
│ │ │ │ +
987 for(auto l : range(lanes(vop2)))
│ │ │ │ +
988 DUNE_SIMD_CHECK_OP(lane(l, vop2) == lane(l, vref2));
│ │ │ │ +
989
│ │ │ │ +
990#undef DUNE_SIMD_OPNAME
│ │ │ │ +
991 }
│ │ │ │ +
992
│ │ │ │ +
993 template<class V1, class V2, class Op>
│ │ │ │ +
994 std::enable_if_t<!Std::is_detected_v<ScalarResult, Op, V1, V2> >
│ │ │ │ +
995 checkBinaryOpVV(MetaType<V1>, MetaType<V2>, Op op)
│ │ │ │ +
996 {
│ │ │ │ +
997 // log_ << "No " << className<Op(decltype(lane(0, std::declval<V1>())),
│ │ │ │ +
998 // decltype(lane(0, std::declval<V2>())))>()
│ │ │ │ +
999 // << std::endl
│ │ │ │ +
1000 // << " ==> Not checking " << className<Op(V1, V2)>() << std::endl;
│ │ │ │ +
1001 }
│ │ │ │ +
1002
│ │ │ │ +
1003 template<class V1, class V2>
│ │ │ │ +
1004 void checkBinaryOpVV(MetaType<V1>, MetaType<V2>, OpInfixComma)
│ │ │ │ +
1005 {
│ │ │ │ +
1006 static_assert(std::is_same<std::decay_t<V1>, std::decay_t<V2> >::value,
│ │ │ │ +
1007 "Internal testsystem error: called with two types that "
│ │ │ │ +
1008 "don't decay to the same thing");
│ │ │ │ +
1009
│ │ │ │ +
1010 checkCommaOp<V1, V2>(leftVector<std::decay_t<V1>>(),
│ │ │ │ +
1011 rightVector<std::decay_t<V2>>());
│ │ │ │ +
1012 }
│ │ │ │ +
1013
│ │ │ │ +
1015 //
│ │ │ │ +
1016 // checks for vector-scalar binary operations
│ │ │ │ +
1017 //
│ │ │ │ +
1018
│ │ │ │ +
1019 // We check the following candidate operation
│ │ │ │ +
1020 //
│ │ │ │ +
1021 // vopres = vop1 @ sop2
│ │ │ │ +
1022 //
│ │ │ │ +
1023 // against the reference operation
│ │ │ │ +
1024 //
│ │ │ │ +
1025 // arefres[l] = aref1[l] @ sref2 foreach l
│ │ │ │ +
1026 //
│ │ │ │ +
1027 // v... variables are simd-vectors, a... variables are arrays, and
│ │ │ │ +
1028 // s... variables are scalars. The operation may modify the left
│ │ │ │ +
1029 // operand, but if is does the modifications needs to happen in both the
│ │ │ │ +
1030 // candidate and the reference.
│ │ │ │ +
1031 //
│ │ │ │ +
1032 // We do the following checks:
│ │ │ │ +
1033 // 1. lanes(vopres) == lanes(vop1)
│ │ │ │ +
1034 // 2. lane(l, vopres) == arefres[l] foreach l
│ │ │ │ +
1035 // 3. lane(l, vop1) == aref1[l] foreach l
│ │ │ │ +
1036 // 4. sop2 is never modified
│ │ │ │ +
1037 // 5. sref2 is never modified
│ │ │ │ +
1038 //
│ │ │ │ +
1039 // In fact, if the property "sref2 is never modified" is violated that
│ │ │ │ +
1040 // means the operation is unsuitable for an automatic broadcast of the
│ │ │ │ +
1041 // second operand and should not be checked. There are no operations in
│ │ │ │ +
1042 // the standard where the second operand is modified like this, but
│ │ │ │ +
1043 // there are operations where the first operand is modified -- and this
│ │ │ │ +
1044 // check is used for those ops as well by exchanging the first and second
│ │ │ │ +
1045 // argument below.
│ │ │ │ +
1046
│ │ │ │ +
1047 template<class V1, class T2, class Op>
│ │ │ │ +
1048 std::enable_if_t<Std::is_detected_v<ScalarResult, Op, V1, T2> >
│ │ │ │ +
1049 checkBinaryOpVS(MetaType<V1>, MetaType<T2>, Op op)
│ │ │ │ +
1050 {
│ │ │ │ +
1051#define DUNE_SIMD_OPNAME (className<Op(V1, T2)>())
│ │ │ │ +
1052 static_assert(std::is_same<Scalar<std::decay_t<V1> >,
│ │ │ │ +
1053 std::decay_t<T2> >::value,
│ │ │ │ +
1054 "Internal testsystem error: called with a scalar that "
│ │ │ │ +
1055 "does not match the vector type.");
│ │ │ │ +
1056
│ │ │ │ +
1057 // initial values
│ │ │ │ +
1058 auto sinit2 = rightScalar<std::decay_t<T2>>();
│ │ │ │ +
1059
│ │ │ │ +
1060 // reference arguments
│ │ │ │ +
1061 auto vref1 = leftVector<std::decay_t<V1>>();
│ │ │ │ +
1062 auto sref2 = sinit2;
│ │ │ │ +
1063
│ │ │ │ +
1064 // candidate arguments
│ │ │ │ +
1065 auto vop1 = vref1;
│ │ │ │ +
1066 auto sop2 = sref2;
│ │ │ │ +
1067
│ │ │ │ +
1068 // candidate operation
│ │ │ │ +
1069 auto &&vopres = op(static_cast<V1>(vop1), static_cast<T2>(sop2));
│ │ │ │ +
1070 using VR = decltype(vopres);
│ │ │ │ +
1071
│ │ │ │ +
1072 // check 1. lanes(vopres) == lanes(vop1)
│ │ │ │ +
1073 static_assert(lanes<std::decay_t<VR> >() == lanes<std::decay_t<V1> >(),
│ │ │ │ +
1074 "The result must have the same number of lanes as the "
│ │ │ │ +
1075 "operands.");
│ │ │ │ +
1076
│ │ │ │ +
1077 // check 4. sop2 is never modified
│ │ │ │ +
1078 DUNE_SIMD_CHECK_OP(sop2 == sinit2);
│ │ │ │ +
1079
│ │ │ │ +
1080 // do the reference operation, and simultaneously check 2. and 5.
│ │ │ │ +
1081 using T = Scalar<std::decay_t<decltype(vopres)> >;
│ │ │ │ +
1082 for(auto l : range(lanes(vopres)))
│ │ │ │ +
1083 {
│ │ │ │ +
1084 // check 2. lane(l, vopres) == arefres[l] foreach l
│ │ │ │ +
1085 // see the lengthy comment in `checkUnaryOpV()` as to why the
│ │ │ │ +
1086 // `static_cast` around the `op()` is necessary
│ │ │ │ + │ │ │ │ +
1088 (lane(l, vopres)
│ │ │ │ +
1089 == static_cast<T>(op(lane(l, static_cast<V1>(vref1)),
│ │ │ │ +
1090 static_cast<T2>(sref2) )));
│ │ │ │ +
1091 // check 5. sref2 is never modified
│ │ │ │ +
1092 DUNE_SIMD_CHECK_OP(sref2 == sinit2);
│ │ │ │ +
1093 }
│ │ │ │ +
1094
│ │ │ │ +
1095 // check 3. lane(l, vop1) == aref1[l] foreach l
│ │ │ │ +
1096 for(auto l : range(lanes(vop1)))
│ │ │ │ +
1097 DUNE_SIMD_CHECK_OP(lane(l, vop1) == lane(l, vref1));
│ │ │ │ +
1098
│ │ │ │ +
1099#undef DUNE_SIMD_OPNAME
│ │ │ │ +
1100 }
│ │ │ │ +
1101
│ │ │ │ +
1102 template<class V1, class T2, class Op>
│ │ │ │ +
1103 std::enable_if_t<!Std::is_detected_v<ScalarResult, Op, V1, T2> >
│ │ │ │ +
1104 checkBinaryOpVS(MetaType<V1>, MetaType<T2>, Op op)
│ │ │ │ +
1105 {
│ │ │ │ +
1106 // log_ << "No "
│ │ │ │ +
1107 // << className<Op(decltype(lane(0, std::declval<V1>())), T2)>()
│ │ │ │ +
1108 // << std::endl
│ │ │ │ +
1109 // << " ==> Not checking " << className<Op(V1, T2)>() << std::endl;
│ │ │ │ +
1110 }
│ │ │ │ +
1111
│ │ │ │ +
1112 template<class V1, class T2>
│ │ │ │ +
1113 void checkBinaryOpVS(MetaType<V1>, MetaType<T2>, OpInfixComma)
│ │ │ │ +
1114 {
│ │ │ │ +
1115 static_assert(std::is_same<Scalar<std::decay_t<V1> >,
│ │ │ │ +
1116 std::decay_t<T2> >::value,
│ │ │ │ +
1117 "Internal testsystem error: called with a scalar that "
│ │ │ │ +
1118 "does not match the vector type.");
│ │ │ │ +
1119
│ │ │ │ +
1120 checkCommaOp<V1, T2>(leftVector<std::decay_t<V1>>(),
│ │ │ │ +
1121 rightScalar<std::decay_t<T2>>());
│ │ │ │ +
1122 }
│ │ │ │ +
1123
│ │ │ │ +
1125 //
│ │ │ │ +
1126 // cross-check scalar-vector binary operations against vector-vector
│ │ │ │ +
1127 //
│ │ │ │ +
1128
│ │ │ │ +
1129 // We check the following candidate operation
│ │ │ │ +
1130 //
│ │ │ │ +
1131 // vopres = vop1 @ vop2, where vop2 = broadcast(sref2)
│ │ │ │ +
1132 //
│ │ │ │ +
1133 // against the reference operation
│ │ │ │ +
1134 //
│ │ │ │ +
1135 // vrefres = vref1 @ sref2
│ │ │ │ +
1136 //
│ │ │ │ +
1137 // v... variables are simd-vectors, a... variables are arrays, and
│ │ │ │ +
1138 // s... variables are scalars.
│ │ │ │ +
1139 //
│ │ │ │ +
1140 // We could check the following properties
│ │ │ │ +
1141 // 1. lanes(vopres) == lanes(vop1)
│ │ │ │ +
1142 // 2. lane(l, vopres) == lane(l, vrefres) foreach l
│ │ │ │ +
1143 // 3. lane(l, vop1) == lane(l, vref1) foreach l
│ │ │ │ +
1144 // but these are given by checking the operation against the scalar
│ │ │ │ +
1145 // operation in the vector@vector and vector@scalar cases above.
│ │ │ │ +
1146 //
│ │ │ │ +
1147 // The only thing left to check is:
│ │ │ │ +
1148 // 4. lane(l, vop2) foreach l is never modified
│ │ │ │ +
1149
│ │ │ │ +
1150 template<class V1, class T2, class Op>
│ │ │ │ +
1151 std::enable_if_t<Std::is_detected_v<ScalarResult, Op, V1, T2> >
│ │ │ │ +
1152 checkBinaryOpVVAgainstVS(MetaType<V1>, MetaType<T2>, Op op)
│ │ │ │ +
1153 {
│ │ │ │ +
1154#define DUNE_SIMD_OPNAME (className<Op(V1, T2)>())
│ │ │ │ +
1155 static_assert(std::is_same<Scalar<std::decay_t<V1> >,
│ │ │ │ +
1156 std::decay_t<T2> >::value,
│ │ │ │ +
1157 "Internal testsystem error: called with a scalar that "
│ │ │ │ +
1158 "does not match the vector type.");
│ │ │ │ +
1159
│ │ │ │ +
1160 // initial values
│ │ │ │ +
1161 auto sinit2 = rightScalar<std::decay_t<T2>>();
│ │ │ │ +
1162
│ │ │ │ +
1163 // reference arguments
│ │ │ │ +
1164 auto vop1 = leftVector<std::decay_t<V1>>();
│ │ │ │ +
1165 using V2 = CopyRefQual<V1, T2>;
│ │ │ │ +
1166 std::decay_t<V2> vop2(sinit2);
│ │ │ │ +
1167
│ │ │ │ +
1168 // candidate operation
│ │ │ │ +
1169 op(static_cast<V1>(vop1), static_cast<V2>(vop2));
│ │ │ │ +
1170
│ │ │ │ +
1171 // 4. lane(l, vop2) foreach l is never modified
│ │ │ │ +
1172 for(auto l : range(lanes(vop2)))
│ │ │ │ +
1173 DUNE_SIMD_CHECK_OP(lane(l, vop2) == sinit2);
│ │ │ │ +
1174
│ │ │ │ +
1175#undef DUNE_SIMD_OPNAME
│ │ │ │ +
1176 }
│ │ │ │ +
1177
│ │ │ │ +
1178 template<class V1, class T2, class Op>
│ │ │ │ +
1179 std::enable_if_t<!Std::is_detected_v<ScalarResult, Op, V1, T2> >
│ │ │ │ +
1180 checkBinaryOpVVAgainstVS(MetaType<V1>, MetaType<T2>, Op op)
│ │ │ │ +
1181 {
│ │ │ │ +
1182 // log_ << "No "
│ │ │ │ +
1183 // << className<Op(decltype(lane(0, std::declval<V1>())), T2)>()
│ │ │ │ +
1184 // << std::endl
│ │ │ │ +
1185 // << " ==> Not checking " << className<Op(V1, T2)>() << std::endl;
│ │ │ │ +
1186 }
│ │ │ │ +
1187
│ │ │ │ +
1188 template<class V1, class T2>
│ │ │ │ +
1189 void checkBinaryOpVVAgainstVS(MetaType<V1>, MetaType<T2>, OpInfixComma)
│ │ │ │ +
1190 { }
│ │ │ │ +
1191
│ │ │ │ +
1193 //
│ │ │ │ +
1194 // checks for vector-proxy binary operations
│ │ │ │ +
1195 //
│ │ │ │ +
1196
│ │ │ │ +
1197 // We check the following candidate operation
│ │ │ │ +
1198 //
│ │ │ │ +
1199 // vopres = vop1 @ pop2
│ │ │ │ +
1200 //
│ │ │ │ +
1201 // against the reference operation
│ │ │ │ +
1202 //
│ │ │ │ +
1203 // arefres[l] = aref1[l] @ sref2 foreach l
│ │ │ │ +
1204 //
│ │ │ │ +
1205 // v... variables are simd-vectors, a... variables are arrays,
│ │ │ │ +
1206 // p... variables are proxies of simd-vector entries and s... variables
│ │ │ │ +
1207 // are scalars. The operation may modify the left operand, but if is
│ │ │ │ +
1208 // does the modifications needs to happen in both the candidate and the
│ │ │ │ +
1209 // reference.
│ │ │ │ +
1210 //
│ │ │ │ +
1211 // We do the following checks:
│ │ │ │ +
1212 // 1. lanes(vopres) == lanes(vop1)
│ │ │ │ +
1213 // 2. lane(l, vopres) == arefres[l] foreach l
│ │ │ │ +
1214 // 3. lane(l, vop1) == aref1[l] foreach l
│ │ │ │ +
1215 // 4. pop2 is never modified
│ │ │ │ +
1216 // 5. sref2 is never modified
│ │ │ │ +
1217 //
│ │ │ │ +
1218 // In fact, if the property "sref2 is never modified" is violated that
│ │ │ │ +
1219 // means the operation is unsuitable for an automatic broadcast of the
│ │ │ │ +
1220 // second operand and should not be checked. There are no operations in
│ │ │ │ +
1221 // the standard where the second operand is modified like this, but
│ │ │ │ +
1222 // there are operations where the first operand is modified -- and this
│ │ │ │ +
1223 // check is used for those ops as well by exchanging the first and second
│ │ │ │ +
1224 // argument below.
│ │ │ │ +
1225
│ │ │ │ +
1226 template<class V1, class V2, class Op>
│ │ │ │ +
1227 std::enable_if_t<Std::is_detected_v<ScalarResult, Op, V1, V2> >
│ │ │ │ +
1228 checkBinaryOpVP(MetaType<V1>, MetaType<V2>, Op op)
│ │ │ │ +
1229 {
│ │ │ │ +
1230 using P2 = decltype(lane(0, std::declval<V2>()));
│ │ │ │ +
1231 using T2 = CopyRefQual<Scalar<V2>, V2>;
│ │ │ │ +
1232#define DUNE_SIMD_OPNAME (className<Op(V1, P2)>())
│ │ │ │ +
1233 static_assert(std::is_same<Scalar<V1>, Scalar<V2> >::value,
│ │ │ │ +
1234 "Internal testsystem error: called with two vector "
│ │ │ │ +
1235 "types whose scalar types don't match.");
│ │ │ │ +
1236
│ │ │ │ +
1237 // initial values
│ │ │ │ +
1238 auto sinit2 = rightScalar<Scalar<V2>>();
│ │ │ │ +
1239
│ │ │ │ +
1240 // reference arguments
│ │ │ │ +
1241 auto vref1 = leftVector<std::decay_t<V1>>();
│ │ │ │ +
1242 auto sref2 = sinit2;
│ │ │ │ +
1243
│ │ │ │ +
1244 // candidate arguments
│ │ │ │ +
1245 auto vop1 = vref1;
│ │ │ │ +
1246 auto vop2 = std::decay_t<V2>(Scalar<V2>(0));
│ │ │ │ +
1247 lane(0, vop2) = sref2; // pop2 is just a name for `lane(0, vop2)`
│ │ │ │ +
1248
│ │ │ │ +
1249 // candidate operation
│ │ │ │ +
1250 auto &&vopres =
│ │ │ │ +
1251 op(static_cast<V1>(vop1), lane(0, static_cast<V2>(vop2)));
│ │ │ │ +
1252 using VR = decltype(vopres);
│ │ │ │ +
1253
│ │ │ │ +
1254 // check 1. lanes(vopres) == lanes(vop1)
│ │ │ │ +
1255 static_assert(lanes<std::decay_t<VR> >() == lanes<std::decay_t<V1> >(),
│ │ │ │ +
1256 "The result must have the same number of lanes as the "
│ │ │ │ +
1257 "operands.");
│ │ │ │ +
1258
│ │ │ │ +
1259 // check 4. pop2 is never modified
│ │ │ │ +
1260 DUNE_SIMD_CHECK_OP(lane(0, vop2) == sinit2);
│ │ │ │ +
1261
│ │ │ │ +
1262 // do the reference operation, and simultaneously check 2. and 5.
│ │ │ │ +
1263 using T = Scalar<decltype(vopres)>;
│ │ │ │ +
1264 for(auto l : range(lanes(vopres)))
│ │ │ │ +
1265 {
│ │ │ │ +
1266 // check 2. lane(l, vopres) == arefres[l] foreach l
│ │ │ │ +
1267 // see the lengthy comment in `checkUnaryOpV()` as to why the
│ │ │ │ +
1268 // `static_cast` around the `op()` is necessary
│ │ │ │ + │ │ │ │ +
1270 (lane(l, vopres)
│ │ │ │ +
1271 == static_cast<T>(op(lane(l, static_cast<V1>(vref1)),
│ │ │ │ +
1272 static_cast<T2>(sref2) )));
│ │ │ │ +
1273 // check 5. sref2 is never modified
│ │ │ │ +
1274 DUNE_SIMD_CHECK_OP(sref2 == sinit2);
│ │ │ │ +
1275 }
│ │ │ │ +
1276
│ │ │ │ +
1277 // check 3. lane(l, vop1) == aref1[l] foreach l
│ │ │ │ +
1278 for(auto l : range(lanes(vop1)))
│ │ │ │ +
1279 DUNE_SIMD_CHECK_OP(lane(l, vop1) == lane(l, vref1));
│ │ │ │ +
1280
│ │ │ │ +
1281#undef DUNE_SIMD_OPNAME
│ │ │ │ +
1282 }
│ │ │ │ +
1283
│ │ │ │ +
1284 template<class V1, class V2, class Op>
│ │ │ │ +
1285 std::enable_if_t<!Std::is_detected_v<ScalarResult, Op, V1, V2> >
│ │ │ │ +
1286 checkBinaryOpVP(MetaType<V1>, MetaType<V2>, Op op)
│ │ │ │ +
1287 {
│ │ │ │ +
1288 // log_ << "No "
│ │ │ │ +
1289 // << className<Op(decltype(lane(0, std::declval<V1>())), T2)>()
│ │ │ │ +
1290 // << std::endl
│ │ │ │ +
1291 // << " ==> Not checking " << className<Op(V1, T2)>() << std::endl;
│ │ │ │ +
1292 }
│ │ │ │ +
1293
│ │ │ │ +
1294 template<class V1, class V2>
│ │ │ │ +
1295 void checkBinaryOpVP(MetaType<V1>, MetaType<V2>, OpInfixComma)
│ │ │ │ +
1296 {
│ │ │ │ +
1297 // Don't really know how to check comma operator for proxies
│ │ │ │ +
1298 }
│ │ │ │ +
1299
│ │ │ │ +
1301 //
│ │ │ │ +
1302 // checks for (scalar/proxy)-vector binary operations
│ │ │ │ +
1303 //
│ │ │ │ +
1304
│ │ │ │ +
1305 template<class Op>
│ │ │ │ +
1306 struct OpInfixSwappedArgs
│ │ │ │ +
1307 {
│ │ │ │ +
1308 Op orig;
│ │ │ │ +
1309
│ │ │ │ +
1310 template<class V1, class V2>
│ │ │ │ +
1311 decltype(auto) operator()(V1&& v1, V2&& v2) const
│ │ │ │ +
1312 {
│ │ │ │ +
1313 return orig(std::forward<V2>(v2), std::forward<V1>(v1));
│ │ │ │ +
1314 }
│ │ │ │ +
1315 template<class S1, class S2>
│ │ │ │ +
1316 auto scalar(S1&& s1, S2&& s2) const
│ │ │ │ +
1317 -> decltype(orig.scalar(std::forward<S2>(s2), std::forward<S1>(s1)));
│ │ │ │ +
1318 };
│ │ │ │ +
1319
│ │ │ │ +
1320 template<class T1, class V2, class Op>
│ │ │ │ +
1321 void checkBinaryOpSV(MetaType<T1> t1, MetaType<V2> v2, Op op)
│ │ │ │ +
1322 {
│ │ │ │ +
1323 checkBinaryOpVS(v2, t1, OpInfixSwappedArgs<Op>{op});
│ │ │ │ +
1324 }
│ │ │ │ +
1325
│ │ │ │ +
1326 template<class T1, class V2>
│ │ │ │ +
1327 void checkBinaryOpSV(MetaType<T1>, MetaType<V2>, OpInfixComma)
│ │ │ │ +
1328 {
│ │ │ │ +
1329 static_assert(std::is_same<std::decay_t<T1>,
│ │ │ │ +
1330 Scalar<std::decay_t<V2> > >::value,
│ │ │ │ +
1331 "Internal testsystem error: called with a scalar that "
│ │ │ │ +
1332 "does not match the vector type.");
│ │ │ │ +
1333
│ │ │ │ +
1334 checkCommaOp<T1, V2>(leftScalar<std::decay_t<T1>>(),
│ │ │ │ +
1335 rightVector<std::decay_t<V2>>());
│ │ │ │ +
1336 }
│ │ │ │ +
1337
│ │ │ │ +
1338 template<class V1, class V2, class Op>
│ │ │ │ +
1339 void checkBinaryOpPV(MetaType<V1> v1, MetaType<V2> v2, Op op)
│ │ │ │ +
1340 {
│ │ │ │ +
1341 checkBinaryOpVP(v2, v1, OpInfixSwappedArgs<Op>{op});
│ │ │ │ +
1342 }
│ │ │ │ +
1343
│ │ │ │ +
1344 template<class V1, class V2>
│ │ │ │ +
1345 void checkBinaryOpPV(MetaType<V1>, MetaType<V2>, OpInfixComma)
│ │ │ │ +
1346 {
│ │ │ │ +
1347 // Don't really know how to check comma operator for proxies
│ │ │ │ +
1348 }
│ │ │ │ +
1349
│ │ │ │ +
1351 //
│ │ │ │ +
1352 // cross-check scalar-vector binary operations against vector-vector
│ │ │ │ +
1353 //
│ │ │ │ +
1354
│ │ │ │ +
1355 // We check the following candidate operation
│ │ │ │ +
1356 //
│ │ │ │ +
1357 // vopres = vop1 @ vop2, where vop2 = broadcast(sref2)
│ │ │ │ +
1358 //
│ │ │ │ +
1359 // against the reference operation
│ │ │ │ +
1360 //
│ │ │ │ +
1361 // vrefres = vref1 @ sref2
│ │ │ │ +
1362 //
│ │ │ │ +
1363 // v... variables are simd-vectors, a... variables are arrays, and
│ │ │ │ +
1364 // s... variables are scalars.
│ │ │ │ +
1365 //
│ │ │ │ +
1366 // We could check the following properties
│ │ │ │ +
1367 // 1. lanes(vopres) == lanes(vop1)
│ │ │ │ +
1368 // 2. lane(l, vopres) == lane(l, vrefres) foreach l
│ │ │ │ +
1369 // 3. lane(l, vop1) == lane(l, vref1) foreach l
│ │ │ │ +
1370 // but these are given by checking the operation against the scalar
│ │ │ │ +
1371 // operation in the vector@vector and vector@scalar cases above.
│ │ │ │ +
1372 //
│ │ │ │ +
1373 // The only thing left to check is:
│ │ │ │ +
1374 // 4. lane(l, vop2) foreach l is never modified
│ │ │ │ +
1375
│ │ │ │ +
1376 template<class T1, class V2, class Op>
│ │ │ │ +
1377 void checkBinaryOpVVAgainstSV(MetaType<T1> t1, MetaType<V2> v2, Op op)
│ │ │ │ +
1378 {
│ │ │ │ +
1379 checkBinaryOpVVAgainstVS(v2, t1, OpInfixSwappedArgs<Op>{op});
│ │ │ │ +
1380 }
│ │ │ │ +
1381
│ │ │ │ +
1382 template<class V1, class T2>
│ │ │ │ +
1383 void checkBinaryOpVVAgainstSV(MetaType<V1>, MetaType<T2>, OpInfixComma)
│ │ │ │ +
1384 { }
│ │ │ │ +
1385
│ │ │ │ +
1387 //
│ │ │ │ +
1388 // Invoke the checks for all combinations
│ │ │ │ +
1389 //
│ │ │ │ +
1390
│ │ │ │ +
1391 template<class T1, class T2, bool condition, class Checker>
│ │ │ │ +
1392 void checkBinaryRefQual(Checker checker)
│ │ │ │ +
1393 {
│ │ │ │ +
1394 if constexpr (condition) {
│ │ │ │ +
1395 Hybrid::forEach(TypeList<T1&, const T1&, T1&&>{}, [=] (auto t1) {
│ │ │ │ +
1396 Hybrid::forEach(TypeList<T2&, const T2&, T2&&>{}, [=] (auto t2) {
│ │ │ │ +
1397 checker(t1, t2);
│ │ │ │ +
1398 });
│ │ │ │ +
1399 });
│ │ │ │ +
1400 }
│ │ │ │ +
1401 }
│ │ │ │ +
1402
│ │ │ │ +
1403 template<class V, class Checker>
│ │ │ │ +
1404 void checkBinaryOps(Checker checker)
│ │ │ │ +
1405 {
│ │ │ │ +
1406 using Std::bool_constant;
│ │ │ │ +
1407
│ │ │ │ +
1408 constexpr bool isMask = std::is_same<Scalar<V>, bool>::value;
│ │ │ │ +
1409
│ │ │ │ +
1410 constexpr bool do_ = false;
│ │ │ │ +
1411 constexpr bool do_SV = true;
│ │ │ │ +
1412 constexpr bool do_VV = true;
│ │ │ │ +
1413 constexpr bool do_VS = true;
│ │ │ │ +
1414
│ │ │ │ +
1415#define DUNE_SIMD_DO(M1, M2, M3, V1, V2, V3, NAME) \
│ │ │ │ +
1416 checker(bool_constant<isMask ? do_##M1 : do_##V1>{}, \
│ │ │ │ +
1417 bool_constant<isMask ? do_##M2 : do_##V2>{}, \
│ │ │ │ +
1418 bool_constant<isMask ? do_##M3 : do_##V3>{}, \
│ │ │ │ +
1419 Op##NAME{})
│ │ │ │ +
1420
│ │ │ │ +
1421 // (Mask , Vector , Name );
│ │ │ │ +
1422
│ │ │ │ +
1423 DUNE_SIMD_DO( , , , SV, VV, VS, InfixMul );
│ │ │ │ +
1424 DUNE_SIMD_DO( , , , SV, VV, VS, InfixDiv );
│ │ │ │ +
1425 DUNE_SIMD_DO( , , , SV, VV, VS, InfixRemainder );
│ │ │ │ +
1426
│ │ │ │ +
1427 DUNE_SIMD_DO( , , , SV, VV, VS, InfixPlus );
│ │ │ │ +
1428 DUNE_SIMD_DO( , , , SV, VV, VS, InfixMinus );
│ │ │ │ +
1429
│ │ │ │ +
1430 DUNE_SIMD_DO( , , , , VV, VS, InfixLeftShift );
│ │ │ │ +
1431 DUNE_SIMD_DO( , , , , VV, VS, InfixRightShift );
│ │ │ │ +
1432
│ │ │ │ +
1433 DUNE_SIMD_DO( , , , SV, VV, VS, InfixLess );
│ │ │ │ +
1434 DUNE_SIMD_DO( , , , SV, VV, VS, InfixGreater );
│ │ │ │ +
1435 DUNE_SIMD_DO( , , , SV, VV, VS, InfixLessEqual );
│ │ │ │ +
1436 DUNE_SIMD_DO( , , , SV, VV, VS, InfixGreaterEqual );
│ │ │ │ +
1437
│ │ │ │ +
1438 DUNE_SIMD_DO( , , , SV, VV, VS, InfixEqual );
│ │ │ │ +
1439 DUNE_SIMD_DO( , , , SV, VV, VS, InfixNotEqual );
│ │ │ │ +
1440
│ │ │ │ +
1441 DUNE_SIMD_DO( , VV, , SV, VV, VS, InfixBitAnd );
│ │ │ │ +
1442 DUNE_SIMD_DO( , VV, , SV, VV, VS, InfixBitXor );
│ │ │ │ +
1443 DUNE_SIMD_DO( , VV, , SV, VV, VS, InfixBitOr );
│ │ │ │ +
1444
│ │ │ │ +
1445 DUNE_SIMD_DO(SV, VV, VS, SV, VV, VS, InfixLogicAnd );
│ │ │ │ +
1446 DUNE_SIMD_DO(SV, VV, VS, SV, VV, VS, InfixLogicOr );
│ │ │ │ +
1447
│ │ │ │ +
1448 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssign );
│ │ │ │ +
1449 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignMul );
│ │ │ │ +
1450 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignDiv );
│ │ │ │ +
1451 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignRemainder );
│ │ │ │ +
1452 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignPlus );
│ │ │ │ +
1453 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignMinus );
│ │ │ │ +
1454 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignLeftShift );
│ │ │ │ +
1455 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignRightShift);
│ │ │ │ +
1456 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssignAnd );
│ │ │ │ +
1457 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssignXor );
│ │ │ │ +
1458 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssignOr );
│ │ │ │ +
1459
│ │ │ │ +
1460 DUNE_SIMD_DO(SV, VV, VS, SV, , VS, InfixComma );
│ │ │ │ +
1461
│ │ │ │ +
1462#undef DUNE_SIMD_DO
│ │ │ │ +
1463 }
│ │ │ │ +
1464
│ │ │ │ +
1466 //
│ │ │ │ +
1467 // SIMD interface functions
│ │ │ │ +
1468 //
│ │ │ │ +
1469
│ │ │ │ +
1470 template<class V>
│ │ │ │ +
1471 void checkAutoCopy()
│ │ │ │ +
1472 {
│ │ │ │ +
1473 using RValueResult = decltype(autoCopy(lane(0, std::declval<V>())));
│ │ │ │ +
1474 static_assert(std::is_same<RValueResult, Scalar<V> >::value,
│ │ │ │ +
1475 "Result of autoCopy() must always be Scalar<V>");
│ │ │ │ +
1476
│ │ │ │ +
1477 using MutableLValueResult =
│ │ │ │ +
1478 decltype(autoCopy(lane(0, std::declval<V&>())));
│ │ │ │ +
1479 static_assert(std::is_same<MutableLValueResult, Scalar<V> >::value,
│ │ │ │ +
1480 "Result of autoCopy() must always be Scalar<V>");
│ │ │ │ +
1481
│ │ │ │ +
1482 using ConstLValueResult =
│ │ │ │ +
1483 decltype(autoCopy(lane(0, std::declval<const V&>())));
│ │ │ │ +
1484 static_assert(std::is_same<ConstLValueResult, Scalar<V> >::value,
│ │ │ │ +
1485 "Result of autoCopy() must always be Scalar<V>");
│ │ │ │ +
1486
│ │ │ │ +
1487 V vec = make123<V>();
│ │ │ │ +
1488 for(std::size_t l = 0; l < lanes(vec); ++l)
│ │ │ │ +
1489 DUNE_SIMD_CHECK(autoCopy(lane(l, vec)) == Scalar<V>(l+1));
│ │ │ │ +
1490 }
│ │ │ │ +
1491
│ │ │ │ +
1492 // may only be called for mask types
│ │ │ │ +
1493 template<class M>
│ │ │ │ +
1494 void checkBoolReductions()
│ │ │ │ +
1495 {
│ │ │ │ +
1496 M trueVec(true);
│ │ │ │ +
1497
│ │ │ │ +
1498 // mutable lvalue
│ │ │ │ +
1499 DUNE_SIMD_CHECK(allTrue (static_cast<M&>(trueVec)) == true);
│ │ │ │ +
1500 DUNE_SIMD_CHECK(anyTrue (static_cast<M&>(trueVec)) == true);
│ │ │ │ +
1501 DUNE_SIMD_CHECK(allFalse(static_cast<M&>(trueVec)) == false);
│ │ │ │ +
1502 DUNE_SIMD_CHECK(anyFalse(static_cast<M&>(trueVec)) == false);
│ │ │ │ +
1503
│ │ │ │ +
1504 // const lvalue
│ │ │ │ +
1505 DUNE_SIMD_CHECK(allTrue (static_cast<const M&>(trueVec)) == true);
│ │ │ │ +
1506 DUNE_SIMD_CHECK(anyTrue (static_cast<const M&>(trueVec)) == true);
│ │ │ │ +
1507 DUNE_SIMD_CHECK(allFalse(static_cast<const M&>(trueVec)) == false);
│ │ │ │ +
1508 DUNE_SIMD_CHECK(anyFalse(static_cast<const M&>(trueVec)) == false);
│ │ │ │ +
1509
│ │ │ │ +
1510 // rvalue
│ │ │ │ +
1511 DUNE_SIMD_CHECK(allTrue (M(true)) == true);
│ │ │ │ +
1512 DUNE_SIMD_CHECK(anyTrue (M(true)) == true);
│ │ │ │ +
1513 DUNE_SIMD_CHECK(allFalse(M(true)) == false);
│ │ │ │ +
1514 DUNE_SIMD_CHECK(anyFalse(M(true)) == false);
│ │ │ │ +
1515
│ │ │ │ +
1516 M falseVec(false);
│ │ │ │ +
1517
│ │ │ │ +
1518 // mutable lvalue
│ │ │ │ +
1519 DUNE_SIMD_CHECK(allTrue (static_cast<M&>(falseVec)) == false);
│ │ │ │ +
1520 DUNE_SIMD_CHECK(anyTrue (static_cast<M&>(falseVec)) == false);
│ │ │ │ +
1521 DUNE_SIMD_CHECK(allFalse(static_cast<M&>(falseVec)) == true);
│ │ │ │ +
1522 DUNE_SIMD_CHECK(anyFalse(static_cast<M&>(falseVec)) == true);
│ │ │ │ +
1523
│ │ │ │ +
1524 // const lvalue
│ │ │ │ +
1525 DUNE_SIMD_CHECK(allTrue (static_cast<const M&>(falseVec)) == false);
│ │ │ │ +
1526 DUNE_SIMD_CHECK(anyTrue (static_cast<const M&>(falseVec)) == false);
│ │ │ │ +
1527 DUNE_SIMD_CHECK(allFalse(static_cast<const M&>(falseVec)) == true);
│ │ │ │ +
1528 DUNE_SIMD_CHECK(anyFalse(static_cast<const M&>(falseVec)) == true);
│ │ │ │ +
1529
│ │ │ │ +
1530 // rvalue
│ │ │ │ +
1531 DUNE_SIMD_CHECK(allTrue (M(false)) == false);
│ │ │ │ +
1532 DUNE_SIMD_CHECK(anyTrue (M(false)) == false);
│ │ │ │ +
1533 DUNE_SIMD_CHECK(allFalse(M(false)) == true);
│ │ │ │ +
1534 DUNE_SIMD_CHECK(anyFalse(M(false)) == true);
│ │ │ │ +
1535
│ │ │ │ +
1536 auto mixedVec = broadcast<M>(0);
│ │ │ │ +
1537 for(std::size_t l = 0; l < lanes(mixedVec); ++l)
│ │ │ │ +
1538 lane(l, mixedVec) = (l % 2);
│ │ │ │ +
1539
│ │ │ │ +
1540 // mutable lvalue
│ │ │ │ + │ │ │ │ +
1542 (allTrue (static_cast<M&>(mixedVec)) == false);
│ │ │ │ + │ │ │ │ +
1544 (anyTrue (static_cast<M&>(mixedVec)) == (lanes<M>() > 1));
│ │ │ │ + │ │ │ │ +
1546 (allFalse(static_cast<M&>(mixedVec)) == (lanes<M>() == 1));
│ │ │ │ + │ │ │ │ +
1548 (anyFalse(static_cast<M&>(mixedVec)) == true);
│ │ │ │ +
1549
│ │ │ │ +
1550 // const lvalue
│ │ │ │ + │ │ │ │ +
1552 (allTrue (static_cast<const M&>(mixedVec)) == false);
│ │ │ │ + │ │ │ │ +
1554 (anyTrue (static_cast<const M&>(mixedVec)) == (lanes<M>() > 1));
│ │ │ │ + │ │ │ │ +
1556 (allFalse(static_cast<const M&>(mixedVec)) == (lanes<M>() == 1));
│ │ │ │ + │ │ │ │ +
1558 (anyFalse(static_cast<const M&>(mixedVec)) == true);
│ │ │ │ +
1559
│ │ │ │ +
1560 // rvalue
│ │ │ │ +
1561 DUNE_SIMD_CHECK(allTrue (M(mixedVec)) == false);
│ │ │ │ +
1562 DUNE_SIMD_CHECK(anyTrue (M(mixedVec)) == (lanes<M>() > 1));
│ │ │ │ +
1563 DUNE_SIMD_CHECK(allFalse(M(mixedVec)) == (lanes<M>() == 1));
│ │ │ │ +
1564 DUNE_SIMD_CHECK(anyFalse(M(mixedVec)) == true);
│ │ │ │ +
1565 }
│ │ │ │ +
1566
│ │ │ │ +
1567 template<class V>
│ │ │ │ +
1568 void checkCond()
│ │ │ │ +
1569 {
│ │ │ │ +
1570 using M = Mask<V>;
│ │ │ │ +
1571
│ │ │ │ +
1572 static_assert
│ │ │ │ +
1573 (std::is_same<decltype(cond(std::declval<M>(), std::declval<V>(),
│ │ │ │ +
1574 std::declval<V>())), V>::value,
│ │ │ │ +
1575 "The result of cond(M, V, V) should have exactly the type V");
│ │ │ │ +
1576
│ │ │ │ +
1577 static_assert
│ │ │ │ +
1578 (std::is_same<decltype(cond(std::declval<const M&>(),
│ │ │ │ +
1579 std::declval<const V&>(),
│ │ │ │ +
1580 std::declval<const V&>())), V>::value,
│ │ │ │ +
1581 "The result of cond(const M&, const V&, const V&) should have "
│ │ │ │ +
1582 "exactly the type V");
│ │ │ │ +
1583
│ │ │ │ +
1584 static_assert
│ │ │ │ +
1585 (std::is_same<decltype(cond(std::declval<M&>(), std::declval<V&>(),
│ │ │ │ +
1586 std::declval<V&>())), V>::value,
│ │ │ │ +
1587 "The result of cond(M&, V&, V&) should have exactly the type V");
│ │ │ │ +
1588
│ │ │ │ +
1589 V vec1 = leftVector<V>();
│ │ │ │ +
1590 V vec2 = rightVector<V>();
│ │ │ │ +
1591
│ │ │ │ +
1592 DUNE_SIMD_CHECK(allTrue(cond(M(true), vec1, vec2) == vec1));
│ │ │ │ +
1593 DUNE_SIMD_CHECK(allTrue(cond(M(false), vec1, vec2) == vec2));
│ │ │ │ +
1594
│ │ │ │ +
1595 auto mixedResult = broadcast<V>(0);
│ │ │ │ +
1596 auto mixedMask = broadcast<M>(false);
│ │ │ │ +
1597 for(std::size_t l = 0; l < lanes(mixedMask); ++l)
│ │ │ │ +
1598 {
│ │ │ │ +
1599 lane(l, mixedMask ) = (l % 2);
│ │ │ │ +
1600 lane(l, mixedResult) = lane(l, (l % 2) ? vec1 : vec2);
│ │ │ │ +
1601 }
│ │ │ │ +
1602
│ │ │ │ +
1603 DUNE_SIMD_CHECK(allTrue(cond(mixedMask, vec1, vec2) == mixedResult));
│ │ │ │ +
1604 }
│ │ │ │ +
1605
│ │ │ │ +
1606 template<class V>
│ │ │ │ +
1607 void checkBoolCond()
│ │ │ │ +
1608 {
│ │ │ │ +
1609 static_assert
│ │ │ │ +
1610 (std::is_same<decltype(cond(std::declval<bool>(), std::declval<V>(),
│ │ │ │ +
1611 std::declval<V>())), V>::value,
│ │ │ │ +
1612 "The result of cond(bool, V, V) should have exactly the type V");
│ │ │ │ +
1613
│ │ │ │ +
1614 static_assert
│ │ │ │ +
1615 (std::is_same<decltype(cond(std::declval<const bool&>(),
│ │ │ │ +
1616 std::declval<const V&>(),
│ │ │ │ +
1617 std::declval<const V&>())), V>::value,
│ │ │ │ +
1618 "The result of cond(const bool&, const V&, const V&) should have "
│ │ │ │ +
1619 "exactly the type V");
│ │ │ │ +
1620
│ │ │ │ +
1621 static_assert
│ │ │ │ +
1622 (std::is_same<decltype(cond(std::declval<bool&>(),
│ │ │ │ +
1623 std::declval<V&>(),
│ │ │ │ +
1624 std::declval<V&>())), V>::value,
│ │ │ │ +
1625 "The result of cond(bool&, V&, V&) should have exactly the type V");
│ │ │ │ +
1626
│ │ │ │ +
1627 V vec1 = leftVector<V>();
│ │ │ │ +
1628 V vec2 = rightVector<V>();
│ │ │ │ +
1629
│ │ │ │ +
1630 DUNE_SIMD_CHECK(allTrue(cond(true, vec1, vec2) == vec1));
│ │ │ │ +
1631 DUNE_SIMD_CHECK(allTrue(cond(false, vec1, vec2) == vec2));
│ │ │ │ +
1632 }
│ │ │ │ +
1633
│ │ │ │ +
1634 template<class V>
│ │ │ │ +
1635 std::enable_if_t<!Impl::LessThenComparable<Scalar<V> >::value>
│ │ │ │ +
1636 checkHorizontalMinMax() {}
│ │ │ │ +
1637
│ │ │ │ +
1638 template<class V>
│ │ │ │ +
1639 std::enable_if_t<Impl::LessThenComparable<Scalar<V> >::value>
│ │ │ │ +
1640 checkHorizontalMinMax()
│ │ │ │ +
1641 {
│ │ │ │ +
1642 static_assert
│ │ │ │ +
1643 (std::is_same<decltype(max(std::declval<V>())), Scalar<V> >::value,
│ │ │ │ +
1644 "The result of max(V) should be exactly Scalar<V>");
│ │ │ │ +
1645
│ │ │ │ +
1646 static_assert
│ │ │ │ +
1647 (std::is_same<decltype(min(std::declval<V>())), Scalar<V> >::value,
│ │ │ │ +
1648 "The result of min(V) should be exactly Scalar<V>");
│ │ │ │ +
1649
│ │ │ │ +
1650 static_assert
│ │ │ │ +
1651 (std::is_same<decltype(max(std::declval<V&>())), Scalar<V> >::value,
│ │ │ │ +
1652 "The result of max(V) should be exactly Scalar<V>");
│ │ │ │ +
1653
│ │ │ │ +
1654 static_assert
│ │ │ │ +
1655 (std::is_same<decltype(min(std::declval<V&>())), Scalar<V> >::value,
│ │ │ │ +
1656 "The result of min(V) should be exactly Scalar<V>");
│ │ │ │ +
1657
│ │ │ │ +
1658 const V vec1 = leftVector<V>();
│ │ │ │ +
1659
│ │ │ │ +
1660 DUNE_SIMD_CHECK(max(vec1) == Scalar<V>(lanes(vec1)));
│ │ │ │ +
1661 DUNE_SIMD_CHECK(min(vec1) == Scalar<V>(1));
│ │ │ │ +
1662 }
│ │ │ │ +
1663
│ │ │ │ +
1664 template<class V>
│ │ │ │ +
1665 std::enable_if_t<!Impl::LessThenComparable<Scalar<V> >::value>
│ │ │ │ +
1666 checkBinaryMinMax() {}
│ │ │ │ +
1667
│ │ │ │ +
1668 template<class V>
│ │ │ │ +
1669 std::enable_if_t<Impl::LessThenComparable<Scalar<V> >::value>
│ │ │ │ +
1670 checkBinaryMinMax()
│ │ │ │ +
1671 {
│ │ │ │ +
1672 using std::max;
│ │ │ │ +
1673 using std::min;
│ │ │ │ +
1674
│ │ │ │ +
1675 static_assert
│ │ │ │ +
1676 (std::is_same<decltype(Simd::max(std::declval<V>(),
│ │ │ │ +
1677 std::declval<V>())), V>::value,
│ │ │ │ +
1678 "The result of Simd::max(V, V) should be exactly V");
│ │ │ │ +
1679 static_assert
│ │ │ │ +
1680 (std::is_same<decltype(Simd::min(std::declval<V>(),
│ │ │ │ +
1681 std::declval<V>())), V>::value,
│ │ │ │ +
1682 "The result of Simd::min(V, V) should be exactly V");
│ │ │ │ +
1683
│ │ │ │ +
1684 static_assert
│ │ │ │ +
1685 (std::is_same<decltype(Simd::max(std::declval<V&>(),
│ │ │ │ +
1686 std::declval<V&>())), V>::value,
│ │ │ │ +
1687 "The result of Simd::max(V&, V&) should be exactly V");
│ │ │ │ +
1688 static_assert
│ │ │ │ +
1689 (std::is_same<decltype(Simd::min(std::declval<V&>(),
│ │ │ │ +
1690 std::declval<V&>())), V>::value,
│ │ │ │ +
1691 "The result of Simd::min(V&, V&) should be exactly V");
│ │ │ │ +
1692
│ │ │ │ +
1693 const V arg1 = leftVector<V>();
│ │ │ │ +
1694 const V arg2 = rightVector<V>();
│ │ │ │ +
1695
│ │ │ │ +
1696 V maxExp(Scalar<V>(0)), minExp(Scalar<V>(0));
│ │ │ │ +
1697 for(auto l : range(lanes<V>()))
│ │ │ │ +
1698 {
│ │ │ │ +
1699 lane(l, maxExp) = max(lane(l, arg1), lane(l, arg2));
│ │ │ │ +
1700 lane(l, minExp) = min(lane(l, arg1), lane(l, arg2));
│ │ │ │ +
1701 }
│ │ │ │ +
1702
│ │ │ │ +
1703 DUNE_SIMD_CHECK(allTrue(maxExp == Simd::max(arg1, arg2)));
│ │ │ │ +
1704 DUNE_SIMD_CHECK(allTrue(minExp == Simd::min(arg1, arg2)));
│ │ │ │ +
1705 }
│ │ │ │ +
1706
│ │ │ │ +
1707 template<class V>
│ │ │ │ +
1708 void checkIO()
│ │ │ │ +
1709 {
│ │ │ │ +
1710 const V vec1 = leftVector<V>();
│ │ │ │ +
1711
│ │ │ │ +
1712 std::string reference;
│ │ │ │ +
1713 {
│ │ │ │ +
1714 const char *sep = "";
│ │ │ │ +
1715 for(auto l : range(lanes(vec1)))
│ │ │ │ +
1716 {
│ │ │ │ +
1717 std::ostringstream stream;
│ │ │ │ +
1718 stream << lane(l, vec1);
│ │ │ │ +
1719
│ │ │ │ +
1720 reference += sep;
│ │ │ │ +
1721 reference += stream.str();
│ │ │ │ +
1722 sep = ", ";
│ │ │ │ +
1723 }
│ │ │ │ +
1724 }
│ │ │ │ +
1725
│ │ │ │ +
1726 {
│ │ │ │ +
1727 std::ostringstream stream;
│ │ │ │ +
1728 stream << io(vec1);
│ │ │ │ +
1729 if(lanes(vec1) == 1)
│ │ │ │ +
1730 DUNE_SIMD_CHECK(stream.str() == reference);
│ │ │ │ +
1731 else
│ │ │ │ +
1732 DUNE_SIMD_CHECK(stream.str() == "<" + reference + ">");
│ │ │ │ +
1733 }
│ │ │ │ +
1734
│ │ │ │ +
1735 {
│ │ │ │ +
1736 std::ostringstream stream;
│ │ │ │ +
1737 stream << vio(vec1);
│ │ │ │ +
1738 DUNE_SIMD_CHECK(stream.str() == "<" + reference + ">");
│ │ │ │ +
1739 }
│ │ │ │ +
1740 }
│ │ │ │ +
1741
│ │ │ │ +
1742#undef DUNE_SIMD_CHECK
│ │ │ │ +
1743
│ │ │ │ +
1744 public:
│ │ │ │ +
1807 template<class V> void checkType();
│ │ │ │ +
1808 template<class V> void checkNonOps();
│ │ │ │ +
1809 template<class V> void checkUnaryOps();
│ │ │ │ +
1810 template<class V> void checkBinaryOps();
│ │ │ │ +
1811 template<class V> void checkBinaryOpsVectorVector();
│ │ │ │ +
1812 template<class V> void checkBinaryOpsScalarVector();
│ │ │ │ +
1813 template<class V> void checkBinaryOpsVectorScalar();
│ │ │ │ +
1814 template<class V> void checkBinaryOpsProxyVector();
│ │ │ │ +
1815 template<class V> void checkBinaryOpsVectorProxy();
│ │ │ │ +
1819
│ │ │ │ +
1836 template<class V, class Rebinds,
│ │ │ │ +
1837 template<class> class RebindPrune = IsLoop,
│ │ │ │ +
1838 template<class> class RebindAccept = Dune::AlwaysTrue>
│ │ │ │ +
│ │ │ │ +
1839 void check() {
│ │ │ │ +
1840 // check whether the test for this type already started
│ │ │ │ +
1841 if(seen_.emplace(typeid (V)).second == false)
│ │ │ │ +
1842 {
│ │ │ │ +
1843 // type already seen, nothing to do
│ │ │ │ +
1844 return;
│ │ │ │ +
1845 }
│ │ │ │ +
1846
│ │ │ │ +
1847 // do these first so everything that appears after "Checking SIMD type
│ │ │ │ +
1848 // ..." really pertains to that type
│ │ │ │ +
1849 auto recurse = [this](auto w) {
│ │ │ │ +
1850 using W = typename decltype(w)::type;
│ │ │ │ +
1851 this->template check<W, Rebinds, RebindPrune, RebindAccept>();
│ │ │ │ +
1852 };
│ │ │ │ +
1853 checkRebindOf<V, Rebinds, RebindPrune, RebindAccept>(recurse);
│ │ │ │ +
1854
│ │ │ │ +
1855 checkType<V>();
│ │ │ │ +
1856 }
│ │ │ │ +
│ │ │ │ +
1857
│ │ │ │ +
│ │ │ │ +
1859 bool good() const
│ │ │ │ +
1860 {
│ │ │ │ +
1861 return good_;
│ │ │ │ +
1862 }
│ │ │ │ +
│ │ │ │ +
1863
│ │ │ │ +
1864 }; // class UnitTest
│ │ │ │ +
│ │ │ │ +
1865
│ │ │ │ +
│ │ │ │ +
1866 template<class V> void UnitTest::checkType()
│ │ │ │ +
1867 {
│ │ │ │ +
1868 static_assert(std::is_same<V, std::decay_t<V> >::value, "Simd types "
│ │ │ │ +
1869 "must not be references, and must not include "
│ │ │ │ +
1870 "cv-qualifiers");
│ │ │ │ +
1871
│ │ │ │ +
1872 log_ << "Checking SIMD type " << className<V>() << std::endl;
│ │ │ │ +
1873
│ │ │ │ +
1874 checkNonOps<V>();
│ │ │ │ +
1875 checkUnaryOps<V>();
│ │ │ │ +
1876 checkBinaryOps<V>();
│ │ │ │ +
1877 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
1878 template<class V> void UnitTest::checkNonOps()
│ │ │ │ +
1879 {
│ │ │ │ +
1880 constexpr auto isMask = typename std::is_same<Scalar<V>, bool>::type{};
│ │ │ │ +
1881
│ │ │ │ +
1882 checkLanes<V>();
│ │ │ │ +
1883 checkScalar<V>();
│ │ │ │ +
1884
│ │ │ │ +
1885 checkDefaultConstruct<V>();
│ │ │ │ +
1886 checkLane<V>();
│ │ │ │ +
1887 checkCopyMoveConstruct<V>();
│ │ │ │ +
1888 checkImplCast<V>();
│ │ │ │ +
1889 checkBroadcast<V>();
│ │ │ │ +
1890 if constexpr (isMask)
│ │ │ │ +
1891 this->template checkBroadcastMaskConstruct<V>();
│ │ │ │ +
1892 else
│ │ │ │ +
1893 this->template checkBroadcastVectorConstruct<V>();
│ │ │ │ +
1894 checkBracedAssign<V>();
│ │ │ │ +
1895 checkBracedBroadcastAssign<V>();
│ │ │ │ +
1896
│ │ │ │ +
1897 checkAutoCopy<V>();
│ │ │ │ +
1898 checkCond<V>();
│ │ │ │ +
1899 checkBoolCond<V>();
│ │ │ │ +
1900
│ │ │ │ +
1901 if constexpr (isMask)
│ │ │ │ +
1902 this->template checkBoolReductions<V>();
│ │ │ │ +
1903 // checkBoolReductions() is not applicable for non-masks
│ │ │ │ +
1904
│ │ │ │ +
1905 checkHorizontalMinMax<V>();
│ │ │ │ +
1906 checkBinaryMinMax<V>();
│ │ │ │ +
1907 checkIO<V>();
│ │ │ │ +
1908 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
1909 template<class V> void UnitTest::checkUnaryOps()
│ │ │ │ +
1910 {
│ │ │ │ +
1911 if constexpr (std::is_same_v<Scalar<V>, bool>) {
│ │ │ │ +
1912 // check mask
│ │ │ │ +
1913 auto check = [this](auto op) {
│ │ │ │ +
1914 this->template checkUnaryOpsV<V>(op);
│ │ │ │ +
1915 };
│ │ │ │ +
1916
│ │ │ │ +
1917 // postfix
│ │ │ │ +
1918 // check(OpPostfixDecrement{});
│ │ │ │ +
1919 // clang deprecation warning if bool++ is tested
│ │ │ │ +
1920 // check(OpPostfixIncrement{});
│ │ │ │ +
1921
│ │ │ │ +
1922 // prefix
│ │ │ │ +
1923 // check(OpPrefixDecrement{});
│ │ │ │ +
1924 // clang deprecation warning if ++bool is tested
│ │ │ │ +
1925 // check(OpPrefixIncrement{});
│ │ │ │ +
1926
│ │ │ │ +
1927 // check(OpPrefixPlus{});
│ │ │ │ +
1928 // check(OpPrefixMinus{});
│ │ │ │ +
1929 check(OpPrefixLogicNot{});
│ │ │ │ +
1930 // check(OpPrefixBitNot{});
│ │ │ │ +
1931 }
│ │ │ │ +
1932 else {
│ │ │ │ +
1933 // check vector
│ │ │ │ +
1934 auto check = [this](auto op) {
│ │ │ │ +
1935 this->template checkUnaryOpsV<V>(op);
│ │ │ │ +
1936 };
│ │ │ │ +
1937
│ │ │ │ +
1938 // postfix
│ │ │ │ +
1939 // check(OpPostfixDecrement{});
│ │ │ │ +
1940 // check(OpPostfixIncrement{});
│ │ │ │ +
1941
│ │ │ │ +
1942 // prefix
│ │ │ │ +
1943 // check(OpPrefixDecrement{});
│ │ │ │ +
1944 // check(OpPrefixIncrement{});
│ │ │ │ +
1945
│ │ │ │ +
1946 // check(OpPrefixPlus{});
│ │ │ │ +
1947 check(OpPrefixMinus{});
│ │ │ │ +
1948 check(OpPrefixLogicNot{});
│ │ │ │ +
1949 check(OpPrefixBitNot{});
│ │ │ │ +
1950 }
│ │ │ │ +
1951 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
1952 template<class V> void UnitTest::checkBinaryOps()
│ │ │ │ +
1953 {
│ │ │ │ +
1954 checkBinaryOpsVectorVector<V>();
│ │ │ │ +
1955 checkBinaryOpsScalarVector<V>();
│ │ │ │ +
1956 checkBinaryOpsVectorScalar<V>();
│ │ │ │ +
1957 checkBinaryOpsProxyVector<V>();
│ │ │ │ +
1958 checkBinaryOpsVectorProxy<V>();
│ │ │ │ +
1959 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1961 {
│ │ │ │ +
1962 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
│ │ │ │ +
1963 auto check = [this,op](auto t1, auto t2) {
│ │ │ │ +
1964 this->checkBinaryOpVV(t1, t2, op);
│ │ │ │ +
1965 };
│ │ │ │ +
1966 this->checkBinaryRefQual<V, V, doVV>(check);
│ │ │ │ +
1967 };
│ │ │ │ +
1968 checkBinaryOps<V>(checker);
│ │ │ │ +
1969 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1971 {
│ │ │ │ +
1972 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
│ │ │ │ +
1973 auto check = [this,op](auto t1, auto t2) {
│ │ │ │ +
1974 this->checkBinaryOpSV(t1, t2, op);
│ │ │ │ +
1975 };
│ │ │ │ +
1976 this->checkBinaryRefQual<Scalar<V>, V, doSV>(check);
│ │ │ │ +
1977
│ │ │ │ +
1978 auto crossCheck = [this,op](auto t1, auto t2) {
│ │ │ │ +
1979 this->checkBinaryOpVVAgainstSV(t1, t2, op);
│ │ │ │ +
1980 };
│ │ │ │ +
1981 this->checkBinaryRefQual<Scalar<V>, V, doSV && doVV>(crossCheck);
│ │ │ │ +
1982 };
│ │ │ │ +
1983 checkBinaryOps<V>(checker);
│ │ │ │ +
1984 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
1986 {
│ │ │ │ +
1987 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
│ │ │ │ +
1988 auto check = [this,op](auto t1, auto t2) {
│ │ │ │ +
1989 this->checkBinaryOpVS(t1, t2, op);
│ │ │ │ +
1990 };
│ │ │ │ +
1991 this->checkBinaryRefQual<V, Scalar<V>, doVS>(check);
│ │ │ │ +
1992
│ │ │ │ +
1993 auto crossCheck = [this,op](auto t1, auto t2) {
│ │ │ │ +
1994 this->checkBinaryOpVVAgainstVS(t1, t2, op);
│ │ │ │ +
1995 };
│ │ │ │ +
1996 this->checkBinaryRefQual<V, Scalar<V>, doVV && doVS>(crossCheck);
│ │ │ │ +
1997 };
│ │ │ │ +
1998 checkBinaryOps<V>(checker);
│ │ │ │ +
1999 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
2001 {
│ │ │ │ +
2002 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
│ │ │ │ +
2003 auto check = [this,op](auto t1, auto t2) {
│ │ │ │ +
2004 this->checkBinaryOpPV(t1, t2, op);
│ │ │ │ +
2005 };
│ │ │ │ +
2006 this->checkBinaryRefQual<V, V, doSV>(check);
│ │ │ │ +
2007 };
│ │ │ │ +
2008 checkBinaryOps<V>(checker);
│ │ │ │ +
2009 }
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
2011 {
│ │ │ │ +
2012 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) {
│ │ │ │ +
2013 auto check = [this,op](auto t1, auto t2) {
│ │ │ │ +
2014 this->checkBinaryOpVP(t1, t2, op);
│ │ │ │ +
2015 };
│ │ │ │ +
2016 this->checkBinaryRefQual<V, V, doVS>(check);
│ │ │ │ +
2017 };
│ │ │ │ +
2018 checkBinaryOps<V>(checker);
│ │ │ │ +
2019 }
│ │ │ │ +
│ │ │ │ +
2020
│ │ │ │ +
2021 } // namespace Simd
│ │ │ │ +
2022} // namespace Dune
│ │ │ │ +
2023
│ │ │ │ +
2024#endif // DUNE_COMMON_SIMD_TEST_HH
│ │ │ │ +
IO interface of the SIMD abstraction.
│ │ │ │ + │ │ │ │ +
#define DUNE_SIMD_POSTFIX_OP(NAME, SYMBOL)
Definition test.hh:670
│ │ │ │ +
#define DUNE_SIMD_INFIX_OP(NAME, SYMBOL)
Definition test.hh:784
│ │ │ │ +
#define DUNE_SIMD_CHECK_OP(expr)
Definition test.hh:191
│ │ │ │ +
#define DUNE_SIMD_CHECK(expr)
Definition test.hh:186
│ │ │ │ +
#define DUNE_SIMD_REPL_OP(NAME, REPLFN, SYMBOL)
Definition test.hh:818
│ │ │ │ +
#define DUNE_SIMD_ASSIGN_OP(NAME, SYMBOL)
Definition test.hh:805
│ │ │ │ +
#define DUNE_SIMD_PREFIX_OP(NAME, SYMBOL)
Definition test.hh:681
│ │ │ │ +
#define DUNE_SIMD_DO(M1, M2, M3, V1, V2, V3, NAME)
│ │ │ │ + │ │ │ │ +
A free function to provide the demangled class name of a given object or type as a string.
│ │ │ │ + │ │ │ │ +
Utilities for reduction like operations on ranges.
│ │ │ │ + │ │ │ │ +
Traits for type conversions and type information.
│ │ │ │ +
static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
Definition rangeutilities.hh:312
│ │ │ │ +
std::tuple< MetaType< T >... > TypeList
A simple type list.
Definition typelist.hh:87
│ │ │ │ +
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition hybridutilities.hh:256
│ │ │ │ +
constexpr AutonomousValue< T > autoCopy(T &&v)
Autonomous copy of an expression's value for use in auto type deduction.
Definition typetraits.hh:672
│ │ │ │ +
typename Impl::voider< Types... >::type void_t
Is void for all valid input types. The workhorse for C++11 SFINAE-techniques.
Definition typetraits.hh:40
│ │ │ │ +
bool anyTrue(const Mask &mask)
Whether any entry is true
Definition simd/interface.hh:429
│ │ │ │ +
auto maskOr(const V1 &v1, const V2 &v2)
Logic or of masks.
Definition simd/interface.hh:499
│ │ │ │ +
V cond(M &&mask, const V &ifTrue, const V &ifFalse)
Like the ?: operator.
Definition simd/interface.hh:386
│ │ │ │ +
auto io(const V &v)
construct a stream inserter
Definition io.hh:106
│ │ │ │ +
bool allTrue(const Mask &mask)
Whether all entries are true
Definition simd/interface.hh:439
│ │ │ │ +
auto vio(const V &v)
construct a stream inserter
Definition io.hh:90
│ │ │ │ +
auto max(const V &v1, const V &v2)
The binary maximum value over two simd objects.
Definition simd/interface.hh:409
│ │ │ │ +
bool anyFalse(const Mask &mask)
Whether any entry is false
Definition simd/interface.hh:449
│ │ │ │ +
constexpr std::size_t lanes()
Number of lanes in a SIMD type.
Definition simd/interface.hh:305
│ │ │ │ +
decltype(auto) lane(std::size_t l, V &&v)
Extract an element of a SIMD type.
Definition simd/interface.hh:324
│ │ │ │ +
bool allFalse(const Mask &mask)
Whether all entries are false
Definition simd/interface.hh:459
│ │ │ │ +
auto maskAnd(const V1 &v1, const V2 &v2)
Logic and of masks.
Definition simd/interface.hh:509
│ │ │ │ +
typename Overloads::ScalarType< std::decay_t< V > >::type Scalar
Element type of some SIMD type.
Definition simd/interface.hh:235
│ │ │ │ +
auto min(const V &v1, const V &v2)
The binary minimum value over two simd objects.
Definition simd/interface.hh:419
│ │ │ │
STL namespace.
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ +
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition integersequence.hh:75
│ │ │ │ +
typename Impl::RemoveEnd< EndMark, TypeList< Types... > >::type RebindList
A list of types with the final element removed.
Definition test.hh:158
│ │ │ │ +
typename Impl::IsLoop< T >::type IsLoop
check whether a type is an instance of LoopSIMD
Definition test.hh:162
│ │ │ │ +
Definition loop.hh:65
│ │ │ │ +
final element marker for RebindList
Definition test.hh:145
│ │ │ │ +
Definition test.hh:164
│ │ │ │ +
void checkUnaryOps()
Definition test.hh:1909
│ │ │ │ +
void checkBinaryOps()
Definition test.hh:1952
│ │ │ │ +
void checkBinaryOpsScalarVector()
Definition test.hh:1970
│ │ │ │ +
void checkType()
Definition test.hh:1866
│ │ │ │ +
void check()
run unit tests for simd vector type V
Definition test.hh:1839
│ │ │ │ +
void checkBinaryOpsVectorScalar()
Definition test.hh:1985
│ │ │ │ +
bool good() const
whether all tests succeeded
Definition test.hh:1859
│ │ │ │ +
void checkBinaryOpsVectorVector()
Definition test.hh:1960
│ │ │ │ +
void checkNonOps()
Definition test.hh:1878
│ │ │ │ +
void checkBinaryOpsVectorProxy()
Definition test.hh:2010
│ │ │ │ +
void checkBinaryOpsProxyVector()
Definition test.hh:2000
│ │ │ │ +
template which always yields a true value
Definition typetraits.hh:134
│ │ │ │ +
Include file for users of the SIMD abstraction layer.
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,110 +1,2101 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -proxymemberaccess.hh │ │ │ │ │ + * simd │ │ │ │ │ +test.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ -2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ -3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PROXYMEMBERACCESS_HH │ │ │ │ │ -6#define DUNE_COMMON_PROXYMEMBERACCESS_HH │ │ │ │ │ -7 │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16 │ │ │ │ │ -17namespace Dune { │ │ │ │ │ -18 │ │ │ │ │ -19 namespace Impl { │ │ │ │ │ -20 │ │ │ │ │ -21 // helper struct to store a temporary / proxy │ │ │ │ │ -22 // for the duration of the member access │ │ │ │ │ -23 template │ │ │ │ │ -24 struct member_access_proxy_holder │ │ │ │ │ -25 { │ │ │ │ │ -26 │ │ │ │ │ -27 // only support moving the temporary into the holder object │ │ │ │ │ -28 member_access_proxy_holder(T&& t) │ │ │ │ │ -29 : _t(std::move(t)) │ │ │ │ │ -30 {} │ │ │ │ │ -31 │ │ │ │ │ -32 // The object is fundamentally a temporary, i.e. an rvalue, │ │ │ │ │ -33 // │ │ │ │ │ -34 const T* operator->() const │ │ │ │ │ -35 { │ │ │ │ │ -36 return &_t; │ │ │ │ │ -37 } │ │ │ │ │ -38 │ │ │ │ │ -39 T _t; │ │ │ │ │ -40 │ │ │ │ │ -41 }; │ │ │ │ │ -42 │ │ │ │ │ -43 } // end Impl namespace │ │ │ │ │ -44 │ │ │ │ │ +2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +3#ifndef DUNE_COMMON_SIMD_TEST_HH │ │ │ │ │ +4#define DUNE_COMMON_SIMD_TEST_HH │ │ │ │ │ +5 │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14#include │ │ │ │ │ +15#include │ │ │ │ │ +16#include │ │ │ │ │ +17#include │ │ │ │ │ +18#include │ │ │ │ │ +19#include │ │ │ │ │ +20#include │ │ │ │ │ +21#include │ │ │ │ │ +22 │ │ │ │ │ +23#include │ │ │ │ │ +24#include │ │ │ │ │ +25#include │ │ │ │ │ +26#include │ │ │ │ │ +27#include │ │ │ │ │ +28#include │ │ │ │ │ +29#include │ │ │ │ │ +30#include │ │ │ │ │ +31#include │ │ │ │ │ +32 │ │ │ │ │ +33namespace Dune { │ │ │ │ │ +34 namespace Simd { │ │ │ │ │ +35 │ │ │ │ │ +36 namespace Impl { │ │ │ │ │ +37 │ │ │ │ │ +38 template │ │ │ │ │ +39 struct LessThenComparable : std::false_type {}; │ │ │ │ │ +40 template │ │ │ │ │ +41 struct LessThenComparable() │ │ │ │ │ +42 < std::declval())> > : │ │ │ │ │ +43 std::true_type │ │ │ │ │ +44 {}; │ │ │ │ │ 45 │ │ │ │ │ -46#ifdef DOXYGEN │ │ │ │ │ -47 │ │ │ │ │ -49 │ │ │ │ │ -79 template │ │ │ │ │ -80 pointer_or_proxy_holder │ │ │ │ │ -81 handle_proxy_member_access(T&& t); │ │ │ │ │ -82 │ │ │ │ │ -83#else // DOXYGEN │ │ │ │ │ +46 template │ │ │ │ │ +47 struct CopyConstHelper │ │ │ │ │ +48 { │ │ │ │ │ +49 using type = Dst; │ │ │ │ │ +50 }; │ │ │ │ │ +51 template │ │ │ │ │ +52 struct CopyConstHelper │ │ │ │ │ +53 { │ │ │ │ │ +54 using type = std::add_const_t; │ │ │ │ │ +55 }; │ │ │ │ │ +56 │ │ │ │ │ +57 template │ │ │ │ │ +58 struct CopyVolatileHelper │ │ │ │ │ +59 { │ │ │ │ │ +60 using type = Dst; │ │ │ │ │ +61 }; │ │ │ │ │ +62 template │ │ │ │ │ +63 struct CopyVolatileHelper │ │ │ │ │ +64 { │ │ │ │ │ +65 using type = std::add_volatile_t; │ │ │ │ │ +66 }; │ │ │ │ │ +67 │ │ │ │ │ +68 template │ │ │ │ │ +69 struct CopyReferenceHelper │ │ │ │ │ +70 { │ │ │ │ │ +71 using type = Dst; │ │ │ │ │ +72 }; │ │ │ │ │ +73 template │ │ │ │ │ +74 struct CopyReferenceHelper │ │ │ │ │ +75 { │ │ │ │ │ +76 using type = std::add_lvalue_reference_t; │ │ │ │ │ +77 }; │ │ │ │ │ +78 │ │ │ │ │ +79 template │ │ │ │ │ +80 struct CopyReferenceHelper │ │ │ │ │ +81 { │ │ │ │ │ +82 using type = std::add_rvalue_reference_t; │ │ │ │ │ +83 }; │ │ │ │ │ 84 │ │ │ │ │ -85 │ │ │ │ │ -86 // This version matches lvalues (the C++ type deduction rules state that │ │ │ │ │ -87 // the T&& signature deduces to a reference iff the argument is an lvalue). │ │ │ │ │ -88 // As the argument is an lvalue, we do not have to worry about its lifetime │ │ │ │ │ -89 // and can just return its address. │ │ │ │ │ -90 template │ │ │ │ │ -91 inline typename std::enable_if< │ │ │ │ │ -92 std::is_lvalue_reference::value, │ │ │ │ │ -93 typename std::add_pointer< │ │ │ │ │ -94 typename std::remove_reference< │ │ │ │ │ -95 T │ │ │ │ │ -96 >::type │ │ │ │ │ -97 >::type │ │ │ │ │ -98 >::type │ │ │ │ │ -99 handle_proxy_member_access(T&& target) │ │ │ │ │ -100 { │ │ │ │ │ -101 return ⌖ │ │ │ │ │ -102 } │ │ │ │ │ -103 │ │ │ │ │ -104 // This version matches rvalues (the C++ type deduction rules state that │ │ │ │ │ -105 // the T&& signature deduces to a non-reference iff the argument is an │ │ │ │ │ -rvalue). │ │ │ │ │ -106 // In this case, we have to capture the rvalue in a new object to make sure │ │ │ │ │ -it │ │ │ │ │ -107 // is kept alive for the duration of the member access. For this purpose, │ │ │ │ │ -we move │ │ │ │ │ -108 // it into a member_access_proxy_holder instance. │ │ │ │ │ -109 template │ │ │ │ │ -110 inline typename std::enable_if< │ │ │ │ │ -111 !std::is_lvalue_reference::value, │ │ │ │ │ -112 Impl::member_access_proxy_holder │ │ │ │ │ -113 >::type │ │ │ │ │ -114 handle_proxy_member_access(T&& target) │ │ │ │ │ -115 { │ │ │ │ │ -116 return {std::forward(target)}; │ │ │ │ │ -117 } │ │ │ │ │ +85 template │ │ │ │ │ +86 using CopyRefQual = typename CopyReferenceHelper< │ │ │ │ │ +87 typename CopyVolatileHelper< │ │ │ │ │ +88 typename CopyConstHelper< │ │ │ │ │ +89 std::decay_t, │ │ │ │ │ +90 std::remove_reference_t │ │ │ │ │ +91 >::type, │ │ │ │ │ +92 std::remove_reference_t │ │ │ │ │ +93 >::type, │ │ │ │ │ +94 Src │ │ │ │ │ +95 >::type; │ │ │ │ │ +96 │ │ │ │ │ +97 template::value - 1> > │ │ │ │ │ +100 struct RemoveEnd; │ │ │ │ │ +101 template │ │ │ │ │ +102 struct RemoveEnd> │ │ │ │ │ +103 { │ │ │ │ │ +104 using Back = TypeListEntry_t::value - 1, Types>; │ │ │ │ │ +105 static_assert(std::is_same::value, │ │ │ │ │ +106 "TypeList not terminated by proper EndMark"); │ │ │ │ │ +107 using type = TypeList...>; │ │ │ │ │ +108 }; │ │ │ │ │ +109 │ │ │ │ │ +110 template │ │ │ │ │ +111 struct TypeInList; │ │ │ │ │ +112 │ │ │ │ │ +113 template │ │ │ │ │ +114 struct TypeInList > : std::false_type {}; │ │ │ │ │ +115 │ │ │ │ │ +116 template │ │ │ │ │ +117 struct TypeInList > : std::true_type {}; │ │ │ │ │ 118 │ │ │ │ │ -119#endif // DOXYGEN │ │ │ │ │ -120 │ │ │ │ │ -121} // namespace Dune │ │ │ │ │ -122 │ │ │ │ │ -123#endif // DUNE_COMMON_PROXYMEMBERACCESS_HH │ │ │ │ │ -Dune::handle_proxy_member_access │ │ │ │ │ -pointer_or_proxy_holder handle_proxy_member_access(T &&t) │ │ │ │ │ -Transparent support for providing member access to both lvalues and rvalues │ │ │ │ │ -(temporary proxies). │ │ │ │ │ +119 template │ │ │ │ │ +120 struct TypeInList, │ │ │ │ │ +121 std::enable_if_t::value> > : │ │ │ │ │ +122 TypeInList >::type │ │ │ │ │ +123 {}; │ │ │ │ │ +124 │ │ │ │ │ +125 template │ │ │ │ │ +126 struct IsLoop : std::false_type {}; │ │ │ │ │ +127 template │ │ │ │ │ +128 struct IsLoop > : std::true_type {}; │ │ │ │ │ +129 │ │ │ │ │ +130 // used inside static_assert to trick the compiler into printing a list │ │ │ │ │ +131 // of types: │ │ │ │ │ +132 // │ │ │ │ │ +133 // static_assert(debugTypes(Std::bool_constant{}), "msg"); │ │ │ │ │ +134 // │ │ │ │ │ +135 // Should include what the type `V` expands to in the error message. │ │ │ │ │ +136 template │ │ │ │ │ +137 constexpr bool debugTypes(std::true_type) { return true; } │ │ │ │ │ +138 template │ │ │ │ │ +139 [[deprecated]] │ │ │ │ │ +140 constexpr bool debugTypes(std::false_type) { return false; } │ │ │ │ │ +141 │ │ │ │ │ +142 } // namespace Impl │ │ │ │ │ +143 │ │ │ │ │ +145 struct EndMark {}; │ │ │ │ │ +147 │ │ │ │ │ +156 template │ │ │ │ │ +157 using RebindList = │ │ │ │ │ +158 typename Impl::RemoveEnd >::type; │ │ │ │ │ +159 │ │ │ │ │ +161 template │ │ │ │ │ +162 using IsLoop = typename Impl::IsLoop::type; │ │ │ │ │ +163 │ │ │ │ │ +164 class UnitTest { │ │ │ │ │ +165 bool good_ = true; │ │ │ │ │ +166 std::ostream &log_ = std::cerr; │ │ │ │ │ +167 // records the types for which checks have started running to avoid │ │ │ │ │ +168 // infinite recursion │ │ │ │ │ +169 std::unordered_set seen_; │ │ │ │ │ +170 │ │ │ │ │ +172 // │ │ │ │ │ +173 // Helper functions │ │ │ │ │ +174 // │ │ │ │ │ +175 │ │ │ │ │ +176 void complain(const char *file, int line, const char *func, │ │ │ │ │ +177 const char *expr); │ │ │ │ │ +178 │ │ │ │ │ +179 void complain(const char *file, int line, const char *func, │ │ │ │ │ +180 const std::string &opname, const char *expr); │ │ │ │ │ +181 │ │ │ │ │ +182 // This macro is defined only within this file, do not use anywhere │ │ │ │ │ +183 // else. Doing the actual printing in an external function dramatically │ │ │ │ │ +184 // reduces memory use during compilation. Defined in such a way that │ │ │ │ │ +185 // the call will only happen for failed checks. │ │ │ │ │ +186#define DUNE_SIMD_CHECK(expr) \ │ │ │ │ │ +187 ((expr) ? void() : complain(__FILE__, __LINE__, __func__, #expr)) │ │ │ │ │ +188 │ │ │ │ │ +189 // the function using this macro must define a way to compute the │ │ │ │ │ +190 // operator name in DUNE_SIMD_OPNAME │ │ │ │ │ +191#define DUNE_SIMD_CHECK_OP(expr) \ │ │ │ │ │ +192 ((expr) ? void() : complain(__FILE__, __LINE__, __func__, \ │ │ │ │ │ +193 DUNE_SIMD_OPNAME, #expr)) │ │ │ │ │ +194 │ │ │ │ │ +195 // "cast" into a prvalue │ │ │ │ │ +196 template │ │ │ │ │ +197 static std::decay_t prvalue(T &&t) │ │ │ │ │ +198 { │ │ │ │ │ +199 return std::forward(t); │ │ │ │ │ +200 } │ │ │ │ │ +201 │ │ │ │ │ +202 // whether the vector is 42 in all lanes │ │ │ │ │ +203 template │ │ │ │ │ +204 static bool is42(const V &v) │ │ │ │ │ +205 { │ │ │ │ │ +206 bool good = true; │ │ │ │ │ +207 │ │ │ │ │ +208 for(std::size_t l = 0; l < lanes(v); ++l) │ │ │ │ │ +209 // need to cast in case we have a mask type │ │ │ │ │ +210 good &= (lane(l, v) == Scalar(42)); │ │ │ │ │ +211 │ │ │ │ │ +212 return good; │ │ │ │ │ +213 } │ │ │ │ │ +214 │ │ │ │ │ +215 // make a vector that contains the sequence { 1, 2, ... } │ │ │ │ │ +216 template │ │ │ │ │ +217 static V make123() │ │ │ │ │ +218 { │ │ │ │ │ +219 // initialize to avoid undefined behaviour if assigning to lane() │ │ │ │ │ +220 // involves lvalue-to-rvalue conversions, e.g. due to bitmask │ │ │ │ │ +221 // operations. Avoid using broadcast() for initialization to avoid │ │ │ │ │ +222 // test interdependencies. │ │ │ │ │ +223 V vec(Scalar(0)); │ │ │ │ │ +224 for(std::size_t l = 0; l < lanes(vec); ++l) │ │ │ │ │ +225 lane(l, vec) = l + 1; │ │ │ │ │ +226 return vec; │ │ │ │ │ +227 } │ │ │ │ │ +228 │ │ │ │ │ +229 // whether the vector contains the sequence { 1, 2, ... } │ │ │ │ │ +230 template │ │ │ │ │ +231 static bool is123(const V &v) │ │ │ │ │ +232 { │ │ │ │ │ +233 bool good = true; │ │ │ │ │ +234 │ │ │ │ │ +235 for(std::size_t l = 0; l < lanes(v); ++l) │ │ │ │ │ +236 // need to cast in case we have a mask type │ │ │ │ │ +237 good &= (lane(l, v) == Scalar(l+1)); │ │ │ │ │ +238 │ │ │ │ │ +239 return good; │ │ │ │ │ +240 } │ │ │ │ │ +241 │ │ │ │ │ +242 template │ │ │ │ │ +243 static V leftVector() │ │ │ │ │ +244 { │ │ │ │ │ +245 // Avoid using broadcast() for initialization to avoid test │ │ │ │ │ +246 // interdependencies. │ │ │ │ │ +247 V res(Scalar(0)); │ │ │ │ │ +248 for(std::size_t l = 0; l < lanes(res); ++l) │ │ │ │ │ +249 lane(l, res) = Scalar(l+1); │ │ │ │ │ +250 return res; │ │ │ │ │ +251 } │ │ │ │ │ +252 │ │ │ │ │ +253 template │ │ │ │ │ +254 static V rightVector() │ │ │ │ │ +255 { │ │ │ │ │ +256 // Avoid using broadcast() for initialization to avoid test │ │ │ │ │ +257 // interdependencies. │ │ │ │ │ +258 V res(Scalar(0)); │ │ │ │ │ +259 for(std::size_t l = 0; l < lanes(res); ++l) │ │ │ │ │ +260 // do not exceed number of bits in char (for shifts) │ │ │ │ │ +261 // avoid 0 (for / and %) │ │ │ │ │ +262 lane(l, res) = Scalar((l)%7+1); │ │ │ │ │ +263 return res; │ │ │ │ │ +264 } │ │ │ │ │ +265 │ │ │ │ │ +266 template │ │ │ │ │ +267 static T leftScalar() │ │ │ │ │ +268 { │ │ │ │ │ +269 return T(42); │ │ │ │ │ +270 } │ │ │ │ │ +271 │ │ │ │ │ +272 template │ │ │ │ │ +273 static T rightScalar() │ │ │ │ │ +274 { │ │ │ │ │ +275 // do not exceed number of bits in char (for shifts) │ │ │ │ │ +276 // avoid 0 (for / and %) │ │ │ │ │ +277 return T(5); │ │ │ │ │ +278 } │ │ │ │ │ +279 │ │ │ │ │ +280 template │ │ │ │ │ +281 using CopyRefQual = Impl::CopyRefQual; │ │ │ │ │ +282 │ │ │ │ │ +283 // test whether the Op supports the operation on scalars. We do not use │ │ │ │ │ +284 // `lane()` to obtain the scalars, because that might return a proxy │ │ │ │ │ +285 // object, and we are interested in what exactly the scalar type can do, │ │ │ │ │ +286 // no a proxy that might have more overloads than needed. In addition, │ │ │ │ │ +287 // `lane()` may not preserve `const` and reference qualifiers. │ │ │ │ │ +288 template │ │ │ │ │ +289 using ScalarResult = │ │ │ │ │ +290 decltype(std::declval(). │ │ │ │ │ +291 scalar(std::declval, │ │ │ │ │ +292 Vectors> >()...)); │ │ │ │ │ +293 │ │ │ │ │ +295 // │ │ │ │ │ +296 // Check associated types │ │ │ │ │ +297 // │ │ │ │ │ +298 │ │ │ │ │ +299 template │ │ │ │ │ +300 void checkScalar() │ │ │ │ │ +301 { │ │ │ │ │ +302 // check that the type Scalar exists │ │ │ │ │ +303 using T = Scalar; │ │ │ │ │ +304 │ │ │ │ │ +305 static_assert(std::is_same >::value, "Scalar types " │ │ │ │ │ +306 "must not be references, and must not include " │ │ │ │ │ +307 "cv-qualifiers"); │ │ │ │ │ +308 [[maybe_unused]] T a{}; │ │ │ │ │ +309 } │ │ │ │ │ +310 │ │ │ │ │ +311 template │ │ │ │ │ +312 [[deprecated("Warning: please include bool in the Rebinds for " │ │ │ │ │ +313 "simd type V, as Masks are not checked otherwise.")]] │ │ │ │ │ +314 void warnMissingMaskRebind(std::true_type) {} │ │ │ │ │ +315 template │ │ │ │ │ +316 void warnMissingMaskRebind(std::false_type) {} │ │ │ │ │ +317 │ │ │ │ │ +318 template class RebindPrune, │ │ │ │ │ +319 template class RebindAccept, class Recurse> │ │ │ │ │ +320 void checkRebindOf(Recurse recurse) │ │ │ │ │ +321 { │ │ │ │ │ +322 Hybrid::forEach(Rebinds{}, [this,recurse](auto target) { │ │ │ │ │ +323 using T = typename decltype(target)::type; │ │ │ │ │ +324 │ │ │ │ │ +325 // check that the rebound type exists │ │ │ │ │ +326 using W = Rebind; │ │ │ │ │ +327 log_ << "Type " << className() << " rebound to " │ │ │ │ │ +328 << className() << " is " << className() << std::endl; │ │ │ │ │ +329 │ │ │ │ │ +330 static_assert(std::is_same >::value, "Rebound " │ │ │ │ │ +331 "types must not be references, and must not include " │ │ │ │ │ +332 "cv-qualifiers"); │ │ │ │ │ +333 static_assert(lanes() == lanes(), "Rebound types must have " │ │ │ │ │ +334 "the same number of lanes as the original vector " │ │ │ │ │ +335 "types"); │ │ │ │ │ +336 static_assert(std::is_same >::value, "Rebound types " │ │ │ │ │ +337 "must have the bound-to scalar type"); │ │ │ │ │ +338 │ │ │ │ │ +339 if constexpr (RebindPrune{}) { │ │ │ │ │ +340 log_ << "Pruning check of Simd type " << className() │ │ │ │ │ +341 << std::endl; │ │ │ │ │ +342 } │ │ │ │ │ +343 else { │ │ │ │ │ +344 using Impl::debugTypes; │ │ │ │ │ +345 static_assert(debugTypes(RebindAccept{}), │ │ │ │ │ +346 "Rebind is W, but that is not accepted " │ │ │ │ │ +347 "by RebindAccept"); │ │ │ │ │ +348 recurse(MetaType{}); │ │ │ │ │ +349 } │ │ │ │ │ +350 }); │ │ │ │ │ +351 │ │ │ │ │ +352 static_assert(std::is_same, V>, V>::value, "A type " │ │ │ │ │ +353 "rebound to its own scalar type must be the same type " │ │ │ │ │ +354 "as the original type"); │ │ │ │ │ +355 static_assert(std::is_same, Mask >::value, "A type " │ │ │ │ │ +356 "rebound to bool must be the mask type for that type"); │ │ │ │ │ +357 │ │ │ │ │ +358 constexpr bool hasBool = Impl::TypeInList::value; │ │ │ │ │ +359 warnMissingMaskRebind(Std::bool_constant{}); │ │ │ │ │ +360 } │ │ │ │ │ +361 │ │ │ │ │ +363 // │ │ │ │ │ +364 // Fundamental checks │ │ │ │ │ +365 // │ │ │ │ │ +366 │ │ │ │ │ +367 template │ │ │ │ │ +368 void checkLanes() │ │ │ │ │ +369 { │ │ │ │ │ +370 // check lanes │ │ │ │ │ +371 static_assert(std::is_same())>::value, │ │ │ │ │ +372 "return type of lanes() should be std::size_t"); │ │ │ │ │ +373 static_assert(std::is_same::value, │ │ │ │ │ +374 "return type of lanes(V{}) should be std::size_t"); │ │ │ │ │ +375 │ │ │ │ │ +376 // the result of lanes() must be constexpr │ │ │ │ │ +377 [[maybe_unused]] constexpr auto size = lanes(); │ │ │ │ │ +378 // but the result of lanes(vec) does not need to be constexpr │ │ │ │ │ +379 DUNE_SIMD_CHECK(lanes() == lanes(V{})); │ │ │ │ │ +380 } │ │ │ │ │ +381 │ │ │ │ │ +382 template │ │ │ │ │ +383 void checkDefaultConstruct() │ │ │ │ │ +384 { │ │ │ │ │ +385 { [[maybe_unused]] V vec; } │ │ │ │ │ +386 { [[maybe_unused]] V vec{}; } │ │ │ │ │ +387 { [[maybe_unused]] V vec = {}; } │ │ │ │ │ +388 } │ │ │ │ │ +389 │ │ │ │ │ +390 template │ │ │ │ │ +391 void checkLane() │ │ │ │ │ +392 { │ │ │ │ │ +393 // Avoid using broadcast() for initialization to avoid test │ │ │ │ │ +394 // interdependencies. │ │ │ │ │ +395 V vec(Scalar(0)); │ │ │ │ │ +396 // check lane() on mutable lvalues │ │ │ │ │ +397 for(std::size_t l = 0; l < lanes(vec); ++l) │ │ │ │ │ +398 lane(l, vec) = l + 1; │ │ │ │ │ +399 for(std::size_t l = 0; l < lanes(vec); ++l) │ │ │ │ │ +400 DUNE_SIMD_CHECK(lane(l, vec) == Scalar(l + 1)); │ │ │ │ │ +401 using MLRes = decltype(lane(0, vec)); │ │ │ │ │ +402 static_assert(std::is_same&>::value || │ │ │ │ │ +403 std::is_same >::value, │ │ │ │ │ +404 "Result of lane() on a mutable lvalue vector must " │ │ │ │ │ +405 "either be a mutable reference to a scalar of that " │ │ │ │ │ +406 "vector or a proxy object (which itself may not be a " │ │ │ │ │ +407 "reference nor const)."); │ │ │ │ │ +408 │ │ │ │ │ +409 // check lane() on const lvalues │ │ │ │ │ +410 const V &vec2 = vec; │ │ │ │ │ +411 for(std::size_t l = 0; l < lanes(vec); ++l) │ │ │ │ │ +412 DUNE_SIMD_CHECK(lane(l, vec2) == Scalar(l + 1)); │ │ │ │ │ +413 using CLRes = decltype(lane(0, vec2)); │ │ │ │ │ +414 static_assert(std::is_same&>::value || │ │ │ │ │ +415 std::is_same >::value, │ │ │ │ │ +416 "Result of lane() on a const lvalue vector must " │ │ │ │ │ +417 "either be a const lvalue reference to a scalar of that " │ │ │ │ │ +418 "vector or a proxy object (which itself may not be a " │ │ │ │ │ +419 "reference nor const)."); │ │ │ │ │ +420 static_assert(!std::is_assignable >::value, │ │ │ │ │ +421 "Result of lane() on a const lvalue vector must not be " │ │ │ │ │ +422 "assignable from a scalar."); │ │ │ │ │ +423 │ │ │ │ │ +424 // check lane() on rvalues │ │ │ │ │ +425 for(std::size_t l = 0; l < lanes(vec); ++l) │ │ │ │ │ +426 DUNE_SIMD_CHECK(lane(l, prvalue(vec)) == Scalar(l + 1)); │ │ │ │ │ +427 using RRes = decltype(lane(0, prvalue(vec))); │ │ │ │ │ +428 // TODO: do we really want to allow Scalar&& here? If we allow it, │ │ │ │ │ +429 // then `auto &&res = lane(0, vec*vec);` creates a dangling reference, │ │ │ │ │ +430 // and the scalar (and even the vector types) are small enough to be │ │ │ │ │ +431 // passed in registers anyway. On the other hand, the only comparable │ │ │ │ │ +432 // accessor function in the standard library that I can think of is │ │ │ │ │ +433 // std::get(), and that does return an rvalue reference in this │ │ │ │ │ +434 // situation. However, that cannot assume anything about the size of │ │ │ │ │ +435 // the returned types. │ │ │ │ │ +436 static_assert(std::is_same >::value || │ │ │ │ │ +437 std::is_same&&>::value, │ │ │ │ │ +438 "Result of lane() on a rvalue vector V must be " │ │ │ │ │ +439 "Scalar or Scalar&&."); │ │ │ │ │ +440 // Can't assert non-assignable, fails for any typical class, │ │ │ │ │ +441 // e.g. std::complex<>. Would need to return const Scalar or const │ │ │ │ │ +442 // Scalar&&, which would inhibit moving from the return value. │ │ │ │ │ +443 // static_assert(!std::is_assignable >::value, │ │ │ │ │ +444 // "Result of lane() on a rvalue vector must not be " │ │ │ │ │ +445 // "assignable from a scalar."); │ │ │ │ │ +446 } │ │ │ │ │ +447 │ │ │ │ │ +448 // check non-default constructors │ │ │ │ │ +449 template │ │ │ │ │ +450 void checkCopyMoveConstruct() │ │ │ │ │ +451 { │ │ │ │ │ +452 // elided copy/move constructors │ │ │ │ │ +453 { V vec (make123()); DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ +454 { V vec = make123() ; DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ +455 { V vec {make123()}; DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ +456 { V vec = {make123()}; DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ +457 │ │ │ │ │ +458 // copy constructors │ │ │ │ │ +459 { V ref(make123()); V vec (ref); │ │ │ │ │ +460 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); } │ │ │ │ │ +461 { V ref(make123()); V vec = ref ; │ │ │ │ │ +462 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); } │ │ │ │ │ +463 { V ref(make123()); V vec {ref}; │ │ │ │ │ +464 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); } │ │ │ │ │ +465 { V ref(make123()); V vec = {ref}; │ │ │ │ │ +466 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); } │ │ │ │ │ +467 { const V ref(make123()); V vec (ref); │ │ │ │ │ +468 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ +469 { const V ref(make123()); V vec = ref ; │ │ │ │ │ +470 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ +471 { const V ref(make123()); V vec {ref}; │ │ │ │ │ +472 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ +473 { const V ref(make123()); V vec = {ref}; │ │ │ │ │ +474 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ +475 │ │ │ │ │ +476 // move constructors │ │ │ │ │ +477 { V ref(make123()); V vec (std::move(ref)); │ │ │ │ │ +478 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ +479 { V ref(make123()); V vec = std::move(ref) ; │ │ │ │ │ +480 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ +481 { V ref(make123()); V vec {std::move(ref)}; │ │ │ │ │ +482 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ +483 { V ref(make123()); V vec = {std::move(ref)}; │ │ │ │ │ +484 DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ +485 } │ │ │ │ │ +486 │ │ │ │ │ +487 template │ │ │ │ │ +488 void checkBroadcastVectorConstruct() │ │ │ │ │ +489 { │ │ │ │ │ +490 // broadcast copy constructors │ │ │ │ │ +491 { Scalar ref = 42; V vec (ref); │ │ │ │ │ +492 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ +493 { Scalar ref = 42; V vec = ref ; │ │ │ │ │ +494 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ +495 // { Scalar ref = 42; V vec {ref}; │ │ │ │ │ +496 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ +497 // { Scalar ref = 42; V vec = {ref}; │ │ │ │ │ +498 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ +499 { const Scalar ref = 42; V vec (ref); │ │ │ │ │ +500 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +501 { const Scalar ref = 42; V vec = ref ; │ │ │ │ │ +502 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +503 // { const Scalar ref = 42; V vec {ref}; │ │ │ │ │ +504 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +505 // { const Scalar ref = 42; V vec = {ref}; │ │ │ │ │ +506 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +507 │ │ │ │ │ +508 // broadcast move constructors │ │ │ │ │ +509 { Scalar ref = 42; V vec (std::move(ref)); │ │ │ │ │ +510 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +511 { Scalar ref = 42; V vec = std::move(ref) ; │ │ │ │ │ +512 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +513 // { Scalar ref = 42; V vec {std::move(ref)}; │ │ │ │ │ +514 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +515 // { Scalar ref = 42; V vec = {std::move(ref)}; │ │ │ │ │ +516 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +517 } │ │ │ │ │ +518 │ │ │ │ │ +519 template │ │ │ │ │ +520 void checkBroadcastMaskConstruct() │ │ │ │ │ +521 { │ │ │ │ │ +522 // broadcast copy constructors │ │ │ │ │ +523 { Scalar ref = 42; V vec (ref); │ │ │ │ │ +524 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ +525 // { Scalar ref = 42; V vec = ref ; │ │ │ │ │ +526 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ +527 { Scalar ref = 42; V vec {ref}; │ │ │ │ │ +528 DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ +529 // { Scalar ref = 42; V vec = {ref}; │ │ │ │ │ +530 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ +531 { const Scalar ref = 42; V vec (ref); │ │ │ │ │ +532 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +533 // { const Scalar ref = 42; V vec = ref ; │ │ │ │ │ +534 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +535 { const Scalar ref = 42; V vec {ref}; │ │ │ │ │ +536 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +537 // { const Scalar ref = 42; V vec = {ref}; │ │ │ │ │ +538 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +539 │ │ │ │ │ +540 // broadcast move constructors │ │ │ │ │ +541 { Scalar ref = 42; V vec (std::move(ref)); │ │ │ │ │ +542 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +543 // { Scalar ref = 42; V vec = std::move(ref) ; │ │ │ │ │ +544 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +545 { Scalar ref = 42; V vec {std::move(ref)}; │ │ │ │ │ +546 DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +547 // { Scalar ref = 42; V vec = {std::move(ref)}; │ │ │ │ │ +548 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +549 } │ │ │ │ │ +550 │ │ │ │ │ +551 // check the implCast function │ │ │ │ │ +552 template │ │ │ │ │ +553 void checkImplCast() │ │ │ │ │ +554 { │ │ │ │ │ +555 { // lvalue arg │ │ │ │ │ +556 FromV fromVec = make123(); │ │ │ │ │ +557 auto toVec = implCast(fromVec); │ │ │ │ │ +558 static_assert(std::is_same::value, │ │ │ │ │ +559 "Unexpected result type for implCast(FromV&)"); │ │ │ │ │ +560 DUNE_SIMD_CHECK(is123(fromVec)); │ │ │ │ │ +561 DUNE_SIMD_CHECK(is123(toVec)); │ │ │ │ │ +562 } │ │ │ │ │ +563 │ │ │ │ │ +564 { // const lvalue arg │ │ │ │ │ +565 const FromV fromVec = make123(); │ │ │ │ │ +566 auto toVec = implCast(fromVec); │ │ │ │ │ +567 static_assert(std::is_same::value, │ │ │ │ │ +568 "Unexpected result type for implCast(const " │ │ │ │ │ +569 "FromV&)"); │ │ │ │ │ +570 DUNE_SIMD_CHECK(is123(toVec)); │ │ │ │ │ +571 } │ │ │ │ │ +572 │ │ │ │ │ +573 { // rvalue arg │ │ │ │ │ +574 auto toVec = implCast(make123()); │ │ │ │ │ +575 static_assert(std::is_same::value, │ │ │ │ │ +576 "Unexpected result type for implCast(FromV&&)"); │ │ │ │ │ +577 DUNE_SIMD_CHECK(is123(toVec)); │ │ │ │ │ +578 } │ │ │ │ │ +579 } │ │ │ │ │ +580 │ │ │ │ │ +581 // check the implCast function │ │ │ │ │ +582 template │ │ │ │ │ +583 void checkImplCast() │ │ │ │ │ +584 { │ │ │ │ │ +585 // check against LoopSIMD │ │ │ │ │ +586 using LoopV = Dune::LoopSIMD, lanes()>; │ │ │ │ │ +587 │ │ │ │ │ +588 checkImplCast(); │ │ │ │ │ +589 checkImplCast(); │ │ │ │ │ +590 checkImplCast(); │ │ │ │ │ +591 } │ │ │ │ │ +592 │ │ │ │ │ +593 // check the broadcast function │ │ │ │ │ +594 template │ │ │ │ │ +595 void checkBroadcast() │ │ │ │ │ +596 { │ │ │ │ │ +597 // broadcast function │ │ │ │ │ +598 { // lvalue arg │ │ │ │ │ +599 Scalar ref = 42; │ │ │ │ │ +600 auto vec = broadcast(ref); │ │ │ │ │ +601 static_assert(std::is_same::value, │ │ │ │ │ +602 "Unexpected result type for broadcast()"); │ │ │ │ │ +603 DUNE_SIMD_CHECK(is42(vec)); │ │ │ │ │ +604 DUNE_SIMD_CHECK(ref == Scalar(42)); │ │ │ │ │ +605 } │ │ │ │ │ +606 │ │ │ │ │ +607 { // const lvalue arg │ │ │ │ │ +608 const Scalar ref = 42; │ │ │ │ │ +609 auto vec = broadcast(ref); │ │ │ │ │ +610 static_assert(std::is_same::value, │ │ │ │ │ +611 "Unexpected result type for broadcast()"); │ │ │ │ │ +612 DUNE_SIMD_CHECK(is42(vec)); │ │ │ │ │ +613 } │ │ │ │ │ +614 │ │ │ │ │ +615 { // rvalue arg │ │ │ │ │ +616 auto vec = broadcast(Scalar(42)); │ │ │ │ │ +617 static_assert(std::is_same::value, │ │ │ │ │ +618 "Unexpected result type for broadcast()"); │ │ │ │ │ +619 DUNE_SIMD_CHECK(is42(vec)); │ │ │ │ │ +620 } │ │ │ │ │ +621 │ │ │ │ │ +622 { // int arg │ │ │ │ │ +623 auto vec = broadcast(42); │ │ │ │ │ +624 static_assert(std::is_same::value, │ │ │ │ │ +625 "Unexpected result type for broadcast()"); │ │ │ │ │ +626 DUNE_SIMD_CHECK(is42(vec)); │ │ │ │ │ +627 } │ │ │ │ │ +628 │ │ │ │ │ +629 { // double arg │ │ │ │ │ +630 auto vec = broadcast(42.0); │ │ │ │ │ +631 static_assert(std::is_same::value, │ │ │ │ │ +632 "Unexpected result type for broadcast()"); │ │ │ │ │ +633 DUNE_SIMD_CHECK(is42(vec)); │ │ │ │ │ +634 } │ │ │ │ │ +635 } │ │ │ │ │ +636 │ │ │ │ │ +637 template │ │ │ │ │ +638 void checkBracedAssign() │ │ │ │ │ +639 { │ │ │ │ │ +640 // copy assignment │ │ │ │ │ +641 { V ref = make123(); V vec; vec = {ref}; │ │ │ │ │ +642 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); } │ │ │ │ │ +643 { const V ref = make123(); V vec; vec = {ref}; │ │ │ │ │ +644 DUNE_SIMD_CHECK(is123(vec)); DUNE_SIMD_CHECK(is123(ref)); } │ │ │ │ │ +645 │ │ │ │ │ +646 // move assignment │ │ │ │ │ +647 { V vec; vec = {make123()}; DUNE_SIMD_CHECK(is123(vec)); } │ │ │ │ │ +648 } │ │ │ │ │ +649 │ │ │ │ │ +650 template │ │ │ │ │ +651 void checkBracedBroadcastAssign() │ │ │ │ │ +652 { │ │ │ │ │ +653 // nothing works here │ │ │ │ │ +654 // // broadcast copy assignment │ │ │ │ │ +655 // { Scalar ref = 42; V vec; vec = {ref}; │ │ │ │ │ +656 // DUNE_SIMD_CHECK(is42(vec)); DUNE_SIMD_CHECK(ref == Scalar(42)); } │ │ │ │ │ +657 // { const Scalar ref = 42; V vec; vec = {ref}; │ │ │ │ │ +658 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +659 │ │ │ │ │ +660 // // broadcast move assignment │ │ │ │ │ +661 // { Scalar ref = 42; V vec; vec = {std::move(ref)}; │ │ │ │ │ +662 // DUNE_SIMD_CHECK(is42(vec)); } │ │ │ │ │ +663 } │ │ │ │ │ +664 │ │ │ │ │ +666 // │ │ │ │ │ +667 // checks for unary operators │ │ │ │ │ +668 // │ │ │ │ │ +669 │ │ │ │ │ +670#define DUNE_SIMD_POSTFIX_OP(NAME, SYMBOL) \ │ │ │ │ │ +671 struct OpPostfix##NAME \ │ │ │ │ │ +672 { \ │ │ │ │ │ +673 template \ │ │ │ │ │ +674 auto operator()(V&& v) const \ │ │ │ │ │ +675 -> decltype(std::forward(v) SYMBOL) \ │ │ │ │ │ +676 { \ │ │ │ │ │ +677 return std::forward(v) SYMBOL; \ │ │ │ │ │ +678 } \ │ │ │ │ │ +679 } │ │ │ │ │ +680 │ │ │ │ │ +681#define DUNE_SIMD_PREFIX_OP(NAME, SYMBOL) \ │ │ │ │ │ +682 struct OpPrefix##NAME \ │ │ │ │ │ +683 { \ │ │ │ │ │ +684 template \ │ │ │ │ │ +685 auto operator()(V&& v) const \ │ │ │ │ │ +686 -> decltype(SYMBOL std::forward(v)) \ │ │ │ │ │ +687 { \ │ │ │ │ │ +688 return SYMBOL std::forward(v); \ │ │ │ │ │ +689 } \ │ │ │ │ │ +690 } │ │ │ │ │ +691 │ │ │ │ │ +692 DUNE_SIMD_POSTFIX_OP(Decrement, -- ); │ │ │ │ │ +693 DUNE_SIMD_POSTFIX_OP(Increment, ++ ); │ │ │ │ │ +694 │ │ │ │ │ +695 DUNE_SIMD_PREFIX_OP (Decrement, -- ); │ │ │ │ │ +696 DUNE_SIMD_PREFIX_OP (Increment, ++ ); │ │ │ │ │ +697 │ │ │ │ │ +698 DUNE_SIMD_PREFIX_OP (Plus, + ); │ │ │ │ │ +699 DUNE_SIMD_PREFIX_OP (Minus, - ); │ │ │ │ │ +700 DUNE_SIMD_PREFIX_OP (LogicNot, ! ); │ │ │ │ │ +701 // Do not warn about ~ being applied to bool. (1) Yes, doing that is │ │ │ │ │ +702 // weird, but we do want to test the weird stuff too. (2) It avoids │ │ │ │ │ +703 // running into on │ │ │ │ │ +704 // g++-7.0 through 7.2. Also, ignore -Wpragmas to not warn about an │ │ │ │ │ +705 // unknown -Wbool-operation on compilers that do not know that option. │ │ │ │ │ +706#pragma GCC diagnostic push │ │ │ │ │ +707#pragma GCC diagnostic ignored "-Wpragmas" │ │ │ │ │ +708#pragma GCC diagnostic ignored "-Wunknown-warning-option" // clang 6.0.1 │ │ │ │ │ +709#pragma GCC diagnostic ignored "-Wbool-operation" │ │ │ │ │ +710 DUNE_SIMD_PREFIX_OP (BitNot, ~ ); │ │ │ │ │ +711#pragma GCC diagnostic pop │ │ │ │ │ +712 │ │ │ │ │ +713#undef DUNE_SIMD_POSTFIX_OP │ │ │ │ │ +714#undef DUNE_SIMD_PREFIX_OP │ │ │ │ │ +715 │ │ │ │ │ +716 template │ │ │ │ │ +717 std::enable_if_t< │ │ │ │ │ +718 IsCallable())))>::value> │ │ │ │ │ +719 checkUnaryOpV(Op op) │ │ │ │ │ +720 { │ │ │ │ │ +721#define DUNE_SIMD_OPNAME (className()) │ │ │ │ │ +722 // arguments │ │ │ │ │ +723 auto val = leftVector>(); │ │ │ │ │ +724 │ │ │ │ │ +725 // copy the arguments in case V is a references │ │ │ │ │ +726 auto arg = val; │ │ │ │ │ +727 auto &&result = op(static_cast(arg)); │ │ │ │ │ +728 using T = Scalar >; │ │ │ │ │ +729 for(std::size_t l = 0; l < lanes(val); ++l) │ │ │ │ │ +730 { │ │ │ │ │ +731 // `op` might promote the argument. This is a problem if the │ │ │ │ │ +732 // argument of the operation on the right of the `==` is │ │ │ │ │ +733 // e.g. `(unsigned short)1` and the operation is e.g. unary `-`. │ │ │ │ │ +734 // Then the argument is promoted to `int` before applying the │ │ │ │ │ +735 // negation, and the result is `(int)-1`. However, the left side of │ │ │ │ │ +736 // the `==` is still `(unsigned short)-1`, which typically is the │ │ │ │ │ +737 // same as `(unsigned short)65535`. The `==` promotes the left side │ │ │ │ │ +738 // before comparing, so that becomes `(int)65535`. It will then │ │ │ │ │ +739 // compare `(int)65535` and `(int)-1` and rightly declare them to be │ │ │ │ │ +740 // not equal. │ │ │ │ │ +741 │ │ │ │ │ +742 // To work around this, we explicitly convert the right side of the │ │ │ │ │ +743 // `==` to the scalar type before comparing. │ │ │ │ │ +744 DUNE_SIMD_CHECK_OP │ │ │ │ │ +745 (lane(l, result) │ │ │ │ │ +746 == static_cast(op(lane(l, static_cast(val))))); │ │ │ │ │ +747 } │ │ │ │ │ +748 // op might modify val, verify that any such modification also happens │ │ │ │ │ +749 // in the vector case │ │ │ │ │ +750 for(std::size_t l = 0; l < lanes >(); ++l) │ │ │ │ │ +751 DUNE_SIMD_CHECK_OP(lane(l, val) == lane(l, arg)); │ │ │ │ │ +752#undef DUNE_SIMD_OPNAME │ │ │ │ │ +753 } │ │ │ │ │ +754 │ │ │ │ │ +755 template │ │ │ │ │ +756 std::enable_if_t< │ │ │ │ │ +757 not IsCallable())))>::value> │ │ │ │ │ +758 checkUnaryOpV(Op op) │ │ │ │ │ +759 { │ │ │ │ │ +760 // log_ << "No " << className())))>() │ │ │ │ │ +761 // << std::endl │ │ │ │ │ +762 // << " ==> Not checking " << className() << std::endl; │ │ │ │ │ +763 } │ │ │ │ │ +764 │ │ │ │ │ +765 template │ │ │ │ │ +766 void checkUnaryOpsV(Op op) │ │ │ │ │ +767 { │ │ │ │ │ +768 checkUnaryOpV(op); │ │ │ │ │ +769 checkUnaryOpV(op); │ │ │ │ │ +770 checkUnaryOpV(op); │ │ │ │ │ +771 } │ │ │ │ │ +772 │ │ │ │ │ +774 // │ │ │ │ │ +775 // checks for binary operators │ │ │ │ │ +776 // │ │ │ │ │ +777 │ │ │ │ │ +778 // The operators contain an `operator()`, which will be invoked for both │ │ │ │ │ +779 // scalar and vector arguments. The function `scalar()` is used the │ │ │ │ │ +780 // test whether the scalar types support the operation (via │ │ │ │ │ +781 // `ScalarResult`). The difference is that `scalar()` should only ever │ │ │ │ │ +782 // receive `const`-ref-qualified version of `Scalar`, while the │ │ │ │ │ +783 // `operator()` may also be called with proxies representing scalars. │ │ │ │ │ +784#define DUNE_SIMD_INFIX_OP(NAME, SYMBOL) \ │ │ │ │ │ +785 struct OpInfix##NAME \ │ │ │ │ │ +786 { \ │ │ │ │ │ +787 template \ │ │ │ │ │ +788 decltype(auto) operator()(V1&& v1, V2&& v2) const \ │ │ │ │ │ +789 { \ │ │ │ │ │ +790 return std::forward(v1) SYMBOL std::forward(v2); \ │ │ │ │ │ +791 } \ │ │ │ │ │ +792 template \ │ │ │ │ │ +793 auto scalar(S1&& s1, S2&& s2) const \ │ │ │ │ │ +794 -> decltype(std::forward(s1) SYMBOL std::forward(s2)); \ │ │ │ │ │ +795 } │ │ │ │ │ +796 │ │ │ │ │ +797 // for assign ops, accept only non-const lvalue arguments for scalars. │ │ │ │ │ +798 // This is needed for class scalars (e.g. std::complex) because │ │ │ │ │ +799 // non-const class rvalues are actually usually assignable. Though that │ │ │ │ │ +800 // assignment happens to a temporary, and thus is lost. Except that the │ │ │ │ │ +801 // tests would bind the result of the assignment to a reference. And │ │ │ │ │ +802 // because that result is returned from a function by reference, even │ │ │ │ │ +803 // though it is a temporary passed as an argument to that function, │ │ │ │ │ +804 // accessing the result later is undefined behaviour. │ │ │ │ │ +805#define DUNE_SIMD_ASSIGN_OP(NAME, SYMBOL) \ │ │ │ │ │ +806 struct OpInfix##NAME \ │ │ │ │ │ +807 { \ │ │ │ │ │ +808 template \ │ │ │ │ │ +809 decltype(auto) operator()(V1&& v1, V2&& v2) const \ │ │ │ │ │ +810 { \ │ │ │ │ │ +811 return std::forward(v1) SYMBOL std::forward(v2); \ │ │ │ │ │ +812 } \ │ │ │ │ │ +813 template \ │ │ │ │ │ +814 auto scalar(S1& s1, S2&& s2) const \ │ │ │ │ │ +815 -> decltype(s1 SYMBOL std::forward(s2)); \ │ │ │ │ │ +816 } │ │ │ │ │ +817 │ │ │ │ │ +818#define DUNE_SIMD_REPL_OP(NAME, REPLFN, SYMBOL) \ │ │ │ │ │ +819 struct OpInfix##NAME \ │ │ │ │ │ +820 { \ │ │ │ │ │ +821 template \ │ │ │ │ │ +822 decltype(auto) operator()(V1&& v1, V2&& v2) const \ │ │ │ │ │ +823 { \ │ │ │ │ │ +824 return Simd::REPLFN(std::forward(v1), std::forward(v2)); \ │ │ │ │ │ +825 } \ │ │ │ │ │ +826 template \ │ │ │ │ │ +827 auto scalar(S1&& s1, S2&& s2) const \ │ │ │ │ │ +828 -> decltype(std::forward(s1) SYMBOL std::forward(s2)); \ │ │ │ │ │ +829 } │ │ │ │ │ +830 │ │ │ │ │ +831 DUNE_SIMD_INFIX_OP(Mul, * ); │ │ │ │ │ +832 DUNE_SIMD_INFIX_OP(Div, / ); │ │ │ │ │ +833 DUNE_SIMD_INFIX_OP(Remainder, % ); │ │ │ │ │ +834 │ │ │ │ │ +835 DUNE_SIMD_INFIX_OP(Plus, + ); │ │ │ │ │ +836 DUNE_SIMD_INFIX_OP(Minus, - ); │ │ │ │ │ +837 │ │ │ │ │ +838 DUNE_SIMD_INFIX_OP(LeftShift, << ); │ │ │ │ │ +839 DUNE_SIMD_INFIX_OP(RightShift, >> ); │ │ │ │ │ +840 │ │ │ │ │ +841 DUNE_SIMD_INFIX_OP(Less, < ); │ │ │ │ │ +842 DUNE_SIMD_INFIX_OP(Greater, > ); │ │ │ │ │ +843 DUNE_SIMD_INFIX_OP(LessEqual, <= ); │ │ │ │ │ +844 DUNE_SIMD_INFIX_OP(GreaterEqual, >= ); │ │ │ │ │ +845 │ │ │ │ │ +846 DUNE_SIMD_INFIX_OP(Equal, == ); │ │ │ │ │ +847 DUNE_SIMD_INFIX_OP(NotEqual, != ); │ │ │ │ │ +848 │ │ │ │ │ +849 DUNE_SIMD_INFIX_OP(BitAnd, & ); │ │ │ │ │ +850 DUNE_SIMD_INFIX_OP(BitXor, ^ ); │ │ │ │ │ +851 DUNE_SIMD_INFIX_OP(BitOr, | ); │ │ │ │ │ +852 │ │ │ │ │ +853 // Those are not supported in any meaningful way by vectorclass │ │ │ │ │ +854 // We need to test replacement functions maskAnd() and maskOr() instead. │ │ │ │ │ +855 DUNE_SIMD_REPL_OP(LogicAnd, maskAnd, && ); │ │ │ │ │ +856 DUNE_SIMD_REPL_OP(LogicOr, maskOr, || ); │ │ │ │ │ +857 │ │ │ │ │ +858 DUNE_SIMD_ASSIGN_OP(Assign, = ); │ │ │ │ │ +859 DUNE_SIMD_ASSIGN_OP(AssignMul, *= ); │ │ │ │ │ +860 DUNE_SIMD_ASSIGN_OP(AssignDiv, /= ); │ │ │ │ │ +861 DUNE_SIMD_ASSIGN_OP(AssignRemainder, %= ); │ │ │ │ │ +862 DUNE_SIMD_ASSIGN_OP(AssignPlus, += ); │ │ │ │ │ +863 DUNE_SIMD_ASSIGN_OP(AssignMinus, -= ); │ │ │ │ │ +864 DUNE_SIMD_ASSIGN_OP(AssignLeftShift, <<=); │ │ │ │ │ +865 DUNE_SIMD_ASSIGN_OP(AssignRightShift, >>=); │ │ │ │ │ +866 DUNE_SIMD_ASSIGN_OP(AssignAnd, &= ); │ │ │ │ │ +867 DUNE_SIMD_ASSIGN_OP(AssignXor, ^= ); │ │ │ │ │ +868 DUNE_SIMD_ASSIGN_OP(AssignOr, |= ); │ │ │ │ │ +869 │ │ │ │ │ +870#undef DUNE_SIMD_INFIX_OP │ │ │ │ │ +871#undef DUNE_SIMD_REPL_OP │ │ │ │ │ +872#undef DUNE_SIMD_ASSIGN_OP │ │ │ │ │ +873 │ │ │ │ │ +874 // just used as a tag │ │ │ │ │ +875 struct OpInfixComma {}; │ │ │ │ │ +876 │ │ │ │ │ +877 template │ │ │ │ │ +878 void checkCommaOp(const std::decay_t &val1, │ │ │ │ │ +879 const std::decay_t &val2) │ │ │ │ │ +880 { │ │ │ │ │ +881#define DUNE_SIMD_OPNAME (className()) │ │ │ │ │ +882 static_assert(std::is_same(), │ │ │ │ │ +883 std::declval())), T2>::value, │ │ │ │ │ +884 "Type and value category of the comma operator must " │ │ │ │ │ +885 "match that of the second operand"); │ │ │ │ │ +886 │ │ │ │ │ +887 // copy the arguments in case T1 or T2 are references │ │ │ │ │ +888 auto arg1 = val1; │ │ │ │ │ +889 auto arg2 = val2; │ │ │ │ │ +890 // Do not warn that the left side of the comma operator is unused. │ │ │ │ │ +891 // Seems to work for g++-4.9 and clang++-3.8. Appears to be harmless │ │ │ │ │ +892 // for icpc (14 and 17), and icpc does not seem to issue a warning │ │ │ │ │ +893 // anyway. │ │ │ │ │ +894#pragma GCC diagnostic push │ │ │ │ │ +895#pragma GCC diagnostic ignored "-Wunused-value" │ │ │ │ │ +896 auto &&result = (static_cast(arg1), │ │ │ │ │ +897 static_cast(arg2)); │ │ │ │ │ +898#pragma GCC diagnostic pop │ │ │ │ │ +899 if(std::is_reference::value) │ │ │ │ │ +900 { │ │ │ │ │ +901 // comma should return the same object as the second argument for │ │ │ │ │ +902 // lvalues and xvalues │ │ │ │ │ +903 DUNE_SIMD_CHECK_OP(&result == &arg2); │ │ │ │ │ +904 // it should not modify any arguments │ │ │ │ │ +905 DUNE_SIMD_CHECK_OP(allTrue(val1 == arg1)); │ │ │ │ │ +906 DUNE_SIMD_CHECK_OP(allTrue(val2 == arg2)); │ │ │ │ │ +907 } │ │ │ │ │ +908 else │ │ │ │ │ +909 { │ │ │ │ │ +910 // comma should return the same value as the second argument for │ │ │ │ │ +911 // prvalues │ │ │ │ │ +912 DUNE_SIMD_CHECK_OP(allTrue(result == arg2)); │ │ │ │ │ +913 // it should not modify any arguments │ │ │ │ │ +914 DUNE_SIMD_CHECK_OP(allTrue(val1 == arg1)); │ │ │ │ │ +915 // second argument is a prvalue, any modifications happen to a │ │ │ │ │ +916 // temporary and we can't detect them │ │ │ │ │ +917 } │ │ │ │ │ +918#undef DUNE_SIMD_OPNAME │ │ │ │ │ +919 } │ │ │ │ │ +920 │ │ │ │ │ +922 // │ │ │ │ │ +923 // checks for vector-vector binary operations │ │ │ │ │ +924 // │ │ │ │ │ +925 │ │ │ │ │ +926 // We check the following candidate operation │ │ │ │ │ +927 // │ │ │ │ │ +928 // vopres = vop1 @ vop2 │ │ │ │ │ +929 // │ │ │ │ │ +930 // against the reference operation │ │ │ │ │ +931 // │ │ │ │ │ +932 // arefres[l] = aref1[l] @ aref2[l] foreach l │ │ │ │ │ +933 // │ │ │ │ │ +934 // v... variables are simd-vectors and a... variables are arrays. The │ │ │ │ │ +935 // operation may modify the operands, but if is does the modification │ │ │ │ │ +936 // needs to happen in both the candidate and the reference. │ │ │ │ │ +937 // │ │ │ │ │ +938 // We do the following checks: │ │ │ │ │ +939 // 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ +940 // 2. lane(l, vopres) == arefres[l] foreach l │ │ │ │ │ +941 // 3. lane(l, vop1) == aref1[l] foreach l │ │ │ │ │ +942 // 4. lane(l, vop2) == aref2[l] foreach l │ │ │ │ │ +943 template │ │ │ │ │ +944 std::enable_if_t > │ │ │ │ │ +945 checkBinaryOpVV(MetaType, MetaType, Op op) │ │ │ │ │ +946 { │ │ │ │ │ +947#define DUNE_SIMD_OPNAME (className()) │ │ │ │ │ +948 static_assert(std::is_same, std::decay_t >::value, │ │ │ │ │ +949 "Internal testsystem error: called with two types that " │ │ │ │ │ +950 "don't decay to the same thing"); │ │ │ │ │ +951 │ │ │ │ │ +952 // reference arguments │ │ │ │ │ +953 auto vref1 = leftVector>(); │ │ │ │ │ +954 auto vref2 = rightVector>(); │ │ │ │ │ +955 │ │ │ │ │ +956 // candidate arguments │ │ │ │ │ +957 auto vop1 = vref1; │ │ │ │ │ +958 auto vop2 = vref2; │ │ │ │ │ +959 │ │ │ │ │ +960 // candidate operation │ │ │ │ │ +961 auto &&vopres = op(static_cast(vop1), static_cast(vop2)); │ │ │ │ │ +962 using VR = decltype(vopres); │ │ │ │ │ +963 │ │ │ │ │ +964 // check 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ +965 static_assert(lanes >() == lanes >(), │ │ │ │ │ +966 "The result must have the same number of lanes as the " │ │ │ │ │ +967 "operands."); │ │ │ │ │ +968 │ │ │ │ │ +969 // do the reference operation, and simultaneously │ │ │ │ │ +970 // check 2. lane(l, vopres) == arefres[l] foreach l │ │ │ │ │ +971 using T = Scalar >; │ │ │ │ │ +972 for(auto l : range(lanes(vopres))) │ │ │ │ │ +973 { │ │ │ │ │ +974 // see the lengthy comment in `checkUnaryOpV()` as to why the │ │ │ │ │ +975 // `static_cast` around the `op()` is necessary │ │ │ │ │ +976 DUNE_SIMD_CHECK_OP │ │ │ │ │ +977 (lane(l, vopres) │ │ │ │ │ +978 == static_cast(op(lane(l, static_cast(vref1)), │ │ │ │ │ +979 lane(l, static_cast(vref2))))); │ │ │ │ │ +980 } │ │ │ │ │ +981 │ │ │ │ │ +982 // check 3. lane(l, vop1) == aref1[l] foreach l │ │ │ │ │ +983 for(auto l : range(lanes(vop1))) │ │ │ │ │ +984 DUNE_SIMD_CHECK_OP(lane(l, vop1) == lane(l, vref1)); │ │ │ │ │ +985 │ │ │ │ │ +986 // check 4. lane(l, vop2) == aref2[l] foreach l │ │ │ │ │ +987 for(auto l : range(lanes(vop2))) │ │ │ │ │ +988 DUNE_SIMD_CHECK_OP(lane(l, vop2) == lane(l, vref2)); │ │ │ │ │ +989 │ │ │ │ │ +990#undef DUNE_SIMD_OPNAME │ │ │ │ │ +991 } │ │ │ │ │ +992 │ │ │ │ │ +993 template │ │ │ │ │ +994 std::enable_if_t > │ │ │ │ │ +995 checkBinaryOpVV(MetaType, MetaType, Op op) │ │ │ │ │ +996 { │ │ │ │ │ +997 // log_ << "No " << className())), │ │ │ │ │ +998 // decltype(lane(0, std::declval())))>() │ │ │ │ │ +999 // << std::endl │ │ │ │ │ +1000 // << " ==> Not checking " << className() << std::endl; │ │ │ │ │ +1001 } │ │ │ │ │ +1002 │ │ │ │ │ +1003 template │ │ │ │ │ +1004 void checkBinaryOpVV(MetaType, MetaType, OpInfixComma) │ │ │ │ │ +1005 { │ │ │ │ │ +1006 static_assert(std::is_same, std::decay_t >::value, │ │ │ │ │ +1007 "Internal testsystem error: called with two types that " │ │ │ │ │ +1008 "don't decay to the same thing"); │ │ │ │ │ +1009 │ │ │ │ │ +1010 checkCommaOp(leftVector>(), │ │ │ │ │ +1011 rightVector>()); │ │ │ │ │ +1012 } │ │ │ │ │ +1013 │ │ │ │ │ +1015 // │ │ │ │ │ +1016 // checks for vector-scalar binary operations │ │ │ │ │ +1017 // │ │ │ │ │ +1018 │ │ │ │ │ +1019 // We check the following candidate operation │ │ │ │ │ +1020 // │ │ │ │ │ +1021 // vopres = vop1 @ sop2 │ │ │ │ │ +1022 // │ │ │ │ │ +1023 // against the reference operation │ │ │ │ │ +1024 // │ │ │ │ │ +1025 // arefres[l] = aref1[l] @ sref2 foreach l │ │ │ │ │ +1026 // │ │ │ │ │ +1027 // v... variables are simd-vectors, a... variables are arrays, and │ │ │ │ │ +1028 // s... variables are scalars. The operation may modify the left │ │ │ │ │ +1029 // operand, but if is does the modifications needs to happen in both the │ │ │ │ │ +1030 // candidate and the reference. │ │ │ │ │ +1031 // │ │ │ │ │ +1032 // We do the following checks: │ │ │ │ │ +1033 // 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ +1034 // 2. lane(l, vopres) == arefres[l] foreach l │ │ │ │ │ +1035 // 3. lane(l, vop1) == aref1[l] foreach l │ │ │ │ │ +1036 // 4. sop2 is never modified │ │ │ │ │ +1037 // 5. sref2 is never modified │ │ │ │ │ +1038 // │ │ │ │ │ +1039 // In fact, if the property "sref2 is never modified" is violated that │ │ │ │ │ +1040 // means the operation is unsuitable for an automatic broadcast of the │ │ │ │ │ +1041 // second operand and should not be checked. There are no operations in │ │ │ │ │ +1042 // the standard where the second operand is modified like this, but │ │ │ │ │ +1043 // there are operations where the first operand is modified -- and this │ │ │ │ │ +1044 // check is used for those ops as well by exchanging the first and second │ │ │ │ │ +1045 // argument below. │ │ │ │ │ +1046 │ │ │ │ │ +1047 template │ │ │ │ │ +1048 std::enable_if_t > │ │ │ │ │ +1049 checkBinaryOpVS(MetaType, MetaType, Op op) │ │ │ │ │ +1050 { │ │ │ │ │ +1051#define DUNE_SIMD_OPNAME (className()) │ │ │ │ │ +1052 static_assert(std::is_same >, │ │ │ │ │ +1053 std::decay_t >::value, │ │ │ │ │ +1054 "Internal testsystem error: called with a scalar that " │ │ │ │ │ +1055 "does not match the vector type."); │ │ │ │ │ +1056 │ │ │ │ │ +1057 // initial values │ │ │ │ │ +1058 auto sinit2 = rightScalar>(); │ │ │ │ │ +1059 │ │ │ │ │ +1060 // reference arguments │ │ │ │ │ +1061 auto vref1 = leftVector>(); │ │ │ │ │ +1062 auto sref2 = sinit2; │ │ │ │ │ +1063 │ │ │ │ │ +1064 // candidate arguments │ │ │ │ │ +1065 auto vop1 = vref1; │ │ │ │ │ +1066 auto sop2 = sref2; │ │ │ │ │ +1067 │ │ │ │ │ +1068 // candidate operation │ │ │ │ │ +1069 auto &&vopres = op(static_cast(vop1), static_cast(sop2)); │ │ │ │ │ +1070 using VR = decltype(vopres); │ │ │ │ │ +1071 │ │ │ │ │ +1072 // check 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ +1073 static_assert(lanes >() == lanes >(), │ │ │ │ │ +1074 "The result must have the same number of lanes as the " │ │ │ │ │ +1075 "operands."); │ │ │ │ │ +1076 │ │ │ │ │ +1077 // check 4. sop2 is never modified │ │ │ │ │ +1078 DUNE_SIMD_CHECK_OP(sop2 == sinit2); │ │ │ │ │ +1079 │ │ │ │ │ +1080 // do the reference operation, and simultaneously check 2. and 5. │ │ │ │ │ +1081 using T = Scalar >; │ │ │ │ │ +1082 for(auto l : range(lanes(vopres))) │ │ │ │ │ +1083 { │ │ │ │ │ +1084 // check 2. lane(l, vopres) == arefres[l] foreach l │ │ │ │ │ +1085 // see the lengthy comment in `checkUnaryOpV()` as to why the │ │ │ │ │ +1086 // `static_cast` around the `op()` is necessary │ │ │ │ │ +1087 DUNE_SIMD_CHECK_OP │ │ │ │ │ +1088 (lane(l, vopres) │ │ │ │ │ +1089 == static_cast(op(lane(l, static_cast(vref1)), │ │ │ │ │ +1090 static_cast(sref2) ))); │ │ │ │ │ +1091 // check 5. sref2 is never modified │ │ │ │ │ +1092 DUNE_SIMD_CHECK_OP(sref2 == sinit2); │ │ │ │ │ +1093 } │ │ │ │ │ +1094 │ │ │ │ │ +1095 // check 3. lane(l, vop1) == aref1[l] foreach l │ │ │ │ │ +1096 for(auto l : range(lanes(vop1))) │ │ │ │ │ +1097 DUNE_SIMD_CHECK_OP(lane(l, vop1) == lane(l, vref1)); │ │ │ │ │ +1098 │ │ │ │ │ +1099#undef DUNE_SIMD_OPNAME │ │ │ │ │ +1100 } │ │ │ │ │ +1101 │ │ │ │ │ +1102 template │ │ │ │ │ +1103 std::enable_if_t > │ │ │ │ │ +1104 checkBinaryOpVS(MetaType, MetaType, Op op) │ │ │ │ │ +1105 { │ │ │ │ │ +1106 // log_ << "No " │ │ │ │ │ +1107 // << className())), T2)>() │ │ │ │ │ +1108 // << std::endl │ │ │ │ │ +1109 // << " ==> Not checking " << className() << std::endl; │ │ │ │ │ +1110 } │ │ │ │ │ +1111 │ │ │ │ │ +1112 template │ │ │ │ │ +1113 void checkBinaryOpVS(MetaType, MetaType, OpInfixComma) │ │ │ │ │ +1114 { │ │ │ │ │ +1115 static_assert(std::is_same >, │ │ │ │ │ +1116 std::decay_t >::value, │ │ │ │ │ +1117 "Internal testsystem error: called with a scalar that " │ │ │ │ │ +1118 "does not match the vector type."); │ │ │ │ │ +1119 │ │ │ │ │ +1120 checkCommaOp(leftVector>(), │ │ │ │ │ +1121 rightScalar>()); │ │ │ │ │ +1122 } │ │ │ │ │ +1123 │ │ │ │ │ +1125 // │ │ │ │ │ +1126 // cross-check scalar-vector binary operations against vector-vector │ │ │ │ │ +1127 // │ │ │ │ │ +1128 │ │ │ │ │ +1129 // We check the following candidate operation │ │ │ │ │ +1130 // │ │ │ │ │ +1131 // vopres = vop1 @ vop2, where vop2 = broadcast(sref2) │ │ │ │ │ +1132 // │ │ │ │ │ +1133 // against the reference operation │ │ │ │ │ +1134 // │ │ │ │ │ +1135 // vrefres = vref1 @ sref2 │ │ │ │ │ +1136 // │ │ │ │ │ +1137 // v... variables are simd-vectors, a... variables are arrays, and │ │ │ │ │ +1138 // s... variables are scalars. │ │ │ │ │ +1139 // │ │ │ │ │ +1140 // We could check the following properties │ │ │ │ │ +1141 // 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ +1142 // 2. lane(l, vopres) == lane(l, vrefres) foreach l │ │ │ │ │ +1143 // 3. lane(l, vop1) == lane(l, vref1) foreach l │ │ │ │ │ +1144 // but these are given by checking the operation against the scalar │ │ │ │ │ +1145 // operation in the vector@vector and vector@scalar cases above. │ │ │ │ │ +1146 // │ │ │ │ │ +1147 // The only thing left to check is: │ │ │ │ │ +1148 // 4. lane(l, vop2) foreach l is never modified │ │ │ │ │ +1149 │ │ │ │ │ +1150 template │ │ │ │ │ +1151 std::enable_if_t > │ │ │ │ │ +1152 checkBinaryOpVVAgainstVS(MetaType, MetaType, Op op) │ │ │ │ │ +1153 { │ │ │ │ │ +1154#define DUNE_SIMD_OPNAME (className()) │ │ │ │ │ +1155 static_assert(std::is_same >, │ │ │ │ │ +1156 std::decay_t >::value, │ │ │ │ │ +1157 "Internal testsystem error: called with a scalar that " │ │ │ │ │ +1158 "does not match the vector type."); │ │ │ │ │ +1159 │ │ │ │ │ +1160 // initial values │ │ │ │ │ +1161 auto sinit2 = rightScalar>(); │ │ │ │ │ +1162 │ │ │ │ │ +1163 // reference arguments │ │ │ │ │ +1164 auto vop1 = leftVector>(); │ │ │ │ │ +1165 using V2 = CopyRefQual; │ │ │ │ │ +1166 std::decay_t vop2(sinit2); │ │ │ │ │ +1167 │ │ │ │ │ +1168 // candidate operation │ │ │ │ │ +1169 op(static_cast(vop1), static_cast(vop2)); │ │ │ │ │ +1170 │ │ │ │ │ +1171 // 4. lane(l, vop2) foreach l is never modified │ │ │ │ │ +1172 for(auto l : range(lanes(vop2))) │ │ │ │ │ +1173 DUNE_SIMD_CHECK_OP(lane(l, vop2) == sinit2); │ │ │ │ │ +1174 │ │ │ │ │ +1175#undef DUNE_SIMD_OPNAME │ │ │ │ │ +1176 } │ │ │ │ │ +1177 │ │ │ │ │ +1178 template │ │ │ │ │ +1179 std::enable_if_t > │ │ │ │ │ +1180 checkBinaryOpVVAgainstVS(MetaType, MetaType, Op op) │ │ │ │ │ +1181 { │ │ │ │ │ +1182 // log_ << "No " │ │ │ │ │ +1183 // << className())), T2)>() │ │ │ │ │ +1184 // << std::endl │ │ │ │ │ +1185 // << " ==> Not checking " << className() << std::endl; │ │ │ │ │ +1186 } │ │ │ │ │ +1187 │ │ │ │ │ +1188 template │ │ │ │ │ +1189 void checkBinaryOpVVAgainstVS(MetaType, MetaType, OpInfixComma) │ │ │ │ │ +1190 { } │ │ │ │ │ +1191 │ │ │ │ │ +1193 // │ │ │ │ │ +1194 // checks for vector-proxy binary operations │ │ │ │ │ +1195 // │ │ │ │ │ +1196 │ │ │ │ │ +1197 // We check the following candidate operation │ │ │ │ │ +1198 // │ │ │ │ │ +1199 // vopres = vop1 @ pop2 │ │ │ │ │ +1200 // │ │ │ │ │ +1201 // against the reference operation │ │ │ │ │ +1202 // │ │ │ │ │ +1203 // arefres[l] = aref1[l] @ sref2 foreach l │ │ │ │ │ +1204 // │ │ │ │ │ +1205 // v... variables are simd-vectors, a... variables are arrays, │ │ │ │ │ +1206 // p... variables are proxies of simd-vector entries and s... variables │ │ │ │ │ +1207 // are scalars. The operation may modify the left operand, but if is │ │ │ │ │ +1208 // does the modifications needs to happen in both the candidate and the │ │ │ │ │ +1209 // reference. │ │ │ │ │ +1210 // │ │ │ │ │ +1211 // We do the following checks: │ │ │ │ │ +1212 // 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ +1213 // 2. lane(l, vopres) == arefres[l] foreach l │ │ │ │ │ +1214 // 3. lane(l, vop1) == aref1[l] foreach l │ │ │ │ │ +1215 // 4. pop2 is never modified │ │ │ │ │ +1216 // 5. sref2 is never modified │ │ │ │ │ +1217 // │ │ │ │ │ +1218 // In fact, if the property "sref2 is never modified" is violated that │ │ │ │ │ +1219 // means the operation is unsuitable for an automatic broadcast of the │ │ │ │ │ +1220 // second operand and should not be checked. There are no operations in │ │ │ │ │ +1221 // the standard where the second operand is modified like this, but │ │ │ │ │ +1222 // there are operations where the first operand is modified -- and this │ │ │ │ │ +1223 // check is used for those ops as well by exchanging the first and second │ │ │ │ │ +1224 // argument below. │ │ │ │ │ +1225 │ │ │ │ │ +1226 template │ │ │ │ │ +1227 std::enable_if_t > │ │ │ │ │ +1228 checkBinaryOpVP(MetaType, MetaType, Op op) │ │ │ │ │ +1229 { │ │ │ │ │ +1230 using P2 = decltype(lane(0, std::declval())); │ │ │ │ │ +1231 using T2 = CopyRefQual, V2>; │ │ │ │ │ +1232#define DUNE_SIMD_OPNAME (className()) │ │ │ │ │ +1233 static_assert(std::is_same, Scalar >::value, │ │ │ │ │ +1234 "Internal testsystem error: called with two vector " │ │ │ │ │ +1235 "types whose scalar types don't match."); │ │ │ │ │ +1236 │ │ │ │ │ +1237 // initial values │ │ │ │ │ +1238 auto sinit2 = rightScalar>(); │ │ │ │ │ +1239 │ │ │ │ │ +1240 // reference arguments │ │ │ │ │ +1241 auto vref1 = leftVector>(); │ │ │ │ │ +1242 auto sref2 = sinit2; │ │ │ │ │ +1243 │ │ │ │ │ +1244 // candidate arguments │ │ │ │ │ +1245 auto vop1 = vref1; │ │ │ │ │ +1246 auto vop2 = std::decay_t(Scalar(0)); │ │ │ │ │ +1247 lane(0, vop2) = sref2; // pop2 is just a name for `lane(0, vop2)` │ │ │ │ │ +1248 │ │ │ │ │ +1249 // candidate operation │ │ │ │ │ +1250 auto &&vopres = │ │ │ │ │ +1251 op(static_cast(vop1), lane(0, static_cast(vop2))); │ │ │ │ │ +1252 using VR = decltype(vopres); │ │ │ │ │ +1253 │ │ │ │ │ +1254 // check 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ +1255 static_assert(lanes >() == lanes >(), │ │ │ │ │ +1256 "The result must have the same number of lanes as the " │ │ │ │ │ +1257 "operands."); │ │ │ │ │ +1258 │ │ │ │ │ +1259 // check 4. pop2 is never modified │ │ │ │ │ +1260 DUNE_SIMD_CHECK_OP(lane(0, vop2) == sinit2); │ │ │ │ │ +1261 │ │ │ │ │ +1262 // do the reference operation, and simultaneously check 2. and 5. │ │ │ │ │ +1263 using T = Scalar; │ │ │ │ │ +1264 for(auto l : range(lanes(vopres))) │ │ │ │ │ +1265 { │ │ │ │ │ +1266 // check 2. lane(l, vopres) == arefres[l] foreach l │ │ │ │ │ +1267 // see the lengthy comment in `checkUnaryOpV()` as to why the │ │ │ │ │ +1268 // `static_cast` around the `op()` is necessary │ │ │ │ │ +1269 DUNE_SIMD_CHECK_OP │ │ │ │ │ +1270 (lane(l, vopres) │ │ │ │ │ +1271 == static_cast(op(lane(l, static_cast(vref1)), │ │ │ │ │ +1272 static_cast(sref2) ))); │ │ │ │ │ +1273 // check 5. sref2 is never modified │ │ │ │ │ +1274 DUNE_SIMD_CHECK_OP(sref2 == sinit2); │ │ │ │ │ +1275 } │ │ │ │ │ +1276 │ │ │ │ │ +1277 // check 3. lane(l, vop1) == aref1[l] foreach l │ │ │ │ │ +1278 for(auto l : range(lanes(vop1))) │ │ │ │ │ +1279 DUNE_SIMD_CHECK_OP(lane(l, vop1) == lane(l, vref1)); │ │ │ │ │ +1280 │ │ │ │ │ +1281#undef DUNE_SIMD_OPNAME │ │ │ │ │ +1282 } │ │ │ │ │ +1283 │ │ │ │ │ +1284 template │ │ │ │ │ +1285 std::enable_if_t > │ │ │ │ │ +1286 checkBinaryOpVP(MetaType, MetaType, Op op) │ │ │ │ │ +1287 { │ │ │ │ │ +1288 // log_ << "No " │ │ │ │ │ +1289 // << className())), T2)>() │ │ │ │ │ +1290 // << std::endl │ │ │ │ │ +1291 // << " ==> Not checking " << className() << std::endl; │ │ │ │ │ +1292 } │ │ │ │ │ +1293 │ │ │ │ │ +1294 template │ │ │ │ │ +1295 void checkBinaryOpVP(MetaType, MetaType, OpInfixComma) │ │ │ │ │ +1296 { │ │ │ │ │ +1297 // Don't really know how to check comma operator for proxies │ │ │ │ │ +1298 } │ │ │ │ │ +1299 │ │ │ │ │ +1301 // │ │ │ │ │ +1302 // checks for (scalar/proxy)-vector binary operations │ │ │ │ │ +1303 // │ │ │ │ │ +1304 │ │ │ │ │ +1305 template │ │ │ │ │ +1306 struct OpInfixSwappedArgs │ │ │ │ │ +1307 { │ │ │ │ │ +1308 Op orig; │ │ │ │ │ +1309 │ │ │ │ │ +1310 template │ │ │ │ │ +1311 decltype(auto) operator()(V1&& v1, V2&& v2) const │ │ │ │ │ +1312 { │ │ │ │ │ +1313 return orig(std::forward(v2), std::forward(v1)); │ │ │ │ │ +1314 } │ │ │ │ │ +1315 template │ │ │ │ │ +1316 auto scalar(S1&& s1, S2&& s2) const │ │ │ │ │ +1317 -> decltype(orig.scalar(std::forward(s2), std::forward(s1))); │ │ │ │ │ +1318 }; │ │ │ │ │ +1319 │ │ │ │ │ +1320 template │ │ │ │ │ +1321 void checkBinaryOpSV(MetaType t1, MetaType v2, Op op) │ │ │ │ │ +1322 { │ │ │ │ │ +1323 checkBinaryOpVS(v2, t1, OpInfixSwappedArgs{op}); │ │ │ │ │ +1324 } │ │ │ │ │ +1325 │ │ │ │ │ +1326 template │ │ │ │ │ +1327 void checkBinaryOpSV(MetaType, MetaType, OpInfixComma) │ │ │ │ │ +1328 { │ │ │ │ │ +1329 static_assert(std::is_same, │ │ │ │ │ +1330 Scalar > >::value, │ │ │ │ │ +1331 "Internal testsystem error: called with a scalar that " │ │ │ │ │ +1332 "does not match the vector type."); │ │ │ │ │ +1333 │ │ │ │ │ +1334 checkCommaOp(leftScalar>(), │ │ │ │ │ +1335 rightVector>()); │ │ │ │ │ +1336 } │ │ │ │ │ +1337 │ │ │ │ │ +1338 template │ │ │ │ │ +1339 void checkBinaryOpPV(MetaType v1, MetaType v2, Op op) │ │ │ │ │ +1340 { │ │ │ │ │ +1341 checkBinaryOpVP(v2, v1, OpInfixSwappedArgs{op}); │ │ │ │ │ +1342 } │ │ │ │ │ +1343 │ │ │ │ │ +1344 template │ │ │ │ │ +1345 void checkBinaryOpPV(MetaType, MetaType, OpInfixComma) │ │ │ │ │ +1346 { │ │ │ │ │ +1347 // Don't really know how to check comma operator for proxies │ │ │ │ │ +1348 } │ │ │ │ │ +1349 │ │ │ │ │ +1351 // │ │ │ │ │ +1352 // cross-check scalar-vector binary operations against vector-vector │ │ │ │ │ +1353 // │ │ │ │ │ +1354 │ │ │ │ │ +1355 // We check the following candidate operation │ │ │ │ │ +1356 // │ │ │ │ │ +1357 // vopres = vop1 @ vop2, where vop2 = broadcast(sref2) │ │ │ │ │ +1358 // │ │ │ │ │ +1359 // against the reference operation │ │ │ │ │ +1360 // │ │ │ │ │ +1361 // vrefres = vref1 @ sref2 │ │ │ │ │ +1362 // │ │ │ │ │ +1363 // v... variables are simd-vectors, a... variables are arrays, and │ │ │ │ │ +1364 // s... variables are scalars. │ │ │ │ │ +1365 // │ │ │ │ │ +1366 // We could check the following properties │ │ │ │ │ +1367 // 1. lanes(vopres) == lanes(vop1) │ │ │ │ │ +1368 // 2. lane(l, vopres) == lane(l, vrefres) foreach l │ │ │ │ │ +1369 // 3. lane(l, vop1) == lane(l, vref1) foreach l │ │ │ │ │ +1370 // but these are given by checking the operation against the scalar │ │ │ │ │ +1371 // operation in the vector@vector and vector@scalar cases above. │ │ │ │ │ +1372 // │ │ │ │ │ +1373 // The only thing left to check is: │ │ │ │ │ +1374 // 4. lane(l, vop2) foreach l is never modified │ │ │ │ │ +1375 │ │ │ │ │ +1376 template │ │ │ │ │ +1377 void checkBinaryOpVVAgainstSV(MetaType t1, MetaType v2, Op op) │ │ │ │ │ +1378 { │ │ │ │ │ +1379 checkBinaryOpVVAgainstVS(v2, t1, OpInfixSwappedArgs{op}); │ │ │ │ │ +1380 } │ │ │ │ │ +1381 │ │ │ │ │ +1382 template │ │ │ │ │ +1383 void checkBinaryOpVVAgainstSV(MetaType, MetaType, OpInfixComma) │ │ │ │ │ +1384 { } │ │ │ │ │ +1385 │ │ │ │ │ +1387 // │ │ │ │ │ +1388 // Invoke the checks for all combinations │ │ │ │ │ +1389 // │ │ │ │ │ +1390 │ │ │ │ │ +1391 template │ │ │ │ │ +1392 void checkBinaryRefQual(Checker checker) │ │ │ │ │ +1393 { │ │ │ │ │ +1394 if constexpr (condition) { │ │ │ │ │ +1395 Hybrid::forEach(TypeList{}, [=] (auto t1) { │ │ │ │ │ +1396 Hybrid::forEach(TypeList{}, [=] (auto t2) { │ │ │ │ │ +1397 checker(t1, t2); │ │ │ │ │ +1398 }); │ │ │ │ │ +1399 }); │ │ │ │ │ +1400 } │ │ │ │ │ +1401 } │ │ │ │ │ +1402 │ │ │ │ │ +1403 template │ │ │ │ │ +1404 void checkBinaryOps(Checker checker) │ │ │ │ │ +1405 { │ │ │ │ │ +1406 using Std::bool_constant; │ │ │ │ │ +1407 │ │ │ │ │ +1408 constexpr bool isMask = std::is_same, bool>::value; │ │ │ │ │ +1409 │ │ │ │ │ +1410 constexpr bool do_ = false; │ │ │ │ │ +1411 constexpr bool do_SV = true; │ │ │ │ │ +1412 constexpr bool do_VV = true; │ │ │ │ │ +1413 constexpr bool do_VS = true; │ │ │ │ │ +1414 │ │ │ │ │ +1415#define DUNE_SIMD_DO(M1, M2, M3, V1, V2, V3, NAME) \ │ │ │ │ │ +1416 checker(bool_constant{}, \ │ │ │ │ │ +1417 bool_constant{}, \ │ │ │ │ │ +1418 bool_constant{}, \ │ │ │ │ │ +1419 Op##NAME{}) │ │ │ │ │ +1420 │ │ │ │ │ +1421 // (Mask , Vector , Name ); │ │ │ │ │ +1422 │ │ │ │ │ +1423 DUNE_SIMD_DO( , , , SV, VV, VS, InfixMul ); │ │ │ │ │ +1424 DUNE_SIMD_DO( , , , SV, VV, VS, InfixDiv ); │ │ │ │ │ +1425 DUNE_SIMD_DO( , , , SV, VV, VS, InfixRemainder ); │ │ │ │ │ +1426 │ │ │ │ │ +1427 DUNE_SIMD_DO( , , , SV, VV, VS, InfixPlus ); │ │ │ │ │ +1428 DUNE_SIMD_DO( , , , SV, VV, VS, InfixMinus ); │ │ │ │ │ +1429 │ │ │ │ │ +1430 DUNE_SIMD_DO( , , , , VV, VS, InfixLeftShift ); │ │ │ │ │ +1431 DUNE_SIMD_DO( , , , , VV, VS, InfixRightShift ); │ │ │ │ │ +1432 │ │ │ │ │ +1433 DUNE_SIMD_DO( , , , SV, VV, VS, InfixLess ); │ │ │ │ │ +1434 DUNE_SIMD_DO( , , , SV, VV, VS, InfixGreater ); │ │ │ │ │ +1435 DUNE_SIMD_DO( , , , SV, VV, VS, InfixLessEqual ); │ │ │ │ │ +1436 DUNE_SIMD_DO( , , , SV, VV, VS, InfixGreaterEqual ); │ │ │ │ │ +1437 │ │ │ │ │ +1438 DUNE_SIMD_DO( , , , SV, VV, VS, InfixEqual ); │ │ │ │ │ +1439 DUNE_SIMD_DO( , , , SV, VV, VS, InfixNotEqual ); │ │ │ │ │ +1440 │ │ │ │ │ +1441 DUNE_SIMD_DO( , VV, , SV, VV, VS, InfixBitAnd ); │ │ │ │ │ +1442 DUNE_SIMD_DO( , VV, , SV, VV, VS, InfixBitXor ); │ │ │ │ │ +1443 DUNE_SIMD_DO( , VV, , SV, VV, VS, InfixBitOr ); │ │ │ │ │ +1444 │ │ │ │ │ +1445 DUNE_SIMD_DO(SV, VV, VS, SV, VV, VS, InfixLogicAnd ); │ │ │ │ │ +1446 DUNE_SIMD_DO(SV, VV, VS, SV, VV, VS, InfixLogicOr ); │ │ │ │ │ +1447 │ │ │ │ │ +1448 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssign ); │ │ │ │ │ +1449 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignMul ); │ │ │ │ │ +1450 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignDiv ); │ │ │ │ │ +1451 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignRemainder ); │ │ │ │ │ +1452 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignPlus ); │ │ │ │ │ +1453 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignMinus ); │ │ │ │ │ +1454 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignLeftShift ); │ │ │ │ │ +1455 DUNE_SIMD_DO( , , , , VV, VS, InfixAssignRightShift); │ │ │ │ │ +1456 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssignAnd ); │ │ │ │ │ +1457 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssignXor ); │ │ │ │ │ +1458 DUNE_SIMD_DO( , VV, , , VV, VS, InfixAssignOr ); │ │ │ │ │ +1459 │ │ │ │ │ +1460 DUNE_SIMD_DO(SV, VV, VS, SV, , VS, InfixComma ); │ │ │ │ │ +1461 │ │ │ │ │ +1462#undef DUNE_SIMD_DO │ │ │ │ │ +1463 } │ │ │ │ │ +1464 │ │ │ │ │ +1466 // │ │ │ │ │ +1467 // SIMD interface functions │ │ │ │ │ +1468 // │ │ │ │ │ +1469 │ │ │ │ │ +1470 template │ │ │ │ │ +1471 void checkAutoCopy() │ │ │ │ │ +1472 { │ │ │ │ │ +1473 using RValueResult = decltype(autoCopy(lane(0, std::declval()))); │ │ │ │ │ +1474 static_assert(std::is_same >::value, │ │ │ │ │ +1475 "Result of autoCopy() must always be Scalar"); │ │ │ │ │ +1476 │ │ │ │ │ +1477 using MutableLValueResult = │ │ │ │ │ +1478 decltype(autoCopy(lane(0, std::declval()))); │ │ │ │ │ +1479 static_assert(std::is_same >::value, │ │ │ │ │ +1480 "Result of autoCopy() must always be Scalar"); │ │ │ │ │ +1481 │ │ │ │ │ +1482 using ConstLValueResult = │ │ │ │ │ +1483 decltype(autoCopy(lane(0, std::declval()))); │ │ │ │ │ +1484 static_assert(std::is_same >::value, │ │ │ │ │ +1485 "Result of autoCopy() must always be Scalar"); │ │ │ │ │ +1486 │ │ │ │ │ +1487 V vec = make123(); │ │ │ │ │ +1488 for(std::size_t l = 0; l < lanes(vec); ++l) │ │ │ │ │ +1489 DUNE_SIMD_CHECK(autoCopy(lane(l, vec)) == Scalar(l+1)); │ │ │ │ │ +1490 } │ │ │ │ │ +1491 │ │ │ │ │ +1492 // may only be called for mask types │ │ │ │ │ +1493 template │ │ │ │ │ +1494 void checkBoolReductions() │ │ │ │ │ +1495 { │ │ │ │ │ +1496 M trueVec(true); │ │ │ │ │ +1497 │ │ │ │ │ +1498 // mutable lvalue │ │ │ │ │ +1499 DUNE_SIMD_CHECK(allTrue (static_cast(trueVec)) == true); │ │ │ │ │ +1500 DUNE_SIMD_CHECK(anyTrue (static_cast(trueVec)) == true); │ │ │ │ │ +1501 DUNE_SIMD_CHECK(allFalse(static_cast(trueVec)) == false); │ │ │ │ │ +1502 DUNE_SIMD_CHECK(anyFalse(static_cast(trueVec)) == false); │ │ │ │ │ +1503 │ │ │ │ │ +1504 // const lvalue │ │ │ │ │ +1505 DUNE_SIMD_CHECK(allTrue (static_cast(trueVec)) == true); │ │ │ │ │ +1506 DUNE_SIMD_CHECK(anyTrue (static_cast(trueVec)) == true); │ │ │ │ │ +1507 DUNE_SIMD_CHECK(allFalse(static_cast(trueVec)) == false); │ │ │ │ │ +1508 DUNE_SIMD_CHECK(anyFalse(static_cast(trueVec)) == false); │ │ │ │ │ +1509 │ │ │ │ │ +1510 // rvalue │ │ │ │ │ +1511 DUNE_SIMD_CHECK(allTrue (M(true)) == true); │ │ │ │ │ +1512 DUNE_SIMD_CHECK(anyTrue (M(true)) == true); │ │ │ │ │ +1513 DUNE_SIMD_CHECK(allFalse(M(true)) == false); │ │ │ │ │ +1514 DUNE_SIMD_CHECK(anyFalse(M(true)) == false); │ │ │ │ │ +1515 │ │ │ │ │ +1516 M falseVec(false); │ │ │ │ │ +1517 │ │ │ │ │ +1518 // mutable lvalue │ │ │ │ │ +1519 DUNE_SIMD_CHECK(allTrue (static_cast(falseVec)) == false); │ │ │ │ │ +1520 DUNE_SIMD_CHECK(anyTrue (static_cast(falseVec)) == false); │ │ │ │ │ +1521 DUNE_SIMD_CHECK(allFalse(static_cast(falseVec)) == true); │ │ │ │ │ +1522 DUNE_SIMD_CHECK(anyFalse(static_cast(falseVec)) == true); │ │ │ │ │ +1523 │ │ │ │ │ +1524 // const lvalue │ │ │ │ │ +1525 DUNE_SIMD_CHECK(allTrue (static_cast(falseVec)) == false); │ │ │ │ │ +1526 DUNE_SIMD_CHECK(anyTrue (static_cast(falseVec)) == false); │ │ │ │ │ +1527 DUNE_SIMD_CHECK(allFalse(static_cast(falseVec)) == true); │ │ │ │ │ +1528 DUNE_SIMD_CHECK(anyFalse(static_cast(falseVec)) == true); │ │ │ │ │ +1529 │ │ │ │ │ +1530 // rvalue │ │ │ │ │ +1531 DUNE_SIMD_CHECK(allTrue (M(false)) == false); │ │ │ │ │ +1532 DUNE_SIMD_CHECK(anyTrue (M(false)) == false); │ │ │ │ │ +1533 DUNE_SIMD_CHECK(allFalse(M(false)) == true); │ │ │ │ │ +1534 DUNE_SIMD_CHECK(anyFalse(M(false)) == true); │ │ │ │ │ +1535 │ │ │ │ │ +1536 auto mixedVec = broadcast(0); │ │ │ │ │ +1537 for(std::size_t l = 0; l < lanes(mixedVec); ++l) │ │ │ │ │ +1538 lane(l, mixedVec) = (l % 2); │ │ │ │ │ +1539 │ │ │ │ │ +1540 // mutable lvalue │ │ │ │ │ +1541 DUNE_SIMD_CHECK │ │ │ │ │ +1542 (allTrue (static_cast(mixedVec)) == false); │ │ │ │ │ +1543 DUNE_SIMD_CHECK │ │ │ │ │ +1544 (anyTrue (static_cast(mixedVec)) == (lanes() > 1)); │ │ │ │ │ +1545 DUNE_SIMD_CHECK │ │ │ │ │ +1546 (allFalse(static_cast(mixedVec)) == (lanes() == 1)); │ │ │ │ │ +1547 DUNE_SIMD_CHECK │ │ │ │ │ +1548 (anyFalse(static_cast(mixedVec)) == true); │ │ │ │ │ +1549 │ │ │ │ │ +1550 // const lvalue │ │ │ │ │ +1551 DUNE_SIMD_CHECK │ │ │ │ │ +1552 (allTrue (static_cast(mixedVec)) == false); │ │ │ │ │ +1553 DUNE_SIMD_CHECK │ │ │ │ │ +1554 (anyTrue (static_cast(mixedVec)) == (lanes() > 1)); │ │ │ │ │ +1555 DUNE_SIMD_CHECK │ │ │ │ │ +1556 (allFalse(static_cast(mixedVec)) == (lanes() == 1)); │ │ │ │ │ +1557 DUNE_SIMD_CHECK │ │ │ │ │ +1558 (anyFalse(static_cast(mixedVec)) == true); │ │ │ │ │ +1559 │ │ │ │ │ +1560 // rvalue │ │ │ │ │ +1561 DUNE_SIMD_CHECK(allTrue (M(mixedVec)) == false); │ │ │ │ │ +1562 DUNE_SIMD_CHECK(anyTrue (M(mixedVec)) == (lanes() > 1)); │ │ │ │ │ +1563 DUNE_SIMD_CHECK(allFalse(M(mixedVec)) == (lanes() == 1)); │ │ │ │ │ +1564 DUNE_SIMD_CHECK(anyFalse(M(mixedVec)) == true); │ │ │ │ │ +1565 } │ │ │ │ │ +1566 │ │ │ │ │ +1567 template │ │ │ │ │ +1568 void checkCond() │ │ │ │ │ +1569 { │ │ │ │ │ +1570 using M = Mask; │ │ │ │ │ +1571 │ │ │ │ │ +1572 static_assert │ │ │ │ │ +1573 (std::is_same(), std::declval(), │ │ │ │ │ +1574 std::declval())), V>::value, │ │ │ │ │ +1575 "The result of cond(M, V, V) should have exactly the type V"); │ │ │ │ │ +1576 │ │ │ │ │ +1577 static_assert │ │ │ │ │ +1578 (std::is_same(), │ │ │ │ │ +1579 std::declval(), │ │ │ │ │ +1580 std::declval())), V>::value, │ │ │ │ │ +1581 "The result of cond(const M&, const V&, const V&) should have " │ │ │ │ │ +1582 "exactly the type V"); │ │ │ │ │ +1583 │ │ │ │ │ +1584 static_assert │ │ │ │ │ +1585 (std::is_same(), std::declval(), │ │ │ │ │ +1586 std::declval())), V>::value, │ │ │ │ │ +1587 "The result of cond(M&, V&, V&) should have exactly the type V"); │ │ │ │ │ +1588 │ │ │ │ │ +1589 V vec1 = leftVector(); │ │ │ │ │ +1590 V vec2 = rightVector(); │ │ │ │ │ +1591 │ │ │ │ │ +1592 DUNE_SIMD_CHECK(allTrue(cond(M(true), vec1, vec2) == vec1)); │ │ │ │ │ +1593 DUNE_SIMD_CHECK(allTrue(cond(M(false), vec1, vec2) == vec2)); │ │ │ │ │ +1594 │ │ │ │ │ +1595 auto mixedResult = broadcast(0); │ │ │ │ │ +1596 auto mixedMask = broadcast(false); │ │ │ │ │ +1597 for(std::size_t l = 0; l < lanes(mixedMask); ++l) │ │ │ │ │ +1598 { │ │ │ │ │ +1599 lane(l, mixedMask ) = (l % 2); │ │ │ │ │ +1600 lane(l, mixedResult) = lane(l, (l % 2) ? vec1 : vec2); │ │ │ │ │ +1601 } │ │ │ │ │ +1602 │ │ │ │ │ +1603 DUNE_SIMD_CHECK(allTrue(cond(mixedMask, vec1, vec2) == mixedResult)); │ │ │ │ │ +1604 } │ │ │ │ │ +1605 │ │ │ │ │ +1606 template │ │ │ │ │ +1607 void checkBoolCond() │ │ │ │ │ +1608 { │ │ │ │ │ +1609 static_assert │ │ │ │ │ +1610 (std::is_same(), std::declval(), │ │ │ │ │ +1611 std::declval())), V>::value, │ │ │ │ │ +1612 "The result of cond(bool, V, V) should have exactly the type V"); │ │ │ │ │ +1613 │ │ │ │ │ +1614 static_assert │ │ │ │ │ +1615 (std::is_same(), │ │ │ │ │ +1616 std::declval(), │ │ │ │ │ +1617 std::declval())), V>::value, │ │ │ │ │ +1618 "The result of cond(const bool&, const V&, const V&) should have " │ │ │ │ │ +1619 "exactly the type V"); │ │ │ │ │ +1620 │ │ │ │ │ +1621 static_assert │ │ │ │ │ +1622 (std::is_same(), │ │ │ │ │ +1623 std::declval(), │ │ │ │ │ +1624 std::declval())), V>::value, │ │ │ │ │ +1625 "The result of cond(bool&, V&, V&) should have exactly the type V"); │ │ │ │ │ +1626 │ │ │ │ │ +1627 V vec1 = leftVector(); │ │ │ │ │ +1628 V vec2 = rightVector(); │ │ │ │ │ +1629 │ │ │ │ │ +1630 DUNE_SIMD_CHECK(allTrue(cond(true, vec1, vec2) == vec1)); │ │ │ │ │ +1631 DUNE_SIMD_CHECK(allTrue(cond(false, vec1, vec2) == vec2)); │ │ │ │ │ +1632 } │ │ │ │ │ +1633 │ │ │ │ │ +1634 template │ │ │ │ │ +1635 std::enable_if_t >::value> │ │ │ │ │ +1636 checkHorizontalMinMax() {} │ │ │ │ │ +1637 │ │ │ │ │ +1638 template │ │ │ │ │ +1639 std::enable_if_t >::value> │ │ │ │ │ +1640 checkHorizontalMinMax() │ │ │ │ │ +1641 { │ │ │ │ │ +1642 static_assert │ │ │ │ │ +1643 (std::is_same())), Scalar >::value, │ │ │ │ │ +1644 "The result of max(V) should be exactly Scalar"); │ │ │ │ │ +1645 │ │ │ │ │ +1646 static_assert │ │ │ │ │ +1647 (std::is_same())), Scalar >::value, │ │ │ │ │ +1648 "The result of min(V) should be exactly Scalar"); │ │ │ │ │ +1649 │ │ │ │ │ +1650 static_assert │ │ │ │ │ +1651 (std::is_same())), Scalar >::value, │ │ │ │ │ +1652 "The result of max(V) should be exactly Scalar"); │ │ │ │ │ +1653 │ │ │ │ │ +1654 static_assert │ │ │ │ │ +1655 (std::is_same())), Scalar >::value, │ │ │ │ │ +1656 "The result of min(V) should be exactly Scalar"); │ │ │ │ │ +1657 │ │ │ │ │ +1658 const V vec1 = leftVector(); │ │ │ │ │ +1659 │ │ │ │ │ +1660 DUNE_SIMD_CHECK(max(vec1) == Scalar(lanes(vec1))); │ │ │ │ │ +1661 DUNE_SIMD_CHECK(min(vec1) == Scalar(1)); │ │ │ │ │ +1662 } │ │ │ │ │ +1663 │ │ │ │ │ +1664 template │ │ │ │ │ +1665 std::enable_if_t >::value> │ │ │ │ │ +1666 checkBinaryMinMax() {} │ │ │ │ │ +1667 │ │ │ │ │ +1668 template │ │ │ │ │ +1669 std::enable_if_t >::value> │ │ │ │ │ +1670 checkBinaryMinMax() │ │ │ │ │ +1671 { │ │ │ │ │ +1672 using std::max; │ │ │ │ │ +1673 using std::min; │ │ │ │ │ +1674 │ │ │ │ │ +1675 static_assert │ │ │ │ │ +1676 (std::is_same(), │ │ │ │ │ +1677 std::declval())), V>::value, │ │ │ │ │ +1678 "The result of Simd::max(V, V) should be exactly V"); │ │ │ │ │ +1679 static_assert │ │ │ │ │ +1680 (std::is_same(), │ │ │ │ │ +1681 std::declval())), V>::value, │ │ │ │ │ +1682 "The result of Simd::min(V, V) should be exactly V"); │ │ │ │ │ +1683 │ │ │ │ │ +1684 static_assert │ │ │ │ │ +1685 (std::is_same(), │ │ │ │ │ +1686 std::declval())), V>::value, │ │ │ │ │ +1687 "The result of Simd::max(V&, V&) should be exactly V"); │ │ │ │ │ +1688 static_assert │ │ │ │ │ +1689 (std::is_same(), │ │ │ │ │ +1690 std::declval())), V>::value, │ │ │ │ │ +1691 "The result of Simd::min(V&, V&) should be exactly V"); │ │ │ │ │ +1692 │ │ │ │ │ +1693 const V arg1 = leftVector(); │ │ │ │ │ +1694 const V arg2 = rightVector(); │ │ │ │ │ +1695 │ │ │ │ │ +1696 V maxExp(Scalar(0)), minExp(Scalar(0)); │ │ │ │ │ +1697 for(auto l : range(lanes())) │ │ │ │ │ +1698 { │ │ │ │ │ +1699 lane(l, maxExp) = max(lane(l, arg1), lane(l, arg2)); │ │ │ │ │ +1700 lane(l, minExp) = min(lane(l, arg1), lane(l, arg2)); │ │ │ │ │ +1701 } │ │ │ │ │ +1702 │ │ │ │ │ +1703 DUNE_SIMD_CHECK(allTrue(maxExp == Simd::max(arg1, arg2))); │ │ │ │ │ +1704 DUNE_SIMD_CHECK(allTrue(minExp == Simd::min(arg1, arg2))); │ │ │ │ │ +1705 } │ │ │ │ │ +1706 │ │ │ │ │ +1707 template │ │ │ │ │ +1708 void checkIO() │ │ │ │ │ +1709 { │ │ │ │ │ +1710 const V vec1 = leftVector(); │ │ │ │ │ +1711 │ │ │ │ │ +1712 std::string reference; │ │ │ │ │ +1713 { │ │ │ │ │ +1714 const char *sep = ""; │ │ │ │ │ +1715 for(auto l : range(lanes(vec1))) │ │ │ │ │ +1716 { │ │ │ │ │ +1717 std::ostringstream stream; │ │ │ │ │ +1718 stream << lane(l, vec1); │ │ │ │ │ +1719 │ │ │ │ │ +1720 reference += sep; │ │ │ │ │ +1721 reference += stream.str(); │ │ │ │ │ +1722 sep = ", "; │ │ │ │ │ +1723 } │ │ │ │ │ +1724 } │ │ │ │ │ +1725 │ │ │ │ │ +1726 { │ │ │ │ │ +1727 std::ostringstream stream; │ │ │ │ │ +1728 stream << io(vec1); │ │ │ │ │ +1729 if(lanes(vec1) == 1) │ │ │ │ │ +1730 DUNE_SIMD_CHECK(stream.str() == reference); │ │ │ │ │ +1731 else │ │ │ │ │ +1732 DUNE_SIMD_CHECK(stream.str() == "<" + reference + ">"); │ │ │ │ │ +1733 } │ │ │ │ │ +1734 │ │ │ │ │ +1735 { │ │ │ │ │ +1736 std::ostringstream stream; │ │ │ │ │ +1737 stream << vio(vec1); │ │ │ │ │ +1738 DUNE_SIMD_CHECK(stream.str() == "<" + reference + ">"); │ │ │ │ │ +1739 } │ │ │ │ │ +1740 } │ │ │ │ │ +1741 │ │ │ │ │ +1742#undef DUNE_SIMD_CHECK │ │ │ │ │ +1743 │ │ │ │ │ +1744 public: │ │ │ │ │ +1807 template void checkType(); │ │ │ │ │ +1808 template void checkNonOps(); │ │ │ │ │ +1809 template void checkUnaryOps(); │ │ │ │ │ +1810 template void checkBinaryOps(); │ │ │ │ │ +1811 template void checkBinaryOpsVectorVector(); │ │ │ │ │ +1812 template void checkBinaryOpsScalarVector(); │ │ │ │ │ +1813 template void checkBinaryOpsVectorScalar(); │ │ │ │ │ +1814 template void checkBinaryOpsProxyVector(); │ │ │ │ │ +1815 template void checkBinaryOpsVectorProxy(); │ │ │ │ │ +1819 │ │ │ │ │ +1836 template class RebindPrune = IsLoop, │ │ │ │ │ +1838 template class RebindAccept = Dune::AlwaysTrue> │ │ │ │ │ +1839 void check() { │ │ │ │ │ +1840 // check whether the test for this type already started │ │ │ │ │ +1841 if(seen_.emplace(typeid (V)).second == false) │ │ │ │ │ +1842 { │ │ │ │ │ +1843 // type already seen, nothing to do │ │ │ │ │ +1844 return; │ │ │ │ │ +1845 } │ │ │ │ │ +1846 │ │ │ │ │ +1847 // do these first so everything that appears after "Checking SIMD type │ │ │ │ │ +1848 // ..." really pertains to that type │ │ │ │ │ +1849 auto recurse = [this](auto w) { │ │ │ │ │ +1850 using W = typename decltype(w)::type; │ │ │ │ │ +1851 this->template check(); │ │ │ │ │ +1852 }; │ │ │ │ │ +1853 checkRebindOf(recurse); │ │ │ │ │ +1854 │ │ │ │ │ +1855 checkType(); │ │ │ │ │ +1856 } │ │ │ │ │ +1857 │ │ │ │ │ +1859 bool good() const │ │ │ │ │ +1860 { │ │ │ │ │ +1861 return good_; │ │ │ │ │ +1862 } │ │ │ │ │ +1863 │ │ │ │ │ +1864 }; // class UnitTest │ │ │ │ │ +1865 │ │ │ │ │ +1866 template void UnitTest::checkType() │ │ │ │ │ +1867 { │ │ │ │ │ +1868 static_assert(std::is_same >::value, "Simd types " │ │ │ │ │ +1869 "must not be references, and must not include " │ │ │ │ │ +1870 "cv-qualifiers"); │ │ │ │ │ +1871 │ │ │ │ │ +1872 log_ << "Checking SIMD type " << className() << std::endl; │ │ │ │ │ +1873 │ │ │ │ │ +1874 checkNonOps(); │ │ │ │ │ +1875 checkUnaryOps(); │ │ │ │ │ +1876 checkBinaryOps(); │ │ │ │ │ +1877 } │ │ │ │ │ +1878 template void UnitTest::checkNonOps() │ │ │ │ │ +1879 { │ │ │ │ │ +1880 constexpr auto isMask = typename std::is_same, bool>::type{}; │ │ │ │ │ +1881 │ │ │ │ │ +1882 checkLanes(); │ │ │ │ │ +1883 checkScalar(); │ │ │ │ │ +1884 │ │ │ │ │ +1885 checkDefaultConstruct(); │ │ │ │ │ +1886 checkLane(); │ │ │ │ │ +1887 checkCopyMoveConstruct(); │ │ │ │ │ +1888 checkImplCast(); │ │ │ │ │ +1889 checkBroadcast(); │ │ │ │ │ +1890 if constexpr (isMask) │ │ │ │ │ +1891 this->template checkBroadcastMaskConstruct(); │ │ │ │ │ +1892 else │ │ │ │ │ +1893 this->template checkBroadcastVectorConstruct(); │ │ │ │ │ +1894 checkBracedAssign(); │ │ │ │ │ +1895 checkBracedBroadcastAssign(); │ │ │ │ │ +1896 │ │ │ │ │ +1897 checkAutoCopy(); │ │ │ │ │ +1898 checkCond(); │ │ │ │ │ +1899 checkBoolCond(); │ │ │ │ │ +1900 │ │ │ │ │ +1901 if constexpr (isMask) │ │ │ │ │ +1902 this->template checkBoolReductions(); │ │ │ │ │ +1903 // checkBoolReductions() is not applicable for non-masks │ │ │ │ │ +1904 │ │ │ │ │ +1905 checkHorizontalMinMax(); │ │ │ │ │ +1906 checkBinaryMinMax(); │ │ │ │ │ +1907 checkIO(); │ │ │ │ │ +1908 } │ │ │ │ │ +1909 template void UnitTest::checkUnaryOps() │ │ │ │ │ +1910 { │ │ │ │ │ +1911 if constexpr (std::is_same_v, bool>) { │ │ │ │ │ +1912 // check mask │ │ │ │ │ +1913 auto check = [this](auto op) { │ │ │ │ │ +1914 this->template checkUnaryOpsV(op); │ │ │ │ │ +1915 }; │ │ │ │ │ +1916 │ │ │ │ │ +1917 // postfix │ │ │ │ │ +1918 // check(OpPostfixDecrement{}); │ │ │ │ │ +1919 // clang deprecation warning if bool++ is tested │ │ │ │ │ +1920 // check(OpPostfixIncrement{}); │ │ │ │ │ +1921 │ │ │ │ │ +1922 // prefix │ │ │ │ │ +1923 // check(OpPrefixDecrement{}); │ │ │ │ │ +1924 // clang deprecation warning if ++bool is tested │ │ │ │ │ +1925 // check(OpPrefixIncrement{}); │ │ │ │ │ +1926 │ │ │ │ │ +1927 // check(OpPrefixPlus{}); │ │ │ │ │ +1928 // check(OpPrefixMinus{}); │ │ │ │ │ +1929 check(OpPrefixLogicNot{}); │ │ │ │ │ +1930 // check(OpPrefixBitNot{}); │ │ │ │ │ +1931 } │ │ │ │ │ +1932 else { │ │ │ │ │ +1933 // check vector │ │ │ │ │ +1934 auto check = [this](auto op) { │ │ │ │ │ +1935 this->template checkUnaryOpsV(op); │ │ │ │ │ +1936 }; │ │ │ │ │ +1937 │ │ │ │ │ +1938 // postfix │ │ │ │ │ +1939 // check(OpPostfixDecrement{}); │ │ │ │ │ +1940 // check(OpPostfixIncrement{}); │ │ │ │ │ +1941 │ │ │ │ │ +1942 // prefix │ │ │ │ │ +1943 // check(OpPrefixDecrement{}); │ │ │ │ │ +1944 // check(OpPrefixIncrement{}); │ │ │ │ │ +1945 │ │ │ │ │ +1946 // check(OpPrefixPlus{}); │ │ │ │ │ +1947 check(OpPrefixMinus{}); │ │ │ │ │ +1948 check(OpPrefixLogicNot{}); │ │ │ │ │ +1949 check(OpPrefixBitNot{}); │ │ │ │ │ +1950 } │ │ │ │ │ +1951 } │ │ │ │ │ +1952 template void UnitTest::checkBinaryOps() │ │ │ │ │ +1953 { │ │ │ │ │ +1954 checkBinaryOpsVectorVector(); │ │ │ │ │ +1955 checkBinaryOpsScalarVector(); │ │ │ │ │ +1956 checkBinaryOpsVectorScalar(); │ │ │ │ │ +1957 checkBinaryOpsProxyVector(); │ │ │ │ │ +1958 checkBinaryOpsVectorProxy(); │ │ │ │ │ +1959 } │ │ │ │ │ +1960 template void UnitTest::checkBinaryOpsVectorVector() │ │ │ │ │ +1961 { │ │ │ │ │ +1962 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) { │ │ │ │ │ +1963 auto check = [this,op](auto t1, auto t2) { │ │ │ │ │ +1964 this->checkBinaryOpVV(t1, t2, op); │ │ │ │ │ +1965 }; │ │ │ │ │ +1966 this->checkBinaryRefQual(check); │ │ │ │ │ +1967 }; │ │ │ │ │ +1968 checkBinaryOps(checker); │ │ │ │ │ +1969 } │ │ │ │ │ +1970 template void UnitTest::checkBinaryOpsScalarVector() │ │ │ │ │ +1971 { │ │ │ │ │ +1972 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) { │ │ │ │ │ +1973 auto check = [this,op](auto t1, auto t2) { │ │ │ │ │ +1974 this->checkBinaryOpSV(t1, t2, op); │ │ │ │ │ +1975 }; │ │ │ │ │ +1976 this->checkBinaryRefQual, V, doSV>(check); │ │ │ │ │ +1977 │ │ │ │ │ +1978 auto crossCheck = [this,op](auto t1, auto t2) { │ │ │ │ │ +1979 this->checkBinaryOpVVAgainstSV(t1, t2, op); │ │ │ │ │ +1980 }; │ │ │ │ │ +1981 this->checkBinaryRefQual, V, doSV && doVV>(crossCheck); │ │ │ │ │ +1982 }; │ │ │ │ │ +1983 checkBinaryOps(checker); │ │ │ │ │ +1984 } │ │ │ │ │ +1985 template void UnitTest::checkBinaryOpsVectorScalar() │ │ │ │ │ +1986 { │ │ │ │ │ +1987 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) { │ │ │ │ │ +1988 auto check = [this,op](auto t1, auto t2) { │ │ │ │ │ +1989 this->checkBinaryOpVS(t1, t2, op); │ │ │ │ │ +1990 }; │ │ │ │ │ +1991 this->checkBinaryRefQual, doVS>(check); │ │ │ │ │ +1992 │ │ │ │ │ +1993 auto crossCheck = [this,op](auto t1, auto t2) { │ │ │ │ │ +1994 this->checkBinaryOpVVAgainstVS(t1, t2, op); │ │ │ │ │ +1995 }; │ │ │ │ │ +1996 this->checkBinaryRefQual, doVV && doVS>(crossCheck); │ │ │ │ │ +1997 }; │ │ │ │ │ +1998 checkBinaryOps(checker); │ │ │ │ │ +1999 } │ │ │ │ │ +2000 template void UnitTest::checkBinaryOpsProxyVector() │ │ │ │ │ +2001 { │ │ │ │ │ +2002 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) { │ │ │ │ │ +2003 auto check = [this,op](auto t1, auto t2) { │ │ │ │ │ +2004 this->checkBinaryOpPV(t1, t2, op); │ │ │ │ │ +2005 }; │ │ │ │ │ +2006 this->checkBinaryRefQual(check); │ │ │ │ │ +2007 }; │ │ │ │ │ +2008 checkBinaryOps(checker); │ │ │ │ │ +2009 } │ │ │ │ │ +2010 template void UnitTest::checkBinaryOpsVectorProxy() │ │ │ │ │ +2011 { │ │ │ │ │ +2012 auto checker = [this](auto doSV, auto doVV, auto doVS, auto op) { │ │ │ │ │ +2013 auto check = [this,op](auto t1, auto t2) { │ │ │ │ │ +2014 this->checkBinaryOpVP(t1, t2, op); │ │ │ │ │ +2015 }; │ │ │ │ │ +2016 this->checkBinaryRefQual(check); │ │ │ │ │ +2017 }; │ │ │ │ │ +2018 checkBinaryOps(checker); │ │ │ │ │ +2019 } │ │ │ │ │ +2020 │ │ │ │ │ +2021 } // namespace Simd │ │ │ │ │ +2022} // namespace Dune │ │ │ │ │ +2023 │ │ │ │ │ +2024#endif // DUNE_COMMON_SIMD_TEST_HH │ │ │ │ │ +io.hh │ │ │ │ │ +IO interface of the SIMD abstraction. │ │ │ │ │ +loop.hh │ │ │ │ │ +DUNE_SIMD_POSTFIX_OP │ │ │ │ │ +#define DUNE_SIMD_POSTFIX_OP(NAME, SYMBOL) │ │ │ │ │ +Definition test.hh:670 │ │ │ │ │ +DUNE_SIMD_INFIX_OP │ │ │ │ │ +#define DUNE_SIMD_INFIX_OP(NAME, SYMBOL) │ │ │ │ │ +Definition test.hh:784 │ │ │ │ │ +DUNE_SIMD_CHECK_OP │ │ │ │ │ +#define DUNE_SIMD_CHECK_OP(expr) │ │ │ │ │ +Definition test.hh:191 │ │ │ │ │ +DUNE_SIMD_CHECK │ │ │ │ │ +#define DUNE_SIMD_CHECK(expr) │ │ │ │ │ +Definition test.hh:186 │ │ │ │ │ +DUNE_SIMD_REPL_OP │ │ │ │ │ +#define DUNE_SIMD_REPL_OP(NAME, REPLFN, SYMBOL) │ │ │ │ │ +Definition test.hh:818 │ │ │ │ │ +DUNE_SIMD_ASSIGN_OP │ │ │ │ │ +#define DUNE_SIMD_ASSIGN_OP(NAME, SYMBOL) │ │ │ │ │ +Definition test.hh:805 │ │ │ │ │ +DUNE_SIMD_PREFIX_OP │ │ │ │ │ +#define DUNE_SIMD_PREFIX_OP(NAME, SYMBOL) │ │ │ │ │ +Definition test.hh:681 │ │ │ │ │ +DUNE_SIMD_DO │ │ │ │ │ +#define DUNE_SIMD_DO(M1, M2, M3, V1, V2, V3, NAME) │ │ │ │ │ +typelist.hh │ │ │ │ │ +classname.hh │ │ │ │ │ +A free function to provide the demangled class name of a given object or type │ │ │ │ │ +as a string. │ │ │ │ │ +hybridutilities.hh │ │ │ │ │ +rangeutilities.hh │ │ │ │ │ +Utilities for reduction like operations on ranges. │ │ │ │ │ +type_traits.hh │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +Dune::range │ │ │ │ │ +static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ +>, std::integral_constant< T, to >) noexcept │ │ │ │ │ +Definition rangeutilities.hh:312 │ │ │ │ │ +Dune::TypeList │ │ │ │ │ +std::tuple< MetaType< T >... > TypeList │ │ │ │ │ +A simple type list. │ │ │ │ │ +Definition typelist.hh:87 │ │ │ │ │ +Dune::Hybrid::forEach │ │ │ │ │ +constexpr void forEach(Range &&range, F &&f) │ │ │ │ │ +Range based for loop. │ │ │ │ │ +Definition hybridutilities.hh:256 │ │ │ │ │ +Dune::autoCopy │ │ │ │ │ +constexpr AutonomousValue< T > autoCopy(T &&v) │ │ │ │ │ +Autonomous copy of an expression's value for use in auto type deduction. │ │ │ │ │ +Definition typetraits.hh:672 │ │ │ │ │ +Dune::void_t │ │ │ │ │ +typename Impl::voider< Types... >::type void_t │ │ │ │ │ +Is void for all valid input types. The workhorse for C++11 SFINAE-techniques. │ │ │ │ │ +Definition typetraits.hh:40 │ │ │ │ │ +Dune::Simd::anyTrue │ │ │ │ │ +bool anyTrue(const Mask &mask) │ │ │ │ │ +Whether any entry is true │ │ │ │ │ +Definition simd/interface.hh:429 │ │ │ │ │ +Dune::Simd::maskOr │ │ │ │ │ +auto maskOr(const V1 &v1, const V2 &v2) │ │ │ │ │ +Logic or of masks. │ │ │ │ │ +Definition simd/interface.hh:499 │ │ │ │ │ +Dune::Simd::cond │ │ │ │ │ +V cond(M &&mask, const V &ifTrue, const V &ifFalse) │ │ │ │ │ +Like the ?: operator. │ │ │ │ │ +Definition simd/interface.hh:386 │ │ │ │ │ +Dune::Simd::io │ │ │ │ │ +auto io(const V &v) │ │ │ │ │ +construct a stream inserter │ │ │ │ │ +Definition io.hh:106 │ │ │ │ │ +Dune::Simd::allTrue │ │ │ │ │ +bool allTrue(const Mask &mask) │ │ │ │ │ +Whether all entries are true │ │ │ │ │ +Definition simd/interface.hh:439 │ │ │ │ │ +Dune::Simd::vio │ │ │ │ │ +auto vio(const V &v) │ │ │ │ │ +construct a stream inserter │ │ │ │ │ +Definition io.hh:90 │ │ │ │ │ +Dune::Simd::max │ │ │ │ │ +auto max(const V &v1, const V &v2) │ │ │ │ │ +The binary maximum value over two simd objects. │ │ │ │ │ +Definition simd/interface.hh:409 │ │ │ │ │ +Dune::Simd::anyFalse │ │ │ │ │ +bool anyFalse(const Mask &mask) │ │ │ │ │ +Whether any entry is false │ │ │ │ │ +Definition simd/interface.hh:449 │ │ │ │ │ +Dune::Simd::lanes │ │ │ │ │ +constexpr std::size_t lanes() │ │ │ │ │ +Number of lanes in a SIMD type. │ │ │ │ │ +Definition simd/interface.hh:305 │ │ │ │ │ +Dune::Simd::lane │ │ │ │ │ +decltype(auto) lane(std::size_t l, V &&v) │ │ │ │ │ +Extract an element of a SIMD type. │ │ │ │ │ +Definition simd/interface.hh:324 │ │ │ │ │ +Dune::Simd::allFalse │ │ │ │ │ +bool allFalse(const Mask &mask) │ │ │ │ │ +Whether all entries are false │ │ │ │ │ +Definition simd/interface.hh:459 │ │ │ │ │ +Dune::Simd::maskAnd │ │ │ │ │ +auto maskAnd(const V1 &v1, const V2 &v2) │ │ │ │ │ +Logic and of masks. │ │ │ │ │ +Definition simd/interface.hh:509 │ │ │ │ │ +Dune::Simd::Scalar │ │ │ │ │ +typename Overloads::ScalarType< std::decay_t< V > >::type Scalar │ │ │ │ │ +Element type of some SIMD type. │ │ │ │ │ +Definition simd/interface.hh:235 │ │ │ │ │ +Dune::Simd::min │ │ │ │ │ +auto min(const V &v1, const V &v2) │ │ │ │ │ +The binary minimum value over two simd objects. │ │ │ │ │ +Definition simd/interface.hh:419 │ │ │ │ │ std │ │ │ │ │ STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::size │ │ │ │ │ +constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std:: │ │ │ │ │ +integer_sequence< T, II... >) │ │ │ │ │ +Return the size of the sequence. │ │ │ │ │ +Definition integersequence.hh:75 │ │ │ │ │ +Dune::Simd::RebindList │ │ │ │ │ +typename Impl::RemoveEnd< EndMark, TypeList< Types... > >::type RebindList │ │ │ │ │ +A list of types with the final element removed. │ │ │ │ │ +Definition test.hh:158 │ │ │ │ │ +Dune::Simd::IsLoop │ │ │ │ │ +typename Impl::IsLoop< T >::type IsLoop │ │ │ │ │ +check whether a type is an instance of LoopSIMD │ │ │ │ │ +Definition test.hh:162 │ │ │ │ │ +Dune::LoopSIMD │ │ │ │ │ +Definition loop.hh:65 │ │ │ │ │ +Dune::Simd::EndMark │ │ │ │ │ +final element marker for RebindList │ │ │ │ │ +Definition test.hh:145 │ │ │ │ │ +Dune::Simd::UnitTest │ │ │ │ │ +Definition test.hh:164 │ │ │ │ │ +Dune::Simd::UnitTest::checkUnaryOps │ │ │ │ │ +void checkUnaryOps() │ │ │ │ │ +Definition test.hh:1909 │ │ │ │ │ +Dune::Simd::UnitTest::checkBinaryOps │ │ │ │ │ +void checkBinaryOps() │ │ │ │ │ +Definition test.hh:1952 │ │ │ │ │ +Dune::Simd::UnitTest::checkBinaryOpsScalarVector │ │ │ │ │ +void checkBinaryOpsScalarVector() │ │ │ │ │ +Definition test.hh:1970 │ │ │ │ │ +Dune::Simd::UnitTest::checkType │ │ │ │ │ +void checkType() │ │ │ │ │ +Definition test.hh:1866 │ │ │ │ │ +Dune::Simd::UnitTest::check │ │ │ │ │ +void check() │ │ │ │ │ +run unit tests for simd vector type V │ │ │ │ │ +Definition test.hh:1839 │ │ │ │ │ +Dune::Simd::UnitTest::checkBinaryOpsVectorScalar │ │ │ │ │ +void checkBinaryOpsVectorScalar() │ │ │ │ │ +Definition test.hh:1985 │ │ │ │ │ +Dune::Simd::UnitTest::good │ │ │ │ │ +bool good() const │ │ │ │ │ +whether all tests succeeded │ │ │ │ │ +Definition test.hh:1859 │ │ │ │ │ +Dune::Simd::UnitTest::checkBinaryOpsVectorVector │ │ │ │ │ +void checkBinaryOpsVectorVector() │ │ │ │ │ +Definition test.hh:1960 │ │ │ │ │ +Dune::Simd::UnitTest::checkNonOps │ │ │ │ │ +void checkNonOps() │ │ │ │ │ +Definition test.hh:1878 │ │ │ │ │ +Dune::Simd::UnitTest::checkBinaryOpsVectorProxy │ │ │ │ │ +void checkBinaryOpsVectorProxy() │ │ │ │ │ +Definition test.hh:2010 │ │ │ │ │ +Dune::Simd::UnitTest::checkBinaryOpsProxyVector │ │ │ │ │ +void checkBinaryOpsProxyVector() │ │ │ │ │ +Definition test.hh:2000 │ │ │ │ │ +Dune::AlwaysTrue │ │ │ │ │ +template which always yields a true value │ │ │ │ │ +Definition typetraits.hh:134 │ │ │ │ │ +simd.hh │ │ │ │ │ +Include file for users of the SIMD abstraction layer. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00032.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: deprecated.hh File Reference │ │ │ │ +dune-common: simd.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,35 +70,96 @@ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ -Macros
│ │ │ │ -
deprecated.hh File Reference
│ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Typedefs | │ │ │ │ +Functions
│ │ │ │ +
simd.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Definition of the DUNE_NO_DEPRECATED_* macros. │ │ │ │ +

Abstractions for support of dedicated SIMD data types. │ │ │ │ More...

│ │ │ │ - │ │ │ │ +
#include <cassert>
│ │ │ │ +#include <cstddef>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <utility>
│ │ │ │ +#include <dune/common/conditional.hh>
│ │ │ │ +#include <dune/common/debugalign.hh>
│ │ │ │ +#include <dune/common/rangeutilities.hh>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │ +#include <dune/common/vc.hh>
│ │ │ │ +
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ -Macros

#define DUNE_NO_DEPRECATED_BEGIN   ...
 Ignore deprecation warnings (start)
 
#define DUNE_NO_DEPRECATED_END   ...
 Ignore deprecation warnings (end)
 

│ │ │ │ +Classes

struct  Dune::SimdScalarTypeTraits< T >
 
struct  Dune::SimdScalarTypeTraits< AlignedNumber< T, align > >
 deduce the underlying scalar data type of an AlignedNumber More...
 
struct  Dune::SimdIndexTypeTraits< V, typename >
 
struct  Dune::SimdMaskTypeTraits< V, typename >
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Typedefs

template<typename T >
using Dune::SimdScalar = typename SimdScalarTypeTraits< T >::type
 
template<typename V >
using Dune::SimdIndex = typename SimdIndexTypeTraits< V >::type
 An simd vector of indices corresponding to a simd vector V.
 
template<typename V >
using Dune::SimdMask = typename SimdMaskTypeTraits< V >::type
 A simd vector of truth values corresponding to a simd vector V.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

template<class T >
std::size_t Dune::lanes (const T &)
 get the number of lanes of a simd vector (scalar version)
 
template<class T >
Dune::lane (std::size_t l, const T &v)
 access a lane of a simd vector (scalar version)
 
template<class T >
T & Dune::lane (std::size_t l, T &v)
 access a lane of a simd vector (scalar version)
 
template<class T >
void Dune::assign (T &dst, const T &src, bool mask)
 masked Simd assignment (scalar version)
 
template<class T >
void Dune::swap (T &v1, T &v2, bool mask)
 
│ │ │ │

Detailed Description

│ │ │ │ -

Definition of the DUNE_NO_DEPRECATED_* macros.

│ │ │ │ +

Abstractions for support of dedicated SIMD data types.

│ │ │ │ +

Libraries like Vc (https://github.com/VcDevel/Vc) add high-level data types for SIMD (or vectorization) support in C++. Most of these operations mimic the behavior of a numerical data type. Some boolean operations can not be implemented in a compatible way to trivial data types.

│ │ │ │ +

This header contains additional abstractions to help writing code that works with trivial numerical data types (like double) and Vc vectorization data types.

│ │ │ │ +

See also the conditional.hh and range_utils.hh headers.

│ │ │ │ +
Deprecated:
Use the newer simd architecture from dune/common/simd/simd.hh instead.
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,21 +1,79 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Macros │ │ │ │ │ -deprecated.hh File Reference │ │ │ │ │ -Definition of the DUNE_NO_DEPRECATED_* macros. More... │ │ │ │ │ +Classes | Namespaces | Typedefs | Functions │ │ │ │ │ +simd.hh File Reference │ │ │ │ │ +Abstractions for support of dedicated SIMD data types. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ -Macros │ │ │ │ │ -#define  DUNE_NO_DEPRECATED_BEGIN   ... │ │ │ │ │ -  Ignore deprecation warnings (start) │ │ │ │ │ +Classes │ │ │ │ │ +struct   Dune::SimdScalarTypeTraits<_T_> │ │ │ │ │   │ │ │ │ │ -#define  DUNE_NO_DEPRECATED_END   ... │ │ │ │ │ -  Ignore deprecation warnings (end) │ │ │ │ │ +struct   Dune::SimdScalarTypeTraits<_AlignedNumber<_T,_align_>_> │ │ │ │ │ +  deduce the underlying scalar data type of an AlignedNumber More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::SimdIndexTypeTraits<_V,_typename_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::SimdMaskTypeTraits<_V,_typename_> │ │ │ │ │ +  │ │ │ │ │ +Namespaces │ │ │ │ │ +namespace   Dune │ │ │ │ │ +  Dune namespace. │ │ │ │ │ +  │ │ │ │ │ +Typedefs │ │ │ │ │ +template │ │ │ │ │ +using  Dune::SimdScalar = typename SimdScalarTypeTraits< T >::type │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +using  Dune::SimdIndex = typename SimdIndexTypeTraits< V >::type │ │ │ │ │ +  An simd vector of indices corresponding to a simd vector V. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +using  Dune::SimdMask = typename SimdMaskTypeTraits< V >::type │ │ │ │ │ +  A simd vector of truth values corresponding to a simd vector V. │ │ │ │ │ +  │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ +std::size_t  Dune::lanes (const T &) │ │ │ │ │ +  get the number of lanes of a simd vector (scalar version) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + T  Dune::lane (std::size_t l, const T &v) │ │ │ │ │ +  access a lane of a simd vector (scalar version) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + T &  Dune::lane (std::size_t l, T &v) │ │ │ │ │ +  access a lane of a simd vector (scalar version) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + void  Dune::assign (T &dst, const T &src, bool mask) │ │ │ │ │ +  masked Simd assignment (scalar version) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + void  Dune::swap (T &v1, T &v2, bool mask) │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Definition of the DUNE_NO_DEPRECATED_* macros. │ │ │ │ │ +Abstractions for support of dedicated SIMD data types. │ │ │ │ │ +Libraries like Vc (https://github.com/VcDevel/Vc) add high-level data types for │ │ │ │ │ +SIMD (or vectorization) support in C++. Most of these operations mimic the │ │ │ │ │ +behavior of a numerical data type. Some boolean operations can not be │ │ │ │ │ +implemented in a compatible way to trivial data types. │ │ │ │ │ +This header contains additional abstractions to help writing code that works │ │ │ │ │ +with trivial numerical data types (like double) and Vc vectorization data │ │ │ │ │ +types. │ │ │ │ │ +See also the conditional.hh and range_utils.hh headers. │ │ │ │ │ + Deprecated: │ │ │ │ │ + Use the newer simd architecture from dune/common/simd/simd.hh instead. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00032_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: deprecated.hh Source File │ │ │ │ +dune-common: simd.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,52 +74,518 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
deprecated.hh
│ │ │ │ +
simd.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ -
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ -
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_DEPRECATED_HH
│ │ │ │ -
6#define DUNE_DEPRECATED_HH
│ │ │ │ -
7
│ │ │ │ -
14#ifdef DOXYGEN
│ │ │ │ -
32#define DUNE_NO_DEPRECATED_BEGIN ...
│ │ │ │ -
38#define DUNE_NO_DEPRECATED_END ...
│ │ │ │ -
39#else
│ │ │ │ -
40# if defined __clang__
│ │ │ │ -
41# define DUNE_NO_DEPRECATED_BEGIN \
│ │ │ │ -
42 _Pragma("clang diagnostic push") \
│ │ │ │ -
43 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
│ │ │ │ -
44# define DUNE_NO_DEPRECATED_END _Pragma("clang diagnostic pop")
│ │ │ │ -
45# elif defined __INTEL_COMPILER
│ │ │ │ -
46# define DUNE_NO_DEPRECATED_BEGIN \
│ │ │ │ -
47 _Pragma("warning push") \
│ │ │ │ -
48 _Pragma("warning(disable:1478)") \
│ │ │ │ -
49 _Pragma("warning(disable:1786)")
│ │ │ │ -
50# define DUNE_NO_DEPRECATED_END _Pragma("warning pop")
│ │ │ │ -
51# elif defined __GNUC__
│ │ │ │ -
52# define DUNE_NO_DEPRECATED_BEGIN \
│ │ │ │ -
53 _Pragma("GCC diagnostic push") \
│ │ │ │ -
54 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
│ │ │ │ -
55# define DUNE_NO_DEPRECATED_END _Pragma("GCC diagnostic pop")
│ │ │ │ -
56# else
│ │ │ │ -
57# define DUNE_NO_DEPRECATED_BEGIN /* Noop. */
│ │ │ │ -
58# define DUNE_NO_DEPRECATED_END /* Noop. */
│ │ │ │ -
59# endif
│ │ │ │ -
60#endif
│ │ │ │ -
61
│ │ │ │ -
63
│ │ │ │ -
64#endif
│ │ │ │ +Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
3#ifndef DUNE_COMMON_SIMD_HH
│ │ │ │ +
4#define DUNE_COMMON_SIMD_HH
│ │ │ │ +
5
│ │ │ │ +
6#warning dune/common/simd.hh is deprecated.
│ │ │ │ +
7#warning Use the new infrastructure from dune/common/simd/simd.h instead.
│ │ │ │ +
8
│ │ │ │ +
30#include <cassert>
│ │ │ │ +
31#include <cstddef>
│ │ │ │ +
32#include <type_traits>
│ │ │ │ +
33#include <utility>
│ │ │ │ +
34
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
38#if HAVE_VC
│ │ │ │ +
39// include Vc part of new simd interface to provide compatibility for
│ │ │ │ +
40// functionality that has been switched over.
│ │ │ │ + │ │ │ │ +
42#endif
│ │ │ │ + │ │ │ │ +
44#include <dune/common/vc.hh>
│ │ │ │ +
45
│ │ │ │ +
46namespace Dune
│ │ │ │ +
47{
│ │ │ │ +
48
│ │ │ │ +
49#if HAVE_VC
│ │ │ │ +
50 namespace VcImpl {
│ │ │ │ +
52
│ │ │ │ +
61 template<class V>
│ │ │ │ +
62 class Proxy
│ │ │ │ +
63 {
│ │ │ │ +
64 static_assert(std::is_same<V, std::decay_t<V> >::value, "Class Proxy "
│ │ │ │ +
65 "may only be instantiated with unqualified types");
│ │ │ │ +
66 public:
│ │ │ │ +
67 using value_type = typename V::value_type;
│ │ │ │ +
68
│ │ │ │ +
69 private:
│ │ │ │ +
70 static_assert(std::is_arithmetic<value_type>::value,
│ │ │ │ +
71 "Only arithmetic types are supported");
│ │ │ │ +
72 V &vec_;
│ │ │ │ +
73 std::size_t idx_;
│ │ │ │ +
74
│ │ │ │ +
75 public:
│ │ │ │ +
76 Proxy(std::size_t idx, V &vec)
│ │ │ │ +
77 : vec_(vec), idx_(idx)
│ │ │ │ +
78 { }
│ │ │ │ +
79
│ │ │ │ +
80 operator value_type() const { return vec_[idx_]; }
│ │ │ │ +
81
│ │ │ │ +
82 // postfix operators
│ │ │ │ +
83
│ │ │ │ +
84 template<class T = value_type,
│ │ │ │ +
85 class = std::enable_if_t<!std::is_same<T, bool>::value> >
│ │ │ │ +
86 value_type operator++(int) { return vec_[idx_]++; }
│ │ │ │ +
87 template<class T = value_type,
│ │ │ │ +
88 class = std::enable_if_t<!std::is_same<T, bool>::value> >
│ │ │ │ +
89 value_type operator--(int) { return vec_[idx_]--; }
│ │ │ │ +
90
│ │ │ │ +
91 // unary (prefix) operators
│ │ │ │ +
92 template<class T = value_type,
│ │ │ │ +
93 class = std::enable_if_t<!std::is_same<T, bool>::value> >
│ │ │ │ +
94 Proxy &operator++() { ++(vec_[idx_]); return *this; }
│ │ │ │ +
95 template<class T = value_type,
│ │ │ │ +
96 class = std::enable_if_t<!std::is_same<T, bool>::value> >
│ │ │ │ +
97 Proxy &operator--() { --(vec_[idx_]); return *this; }
│ │ │ │ +
98 decltype(auto) operator!() const { return !(vec_[idx_]); }
│ │ │ │ +
99 decltype(auto) operator+() const { return +(vec_[idx_]); }
│ │ │ │ +
100 decltype(auto) operator-() const { return -(vec_[idx_]); }
│ │ │ │ +
101 template<class T = value_type,
│ │ │ │ +
102 class = std::enable_if_t<std::is_integral<T>::value> >
│ │ │ │ +
103 decltype(auto) operator~() const { return ~(vec_[idx_]); }
│ │ │ │ +
104
│ │ │ │ +
105 // binary operators
│ │ │ │ +
106#define DUNE_SIMD_VC_BINARY_OP(OP) \
│ │ │ │ +
107 template<class T> \
│ │ │ │ +
108 auto operator OP(T &&o) const \
│ │ │ │ +
109 -> decltype(vec_[idx_] OP valueCast(std::forward<T>(o))) \
│ │ │ │ +
110 { \
│ │ │ │ +
111 return vec_[idx_] OP valueCast(std::forward<T>(o)); \
│ │ │ │ +
112 } \
│ │ │ │ +
113 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ +
114
│ │ │ │ +
115 DUNE_SIMD_VC_BINARY_OP(*);
│ │ │ │ +
116 DUNE_SIMD_VC_BINARY_OP(/);
│ │ │ │ +
117 DUNE_SIMD_VC_BINARY_OP(%);
│ │ │ │ +
118
│ │ │ │ +
119 DUNE_SIMD_VC_BINARY_OP(+);
│ │ │ │ +
120 DUNE_SIMD_VC_BINARY_OP(-);
│ │ │ │ +
121
│ │ │ │ +
122 DUNE_SIMD_VC_BINARY_OP(<<);
│ │ │ │ +
123 DUNE_SIMD_VC_BINARY_OP(>>);
│ │ │ │ +
124
│ │ │ │ +
125 DUNE_SIMD_VC_BINARY_OP(<);
│ │ │ │ +
126 DUNE_SIMD_VC_BINARY_OP(>);
│ │ │ │ +
127 DUNE_SIMD_VC_BINARY_OP(<=);
│ │ │ │ +
128 DUNE_SIMD_VC_BINARY_OP(>=);
│ │ │ │ +
129
│ │ │ │ +
130 DUNE_SIMD_VC_BINARY_OP(==);
│ │ │ │ +
131 DUNE_SIMD_VC_BINARY_OP(!=);
│ │ │ │ +
132
│ │ │ │ +
133 DUNE_SIMD_VC_BINARY_OP(&);
│ │ │ │ +
134 DUNE_SIMD_VC_BINARY_OP(^);
│ │ │ │ +
135 DUNE_SIMD_VC_BINARY_OP(|);
│ │ │ │ +
136
│ │ │ │ +
137 DUNE_SIMD_VC_BINARY_OP(&&);
│ │ │ │ +
138 DUNE_SIMD_VC_BINARY_OP(||);
│ │ │ │ +
139#undef DUNE_SIMD_VC_BINARY_OP
│ │ │ │ +
140
│ │ │ │ +
141#define DUNE_SIMD_VC_ASSIGNMENT(OP) \
│ │ │ │ +
142 template<class T> \
│ │ │ │ +
143 auto operator OP(T &&o) \
│ │ │ │ +
144 -> std::enable_if_t<AlwaysTrue<decltype( \
│ │ │ │ +
145 vec_[idx_] OP valueCast(std::forward<T>(o)) \
│ │ │ │ +
146 )>::value, Proxy&> \
│ │ │ │ +
147 { \
│ │ │ │ +
148 vec_[idx_] OP valueCast(std::forward<T>(o)); \
│ │ │ │ +
149 return *this; \
│ │ │ │ +
150 } \
│ │ │ │ +
151 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ +
152
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
164#undef DUNE_SIMD_VC_ASSIGNMENT
│ │ │ │ +
165
│ │ │ │ +
166 // swap on proxies swaps the proxied vector entries. As such, it
│ │ │ │ +
167 // applies to rvalues of proxies too, not just lvalues
│ │ │ │ +
168 template<class V1, class V2>
│ │ │ │ +
169 friend void swap(Proxy<V1>, Proxy<V2>);
│ │ │ │ +
170
│ │ │ │ +
171 template<class T>
│ │ │ │ +
172 friend void swap(Proxy p1, T& s2)
│ │ │ │ +
173 {
│ │ │ │ +
174 // don't use swap() ourselves -- not supported by Vc 1.3.0 (but is
│ │ │ │ +
175 // supported by Vc 1.3.2)
│ │ │ │ +
176 T tmp = p1.vec_[p1.idx_];
│ │ │ │ +
177 p1.vec_[p1.idx_] = s2;
│ │ │ │ +
178 s2 = tmp;
│ │ │ │ +
179 }
│ │ │ │ +
180
│ │ │ │ +
181 template<class T>
│ │ │ │ +
182 friend void swap(T& s1, Proxy p2)
│ │ │ │ +
183 {
│ │ │ │ +
184 T tmp = s1;
│ │ │ │ +
185 s1 = p2.vec_[p2.idx_];
│ │ │ │ +
186 p2.vec_[p2.idx_] = tmp;
│ │ │ │ +
187 }
│ │ │ │ +
188 };
│ │ │ │ +
189
│ │ │ │ +
190 template<class V1, class V2>
│ │ │ │ +
191 void swap(Proxy<V1> p1, Proxy<V2> p2)
│ │ │ │ +
192 {
│ │ │ │ +
193 typename V1::value_type tmp = p1.vec_[p1.idx_];
│ │ │ │ +
194 p1.vec_[p1.idx_] = p2.vec_[p2.idx_];
│ │ │ │ +
195 p2.vec_[p2.idx_] = tmp;
│ │ │ │ +
196 }
│ │ │ │ +
197 } // namespace VcImpl
│ │ │ │ +
198#endif // HAVE_VC
│ │ │ │ +
199
│ │ │ │ +
200 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
202 {
│ │ │ │ +
203 using type = T;
│ │ │ │ +
204 };
│ │ │ │ +
│ │ │ │ +
205
│ │ │ │ +
206 template<typename T>
│ │ │ │ + │ │ │ │ +
208
│ │ │ │ +
209#if HAVE_VC
│ │ │ │ +
210 /*
│ │ │ │ +
211 Add Vc specializations for the SimdScalarTypeTraits trais class
│ │ │ │ +
212 */
│ │ │ │ +
213 template<typename T, typename A>
│ │ │ │ +
214 struct SimdScalarTypeTraits< Vc::Vector<T,A> >
│ │ │ │ +
215 {
│ │ │ │ +
216 using type = T;
│ │ │ │ +
217 };
│ │ │ │ +
218
│ │ │ │ +
219 template<typename T, std::size_t N, typename V, std::size_t M>
│ │ │ │ +
220 struct SimdScalarTypeTraits< Vc::SimdArray<T,N,V,M> >
│ │ │ │ +
221 {
│ │ │ │ +
222 using type = T;
│ │ │ │ +
223 };
│ │ │ │ +
224#endif // HAVE_VC
│ │ │ │ +
225
│ │ │ │ +
227 template<typename T, std::size_t align>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
229 {
│ │ │ │ +
230 using type = T;
│ │ │ │ +
231 };
│ │ │ │ +
│ │ │ │ +
232
│ │ │ │ +
233 template<typename V, typename = void>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
235 using type = std::size_t;
│ │ │ │ +
236 };
│ │ │ │ +
│ │ │ │ +
237
│ │ │ │ +
239
│ │ │ │ +
245 template<typename V>
│ │ │ │ + │ │ │ │ +
247
│ │ │ │ +
248#if HAVE_VC
│ │ │ │ +
249 template<typename T, typename A>
│ │ │ │ +
250 struct SimdIndexTypeTraits<Vc::Vector<T, A> > {
│ │ │ │ +
251 using type = typename Vc::Vector<T, A>::index_type;
│ │ │ │ +
252 };
│ │ │ │ +
253
│ │ │ │ +
254 template<typename T, std::size_t n, typename V>
│ │ │ │ +
255 struct SimdIndexTypeTraits<Vc::SimdArray<T, n, V> > {
│ │ │ │ +
256 using type = typename Vc::SimdArray<T, n, V>::index_type;
│ │ │ │ +
257 };
│ │ │ │ +
258#endif // HAVE_VC
│ │ │ │ +
259
│ │ │ │ +
260 template<typename V, typename = void>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
262 using type = bool;
│ │ │ │ +
263 };
│ │ │ │ +
│ │ │ │ +
264
│ │ │ │ +
266
│ │ │ │ +
269 template<typename V>
│ │ │ │ + │ │ │ │ +
271
│ │ │ │ +
272#if HAVE_VC
│ │ │ │ +
273 template<typename T, typename A>
│ │ │ │ +
274 struct SimdMaskTypeTraits<Vc::Vector<T, A> > {
│ │ │ │ +
275 using type = typename Vc::Vector<T, A>::mask_type;
│ │ │ │ +
276 };
│ │ │ │ +
277
│ │ │ │ +
278 template<typename T, std::size_t n, typename V>
│ │ │ │ +
279 struct SimdMaskTypeTraits<Vc::SimdArray<T, n, V> > {
│ │ │ │ +
280 using type = typename Vc::SimdArray<T, n, V>::mask_type;
│ │ │ │ +
281 };
│ │ │ │ +
282#endif // HAVE_VC
│ │ │ │ +
283
│ │ │ │ +
284#if HAVE_VC
│ │ │ │ +
285 /*
│ │ │ │ +
286 Add Vc specializations for cond(), see conditional.hh
│ │ │ │ +
287 */
│ │ │ │ +
288 template<typename T, typename A>
│ │ │ │ +
289 Vc::Vector<T,A> cond(const Vc::Mask<T,A> & b,
│ │ │ │ +
290 const Vc::Vector<T,A> & v1,
│ │ │ │ +
291 const Vc::Vector<T,A> & v2)
│ │ │ │ +
292 {
│ │ │ │ +
293 return std::move(Vc::iif(b, v1, v2));
│ │ │ │ +
294 }
│ │ │ │ +
295
│ │ │ │ +
296 template<typename T, std::size_t N, typename V, std::size_t M>
│ │ │ │ +
297 Vc::SimdArray<T,N,V,M> cond(const typename Vc::SimdArray<T,N,V,M>::mask_type & b,
│ │ │ │ +
298 const Vc::SimdArray<T,N,V,M> & v1,
│ │ │ │ +
299 const Vc::SimdArray<T,N,V,M> & v2)
│ │ │ │ +
300 {
│ │ │ │ +
301 return std::move(Vc::iif(b, v1, v2));
│ │ │ │ +
302 }
│ │ │ │ +
303#endif // HAVE_VC
│ │ │ │ +
304
│ │ │ │ +
305#if HAVE_VC
│ │ │ │ +
306 /*
│ │ │ │ +
307 Add Vc specializations for several boolean operations, see rangeutitlities.hh:
│ │ │ │ +
308
│ │ │ │ +
309 max_value, min_value, any_true, all_true
│ │ │ │ +
310 */
│ │ │ │ +
311 template<typename T, typename A>
│ │ │ │ +
312 T max_value(const Vc::Vector<T,A> & v)
│ │ │ │ +
313 {
│ │ │ │ +
314 return v.max();
│ │ │ │ +
315 }
│ │ │ │ +
316
│ │ │ │ +
317 template<typename T, std::size_t N, typename V, std::size_t M>
│ │ │ │ +
318 double max_value(const Vc::SimdArray<T,N,V,M> & v)
│ │ │ │ +
319 {
│ │ │ │ +
320 return v.max();
│ │ │ │ +
321 }
│ │ │ │ +
322
│ │ │ │ +
323 template<typename T, typename A>
│ │ │ │ +
324 T min_value(const Vc::Vector<T,A> & v)
│ │ │ │ +
325 {
│ │ │ │ +
326 return v.min();
│ │ │ │ +
327 }
│ │ │ │ +
328
│ │ │ │ +
329 template<typename T, std::size_t N, typename V, std::size_t M>
│ │ │ │ +
330 double min_value(const Vc::SimdArray<T,N,V,M> & v)
│ │ │ │ +
331 {
│ │ │ │ +
332 return v.min();
│ │ │ │ +
333 }
│ │ │ │ +
334
│ │ │ │ +
335 template<typename T, typename A>
│ │ │ │ +
336 bool any_true(const Vc::Mask<T,A> & v)
│ │ │ │ +
337 {
│ │ │ │ +
338 return Vc::any_of(v);
│ │ │ │ +
339 }
│ │ │ │ +
340
│ │ │ │ +
341 template<typename T, std::size_t N, typename V, std::size_t M>
│ │ │ │ +
342 bool any_true(const Vc::SimdMaskArray<T,N,V,M> & v)
│ │ │ │ +
343 {
│ │ │ │ +
344 return Vc::any_of(v);
│ │ │ │ +
345 }
│ │ │ │ +
346
│ │ │ │ +
347 template<typename T, typename A>
│ │ │ │ +
348 bool all_true(const Vc::Mask<T,A> & v)
│ │ │ │ +
349 {
│ │ │ │ +
350 return Vc::all_of(v);
│ │ │ │ +
351 }
│ │ │ │ +
352
│ │ │ │ +
353 template<typename T, std::size_t N, typename V, std::size_t M>
│ │ │ │ +
354 bool all_true(const Vc::SimdMaskArray<T,N,V,M> & v)
│ │ │ │ +
355 {
│ │ │ │ +
356 return Vc::all_of(v);
│ │ │ │ +
357 }
│ │ │ │ +
358#endif // HAVE_VC
│ │ │ │ +
359
│ │ │ │ +
361 template<class T>
│ │ │ │ +
362 std::size_t lanes(const T &) { return 1; }
│ │ │ │ +
363
│ │ │ │ +
365 template<class T>
│ │ │ │ +
│ │ │ │ +
366 T lane(std::size_t l, const T &v)
│ │ │ │ +
367 {
│ │ │ │ +
368 assert(l == 0);
│ │ │ │ +
369 return v;
│ │ │ │ +
370 }
│ │ │ │ +
│ │ │ │ +
371
│ │ │ │ +
373 template<class T>
│ │ │ │ +
│ │ │ │ +
374 T &lane(std::size_t l, T &v)
│ │ │ │ +
375 {
│ │ │ │ +
376 assert(l == 0);
│ │ │ │ +
377 return v;
│ │ │ │ +
378 }
│ │ │ │ +
│ │ │ │ +
379
│ │ │ │ +
380#if HAVE_VC
│ │ │ │ +
381 template<class T, class A>
│ │ │ │ +
382 std::size_t lanes(const Vc::Vector<T, A> &)
│ │ │ │ +
383 {
│ │ │ │ +
384 return Vc::Vector<T, A>::size();
│ │ │ │ +
385 }
│ │ │ │ +
386
│ │ │ │ +
387 template<class T, class A>
│ │ │ │ +
388 T lane(std::size_t l, const Vc::Vector<T, A> &v)
│ │ │ │ +
389 {
│ │ │ │ +
390 assert(l < lanes(v));
│ │ │ │ +
391 return v[l];
│ │ │ │ +
392 }
│ │ │ │ +
393
│ │ │ │ +
394 template<class T, class A>
│ │ │ │ +
395 auto lane(std::size_t l, Vc::Vector<T, A> &v)
│ │ │ │ +
396 {
│ │ │ │ +
397 assert(l < lanes(v));
│ │ │ │ +
398 return VcImpl::Proxy<Vc::Vector<T, A> >{l, v};
│ │ │ │ +
399 }
│ │ │ │ +
400
│ │ │ │ +
401 template<class T, std::size_t n, class V>
│ │ │ │ +
402 std::size_t lanes(const Vc::SimdArray<T, n, V> &)
│ │ │ │ +
403 {
│ │ │ │ +
404 return n;
│ │ │ │ +
405 }
│ │ │ │ +
406
│ │ │ │ +
407 template<class T, std::size_t n, class V>
│ │ │ │ +
408 T lane(std::size_t l, const Vc::SimdArray<T, n, V> &v)
│ │ │ │ +
409 {
│ │ │ │ +
410 assert(l < n);
│ │ │ │ +
411 return v[l];
│ │ │ │ +
412 }
│ │ │ │ +
413
│ │ │ │ +
414 template<class T, std::size_t n, class V>
│ │ │ │ +
415 auto lane(std::size_t l, Vc::SimdArray<T, n, V> &v)
│ │ │ │ +
416 {
│ │ │ │ +
417 assert(l < n);
│ │ │ │ +
418 return VcImpl::Proxy<Vc::SimdArray<T, n, V> >{l, v};
│ │ │ │ +
419 }
│ │ │ │ +
420
│ │ │ │ +
421 template<class T, std::size_t n, class V>
│ │ │ │ +
422 std::size_t lanes(const Vc::SimdMaskArray<T, n, V> &)
│ │ │ │ +
423 {
│ │ │ │ +
424 return n;
│ │ │ │ +
425 }
│ │ │ │ +
426
│ │ │ │ +
427 template<class T, std::size_t n, class V>
│ │ │ │ +
428 bool lane(std::size_t l, const Vc::SimdMaskArray<T, n, V> &v)
│ │ │ │ +
429 {
│ │ │ │ +
430 assert(l < n);
│ │ │ │ +
431 return v[l];
│ │ │ │ +
432 }
│ │ │ │ +
433
│ │ │ │ +
434 template<class T, std::size_t n, class V>
│ │ │ │ +
435 auto lane(std::size_t l, Vc::SimdMaskArray<T, n, V> &v)
│ │ │ │ +
436 {
│ │ │ │ +
437 assert(l < n);
│ │ │ │ +
438 return VcImpl::Proxy<Vc::SimdMaskArray<T, n, V> >{l, v};
│ │ │ │ +
439 }
│ │ │ │ +
440#endif // HAVE_VC
│ │ │ │ +
441
│ │ │ │ +
443
│ │ │ │ +
446 template<class T>
│ │ │ │ +
│ │ │ │ +
447 void assign(T &dst, const T &src, bool mask)
│ │ │ │ +
448 {
│ │ │ │ +
449 if(mask) dst = src;
│ │ │ │ +
450 }
│ │ │ │ +
│ │ │ │ +
451
│ │ │ │ +
452#if HAVE_VC
│ │ │ │ +
453 /*
│ │ │ │ +
454 Add Vc specializations for masked assignment
│ │ │ │ +
455 */
│ │ │ │ +
456 template<class T, class A>
│ │ │ │ +
457 void assign(Vc::Vector<T, A> &dst, const Vc::Vector<T, A> &src,
│ │ │ │ +
458 typename Vc::Vector<T, A>::mask_type mask)
│ │ │ │ +
459 {
│ │ │ │ +
460 dst(mask) = src;
│ │ │ │ +
461 }
│ │ │ │ +
462
│ │ │ │ +
463 template<class T, std::size_t n, class V>
│ │ │ │ +
464 void assign(Vc::SimdArray<T, n, V> &dst, const Vc::SimdArray<T, n, V> &src,
│ │ │ │ +
465 typename Vc::SimdArray<T, n, V>::mask_type mask)
│ │ │ │ +
466 {
│ │ │ │ +
467 dst(mask) = src;
│ │ │ │ +
468 }
│ │ │ │ +
469#endif // HAVE_VC
│ │ │ │ +
470
│ │ │ │ +
471 template<class T>
│ │ │ │ +
│ │ │ │ +
472 void swap(T &v1, T &v2, bool mask)
│ │ │ │ +
473 {
│ │ │ │ +
474 using std::swap;
│ │ │ │ +
475 if(mask) swap(v1, v2);
│ │ │ │ +
476 }
│ │ │ │ +
│ │ │ │ +
477
│ │ │ │ +
478#if HAVE_VC
│ │ │ │ +
479 /*
│ │ │ │ +
480 Add Vc specializations for masked swap
│ │ │ │ +
481 */
│ │ │ │ +
482 template<class T, class A>
│ │ │ │ +
483 void swap(Vc::Vector<T, A> &v1, Vc::Vector<T, A> &v2,
│ │ │ │ +
484 typename Vc::Vector<T, A>::mask_type mask)
│ │ │ │ +
485 {
│ │ │ │ +
486 auto tmp = v1;
│ │ │ │ +
487 v1(mask) = v2;
│ │ │ │ +
488 v2(mask) = tmp;
│ │ │ │ +
489 }
│ │ │ │ +
490
│ │ │ │ +
491 template<class T, std::size_t n, class V>
│ │ │ │ +
492 void swap(Vc::SimdArray<T, n, V> &v1, Vc::SimdArray<T, n, V> &v2,
│ │ │ │ +
493 typename Vc::SimdArray<T, n, V>::mask_type mask)
│ │ │ │ +
494 {
│ │ │ │ +
495 auto tmp = v1;
│ │ │ │ +
496 v1(mask) = v2;
│ │ │ │ +
497 v2(mask) = tmp;
│ │ │ │ +
498 }
│ │ │ │ +
499#endif // HAVE_VC
│ │ │ │ +
500
│ │ │ │ +
501} // end namespace Dune
│ │ │ │ +
502
│ │ │ │ +
503#endif // DUNE_COMMON_SIMD_HH
│ │ │ │ +
Compatibility header for including <Vc/Vc>
│ │ │ │ +
Utilities for reduction like operations on ranges.
│ │ │ │ + │ │ │ │ + │ │ │ │ +
Traits for type conversions and type information.
│ │ │ │ +
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ +
bool any_true(const AlignedNumber< bool, align > &val)
Definition debugalign.hh:506
│ │ │ │ +
bool all_true(const AlignedNumber< bool, align > &val)
Definition debugalign.hh:512
│ │ │ │ +
typename SimdIndexTypeTraits< V >::type SimdIndex
An simd vector of indices corresponding to a simd vector V.
Definition simd.hh:246
│ │ │ │ +
typename SimdScalarTypeTraits< T >::type SimdScalar
Definition simd.hh:207
│ │ │ │ +
typename SimdMaskTypeTraits< V >::type SimdMask
A simd vector of truth values corresponding to a simd vector V.
Definition simd.hh:270
│ │ │ │ +
T lane(std::size_t l, const T &v)
access a lane of a simd vector (scalar version)
Definition simd.hh:366
│ │ │ │ +
void swap(T &v1, T &v2, bool mask)
Definition simd.hh:472
│ │ │ │ +
void assign(T &dst, const T &src, bool mask)
masked Simd assignment (scalar version)
Definition simd.hh:447
│ │ │ │ +
const T1 cond(bool b, const T1 &v1, const T2 &v2)
conditional evaluate
Definition conditional.hh:28
│ │ │ │ +
T max_value(const AlignedNumber< T, align > &val)
Definition debugalign.hh:494
│ │ │ │ +
T min_value(const AlignedNumber< T, align > &val)
Definition debugalign.hh:500
│ │ │ │ +
std::size_t lanes(const T &)
get the number of lanes of a simd vector (scalar version)
Definition simd.hh:362
│ │ │ │ +
aligned wrappers for arithmetic types
Definition debugalign.hh:128
│ │ │ │ +
Definition simd.hh:202
│ │ │ │ +
T type
Definition simd.hh:203
│ │ │ │ + │ │ │ │ +
Definition simd.hh:234
│ │ │ │ +
std::size_t type
Definition simd.hh:235
│ │ │ │ +
Definition simd.hh:261
│ │ │ │ +
bool type
Definition simd.hh:262
│ │ │ │ +
SIMD abstractions for Vc.
│ │ │ │ +
#define DUNE_SIMD_VC_ASSIGNMENT(OP)
Definition simd/vc.hh:224
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,46 +1,549 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -deprecated.hh │ │ │ │ │ +simd.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ -2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ -3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_DEPRECATED_HH │ │ │ │ │ -6#define DUNE_DEPRECATED_HH │ │ │ │ │ -7 │ │ │ │ │ -14#ifdef DOXYGEN │ │ │ │ │ -32#define DUNE_NO_DEPRECATED_BEGIN ... │ │ │ │ │ -38#define DUNE_NO_DEPRECATED_END ... │ │ │ │ │ -39#else │ │ │ │ │ -40# if defined __clang__ │ │ │ │ │ -41# define DUNE_NO_DEPRECATED_BEGIN \ │ │ │ │ │ -42 _Pragma("clang diagnostic push") \ │ │ │ │ │ -43 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") │ │ │ │ │ -44# define DUNE_NO_DEPRECATED_END _Pragma("clang diagnostic pop") │ │ │ │ │ -45# elif defined __INTEL_COMPILER │ │ │ │ │ -46# define DUNE_NO_DEPRECATED_BEGIN \ │ │ │ │ │ -47 _Pragma("warning push") \ │ │ │ │ │ -48 _Pragma("warning(disable:1478)") \ │ │ │ │ │ -49 _Pragma("warning(disable:1786)") │ │ │ │ │ -50# define DUNE_NO_DEPRECATED_END _Pragma("warning pop") │ │ │ │ │ -51# elif defined __GNUC__ │ │ │ │ │ -52# define DUNE_NO_DEPRECATED_BEGIN \ │ │ │ │ │ -53 _Pragma("GCC diagnostic push") \ │ │ │ │ │ -54 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") │ │ │ │ │ -55# define DUNE_NO_DEPRECATED_END _Pragma("GCC diagnostic pop") │ │ │ │ │ -56# else │ │ │ │ │ -57# define DUNE_NO_DEPRECATED_BEGIN /* Noop. */ │ │ │ │ │ -58# define DUNE_NO_DEPRECATED_END /* Noop. */ │ │ │ │ │ -59# endif │ │ │ │ │ -60#endif │ │ │ │ │ -61 │ │ │ │ │ -63 │ │ │ │ │ -64#endif │ │ │ │ │ +2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +3#ifndef DUNE_COMMON_SIMD_HH │ │ │ │ │ +4#define DUNE_COMMON_SIMD_HH │ │ │ │ │ +5 │ │ │ │ │ +6#warning dune/common/simd.hh is deprecated. │ │ │ │ │ +7#warning Use the new infrastructure from dune/common/simd/simd.h instead. │ │ │ │ │ +8 │ │ │ │ │ +30#include │ │ │ │ │ +31#include │ │ │ │ │ +32#include │ │ │ │ │ +33#include │ │ │ │ │ +34 │ │ │ │ │ +35#include │ │ │ │ │ +36#include │ │ │ │ │ +37#include │ │ │ │ │ +38#if HAVE_VC │ │ │ │ │ +39// include Vc part of new simd interface to provide compatibility for │ │ │ │ │ +40// functionality that has been switched over. │ │ │ │ │ +41#include │ │ │ │ │ +42#endif │ │ │ │ │ +43#include │ │ │ │ │ +44#include │ │ │ │ │ +45 │ │ │ │ │ +46namespace Dune │ │ │ │ │ +47{ │ │ │ │ │ +48 │ │ │ │ │ +49#if HAVE_VC │ │ │ │ │ +50 namespace VcImpl { │ │ │ │ │ +52 │ │ │ │ │ +61 template │ │ │ │ │ +62 class Proxy │ │ │ │ │ +63 { │ │ │ │ │ +64 static_assert(std::is_same >::value, "Class Proxy " │ │ │ │ │ +65 "may only be instantiated with unqualified types"); │ │ │ │ │ +66 public: │ │ │ │ │ +67 using value_type = typename V::value_type; │ │ │ │ │ +68 │ │ │ │ │ +69 private: │ │ │ │ │ +70 static_assert(std::is_arithmetic::value, │ │ │ │ │ +71 "Only arithmetic types are supported"); │ │ │ │ │ +72 V &vec_; │ │ │ │ │ +73 std::size_t idx_; │ │ │ │ │ +74 │ │ │ │ │ +75 public: │ │ │ │ │ +76 Proxy(std::size_t idx, V &vec) │ │ │ │ │ +77 : vec_(vec), idx_(idx) │ │ │ │ │ +78 { } │ │ │ │ │ +79 │ │ │ │ │ +80 operator value_type() const { return vec_[idx_]; } │ │ │ │ │ +81 │ │ │ │ │ +82 // postfix operators │ │ │ │ │ +83 │ │ │ │ │ +84 template::value> > │ │ │ │ │ +86 value_type operator++(int) { return vec_[idx_]++; } │ │ │ │ │ +87 template::value> > │ │ │ │ │ +89 value_type operator--(int) { return vec_[idx_]--; } │ │ │ │ │ +90 │ │ │ │ │ +91 // unary (prefix) operators │ │ │ │ │ +92 template::value> > │ │ │ │ │ +94 Proxy &operator++() { ++(vec_[idx_]); return *this; } │ │ │ │ │ +95 template::value> > │ │ │ │ │ +97 Proxy &operator--() { --(vec_[idx_]); return *this; } │ │ │ │ │ +98 decltype(auto) operator!() const { return !(vec_[idx_]); } │ │ │ │ │ +99 decltype(auto) operator+() const { return +(vec_[idx_]); } │ │ │ │ │ +100 decltype(auto) operator-() const { return -(vec_[idx_]); } │ │ │ │ │ +101 template::value> > │ │ │ │ │ +103 decltype(auto) operator~() const { return ~(vec_[idx_]); } │ │ │ │ │ +104 │ │ │ │ │ +105 // binary operators │ │ │ │ │ +106#define DUNE_SIMD_VC_BINARY_OP(OP) \ │ │ │ │ │ +107 template \ │ │ │ │ │ +108 auto operator OP(T &&o) const \ │ │ │ │ │ +109 -> decltype(vec_[idx_] OP valueCast(std::forward(o))) \ │ │ │ │ │ +110 { \ │ │ │ │ │ +111 return vec_[idx_] OP valueCast(std::forward(o)); \ │ │ │ │ │ +112 } \ │ │ │ │ │ +113 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ +114 │ │ │ │ │ +115 DUNE_SIMD_VC_BINARY_OP(*); │ │ │ │ │ +116 DUNE_SIMD_VC_BINARY_OP(/); │ │ │ │ │ +117 DUNE_SIMD_VC_BINARY_OP(%); │ │ │ │ │ +118 │ │ │ │ │ +119 DUNE_SIMD_VC_BINARY_OP(+); │ │ │ │ │ +120 DUNE_SIMD_VC_BINARY_OP(-); │ │ │ │ │ +121 │ │ │ │ │ +122 DUNE_SIMD_VC_BINARY_OP(<<); │ │ │ │ │ +123 DUNE_SIMD_VC_BINARY_OP(>>); │ │ │ │ │ +124 │ │ │ │ │ +125 DUNE_SIMD_VC_BINARY_OP(<); │ │ │ │ │ +126 DUNE_SIMD_VC_BINARY_OP(>); │ │ │ │ │ +127 DUNE_SIMD_VC_BINARY_OP(<=); │ │ │ │ │ +128 DUNE_SIMD_VC_BINARY_OP(>=); │ │ │ │ │ +129 │ │ │ │ │ +130 DUNE_SIMD_VC_BINARY_OP(==); │ │ │ │ │ +131 DUNE_SIMD_VC_BINARY_OP(!=); │ │ │ │ │ +132 │ │ │ │ │ +133 DUNE_SIMD_VC_BINARY_OP(&); │ │ │ │ │ +134 DUNE_SIMD_VC_BINARY_OP(^); │ │ │ │ │ +135 DUNE_SIMD_VC_BINARY_OP(|); │ │ │ │ │ +136 │ │ │ │ │ +137 DUNE_SIMD_VC_BINARY_OP(&&); │ │ │ │ │ +138 DUNE_SIMD_VC_BINARY_OP(||); │ │ │ │ │ +139#undef DUNE_SIMD_VC_BINARY_OP │ │ │ │ │ +140 │ │ │ │ │ +141#define DUNE_SIMD_VC_ASSIGNMENT(OP) \ │ │ │ │ │ +142 template \ │ │ │ │ │ +143 auto operator OP(T &&o) \ │ │ │ │ │ +144 -> std::enable_if_t(o)) \ │ │ │ │ │ +146 )>::value, Proxy&> \ │ │ │ │ │ +147 { \ │ │ │ │ │ +148 vec_[idx_] OP valueCast(std::forward(o)); \ │ │ │ │ │ +149 return *this; \ │ │ │ │ │ +150 } \ │ │ │ │ │ +151 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ +152 │ │ │ │ │ +153 DUNE_SIMD_VC_ASSIGNMENT(=); │ │ │ │ │ +154 DUNE_SIMD_VC_ASSIGNMENT(*=); │ │ │ │ │ +155 DUNE_SIMD_VC_ASSIGNMENT(/=); │ │ │ │ │ +156 DUNE_SIMD_VC_ASSIGNMENT(%=); │ │ │ │ │ +157 DUNE_SIMD_VC_ASSIGNMENT(+=); │ │ │ │ │ +158 DUNE_SIMD_VC_ASSIGNMENT(-=); │ │ │ │ │ +159 DUNE_SIMD_VC_ASSIGNMENT(<<=); │ │ │ │ │ +160 DUNE_SIMD_VC_ASSIGNMENT(>>=); │ │ │ │ │ +161 DUNE_SIMD_VC_ASSIGNMENT(&=); │ │ │ │ │ +162 DUNE_SIMD_VC_ASSIGNMENT(^=); │ │ │ │ │ +163 DUNE_SIMD_VC_ASSIGNMENT(|=); │ │ │ │ │ +164#undef DUNE_SIMD_VC_ASSIGNMENT │ │ │ │ │ +165 │ │ │ │ │ +166 // swap on proxies swaps the proxied vector entries. As such, it │ │ │ │ │ +167 // applies to rvalues of proxies too, not just lvalues │ │ │ │ │ +168 template │ │ │ │ │ +169 friend void swap(Proxy, Proxy); │ │ │ │ │ +170 │ │ │ │ │ +171 template │ │ │ │ │ +172 friend void swap(Proxy p1, T& s2) │ │ │ │ │ +173 { │ │ │ │ │ +174 // don't use swap() ourselves -- not supported by Vc 1.3.0 (but is │ │ │ │ │ +175 // supported by Vc 1.3.2) │ │ │ │ │ +176 T tmp = p1.vec_[p1.idx_]; │ │ │ │ │ +177 p1.vec_[p1.idx_] = s2; │ │ │ │ │ +178 s2 = tmp; │ │ │ │ │ +179 } │ │ │ │ │ +180 │ │ │ │ │ +181 template │ │ │ │ │ +182 friend void swap(T& s1, Proxy p2) │ │ │ │ │ +183 { │ │ │ │ │ +184 T tmp = s1; │ │ │ │ │ +185 s1 = p2.vec_[p2.idx_]; │ │ │ │ │ +186 p2.vec_[p2.idx_] = tmp; │ │ │ │ │ +187 } │ │ │ │ │ +188 }; │ │ │ │ │ +189 │ │ │ │ │ +190 template │ │ │ │ │ +191 void swap(Proxy p1, Proxy p2) │ │ │ │ │ +192 { │ │ │ │ │ +193 typename V1::value_type tmp = p1.vec_[p1.idx_]; │ │ │ │ │ +194 p1.vec_[p1.idx_] = p2.vec_[p2.idx_]; │ │ │ │ │ +195 p2.vec_[p2.idx_] = tmp; │ │ │ │ │ +196 } │ │ │ │ │ +197 } // namespace VcImpl │ │ │ │ │ +198#endif // HAVE_VC │ │ │ │ │ +199 │ │ │ │ │ +200 template │ │ │ │ │ +201 struct SimdScalarTypeTraits │ │ │ │ │ +202 { │ │ │ │ │ +203 using type = T; │ │ │ │ │ +204 }; │ │ │ │ │ +205 │ │ │ │ │ +206 template │ │ │ │ │ +207 using SimdScalar = typename SimdScalarTypeTraits::type; │ │ │ │ │ +208 │ │ │ │ │ +209#if HAVE_VC │ │ │ │ │ +210 /* │ │ │ │ │ +211 Add Vc specializations for the SimdScalarTypeTraits trais class │ │ │ │ │ +212 */ │ │ │ │ │ +213 template │ │ │ │ │ +214 struct SimdScalarTypeTraits< Vc::Vector > │ │ │ │ │ +215 { │ │ │ │ │ +216 using type = T; │ │ │ │ │ +217 }; │ │ │ │ │ +218 │ │ │ │ │ +219 template │ │ │ │ │ +220 struct SimdScalarTypeTraits< Vc::SimdArray > │ │ │ │ │ +221 { │ │ │ │ │ +222 using type = T; │ │ │ │ │ +223 }; │ │ │ │ │ +224#endif // HAVE_VC │ │ │ │ │ +225 │ │ │ │ │ +227 template │ │ │ │ │ +228 struct SimdScalarTypeTraits< AlignedNumber > │ │ │ │ │ +229 { │ │ │ │ │ +230 using type = T; │ │ │ │ │ +231 }; │ │ │ │ │ +232 │ │ │ │ │ +233 template │ │ │ │ │ +234 struct SimdIndexTypeTraits { │ │ │ │ │ +235 using type = std::size_t; │ │ │ │ │ +236 }; │ │ │ │ │ +237 │ │ │ │ │ +239 │ │ │ │ │ +245 template │ │ │ │ │ +246 using SimdIndex = typename SimdIndexTypeTraits::type; │ │ │ │ │ +247 │ │ │ │ │ +248#if HAVE_VC │ │ │ │ │ +249 template │ │ │ │ │ +250 struct SimdIndexTypeTraits > { │ │ │ │ │ +251 using type = typename Vc::Vector::index_type; │ │ │ │ │ +252 }; │ │ │ │ │ +253 │ │ │ │ │ +254 template │ │ │ │ │ +255 struct SimdIndexTypeTraits > { │ │ │ │ │ +256 using type = typename Vc::SimdArray::index_type; │ │ │ │ │ +257 }; │ │ │ │ │ +258#endif // HAVE_VC │ │ │ │ │ +259 │ │ │ │ │ +260 template │ │ │ │ │ +261 struct SimdMaskTypeTraits { │ │ │ │ │ +262 using type = bool; │ │ │ │ │ +263 }; │ │ │ │ │ +264 │ │ │ │ │ +266 │ │ │ │ │ +269 template │ │ │ │ │ +270 using SimdMask = typename SimdMaskTypeTraits::type; │ │ │ │ │ +271 │ │ │ │ │ +272#if HAVE_VC │ │ │ │ │ +273 template │ │ │ │ │ +274 struct SimdMaskTypeTraits > { │ │ │ │ │ +275 using type = typename Vc::Vector::mask_type; │ │ │ │ │ +276 }; │ │ │ │ │ +277 │ │ │ │ │ +278 template │ │ │ │ │ +279 struct SimdMaskTypeTraits > { │ │ │ │ │ +280 using type = typename Vc::SimdArray::mask_type; │ │ │ │ │ +281 }; │ │ │ │ │ +282#endif // HAVE_VC │ │ │ │ │ +283 │ │ │ │ │ +284#if HAVE_VC │ │ │ │ │ +285 /* │ │ │ │ │ +286 Add Vc specializations for cond(), see conditional.hh │ │ │ │ │ +287 */ │ │ │ │ │ +288 template │ │ │ │ │ +289 Vc::Vector cond(const Vc::Mask & b, │ │ │ │ │ +290 const Vc::Vector & v1, │ │ │ │ │ +291 const Vc::Vector & v2) │ │ │ │ │ +292 { │ │ │ │ │ +293 return std::move(Vc::iif(b, v1, v2)); │ │ │ │ │ +294 } │ │ │ │ │ +295 │ │ │ │ │ +296 template │ │ │ │ │ +297 Vc::SimdArray cond(const typename Vc::SimdArray::mask_ │ │ │ │ │ +type & b, │ │ │ │ │ +298 const Vc::SimdArray & v1, │ │ │ │ │ +299 const Vc::SimdArray & v2) │ │ │ │ │ +300 { │ │ │ │ │ +301 return std::move(Vc::iif(b, v1, v2)); │ │ │ │ │ +302 } │ │ │ │ │ +303#endif // HAVE_VC │ │ │ │ │ +304 │ │ │ │ │ +305#if HAVE_VC │ │ │ │ │ +306 /* │ │ │ │ │ +307 Add Vc specializations for several boolean operations, see │ │ │ │ │ +rangeutitlities.hh: │ │ │ │ │ +308 │ │ │ │ │ +309 max_value, min_value, any_true, all_true │ │ │ │ │ +310 */ │ │ │ │ │ +311 template │ │ │ │ │ +312 T max_value(const Vc::Vector & v) │ │ │ │ │ +313 { │ │ │ │ │ +314 return v.max(); │ │ │ │ │ +315 } │ │ │ │ │ +316 │ │ │ │ │ +317 template │ │ │ │ │ +318 double max_value(const Vc::SimdArray & v) │ │ │ │ │ +319 { │ │ │ │ │ +320 return v.max(); │ │ │ │ │ +321 } │ │ │ │ │ +322 │ │ │ │ │ +323 template │ │ │ │ │ +324 T min_value(const Vc::Vector & v) │ │ │ │ │ +325 { │ │ │ │ │ +326 return v.min(); │ │ │ │ │ +327 } │ │ │ │ │ +328 │ │ │ │ │ +329 template │ │ │ │ │ +330 double min_value(const Vc::SimdArray & v) │ │ │ │ │ +331 { │ │ │ │ │ +332 return v.min(); │ │ │ │ │ +333 } │ │ │ │ │ +334 │ │ │ │ │ +335 template │ │ │ │ │ +336 bool any_true(const Vc::Mask & v) │ │ │ │ │ +337 { │ │ │ │ │ +338 return Vc::any_of(v); │ │ │ │ │ +339 } │ │ │ │ │ +340 │ │ │ │ │ +341 template │ │ │ │ │ +342 bool any_true(const Vc::SimdMaskArray & v) │ │ │ │ │ +343 { │ │ │ │ │ +344 return Vc::any_of(v); │ │ │ │ │ +345 } │ │ │ │ │ +346 │ │ │ │ │ +347 template │ │ │ │ │ +348 bool all_true(const Vc::Mask & v) │ │ │ │ │ +349 { │ │ │ │ │ +350 return Vc::all_of(v); │ │ │ │ │ +351 } │ │ │ │ │ +352 │ │ │ │ │ +353 template │ │ │ │ │ +354 bool all_true(const Vc::SimdMaskArray & v) │ │ │ │ │ +355 { │ │ │ │ │ +356 return Vc::all_of(v); │ │ │ │ │ +357 } │ │ │ │ │ +358#endif // HAVE_VC │ │ │ │ │ +359 │ │ │ │ │ +361 template │ │ │ │ │ +362 std::size_t lanes(const T &) { return 1; } │ │ │ │ │ +363 │ │ │ │ │ +365 template │ │ │ │ │ +366 T lane(std::size_t l, const T &v) │ │ │ │ │ +367 { │ │ │ │ │ +368 assert(l == 0); │ │ │ │ │ +369 return v; │ │ │ │ │ +370 } │ │ │ │ │ +371 │ │ │ │ │ +373 template │ │ │ │ │ +374 T &lane(std::size_t l, T &v) │ │ │ │ │ +375 { │ │ │ │ │ +376 assert(l == 0); │ │ │ │ │ +377 return v; │ │ │ │ │ +378 } │ │ │ │ │ +379 │ │ │ │ │ +380#if HAVE_VC │ │ │ │ │ +381 template │ │ │ │ │ +382 std::size_t lanes(const Vc::Vector &) │ │ │ │ │ +383 { │ │ │ │ │ +384 return Vc::Vector::size(); │ │ │ │ │ +385 } │ │ │ │ │ +386 │ │ │ │ │ +387 template │ │ │ │ │ +388 T lane(std::size_t l, const Vc::Vector &v) │ │ │ │ │ +389 { │ │ │ │ │ +390 assert(l < lanes(v)); │ │ │ │ │ +391 return v[l]; │ │ │ │ │ +392 } │ │ │ │ │ +393 │ │ │ │ │ +394 template │ │ │ │ │ +395 auto lane(std::size_t l, Vc::Vector &v) │ │ │ │ │ +396 { │ │ │ │ │ +397 assert(l < lanes(v)); │ │ │ │ │ +398 return VcImpl::Proxy >{l, v}; │ │ │ │ │ +399 } │ │ │ │ │ +400 │ │ │ │ │ +401 template │ │ │ │ │ +402 std::size_t lanes(const Vc::SimdArray &) │ │ │ │ │ +403 { │ │ │ │ │ +404 return n; │ │ │ │ │ +405 } │ │ │ │ │ +406 │ │ │ │ │ +407 template │ │ │ │ │ +408 T lane(std::size_t l, const Vc::SimdArray &v) │ │ │ │ │ +409 { │ │ │ │ │ +410 assert(l < n); │ │ │ │ │ +411 return v[l]; │ │ │ │ │ +412 } │ │ │ │ │ +413 │ │ │ │ │ +414 template │ │ │ │ │ +415 auto lane(std::size_t l, Vc::SimdArray &v) │ │ │ │ │ +416 { │ │ │ │ │ +417 assert(l < n); │ │ │ │ │ +418 return VcImpl::Proxy >{l, v}; │ │ │ │ │ +419 } │ │ │ │ │ +420 │ │ │ │ │ +421 template │ │ │ │ │ +422 std::size_t lanes(const Vc::SimdMaskArray &) │ │ │ │ │ +423 { │ │ │ │ │ +424 return n; │ │ │ │ │ +425 } │ │ │ │ │ +426 │ │ │ │ │ +427 template │ │ │ │ │ +428 bool lane(std::size_t l, const Vc::SimdMaskArray &v) │ │ │ │ │ +429 { │ │ │ │ │ +430 assert(l < n); │ │ │ │ │ +431 return v[l]; │ │ │ │ │ +432 } │ │ │ │ │ +433 │ │ │ │ │ +434 template │ │ │ │ │ +435 auto lane(std::size_t l, Vc::SimdMaskArray &v) │ │ │ │ │ +436 { │ │ │ │ │ +437 assert(l < n); │ │ │ │ │ +438 return VcImpl::Proxy >{l, v}; │ │ │ │ │ +439 } │ │ │ │ │ +440#endif // HAVE_VC │ │ │ │ │ +441 │ │ │ │ │ +443 │ │ │ │ │ +446 template │ │ │ │ │ +447 void assign(T &dst, const T &src, bool mask) │ │ │ │ │ +448 { │ │ │ │ │ +449 if(mask) dst = src; │ │ │ │ │ +450 } │ │ │ │ │ +451 │ │ │ │ │ +452#if HAVE_VC │ │ │ │ │ +453 /* │ │ │ │ │ +454 Add Vc specializations for masked assignment │ │ │ │ │ +455 */ │ │ │ │ │ +456 template │ │ │ │ │ +457 void assign(Vc::Vector &dst, const Vc::Vector &src, │ │ │ │ │ +458 typename Vc::Vector::mask_type mask) │ │ │ │ │ +459 { │ │ │ │ │ +460 dst(mask) = src; │ │ │ │ │ +461 } │ │ │ │ │ +462 │ │ │ │ │ +463 template │ │ │ │ │ +464 void assign(Vc::SimdArray &dst, const Vc::SimdArray &src, │ │ │ │ │ +465 typename Vc::SimdArray::mask_type mask) │ │ │ │ │ +466 { │ │ │ │ │ +467 dst(mask) = src; │ │ │ │ │ +468 } │ │ │ │ │ +469#endif // HAVE_VC │ │ │ │ │ +470 │ │ │ │ │ +471 template │ │ │ │ │ +472 void swap(T &v1, T &v2, bool mask) │ │ │ │ │ +473 { │ │ │ │ │ +474 using std::swap; │ │ │ │ │ +475 if(mask) swap(v1, v2); │ │ │ │ │ +476 } │ │ │ │ │ +477 │ │ │ │ │ +478#if HAVE_VC │ │ │ │ │ +479 /* │ │ │ │ │ +480 Add Vc specializations for masked swap │ │ │ │ │ +481 */ │ │ │ │ │ +482 template │ │ │ │ │ +483 void swap(Vc::Vector &v1, Vc::Vector &v2, │ │ │ │ │ +484 typename Vc::Vector::mask_type mask) │ │ │ │ │ +485 { │ │ │ │ │ +486 auto tmp = v1; │ │ │ │ │ +487 v1(mask) = v2; │ │ │ │ │ +488 v2(mask) = tmp; │ │ │ │ │ +489 } │ │ │ │ │ +490 │ │ │ │ │ +491 template │ │ │ │ │ +492 void swap(Vc::SimdArray &v1, Vc::SimdArray &v2, │ │ │ │ │ +493 typename Vc::SimdArray::mask_type mask) │ │ │ │ │ +494 { │ │ │ │ │ +495 auto tmp = v1; │ │ │ │ │ +496 v1(mask) = v2; │ │ │ │ │ +497 v2(mask) = tmp; │ │ │ │ │ +498 } │ │ │ │ │ +499#endif // HAVE_VC │ │ │ │ │ +500 │ │ │ │ │ +501} // end namespace Dune │ │ │ │ │ +502 │ │ │ │ │ +503#endif // DUNE_COMMON_SIMD_HH │ │ │ │ │ +vc.hh │ │ │ │ │ +Compatibility header for including │ │ │ │ │ +rangeutilities.hh │ │ │ │ │ +Utilities for reduction like operations on ranges. │ │ │ │ │ +debugalign.hh │ │ │ │ │ +conditional.hh │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +Dune │ │ │ │ │ +Dune namespace. │ │ │ │ │ +Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::any_true │ │ │ │ │ +bool any_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ +Definition debugalign.hh:506 │ │ │ │ │ +Dune::all_true │ │ │ │ │ +bool all_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ +Definition debugalign.hh:512 │ │ │ │ │ +Dune::SimdIndex │ │ │ │ │ +typename SimdIndexTypeTraits< V >::type SimdIndex │ │ │ │ │ +An simd vector of indices corresponding to a simd vector V. │ │ │ │ │ +Definition simd.hh:246 │ │ │ │ │ +Dune::SimdScalar │ │ │ │ │ +typename SimdScalarTypeTraits< T >::type SimdScalar │ │ │ │ │ +Definition simd.hh:207 │ │ │ │ │ +Dune::SimdMask │ │ │ │ │ +typename SimdMaskTypeTraits< V >::type SimdMask │ │ │ │ │ +A simd vector of truth values corresponding to a simd vector V. │ │ │ │ │ +Definition simd.hh:270 │ │ │ │ │ +Dune::lane │ │ │ │ │ +T lane(std::size_t l, const T &v) │ │ │ │ │ +access a lane of a simd vector (scalar version) │ │ │ │ │ +Definition simd.hh:366 │ │ │ │ │ +Dune::swap │ │ │ │ │ +void swap(T &v1, T &v2, bool mask) │ │ │ │ │ +Definition simd.hh:472 │ │ │ │ │ +Dune::assign │ │ │ │ │ +void assign(T &dst, const T &src, bool mask) │ │ │ │ │ +masked Simd assignment (scalar version) │ │ │ │ │ +Definition simd.hh:447 │ │ │ │ │ +Dune::cond │ │ │ │ │ +const T1 cond(bool b, const T1 &v1, const T2 &v2) │ │ │ │ │ +conditional evaluate │ │ │ │ │ +Definition conditional.hh:28 │ │ │ │ │ +Dune::max_value │ │ │ │ │ +T max_value(const AlignedNumber< T, align > &val) │ │ │ │ │ +Definition debugalign.hh:494 │ │ │ │ │ +Dune::min_value │ │ │ │ │ +T min_value(const AlignedNumber< T, align > &val) │ │ │ │ │ +Definition debugalign.hh:500 │ │ │ │ │ +Dune::lanes │ │ │ │ │ +std::size_t lanes(const T &) │ │ │ │ │ +get the number of lanes of a simd vector (scalar version) │ │ │ │ │ +Definition simd.hh:362 │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber │ │ │ │ │ +aligned wrappers for arithmetic types │ │ │ │ │ +Definition debugalign.hh:128 │ │ │ │ │ +Dune::SimdScalarTypeTraits │ │ │ │ │ +Definition simd.hh:202 │ │ │ │ │ +Dune::SimdScalarTypeTraits::type │ │ │ │ │ +T type │ │ │ │ │ +Definition simd.hh:203 │ │ │ │ │ +Dune::SimdScalarTypeTraits<_AlignedNumber<_T,_align_>_>::type │ │ │ │ │ +T type │ │ │ │ │ +Definition simd.hh:230 │ │ │ │ │ +Dune::SimdIndexTypeTraits │ │ │ │ │ +Definition simd.hh:234 │ │ │ │ │ +Dune::SimdIndexTypeTraits::type │ │ │ │ │ +std::size_t type │ │ │ │ │ +Definition simd.hh:235 │ │ │ │ │ +Dune::SimdMaskTypeTraits │ │ │ │ │ +Definition simd.hh:261 │ │ │ │ │ +Dune::SimdMaskTypeTraits::type │ │ │ │ │ +bool type │ │ │ │ │ +Definition simd.hh:262 │ │ │ │ │ +vc.hh │ │ │ │ │ +SIMD abstractions for Vc. │ │ │ │ │ +DUNE_SIMD_VC_ASSIGNMENT │ │ │ │ │ +#define DUNE_SIMD_VC_ASSIGNMENT(OP) │ │ │ │ │ +Definition simd/vc.hh:224 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00035.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: ios_state.hh File Reference │ │ │ │ +dune-common: typelist.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -71,40 +71,87 @@ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
ios_state.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Typedefs | │ │ │ │ +Functions
│ │ │ │ +
typelist.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

Utility class for storing and resetting stream attributes. │ │ │ │ -More...

│ │ │ │ -
#include <ios>
│ │ │ │ +
#include <type_traits>
│ │ │ │ +#include <tuple>
│ │ │ │ +#include <utility>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::ios_base_all_saver
 Utility class for storing and resetting stream attributes. More...
struct  Dune::MetaType< T >
 A type that refers to another type. More...
 
struct  Dune::IsTypeList< T >
 Check if given type is a TypeList. More...
 
struct  Dune::IsTypeList< TypeList< T... > >
 Check if given type is a TypeList. More...
 
struct  Dune::IsEmptyTypeList< T >
 Check if given type is an empty TypeList. More...
 
struct  Dune::TypeListSize< T >
 
struct  Dune::TypeListSize< TypeList< T... > >
 Get size of TypeList. More...
 
struct  Dune::TypeListElement< i, T >
 
struct  Dune::TypeListElement< i, TypeList< T... > >
 Get element of TypeList. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Typedefs

template<class... T>
using Dune::TypeList = std::tuple< MetaType< T >... >
 A simple type list.
 
template<std::size_t i, class T >
using Dune::TypeListEntry_t = typename TypeListElement< i, T >::type
 Shortcut for TypeListElement<i, T>::type;.
 
template<template< class... > class Target, class TL >
using Dune::UnpackTypeList_t = typename Impl::UnpackTypeList< Target, TL >::type
 Unpack Dune::TypeList.
 
template<template< class... > class Target, class... T>
using Dune::UniqueTypes_t = typename Impl::UniqueTypesHelper< Target, TypeList< T... > >::type
 Remove duplicates from a list of types.
 
template<class NonUniqueTypeList >
using Dune::UniqueTypeList_t = typename Impl::UniqueTypesHelper< TypeList, NonUniqueTypeList >::type
 Remove duplicates from a Dune::TypeList.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

template<class... T>
constexpr auto Dune::uniqueTypeList (TypeList< T... > list)
 Remove duplicates from a Dune::TypeList.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Utility class for storing and resetting stream attributes.

│ │ │ │ -
Author
Markus Blatt
│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,26 +1,70 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -ios_state.hh File Reference │ │ │ │ │ -Common │ │ │ │ │ -Utility class for storing and resetting stream attributes. More... │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Typedefs | Functions │ │ │ │ │ +typelist.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::ios_base_all_saver │ │ │ │ │ -  Utility class for storing and resetting stream attributes. More... │ │ │ │ │ +struct   Dune::MetaType<_T_> │ │ │ │ │ +  A type that refers to another type. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::IsTypeList<_T_> │ │ │ │ │ +  Check if given type is a TypeList. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::IsTypeList<_TypeList<_T..._>_> │ │ │ │ │ +  Check if given type is a TypeList. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::IsEmptyTypeList<_T_> │ │ │ │ │ +  Check if given type is an empty TypeList. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::TypeListSize<_T_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::TypeListSize<_TypeList<_T..._>_> │ │ │ │ │ +  Get size of TypeList. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::TypeListElement<_i,_T_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::TypeListElement<_i,_TypeList<_T..._>_> │ │ │ │ │ +  Get element of TypeList. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Utility class for storing and resetting stream attributes. │ │ │ │ │ - Author │ │ │ │ │ - Markus Blatt │ │ │ │ │ +Typedefs │ │ │ │ │ +template │ │ │ │ │ +using  Dune::TypeList = std::tuple< MetaType< T >... > │ │ │ │ │ +  A simple type list. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +using  Dune::TypeListEntry_t = typename TypeListElement< i, T >::type │ │ │ │ │ +  Shortcut for TypeListElement::type;. │ │ │ │ │ +  │ │ │ │ │ +template class Target, class TL > │ │ │ │ │ +using  Dune::UnpackTypeList_t = typename Impl::UnpackTypeList< Target, TL >:: │ │ │ │ │ + type │ │ │ │ │ +  Unpack Dune::TypeList. │ │ │ │ │ +  │ │ │ │ │ +template class Target, class... T> │ │ │ │ │ +using  Dune::UniqueTypes_t = typename Impl::UniqueTypesHelper< Target, │ │ │ │ │ + TypeList< T... > >::type │ │ │ │ │ +  Remove duplicates from a list of types. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +using  Dune::UniqueTypeList_t = typename Impl::UniqueTypesHelper< TypeList, │ │ │ │ │ + NonUniqueTypeList >::type │ │ │ │ │ +  Remove duplicates from a Dune::TypeList. │ │ │ │ │ +  │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ +constexpr auto  Dune::uniqueTypeList (TypeList< T... > list) │ │ │ │ │ +  Remove duplicates from a Dune::TypeList. │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00035_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: ios_state.hh Source File │ │ │ │ +dune-common: typelist.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,55 +74,148 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
ios_state.hh
│ │ │ │ +
typelist.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_IOS_STATE_HH
│ │ │ │ -
6#define DUNE_COMMON_IOS_STATE_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_TYPELIST_HH
│ │ │ │ +
6#define DUNE_COMMON_TYPELIST_HH
│ │ │ │
7
│ │ │ │ -
8#include <ios>
│ │ │ │ -
9
│ │ │ │ -
10namespace Dune {
│ │ │ │ +
8#include <type_traits>
│ │ │ │ +
9#include <tuple>
│ │ │ │ +
10#include <utility>
│ │ │ │ +
11
│ │ │ │ +
12namespace Dune {
│ │ │ │ +
13
│ │ │ │ +
32 template<class T>
│ │ │ │
│ │ │ │ - │ │ │ │ -
34 {
│ │ │ │ -
35 public:
│ │ │ │ -
37 typedef std::ios_base state_type;
│ │ │ │ -
38
│ │ │ │ - │ │ │ │ -
49
│ │ │ │ - │ │ │ │ -
54
│ │ │ │ -
61 void restore();
│ │ │ │ -
62
│ │ │ │ -
63 private:
│ │ │ │ -
65 state_type& ios;
│ │ │ │ -
67 state_type::fmtflags oldflags;
│ │ │ │ -
69 std::streamsize oldprec;
│ │ │ │ -
71 std::streamsize oldwidth;
│ │ │ │ -
72 };
│ │ │ │ -
│ │ │ │ -
73
│ │ │ │ -
75}
│ │ │ │ -
76
│ │ │ │ -
77#endif // DUNE_COMMON_IOS_STATE_HH
│ │ │ │ -
~ios_base_all_saver()
Destructor that restores the flags stored by the constructor.
Definition ios_state.cc:20
│ │ │ │ -
void restore()
Restore flags now.
Definition ios_state.cc:25
│ │ │ │ -
std::ios_base state_type
Export type of object we save the state for.
Definition ios_state.hh:37
│ │ │ │ +
33 struct MetaType {
│ │ │ │ +
35 using type = T;
│ │ │ │ +
36 };
│ │ │ │ +
│ │ │ │ +
37
│ │ │ │ +
86 template<class... T>
│ │ │ │ +
87 using TypeList = std::tuple<MetaType<T>...>;
│ │ │ │ +
88
│ │ │ │ +
89
│ │ │ │ +
90
│ │ │ │ +
99 template<class T>
│ │ │ │ +
100 struct IsTypeList : std::false_type {};
│ │ │ │ +
101
│ │ │ │ +
107 template<class... T>
│ │ │ │ +
108 struct IsTypeList<TypeList<T...> > : std::true_type {};
│ │ │ │ +
109
│ │ │ │ +
110
│ │ │ │ +
111
│ │ │ │ +
120 template<class T>
│ │ │ │ +
121 struct IsEmptyTypeList : std::is_same<T, TypeList<> > {};
│ │ │ │ +
122
│ │ │ │ +
123
│ │ │ │ +
124
│ │ │ │ +
125 template<class T>
│ │ │ │ +
126 struct TypeListSize {};
│ │ │ │ +
127
│ │ │ │ +
136 template<class... T>
│ │ │ │ +
137 struct TypeListSize<TypeList<T...>> : std::integral_constant<std::size_t, sizeof...(T)> {};
│ │ │ │ +
138
│ │ │ │ +
139
│ │ │ │ +
140
│ │ │ │ +
141 template<std::size_t i, class T>
│ │ │ │ + │ │ │ │ +
143
│ │ │ │ +
149 template<std::size_t i, class... T>
│ │ │ │ +
│ │ │ │ +
150 struct TypeListElement<i, TypeList<T...>>
│ │ │ │ +
151 {
│ │ │ │ +
157 using type = typename std::tuple_element<i, std::tuple<T...>>::type;
│ │ │ │ +
158
│ │ │ │ +
164 using Type = type;
│ │ │ │ +
165 };
│ │ │ │ +
│ │ │ │ +
166
│ │ │ │ +
170 template<std::size_t i, class T>
│ │ │ │ + │ │ │ │ +
172
│ │ │ │ +
173 namespace Impl {
│ │ │ │ +
174
│ │ │ │ +
175 template<template<class...> class Target, class ToDoList, class... Processed>
│ │ │ │ +
176 struct UniqueTypesHelper;
│ │ │ │ +
177
│ │ │ │ +
178 template<template<class...> class Target, class... Processed>
│ │ │ │ +
179 struct UniqueTypesHelper<Target, TypeList<>, Processed...>
│ │ │ │ +
180 {
│ │ │ │ +
181 using type = Target<Processed...>;
│ │ │ │ +
182 };
│ │ │ │ +
183
│ │ │ │ +
184 template<template<class...> class Target, class T0, class... T, class... Processed>
│ │ │ │ +
185 struct UniqueTypesHelper<Target, TypeList<T0, T...>, Processed...>
│ │ │ │ +
186 {
│ │ │ │ +
187 using type = std::conditional_t<
│ │ │ │ +
188 std::disjunction<std::is_same<T0, Processed>...>::value,
│ │ │ │ +
189 typename UniqueTypesHelper<Target, TypeList<T...>, Processed...>::type,
│ │ │ │ +
190 typename UniqueTypesHelper<Target, TypeList<T...>, T0, Processed...>::type>;
│ │ │ │ +
191 };
│ │ │ │ +
192
│ │ │ │ +
193 // Helper for unpacking Dune::TypeList
│ │ │ │ +
194 template<template<class...> class Target, class TL>
│ │ │ │ +
195 struct UnpackTypeList;
│ │ │ │ +
196
│ │ │ │ +
197 template<template<class...> class Target, class... T>
│ │ │ │ +
198 struct UnpackTypeList<Target, Dune::TypeList<T...>>
│ │ │ │ +
199 {
│ │ │ │ +
200 using type = Target<T...>;
│ │ │ │ +
201 };
│ │ │ │ +
202
│ │ │ │ +
203 } // namespace Impl
│ │ │ │ +
204
│ │ │ │ +
209 template<template<class...> class Target, class TL>
│ │ │ │ +
210 using UnpackTypeList_t = typename Impl::UnpackTypeList<Target, TL>::type;
│ │ │ │ +
211
│ │ │ │ +
219 template<template<class...> class Target, class... T>
│ │ │ │ +
220 using UniqueTypes_t = typename Impl::UniqueTypesHelper<Target, TypeList<T...>>::type;
│ │ │ │ +
221
│ │ │ │ +
227 template<class NonUniqueTypeList>
│ │ │ │ +
228 using UniqueTypeList_t = typename Impl::UniqueTypesHelper<TypeList, NonUniqueTypeList>::type;
│ │ │ │ +
229
│ │ │ │ +
235 template<class... T>
│ │ │ │ +
│ │ │ │ +
236 constexpr auto uniqueTypeList(TypeList<T...> list)
│ │ │ │ +
237 {
│ │ │ │ +
238 return typename Impl::UniqueTypesHelper<TypeList, TypeList<T...>>::type{};
│ │ │ │ +
239 }
│ │ │ │ +
│ │ │ │ +
240
│ │ │ │ +
241
│ │ │ │ +
242
│ │ │ │ +
243} // namespace Dune
│ │ │ │ +
244
│ │ │ │ +
245#endif // DUNE_COMMON_TYPELIST_HH
│ │ │ │ +
std::tuple< MetaType< T >... > TypeList
A simple type list.
Definition typelist.hh:87
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Utility class for storing and resetting stream attributes.
Definition ios_state.hh:34
│ │ │ │ +
typename Impl::UnpackTypeList< Target, TL >::type UnpackTypeList_t
Unpack Dune::TypeList.
Definition typelist.hh:210
│ │ │ │ +
constexpr auto uniqueTypeList(TypeList< T... > list)
Remove duplicates from a Dune::TypeList.
Definition typelist.hh:236
│ │ │ │ +
typename Impl::UniqueTypesHelper< Target, TypeList< T... > >::type UniqueTypes_t
Remove duplicates from a list of types.
Definition typelist.hh:220
│ │ │ │ +
typename Impl::UniqueTypesHelper< TypeList, NonUniqueTypeList >::type UniqueTypeList_t
Remove duplicates from a Dune::TypeList.
Definition typelist.hh:228
│ │ │ │ +
typename TypeListElement< i, T >::type TypeListEntry_t
Shortcut for TypeListElement<i, T>::type;.
Definition typelist.hh:171
│ │ │ │ +
A type that refers to another type.
Definition typelist.hh:33
│ │ │ │ +
T type
The referred-to type.
Definition typelist.hh:35
│ │ │ │ +
Check if given type is a TypeList.
Definition typelist.hh:100
│ │ │ │ +
Check if given type is an empty TypeList.
Definition typelist.hh:121
│ │ │ │ +
Definition typelist.hh:126
│ │ │ │ +
Definition typelist.hh:142
│ │ │ │ +
typename std::tuple_element< i, std::tuple< T... > >::type type
Export type of i-th element in TypeList.
Definition typelist.hh:157
│ │ │ │ +
type Type
Export type of i-th element in TypeList.
Definition typelist.hh:164
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,60 +1,181 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -ios_state.hh │ │ │ │ │ +typelist.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_IOS_STATE_HH │ │ │ │ │ -6#define DUNE_COMMON_IOS_STATE_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_TYPELIST_HH │ │ │ │ │ +6#define DUNE_COMMON_TYPELIST_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ -9 │ │ │ │ │ -10namespace Dune { │ │ │ │ │ -33 class ios_base_all_saver │ │ │ │ │ -34 { │ │ │ │ │ -35 public: │ │ │ │ │ -37 typedef std::ios_base state_type; │ │ │ │ │ -38 │ │ │ │ │ -48 ios_base_all_saver(state_type& ios_); │ │ │ │ │ -49 │ │ │ │ │ -53 ~ios_base_all_saver(); │ │ │ │ │ -54 │ │ │ │ │ -61 void restore(); │ │ │ │ │ -62 │ │ │ │ │ -63 private: │ │ │ │ │ -65 state_type& ios; │ │ │ │ │ -67 state_type::fmtflags oldflags; │ │ │ │ │ -69 std::streamsize oldprec; │ │ │ │ │ -71 std::streamsize oldwidth; │ │ │ │ │ -72 }; │ │ │ │ │ -73 │ │ │ │ │ -75} │ │ │ │ │ -76 │ │ │ │ │ -77#endif // DUNE_COMMON_IOS_STATE_HH │ │ │ │ │ -Dune::ios_base_all_saver::~ios_base_all_saver │ │ │ │ │ -~ios_base_all_saver() │ │ │ │ │ -Destructor that restores the flags stored by the constructor. │ │ │ │ │ -Definition ios_state.cc:20 │ │ │ │ │ -Dune::ios_base_all_saver::restore │ │ │ │ │ -void restore() │ │ │ │ │ -Restore flags now. │ │ │ │ │ -Definition ios_state.cc:25 │ │ │ │ │ -Dune::ios_base_all_saver::state_type │ │ │ │ │ -std::ios_base state_type │ │ │ │ │ -Export type of object we save the state for. │ │ │ │ │ -Definition ios_state.hh:37 │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11 │ │ │ │ │ +12namespace Dune { │ │ │ │ │ +13 │ │ │ │ │ +32 template │ │ │ │ │ +33 struct MetaType { │ │ │ │ │ +35 using type = T; │ │ │ │ │ +36 }; │ │ │ │ │ +37 │ │ │ │ │ +86 template │ │ │ │ │ +87 using TypeList = std::tuple...>; │ │ │ │ │ +88 │ │ │ │ │ +89 │ │ │ │ │ +90 │ │ │ │ │ +99 template │ │ │ │ │ +100 struct IsTypeList : std::false_type {}; │ │ │ │ │ +101 │ │ │ │ │ +107 template │ │ │ │ │ +108 struct IsTypeList > : std::true_type {}; │ │ │ │ │ +109 │ │ │ │ │ +110 │ │ │ │ │ +111 │ │ │ │ │ +120 template │ │ │ │ │ +121 struct IsEmptyTypeList : std::is_same > {}; │ │ │ │ │ +122 │ │ │ │ │ +123 │ │ │ │ │ +124 │ │ │ │ │ +125 template │ │ │ │ │ +126 struct TypeListSize {}; │ │ │ │ │ +127 │ │ │ │ │ +136 template │ │ │ │ │ +137 struct TypeListSize> : std::integral_constant {}; │ │ │ │ │ +138 │ │ │ │ │ +139 │ │ │ │ │ +140 │ │ │ │ │ +141 template │ │ │ │ │ +142 struct TypeListElement {}; │ │ │ │ │ +143 │ │ │ │ │ +149 template │ │ │ │ │ +150 struct TypeListElement> │ │ │ │ │ +151 { │ │ │ │ │ +157 using type = typename std::tuple_element>::type; │ │ │ │ │ +158 │ │ │ │ │ +164 using Type = type; │ │ │ │ │ +165 }; │ │ │ │ │ +166 │ │ │ │ │ +170 template │ │ │ │ │ +171 using TypeListEntry_t = typename TypeListElement::type; │ │ │ │ │ +172 │ │ │ │ │ +173 namespace Impl { │ │ │ │ │ +174 │ │ │ │ │ +175 template class Target, class ToDoList, class... │ │ │ │ │ +Processed> │ │ │ │ │ +176 struct UniqueTypesHelper; │ │ │ │ │ +177 │ │ │ │ │ +178 template class Target, class... Processed> │ │ │ │ │ +179 struct UniqueTypesHelper, Processed...> │ │ │ │ │ +180 { │ │ │ │ │ +181 using type = Target; │ │ │ │ │ +182 }; │ │ │ │ │ +183 │ │ │ │ │ +184 template class Target, class T0, class... T, class... │ │ │ │ │ +Processed> │ │ │ │ │ +185 struct UniqueTypesHelper, Processed...> │ │ │ │ │ +186 { │ │ │ │ │ +187 using type = std::conditional_t< │ │ │ │ │ +188 std::disjunction...>::value, │ │ │ │ │ +189 typename UniqueTypesHelper, Processed...>::type, │ │ │ │ │ +190 typename UniqueTypesHelper, T0, Processed...>:: │ │ │ │ │ +type>; │ │ │ │ │ +191 }; │ │ │ │ │ +192 │ │ │ │ │ +193 // Helper for unpacking Dune::TypeList │ │ │ │ │ +194 template class Target, class TL> │ │ │ │ │ +195 struct UnpackTypeList; │ │ │ │ │ +196 │ │ │ │ │ +197 template class Target, class... T> │ │ │ │ │ +198 struct UnpackTypeList> │ │ │ │ │ +199 { │ │ │ │ │ +200 using type = Target; │ │ │ │ │ +201 }; │ │ │ │ │ +202 │ │ │ │ │ +203 } // namespace Impl │ │ │ │ │ +204 │ │ │ │ │ +209 template class Target, class TL> │ │ │ │ │ +210 using UnpackTypeList_t = typename Impl::UnpackTypeList::type; │ │ │ │ │ +211 │ │ │ │ │ +219 template class Target, class... T> │ │ │ │ │ +220 using UniqueTypes_t = typename Impl::UniqueTypesHelper>::type; │ │ │ │ │ +221 │ │ │ │ │ +227 template │ │ │ │ │ +228 using UniqueTypeList_t = typename Impl::UniqueTypesHelper::type; │ │ │ │ │ +229 │ │ │ │ │ +235 template │ │ │ │ │ +236 constexpr auto uniqueTypeList(TypeList list) │ │ │ │ │ +237 { │ │ │ │ │ +238 return typename Impl::UniqueTypesHelper>::type{}; │ │ │ │ │ +239 } │ │ │ │ │ +240 │ │ │ │ │ +241 │ │ │ │ │ +242 │ │ │ │ │ +243} // namespace Dune │ │ │ │ │ +244 │ │ │ │ │ +245#endif // DUNE_COMMON_TYPELIST_HH │ │ │ │ │ +Dune::TypeList │ │ │ │ │ +std::tuple< MetaType< T >... > TypeList │ │ │ │ │ +A simple type list. │ │ │ │ │ +Definition typelist.hh:87 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::ios_base_all_saver │ │ │ │ │ -Utility class for storing and resetting stream attributes. │ │ │ │ │ -Definition ios_state.hh:34 │ │ │ │ │ +Dune::UnpackTypeList_t │ │ │ │ │ +typename Impl::UnpackTypeList< Target, TL >::type UnpackTypeList_t │ │ │ │ │ +Unpack Dune::TypeList. │ │ │ │ │ +Definition typelist.hh:210 │ │ │ │ │ +Dune::uniqueTypeList │ │ │ │ │ +constexpr auto uniqueTypeList(TypeList< T... > list) │ │ │ │ │ +Remove duplicates from a Dune::TypeList. │ │ │ │ │ +Definition typelist.hh:236 │ │ │ │ │ +Dune::UniqueTypes_t │ │ │ │ │ +typename Impl::UniqueTypesHelper< Target, TypeList< T... > >::type UniqueTypes_ │ │ │ │ │ +t │ │ │ │ │ +Remove duplicates from a list of types. │ │ │ │ │ +Definition typelist.hh:220 │ │ │ │ │ +Dune::UniqueTypeList_t │ │ │ │ │ +typename Impl::UniqueTypesHelper< TypeList, NonUniqueTypeList >::type │ │ │ │ │ +UniqueTypeList_t │ │ │ │ │ +Remove duplicates from a Dune::TypeList. │ │ │ │ │ +Definition typelist.hh:228 │ │ │ │ │ +Dune::TypeListEntry_t │ │ │ │ │ +typename TypeListElement< i, T >::type TypeListEntry_t │ │ │ │ │ +Shortcut for TypeListElement::type;. │ │ │ │ │ +Definition typelist.hh:171 │ │ │ │ │ +Dune::MetaType │ │ │ │ │ +A type that refers to another type. │ │ │ │ │ +Definition typelist.hh:33 │ │ │ │ │ +Dune::MetaType::type │ │ │ │ │ +T type │ │ │ │ │ +The referred-to type. │ │ │ │ │ +Definition typelist.hh:35 │ │ │ │ │ +Dune::IsTypeList │ │ │ │ │ +Check if given type is a TypeList. │ │ │ │ │ +Definition typelist.hh:100 │ │ │ │ │ +Dune::IsEmptyTypeList │ │ │ │ │ +Check if given type is an empty TypeList. │ │ │ │ │ +Definition typelist.hh:121 │ │ │ │ │ +Dune::TypeListSize │ │ │ │ │ +Definition typelist.hh:126 │ │ │ │ │ +Dune::TypeListElement │ │ │ │ │ +Definition typelist.hh:142 │ │ │ │ │ +Dune::TypeListElement<_i,_TypeList<_T..._>_>::type │ │ │ │ │ +typename std::tuple_element< i, std::tuple< T... > >::type type │ │ │ │ │ +Export type of i-th element in TypeList. │ │ │ │ │ +Definition typelist.hh:157 │ │ │ │ │ +Dune::TypeListElement<_i,_TypeList<_T..._>_>::Type │ │ │ │ │ +type Type │ │ │ │ │ +Export type of i-th element in TypeList. │ │ │ │ │ +Definition typelist.hh:164 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00038.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: variablesizecommunicator.hh File Reference │ │ │ │ +dune-common: overloadset.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,79 +65,47 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ -Namespaces
│ │ │ │ -
variablesizecommunicator.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
overloadset.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

A communicator that only needs to know the number of elements per index at the sender side. │ │ │ │ -More...

│ │ │ │ -
#include <algorithm>
│ │ │ │ -#include <cassert>
│ │ │ │ -#include <cstddef>
│ │ │ │ -#include <functional>
│ │ │ │ -#include <map>
│ │ │ │ -#include <memory>
│ │ │ │ -#include <utility>
│ │ │ │ -#include <vector>
│ │ │ │ -#include <mpi.h>
│ │ │ │ -#include <dune/common/concept.hh>
│ │ │ │ -#include <dune/common/parallel/interface.hh>
│ │ │ │ -#include <dune/common/parallel/mpitraits.hh>
│ │ │ │ +
#include <utility>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

struct  Dune::Concept::HasFixedSize
 
class  Dune::VariableSizeCommunicator< Allocator >
 A buffered communicator where the amount of data sent does not have to be known a priori. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Concept
 Namespace for concepts.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

template<class... F>
auto Dune::overload (F &&... f)
 Create an overload set.
 
template<class... F>
auto Dune::orderedOverload (F &&... f)
 Create an ordered overload set.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

A communicator that only needs to know the number of elements per index at the sender side.

│ │ │ │ -
Author
Markus Blatt
│ │ │ │ -

Variable Documentation

│ │ │ │ - │ │ │ │ -

◆ fixedSize

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
std::size_t fixedSize
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

The number of data items per index if it is fixed, 0 otherwise.

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,50 +1,27 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -variablesizecommunicator.hh File Reference │ │ │ │ │ -Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ -A communicator that only needs to know the number of elements per index at the │ │ │ │ │ -sender side. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +overloadset.hh File Reference │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ -Classes │ │ │ │ │ -struct   Dune::Concept::HasFixedSize │ │ │ │ │ -  │ │ │ │ │ - class   Dune::VariableSizeCommunicator<_Allocator_> │ │ │ │ │ -  A buffered communicator where the amount of data sent does not have to │ │ │ │ │ - be known a priori. More... │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace   Dune::Concept │ │ │ │ │ -  Namespace for concepts. │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ +auto  Dune::overload (F &&... f) │ │ │ │ │ +  Create an overload set. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +auto  Dune::orderedOverload (F &&... f) │ │ │ │ │ +  Create an ordered overload set. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -A communicator that only needs to know the number of elements per index at the │ │ │ │ │ -sender side. │ │ │ │ │ - Author │ │ │ │ │ - Markus Blatt │ │ │ │ │ -***** Variable Documentation ***** │ │ │ │ │ -***** ◆ fixedSize ***** │ │ │ │ │ -std::size_t fixedSize │ │ │ │ │ -The number of data items per index if it is fixed, 0 otherwise. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00038_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: variablesizecommunicator.hh Source File │ │ │ │ +dune-common: overloadset.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,914 +70,143 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
variablesizecommunicator.hh
│ │ │ │ +
overloadset.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PARALLEL_VARIABLESIZECOMMUNICATOR_HH
│ │ │ │ -
6#define DUNE_COMMON_PARALLEL_VARIABLESIZECOMMUNICATOR_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_OVERLOADSET_HH
│ │ │ │ +
6#define DUNE_COMMON_OVERLOADSET_HH
│ │ │ │
7
│ │ │ │ -
8#if HAVE_MPI
│ │ │ │ -
9
│ │ │ │ -
10#include <algorithm>
│ │ │ │ -
11#include <cassert>
│ │ │ │ -
12#include <cstddef>
│ │ │ │ -
13#include <functional>
│ │ │ │ -
14#include <map>
│ │ │ │ -
15#include <memory>
│ │ │ │ -
16#include <utility>
│ │ │ │ -
17#include <vector>
│ │ │ │ -
18
│ │ │ │ -
19#include <mpi.h>
│ │ │ │ +
8#include <utility>
│ │ │ │ +
9#include <type_traits>
│ │ │ │ + │ │ │ │ +
11
│ │ │ │ +
12namespace Dune {
│ │ │ │ +
13
│ │ │ │ +
14namespace Impl {
│ │ │ │ +
15
│ │ │ │ +
16 template<typename... F>
│ │ │ │ +
17 class OverloadSet
│ │ │ │ +
18 : public F...
│ │ │ │ +
19 {
│ │ │ │
20
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
24
│ │ │ │ -
37namespace Dune
│ │ │ │ -
38{
│ │ │ │ -
39
│ │ │ │ -
40namespace Concept {
│ │ │ │ -
41
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
43 template <typename H> auto require(H &&h) -> decltype(h.fixedSize());
│ │ │ │ -
44};
│ │ │ │ -
│ │ │ │ -
45
│ │ │ │ -
46} // namespace Concept
│ │ │ │ -
47
│ │ │ │ -
48namespace Impl {
│ │ │ │ -
49
│ │ │ │ -
50template <typename H,
│ │ │ │ -
51 std::enable_if_t<models<Concept::HasFixedSize, H>(), int> = 0>
│ │ │ │ -
52constexpr bool callFixedSize(H &&handle) {
│ │ │ │ -
53 return handle.fixedSize();
│ │ │ │ -
54}
│ │ │ │ -
55
│ │ │ │ -
56} // namespace Impl
│ │ │ │ -
57
│ │ │ │ -
58namespace
│ │ │ │ -
59{
│ │ │ │ -
64template<class T, class Allocator=std::allocator<T> >
│ │ │ │ -
65class MessageBuffer
│ │ │ │ -
66{
│ │ │ │ -
67public:
│ │ │ │ -
72 explicit MessageBuffer(int size)
│ │ │ │ -
73 : buffer_(new T[size]), size_(size), position_(0)
│ │ │ │ -
74 {}
│ │ │ │ -
79 explicit MessageBuffer(const MessageBuffer& o)
│ │ │ │ -
80 : buffer_(new T[o.size_]), size_(o.size_), position_(o.position_)
│ │ │ │ -
81 {
│ │ │ │ -
82 }
│ │ │ │ -
84 ~MessageBuffer()
│ │ │ │ -
85 {
│ │ │ │ -
86 delete[] buffer_;
│ │ │ │ -
87 }
│ │ │ │ -
92 void write(const T& data)
│ │ │ │ -
93 {
│ │ │ │ -
94 buffer_[position_++]=data;
│ │ │ │ -
95 }
│ │ │ │ -
96
│ │ │ │ -
101 void read(T& data)
│ │ │ │ -
102 {
│ │ │ │ -
103 data=buffer_[position_++];
│ │ │ │ -
104 }
│ │ │ │ -
105
│ │ │ │ -
111 void reset()
│ │ │ │ -
112 {
│ │ │ │ -
113 position_=0;
│ │ │ │ -
114 }
│ │ │ │ -
115
│ │ │ │ -
120 bool finished()
│ │ │ │ -
121 {
│ │ │ │ -
122 return position_==size_;
│ │ │ │ -
123 }
│ │ │ │ +
21 public:
│ │ │ │ +
22
│ │ │ │ +
23 template<typename... FF>
│ │ │ │ +
24 OverloadSet(FF&&... ff)
│ │ │ │ +
25 : F(std::forward<FF>(ff))...
│ │ │ │ +
26 {}
│ │ │ │ +
27
│ │ │ │ +
28 using F::operator()...;
│ │ │ │ +
29
│ │ │ │ +
30 };
│ │ │ │ +
31
│ │ │ │ +
32} // end namespace Impl
│ │ │ │ +
33
│ │ │ │ +
34
│ │ │ │ +
35
│ │ │ │ +
60template<class... F>
│ │ │ │ +
│ │ │ │ +
61auto overload(F&&... f)
│ │ │ │ +
62{
│ │ │ │ +
63 return Impl::OverloadSet<std::decay_t<F>...>(std::forward<F>(f)...);
│ │ │ │ +
64}
│ │ │ │ +
│ │ │ │ +
65
│ │ │ │ +
66
│ │ │ │ +
67
│ │ │ │ +
68namespace Impl {
│ │ │ │ +
69
│ │ │ │ +
70 template<class F0, class... F>
│ │ │ │ +
71 class OrderedOverloadSet: public OrderedOverloadSet<F...>, F0
│ │ │ │ +
72 {
│ │ │ │ +
73 using Base = OrderedOverloadSet<F...>;
│ │ │ │ +
74 public:
│ │ │ │ +
75
│ │ │ │ +
76 template<class FF0, class... FF>
│ │ │ │ +
77 OrderedOverloadSet(FF0&& f0, FF&&... ff) :
│ │ │ │ +
78 Base(std::forward<FF>(ff)...),
│ │ │ │ +
79 F0(std::forward<FF0>(f0))
│ │ │ │ +
80 {}
│ │ │ │ +
81
│ │ │ │ +
82 // Forward to operator() of F0 if it can be called with the given arguments.
│ │ │ │ +
83 template<class... Args,
│ │ │ │ +
84 std::enable_if_t<IsCallable<F0(Args&&...)>::value, int> = 0>
│ │ │ │ +
85 decltype(auto) operator()(Args&&... args)
│ │ │ │ +
86 {
│ │ │ │ +
87 return F0::operator()(std::forward<Args>(args)...);
│ │ │ │ +
88 }
│ │ │ │ +
89
│ │ │ │ +
90 // Forward to operator() of base class if F0 cannot be called with the given
│ │ │ │ +
91 // arguments. In this case the base class will successively try operator()
│ │ │ │ +
92 // of all F... .
│ │ │ │ +
93 template<class... Args,
│ │ │ │ +
94 std::enable_if_t<not IsCallable<F0(Args&&...)>::value, int> = 0>
│ │ │ │ +
95 decltype(auto) operator()(Args&&... args)
│ │ │ │ +
96 {
│ │ │ │ +
97 return Base::operator()(std::forward<Args>(args)...);
│ │ │ │ +
98 }
│ │ │ │ +
99
│ │ │ │ +
100 };
│ │ │ │ +
101
│ │ │ │ +
102 template<class F0>
│ │ │ │ +
103 class OrderedOverloadSet<F0>: public F0
│ │ │ │ +
104 {
│ │ │ │ +
105 public:
│ │ │ │ +
106
│ │ │ │ +
107 template<class FF0>
│ │ │ │ +
108 OrderedOverloadSet(FF0&& f0) :
│ │ │ │ +
109 F0(std::forward<FF0>(f0))
│ │ │ │ +
110 {}
│ │ │ │ +
111
│ │ │ │ +
112 // Forward to operator() of F0. If it cannot be called with
│ │ │ │ +
113 // the given arguments a static assertion will fail.
│ │ │ │ +
114 template<class... Args>
│ │ │ │ +
115 decltype(auto) operator()(Args&&... args)
│ │ │ │ +
116 {
│ │ │ │ +
117 static_assert(IsCallable<F0(Args&&...)>::value,
│ │ │ │ +
118 "No matching overload found in OrderedOverloadSet");
│ │ │ │ +
119 return F0::operator()(std::forward<Args>(args)...);
│ │ │ │ +
120 }
│ │ │ │ +
121 };
│ │ │ │ +
122
│ │ │ │ +
123} // end namespace Impl
│ │ │ │
124
│ │ │ │ -
130 bool hasSpaceForItems(int noItems)
│ │ │ │ -
131 {
│ │ │ │ -
132 return position_+noItems<=size_;
│ │ │ │ -
133 }
│ │ │ │ -
138 std::size_t size() const
│ │ │ │ -
139 {
│ │ │ │ -
140 return size_;
│ │ │ │ -
141 }
│ │ │ │ -
146 operator T*()
│ │ │ │ -
147 {
│ │ │ │ -
148 return buffer_;
│ │ │ │ -
149 }
│ │ │ │ -
150
│ │ │ │ -
151private:
│ │ │ │ -
155 T* buffer_;
│ │ │ │ -
159 std::size_t size_;
│ │ │ │ -
163 std::size_t position_;
│ │ │ │ -
164};
│ │ │ │ -
165
│ │ │ │ -
169class InterfaceTracker
│ │ │ │ -
170{
│ │ │ │ -
171public:
│ │ │ │ -
177 InterfaceTracker(int rank, InterfaceInformation info, std::size_t fixedsize=0,
│ │ │ │ -
178 bool allocateSizes=false)
│ │ │ │ -
179 : fixedSize(fixedsize),rank_(rank), index_(), interface_(info), sizes_()
│ │ │ │ -
180 {
│ │ │ │ -
181 if(allocateSizes)
│ │ │ │ -
182 {
│ │ │ │ -
183 sizes_.resize(info.size());
│ │ │ │ -
184 }
│ │ │ │ -
185 }
│ │ │ │ -
186
│ │ │ │ -
190 void moveToNextIndex()
│ │ │ │ -
191 {
│ │ │ │ -
192 index_++;
│ │ │ │ -
193 assert(index_<=interface_.size());
│ │ │ │ -
194 skipZeroIndices();
│ │ │ │ -
195 }
│ │ │ │ -
200 void increment(std::size_t i)
│ │ │ │ -
201 {
│ │ │ │ -
202 index_+=i;
│ │ │ │ -
203 assert(index_<=interface_.size());
│ │ │ │ -
204 }
│ │ │ │ -
209 bool finished() const
│ │ │ │ -
210 {
│ │ │ │ -
211 return index_==interface_.size();
│ │ │ │ -
212 }
│ │ │ │ -
213
│ │ │ │ -
214 void skipZeroIndices()
│ │ │ │ -
215 {
│ │ │ │ -
216 // skip indices with size zero!
│ │ │ │ -
217 while(sizes_.size() && index_!=interface_.size() &&!size())
│ │ │ │ -
218 ++index_;
│ │ │ │ -
219 }
│ │ │ │ -
220
│ │ │ │ -
225 std::size_t index() const
│ │ │ │ -
226 {
│ │ │ │ -
227 return interface_[index_];
│ │ │ │ -
228 }
│ │ │ │ -
232 std::size_t size() const
│ │ │ │ -
233 {
│ │ │ │ -
234 assert(sizes_.size());
│ │ │ │ -
235 return sizes_[index_];
│ │ │ │ -
236 }
│ │ │ │ -
240 std::size_t* getSizesPointer()
│ │ │ │ -
241 {
│ │ │ │ -
242 return &sizes_[0];
│ │ │ │ -
243 }
│ │ │ │ -
248 bool empty() const
│ │ │ │ -
249 {
│ │ │ │ -
250 return !interface_.size();
│ │ │ │ -
251 }
│ │ │ │ -
252
│ │ │ │ -
257 std::size_t indicesLeft() const
│ │ │ │ -
258 {
│ │ │ │ -
259 return interface_.size()-index_;
│ │ │ │ -
260 }
│ │ │ │ -
264 std::size_t fixedSize;
│ │ │ │ -
268 int rank() const
│ │ │ │ -
269 {
│ │ │ │ -
270 return rank_;
│ │ │ │ -
271 }
│ │ │ │ -
275 std::size_t offset() const
│ │ │ │ -
276 {
│ │ │ │ -
277 return index_;
│ │ │ │ -
278 }
│ │ │ │ -
279private:
│ │ │ │ -
281 int rank_;
│ │ │ │ -
283 std::size_t index_;
│ │ │ │ -
285 InterfaceInformation interface_;
│ │ │ │ -
286 std::vector<std::size_t> sizes_;
│ │ │ │ -
287};
│ │ │ │ -
288
│ │ │ │ -
289
│ │ │ │ -
290} // end unnamed namespace
│ │ │ │ -
291
│ │ │ │ -
329template<class Allocator=std::allocator<std::pair<InterfaceInformation,InterfaceInformation> > >
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
331{
│ │ │ │ -
332public:
│ │ │ │ -
337 typedef std::map<int,std::pair<InterfaceInformation,InterfaceInformation>,
│ │ │ │ -
338 std::less<int>,
│ │ │ │ -
339 typename std::allocator_traits<Allocator>::template rebind_alloc< std::pair<const int,std::pair<InterfaceInformation,InterfaceInformation> > > > InterfaceMap;
│ │ │ │ -
340
│ │ │ │ -
341#ifndef DUNE_PARALLEL_MAX_COMMUNICATION_BUFFER_SIZE
│ │ │ │ -
│ │ │ │ -
348 VariableSizeCommunicator(MPI_Comm comm, const InterfaceMap& inf)
│ │ │ │ -
349 : maxBufferSize_(32768), interface_(&inf)
│ │ │ │ -
350 {
│ │ │ │ -
351 MPI_Comm_dup(comm, &communicator_);
│ │ │ │ -
352 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
358 : maxBufferSize_(32768), interface_(&inf.interfaces())
│ │ │ │ -
359 {
│ │ │ │ -
360 MPI_Comm_dup(inf.communicator(), &communicator_);
│ │ │ │ -
361 }
│ │ │ │ -
│ │ │ │ -
362#else
│ │ │ │ -
369 VariableSizeCommunicator(MPI_Comm comm, InterfaceMap& inf)
│ │ │ │ -
370 : maxBufferSize_(DUNE_PARALLEL_MAX_COMMUNICATION_BUFFER_SIZE),
│ │ │ │ -
371 interface_(&inf)
│ │ │ │ -
372 {
│ │ │ │ -
373 MPI_Comm_dup(comm, &communicator_);
│ │ │ │ -
374 }
│ │ │ │ -
379 VariableSizeCommunicator(const Interface& inf)
│ │ │ │ -
380 : maxBufferSize_(DUNE_PARALLEL_MAX_COMMUNICATION_BUFFER_SIZE),
│ │ │ │ -
381 interface_(&inf.interfaces())
│ │ │ │ -
382 {
│ │ │ │ -
383 MPI_Comm_dup(inf.communicator(), &communicator_);
│ │ │ │ -
384 }
│ │ │ │ -
385#endif
│ │ │ │ -
│ │ │ │ -
392 VariableSizeCommunicator(MPI_Comm comm, const InterfaceMap& inf, std::size_t max_buffer_size)
│ │ │ │ -
393 : maxBufferSize_(max_buffer_size), interface_(&inf)
│ │ │ │ -
394 {
│ │ │ │ -
395 MPI_Comm_dup(comm, &communicator_);
│ │ │ │ -
396 }
│ │ │ │ -
│ │ │ │ -
397
│ │ │ │ -
│ │ │ │ -
403 VariableSizeCommunicator(const Interface& inf, std::size_t max_buffer_size)
│ │ │ │ -
404 : maxBufferSize_(max_buffer_size), interface_(&inf.interfaces())
│ │ │ │ -
405 {
│ │ │ │ -
406 MPI_Comm_dup(inf.communicator(), &communicator_);
│ │ │ │ -
407 }
│ │ │ │ -
│ │ │ │ -
408
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
410 {
│ │ │ │ -
411 MPI_Comm_free(&communicator_);
│ │ │ │ -
412 }
│ │ │ │ -
│ │ │ │ -
413
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
419 maxBufferSize_ = other.maxBufferSize_;
│ │ │ │ -
420 interface_ = other.interface_;
│ │ │ │ -
421 MPI_Comm_dup(other.communicator_, &communicator_);
│ │ │ │ -
422 }
│ │ │ │ -
│ │ │ │ -
423
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
429 if(this == &other) // don't do anything if objects are the same
│ │ │ │ -
430 return *this;
│ │ │ │ -
431
│ │ │ │ -
432 maxBufferSize_ = other.maxBufferSize_;
│ │ │ │ -
433 interface_ = other.interface_;
│ │ │ │ -
434 MPI_Comm_free(&communicator_);
│ │ │ │ -
435 MPI_Comm_dup(other.communicator_, &communicator_);
│ │ │ │ -
436
│ │ │ │ -
437 return *this;
│ │ │ │ -
438 }
│ │ │ │ -
│ │ │ │ -
439
│ │ │ │ -
459 template<class DataHandle>
│ │ │ │ -
│ │ │ │ -
460 void forward(DataHandle& handle)
│ │ │ │ -
461 {
│ │ │ │ -
462 communicate<true>(handle);
│ │ │ │ -
463 }
│ │ │ │ -
│ │ │ │ -
464
│ │ │ │ -
484 template<class DataHandle>
│ │ │ │ -
│ │ │ │ -
485 void backward(DataHandle& handle)
│ │ │ │ -
486 {
│ │ │ │ -
487 communicate<false>(handle);
│ │ │ │ -
488 }
│ │ │ │ -
│ │ │ │ -
489
│ │ │ │ -
490private:
│ │ │ │ -
491 template<bool FORWARD, class DataHandle>
│ │ │ │ -
492 void communicateSizes(DataHandle& handle,
│ │ │ │ -
493 std::vector<InterfaceTracker>& recv_trackers);
│ │ │ │ -
494
│ │ │ │ -
501 template<bool forward,class DataHandle>
│ │ │ │ -
502 void communicate(DataHandle& handle);
│ │ │ │ -
512 template<bool FORWARD, class DataHandle>
│ │ │ │ -
513 void setupInterfaceTrackers(DataHandle& handle,
│ │ │ │ -
514 std::vector<InterfaceTracker>& send_trackers,
│ │ │ │ -
515 std::vector<InterfaceTracker>& recv_trackers);
│ │ │ │ -
523 template<bool FORWARD, class DataHandle>
│ │ │ │ -
524 void communicateFixedSize(DataHandle& handle);
│ │ │ │ -
532 template<bool FORWARD, class DataHandle>
│ │ │ │ -
533 void communicateVariableSize(DataHandle& handle);
│ │ │ │ -
540 std::size_t maxBufferSize_;
│ │ │ │ -
548 const InterfaceMap* interface_;
│ │ │ │ -
554 MPI_Comm communicator_;
│ │ │ │ -
555};
│ │ │ │ -
│ │ │ │ -
556
│ │ │ │ -
558namespace
│ │ │ │ -
559{
│ │ │ │ -
563template<class DataHandle>
│ │ │ │ -
564class SizeDataHandle
│ │ │ │ -
565{
│ │ │ │ -
566public:
│ │ │ │ -
567 typedef std::size_t DataType;
│ │ │ │ -
568
│ │ │ │ -
569 SizeDataHandle(DataHandle& data,
│ │ │ │ -
570 std::vector<InterfaceTracker>& trackers)
│ │ │ │ -
571 : data_(data), trackers_(trackers), index_()
│ │ │ │ -
572 {}
│ │ │ │ -
573 bool fixedSize()
│ │ │ │ -
574 {
│ │ │ │ -
575 return true;
│ │ │ │ -
576 }
│ │ │ │ -
577 std::size_t size([[maybe_unused]] std::size_t i)
│ │ │ │ -
578 {
│ │ │ │ -
579 return 1;
│ │ │ │ -
580 }
│ │ │ │ -
581 template<class B>
│ │ │ │ -
582 void gather(B& buf, int i)
│ │ │ │ -
583 {
│ │ │ │ -
584 buf.write(data_.size(i));
│ │ │ │ -
585 }
│ │ │ │ -
586 void setReceivingIndex(std::size_t i)
│ │ │ │ -
587 {
│ │ │ │ -
588 index_=i;
│ │ │ │ -
589 }
│ │ │ │ -
590 std::size_t* getSizesPointer()
│ │ │ │ -
591 {
│ │ │ │ -
592 return trackers_[index_].getSizesPointer();
│ │ │ │ -
593 }
│ │ │ │ -
594
│ │ │ │ -
595private:
│ │ │ │ -
596 DataHandle& data_;
│ │ │ │ -
597 std::vector<InterfaceTracker>& trackers_;
│ │ │ │ -
598 int index_;
│ │ │ │ -
599};
│ │ │ │ -
600
│ │ │ │ -
601template<class T>
│ │ │ │ -
602void setReceivingIndex(T&, int)
│ │ │ │ -
603{}
│ │ │ │ -
604
│ │ │ │ -
605template<class T>
│ │ │ │ -
606void setReceivingIndex(SizeDataHandle<T>& t, int i)
│ │ │ │ -
607{
│ │ │ │ -
608 t.setReceivingIndex(i);
│ │ │ │ -
609}
│ │ │ │ -
610
│ │ │ │ -
611
│ │ │ │ -
617template<bool FORWARD>
│ │ │ │ -
618struct InterfaceInformationChooser
│ │ │ │ -
619{
│ │ │ │ -
623 static const InterfaceInformation&
│ │ │ │ -
624 getSend(const std::pair<InterfaceInformation,InterfaceInformation>& info)
│ │ │ │ -
625 {
│ │ │ │ -
626 return info.first;
│ │ │ │ -
627 }
│ │ │ │ -
628
│ │ │ │ -
632 static const InterfaceInformation&
│ │ │ │ -
633 getReceive(const std::pair<InterfaceInformation,InterfaceInformation>& info)
│ │ │ │ -
634 {
│ │ │ │ -
635 return info.second;
│ │ │ │ -
636 }
│ │ │ │ -
637};
│ │ │ │ -
638
│ │ │ │ -
639template<>
│ │ │ │ -
640struct InterfaceInformationChooser<false>
│ │ │ │ -
641{
│ │ │ │ -
642 static const InterfaceInformation&
│ │ │ │ -
643 getSend(const std::pair<InterfaceInformation,InterfaceInformation>& info)
│ │ │ │ -
644 {
│ │ │ │ -
645 return info.second;
│ │ │ │ -
646 }
│ │ │ │ -
647
│ │ │ │ -
648 static const InterfaceInformation&
│ │ │ │ -
649 getReceive(const std::pair<InterfaceInformation,InterfaceInformation>& info)
│ │ │ │ -
650 {
│ │ │ │ -
651 return info.first;
│ │ │ │ -
652 }
│ │ │ │ -
653};
│ │ │ │ -
654
│ │ │ │ -
660template<class DataHandle>
│ │ │ │ -
661struct PackEntries
│ │ │ │ -
662{
│ │ │ │ -
663
│ │ │ │ -
664 int operator()(DataHandle& handle, InterfaceTracker& tracker,
│ │ │ │ -
665 MessageBuffer<typename DataHandle::DataType>& buffer,
│ │ │ │ -
666 [[maybe_unused]] int i) const
│ │ │ │ -
667 {
│ │ │ │ -
668 return operator()(handle,tracker,buffer);
│ │ │ │ -
669 }
│ │ │ │ -
670
│ │ │ │ -
678 int operator()(DataHandle& handle, InterfaceTracker& tracker,
│ │ │ │ -
679 MessageBuffer<typename DataHandle::DataType>& buffer) const
│ │ │ │ -
680 {
│ │ │ │ -
681 if(tracker.fixedSize) // fixed size if variable is >0!
│ │ │ │ -
682 {
│ │ │ │ -
683
│ │ │ │ -
684 std::size_t noIndices=std::min(buffer.size()/tracker.fixedSize, tracker.indicesLeft());
│ │ │ │ -
685 for(std::size_t i=0; i< noIndices; ++i)
│ │ │ │ -
686 {
│ │ │ │ -
687 handle.gather(buffer, tracker.index());
│ │ │ │ -
688 tracker.moveToNextIndex();
│ │ │ │ -
689 }
│ │ │ │ -
690 return noIndices*tracker.fixedSize;
│ │ │ │ -
691 }
│ │ │ │ -
692 else
│ │ │ │ -
693 {
│ │ │ │ -
694 int packed=0;
│ │ │ │ -
695 tracker.skipZeroIndices();
│ │ │ │ -
696 while(!tracker.finished())
│ │ │ │ -
697 if(buffer.hasSpaceForItems(handle.size(tracker.index())))
│ │ │ │ -
698 {
│ │ │ │ -
699 handle.gather(buffer, tracker.index());
│ │ │ │ -
700 packed+=handle.size(tracker.index());
│ │ │ │ -
701 tracker.moveToNextIndex();
│ │ │ │ -
702 }
│ │ │ │ -
703 else
│ │ │ │ -
704 break;
│ │ │ │ -
705 return packed;
│ │ │ │ -
706 }
│ │ │ │ -
707 }
│ │ │ │ -
708};
│ │ │ │ -
709
│ │ │ │ -
715template<class DataHandle>
│ │ │ │ -
716struct UnpackEntries{
│ │ │ │ -
717
│ │ │ │ -
725 bool operator()(DataHandle& handle, InterfaceTracker& tracker,
│ │ │ │ -
726 MessageBuffer<typename DataHandle::DataType>& buffer,
│ │ │ │ -
727 int count=0)
│ │ │ │ -
728 {
│ │ │ │ -
729 if(tracker.fixedSize) // fixed size if variable is >0!
│ │ │ │ -
730 {
│ │ │ │ -
731 std::size_t noIndices=std::min(buffer.size()/tracker.fixedSize, tracker.indicesLeft());
│ │ │ │ -
732
│ │ │ │ -
733 for(std::size_t i=0; i< noIndices; ++i)
│ │ │ │ -
734 {
│ │ │ │ -
735 handle.scatter(buffer, tracker.index(), tracker.fixedSize);
│ │ │ │ -
736 tracker.moveToNextIndex();
│ │ │ │ -
737 }
│ │ │ │ -
738 return tracker.finished();
│ │ │ │ -
739 }
│ │ │ │ -
740 else
│ │ │ │ -
741 {
│ │ │ │ -
742 assert(count);
│ │ │ │ -
743 for(int unpacked=0;unpacked<count;)
│ │ │ │ -
744 {
│ │ │ │ -
745 assert(!tracker.finished());
│ │ │ │ -
746 assert(buffer.hasSpaceForItems(tracker.size()));
│ │ │ │ -
747 handle.scatter(buffer, tracker.index(), tracker.size());
│ │ │ │ -
748 unpacked+=tracker.size();
│ │ │ │ -
749 tracker.moveToNextIndex();
│ │ │ │ -
750 }
│ │ │ │ -
751 return tracker.finished();
│ │ │ │ -
752 }
│ │ │ │ -
753 }
│ │ │ │ -
754};
│ │ │ │ -
755
│ │ │ │ -
756
│ │ │ │ -
760template<class DataHandle>
│ │ │ │ -
761struct UnpackSizeEntries{
│ │ │ │ -
762
│ │ │ │ -
770 bool operator()(SizeDataHandle<DataHandle>& handle, InterfaceTracker& tracker,
│ │ │ │ -
771 MessageBuffer<typename SizeDataHandle<DataHandle>::DataType>& buffer) const
│ │ │ │ -
772 {
│ │ │ │ -
773 std::size_t noIndices=std::min(buffer.size(), tracker.indicesLeft());
│ │ │ │ -
774 std::copy(static_cast<std::size_t*>(buffer), static_cast<std::size_t*>(buffer)+noIndices,
│ │ │ │ -
775 handle.getSizesPointer()+tracker.offset());
│ │ │ │ -
776 tracker.increment(noIndices);
│ │ │ │ -
777 return noIndices;
│ │ │ │ -
778 }
│ │ │ │ -
779 bool operator()(SizeDataHandle<DataHandle>& handle, InterfaceTracker& tracker,
│ │ │ │ -
780 MessageBuffer<typename SizeDataHandle<DataHandle>::DataType>& buffer, int) const
│ │ │ │ -
781 {
│ │ │ │ -
782 return operator()(handle,tracker,buffer);
│ │ │ │ -
783 }
│ │ │ │ -
784};
│ │ │ │ -
785
│ │ │ │ -
793void sendFixedSize(std::vector<InterfaceTracker>& send_trackers,
│ │ │ │ -
794 std::vector<MPI_Request>& send_requests,
│ │ │ │ -
795 std::vector<InterfaceTracker>& recv_trackers,
│ │ │ │ -
796 std::vector<MPI_Request>& recv_requests,
│ │ │ │ -
797 MPI_Comm communicator)
│ │ │ │ -
798{
│ │ │ │ -
799 typedef std::vector<InterfaceTracker>::iterator TIter;
│ │ │ │ -
800 std::vector<MPI_Request>::iterator mIter=recv_requests.begin();
│ │ │ │ -
801
│ │ │ │ -
802 for(TIter iter=recv_trackers.begin(), end=recv_trackers.end(); iter!=end;
│ │ │ │ -
803 ++iter, ++mIter)
│ │ │ │ -
804 {
│ │ │ │ -
805 MPI_Irecv(&(iter->fixedSize), 1, MPITraits<std::size_t>::getType(),
│ │ │ │ -
806 iter->rank(), 933881, communicator, &(*mIter));
│ │ │ │ -
807 }
│ │ │ │ -
808
│ │ │ │ -
809 // Send our size to all neighbours using non-blocking synchronous communication.
│ │ │ │ -
810 std::vector<MPI_Request>::iterator mIter1=send_requests.begin();
│ │ │ │ -
811 for(TIter iter=send_trackers.begin(), end=send_trackers.end();
│ │ │ │ -
812 iter!=end;
│ │ │ │ -
813 ++iter, ++mIter1)
│ │ │ │ -
814 {
│ │ │ │ -
815 MPI_Issend(&(iter->fixedSize), 1, MPITraits<std::size_t>::getType(),
│ │ │ │ -
816 iter->rank(), 933881, communicator, &(*mIter1));
│ │ │ │ -
817 }
│ │ │ │ -
818}
│ │ │ │ -
819
│ │ │ │ -
820
│ │ │ │ -
825template<class DataHandle>
│ │ │ │ -
826struct SetupSendRequest{
│ │ │ │ -
827 void operator()(DataHandle& handle,
│ │ │ │ -
828 InterfaceTracker& tracker,
│ │ │ │ -
829 MessageBuffer<typename DataHandle::DataType>& buffer,
│ │ │ │ -
830 MPI_Request& request,
│ │ │ │ -
831 MPI_Comm comm) const
│ │ │ │ -
832 {
│ │ │ │ -
833 buffer.reset();
│ │ │ │ -
834 int size=PackEntries<DataHandle>()(handle, tracker, buffer);
│ │ │ │ -
835 // Skip indices of zero size.
│ │ │ │ -
836 while(!tracker.finished() && !handle.size(tracker.index()))
│ │ │ │ -
837 tracker.moveToNextIndex();
│ │ │ │ -
838 if(size)
│ │ │ │ - │ │ │ │ -
840 tracker.rank(), 933399, comm, &request);
│ │ │ │ -
841 }
│ │ │ │ -
842};
│ │ │ │ -
843
│ │ │ │ -
844
│ │ │ │ -
849template<class DataHandle>
│ │ │ │ -
850struct SetupRecvRequest{
│ │ │ │ -
851 void operator()(DataHandle& /*handle*/,
│ │ │ │ -
852 InterfaceTracker& tracker,
│ │ │ │ -
853 MessageBuffer<typename DataHandle::DataType>& buffer,
│ │ │ │ -
854 MPI_Request& request,
│ │ │ │ -
855 MPI_Comm comm) const
│ │ │ │ -
856 {
│ │ │ │ -
857 buffer.reset();
│ │ │ │ -
858 if(tracker.indicesLeft())
│ │ │ │ -
859 MPI_Irecv(buffer, buffer.size(), MPITraits<typename DataHandle::DataType>::getType(),
│ │ │ │ -
860 tracker.rank(), 933399, comm, &request);
│ │ │ │ -
861 }
│ │ │ │ -
862};
│ │ │ │ -
863
│ │ │ │ -
867template<class DataHandle>
│ │ │ │ -
868struct NullPackUnpackFunctor
│ │ │ │ -
869{
│ │ │ │ -
870 int operator()(DataHandle&, InterfaceTracker&,
│ │ │ │ -
871 MessageBuffer<typename DataHandle::DataType>&, int)
│ │ │ │ -
872 {
│ │ │ │ -
873 return 0;
│ │ │ │ -
874 }
│ │ │ │ -
875 int operator()(DataHandle&, InterfaceTracker&,
│ │ │ │ -
876 MessageBuffer<typename DataHandle::DataType>&)
│ │ │ │ -
877 {
│ │ │ │ -
878 return 0;
│ │ │ │ -
879 }
│ │ │ │ -
880};
│ │ │ │ -
881
│ │ │ │ -
896template<class DataHandle, class BufferFunctor, class CommunicationFunctor>
│ │ │ │ -
897std::size_t checkAndContinue(DataHandle& handle,
│ │ │ │ -
898 std::vector<InterfaceTracker>& trackers,
│ │ │ │ -
899 std::vector<MPI_Request>& requests,
│ │ │ │ -
900 std::vector<MPI_Request>& requests2,
│ │ │ │ -
901 std::vector<MessageBuffer<typename DataHandle::DataType> >& buffers,
│ │ │ │ -
902 MPI_Comm comm,
│ │ │ │ -
903 BufferFunctor buffer_func,
│ │ │ │ -
904 CommunicationFunctor comm_func,
│ │ │ │ -
905 bool valid=true,
│ │ │ │ -
906 bool getCount=false)
│ │ │ │ -
907{
│ │ │ │ -
908 std::size_t size=requests.size();
│ │ │ │ -
909 std::vector<MPI_Status> statuses(size);
│ │ │ │ -
910 int no_completed;
│ │ │ │ -
911 std::vector<int> indices(size, -1); // the indices for which the communication finished.
│ │ │ │ -
912
│ │ │ │ -
913 MPI_Testsome(size, &(requests[0]), &no_completed, &(indices[0]), &(statuses[0]));
│ │ │ │ -
914 indices.resize(no_completed);
│ │ │ │ -
915 for(std::vector<int>::iterator index=indices.begin(), end=indices.end();
│ │ │ │ -
916 index!=end; ++index)
│ │ │ │ -
917 {
│ │ │ │ -
918 InterfaceTracker& tracker=trackers[*index];
│ │ │ │ -
919 setReceivingIndex(handle, *index);
│ │ │ │ -
920 if(getCount)
│ │ │ │ -
921 {
│ │ │ │ -
922 // Get the number of entries received
│ │ │ │ -
923 int count;
│ │ │ │ -
924 MPI_Get_count(&(statuses[index-indices.begin()]),
│ │ │ │ - │ │ │ │ -
926 &count);
│ │ │ │ -
927 // Communication completed, we can reuse the buffers, e.g. unpack or repack
│ │ │ │ -
928 buffer_func(handle, tracker, buffers[*index], count);
│ │ │ │ -
929 }else
│ │ │ │ -
930 buffer_func(handle, tracker, buffers[*index]);
│ │ │ │ -
931 tracker.skipZeroIndices();
│ │ │ │ -
932 if(!tracker.finished()){
│ │ │ │ -
933 // Maybe start another communication.
│ │ │ │ -
934 comm_func(handle, tracker, buffers[*index], requests2[*index], comm);
│ │ │ │ -
935 tracker.skipZeroIndices();
│ │ │ │ -
936 if(valid)
│ │ │ │ -
937 --no_completed; // communication not finished, decrement counter for finished ones.
│ │ │ │ -
938 }
│ │ │ │ -
939 }
│ │ │ │ -
940 return no_completed;
│ │ │ │ -
941
│ │ │ │ -
942}
│ │ │ │ -
943
│ │ │ │ -
953template<class DataHandle>
│ │ │ │ -
954std::size_t receiveSizeAndSetupReceive(DataHandle& handle,
│ │ │ │ -
955 std::vector<InterfaceTracker>& trackers,
│ │ │ │ -
956 std::vector<MPI_Request>& size_requests,
│ │ │ │ -
957 std::vector<MPI_Request>& data_requests,
│ │ │ │ -
958 std::vector<MessageBuffer<typename DataHandle::DataType> >& buffers,
│ │ │ │ -
959 MPI_Comm comm)
│ │ │ │ -
960{
│ │ │ │ -
961 return checkAndContinue(handle, trackers, size_requests, data_requests, buffers, comm,
│ │ │ │ -
962 NullPackUnpackFunctor<DataHandle>(), SetupRecvRequest<DataHandle>(), false);
│ │ │ │ -
963}
│ │ │ │ -
964
│ │ │ │ -
973template<class DataHandle>
│ │ │ │ -
974std::size_t checkSendAndContinueSending(DataHandle& handle,
│ │ │ │ -
975 std::vector<InterfaceTracker>& trackers,
│ │ │ │ -
976 std::vector<MPI_Request>& requests,
│ │ │ │ -
977 std::vector<MessageBuffer<typename DataHandle::DataType> >& buffers,
│ │ │ │ -
978 MPI_Comm comm)
│ │ │ │ -
979{
│ │ │ │ -
980 return checkAndContinue(handle, trackers, requests, requests, buffers, comm,
│ │ │ │ -
981 NullPackUnpackFunctor<DataHandle>(), SetupSendRequest<DataHandle>());
│ │ │ │ -
982}
│ │ │ │ -
983
│ │ │ │ -
992template<class DataHandle>
│ │ │ │ -
993std::size_t checkReceiveAndContinueReceiving(DataHandle& handle,
│ │ │ │ -
994 std::vector<InterfaceTracker>& trackers,
│ │ │ │ -
995 std::vector<MPI_Request>& requests,
│ │ │ │ -
996 std::vector<MessageBuffer<typename DataHandle::DataType> >& buffers,
│ │ │ │ -
997 MPI_Comm comm)
│ │ │ │ -
998{
│ │ │ │ -
999 return checkAndContinue(handle, trackers, requests, requests, buffers, comm,
│ │ │ │ -
1000 UnpackEntries<DataHandle>(), SetupRecvRequest<DataHandle>(),
│ │ │ │ -
1001 true, !Impl::callFixedSize(handle));
│ │ │ │ -
1002}
│ │ │ │ -
1003
│ │ │ │ -
1004
│ │ │ │ -
1005bool validRecvRequests(const std::vector<MPI_Request> reqs)
│ │ │ │ -
1006{
│ │ │ │ -
1007 for(std::vector<MPI_Request>::const_iterator i=reqs.begin(), end=reqs.end();
│ │ │ │ -
1008 i!=end; ++i)
│ │ │ │ -
1009 if(*i!=MPI_REQUEST_NULL)
│ │ │ │ -
1010 return true;
│ │ │ │ -
1011 return false;
│ │ │ │ -
1012}
│ │ │ │ -
1013
│ │ │ │ -
1024template<class DataHandle, class Functor>
│ │ │ │ -
1025std::size_t setupRequests(DataHandle& handle,
│ │ │ │ -
1026 std::vector<InterfaceTracker>& trackers,
│ │ │ │ -
1027 std::vector<MessageBuffer<typename DataHandle::DataType> >& buffers,
│ │ │ │ -
1028 std::vector<MPI_Request>& requests,
│ │ │ │ -
1029 const Functor& setupFunctor,
│ │ │ │ -
1030 MPI_Comm communicator)
│ │ │ │ -
1031{
│ │ │ │ -
1032 typedef typename std::vector<InterfaceTracker>::iterator TIter;
│ │ │ │ -
1033 typename std::vector<MessageBuffer<typename DataHandle::DataType> >::iterator
│ │ │ │ -
1034 biter=buffers.begin();
│ │ │ │ -
1035 typename std::vector<MPI_Request>::iterator riter=requests.begin();
│ │ │ │ -
1036 std::size_t complete=0;
│ │ │ │ -
1037 for(TIter titer=trackers.begin(), end=trackers.end(); titer!=end; ++titer, ++biter, ++riter)
│ │ │ │ -
1038 {
│ │ │ │ -
1039 setupFunctor(handle, *titer, *biter, *riter, communicator);
│ │ │ │ -
1040 complete+=titer->finished();
│ │ │ │ -
1041 }
│ │ │ │ -
1042 return complete;
│ │ │ │ -
1043}
│ │ │ │ -
1044} // end unnamed namespace
│ │ │ │ -
1045
│ │ │ │ -
1046template<class Allocator>
│ │ │ │ -
1047template<bool FORWARD, class DataHandle>
│ │ │ │ -
1048void VariableSizeCommunicator<Allocator>::setupInterfaceTrackers(DataHandle& handle,
│ │ │ │ -
1049 std::vector<InterfaceTracker>& send_trackers,
│ │ │ │ -
1050 std::vector<InterfaceTracker>& recv_trackers)
│ │ │ │ -
1051{
│ │ │ │ -
1052 if(interface_->size()==0)
│ │ │ │ -
1053 return;
│ │ │ │ -
1054 send_trackers.reserve(interface_->size());
│ │ │ │ -
1055 recv_trackers.reserve(interface_->size());
│ │ │ │ -
1056
│ │ │ │ -
1057 int fixedsize=0;
│ │ │ │ -
1058 if(Impl::callFixedSize(handle))
│ │ │ │ -
1059 ++fixedsize;
│ │ │ │ -
1060
│ │ │ │ -
1061
│ │ │ │ -
1062 typedef typename InterfaceMap::const_iterator IIter;
│ │ │ │ -
1063 for(IIter inf=interface_->begin(), end=interface_->end(); inf!=end; ++inf)
│ │ │ │ -
1064 {
│ │ │ │ -
1065
│ │ │ │ -
1066 if(Impl::callFixedSize(handle) && InterfaceInformationChooser<FORWARD>::getSend(inf->second).size())
│ │ │ │ -
1067 fixedsize=handle.size(InterfaceInformationChooser<FORWARD>::getSend(inf->second)[0]);
│ │ │ │ -
1068 assert(!Impl::callFixedSize(handle)||fixedsize>0);
│ │ │ │ -
1069 send_trackers.push_back(InterfaceTracker(inf->first,
│ │ │ │ -
1070 InterfaceInformationChooser<FORWARD>::getSend(inf->second), fixedsize));
│ │ │ │ -
1071 recv_trackers.push_back(InterfaceTracker(inf->first,
│ │ │ │ -
1072 InterfaceInformationChooser<FORWARD>::getReceive(inf->second), fixedsize, fixedsize==0));
│ │ │ │ -
1073 }
│ │ │ │ -
1074}
│ │ │ │ -
1075
│ │ │ │ -
1076template<class Allocator>
│ │ │ │ -
1077template<bool FORWARD, class DataHandle>
│ │ │ │ -
1078void VariableSizeCommunicator<Allocator>::communicateFixedSize(DataHandle& handle)
│ │ │ │ -
1079{
│ │ │ │ -
1080 std::vector<MPI_Request> size_send_req(interface_->size());
│ │ │ │ -
1081 std::vector<MPI_Request> size_recv_req(interface_->size());
│ │ │ │ -
1082
│ │ │ │ -
1083 std::vector<InterfaceTracker> send_trackers;
│ │ │ │ -
1084 std::vector<InterfaceTracker> recv_trackers;
│ │ │ │ -
1085 setupInterfaceTrackers<FORWARD>(handle,send_trackers, recv_trackers);
│ │ │ │ -
1086 sendFixedSize(send_trackers, size_send_req, recv_trackers, size_recv_req, communicator_);
│ │ │ │ -
1087
│ │ │ │ -
1088 std::vector<MPI_Request> data_send_req(interface_->size(), MPI_REQUEST_NULL);
│ │ │ │ -
1089 std::vector<MPI_Request> data_recv_req(interface_->size(), MPI_REQUEST_NULL);
│ │ │ │ -
1090 typedef typename DataHandle::DataType DataType;
│ │ │ │ -
1091 std::vector<MessageBuffer<DataType> > send_buffers(interface_->size(), MessageBuffer<DataType>(maxBufferSize_)),
│ │ │ │ -
1092 recv_buffers(interface_->size(), MessageBuffer<DataType>(maxBufferSize_));
│ │ │ │ -
1093
│ │ │ │ -
1094
│ │ │ │ -
1095 setupRequests(handle, send_trackers, send_buffers, data_send_req,
│ │ │ │ -
1096 SetupSendRequest<DataHandle>(), communicator_);
│ │ │ │ -
1097
│ │ │ │ -
1098 std::size_t no_size_to_recv, no_to_send, no_to_recv, old_size;
│ │ │ │ -
1099 no_size_to_recv = no_to_send = no_to_recv = old_size = interface_->size();
│ │ │ │ -
1100
│ │ │ │ -
1101 // Skip empty interfaces.
│ │ │ │ -
1102 typedef typename std::vector<InterfaceTracker>::const_iterator Iter;
│ │ │ │ -
1103 for(Iter i=recv_trackers.begin(), end=recv_trackers.end(); i!=end; ++i)
│ │ │ │ -
1104 if(i->empty())
│ │ │ │ -
1105 --no_to_recv;
│ │ │ │ -
1106 for(Iter i=send_trackers.begin(), end=send_trackers.end(); i!=end; ++i)
│ │ │ │ -
1107 if(i->empty())
│ │ │ │ -
1108 --no_to_send;
│ │ │ │ -
1109
│ │ │ │ -
1110 while(no_size_to_recv+no_to_send+no_to_recv)
│ │ │ │ -
1111 {
│ │ │ │ -
1112 // Receive the fixedsize and setup receives accordingly
│ │ │ │ -
1113 if(no_size_to_recv)
│ │ │ │ -
1114 no_size_to_recv -= receiveSizeAndSetupReceive(handle,recv_trackers, size_recv_req,
│ │ │ │ -
1115 data_recv_req, recv_buffers,
│ │ │ │ -
1116 communicator_);
│ │ │ │ -
1117
│ │ │ │ -
1118 // Check send completion and initiate other necessary sends
│ │ │ │ -
1119 if(no_to_send)
│ │ │ │ -
1120 no_to_send -= checkSendAndContinueSending(handle, send_trackers, data_send_req,
│ │ │ │ -
1121 send_buffers, communicator_);
│ │ │ │ -
1122 if(validRecvRequests(data_recv_req))
│ │ │ │ -
1123 // Receive data and setup new unblocking receives if necessary
│ │ │ │ -
1124 no_to_recv -= checkReceiveAndContinueReceiving(handle, recv_trackers, data_recv_req,
│ │ │ │ -
1125 recv_buffers, communicator_);
│ │ │ │ -
1126 }
│ │ │ │ -
1127
│ │ │ │ -
1128 // Wait for completion of sending the size.
│ │ │ │ -
1129 //std::vector<MPI_Status> statuses(interface_->size(), MPI_STATUSES_IGNORE);
│ │ │ │ -
1130 MPI_Waitall(size_send_req.size(), &(size_send_req[0]), MPI_STATUSES_IGNORE);
│ │ │ │ -
1131
│ │ │ │ -
1132}
│ │ │ │ -
1133
│ │ │ │ -
1134template<class Allocator>
│ │ │ │ -
1135template<bool FORWARD, class DataHandle>
│ │ │ │ -
1136void VariableSizeCommunicator<Allocator>::communicateSizes(DataHandle& handle,
│ │ │ │ -
1137 std::vector<InterfaceTracker>& data_recv_trackers)
│ │ │ │ -
1138{
│ │ │ │ -
1139 std::vector<InterfaceTracker> send_trackers;
│ │ │ │ -
1140 std::vector<InterfaceTracker> recv_trackers;
│ │ │ │ -
1141 std::size_t size = interface_->size();
│ │ │ │ -
1142 std::vector<MPI_Request> send_requests(size, MPI_REQUEST_NULL);
│ │ │ │ -
1143 std::vector<MPI_Request> recv_requests(size, MPI_REQUEST_NULL);
│ │ │ │ -
1144 std::vector<MessageBuffer<std::size_t> >
│ │ │ │ -
1145 send_buffers(size, MessageBuffer<std::size_t>(maxBufferSize_)),
│ │ │ │ -
1146 recv_buffers(size, MessageBuffer<std::size_t>(maxBufferSize_));
│ │ │ │ -
1147 SizeDataHandle<DataHandle> size_handle(handle,data_recv_trackers);
│ │ │ │ -
1148 setupInterfaceTrackers<FORWARD>(size_handle,send_trackers, recv_trackers);
│ │ │ │ -
1149 setupRequests(size_handle, send_trackers, send_buffers, send_requests,
│ │ │ │ -
1150 SetupSendRequest<SizeDataHandle<DataHandle> >(), communicator_);
│ │ │ │ -
1151 setupRequests(size_handle, recv_trackers, recv_buffers, recv_requests,
│ │ │ │ -
1152 SetupRecvRequest<SizeDataHandle<DataHandle> >(), communicator_);
│ │ │ │ -
1153
│ │ │ │ -
1154 // Count valid requests that we have to wait for.
│ │ │ │ -
1155 auto valid_req_func =
│ │ │ │ -
1156 [](const MPI_Request& req) { return req != MPI_REQUEST_NULL; };
│ │ │ │ -
1157
│ │ │ │ -
1158 auto size_to_send = std::count_if(send_requests.begin(), send_requests.end(),
│ │ │ │ -
1159 valid_req_func);
│ │ │ │ -
1160 auto size_to_recv = std::count_if(recv_requests.begin(), recv_requests.end(),
│ │ │ │ -
1161 valid_req_func);
│ │ │ │ -
1162
│ │ │ │ -
1163 while(size_to_send+size_to_recv)
│ │ │ │ -
1164 {
│ │ │ │ -
1165 if(size_to_send)
│ │ │ │ -
1166 size_to_send -=
│ │ │ │ -
1167 checkSendAndContinueSending(size_handle, send_trackers, send_requests,
│ │ │ │ -
1168 send_buffers, communicator_);
│ │ │ │ -
1169 if(size_to_recv)
│ │ │ │ -
1170 // Could have done this using checkSendAndContinueSending
│ │ │ │ -
1171 // But the call below is more efficient as UnpackSizeEntries
│ │ │ │ -
1172 // uses std::copy.
│ │ │ │ -
1173 size_to_recv -=
│ │ │ │ -
1174 checkAndContinue(size_handle, recv_trackers, recv_requests, recv_requests,
│ │ │ │ -
1175 recv_buffers, communicator_, UnpackSizeEntries<DataHandle>(),
│ │ │ │ -
1176 SetupRecvRequest<SizeDataHandle<DataHandle> >());
│ │ │ │ -
1177 }
│ │ │ │ -
1178}
│ │ │ │ -
1179
│ │ │ │ -
1180template<class Allocator>
│ │ │ │ -
1181template<bool FORWARD, class DataHandle>
│ │ │ │ -
1182void VariableSizeCommunicator<Allocator>::communicateVariableSize(DataHandle& handle)
│ │ │ │ -
1183{
│ │ │ │ -
1184
│ │ │ │ -
1185 std::vector<InterfaceTracker> send_trackers;
│ │ │ │ -
1186 std::vector<InterfaceTracker> recv_trackers;
│ │ │ │ -
1187 setupInterfaceTrackers<FORWARD>(handle, send_trackers, recv_trackers);
│ │ │ │ -
1188
│ │ │ │ -
1189 std::vector<MPI_Request> send_requests(interface_->size(), MPI_REQUEST_NULL);
│ │ │ │ -
1190 std::vector<MPI_Request> recv_requests(interface_->size(), MPI_REQUEST_NULL);
│ │ │ │ -
1191 typedef typename DataHandle::DataType DataType;
│ │ │ │ -
1192 std::vector<MessageBuffer<DataType> >
│ │ │ │ -
1193 send_buffers(interface_->size(), MessageBuffer<DataType>(maxBufferSize_)),
│ │ │ │ -
1194 recv_buffers(interface_->size(), MessageBuffer<DataType>(maxBufferSize_));
│ │ │ │ -
1195
│ │ │ │ -
1196 communicateSizes<FORWARD>(handle, recv_trackers);
│ │ │ │ -
1197 // Setup requests for sending and receiving.
│ │ │ │ -
1198 setupRequests(handle, send_trackers, send_buffers, send_requests,
│ │ │ │ -
1199 SetupSendRequest<DataHandle>(), communicator_);
│ │ │ │ -
1200 setupRequests(handle, recv_trackers, recv_buffers, recv_requests,
│ │ │ │ -
1201 SetupRecvRequest<DataHandle>(), communicator_);
│ │ │ │ -
1202
│ │ │ │ -
1203 // Determine number of valid requests.
│ │ │ │ -
1204 auto valid_req_func =
│ │ │ │ -
1205 [](const MPI_Request& req) { return req != MPI_REQUEST_NULL;};
│ │ │ │ -
1206
│ │ │ │ -
1207 auto no_to_send = std::count_if(send_requests.begin(), send_requests.end(),
│ │ │ │ -
1208 valid_req_func);
│ │ │ │ -
1209 auto no_to_recv = std::count_if(recv_requests.begin(), recv_requests.end(),
│ │ │ │ -
1210 valid_req_func);
│ │ │ │ -
1211 while(no_to_send+no_to_recv)
│ │ │ │ -
1212 {
│ │ │ │ -
1213 // Check send completion and initiate other necessary sends
│ │ │ │ -
1214 if(no_to_send)
│ │ │ │ -
1215 no_to_send -= checkSendAndContinueSending(handle, send_trackers, send_requests,
│ │ │ │ -
1216 send_buffers, communicator_);
│ │ │ │ -
1217 if(no_to_recv)
│ │ │ │ -
1218 // Receive data and setup new unblocking receives if necessary
│ │ │ │ -
1219 no_to_recv -= checkReceiveAndContinueReceiving(handle, recv_trackers, recv_requests,
│ │ │ │ -
1220 recv_buffers, communicator_);
│ │ │ │ -
1221 }
│ │ │ │ -
1222}
│ │ │ │ -
1223
│ │ │ │ -
1224template<class Allocator>
│ │ │ │ -
1225template<bool FORWARD, class DataHandle>
│ │ │ │ -
1226void VariableSizeCommunicator<Allocator>::communicate(DataHandle& handle)
│ │ │ │ -
1227{
│ │ │ │ -
1228 if( interface_->size() == 0)
│ │ │ │ -
1229 // Simply return as otherwise we will index an empty container
│ │ │ │ -
1230 // either for MPI_Wait_all or MPI_Test_some.
│ │ │ │ -
1231 return;
│ │ │ │ -
1232
│ │ │ │ -
1233 if(Impl::callFixedSize(handle))
│ │ │ │ -
1234 communicateFixedSize<FORWARD>(handle);
│ │ │ │ -
1235 else
│ │ │ │ -
1236 communicateVariableSize<FORWARD>(handle);
│ │ │ │ -
1237}
│ │ │ │ -
1238} // end namespace Dune
│ │ │ │ -
1239
│ │ │ │ -
1240#endif // HAVE_MPI
│ │ │ │ -
1241#endif // DUNE_COMMON_PARALLEL_VARIABLESIZECOMMUNICATOR_HH
│ │ │ │ -
std::size_t fixedSize
The number of data items per index if it is fixed, 0 otherwise.
Definition variablesizecommunicator.hh:264
│ │ │ │ -
Traits classes for mapping types onto MPI_Datatype.
│ │ │ │ -
Infrastructure for concepts.
│ │ │ │ -
MPI_Comm communicator() const
Get the MPI Communicator.
Definition parallel/interface.hh:426
│ │ │ │ +
125
│ │ │ │ +
126
│ │ │ │ +
149template<class... F>
│ │ │ │ +
│ │ │ │ +
150auto orderedOverload(F&&... f)
│ │ │ │ +
151{
│ │ │ │ +
152 return Impl::OrderedOverloadSet<std::decay_t<F>...>(std::forward<F>(f)...);
│ │ │ │ +
153}
│ │ │ │ +
│ │ │ │ +
154
│ │ │ │ +
155
│ │ │ │ +
156
│ │ │ │ +
157} // end namespace Dune
│ │ │ │ +
158
│ │ │ │ +
159#endif // DUNE_COMMON_OVERLOADSET_HH
│ │ │ │ +
Traits for type conversions and type information.
│ │ │ │ +
auto orderedOverload(F &&... f)
Create an ordered overload set.
Definition overloadset.hh:150
│ │ │ │ +
auto overload(F &&... f)
Create an overload set.
Definition overloadset.hh:61
│ │ │ │ +
STL namespace.
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition integersequence.hh:75
│ │ │ │ -
constexpr std::bool_constant<(sizeof...(II)==0)> empty(std::integer_sequence< T, II... >)
Checks whether the sequence is empty.
Definition integersequence.hh:80
│ │ │ │ -
static MPI_Datatype getType()
Definition mpitraits.hh:48
│ │ │ │ -
size_t size() const
Get the number of entries in the interface.
Definition parallel/interface.hh:117
│ │ │ │ -
Communication interface between remote and local indices.
Definition parallel/interface.hh:218
│ │ │ │ -
Definition variablesizecommunicator.hh:42
│ │ │ │ -
auto require(H &&h) -> decltype(h.fixedSize())
│ │ │ │ -
A buffered communicator where the amount of data sent does not have to be known a priori.
Definition variablesizecommunicator.hh:331
│ │ │ │ -
VariableSizeCommunicator(const Interface &inf, std::size_t max_buffer_size)
Creates a communicator with a specific maximum buffer size.
Definition variablesizecommunicator.hh:403
│ │ │ │ -
void backward(DataHandle &handle)
Communicate backwards.
Definition variablesizecommunicator.hh:485
│ │ │ │ -
~VariableSizeCommunicator()
Definition variablesizecommunicator.hh:409
│ │ │ │ -
VariableSizeCommunicator(MPI_Comm comm, const InterfaceMap &inf, std::size_t max_buffer_size)
Creates a communicator with a specific maximum buffer size.
Definition variablesizecommunicator.hh:392
│ │ │ │ -
VariableSizeCommunicator(const VariableSizeCommunicator &other)
Copy-constructs a communicator.
Definition variablesizecommunicator.hh:418
│ │ │ │ -
void forward(DataHandle &handle)
Communicate forward.
Definition variablesizecommunicator.hh:460
│ │ │ │ -
VariableSizeCommunicator & operator=(const VariableSizeCommunicator &other)
Copy-assignes a communicator.
Definition variablesizecommunicator.hh:428
│ │ │ │ -
std::map< int, std::pair< InterfaceInformation, InterfaceInformation >, std::less< int >, typename std::allocator_traits< Allocator >::template rebind_alloc< std::pair< const int, std::pair< InterfaceInformation, InterfaceInformation > > > > InterfaceMap
The type of the map from process number to InterfaceInformation for sending and receiving to and from...
Definition variablesizecommunicator.hh:339
│ │ │ │ -
VariableSizeCommunicator(MPI_Comm comm, const InterfaceMap &inf)
Creates a communicator with the default maximum buffer size.
Definition variablesizecommunicator.hh:348
│ │ │ │ -
VariableSizeCommunicator(const Interface &inf)
Creates a communicator with the default maximum buffer size.
Definition variablesizecommunicator.hh:357
│ │ │ │ -
Provides classes for building the communication interface between remote indices.
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,1000 +1,139 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -variablesizecommunicator.hh │ │ │ │ │ +overloadset.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PARALLEL_VARIABLESIZECOMMUNICATOR_HH │ │ │ │ │ -6#define DUNE_COMMON_PARALLEL_VARIABLESIZECOMMUNICATOR_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_OVERLOADSET_HH │ │ │ │ │ +6#define DUNE_COMMON_OVERLOADSET_HH │ │ │ │ │ 7 │ │ │ │ │ -8#if HAVE_MPI │ │ │ │ │ -9 │ │ │ │ │ -10#include │ │ │ │ │ -11#include │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18 │ │ │ │ │ -19#include │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11 │ │ │ │ │ +12namespace Dune { │ │ │ │ │ +13 │ │ │ │ │ +14namespace Impl { │ │ │ │ │ +15 │ │ │ │ │ +16 template │ │ │ │ │ +17 class OverloadSet │ │ │ │ │ +18 : public F... │ │ │ │ │ +19 { │ │ │ │ │ 20 │ │ │ │ │ -21#include │ │ │ │ │ -22#include │ │ │ │ │ -23#include │ │ │ │ │ -24 │ │ │ │ │ -37namespace Dune │ │ │ │ │ -38{ │ │ │ │ │ -39 │ │ │ │ │ -40namespace Concept { │ │ │ │ │ -41 │ │ │ │ │ -42struct HasFixedSize { │ │ │ │ │ -43 template auto require(H &&h) -> decltype(h.fixedSize()); │ │ │ │ │ -44}; │ │ │ │ │ -45 │ │ │ │ │ -46} // namespace Concept │ │ │ │ │ -47 │ │ │ │ │ -48namespace Impl { │ │ │ │ │ -49 │ │ │ │ │ -50template (), int> = 0> │ │ │ │ │ -52constexpr bool callFixedSize(H &&handle) { │ │ │ │ │ -53 return handle.fixedSize(); │ │ │ │ │ -54} │ │ │ │ │ -55 │ │ │ │ │ -56} // namespace Impl │ │ │ │ │ -57 │ │ │ │ │ -58namespace │ │ │ │ │ -59{ │ │ │ │ │ -64template > │ │ │ │ │ -65class MessageBuffer │ │ │ │ │ -66{ │ │ │ │ │ -67public: │ │ │ │ │ -72 explicit MessageBuffer(int size) │ │ │ │ │ -73 : buffer_(new T[size]), size_(size), position_(0) │ │ │ │ │ -74 {} │ │ │ │ │ -79 explicit MessageBuffer(const MessageBuffer& o) │ │ │ │ │ -80 : buffer_(new T[o.size_]), size_(o.size_), position_(o.position_) │ │ │ │ │ -81 { │ │ │ │ │ -82 } │ │ │ │ │ -84 ~MessageBuffer() │ │ │ │ │ -85 { │ │ │ │ │ -86 delete[] buffer_; │ │ │ │ │ -87 } │ │ │ │ │ -92 void write(const T& data) │ │ │ │ │ -93 { │ │ │ │ │ -94 buffer_[position_++]=data; │ │ │ │ │ -95 } │ │ │ │ │ -96 │ │ │ │ │ -101 void read(T& data) │ │ │ │ │ -102 { │ │ │ │ │ -103 data=buffer_[position_++]; │ │ │ │ │ -104 } │ │ │ │ │ -105 │ │ │ │ │ -111 void reset() │ │ │ │ │ -112 { │ │ │ │ │ -113 position_=0; │ │ │ │ │ -114 } │ │ │ │ │ -115 │ │ │ │ │ -120 bool finished() │ │ │ │ │ -121 { │ │ │ │ │ -122 return position_==size_; │ │ │ │ │ -123 } │ │ │ │ │ +21 public: │ │ │ │ │ +22 │ │ │ │ │ +23 template │ │ │ │ │ +24 OverloadSet(FF&&... ff) │ │ │ │ │ +25 : F(std::forward(ff))... │ │ │ │ │ +26 {} │ │ │ │ │ +27 │ │ │ │ │ +28 using F::operator()...; │ │ │ │ │ +29 │ │ │ │ │ +30 }; │ │ │ │ │ +31 │ │ │ │ │ +32} // end namespace Impl │ │ │ │ │ +33 │ │ │ │ │ +34 │ │ │ │ │ +35 │ │ │ │ │ +60template │ │ │ │ │ +61auto overload(F&&... f) │ │ │ │ │ +62{ │ │ │ │ │ +63 return Impl::OverloadSet...>(std::forward(f)...); │ │ │ │ │ +64} │ │ │ │ │ +65 │ │ │ │ │ +66 │ │ │ │ │ +67 │ │ │ │ │ +68namespace Impl { │ │ │ │ │ +69 │ │ │ │ │ +70 template │ │ │ │ │ +71 class OrderedOverloadSet: public OrderedOverloadSet, F0 │ │ │ │ │ +72 { │ │ │ │ │ +73 using Base = OrderedOverloadSet; │ │ │ │ │ +74 public: │ │ │ │ │ +75 │ │ │ │ │ +76 template │ │ │ │ │ +77 OrderedOverloadSet(FF0&& f0, FF&&... ff) : │ │ │ │ │ +78 Base(std::forward(ff)...), │ │ │ │ │ +79 F0(std::forward(f0)) │ │ │ │ │ +80 {} │ │ │ │ │ +81 │ │ │ │ │ +82 // Forward to operator() of F0 if it can be called with the given arguments. │ │ │ │ │ +83 template::value, int> = 0> │ │ │ │ │ +85 decltype(auto) operator()(Args&&... args) │ │ │ │ │ +86 { │ │ │ │ │ +87 return F0::operator()(std::forward(args)...); │ │ │ │ │ +88 } │ │ │ │ │ +89 │ │ │ │ │ +90 // Forward to operator() of base class if F0 cannot be called with the given │ │ │ │ │ +91 // arguments. In this case the base class will successively try operator() │ │ │ │ │ +92 // of all F... . │ │ │ │ │ +93 template::value, int> = 0> │ │ │ │ │ +95 decltype(auto) operator()(Args&&... args) │ │ │ │ │ +96 { │ │ │ │ │ +97 return Base::operator()(std::forward(args)...); │ │ │ │ │ +98 } │ │ │ │ │ +99 │ │ │ │ │ +100 }; │ │ │ │ │ +101 │ │ │ │ │ +102 template │ │ │ │ │ +103 class OrderedOverloadSet: public F0 │ │ │ │ │ +104 { │ │ │ │ │ +105 public: │ │ │ │ │ +106 │ │ │ │ │ +107 template │ │ │ │ │ +108 OrderedOverloadSet(FF0&& f0) : │ │ │ │ │ +109 F0(std::forward(f0)) │ │ │ │ │ +110 {} │ │ │ │ │ +111 │ │ │ │ │ +112 // Forward to operator() of F0. If it cannot be called with │ │ │ │ │ +113 // the given arguments a static assertion will fail. │ │ │ │ │ +114 template │ │ │ │ │ +115 decltype(auto) operator()(Args&&... args) │ │ │ │ │ +116 { │ │ │ │ │ +117 static_assert(IsCallable::value, │ │ │ │ │ +118 "No matching overload found in OrderedOverloadSet"); │ │ │ │ │ +119 return F0::operator()(std::forward(args)...); │ │ │ │ │ +120 } │ │ │ │ │ +121 }; │ │ │ │ │ +122 │ │ │ │ │ +123} // end namespace Impl │ │ │ │ │ 124 │ │ │ │ │ -130 bool hasSpaceForItems(int noItems) │ │ │ │ │ -131 { │ │ │ │ │ -132 return position_+noItems<=size_; │ │ │ │ │ -133 } │ │ │ │ │ -138 std::size_t size() const │ │ │ │ │ -139 { │ │ │ │ │ -140 return size_; │ │ │ │ │ -141 } │ │ │ │ │ -146 operator T*() │ │ │ │ │ -147 { │ │ │ │ │ -148 return buffer_; │ │ │ │ │ -149 } │ │ │ │ │ -150 │ │ │ │ │ -151private: │ │ │ │ │ -155 T* buffer_; │ │ │ │ │ -159 std::size_t size_; │ │ │ │ │ -163 std::size_t position_; │ │ │ │ │ -164}; │ │ │ │ │ -165 │ │ │ │ │ -169class InterfaceTracker │ │ │ │ │ -170{ │ │ │ │ │ -171public: │ │ │ │ │ -177 InterfaceTracker(int rank, InterfaceInformation info, std::size_ │ │ │ │ │ -t fixedsize=0, │ │ │ │ │ -178 bool allocateSizes=false) │ │ │ │ │ -179 : fixedSize(fixedsize),rank_(rank), index_(), interface_(info), sizes_() │ │ │ │ │ -180 { │ │ │ │ │ -181 if(allocateSizes) │ │ │ │ │ -182 { │ │ │ │ │ -183 sizes_.resize(info.size()); │ │ │ │ │ -184 } │ │ │ │ │ -185 } │ │ │ │ │ -186 │ │ │ │ │ -190 void moveToNextIndex() │ │ │ │ │ -191 { │ │ │ │ │ -192 index_++; │ │ │ │ │ -193 assert(index_<=interface_.size()); │ │ │ │ │ -194 skipZeroIndices(); │ │ │ │ │ -195 } │ │ │ │ │ -200 void increment(std::size_t i) │ │ │ │ │ -201 { │ │ │ │ │ -202 index_+=i; │ │ │ │ │ -203 assert(index_<=interface_.size()); │ │ │ │ │ -204 } │ │ │ │ │ -209 bool finished() const │ │ │ │ │ -210 { │ │ │ │ │ -211 return index_==interface_.size(); │ │ │ │ │ -212 } │ │ │ │ │ -213 │ │ │ │ │ -214 void skipZeroIndices() │ │ │ │ │ -215 { │ │ │ │ │ -216 // skip indices with size zero! │ │ │ │ │ -217 while(sizes_.size() && index_!=interface_.size() &&!size()) │ │ │ │ │ -218 ++index_; │ │ │ │ │ -219 } │ │ │ │ │ -220 │ │ │ │ │ -225 std::size_t index() const │ │ │ │ │ -226 { │ │ │ │ │ -227 return interface_[index_]; │ │ │ │ │ -228 } │ │ │ │ │ -232 std::size_t size() const │ │ │ │ │ -233 { │ │ │ │ │ -234 assert(sizes_.size()); │ │ │ │ │ -235 return sizes_[index_]; │ │ │ │ │ -236 } │ │ │ │ │ -240 std::size_t* getSizesPointer() │ │ │ │ │ -241 { │ │ │ │ │ -242 return &sizes_[0]; │ │ │ │ │ -243 } │ │ │ │ │ -248 bool empty() const │ │ │ │ │ -249 { │ │ │ │ │ -250 return !interface_.size(); │ │ │ │ │ -251 } │ │ │ │ │ -252 │ │ │ │ │ -257 std::size_t indicesLeft() const │ │ │ │ │ -258 { │ │ │ │ │ -259 return interface_.size()-index_; │ │ │ │ │ -260 } │ │ │ │ │ -264 std::size_t fixedSize; │ │ │ │ │ -268 int rank() const │ │ │ │ │ -269 { │ │ │ │ │ -270 return rank_; │ │ │ │ │ -271 } │ │ │ │ │ -275 std::size_t offset() const │ │ │ │ │ -276 { │ │ │ │ │ -277 return index_; │ │ │ │ │ -278 } │ │ │ │ │ -279private: │ │ │ │ │ -281 int rank_; │ │ │ │ │ -283 std::size_t index_; │ │ │ │ │ -285 InterfaceInformation interface_; │ │ │ │ │ -286 std::vector sizes_; │ │ │ │ │ -287}; │ │ │ │ │ -288 │ │ │ │ │ -289 │ │ │ │ │ -290} // end unnamed namespace │ │ │ │ │ -291 │ │ │ │ │ -329template > > │ │ │ │ │ -330class VariableSizeCommunicator │ │ │ │ │ -331{ │ │ │ │ │ -332public: │ │ │ │ │ -337 typedef std::map, │ │ │ │ │ -338 std::less, │ │ │ │ │ -339 typename std::allocator_traits::template rebind_alloc< std:: │ │ │ │ │ -pair > > > │ │ │ │ │ -InterfaceMap; │ │ │ │ │ -340 │ │ │ │ │ -341#ifndef DUNE_PARALLEL_MAX_COMMUNICATION_BUFFER_SIZE │ │ │ │ │ -348 VariableSizeCommunicator(MPI_Comm comm, const InterfaceMap& inf) │ │ │ │ │ -349 : maxBufferSize_(32768), interface_(&inf) │ │ │ │ │ -350 { │ │ │ │ │ -351 MPI_Comm_dup(comm, &communicator_); │ │ │ │ │ -352 } │ │ │ │ │ -357 VariableSizeCommunicator(const Interface& inf) │ │ │ │ │ -358 : maxBufferSize_(32768), interface_(&inf.interfaces()) │ │ │ │ │ -359 { │ │ │ │ │ -360 MPI_Comm_dup(inf.communicator(), &communicator_); │ │ │ │ │ -361 } │ │ │ │ │ -362#else │ │ │ │ │ -369 VariableSizeCommunicator(MPI_Comm comm, InterfaceMap& inf) │ │ │ │ │ -370 : maxBufferSize_(DUNE_PARALLEL_MAX_COMMUNICATION_BUFFER_SIZE), │ │ │ │ │ -371 interface_(&inf) │ │ │ │ │ -372 { │ │ │ │ │ -373 MPI_Comm_dup(comm, &communicator_); │ │ │ │ │ -374 } │ │ │ │ │ -379 VariableSizeCommunicator(const Interface& inf) │ │ │ │ │ -380 : maxBufferSize_(DUNE_PARALLEL_MAX_COMMUNICATION_BUFFER_SIZE), │ │ │ │ │ -381 interface_(&inf.interfaces()) │ │ │ │ │ -382 { │ │ │ │ │ -383 MPI_Comm_dup(inf.communicator(), &communicator_); │ │ │ │ │ -384 } │ │ │ │ │ -385#endif │ │ │ │ │ -392 VariableSizeCommunicator(MPI_Comm comm, const InterfaceMap& inf, std::size_ │ │ │ │ │ -t max_buffer_size) │ │ │ │ │ -393 : maxBufferSize_(max_buffer_size), interface_(&inf) │ │ │ │ │ -394 { │ │ │ │ │ -395 MPI_Comm_dup(comm, &communicator_); │ │ │ │ │ -396 } │ │ │ │ │ -397 │ │ │ │ │ -403 VariableSizeCommunicator(const Interface& inf, std::size_t max_buffer_size) │ │ │ │ │ -404 : maxBufferSize_(max_buffer_size), interface_(&inf.interfaces()) │ │ │ │ │ -405 { │ │ │ │ │ -406 MPI_Comm_dup(inf.communicator(), &communicator_); │ │ │ │ │ -407 } │ │ │ │ │ -408 │ │ │ │ │ -409 ~VariableSizeCommunicator() │ │ │ │ │ -410 { │ │ │ │ │ -411 MPI_Comm_free(&communicator_); │ │ │ │ │ -412 } │ │ │ │ │ -413 │ │ │ │ │ -418 VariableSizeCommunicator(const VariableSizeCommunicator& other) { │ │ │ │ │ -419 maxBufferSize_ = other.maxBufferSize_; │ │ │ │ │ -420 interface_ = other.interface_; │ │ │ │ │ -421 MPI_Comm_dup(other.communicator_, &communicator_); │ │ │ │ │ -422 } │ │ │ │ │ -423 │ │ │ │ │ -428 VariableSizeCommunicator& operator=(const VariableSizeCommunicator& other) │ │ │ │ │ -{ │ │ │ │ │ -429 if(this == &other) // don't do anything if objects are the same │ │ │ │ │ -430 return *this; │ │ │ │ │ -431 │ │ │ │ │ -432 maxBufferSize_ = other.maxBufferSize_; │ │ │ │ │ -433 interface_ = other.interface_; │ │ │ │ │ -434 MPI_Comm_free(&communicator_); │ │ │ │ │ -435 MPI_Comm_dup(other.communicator_, &communicator_); │ │ │ │ │ -436 │ │ │ │ │ -437 return *this; │ │ │ │ │ -438 } │ │ │ │ │ -439 │ │ │ │ │ -459 template │ │ │ │ │ -460 void forward(DataHandle& handle) │ │ │ │ │ -461 { │ │ │ │ │ -462 communicate(handle); │ │ │ │ │ -463 } │ │ │ │ │ -464 │ │ │ │ │ -484 template │ │ │ │ │ -485 void backward(DataHandle& handle) │ │ │ │ │ -486 { │ │ │ │ │ -487 communicate(handle); │ │ │ │ │ -488 } │ │ │ │ │ -489 │ │ │ │ │ -490private: │ │ │ │ │ -491 template │ │ │ │ │ -492 void communicateSizes(DataHandle& handle, │ │ │ │ │ -493 std::vector& recv_trackers); │ │ │ │ │ -494 │ │ │ │ │ -501 template │ │ │ │ │ -502 void communicate(DataHandle& handle); │ │ │ │ │ -512 template │ │ │ │ │ -513 void setupInterfaceTrackers(DataHandle& handle, │ │ │ │ │ -514 std::vector& send_trackers, │ │ │ │ │ -515 std::vector& recv_trackers); │ │ │ │ │ -523 template │ │ │ │ │ -524 void communicateFixedSize(DataHandle& handle); │ │ │ │ │ -532 template │ │ │ │ │ -533 void communicateVariableSize(DataHandle& handle); │ │ │ │ │ -540 std::size_t maxBufferSize_; │ │ │ │ │ -548 const InterfaceMap* interface_; │ │ │ │ │ -554 MPI_Comm communicator_; │ │ │ │ │ -555}; │ │ │ │ │ -556 │ │ │ │ │ -558namespace │ │ │ │ │ -559{ │ │ │ │ │ -563template │ │ │ │ │ -564class SizeDataHandle │ │ │ │ │ -565{ │ │ │ │ │ -566public: │ │ │ │ │ -567 typedef std::size_t DataType; │ │ │ │ │ -568 │ │ │ │ │ -569 SizeDataHandle(DataHandle& data, │ │ │ │ │ -570 std::vector& trackers) │ │ │ │ │ -571 : data_(data), trackers_(trackers), index_() │ │ │ │ │ -572 {} │ │ │ │ │ -573 bool fixedSize() │ │ │ │ │ -574 { │ │ │ │ │ -575 return true; │ │ │ │ │ -576 } │ │ │ │ │ -577 std::size_t size([[maybe_unused]] std::size_t i) │ │ │ │ │ -578 { │ │ │ │ │ -579 return 1; │ │ │ │ │ -580 } │ │ │ │ │ -581 template │ │ │ │ │ -582 void gather(B& buf, int i) │ │ │ │ │ -583 { │ │ │ │ │ -584 buf.write(data_.size(i)); │ │ │ │ │ -585 } │ │ │ │ │ -586 void setReceivingIndex(std::size_t i) │ │ │ │ │ -587 { │ │ │ │ │ -588 index_=i; │ │ │ │ │ -589 } │ │ │ │ │ -590 std::size_t* getSizesPointer() │ │ │ │ │ -591 { │ │ │ │ │ -592 return trackers_[index_].getSizesPointer(); │ │ │ │ │ -593 } │ │ │ │ │ -594 │ │ │ │ │ -595private: │ │ │ │ │ -596 DataHandle& data_; │ │ │ │ │ -597 std::vector& trackers_; │ │ │ │ │ -598 int index_; │ │ │ │ │ -599}; │ │ │ │ │ -600 │ │ │ │ │ -601template │ │ │ │ │ -602void setReceivingIndex(T&, int) │ │ │ │ │ -603{} │ │ │ │ │ -604 │ │ │ │ │ -605template │ │ │ │ │ -606void setReceivingIndex(SizeDataHandle& t, int i) │ │ │ │ │ -607{ │ │ │ │ │ -608 t.setReceivingIndex(i); │ │ │ │ │ -609} │ │ │ │ │ -610 │ │ │ │ │ -611 │ │ │ │ │ -617template │ │ │ │ │ -618struct InterfaceInformationChooser │ │ │ │ │ -619{ │ │ │ │ │ -623 static const InterfaceInformation& │ │ │ │ │ -624 getSend(const std::pair& info) │ │ │ │ │ -625 { │ │ │ │ │ -626 return info.first; │ │ │ │ │ -627 } │ │ │ │ │ -628 │ │ │ │ │ -632 static const InterfaceInformation& │ │ │ │ │ -633 getReceive(const std::pair& │ │ │ │ │ -info) │ │ │ │ │ -634 { │ │ │ │ │ -635 return info.second; │ │ │ │ │ -636 } │ │ │ │ │ -637}; │ │ │ │ │ -638 │ │ │ │ │ -639template<> │ │ │ │ │ -640struct InterfaceInformationChooser │ │ │ │ │ -641{ │ │ │ │ │ -642 static const InterfaceInformation& │ │ │ │ │ -643 getSend(const std::pair& info) │ │ │ │ │ -644 { │ │ │ │ │ -645 return info.second; │ │ │ │ │ -646 } │ │ │ │ │ -647 │ │ │ │ │ -648 static const InterfaceInformation& │ │ │ │ │ -649 getReceive(const std::pair& │ │ │ │ │ -info) │ │ │ │ │ -650 { │ │ │ │ │ -651 return info.first; │ │ │ │ │ -652 } │ │ │ │ │ -653}; │ │ │ │ │ -654 │ │ │ │ │ -660template │ │ │ │ │ -661struct PackEntries │ │ │ │ │ -662{ │ │ │ │ │ -663 │ │ │ │ │ -664 int operator()(DataHandle& handle, InterfaceTracker& tracker, │ │ │ │ │ -665 MessageBuffer& buffer, │ │ │ │ │ -666 [[maybe_unused]] int i) const │ │ │ │ │ -667 { │ │ │ │ │ -668 return operator()(handle,tracker,buffer); │ │ │ │ │ -669 } │ │ │ │ │ -670 │ │ │ │ │ -678 int operator()(DataHandle& handle, InterfaceTracker& tracker, │ │ │ │ │ -679 MessageBuffer& buffer) const │ │ │ │ │ -680 { │ │ │ │ │ -681 if(tracker.fixedSize) // fixed size if variable is >0! │ │ │ │ │ -682 { │ │ │ │ │ -683 │ │ │ │ │ -684 std::size_t noIndices=std::min(buffer.size()/tracker.fixedSize, │ │ │ │ │ -tracker.indicesLeft()); │ │ │ │ │ -685 for(std::size_t i=0; i< noIndices; ++i) │ │ │ │ │ -686 { │ │ │ │ │ -687 handle.gather(buffer, tracker.index()); │ │ │ │ │ -688 tracker.moveToNextIndex(); │ │ │ │ │ -689 } │ │ │ │ │ -690 return noIndices*tracker.fixedSize; │ │ │ │ │ -691 } │ │ │ │ │ -692 else │ │ │ │ │ -693 { │ │ │ │ │ -694 int packed=0; │ │ │ │ │ -695 tracker.skipZeroIndices(); │ │ │ │ │ -696 while(!tracker.finished()) │ │ │ │ │ -697 if(buffer.hasSpaceForItems(handle.size(tracker.index()))) │ │ │ │ │ -698 { │ │ │ │ │ -699 handle.gather(buffer, tracker.index()); │ │ │ │ │ -700 packed+=handle.size(tracker.index()); │ │ │ │ │ -701 tracker.moveToNextIndex(); │ │ │ │ │ -702 } │ │ │ │ │ -703 else │ │ │ │ │ -704 break; │ │ │ │ │ -705 return packed; │ │ │ │ │ -706 } │ │ │ │ │ -707 } │ │ │ │ │ -708}; │ │ │ │ │ -709 │ │ │ │ │ -715template │ │ │ │ │ -716struct UnpackEntries{ │ │ │ │ │ -717 │ │ │ │ │ -725 bool operator()(DataHandle& handle, InterfaceTracker& tracker, │ │ │ │ │ -726 MessageBuffer& buffer, │ │ │ │ │ -727 int count=0) │ │ │ │ │ -728 { │ │ │ │ │ -729 if(tracker.fixedSize) // fixed size if variable is >0! │ │ │ │ │ -730 { │ │ │ │ │ -731 std::size_t noIndices=std::min(buffer.size()/tracker.fixedSize, │ │ │ │ │ -tracker.indicesLeft()); │ │ │ │ │ -732 │ │ │ │ │ -733 for(std::size_t i=0; i< noIndices; ++i) │ │ │ │ │ -734 { │ │ │ │ │ -735 handle.scatter(buffer, tracker.index(), tracker.fixedSize); │ │ │ │ │ -736 tracker.moveToNextIndex(); │ │ │ │ │ -737 } │ │ │ │ │ -738 return tracker.finished(); │ │ │ │ │ -739 } │ │ │ │ │ -740 else │ │ │ │ │ -741 { │ │ │ │ │ -742 assert(count); │ │ │ │ │ -743 for(int unpacked=0;unpacked │ │ │ │ │ -761struct UnpackSizeEntries{ │ │ │ │ │ -762 │ │ │ │ │ -770 bool operator()(SizeDataHandle& handle, InterfaceTracker& │ │ │ │ │ -tracker, │ │ │ │ │ -771 MessageBuffer::DataType>& buffer) const │ │ │ │ │ -772 { │ │ │ │ │ -773 std::size_t noIndices=std::min(buffer.size(), tracker.indicesLeft()); │ │ │ │ │ -774 std::copy(static_cast(buffer), static_cast │ │ │ │ │ -(buffer)+noIndices, │ │ │ │ │ -775 handle.getSizesPointer()+tracker.offset()); │ │ │ │ │ -776 tracker.increment(noIndices); │ │ │ │ │ -777 return noIndices; │ │ │ │ │ -778 } │ │ │ │ │ -779 bool operator()(SizeDataHandle& handle, InterfaceTracker& │ │ │ │ │ -tracker, │ │ │ │ │ -780 MessageBuffer::DataType>& buffer, int) │ │ │ │ │ -const │ │ │ │ │ -781 { │ │ │ │ │ -782 return operator()(handle,tracker,buffer); │ │ │ │ │ -783 } │ │ │ │ │ -784}; │ │ │ │ │ -785 │ │ │ │ │ -793void sendFixedSize(std::vector& send_trackers, │ │ │ │ │ -794 std::vector& send_requests, │ │ │ │ │ -795 std::vector& recv_trackers, │ │ │ │ │ -796 std::vector& recv_requests, │ │ │ │ │ -797 MPI_Comm communicator) │ │ │ │ │ -798{ │ │ │ │ │ -799 typedef std::vector::iterator TIter; │ │ │ │ │ -800 std::vector::iterator mIter=recv_requests.begin(); │ │ │ │ │ -801 │ │ │ │ │ -802 for(TIter iter=recv_trackers.begin(), end=recv_trackers.end(); iter!=end; │ │ │ │ │ -803 ++iter, ++mIter) │ │ │ │ │ -804 { │ │ │ │ │ -805 MPI_Irecv(&(iter->fixedSize), 1, MPITraits::getType(), │ │ │ │ │ -806 iter->rank(), 933881, communicator, &(*mIter)); │ │ │ │ │ -807 } │ │ │ │ │ -808 │ │ │ │ │ -809 // Send our size to all neighbours using non-blocking synchronous │ │ │ │ │ -communication. │ │ │ │ │ -810 std::vector::iterator mIter1=send_requests.begin(); │ │ │ │ │ -811 for(TIter iter=send_trackers.begin(), end=send_trackers.end(); │ │ │ │ │ -812 iter!=end; │ │ │ │ │ -813 ++iter, ++mIter1) │ │ │ │ │ -814 { │ │ │ │ │ -815 MPI_Issend(&(iter->fixedSize), 1, MPITraits::getType(), │ │ │ │ │ -816 iter->rank(), 933881, communicator, &(*mIter1)); │ │ │ │ │ -817 } │ │ │ │ │ -818} │ │ │ │ │ -819 │ │ │ │ │ -820 │ │ │ │ │ -825template │ │ │ │ │ -826struct SetupSendRequest{ │ │ │ │ │ -827 void operator()(DataHandle& handle, │ │ │ │ │ -828 InterfaceTracker& tracker, │ │ │ │ │ -829 MessageBuffer& buffer, │ │ │ │ │ -830 MPI_Request& request, │ │ │ │ │ -831 MPI_Comm comm) const │ │ │ │ │ -832 { │ │ │ │ │ -833 buffer.reset(); │ │ │ │ │ -834 int size=PackEntries()(handle, tracker, buffer); │ │ │ │ │ -835 // Skip indices of zero size. │ │ │ │ │ -836 while(!tracker.finished() && !handle.size(tracker.index())) │ │ │ │ │ -837 tracker.moveToNextIndex(); │ │ │ │ │ -838 if(size) │ │ │ │ │ -839 MPI_Issend(buffer, size, MPITraits::getType │ │ │ │ │ -(), │ │ │ │ │ -840 tracker.rank(), 933399, comm, &request); │ │ │ │ │ -841 } │ │ │ │ │ -842}; │ │ │ │ │ -843 │ │ │ │ │ -844 │ │ │ │ │ -849template │ │ │ │ │ -850struct SetupRecvRequest{ │ │ │ │ │ -851 void operator()(DataHandle& /*handle*/, │ │ │ │ │ -852 InterfaceTracker& tracker, │ │ │ │ │ -853 MessageBuffer& buffer, │ │ │ │ │ -854 MPI_Request& request, │ │ │ │ │ -855 MPI_Comm comm) const │ │ │ │ │ -856 { │ │ │ │ │ -857 buffer.reset(); │ │ │ │ │ -858 if(tracker.indicesLeft()) │ │ │ │ │ -859 MPI_Irecv(buffer, buffer.size(), MPITraits:: │ │ │ │ │ -getType(), │ │ │ │ │ -860 tracker.rank(), 933399, comm, &request); │ │ │ │ │ -861 } │ │ │ │ │ -862}; │ │ │ │ │ -863 │ │ │ │ │ -867template │ │ │ │ │ -868struct NullPackUnpackFunctor │ │ │ │ │ -869{ │ │ │ │ │ -870 int operator()(DataHandle&, InterfaceTracker&, │ │ │ │ │ -871 MessageBuffer&, int) │ │ │ │ │ -872 { │ │ │ │ │ -873 return 0; │ │ │ │ │ -874 } │ │ │ │ │ -875 int operator()(DataHandle&, InterfaceTracker&, │ │ │ │ │ -876 MessageBuffer&) │ │ │ │ │ -877 { │ │ │ │ │ -878 return 0; │ │ │ │ │ -879 } │ │ │ │ │ -880}; │ │ │ │ │ -881 │ │ │ │ │ -896template │ │ │ │ │ -897std::size_t checkAndContinue(DataHandle& handle, │ │ │ │ │ -898 std::vector& trackers, │ │ │ │ │ -899 std::vector& requests, │ │ │ │ │ -900 std::vector& requests2, │ │ │ │ │ -901 std::vector >& buffers, │ │ │ │ │ -902 MPI_Comm comm, │ │ │ │ │ -903 BufferFunctor buffer_func, │ │ │ │ │ -904 CommunicationFunctor comm_func, │ │ │ │ │ -905 bool valid=true, │ │ │ │ │ -906 bool getCount=false) │ │ │ │ │ -907{ │ │ │ │ │ -908 std::size_t size=requests.size(); │ │ │ │ │ -909 std::vector statuses(size); │ │ │ │ │ -910 int no_completed; │ │ │ │ │ -911 std::vector indices(size, -1); // the indices for which the │ │ │ │ │ -communication finished. │ │ │ │ │ -912 │ │ │ │ │ -913 MPI_Testsome(size, &(requests[0]), &no_completed, &(indices[0]), &(statuses │ │ │ │ │ -[0])); │ │ │ │ │ -914 indices.resize(no_completed); │ │ │ │ │ -915 for(std::vector::iterator index=indices.begin(), end=indices.end(); │ │ │ │ │ -916 index!=end; ++index) │ │ │ │ │ -917 { │ │ │ │ │ -918 InterfaceTracker& tracker=trackers[*index]; │ │ │ │ │ -919 setReceivingIndex(handle, *index); │ │ │ │ │ -920 if(getCount) │ │ │ │ │ -921 { │ │ │ │ │ -922 // Get the number of entries received │ │ │ │ │ -923 int count; │ │ │ │ │ -924 MPI_Get_count(&(statuses[index-indices.begin()]), │ │ │ │ │ -925 MPITraits::getType(), │ │ │ │ │ -926 &count); │ │ │ │ │ -927 // Communication completed, we can reuse the buffers, e.g. unpack or repack │ │ │ │ │ -928 buffer_func(handle, tracker, buffers[*index], count); │ │ │ │ │ -929 }else │ │ │ │ │ -930 buffer_func(handle, tracker, buffers[*index]); │ │ │ │ │ -931 tracker.skipZeroIndices(); │ │ │ │ │ -932 if(!tracker.finished()){ │ │ │ │ │ -933 // Maybe start another communication. │ │ │ │ │ -934 comm_func(handle, tracker, buffers[*index], requests2[*index], comm); │ │ │ │ │ -935 tracker.skipZeroIndices(); │ │ │ │ │ -936 if(valid) │ │ │ │ │ -937 --no_completed; // communication not finished, decrement counter for │ │ │ │ │ -finished ones. │ │ │ │ │ -938 } │ │ │ │ │ -939 } │ │ │ │ │ -940 return no_completed; │ │ │ │ │ -941 │ │ │ │ │ -942} │ │ │ │ │ -943 │ │ │ │ │ -953template │ │ │ │ │ -954std::size_t receiveSizeAndSetupReceive(DataHandle& handle, │ │ │ │ │ -955 std::vector& trackers, │ │ │ │ │ -956 std::vector& size_requests, │ │ │ │ │ -957 std::vector& data_requests, │ │ │ │ │ -958 std::vector >& buffers, │ │ │ │ │ -959 MPI_Comm comm) │ │ │ │ │ -960{ │ │ │ │ │ -961 return checkAndContinue(handle, trackers, size_requests, data_requests, │ │ │ │ │ -buffers, comm, │ │ │ │ │ -962 NullPackUnpackFunctor(), SetupRecvRequest(), │ │ │ │ │ -false); │ │ │ │ │ -963} │ │ │ │ │ -964 │ │ │ │ │ -973template │ │ │ │ │ -974std::size_t checkSendAndContinueSending(DataHandle& handle, │ │ │ │ │ -975 std::vector& trackers, │ │ │ │ │ -976 std::vector& requests, │ │ │ │ │ -977 std::vector >& buffers, │ │ │ │ │ -978 MPI_Comm comm) │ │ │ │ │ -979{ │ │ │ │ │ -980 return checkAndContinue(handle, trackers, requests, requests, buffers, │ │ │ │ │ -comm, │ │ │ │ │ -981 NullPackUnpackFunctor(), SetupSendRequest()); │ │ │ │ │ -982} │ │ │ │ │ -983 │ │ │ │ │ -992template │ │ │ │ │ -993std::size_t checkReceiveAndContinueReceiving(DataHandle& handle, │ │ │ │ │ -994 std::vector& trackers, │ │ │ │ │ -995 std::vector& requests, │ │ │ │ │ -996 std::vector >& buffers, │ │ │ │ │ -997 MPI_Comm comm) │ │ │ │ │ -998{ │ │ │ │ │ -999 return checkAndContinue(handle, trackers, requests, requests, buffers, │ │ │ │ │ -comm, │ │ │ │ │ -1000 UnpackEntries(), SetupRecvRequest(), │ │ │ │ │ -1001 true, !Impl::callFixedSize(handle)); │ │ │ │ │ -1002} │ │ │ │ │ -1003 │ │ │ │ │ -1004 │ │ │ │ │ -1005bool validRecvRequests(const std::vector reqs) │ │ │ │ │ -1006{ │ │ │ │ │ -1007 for(std::vector::const_iterator i=reqs.begin(), end=reqs.end │ │ │ │ │ -(); │ │ │ │ │ -1008 i!=end; ++i) │ │ │ │ │ -1009 if(*i!=MPI_REQUEST_NULL) │ │ │ │ │ -1010 return true; │ │ │ │ │ -1011 return false; │ │ │ │ │ -1012} │ │ │ │ │ -1013 │ │ │ │ │ -1024template │ │ │ │ │ -1025std::size_t setupRequests(DataHandle& handle, │ │ │ │ │ -1026 std::vector& trackers, │ │ │ │ │ -1027 std::vector >& buffers, │ │ │ │ │ -1028 std::vector& requests, │ │ │ │ │ -1029 const Functor& setupFunctor, │ │ │ │ │ -1030 MPI_Comm communicator) │ │ │ │ │ -1031{ │ │ │ │ │ -1032 typedef typename std::vector::iterator TIter; │ │ │ │ │ -1033 typename std::vector >:: │ │ │ │ │ -iterator │ │ │ │ │ -1034 biter=buffers.begin(); │ │ │ │ │ -1035 typename std::vector::iterator riter=requests.begin(); │ │ │ │ │ -1036 std::size_t complete=0; │ │ │ │ │ -1037 for(TIter titer=trackers.begin(), end=trackers.end(); titer!=end; ++titer, │ │ │ │ │ -++biter, ++riter) │ │ │ │ │ -1038 { │ │ │ │ │ -1039 setupFunctor(handle, *titer, *biter, *riter, communicator); │ │ │ │ │ -1040 complete+=titer->finished(); │ │ │ │ │ -1041 } │ │ │ │ │ -1042 return complete; │ │ │ │ │ -1043} │ │ │ │ │ -1044} // end unnamed namespace │ │ │ │ │ -1045 │ │ │ │ │ -1046template │ │ │ │ │ -1047template │ │ │ │ │ -1048void VariableSizeCommunicator::setupInterfaceTrackers │ │ │ │ │ -(DataHandle& handle, │ │ │ │ │ -1049 std::vector& send_trackers, │ │ │ │ │ -1050 std::vector& recv_trackers) │ │ │ │ │ -1051{ │ │ │ │ │ -1052 if(interface_->size()==0) │ │ │ │ │ -1053 return; │ │ │ │ │ -1054 send_trackers.reserve(interface_->size()); │ │ │ │ │ -1055 recv_trackers.reserve(interface_->size()); │ │ │ │ │ -1056 │ │ │ │ │ -1057 int fixedsize=0; │ │ │ │ │ -1058 if(Impl::callFixedSize(handle)) │ │ │ │ │ -1059 ++fixedsize; │ │ │ │ │ -1060 │ │ │ │ │ -1061 │ │ │ │ │ -1062 typedef typename InterfaceMap::const_iterator IIter; │ │ │ │ │ -1063 for(IIter inf=interface_->begin(), end=interface_->end(); inf!=end; ++inf) │ │ │ │ │ -1064 { │ │ │ │ │ -1065 │ │ │ │ │ -1066 if(Impl::callFixedSize(handle) && InterfaceInformationChooser:: │ │ │ │ │ -getSend(inf->second).size()) │ │ │ │ │ -1067 fixedsize=handle.size(InterfaceInformationChooser::getSend(inf- │ │ │ │ │ ->second)[0]); │ │ │ │ │ -1068 assert(!Impl::callFixedSize(handle)||fixedsize>0); │ │ │ │ │ -1069 send_trackers.push_back(InterfaceTracker(inf->first, │ │ │ │ │ -1070 InterfaceInformationChooser::getSend(inf->second), fixedsize)); │ │ │ │ │ -1071 recv_trackers.push_back(InterfaceTracker(inf->first, │ │ │ │ │ -1072 InterfaceInformationChooser::getReceive(inf->second), fixedsize, │ │ │ │ │ -fixedsize==0)); │ │ │ │ │ -1073 } │ │ │ │ │ -1074} │ │ │ │ │ -1075 │ │ │ │ │ -1076template │ │ │ │ │ -1077template │ │ │ │ │ -1078void VariableSizeCommunicator::communicateFixedSize(DataHandle& │ │ │ │ │ -handle) │ │ │ │ │ -1079{ │ │ │ │ │ -1080 std::vector size_send_req(interface_->size()); │ │ │ │ │ -1081 std::vector size_recv_req(interface_->size()); │ │ │ │ │ -1082 │ │ │ │ │ -1083 std::vector send_trackers; │ │ │ │ │ -1084 std::vector recv_trackers; │ │ │ │ │ -1085 setupInterfaceTrackers(handle,send_trackers, recv_trackers); │ │ │ │ │ -1086 sendFixedSize(send_trackers, size_send_req, recv_trackers, size_recv_req, │ │ │ │ │ -communicator_); │ │ │ │ │ -1087 │ │ │ │ │ -1088 std::vector data_send_req(interface_->size(), MPI_REQUEST_ │ │ │ │ │ -NULL); │ │ │ │ │ -1089 std::vector data_recv_req(interface_->size(), MPI_REQUEST_ │ │ │ │ │ -NULL); │ │ │ │ │ -1090 typedef typename DataHandle::DataType DataType; │ │ │ │ │ -1091 std::vector > send_buffers(interface_->size(), │ │ │ │ │ -MessageBuffer(maxBufferSize_)), │ │ │ │ │ -1092 recv_buffers(interface_->size(), MessageBuffer(maxBufferSize_)); │ │ │ │ │ -1093 │ │ │ │ │ -1094 │ │ │ │ │ -1095 setupRequests(handle, send_trackers, send_buffers, data_send_req, │ │ │ │ │ -1096 SetupSendRequest(), communicator_); │ │ │ │ │ -1097 │ │ │ │ │ -1098 std::size_t no_size_to_recv, no_to_send, no_to_recv, old_size; │ │ │ │ │ -1099 no_size_to_recv = no_to_send = no_to_recv = old_size = interface_->size(); │ │ │ │ │ -1100 │ │ │ │ │ -1101 // Skip empty interfaces. │ │ │ │ │ -1102 typedef typename std::vector::const_iterator Iter; │ │ │ │ │ -1103 for(Iter i=recv_trackers.begin(), end=recv_trackers.end(); i!=end; ++i) │ │ │ │ │ -1104 if(i->empty()) │ │ │ │ │ -1105 --no_to_recv; │ │ │ │ │ -1106 for(Iter i=send_trackers.begin(), end=send_trackers.end(); i!=end; ++i) │ │ │ │ │ -1107 if(i->empty()) │ │ │ │ │ -1108 --no_to_send; │ │ │ │ │ -1109 │ │ │ │ │ -1110 while(no_size_to_recv+no_to_send+no_to_recv) │ │ │ │ │ -1111 { │ │ │ │ │ -1112 // Receive the fixedsize and setup receives accordingly │ │ │ │ │ -1113 if(no_size_to_recv) │ │ │ │ │ -1114 no_size_to_recv -= receiveSizeAndSetupReceive(handle,recv_trackers, size_ │ │ │ │ │ -recv_req, │ │ │ │ │ -1115 data_recv_req, recv_buffers, │ │ │ │ │ -1116 communicator_); │ │ │ │ │ -1117 │ │ │ │ │ -1118 // Check send completion and initiate other necessary sends │ │ │ │ │ -1119 if(no_to_send) │ │ │ │ │ -1120 no_to_send -= checkSendAndContinueSending(handle, send_trackers, data_ │ │ │ │ │ -send_req, │ │ │ │ │ -1121 send_buffers, communicator_); │ │ │ │ │ -1122 if(validRecvRequests(data_recv_req)) │ │ │ │ │ -1123 // Receive data and setup new unblocking receives if necessary │ │ │ │ │ -1124 no_to_recv -= checkReceiveAndContinueReceiving(handle, recv_trackers, │ │ │ │ │ -data_recv_req, │ │ │ │ │ -1125 recv_buffers, communicator_); │ │ │ │ │ -1126 } │ │ │ │ │ -1127 │ │ │ │ │ -1128 // Wait for completion of sending the size. │ │ │ │ │ -1129 //std::vector statuses(interface_->size(), MPI_STATUSES_ │ │ │ │ │ -IGNORE); │ │ │ │ │ -1130 MPI_Waitall(size_send_req.size(), &(size_send_req[0]), MPI_STATUSES_ │ │ │ │ │ -IGNORE); │ │ │ │ │ -1131 │ │ │ │ │ -1132} │ │ │ │ │ -1133 │ │ │ │ │ -1134template │ │ │ │ │ -1135template │ │ │ │ │ -1136void VariableSizeCommunicator::communicateSizes(DataHandle& │ │ │ │ │ -handle, │ │ │ │ │ -1137 std::vector& data_recv_trackers) │ │ │ │ │ -1138{ │ │ │ │ │ -1139 std::vector send_trackers; │ │ │ │ │ -1140 std::vector recv_trackers; │ │ │ │ │ -1141 std::size_t size = interface_->size(); │ │ │ │ │ -1142 std::vector send_requests(size, MPI_REQUEST_NULL); │ │ │ │ │ -1143 std::vector recv_requests(size, MPI_REQUEST_NULL); │ │ │ │ │ -1144 std::vector > │ │ │ │ │ -1145 send_buffers(size, MessageBuffer(maxBufferSize_)), │ │ │ │ │ -1146 recv_buffers(size, MessageBuffer(maxBufferSize_)); │ │ │ │ │ -1147 SizeDataHandle size_handle(handle,data_recv_trackers); │ │ │ │ │ -1148 setupInterfaceTrackers(size_handle,send_trackers, recv_trackers); │ │ │ │ │ -1149 setupRequests(size_handle, send_trackers, send_buffers, send_requests, │ │ │ │ │ -1150 SetupSendRequest >(), communicator_); │ │ │ │ │ -1151 setupRequests(size_handle, recv_trackers, recv_buffers, recv_requests, │ │ │ │ │ -1152 SetupRecvRequest >(), communicator_); │ │ │ │ │ -1153 │ │ │ │ │ -1154 // Count valid requests that we have to wait for. │ │ │ │ │ -1155 auto valid_req_func = │ │ │ │ │ -1156 [](const MPI_Request& req) { return req != MPI_REQUEST_NULL; }; │ │ │ │ │ -1157 │ │ │ │ │ -1158 auto size_to_send = std::count_if(send_requests.begin(), send_requests.end │ │ │ │ │ -(), │ │ │ │ │ -1159 valid_req_func); │ │ │ │ │ -1160 auto size_to_recv = std::count_if(recv_requests.begin(), recv_requests.end │ │ │ │ │ -(), │ │ │ │ │ -1161 valid_req_func); │ │ │ │ │ -1162 │ │ │ │ │ -1163 while(size_to_send+size_to_recv) │ │ │ │ │ -1164 { │ │ │ │ │ -1165 if(size_to_send) │ │ │ │ │ -1166 size_to_send -= │ │ │ │ │ -1167 checkSendAndContinueSending(size_handle, send_trackers, send_requests, │ │ │ │ │ -1168 send_buffers, communicator_); │ │ │ │ │ -1169 if(size_to_recv) │ │ │ │ │ -1170 // Could have done this using checkSendAndContinueSending │ │ │ │ │ -1171 // But the call below is more efficient as UnpackSizeEntries │ │ │ │ │ -1172 // uses std::copy. │ │ │ │ │ -1173 size_to_recv -= │ │ │ │ │ -1174 checkAndContinue(size_handle, recv_trackers, recv_requests, recv_requests, │ │ │ │ │ -1175 recv_buffers, communicator_, UnpackSizeEntries(), │ │ │ │ │ -1176 SetupRecvRequest >()); │ │ │ │ │ -1177 } │ │ │ │ │ -1178} │ │ │ │ │ -1179 │ │ │ │ │ -1180template │ │ │ │ │ -1181template │ │ │ │ │ -1182void VariableSizeCommunicator::communicateVariableSize │ │ │ │ │ -(DataHandle& handle) │ │ │ │ │ -1183{ │ │ │ │ │ -1184 │ │ │ │ │ -1185 std::vector send_trackers; │ │ │ │ │ -1186 std::vector recv_trackers; │ │ │ │ │ -1187 setupInterfaceTrackers(handle, send_trackers, recv_trackers); │ │ │ │ │ -1188 │ │ │ │ │ -1189 std::vector send_requests(interface_->size(), MPI_REQUEST_ │ │ │ │ │ -NULL); │ │ │ │ │ -1190 std::vector recv_requests(interface_->size(), MPI_REQUEST_ │ │ │ │ │ -NULL); │ │ │ │ │ -1191 typedef typename DataHandle::DataType DataType; │ │ │ │ │ -1192 std::vector > │ │ │ │ │ -1193 send_buffers(interface_->size(), MessageBuffer(maxBufferSize_)), │ │ │ │ │ -1194 recv_buffers(interface_->size(), MessageBuffer(maxBufferSize_)); │ │ │ │ │ -1195 │ │ │ │ │ -1196 communicateSizes(handle, recv_trackers); │ │ │ │ │ -1197 // Setup requests for sending and receiving. │ │ │ │ │ -1198 setupRequests(handle, send_trackers, send_buffers, send_requests, │ │ │ │ │ -1199 SetupSendRequest(), communicator_); │ │ │ │ │ -1200 setupRequests(handle, recv_trackers, recv_buffers, recv_requests, │ │ │ │ │ -1201 SetupRecvRequest(), communicator_); │ │ │ │ │ -1202 │ │ │ │ │ -1203 // Determine number of valid requests. │ │ │ │ │ -1204 auto valid_req_func = │ │ │ │ │ -1205 [](const MPI_Request& req) { return req != MPI_REQUEST_NULL;}; │ │ │ │ │ -1206 │ │ │ │ │ -1207 auto no_to_send = std::count_if(send_requests.begin(), send_requests.end │ │ │ │ │ -(), │ │ │ │ │ -1208 valid_req_func); │ │ │ │ │ -1209 auto no_to_recv = std::count_if(recv_requests.begin(), recv_requests.end │ │ │ │ │ -(), │ │ │ │ │ -1210 valid_req_func); │ │ │ │ │ -1211 while(no_to_send+no_to_recv) │ │ │ │ │ -1212 { │ │ │ │ │ -1213 // Check send completion and initiate other necessary sends │ │ │ │ │ -1214 if(no_to_send) │ │ │ │ │ -1215 no_to_send -= checkSendAndContinueSending(handle, send_trackers, send_ │ │ │ │ │ -requests, │ │ │ │ │ -1216 send_buffers, communicator_); │ │ │ │ │ -1217 if(no_to_recv) │ │ │ │ │ -1218 // Receive data and setup new unblocking receives if necessary │ │ │ │ │ -1219 no_to_recv -= checkReceiveAndContinueReceiving(handle, recv_trackers, │ │ │ │ │ -recv_requests, │ │ │ │ │ -1220 recv_buffers, communicator_); │ │ │ │ │ -1221 } │ │ │ │ │ -1222} │ │ │ │ │ -1223 │ │ │ │ │ -1224template │ │ │ │ │ -1225template │ │ │ │ │ -1226void VariableSizeCommunicator::communicate(DataHandle& handle) │ │ │ │ │ -1227{ │ │ │ │ │ -1228 if( interface_->size() == 0) │ │ │ │ │ -1229 // Simply return as otherwise we will index an empty container │ │ │ │ │ -1230 // either for MPI_Wait_all or MPI_Test_some. │ │ │ │ │ -1231 return; │ │ │ │ │ -1232 │ │ │ │ │ -1233 if(Impl::callFixedSize(handle)) │ │ │ │ │ -1234 communicateFixedSize(handle); │ │ │ │ │ -1235 else │ │ │ │ │ -1236 communicateVariableSize(handle); │ │ │ │ │ -1237} │ │ │ │ │ -1238} // end namespace Dune │ │ │ │ │ -1239 │ │ │ │ │ -1240#endif // HAVE_MPI │ │ │ │ │ -1241#endif // DUNE_COMMON_PARALLEL_VARIABLESIZECOMMUNICATOR_HH │ │ │ │ │ -fixedSize │ │ │ │ │ -std::size_t fixedSize │ │ │ │ │ -The number of data items per index if it is fixed, 0 otherwise. │ │ │ │ │ -Definition variablesizecommunicator.hh:264 │ │ │ │ │ -mpitraits.hh │ │ │ │ │ -Traits classes for mapping types onto MPI_Datatype. │ │ │ │ │ -concept.hh │ │ │ │ │ -Infrastructure for concepts. │ │ │ │ │ -Dune::Interface::communicator │ │ │ │ │ -MPI_Comm communicator() const │ │ │ │ │ -Get the MPI Communicator. │ │ │ │ │ -Definition parallel/interface.hh:426 │ │ │ │ │ +125 │ │ │ │ │ +126 │ │ │ │ │ +149template │ │ │ │ │ +150auto orderedOverload(F&&... f) │ │ │ │ │ +151{ │ │ │ │ │ +152 return Impl::OrderedOverloadSet...>(std::forward(f)...); │ │ │ │ │ +153} │ │ │ │ │ +154 │ │ │ │ │ +155 │ │ │ │ │ +156 │ │ │ │ │ +157} // end namespace Dune │ │ │ │ │ +158 │ │ │ │ │ +159#endif // DUNE_COMMON_OVERLOADSET_HH │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +Dune::orderedOverload │ │ │ │ │ +auto orderedOverload(F &&... f) │ │ │ │ │ +Create an ordered overload set. │ │ │ │ │ +Definition overloadset.hh:150 │ │ │ │ │ +Dune::overload │ │ │ │ │ +auto overload(F &&... f) │ │ │ │ │ +Create an overload set. │ │ │ │ │ +Definition overloadset.hh:61 │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::size │ │ │ │ │ -constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std:: │ │ │ │ │ -integer_sequence< T, II... >) │ │ │ │ │ -Return the size of the sequence. │ │ │ │ │ -Definition integersequence.hh:75 │ │ │ │ │ -Dune::empty │ │ │ │ │ -constexpr std::bool_constant<(sizeof...(II)==0)> empty(std::integer_sequence< │ │ │ │ │ -T, II... >) │ │ │ │ │ -Checks whether the sequence is empty. │ │ │ │ │ -Definition integersequence.hh:80 │ │ │ │ │ -Dune::MPITraits::getType │ │ │ │ │ -static MPI_Datatype getType() │ │ │ │ │ -Definition mpitraits.hh:48 │ │ │ │ │ -Dune::InterfaceInformation::size │ │ │ │ │ -size_t size() const │ │ │ │ │ -Get the number of entries in the interface. │ │ │ │ │ -Definition parallel/interface.hh:117 │ │ │ │ │ -Dune::Interface │ │ │ │ │ -Communication interface between remote and local indices. │ │ │ │ │ -Definition parallel/interface.hh:218 │ │ │ │ │ -Dune::Concept::HasFixedSize │ │ │ │ │ -Definition variablesizecommunicator.hh:42 │ │ │ │ │ -Dune::Concept::HasFixedSize::require │ │ │ │ │ -auto require(H &&h) -> decltype(h.fixedSize()) │ │ │ │ │ -Dune::VariableSizeCommunicator │ │ │ │ │ -A buffered communicator where the amount of data sent does not have to be known │ │ │ │ │ -a priori. │ │ │ │ │ -Definition variablesizecommunicator.hh:331 │ │ │ │ │ -Dune::VariableSizeCommunicator::VariableSizeCommunicator │ │ │ │ │ -VariableSizeCommunicator(const Interface &inf, std::size_t max_buffer_size) │ │ │ │ │ -Creates a communicator with a specific maximum buffer size. │ │ │ │ │ -Definition variablesizecommunicator.hh:403 │ │ │ │ │ -Dune::VariableSizeCommunicator::backward │ │ │ │ │ -void backward(DataHandle &handle) │ │ │ │ │ -Communicate backwards. │ │ │ │ │ -Definition variablesizecommunicator.hh:485 │ │ │ │ │ -Dune::VariableSizeCommunicator::~VariableSizeCommunicator │ │ │ │ │ -~VariableSizeCommunicator() │ │ │ │ │ -Definition variablesizecommunicator.hh:409 │ │ │ │ │ -Dune::VariableSizeCommunicator::VariableSizeCommunicator │ │ │ │ │ -VariableSizeCommunicator(MPI_Comm comm, const InterfaceMap &inf, std::size_ │ │ │ │ │ -t max_buffer_size) │ │ │ │ │ -Creates a communicator with a specific maximum buffer size. │ │ │ │ │ -Definition variablesizecommunicator.hh:392 │ │ │ │ │ -Dune::VariableSizeCommunicator::VariableSizeCommunicator │ │ │ │ │ -VariableSizeCommunicator(const VariableSizeCommunicator &other) │ │ │ │ │ -Copy-constructs a communicator. │ │ │ │ │ -Definition variablesizecommunicator.hh:418 │ │ │ │ │ -Dune::VariableSizeCommunicator::forward │ │ │ │ │ -void forward(DataHandle &handle) │ │ │ │ │ -Communicate forward. │ │ │ │ │ -Definition variablesizecommunicator.hh:460 │ │ │ │ │ -Dune::VariableSizeCommunicator::operator= │ │ │ │ │ -VariableSizeCommunicator & operator=(const VariableSizeCommunicator &other) │ │ │ │ │ -Copy-assignes a communicator. │ │ │ │ │ -Definition variablesizecommunicator.hh:428 │ │ │ │ │ -Dune::VariableSizeCommunicator::InterfaceMap │ │ │ │ │ -std::map< int, std::pair< InterfaceInformation, InterfaceInformation >, std:: │ │ │ │ │ -less< int >, typename std::allocator_traits< Allocator >::template rebind_ │ │ │ │ │ -alloc< std::pair< const int, std::pair< InterfaceInformation, │ │ │ │ │ -InterfaceInformation > > > > InterfaceMap │ │ │ │ │ -The type of the map from process number to InterfaceInformation for sending and │ │ │ │ │ -receiving to and from... │ │ │ │ │ -Definition variablesizecommunicator.hh:339 │ │ │ │ │ -Dune::VariableSizeCommunicator::VariableSizeCommunicator │ │ │ │ │ -VariableSizeCommunicator(MPI_Comm comm, const InterfaceMap &inf) │ │ │ │ │ -Creates a communicator with the default maximum buffer size. │ │ │ │ │ -Definition variablesizecommunicator.hh:348 │ │ │ │ │ -Dune::VariableSizeCommunicator::VariableSizeCommunicator │ │ │ │ │ -VariableSizeCommunicator(const Interface &inf) │ │ │ │ │ -Creates a communicator with the default maximum buffer size. │ │ │ │ │ -Definition variablesizecommunicator.hh:357 │ │ │ │ │ -interface.hh │ │ │ │ │ -Provides classes for building the communication interface between remote │ │ │ │ │ -indices. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00041.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpipack.hh File Reference │ │ │ │ +dune-common: parameterizedobject.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,52 +65,43 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
mpipack.hh File Reference
│ │ │ │ +
parameterizedobject.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ -

See MPI_Pack. │ │ │ │ -More...

│ │ │ │ -
#include <type_traits>
│ │ │ │ -#include <vector>
│ │ │ │ -#include <mpi.h>
│ │ │ │ -#include <dune/common/parallel/mpicommunication.hh>
│ │ │ │ -#include <dune/common/parallel/mpidata.hh>
│ │ │ │ +
#include <functional>
│ │ │ │ +#include <map>
│ │ │ │ +#include <memory>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │ +#include <dune/common/typeutilities.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::MPIPack
 
struct  Dune::MPIData< P, std::enable_if_t< std::is_same< std::remove_const_t< P >, MPIPack >::value > >
class  Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

See MPI_Pack.

│ │ │ │ -

This Wrapper class takes care of the memory management and provides methods to pack and unpack objects. All objects that can be used for MPI communication can also be packed and unpacked to/from MPIPack.

│ │ │ │ -
Author
Nils-Arne Dreier
│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,36 +1,23 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -mpipack.hh File Reference │ │ │ │ │ -Common » Parallel_Communication │ │ │ │ │ -See MPI_Pack. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +parameterizedobject.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ - class   Dune::MPIPack │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::MPIData<_P,_std::enable_if_t<_std::is_same<_std::remove_const_t< │ │ │ │ │ - P_>,_MPIPack_>::value_>_> │ │ │ │ │ +class   Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -See MPI_Pack. │ │ │ │ │ -This Wrapper class takes care of the memory management and provides methods to │ │ │ │ │ -pack and unpack objects. All objects that can be used for MPI communication can │ │ │ │ │ -also be packed and unpacked to/from MPIPack. │ │ │ │ │ - Author │ │ │ │ │ - Nils-Arne Dreier │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00041_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpipack.hh Source File │ │ │ │ +dune-common: parameterizedobject.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,287 +70,182 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
mpipack.hh
│ │ │ │ +
parameterizedobject.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ -
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ +Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
│ │ │ │ +
2// vi: set et ts=4 sw=4 sts=4:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
20#ifndef DUNE_COMMON_PARALLEL_MPIPACK_HH
│ │ │ │ -
21#define DUNE_COMMON_PARALLEL_MPIPACK_HH
│ │ │ │ -
22
│ │ │ │ -
23#if HAVE_MPI
│ │ │ │ -
24
│ │ │ │ -
25#include <type_traits>
│ │ │ │ -
26#include <vector>
│ │ │ │ -
27
│ │ │ │ -
28#include <mpi.h>
│ │ │ │ -
29
│ │ │ │ - │ │ │ │ - │ │ │ │ -
32
│ │ │ │ -
33
│ │ │ │ -
34namespace Dune {
│ │ │ │ -
35
│ │ │ │ -
│ │ │ │ -
36 class MPIPack {
│ │ │ │ -
37 std::vector<char> _buffer;
│ │ │ │ -
38 int _position;
│ │ │ │ -
39 MPI_Comm _comm;
│ │ │ │ -
40
│ │ │ │ -
41 friend struct MPIData<MPIPack>;
│ │ │ │ -
42 friend struct MPIData<const MPIPack>;
│ │ │ │ -
43 public:
│ │ │ │ -
│ │ │ │ -
44 MPIPack(Communication<MPI_Comm> comm, std::size_t size = 0)
│ │ │ │ -
45 : _buffer(size)
│ │ │ │ -
46 , _position(0)
│ │ │ │ -
47 , _comm(comm)
│ │ │ │ -
48 {}
│ │ │ │ -
│ │ │ │ -
49
│ │ │ │ -
50 // Its not valid to copy a MPIPack but you can move it
│ │ │ │ -
51 MPIPack(const MPIPack&) = delete;
│ │ │ │ -
52 MPIPack& operator = (const MPIPack& other) = delete;
│ │ │ │ -
53 MPIPack(MPIPack&&) = default;
│ │ │ │ -
54 MPIPack& operator = (MPIPack&& other) = default;
│ │ │ │ -
55
│ │ │ │ -
61 template<class T>
│ │ │ │ -
│ │ │ │ -
62 void pack(const T& data){
│ │ │ │ -
63 auto mpidata = getMPIData(data);
│ │ │ │ -
64 int size = getPackSize(mpidata.size(), _comm, mpidata.type());
│ │ │ │ -
65 constexpr bool has_static_size = decltype(getMPIData(std::declval<T&>()))::static_size;
│ │ │ │ -
66 if(!has_static_size)
│ │ │ │ -
67 size += getPackSize(1, _comm, MPI_INT);
│ │ │ │ -
68 if (_position + size > 0 && size_t(_position + size) > _buffer.size()) // resize buffer if necessary
│ │ │ │ -
69 _buffer.resize(_position + size);
│ │ │ │ -
70 if(!has_static_size){
│ │ │ │ -
71 int size = mpidata.size();
│ │ │ │ -
72 MPI_Pack(&size, 1, MPI_INT, _buffer.data(), _buffer.size(),
│ │ │ │ -
73 &_position, _comm);
│ │ │ │ -
74 }
│ │ │ │ -
75 MPI_Pack(mpidata.ptr(), mpidata.size(),
│ │ │ │ -
76 mpidata.type(), _buffer.data(), _buffer.size(),
│ │ │ │ -
77 &_position, _comm);
│ │ │ │ -
78 }
│ │ │ │ -
│ │ │ │ -
79
│ │ │ │ -
84 template<class T>
│ │ │ │ -
│ │ │ │ -
85 auto /*void*/ unpack(T& data)
│ │ │ │ -
86 -> std::enable_if_t<decltype(getMPIData(data))::static_size, void>
│ │ │ │ -
87 {
│ │ │ │ -
88 auto mpidata = getMPIData(data);
│ │ │ │ -
89 MPI_Unpack(_buffer.data(), _buffer.size(), &_position,
│ │ │ │ -
90 mpidata.ptr(), mpidata.size(),
│ │ │ │ -
91 mpidata.type(), _comm);
│ │ │ │ -
92 }
│ │ │ │ -
│ │ │ │ -
93
│ │ │ │ -
98 template<class T>
│ │ │ │ -
│ │ │ │ -
99 auto /*void*/ unpack(T& data)
│ │ │ │ -
100 -> std::enable_if_t<!decltype(getMPIData(data))::static_size, void>
│ │ │ │ -
101 {
│ │ │ │ -
102 auto mpidata = getMPIData(data);
│ │ │ │ -
103 int size = 0;
│ │ │ │ -
104 MPI_Unpack(_buffer.data(), _buffer.size(), &_position,
│ │ │ │ -
105 &size, 1,
│ │ │ │ -
106 MPI_INT, _comm);
│ │ │ │ -
107 mpidata.resize(size);
│ │ │ │ -
108 MPI_Unpack(_buffer.data(), _buffer.size(), &_position,
│ │ │ │ -
109 mpidata.ptr(), mpidata.size(),
│ │ │ │ -
110 mpidata.type(), _comm);
│ │ │ │ -
111 }
│ │ │ │ -
│ │ │ │ -
112
│ │ │ │ -
113
│ │ │ │ -
115 template<typename T>
│ │ │ │ -
│ │ │ │ -
116 friend MPIPack& operator << (MPIPack& p, const T& t){
│ │ │ │ -
117 p.pack(t);
│ │ │ │ -
118 return p;
│ │ │ │ -
119 }
│ │ │ │ -
│ │ │ │ -
120
│ │ │ │ -
122 template<typename T>
│ │ │ │ -
│ │ │ │ -
123 friend MPIPack& operator >> (MPIPack& p, T& t){
│ │ │ │ -
124 p.unpack(t);
│ │ │ │ -
125 return p;
│ │ │ │ -
126 }
│ │ │ │ -
│ │ │ │ -
127
│ │ │ │ -
129 template<typename T>
│ │ │ │ -
│ │ │ │ -
130 MPIPack& read(T& t){
│ │ │ │ -
131 unpack(t);
│ │ │ │ -
132 return *this;
│ │ │ │ -
133 }
│ │ │ │ -
│ │ │ │ -
134
│ │ │ │ -
136 template<typename T>
│ │ │ │ -
│ │ │ │ -
137 MPIPack& write(const T& t){
│ │ │ │ -
138 pack(t);
│ │ │ │ -
139 return *this;
│ │ │ │ -
140 }
│ │ │ │ -
│ │ │ │ -
141
│ │ │ │ +
5#ifndef DUNE_COMMON_PARAMETERIZEDOBJECT_HH
│ │ │ │ +
6#define DUNE_COMMON_PARAMETERIZEDOBJECT_HH
│ │ │ │ +
7
│ │ │ │ +
8#include <functional>
│ │ │ │ +
9#include <map>
│ │ │ │ +
10#include <memory>
│ │ │ │ +
11
│ │ │ │ + │ │ │ │ + │ │ │ │ +
14
│ │ │ │ +
15namespace Dune {
│ │ │ │ +
16
│ │ │ │ +
34template<typename Signature,
│ │ │ │ +
35 typename KeyT = std::string>
│ │ │ │ + │ │ │ │ +
37
│ │ │ │ +
38template<typename TypeT,
│ │ │ │ +
39 typename KeyT,
│ │ │ │ +
40 typename... Args>
│ │ │ │ +
│ │ │ │ +
41class ParameterizedObjectFactory<TypeT(Args...), KeyT>
│ │ │ │ +
42{
│ │ │ │ +
43 public:
│ │ │ │ +
44
│ │ │ │ +
46 typedef KeyT Key;
│ │ │ │ +
47
│ │ │ │ +
49 using Type = TypeT;
│ │ │ │ +
50
│ │ │ │ +
51 protected:
│ │ │ │ +
52
│ │ │ │ +
53 using Creator = std::function<Type(Args...)>;
│ │ │ │ +
54
│ │ │ │ +
55 template<class F>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
57 -> decltype( std::declval<F>()(std::declval<Args>()...), std::true_type())
│ │ │ │ +
58 {
│ │ │ │ +
59 return {};
│ │ │ │ +
60 }
│ │ │ │ +
│ │ │ │ +
61
│ │ │ │ +
62 template<class F>
│ │ │ │ +
│ │ │ │ +
63 static constexpr std::false_type has_proper_signature(Dune::PriorityTag<0>)
│ │ │ │ +
64 {
│ │ │ │ +
65 return {};
│ │ │ │ +
66 }
│ │ │ │ +
│ │ │ │ +
67
│ │ │ │ +
68 public:
│ │ │ │ +
69
│ │ │ │ +
│ │ │ │ +
77 Type create(Key const& key, Args ... args) const {
│ │ │ │ +
78 typename Registry::const_iterator i = registry_.find(key);
│ │ │ │ +
79 if (i == registry_.end()) {
│ │ │ │ + │ │ │ │ +
81 "ParametrizedObjectFactory: key ``" <<
│ │ │ │ +
82 key << "'' not registered");
│ │ │ │ +
83 }
│ │ │ │ +
84 else return i->second(args...);
│ │ │ │ +
85 }
│ │ │ │ +
│ │ │ │ +
86
│ │ │ │ +
100 template<class Impl>
│ │ │ │ +
│ │ │ │ +
101 void define(Key const& key)
│ │ │ │ +
102 {
│ │ │ │ +
103 registry_[key] = DefaultCreator<Impl>();
│ │ │ │ +
104 }
│ │ │ │ +
│ │ │ │ +
105
│ │ │ │ +
119 template<class F,
│ │ │ │ +
120 typename std::enable_if<has_proper_signature<F>(PriorityTag<42>()), int>::type = 0>
│ │ │ │ +
│ │ │ │ +
121 void define(Key const& key, F&& f)
│ │ │ │ +
122 {
│ │ │ │ +
123 registry_[key] = f;
│ │ │ │ +
124 }
│ │ │ │ +
│ │ │ │ +
125
│ │ │ │ +
140 template<class Impl,
│ │ │ │ +
141 typename std::enable_if<
│ │ │ │ +
142 std::is_convertible<Impl, Type>::value
│ │ │ │ +
143 and not std::is_convertible<Impl, Creator>::value,
│ │ │ │ +
144 int>::type = 0>
│ │ │ │
│ │ │ │ -
145 void resize(size_t size){
│ │ │ │ -
146 _buffer.resize(size);
│ │ │ │ -
147 }
│ │ │ │ -
│ │ │ │ -
148
│ │ │ │ -
│ │ │ │ -
151 void enlarge(int s) {
│ │ │ │ -
152 _buffer.resize(_buffer.size() + s);
│ │ │ │ -
153 }
│ │ │ │ +
145 void define(Key const& key, Impl&& t)
│ │ │ │ +
146 {
│ │ │ │ +
147 registry_[key] = [=](Args...) { return t;};
│ │ │ │ +
148 }
│ │ │ │ +
│ │ │ │ +
149
│ │ │ │ +
│ │ │ │ +
150 bool contains(Key const& key) const
│ │ │ │ +
151 {
│ │ │ │ +
152 return registry_.count(key);
│ │ │ │ +
153 }
│ │ │ │
│ │ │ │
154
│ │ │ │ -
│ │ │ │ -
157 size_t size() const {
│ │ │ │ -
158 return _buffer.size();
│ │ │ │ -
159 }
│ │ │ │ -
│ │ │ │ -
160
│ │ │ │ -
│ │ │ │ -
164 void seek(int p){
│ │ │ │ -
165 _position = p;
│ │ │ │ -
166 }
│ │ │ │ -
│ │ │ │ -
167
│ │ │ │ -
│ │ │ │ -
171 int tell() const{
│ │ │ │ -
172 return _position;
│ │ │ │ -
173 }
│ │ │ │ -
│ │ │ │ -
174
│ │ │ │ -
│ │ │ │ -
177 bool eof() const{
│ │ │ │ -
178 return std::size_t(_position)==_buffer.size();
│ │ │ │ -
179 }
│ │ │ │ -
│ │ │ │ -
180
│ │ │ │ -
│ │ │ │ -
184 static int getPackSize(int len, const MPI_Comm& comm, const MPI_Datatype& dt){
│ │ │ │ -
185 int size;
│ │ │ │ -
186 MPI_Pack_size(len, dt, comm, &size);
│ │ │ │ -
187 return size;
│ │ │ │ -
188 }
│ │ │ │ +
155 private:
│ │ │ │ +
156
│ │ │ │ +
157 template<class T>
│ │ │ │ +
158 struct Tag{};
│ │ │ │ +
159
│ │ │ │ +
160 template<class Impl>
│ │ │ │ +
161 struct DefaultCreator
│ │ │ │ +
162 {
│ │ │ │ +
163 template<class... T>
│ │ │ │ +
164 Type operator()(T&&... args) const
│ │ │ │ +
165 {
│ │ │ │ +
166 return DefaultCreator::create(Tag<Type>(), PriorityTag<42>(), std::forward<T>(args)...);
│ │ │ │ +
167 }
│ │ │ │ +
168
│ │ │ │ +
169 template<class Target, class... T>
│ │ │ │ +
170 static Type create(Tag<Target>, PriorityTag<1>, T&& ... args) {
│ │ │ │ +
171 return Impl(std::forward<T>(args)...);
│ │ │ │ +
172 }
│ │ │ │ +
173
│ │ │ │ +
174 template<class Target, class... T>
│ │ │ │ +
175 static Type create(Tag<std::unique_ptr<Target>>, PriorityTag<2>, T&& ... args) {
│ │ │ │ +
176 return std::make_unique<Impl>(std::forward<T>(args)...);
│ │ │ │ +
177 }
│ │ │ │ +
178
│ │ │ │ +
179 template<class Target, class... T>
│ │ │ │ +
180 static Type create(Tag<std::shared_ptr<Target>>, PriorityTag<3>, T&& ... args) {
│ │ │ │ +
181 return std::make_shared<Impl>(std::forward<T>(args)...);
│ │ │ │ +
182 }
│ │ │ │ +
183
│ │ │ │ +
184 };
│ │ │ │ +
185
│ │ │ │ +
186 typedef std::map<Key, Creator> Registry;
│ │ │ │ +
187 Registry registry_;
│ │ │ │ +
188};
│ │ │ │
│ │ │ │
189
│ │ │ │ -
│ │ │ │ -
190 friend bool operator==(const MPIPack& a, const MPIPack& b) {
│ │ │ │ -
191 return a._buffer == b._buffer && a._comm == b._comm;
│ │ │ │ -
192 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
193 friend bool operator!=(const MPIPack& a, const MPIPack& b) {
│ │ │ │ -
194 return !(a==b);
│ │ │ │ -
195 }
│ │ │ │ -
│ │ │ │ -
196
│ │ │ │ -
197 };
│ │ │ │ -
│ │ │ │ -
198
│ │ │ │ -
199 template<class P>
│ │ │ │ -
│ │ │ │ -
200 struct MPIData<P, std::enable_if_t<std::is_same<std::remove_const_t<P>, MPIPack>::value>> {
│ │ │ │ -
201 protected:
│ │ │ │ -
202 friend auto getMPIData<P>(P& t);
│ │ │ │ -
│ │ │ │ -
203 MPIData(P& t) :
│ │ │ │ -
204 data_(t)
│ │ │ │ -
205 {}
│ │ │ │ -
│ │ │ │ -
206 public:
│ │ │ │ -
207 static constexpr bool static_size = std::is_const<P>::value;
│ │ │ │ -
208
│ │ │ │ -
│ │ │ │ -
209 void* ptr() {
│ │ │ │ -
210 return (void*) data_._buffer.data();
│ │ │ │ -
211 }
│ │ │ │ -
│ │ │ │ -
212
│ │ │ │ -
│ │ │ │ -
213 int size() {
│ │ │ │ -
214 return data_.size();
│ │ │ │ -
215 }
│ │ │ │ -
│ │ │ │ -
216
│ │ │ │ -
│ │ │ │ -
217 MPI_Datatype type() const{
│ │ │ │ -
218 return MPI_PACKED;
│ │ │ │ -
219 }
│ │ │ │ -
│ │ │ │ -
220
│ │ │ │ -
│ │ │ │ -
221 void resize(int size){
│ │ │ │ -
222 data_.resize(size);
│ │ │ │ -
223 }
│ │ │ │ -
│ │ │ │ -
224 protected:
│ │ │ │ - │ │ │ │ -
226 };
│ │ │ │ -
│ │ │ │ -
227
│ │ │ │ -
228} // end namespace Dune
│ │ │ │ -
229
│ │ │ │ -
230#endif // HAVE_MPI
│ │ │ │ -
231#endif // DUNE_COMMON_PARALLEL_MPIPACK_HH
│ │ │ │ -
Interface class to translate objects to a MPI_Datatype, void* and size used for MPI calls.
│ │ │ │ -
Implements an utility class that provides MPI's collective communication methods.
│ │ │ │ -
STL namespace.
│ │ │ │ +
190
│ │ │ │ +
191
│ │ │ │ +
192} // end namespace Dune
│ │ │ │ +
193
│ │ │ │ +
194#endif // DUNE_COMMON_PARAMETERIZEDOBJECT_HH
│ │ │ │ +
A few common exception classes.
│ │ │ │ +
Utilities for type computations, constraining overloads, ...
│ │ │ │ +
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
auto getMPIData(T &t)
Definition mpidata.hh:44
│ │ │ │ -
Collective communication interface and sequential default implementation.
Definition communication.hh:100
│ │ │ │ -
Definition mpidata.hh:51
│ │ │ │ -
T & data_
Definition mpidata.hh:54
│ │ │ │ -
int size() const
Definition mpidata.hh:68
│ │ │ │ -
static constexpr bool static_size
Definition mpidata.hh:66
│ │ │ │ -
Definition mpipack.hh:36
│ │ │ │ -
void enlarge(int s)
Enlarges the internal buffer.
Definition mpipack.hh:151
│ │ │ │ -
friend MPIPack & operator>>(MPIPack &p, T &t)
Unpacks data from the object.
Definition mpipack.hh:123
│ │ │ │ -
friend MPIPack & operator<<(MPIPack &p, const T &t)
Packs the data into the object. Enlarges the internal buffer if necessary.
Definition mpipack.hh:116
│ │ │ │ -
friend bool operator!=(const MPIPack &a, const MPIPack &b)
Definition mpipack.hh:193
│ │ │ │ -
size_t size() const
Returns the size of the internal buffer.
Definition mpipack.hh:157
│ │ │ │ -
MPIPack & operator=(const MPIPack &other)=delete
│ │ │ │ -
MPIPack(Communication< MPI_Comm > comm, std::size_t size=0)
Definition mpipack.hh:44
│ │ │ │ -
void pack(const T &data)
Packs the data into the object. Enlarges the internal buffer if necessary.
Definition mpipack.hh:62
│ │ │ │ -
auto unpack(T &data) -> std::enable_if_t<!decltype(getMPIData(data))::static_size, void >
Unpacks data from the object.
Definition mpipack.hh:99
│ │ │ │ -
auto unpack(T &data) -> std::enable_if_t< decltype(getMPIData(data))::static_size, void >
Unpacks data from the object.
Definition mpipack.hh:85
│ │ │ │ -
friend bool operator==(const MPIPack &a, const MPIPack &b)
Definition mpipack.hh:190
│ │ │ │ -
MPIPack(const MPIPack &)=delete
│ │ │ │ -
void seek(int p)
Sets the position in the buffer where the next pack/unpack operation should take place.
Definition mpipack.hh:164
│ │ │ │ -
bool eof() const
Checks whether the end of the buffer is reached.
Definition mpipack.hh:177
│ │ │ │ -
void resize(size_t size)
Resizes the internal buffer.
Definition mpipack.hh:145
│ │ │ │ -
int tell() const
Gets the position in the buffer where the next pack/unpack operation should take place.
Definition mpipack.hh:171
│ │ │ │ -
MPIPack(MPIPack &&)=default
│ │ │ │ -
MPIPack & read(T &t)
Unpacks data from the object.
Definition mpipack.hh:130
│ │ │ │ -
static int getPackSize(int len, const MPI_Comm &comm, const MPI_Datatype &dt)
Returns the size of the data needed to store the data in an MPIPack. See MPI_Pack_size.
Definition mpipack.hh:184
│ │ │ │ -
MPIPack & write(const T &t)
Packs the data into the object. Enlarges the internal buffer if necessary.
Definition mpipack.hh:137
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ +
Default exception if a function was called while the object is not in a valid state for that function...
Definition exceptions.hh:281
│ │ │ │ +
A factory class for parameterized objects.
Definition parameterizedobject.hh:36
│ │ │ │ +
std::function< Type(Args...)> Creator
Definition parameterizedobject.hh:53
│ │ │ │ +
static constexpr auto has_proper_signature(Dune::PriorityTag< 1 >) -> decltype(std::declval< F >()(std::declval< Args >()...), std::true_type())
Definition parameterizedobject.hh:56
│ │ │ │ +
TypeT Type
The type of objects created by the factory.
Definition parameterizedobject.hh:49
│ │ │ │ +
void define(Key const &key, Impl &&t)
Registers a new type with a key.
Definition parameterizedobject.hh:145
│ │ │ │ +
KeyT Key
The typ of the keys.
Definition parameterizedobject.hh:46
│ │ │ │ +
Type create(Key const &key, Args ... args) const
Creates an object identified by a key from given parameters.
Definition parameterizedobject.hh:77
│ │ │ │ +
void define(Key const &key)
Registers a new type with a key.
Definition parameterizedobject.hh:101
│ │ │ │ +
void define(Key const &key, F &&f)
Registers a new creator with a key.
Definition parameterizedobject.hh:121
│ │ │ │ +
static constexpr std::false_type has_proper_signature(Dune::PriorityTag< 0 >)
Definition parameterizedobject.hh:63
│ │ │ │ +
bool contains(Key const &key) const
Definition parameterizedobject.hh:150
│ │ │ │ +
Helper class for tagging priorities.
Definition typeutilities.hh:73
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,327 +1,200 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -mpipack.hh │ │ │ │ │ +parameterizedobject.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ -2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ +1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- │ │ │ │ │ +2// vi: set et ts=4 sw=4 sts=4: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -20#ifndef DUNE_COMMON_PARALLEL_MPIPACK_HH │ │ │ │ │ -21#define DUNE_COMMON_PARALLEL_MPIPACK_HH │ │ │ │ │ -22 │ │ │ │ │ -23#if HAVE_MPI │ │ │ │ │ -24 │ │ │ │ │ -25#include │ │ │ │ │ -26#include │ │ │ │ │ -27 │ │ │ │ │ -28#include │ │ │ │ │ -29 │ │ │ │ │ -30#include │ │ │ │ │ -31#include │ │ │ │ │ -32 │ │ │ │ │ -33 │ │ │ │ │ -34namespace Dune { │ │ │ │ │ -35 │ │ │ │ │ -36 class MPIPack { │ │ │ │ │ -37 std::vector _buffer; │ │ │ │ │ -38 int _position; │ │ │ │ │ -39 MPI_Comm _comm; │ │ │ │ │ -40 │ │ │ │ │ -41 friend struct MPIData; │ │ │ │ │ -42 friend struct MPIData; │ │ │ │ │ +5#ifndef DUNE_COMMON_PARAMETERIZEDOBJECT_HH │ │ │ │ │ +6#define DUNE_COMMON_PARAMETERIZEDOBJECT_HH │ │ │ │ │ +7 │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11 │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14 │ │ │ │ │ +15namespace Dune { │ │ │ │ │ +16 │ │ │ │ │ +34template │ │ │ │ │ +36class ParameterizedObjectFactory; │ │ │ │ │ +37 │ │ │ │ │ +38template │ │ │ │ │ +41class ParameterizedObjectFactory │ │ │ │ │ +42{ │ │ │ │ │ 43 public: │ │ │ │ │ -44 MPIPack(Communication comm, std::size_t size = 0) │ │ │ │ │ -45 : _buffer(size) │ │ │ │ │ -46 , _position(0) │ │ │ │ │ -47 , _comm(comm) │ │ │ │ │ -48 {} │ │ │ │ │ -49 │ │ │ │ │ -50 // Its not valid to copy a MPIPack but you can move it │ │ │ │ │ -51 MPIPack(const MPIPack&) = delete; │ │ │ │ │ -52 MPIPack& operator_=_(const MPIPack& other) = delete; │ │ │ │ │ -53 MPIPack(MPIPack&&) = default; │ │ │ │ │ -54 MPIPack& operator_=_(MPIPack&& other) = default; │ │ │ │ │ -55 │ │ │ │ │ -61 template │ │ │ │ │ -62 void pack(const T& data){ │ │ │ │ │ -63 auto mpidata = getMPIData(data); │ │ │ │ │ -64 int size = getPackSize(mpidata.size(), _comm, mpidata.type()); │ │ │ │ │ -65 constexpr bool has_static_size = decltype(getMPIData(std::declval())):: │ │ │ │ │ -static_size; │ │ │ │ │ -66 if(!has_static_size) │ │ │ │ │ -67 size += getPackSize(1, _comm, MPI_INT); │ │ │ │ │ -68 if (_position + size > 0 && size_t(_position + size) > _buffer.size()) / │ │ │ │ │ -/ resize buffer if necessary │ │ │ │ │ -69 _buffer.resize(_position + size); │ │ │ │ │ -70 if(!has_static_size){ │ │ │ │ │ -71 int size = mpidata.size(); │ │ │ │ │ -72 MPI_Pack(&size, 1, MPI_INT, _buffer.data(), _buffer.size(), │ │ │ │ │ -73 &_position, _comm); │ │ │ │ │ -74 } │ │ │ │ │ -75 MPI_Pack(mpidata.ptr(), mpidata.size(), │ │ │ │ │ -76 mpidata.type(), _buffer.data(), _buffer.size(), │ │ │ │ │ -77 &_position, _comm); │ │ │ │ │ -78 } │ │ │ │ │ -79 │ │ │ │ │ -84 template │ │ │ │ │ -85 auto /*void*/ unpack(T& data) │ │ │ │ │ -86 -> std::enable_if_t │ │ │ │ │ -87 { │ │ │ │ │ -88 auto mpidata = getMPIData(data); │ │ │ │ │ -89 MPI_Unpack(_buffer.data(), _buffer.size(), &_position, │ │ │ │ │ -90 mpidata.ptr(), mpidata.size(), │ │ │ │ │ -91 mpidata.type(), _comm); │ │ │ │ │ -92 } │ │ │ │ │ -93 │ │ │ │ │ -98 template │ │ │ │ │ -99 auto /*void*/ unpack(T& data) │ │ │ │ │ -100 -> std::enable_if_t │ │ │ │ │ -101 { │ │ │ │ │ -102 auto mpidata = getMPIData(data); │ │ │ │ │ -103 int size = 0; │ │ │ │ │ -104 MPI_Unpack(_buffer.data(), _buffer.size(), &_position, │ │ │ │ │ -105 &size, 1, │ │ │ │ │ -106 MPI_INT, _comm); │ │ │ │ │ -107 mpidata.resize(size); │ │ │ │ │ -108 MPI_Unpack(_buffer.data(), _buffer.size(), &_position, │ │ │ │ │ -109 mpidata.ptr(), mpidata.size(), │ │ │ │ │ -110 mpidata.type(), _comm); │ │ │ │ │ -111 } │ │ │ │ │ -112 │ │ │ │ │ -113 │ │ │ │ │ -115 template │ │ │ │ │ -116 friend MPIPack& operator_<<_(MPIPack& p, const T& t){ │ │ │ │ │ -117 p.pack(t); │ │ │ │ │ -118 return p; │ │ │ │ │ -119 } │ │ │ │ │ -120 │ │ │ │ │ -122 template │ │ │ │ │ -123 friend MPIPack& operator_>>_(MPIPack& p, T& t){ │ │ │ │ │ -124 p.unpack(t); │ │ │ │ │ -125 return p; │ │ │ │ │ -126 } │ │ │ │ │ -127 │ │ │ │ │ -129 template │ │ │ │ │ -130 MPIPack& read(T& t){ │ │ │ │ │ -131 unpack(t); │ │ │ │ │ -132 return *this; │ │ │ │ │ -133 } │ │ │ │ │ -134 │ │ │ │ │ -136 template │ │ │ │ │ -137 MPIPack& write(const T& t){ │ │ │ │ │ -138 pack(t); │ │ │ │ │ -139 return *this; │ │ │ │ │ -140 } │ │ │ │ │ -141 │ │ │ │ │ -145 void resize(size_t size){ │ │ │ │ │ -146 _buffer.resize(size); │ │ │ │ │ -147 } │ │ │ │ │ -148 │ │ │ │ │ -151 void enlarge(int s) { │ │ │ │ │ -152 _buffer.resize(_buffer.size() + s); │ │ │ │ │ +44 │ │ │ │ │ +46 typedef KeyT Key; │ │ │ │ │ +47 │ │ │ │ │ +49 using Type = TypeT; │ │ │ │ │ +50 │ │ │ │ │ +51 protected: │ │ │ │ │ +52 │ │ │ │ │ +53 using Creator = std::function; │ │ │ │ │ +54 │ │ │ │ │ +55 template │ │ │ │ │ +56 static constexpr auto has_proper_signature(Dune::PriorityTag<1>) │ │ │ │ │ +57 -> decltype( std::declval()(std::declval()...), std::true_type()) │ │ │ │ │ +58 { │ │ │ │ │ +59 return {}; │ │ │ │ │ +60 } │ │ │ │ │ +61 │ │ │ │ │ +62 template │ │ │ │ │ +63 static constexpr std::false_type has_proper_signature(Dune::PriorityTag<0>) │ │ │ │ │ +64 { │ │ │ │ │ +65 return {}; │ │ │ │ │ +66 } │ │ │ │ │ +67 │ │ │ │ │ +68 public: │ │ │ │ │ +69 │ │ │ │ │ +77 Type create(Key const& key, Args ... args) const { │ │ │ │ │ +78 typename Registry::const_iterator i = registry_.find(key); │ │ │ │ │ +79 if (i == registry_.end()) { │ │ │ │ │ +80 DUNE_THROW(Dune::InvalidStateException, │ │ │ │ │ +81 "ParametrizedObjectFactory: key ``" << │ │ │ │ │ +82 key << "'' not registered"); │ │ │ │ │ +83 } │ │ │ │ │ +84 else return i->second(args...); │ │ │ │ │ +85 } │ │ │ │ │ +86 │ │ │ │ │ +100 template │ │ │ │ │ +101 void define(Key const& key) │ │ │ │ │ +102 { │ │ │ │ │ +103 registry_[key] = DefaultCreator(); │ │ │ │ │ +104 } │ │ │ │ │ +105 │ │ │ │ │ +119 template(PriorityTag<42>()), int>:: │ │ │ │ │ +type = 0> │ │ │ │ │ +121 void define(Key const& key, F&& f) │ │ │ │ │ +122 { │ │ │ │ │ +123 registry_[key] = f; │ │ │ │ │ +124 } │ │ │ │ │ +125 │ │ │ │ │ +140 template::value │ │ │ │ │ +143 and not std::is_convertible::value, │ │ │ │ │ +144 int>::type = 0> │ │ │ │ │ +145 void define(Key const& key, Impl&& t) │ │ │ │ │ +146 { │ │ │ │ │ +147 registry_[key] = [=](Args...) { return t;}; │ │ │ │ │ +148 } │ │ │ │ │ +149 │ │ │ │ │ +150 bool contains(Key const& key) const │ │ │ │ │ +151 { │ │ │ │ │ +152 return registry_.count(key); │ │ │ │ │ 153 } │ │ │ │ │ 154 │ │ │ │ │ -157 size_t size() const { │ │ │ │ │ -158 return _buffer.size(); │ │ │ │ │ -159 } │ │ │ │ │ -160 │ │ │ │ │ -164 void seek(int p){ │ │ │ │ │ -165 _position = p; │ │ │ │ │ -166 } │ │ │ │ │ -167 │ │ │ │ │ -171 int tell() const{ │ │ │ │ │ -172 return _position; │ │ │ │ │ -173 } │ │ │ │ │ -174 │ │ │ │ │ -177 bool eof() const{ │ │ │ │ │ -178 return std::size_t(_position)==_buffer.size(); │ │ │ │ │ -179 } │ │ │ │ │ -180 │ │ │ │ │ -184 static int getPackSize(int len, const MPI_Comm& comm, const MPI_Datatype& │ │ │ │ │ -dt){ │ │ │ │ │ -185 int size; │ │ │ │ │ -186 MPI_Pack_size(len, dt, comm, &size); │ │ │ │ │ -187 return size; │ │ │ │ │ -188 } │ │ │ │ │ +155 private: │ │ │ │ │ +156 │ │ │ │ │ +157 template │ │ │ │ │ +158 struct Tag{}; │ │ │ │ │ +159 │ │ │ │ │ +160 template │ │ │ │ │ +161 struct DefaultCreator │ │ │ │ │ +162 { │ │ │ │ │ +163 template │ │ │ │ │ +164 Type operator()(T&&... args) const │ │ │ │ │ +165 { │ │ │ │ │ +166 return DefaultCreator::create(Tag(), PriorityTag<42>(), std:: │ │ │ │ │ +forward(args)...); │ │ │ │ │ +167 } │ │ │ │ │ +168 │ │ │ │ │ +169 template │ │ │ │ │ +170 static Type create(Tag, PriorityTag<1>, T&& ... args) { │ │ │ │ │ +171 return Impl(std::forward(args)...); │ │ │ │ │ +172 } │ │ │ │ │ +173 │ │ │ │ │ +174 template │ │ │ │ │ +175 static Type create(Tag>, PriorityTag<2>, T&& ... │ │ │ │ │ +args) { │ │ │ │ │ +176 return std::make_unique(std::forward(args)...); │ │ │ │ │ +177 } │ │ │ │ │ +178 │ │ │ │ │ +179 template │ │ │ │ │ +180 static Type create(Tag>, PriorityTag<3>, T&& ... │ │ │ │ │ +args) { │ │ │ │ │ +181 return std::make_shared(std::forward(args)...); │ │ │ │ │ +182 } │ │ │ │ │ +183 │ │ │ │ │ +184 }; │ │ │ │ │ +185 │ │ │ │ │ +186 typedef std::map Registry; │ │ │ │ │ +187 Registry registry_; │ │ │ │ │ +188}; │ │ │ │ │ 189 │ │ │ │ │ -190 friend bool operator==(const MPIPack& a, const MPIPack& b) { │ │ │ │ │ -191 return a._buffer == b._buffer && a._comm == b._comm; │ │ │ │ │ -192 } │ │ │ │ │ -193 friend bool operator!=(const MPIPack& a, const MPIPack& b) { │ │ │ │ │ -194 return !(a==b); │ │ │ │ │ -195 } │ │ │ │ │ -196 │ │ │ │ │ -197 }; │ │ │ │ │ -198 │ │ │ │ │ -199 template │ │ │ │ │ -200 struct MPIData, │ │ │ │ │ -MPIPack>::value>> { │ │ │ │ │ -201 protected: │ │ │ │ │ -202 friend auto getMPIData

(P& t); │ │ │ │ │ -203 MPIData(P& t) : │ │ │ │ │ -204 data_(t) │ │ │ │ │ -205 {} │ │ │ │ │ -206 public: │ │ │ │ │ -207 static constexpr bool static_size = std::is_const

::value; │ │ │ │ │ -208 │ │ │ │ │ -209 void* ptr() { │ │ │ │ │ -210 return (void*) data_._buffer.data(); │ │ │ │ │ -211 } │ │ │ │ │ -212 │ │ │ │ │ -213 int size() { │ │ │ │ │ -214 return data_.size(); │ │ │ │ │ -215 } │ │ │ │ │ -216 │ │ │ │ │ -217 MPI_Datatype type() const{ │ │ │ │ │ -218 return MPI_PACKED; │ │ │ │ │ -219 } │ │ │ │ │ -220 │ │ │ │ │ -221 void resize(int size){ │ │ │ │ │ -222 data_.resize(size); │ │ │ │ │ -223 } │ │ │ │ │ -224 protected: │ │ │ │ │ -225 P& data_; │ │ │ │ │ -226 }; │ │ │ │ │ -227 │ │ │ │ │ -228} // end namespace Dune │ │ │ │ │ -229 │ │ │ │ │ -230#endif // HAVE_MPI │ │ │ │ │ -231#endif // DUNE_COMMON_PARALLEL_MPIPACK_HH │ │ │ │ │ -mpidata.hh │ │ │ │ │ -Interface class to translate objects to a MPI_Datatype, void* and size used for │ │ │ │ │ -MPI calls. │ │ │ │ │ -mpicommunication.hh │ │ │ │ │ -Implements an utility class that provides MPI's collective communication │ │ │ │ │ -methods. │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ +190 │ │ │ │ │ +191 │ │ │ │ │ +192} // end namespace Dune │ │ │ │ │ +193 │ │ │ │ │ +194#endif // DUNE_COMMON_PARAMETERIZEDOBJECT_HH │ │ │ │ │ +exceptions.hh │ │ │ │ │ +A few common exception classes. │ │ │ │ │ +typeutilities.hh │ │ │ │ │ +Utilities for type computations, constraining overloads, ... │ │ │ │ │ +DUNE_THROW │ │ │ │ │ +#define DUNE_THROW(E, m) │ │ │ │ │ +Definition exceptions.hh:218 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::getMPIData │ │ │ │ │ -auto getMPIData(T &t) │ │ │ │ │ -Definition mpidata.hh:44 │ │ │ │ │ -Dune::Communication │ │ │ │ │ -Collective communication interface and sequential default implementation. │ │ │ │ │ -Definition communication.hh:100 │ │ │ │ │ -Dune::MPIData │ │ │ │ │ -Definition mpidata.hh:51 │ │ │ │ │ -Dune::MPIData::data_ │ │ │ │ │ -T & data_ │ │ │ │ │ -Definition mpidata.hh:54 │ │ │ │ │ -Dune::MPIData::size │ │ │ │ │ -int size() const │ │ │ │ │ -Definition mpidata.hh:68 │ │ │ │ │ -Dune::MPIData::static_size │ │ │ │ │ -static constexpr bool static_size │ │ │ │ │ -Definition mpidata.hh:66 │ │ │ │ │ -Dune::MPIPack │ │ │ │ │ -Definition mpipack.hh:36 │ │ │ │ │ -Dune::MPIPack::enlarge │ │ │ │ │ -void enlarge(int s) │ │ │ │ │ -Enlarges the internal buffer. │ │ │ │ │ -Definition mpipack.hh:151 │ │ │ │ │ -Dune::MPIPack::operator>> │ │ │ │ │ -friend MPIPack & operator>>(MPIPack &p, T &t) │ │ │ │ │ -Unpacks data from the object. │ │ │ │ │ -Definition mpipack.hh:123 │ │ │ │ │ -Dune::MPIPack::operator<< │ │ │ │ │ -friend MPIPack & operator<<(MPIPack &p, const T &t) │ │ │ │ │ -Packs the data into the object. Enlarges the internal buffer if necessary. │ │ │ │ │ -Definition mpipack.hh:116 │ │ │ │ │ -Dune::MPIPack::operator!= │ │ │ │ │ -friend bool operator!=(const MPIPack &a, const MPIPack &b) │ │ │ │ │ -Definition mpipack.hh:193 │ │ │ │ │ -Dune::MPIPack::size │ │ │ │ │ -size_t size() const │ │ │ │ │ -Returns the size of the internal buffer. │ │ │ │ │ -Definition mpipack.hh:157 │ │ │ │ │ -Dune::MPIPack::operator= │ │ │ │ │ -MPIPack & operator=(const MPIPack &other)=delete │ │ │ │ │ -Dune::MPIPack::MPIPack │ │ │ │ │ -MPIPack(Communication< MPI_Comm > comm, std::size_t size=0) │ │ │ │ │ -Definition mpipack.hh:44 │ │ │ │ │ -Dune::MPIPack::pack │ │ │ │ │ -void pack(const T &data) │ │ │ │ │ -Packs the data into the object. Enlarges the internal buffer if necessary. │ │ │ │ │ -Definition mpipack.hh:62 │ │ │ │ │ -Dune::MPIPack::unpack │ │ │ │ │ -auto unpack(T &data) -> std::enable_if_t │ │ │ │ │ -Unpacks data from the object. │ │ │ │ │ -Definition mpipack.hh:99 │ │ │ │ │ -Dune::MPIPack::unpack │ │ │ │ │ -auto unpack(T &data) -> std::enable_if_t< decltype(getMPIData(data))::static_ │ │ │ │ │ -size, void > │ │ │ │ │ -Unpacks data from the object. │ │ │ │ │ -Definition mpipack.hh:85 │ │ │ │ │ -Dune::MPIPack::operator== │ │ │ │ │ -friend bool operator==(const MPIPack &a, const MPIPack &b) │ │ │ │ │ -Definition mpipack.hh:190 │ │ │ │ │ -Dune::MPIPack::MPIPack │ │ │ │ │ -MPIPack(const MPIPack &)=delete │ │ │ │ │ -Dune::MPIPack::seek │ │ │ │ │ -void seek(int p) │ │ │ │ │ -Sets the position in the buffer where the next pack/unpack operation should │ │ │ │ │ -take place. │ │ │ │ │ -Definition mpipack.hh:164 │ │ │ │ │ -Dune::MPIPack::eof │ │ │ │ │ -bool eof() const │ │ │ │ │ -Checks whether the end of the buffer is reached. │ │ │ │ │ -Definition mpipack.hh:177 │ │ │ │ │ -Dune::MPIPack::resize │ │ │ │ │ -void resize(size_t size) │ │ │ │ │ -Resizes the internal buffer. │ │ │ │ │ -Definition mpipack.hh:145 │ │ │ │ │ -Dune::MPIPack::tell │ │ │ │ │ -int tell() const │ │ │ │ │ -Gets the position in the buffer where the next pack/unpack operation should │ │ │ │ │ -take place. │ │ │ │ │ -Definition mpipack.hh:171 │ │ │ │ │ -Dune::MPIPack::MPIPack │ │ │ │ │ -MPIPack(MPIPack &&)=default │ │ │ │ │ -Dune::MPIPack::read │ │ │ │ │ -MPIPack & read(T &t) │ │ │ │ │ -Unpacks data from the object. │ │ │ │ │ -Definition mpipack.hh:130 │ │ │ │ │ -Dune::MPIPack::getPackSize │ │ │ │ │ -static int getPackSize(int len, const MPI_Comm &comm, const MPI_Datatype &dt) │ │ │ │ │ -Returns the size of the data needed to store the data in an MPIPack. See MPI_ │ │ │ │ │ -Pack_size. │ │ │ │ │ -Definition mpipack.hh:184 │ │ │ │ │ -Dune::MPIPack::write │ │ │ │ │ -MPIPack & write(const T &t) │ │ │ │ │ -Packs the data into the object. Enlarges the internal buffer if necessary. │ │ │ │ │ -Definition mpipack.hh:137 │ │ │ │ │ -Dune::MPIData<_P,_std::enable_if_t<_std::is_same<_std::remove_const_t<_P_>, │ │ │ │ │ -MPIPack_>::value_>_>::type │ │ │ │ │ -MPI_Datatype type() const │ │ │ │ │ -Definition mpipack.hh:217 │ │ │ │ │ -Dune::MPIData<_P,_std::enable_if_t<_std::is_same<_std::remove_const_t<_P_>, │ │ │ │ │ -MPIPack_>::value_>_>::MPIData │ │ │ │ │ -MPIData(P &t) │ │ │ │ │ -Definition mpipack.hh:203 │ │ │ │ │ -Dune::MPIData<_P,_std::enable_if_t<_std::is_same<_std::remove_const_t<_P_>, │ │ │ │ │ -MPIPack_>::value_>_>::size │ │ │ │ │ -int size() │ │ │ │ │ -Definition mpipack.hh:213 │ │ │ │ │ -Dune::MPIData<_P,_std::enable_if_t<_std::is_same<_std::remove_const_t<_P_>, │ │ │ │ │ -MPIPack_>::value_>_>::ptr │ │ │ │ │ -void * ptr() │ │ │ │ │ -Definition mpipack.hh:209 │ │ │ │ │ -Dune::MPIData<_P,_std::enable_if_t<_std::is_same<_std::remove_const_t<_P_>, │ │ │ │ │ -MPIPack_>::value_>_>::data_ │ │ │ │ │ -P & data_ │ │ │ │ │ -Definition mpipack.hh:225 │ │ │ │ │ -Dune::MPIData<_P,_std::enable_if_t<_std::is_same<_std::remove_const_t<_P_>, │ │ │ │ │ -MPIPack_>::value_>_>::resize │ │ │ │ │ -void resize(int size) │ │ │ │ │ -Definition mpipack.hh:221 │ │ │ │ │ +Dune::InvalidStateException │ │ │ │ │ +Default exception if a function was called while the object is not in a valid │ │ │ │ │ +state for that function... │ │ │ │ │ +Definition exceptions.hh:281 │ │ │ │ │ +Dune::ParameterizedObjectFactory │ │ │ │ │ +A factory class for parameterized objects. │ │ │ │ │ +Definition parameterizedobject.hh:36 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::Creator │ │ │ │ │ +std::function< Type(Args...)> Creator │ │ │ │ │ +Definition parameterizedobject.hh:53 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::has_proper_signature │ │ │ │ │ +static constexpr auto has_proper_signature(Dune::PriorityTag< 1 >) -> decltype │ │ │ │ │ +(std::declval< F >()(std::declval< Args >()...), std::true_type()) │ │ │ │ │ +Definition parameterizedobject.hh:56 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::Type │ │ │ │ │ +TypeT Type │ │ │ │ │ +The type of objects created by the factory. │ │ │ │ │ +Definition parameterizedobject.hh:49 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::define │ │ │ │ │ +void define(Key const &key, Impl &&t) │ │ │ │ │ +Registers a new type with a key. │ │ │ │ │ +Definition parameterizedobject.hh:145 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::Key │ │ │ │ │ +KeyT Key │ │ │ │ │ +The typ of the keys. │ │ │ │ │ +Definition parameterizedobject.hh:46 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::create │ │ │ │ │ +Type create(Key const &key, Args ... args) const │ │ │ │ │ +Creates an object identified by a key from given parameters. │ │ │ │ │ +Definition parameterizedobject.hh:77 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::define │ │ │ │ │ +void define(Key const &key) │ │ │ │ │ +Registers a new type with a key. │ │ │ │ │ +Definition parameterizedobject.hh:101 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::define │ │ │ │ │ +void define(Key const &key, F &&f) │ │ │ │ │ +Registers a new creator with a key. │ │ │ │ │ +Definition parameterizedobject.hh:121 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::has_proper_signature │ │ │ │ │ +static constexpr std::false_type has_proper_signature(Dune::PriorityTag< 0 >) │ │ │ │ │ +Definition parameterizedobject.hh:63 │ │ │ │ │ +Dune::ParameterizedObjectFactory<_TypeT(Args...),_KeyT_>::contains │ │ │ │ │ +bool contains(Key const &key) const │ │ │ │ │ +Definition parameterizedobject.hh:150 │ │ │ │ │ +Dune::PriorityTag │ │ │ │ │ +Helper class for tagging priorities. │ │ │ │ │ +Definition typeutilities.hh:73 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00044.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpifuture.hh File Reference │ │ │ │ +dune-common: classname.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,57 +65,54 @@ │ │ │ │

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ -Namespaces
│ │ │ │ -
mpifuture.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
classname.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <functional>
│ │ │ │ + │ │ │ │ +

A free function to provide the demangled class name of a given object or type as a string. │ │ │ │ +More...

│ │ │ │ +
#include <cstdlib>
│ │ │ │ #include <memory>
│ │ │ │ -#include <optional>
│ │ │ │ +#include <string>
│ │ │ │ +#include <typeinfo>
│ │ │ │ #include <type_traits>
│ │ │ │ -#include <utility>
│ │ │ │ -#include <mpi.h>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/parallel/communication.hh>
│ │ │ │ -#include <dune/common/parallel/future.hh>
│ │ │ │ -#include <dune/common/parallel/mpidata.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

struct  Dune::impl::Buffer< T >
 
struct  Dune::impl::Buffer< T & >
 
struct  Dune::impl::Buffer< void >
 
class  Dune::MPIFuture< R, S >
 Provides a future-like object for MPI communication. It contains the object that will be received and might contain also a sending object, which must be hold (keep alive) until the communication has been completed. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::impl
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

template<class T >
std::string Dune::className ()
 Provide the demangled class name of a type T as a string.
 
template<class T >
std::string Dune::className (T &&v)
 Provide the demangled class name of a given object as a string.
 
│ │ │ │ -
│ │ │ │ +

Detailed Description

│ │ │ │ +

A free function to provide the demangled class name of a given object or type as a string.

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,41 +1,34 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -mpifuture.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +classname.hh File Reference │ │ │ │ │ +A free function to provide the demangled class name of a given object or type │ │ │ │ │ +as a string. More... │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ -Classes │ │ │ │ │ -struct   Dune::impl::Buffer<_T_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::impl::Buffer<_T_&_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::impl::Buffer<_void_> │ │ │ │ │ -  │ │ │ │ │ - class   Dune::MPIFuture<_R,_S_> │ │ │ │ │ - Provides a future-like object for MPI communication. It contains the │ │ │ │ │ -  object that will be received and might contain also a sending object, │ │ │ │ │ - which must be hold (keep alive) until the communication has been │ │ │ │ │ - completed. More... │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -namespace   Dune::impl │ │ │ │ │ -  │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ +std::string  Dune::className () │ │ │ │ │ +  Provide the demangled class name of a type T as a string. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +std::string  Dune::className (T &&v) │ │ │ │ │ +  Provide the demangled class name of a given object as a string. │ │ │ │ │ +  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +A free function to provide the demangled class name of a given object or type │ │ │ │ │ +as a string. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00044_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpifuture.hh Source File │ │ │ │ +dune-common: classname.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,299 +70,99 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
mpifuture.hh
│ │ │ │ +
classname.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PARALLEL_MPIFUTURE_HH
│ │ │ │ -
6#define DUNE_COMMON_PARALLEL_MPIFUTURE_HH
│ │ │ │ +
5#ifndef DUNE_CLASSNAME_HH
│ │ │ │ +
6#define DUNE_CLASSNAME_HH
│ │ │ │
7
│ │ │ │ -
8#if HAVE_MPI
│ │ │ │ -
9
│ │ │ │ -
10#include <functional>
│ │ │ │ -
11#include <memory>
│ │ │ │ -
12#include <optional>
│ │ │ │ -
13#include <type_traits>
│ │ │ │ -
14#include <utility>
│ │ │ │ -
15
│ │ │ │ -
16#include <mpi.h>
│ │ │ │ -
17
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
22
│ │ │ │ -
23namespace Dune{
│ │ │ │ -
24
│ │ │ │ -
│ │ │ │ -
25 namespace impl{
│ │ │ │ -
26 template<class T>
│ │ │ │ -
│ │ │ │ -
27 struct Buffer{
│ │ │ │ -
│ │ │ │ -
28 Buffer(bool valid){
│ │ │ │ -
29 if(valid)
│ │ │ │ -
30 value = std::make_unique<T>();
│ │ │ │ -
31 }
│ │ │ │ -
│ │ │ │ -
32 template<class V>
│ │ │ │ -
│ │ │ │ -
33 Buffer(V&& t)
│ │ │ │ -
34 : value(std::make_unique<T>(std::forward<V>(t)))
│ │ │ │ -
35 {}
│ │ │ │ -
│ │ │ │ -
36 std::unique_ptr<T> value;
│ │ │ │ -
│ │ │ │ -
37 T get(){
│ │ │ │ -
38 T tmp = std::move(*value);
│ │ │ │ -
39 value.reset();
│ │ │ │ -
40 return tmp;
│ │ │ │ -
41 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
42 operator bool () const {
│ │ │ │ -
43 return (bool)value;
│ │ │ │ -
44 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
45 T& operator *() const{
│ │ │ │ -
46 return *value;
│ │ │ │ -
47 }
│ │ │ │ -
│ │ │ │ -
48 };
│ │ │ │ -
│ │ │ │ -
49
│ │ │ │ -
50 template<class T>
│ │ │ │ -
│ │ │ │ -
51 struct Buffer<T&>{
│ │ │ │ -
│ │ │ │ -
52 Buffer(bool valid = false)
│ │ │ │ -
53 {
│ │ │ │ -
54 if(valid)
│ │ │ │ -
55 value = T();
│ │ │ │ -
56 }
│ │ │ │ -
│ │ │ │ -
57 template<class V>
│ │ │ │ -
│ │ │ │ -
58 Buffer(V&& t)
│ │ │ │ -
59 : value(std::forward<V>(t))
│ │ │ │ -
60 {}
│ │ │ │ -
│ │ │ │ -
61 std::optional<std::reference_wrapper<T>> value;
│ │ │ │ -
│ │ │ │ -
62 T& get(){
│ │ │ │ -
63 T& tmp = *value;
│ │ │ │ -
64 value.reset();
│ │ │ │ -
65 return tmp;
│ │ │ │ -
66 }
│ │ │ │ -
│ │ │ │ +
13#include <cstdlib>
│ │ │ │ +
14#include <memory>
│ │ │ │ +
15#include <string>
│ │ │ │ +
16#include <typeinfo>
│ │ │ │ +
17#include <type_traits>
│ │ │ │ +
18
│ │ │ │ +
19#if __has_include(<cxxabi.h>) && !DISABLE_CXA_DEMANGLE
│ │ │ │ +
20#define HAVE_CXA_DEMANGLE 1
│ │ │ │ +
21#include <cxxabi.h>
│ │ │ │ +
22#endif // #if HAVE_CXA_DEMANGLE
│ │ │ │ +
23
│ │ │ │ +
24namespace Dune {
│ │ │ │ +
25
│ │ │ │ +
26 namespace Impl {
│ │ │ │ +
27
│ │ │ │ +
28 inline std::string demangle(std::string name)
│ │ │ │ +
29 {
│ │ │ │ +
30#if HAVE_CXA_DEMANGLE
│ │ │ │ +
31 int status;
│ │ │ │ +
32 std::unique_ptr<char, void(*)(void*)>
│ │ │ │ +
33 demangled(abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status),
│ │ │ │ +
34 std::free);
│ │ │ │ +
35 if( demangled )
│ │ │ │ +
36 name = demangled.get();
│ │ │ │ +
37#endif // #if HAVE_CXA_DEMANGLE
│ │ │ │ +
38 return name;
│ │ │ │ +
39 }
│ │ │ │ +
40 }
│ │ │ │ +
41
│ │ │ │ +
43 /*
│ │ │ │ +
44 * \ingroup CxxUtilities
│ │ │ │ +
45 */
│ │ │ │ +
46 template <class T>
│ │ │ │ +
│ │ │ │ +
47 std::string className ()
│ │ │ │ +
48 {
│ │ │ │ +
49 typedef typename std::remove_reference<T>::type TR;
│ │ │ │ +
50 std::string className = Impl::demangle( typeid( TR ).name() );
│ │ │ │ +
51 if (std::is_const<TR>::value)
│ │ │ │ +
52 className += " const";
│ │ │ │ +
53 if (std::is_volatile<TR>::value)
│ │ │ │ +
54 className += " volatile";
│ │ │ │ +
55 if (std::is_lvalue_reference<T>::value)
│ │ │ │ +
56 className += "&";
│ │ │ │ +
57 else if (std::is_rvalue_reference<T>::value)
│ │ │ │ +
58 className += "&&";
│ │ │ │ +
59 return className;
│ │ │ │ +
60 }
│ │ │ │ +
│ │ │ │ +
61
│ │ │ │ +
63 /*
│ │ │ │ +
64 * \ingroup CxxUtilities
│ │ │ │ +
65 */
│ │ │ │ +
66 template <class T>
│ │ │ │
│ │ │ │ -
67 operator bool () const{
│ │ │ │ -
68 return (bool)value;
│ │ │ │ -
69 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
70 T& operator *() const{
│ │ │ │ -
71 return *value;
│ │ │ │ -
72 }
│ │ │ │ -
│ │ │ │ -
73 };
│ │ │ │ -
│ │ │ │ -
74
│ │ │ │ -
75 template<>
│ │ │ │ -
│ │ │ │ -
76 struct Buffer<void>{
│ │ │ │ -
77 bool valid_;
│ │ │ │ -
│ │ │ │ -
78 Buffer(bool valid = false)
│ │ │ │ -
79 : valid_(valid)
│ │ │ │ -
80 {}
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
81 operator bool () const{
│ │ │ │ -
82 return valid_;
│ │ │ │ -
83 }
│ │ │ │ -
│ │ │ │ -
84 void get(){}
│ │ │ │ -
85 };
│ │ │ │ -
│ │ │ │ -
86 }
│ │ │ │ -
│ │ │ │ -
87
│ │ │ │ -
92 template<class R, class S = void>
│ │ │ │ -
│ │ │ │ -
93 class MPIFuture{
│ │ │ │ -
94 mutable MPI_Request req_;
│ │ │ │ -
95 mutable MPI_Status status_;
│ │ │ │ -
96 impl::Buffer<R> data_;
│ │ │ │ -
97 impl::Buffer<S> send_data_;
│ │ │ │ -
98 friend class Communication<MPI_Comm>;
│ │ │ │ -
99 public:
│ │ │ │ -
│ │ │ │ -
100 MPIFuture(bool valid = false)
│ │ │ │ -
101 : req_(MPI_REQUEST_NULL)
│ │ │ │ -
102 , data_(valid)
│ │ │ │ -
103 {}
│ │ │ │ -
│ │ │ │ -
104
│ │ │ │ -
105 // Hide this constructor if R or S is void
│ │ │ │ -
106 template<class V = R, class U = S>
│ │ │ │ -
│ │ │ │ -
107 MPIFuture(V&& recv_data, U&& send_data, typename std::enable_if_t<!std::is_void<V>::value && !std::is_void<U>::value>* = 0) :
│ │ │ │ -
108 req_(MPI_REQUEST_NULL)
│ │ │ │ -
109 , data_(std::forward<R>(recv_data))
│ │ │ │ -
110 , send_data_(std::forward<S>(send_data))
│ │ │ │ -
111 {}
│ │ │ │ -
│ │ │ │ -
112
│ │ │ │ -
113 // hide this constructor if R is void
│ │ │ │ -
114 template<class V = R>
│ │ │ │ -
│ │ │ │ -
115 MPIFuture(V&& recv_data, typename std::enable_if_t<!std::is_void<V>::value>* = 0)
│ │ │ │ -
116 : req_(MPI_REQUEST_NULL)
│ │ │ │ -
117 , data_(std::forward<V>(recv_data))
│ │ │ │ -
118 {}
│ │ │ │ -
│ │ │ │ -
119
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
121 if(req_ != MPI_REQUEST_NULL){
│ │ │ │ -
122 try{ // might fail when it is a collective communication
│ │ │ │ -
123 MPI_Cancel(&req_);
│ │ │ │ -
124 MPI_Request_free(&req_);
│ │ │ │ -
125 }catch(...){
│ │ │ │ -
126 }
│ │ │ │ -
127 }
│ │ │ │ -
128 }
│ │ │ │ -
│ │ │ │ -
129
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
131 : req_(MPI_REQUEST_NULL)
│ │ │ │ -
132 , data_(std::move(f.data_))
│ │ │ │ -
133 , send_data_(std::move(f.send_data_))
│ │ │ │ -
134 {
│ │ │ │ -
135 std::swap(req_, f.req_);
│ │ │ │ -
136 std::swap(status_, f.status_);
│ │ │ │ -
137 }
│ │ │ │ -
│ │ │ │ -
138
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
140 std::swap(req_, f.req_);
│ │ │ │ -
141 std::swap(status_, f.status_);
│ │ │ │ -
142 std::swap(data_, f.data_);
│ │ │ │ -
143 std::swap(send_data_, f.send_data_);
│ │ │ │ -
144 return *this;
│ │ │ │ -
145 }
│ │ │ │ -
│ │ │ │ -
146
│ │ │ │ -
│ │ │ │ -
147 bool valid() const{
│ │ │ │ -
148 return (bool)data_;
│ │ │ │ -
149 }
│ │ │ │ -
│ │ │ │ -
150
│ │ │ │ -
│ │ │ │ -
151 void wait(){
│ │ │ │ -
152 if(!valid())
│ │ │ │ -
153 DUNE_THROW(InvalidFutureException, "The MPIFuture is not valid!");
│ │ │ │ -
154 MPI_Wait(&req_, &status_);
│ │ │ │ -
155 }
│ │ │ │ -
│ │ │ │ -
156
│ │ │ │ -
│ │ │ │ -
157 bool ready() const{
│ │ │ │ -
158 int flag = -1;
│ │ │ │ -
159 MPI_Test(&req_, &flag, &status_);
│ │ │ │ -
160 return flag;
│ │ │ │ -
161 }
│ │ │ │ -
│ │ │ │ -
162
│ │ │ │ -
│ │ │ │ -
163 R get() {
│ │ │ │ -
164 wait();
│ │ │ │ -
165 return data_.get();
│ │ │ │ -
166 }
│ │ │ │ -
│ │ │ │ -
167
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
169 wait();
│ │ │ │ -
170 return send_data_.get();
│ │ │ │ -
171 }
│ │ │ │ -
│ │ │ │ -
172
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
174 return getMPIData(*data_);
│ │ │ │ -
175 }
│ │ │ │ -
│ │ │ │ -
176
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
178 return getMPIData(*send_data_);
│ │ │ │ -
179 }
│ │ │ │ -
│ │ │ │ -
180 };
│ │ │ │ -
│ │ │ │ -
181
│ │ │ │ -
182}
│ │ │ │ -
183#endif // HAVE_MPI
│ │ │ │ -
184#endif // DUNE_COMMON_PARALLEL_MPIFUTURE_HH
│ │ │ │ -
Implements an utility class that provides collective communication methods for sequential programs.
│ │ │ │ -
Interface class to translate objects to a MPI_Datatype, void* and size used for MPI calls.
│ │ │ │ - │ │ │ │ -
A few common exception classes.
│ │ │ │ -
bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y)
Definition bigunsignedint.hh:549
│ │ │ │ -
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ -
STL namespace.
│ │ │ │ +
67 std::string className ( T&& v)
│ │ │ │ +
68 {
│ │ │ │ +
69 typedef typename std::remove_reference<T>::type TR;
│ │ │ │ +
70 std::string className = Impl::demangle( typeid(v).name() );
│ │ │ │ +
71 if (std::is_const<TR>::value)
│ │ │ │ +
72 className += " const";
│ │ │ │ +
73 if (std::is_volatile<TR>::value)
│ │ │ │ +
74 className += " volatile";
│ │ │ │ +
75 return className;
│ │ │ │ +
76 }
│ │ │ │ +
│ │ │ │ +
77} // namespace Dune
│ │ │ │ +
78
│ │ │ │ +
79#endif // DUNE_CLASSNAME_HH
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
auto getMPIData(T &t)
Definition mpidata.hh:44
│ │ │ │ -
Collective communication interface and sequential default implementation.
Definition communication.hh:100
│ │ │ │ -
This exception is thrown when ready(), wait() or get() is called on an invalid future....
Definition future.hh:20
│ │ │ │ -
Definition mpifuture.hh:27
│ │ │ │ -
std::unique_ptr< T > value
Definition mpifuture.hh:36
│ │ │ │ -
T & operator*() const
Definition mpifuture.hh:45
│ │ │ │ -
Buffer(V &&t)
Definition mpifuture.hh:33
│ │ │ │ -
T get()
Definition mpifuture.hh:37
│ │ │ │ -
Buffer(bool valid)
Definition mpifuture.hh:28
│ │ │ │ -
std::optional< std::reference_wrapper< T > > value
Definition mpifuture.hh:61
│ │ │ │ -
Buffer(bool valid=false)
Definition mpifuture.hh:52
│ │ │ │ -
T & get()
Definition mpifuture.hh:62
│ │ │ │ -
Buffer(V &&t)
Definition mpifuture.hh:58
│ │ │ │ -
bool valid_
Definition mpifuture.hh:77
│ │ │ │ -
void get()
Definition mpifuture.hh:84
│ │ │ │ -
Buffer(bool valid=false)
Definition mpifuture.hh:78
│ │ │ │ -
Provides a future-like object for MPI communication. It contains the object that will be received and...
Definition mpifuture.hh:93
│ │ │ │ -
MPIFuture(V &&recv_data, typename std::enable_if_t<!std::is_void< V >::value > *=0)
Definition mpifuture.hh:115
│ │ │ │ -
bool ready() const
Definition mpifuture.hh:157
│ │ │ │ -
bool valid() const
Definition mpifuture.hh:147
│ │ │ │ -
~MPIFuture()
Definition mpifuture.hh:120
│ │ │ │ -
MPIFuture(bool valid=false)
Definition mpifuture.hh:100
│ │ │ │ -
MPIFuture & operator=(MPIFuture &&f)
Definition mpifuture.hh:139
│ │ │ │ -
auto get_send_mpidata()
Definition mpifuture.hh:177
│ │ │ │ -
void wait()
Definition mpifuture.hh:151
│ │ │ │ -
auto get_mpidata()
Definition mpifuture.hh:173
│ │ │ │ -
R get()
Definition mpifuture.hh:163
│ │ │ │ -
MPIFuture(V &&recv_data, U &&send_data, typename std::enable_if_t<!std::is_void< V >::value &&!std::is_void< U >::value > *=0)
Definition mpifuture.hh:107
│ │ │ │ -
S get_send_data()
Definition mpifuture.hh:168
│ │ │ │ -
MPIFuture(MPIFuture &&f)
Definition mpifuture.hh:130
│ │ │ │ +
std::string className()
Provide the demangled class name of a type T as a string.
Definition classname.hh:47
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,307 +1,90 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -mpifuture.hh │ │ │ │ │ +classname.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PARALLEL_MPIFUTURE_HH │ │ │ │ │ -6#define DUNE_COMMON_PARALLEL_MPIFUTURE_HH │ │ │ │ │ +5#ifndef DUNE_CLASSNAME_HH │ │ │ │ │ +6#define DUNE_CLASSNAME_HH │ │ │ │ │ 7 │ │ │ │ │ -8#if HAVE_MPI │ │ │ │ │ -9 │ │ │ │ │ -10#include │ │ │ │ │ -11#include │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15 │ │ │ │ │ -16#include │ │ │ │ │ -17 │ │ │ │ │ -18#include │ │ │ │ │ -19#include │ │ │ │ │ -20#include │ │ │ │ │ -21#include │ │ │ │ │ -22 │ │ │ │ │ -23namespace Dune{ │ │ │ │ │ -24 │ │ │ │ │ -25 namespace impl{ │ │ │ │ │ -26 template │ │ │ │ │ -27 struct Buffer{ │ │ │ │ │ -28 Buffer(bool valid){ │ │ │ │ │ -29 if(valid) │ │ │ │ │ -30 value = std::make_unique(); │ │ │ │ │ -31 } │ │ │ │ │ -32 template │ │ │ │ │ -33 Buffer(V&& t) │ │ │ │ │ -34 : value(std::make_unique(std::forward(t))) │ │ │ │ │ -35 {} │ │ │ │ │ -36 std::unique_ptr value; │ │ │ │ │ -37 T get(){ │ │ │ │ │ -38 T tmp = std::move(*value); │ │ │ │ │ -39 value.reset(); │ │ │ │ │ -40 return tmp; │ │ │ │ │ -41 } │ │ │ │ │ -42 operator bool () const { │ │ │ │ │ -43 return (bool)value; │ │ │ │ │ -44 } │ │ │ │ │ -45 T& operator_*() const{ │ │ │ │ │ -46 return *value; │ │ │ │ │ -47 } │ │ │ │ │ -48 }; │ │ │ │ │ -49 │ │ │ │ │ -50 template │ │ │ │ │ -51 struct Buffer{ │ │ │ │ │ -52 Buffer(bool valid = false) │ │ │ │ │ -53 { │ │ │ │ │ -54 if(valid) │ │ │ │ │ -55 value = T(); │ │ │ │ │ -56 } │ │ │ │ │ -57 template │ │ │ │ │ -58 Buffer(V&& t) │ │ │ │ │ -59 : value(std::forward(t)) │ │ │ │ │ -60 {} │ │ │ │ │ -61 std::optional> value; │ │ │ │ │ -62 T& get(){ │ │ │ │ │ -63 T& tmp = *value; │ │ │ │ │ -64 value.reset(); │ │ │ │ │ -65 return tmp; │ │ │ │ │ -66 } │ │ │ │ │ -67 operator bool () const{ │ │ │ │ │ -68 return (bool)value; │ │ │ │ │ -69 } │ │ │ │ │ -70 T& operator_*() const{ │ │ │ │ │ -71 return *value; │ │ │ │ │ -72 } │ │ │ │ │ -73 }; │ │ │ │ │ -74 │ │ │ │ │ -75 template<> │ │ │ │ │ -76 struct Buffer{ │ │ │ │ │ -77 bool valid_; │ │ │ │ │ -78 Buffer(bool valid = false) │ │ │ │ │ -79 : valid_(valid) │ │ │ │ │ -80 {} │ │ │ │ │ -81 operator bool () const{ │ │ │ │ │ -82 return valid_; │ │ │ │ │ -83 } │ │ │ │ │ -84 void get(){} │ │ │ │ │ -85 }; │ │ │ │ │ -86 } │ │ │ │ │ -87 │ │ │ │ │ -92 template │ │ │ │ │ -93 class MPIFuture{ │ │ │ │ │ -94 mutable MPI_Request req_; │ │ │ │ │ -95 mutable MPI_Status status_; │ │ │ │ │ -96 impl::Buffer data_; │ │ │ │ │ -97 impl::Buffer send_data_; │ │ │ │ │ -98 friend class Communication; │ │ │ │ │ -99 public: │ │ │ │ │ -100 MPIFuture(bool valid = false) │ │ │ │ │ -101 : req_(MPI_REQUEST_NULL) │ │ │ │ │ -102 , data_(valid) │ │ │ │ │ -103 {} │ │ │ │ │ -104 │ │ │ │ │ -105 // Hide this constructor if R or S is void │ │ │ │ │ -106 template │ │ │ │ │ -107 MPIFuture(V&& recv_data, U&& send_data, typename std::enable_if_t::value && !std::is_void::value>* = 0) : │ │ │ │ │ -108 req_(MPI_REQUEST_NULL) │ │ │ │ │ -109 , data_(std::forward(recv_data)) │ │ │ │ │ -110 , send_data_(std::forward(send_data)) │ │ │ │ │ -111 {} │ │ │ │ │ -112 │ │ │ │ │ -113 // hide this constructor if R is void │ │ │ │ │ -114 template │ │ │ │ │ -115 MPIFuture(V&& recv_data, typename std::enable_if_t:: │ │ │ │ │ -value>* = 0) │ │ │ │ │ -116 : req_(MPI_REQUEST_NULL) │ │ │ │ │ -117 , data_(std::forward(recv_data)) │ │ │ │ │ -118 {} │ │ │ │ │ -119 │ │ │ │ │ -120 ~MPIFuture() { │ │ │ │ │ -121 if(req_ != MPI_REQUEST_NULL){ │ │ │ │ │ -122 try{ // might fail when it is a collective communication │ │ │ │ │ -123 MPI_Cancel(&req_); │ │ │ │ │ -124 MPI_Request_free(&req_); │ │ │ │ │ -125 }catch(...){ │ │ │ │ │ -126 } │ │ │ │ │ -127 } │ │ │ │ │ -128 } │ │ │ │ │ -129 │ │ │ │ │ -130 MPIFuture(MPIFuture&& f) │ │ │ │ │ -131 : req_(MPI_REQUEST_NULL) │ │ │ │ │ -132 , data_(std::move(f.data_)) │ │ │ │ │ -133 , send_data_(std::move(f.send_data_)) │ │ │ │ │ -134 { │ │ │ │ │ -135 std::swap(req_, f.req_); │ │ │ │ │ -136 std::swap(status_, f.status_); │ │ │ │ │ -137 } │ │ │ │ │ -138 │ │ │ │ │ -139 MPIFuture& operator=(MPIFuture&& f){ │ │ │ │ │ -140 std::swap(req_, f.req_); │ │ │ │ │ -141 std::swap(status_, f.status_); │ │ │ │ │ -142 std::swap(data_, f.data_); │ │ │ │ │ -143 std::swap(send_data_, f.send_data_); │ │ │ │ │ -144 return *this; │ │ │ │ │ -145 } │ │ │ │ │ -146 │ │ │ │ │ -147 bool valid() const{ │ │ │ │ │ -148 return (bool)data_; │ │ │ │ │ -149 } │ │ │ │ │ -150 │ │ │ │ │ -151 void wait(){ │ │ │ │ │ -152 if(!valid()) │ │ │ │ │ -153 DUNE_THROW(InvalidFutureException, "The MPIFuture is not valid!"); │ │ │ │ │ -154 MPI_Wait(&req_, &status_); │ │ │ │ │ -155 } │ │ │ │ │ -156 │ │ │ │ │ -157 bool ready() const{ │ │ │ │ │ -158 int flag = -1; │ │ │ │ │ -159 MPI_Test(&req_, &flag, &status_); │ │ │ │ │ -160 return flag; │ │ │ │ │ -161 } │ │ │ │ │ -162 │ │ │ │ │ -163 R get() { │ │ │ │ │ -164 wait(); │ │ │ │ │ -165 return data_.get(); │ │ │ │ │ -166 } │ │ │ │ │ -167 │ │ │ │ │ -168 S get_send_data(){ │ │ │ │ │ -169 wait(); │ │ │ │ │ -170 return send_data_.get(); │ │ │ │ │ -171 } │ │ │ │ │ -172 │ │ │ │ │ -173 auto get_mpidata(){ │ │ │ │ │ -174 return getMPIData(*data_); │ │ │ │ │ -175 } │ │ │ │ │ -176 │ │ │ │ │ -177 auto get_send_mpidata(){ │ │ │ │ │ -178 return getMPIData(*send_data_); │ │ │ │ │ -179 } │ │ │ │ │ -180 }; │ │ │ │ │ -181 │ │ │ │ │ -182} │ │ │ │ │ -183#endif // HAVE_MPI │ │ │ │ │ -184#endif // DUNE_COMMON_PARALLEL_MPIFUTURE_HH │ │ │ │ │ -communication.hh │ │ │ │ │ -Implements an utility class that provides collective communication methods for │ │ │ │ │ -sequential programs. │ │ │ │ │ -mpidata.hh │ │ │ │ │ -Interface class to translate objects to a MPI_Datatype, void* and size used for │ │ │ │ │ -MPI calls. │ │ │ │ │ -future.hh │ │ │ │ │ -exceptions.hh │ │ │ │ │ -A few common exception classes. │ │ │ │ │ -Dune::operator* │ │ │ │ │ -bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ -Definition bigunsignedint.hh:549 │ │ │ │ │ -DUNE_THROW │ │ │ │ │ -#define DUNE_THROW(E, m) │ │ │ │ │ -Definition exceptions.hh:218 │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ +13#include │ │ │ │ │ +14#include │ │ │ │ │ +15#include │ │ │ │ │ +16#include │ │ │ │ │ +17#include │ │ │ │ │ +18 │ │ │ │ │ +19#if __has_include() && !DISABLE_CXA_DEMANGLE │ │ │ │ │ +20#define HAVE_CXA_DEMANGLE 1 │ │ │ │ │ +21#include │ │ │ │ │ +22#endif // #if HAVE_CXA_DEMANGLE │ │ │ │ │ +23 │ │ │ │ │ +24namespace Dune { │ │ │ │ │ +25 │ │ │ │ │ +26 namespace Impl { │ │ │ │ │ +27 │ │ │ │ │ +28 inline std::string demangle(std::string name) │ │ │ │ │ +29 { │ │ │ │ │ +30#if HAVE_CXA_DEMANGLE │ │ │ │ │ +31 int status; │ │ │ │ │ +32 std::unique_ptr │ │ │ │ │ +33 demangled(abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status), │ │ │ │ │ +34 std::free); │ │ │ │ │ +35 if( demangled ) │ │ │ │ │ +36 name = demangled.get(); │ │ │ │ │ +37#endif // #if HAVE_CXA_DEMANGLE │ │ │ │ │ +38 return name; │ │ │ │ │ +39 } │ │ │ │ │ +40 } │ │ │ │ │ +41 │ │ │ │ │ +43 /* │ │ │ │ │ +44 * \ingroup CxxUtilities │ │ │ │ │ +45 */ │ │ │ │ │ +46 template │ │ │ │ │ +47 std::string className () │ │ │ │ │ +48 { │ │ │ │ │ +49 typedef typename std::remove_reference::type TR; │ │ │ │ │ +50 std::string className = Impl::demangle( typeid( TR ).name() ); │ │ │ │ │ +51 if (std::is_const::value) │ │ │ │ │ +52 className += " const"; │ │ │ │ │ +53 if (std::is_volatile::value) │ │ │ │ │ +54 className += " volatile"; │ │ │ │ │ +55 if (std::is_lvalue_reference::value) │ │ │ │ │ +56 className += "&"; │ │ │ │ │ +57 else if (std::is_rvalue_reference::value) │ │ │ │ │ +58 className += "&&"; │ │ │ │ │ +59 return className; │ │ │ │ │ +60 } │ │ │ │ │ +61 │ │ │ │ │ +63 /* │ │ │ │ │ +64 * \ingroup CxxUtilities │ │ │ │ │ +65 */ │ │ │ │ │ +66 template │ │ │ │ │ +67 std::string className ( T&& v) │ │ │ │ │ +68 { │ │ │ │ │ +69 typedef typename std::remove_reference::type TR; │ │ │ │ │ +70 std::string className = Impl::demangle( typeid(v).name() ); │ │ │ │ │ +71 if (std::is_const::value) │ │ │ │ │ +72 className += " const"; │ │ │ │ │ +73 if (std::is_volatile::value) │ │ │ │ │ +74 className += " volatile"; │ │ │ │ │ +75 return className; │ │ │ │ │ +76 } │ │ │ │ │ +77} // namespace Dune │ │ │ │ │ +78 │ │ │ │ │ +79#endif // DUNE_CLASSNAME_HH │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::getMPIData │ │ │ │ │ -auto getMPIData(T &t) │ │ │ │ │ -Definition mpidata.hh:44 │ │ │ │ │ -Dune::Communication │ │ │ │ │ -Collective communication interface and sequential default implementation. │ │ │ │ │ -Definition communication.hh:100 │ │ │ │ │ -Dune::InvalidFutureException │ │ │ │ │ -This exception is thrown when ready(), wait() or get() is called on an invalid │ │ │ │ │ -future.... │ │ │ │ │ -Definition future.hh:20 │ │ │ │ │ -Dune::impl::Buffer │ │ │ │ │ -Definition mpifuture.hh:27 │ │ │ │ │ -Dune::impl::Buffer::value │ │ │ │ │ -std::unique_ptr< T > value │ │ │ │ │ -Definition mpifuture.hh:36 │ │ │ │ │ -Dune::impl::Buffer::operator* │ │ │ │ │ -T & operator*() const │ │ │ │ │ -Definition mpifuture.hh:45 │ │ │ │ │ -Dune::impl::Buffer::Buffer │ │ │ │ │ -Buffer(V &&t) │ │ │ │ │ -Definition mpifuture.hh:33 │ │ │ │ │ -Dune::impl::Buffer::get │ │ │ │ │ -T get() │ │ │ │ │ -Definition mpifuture.hh:37 │ │ │ │ │ -Dune::impl::Buffer::Buffer │ │ │ │ │ -Buffer(bool valid) │ │ │ │ │ -Definition mpifuture.hh:28 │ │ │ │ │ -Dune::impl::Buffer<_T_&_>::value │ │ │ │ │ -std::optional< std::reference_wrapper< T > > value │ │ │ │ │ -Definition mpifuture.hh:61 │ │ │ │ │ -Dune::impl::Buffer<_T_&_>::Buffer │ │ │ │ │ -Buffer(bool valid=false) │ │ │ │ │ -Definition mpifuture.hh:52 │ │ │ │ │ -Dune::impl::Buffer<_T_&_>::get │ │ │ │ │ -T & get() │ │ │ │ │ -Definition mpifuture.hh:62 │ │ │ │ │ -Dune::impl::Buffer<_T_&_>::Buffer │ │ │ │ │ -Buffer(V &&t) │ │ │ │ │ -Definition mpifuture.hh:58 │ │ │ │ │ -Dune::impl::Buffer<_void_>::valid_ │ │ │ │ │ -bool valid_ │ │ │ │ │ -Definition mpifuture.hh:77 │ │ │ │ │ -Dune::impl::Buffer<_void_>::get │ │ │ │ │ -void get() │ │ │ │ │ -Definition mpifuture.hh:84 │ │ │ │ │ -Dune::impl::Buffer<_void_>::Buffer │ │ │ │ │ -Buffer(bool valid=false) │ │ │ │ │ -Definition mpifuture.hh:78 │ │ │ │ │ -Dune::MPIFuture │ │ │ │ │ -Provides a future-like object for MPI communication. It contains the object │ │ │ │ │ -that will be received and... │ │ │ │ │ -Definition mpifuture.hh:93 │ │ │ │ │ -Dune::MPIFuture::MPIFuture │ │ │ │ │ -MPIFuture(V &&recv_data, typename std::enable_if_t::value > │ │ │ │ │ -*=0) │ │ │ │ │ -Definition mpifuture.hh:115 │ │ │ │ │ -Dune::MPIFuture::ready │ │ │ │ │ -bool ready() const │ │ │ │ │ -Definition mpifuture.hh:157 │ │ │ │ │ -Dune::MPIFuture::valid │ │ │ │ │ -bool valid() const │ │ │ │ │ -Definition mpifuture.hh:147 │ │ │ │ │ -Dune::MPIFuture::~MPIFuture │ │ │ │ │ -~MPIFuture() │ │ │ │ │ -Definition mpifuture.hh:120 │ │ │ │ │ -Dune::MPIFuture::MPIFuture │ │ │ │ │ -MPIFuture(bool valid=false) │ │ │ │ │ -Definition mpifuture.hh:100 │ │ │ │ │ -Dune::MPIFuture::operator= │ │ │ │ │ -MPIFuture & operator=(MPIFuture &&f) │ │ │ │ │ -Definition mpifuture.hh:139 │ │ │ │ │ -Dune::MPIFuture::get_send_mpidata │ │ │ │ │ -auto get_send_mpidata() │ │ │ │ │ -Definition mpifuture.hh:177 │ │ │ │ │ -Dune::MPIFuture::wait │ │ │ │ │ -void wait() │ │ │ │ │ -Definition mpifuture.hh:151 │ │ │ │ │ -Dune::MPIFuture::get_mpidata │ │ │ │ │ -auto get_mpidata() │ │ │ │ │ -Definition mpifuture.hh:173 │ │ │ │ │ -Dune::MPIFuture::get │ │ │ │ │ -R get() │ │ │ │ │ -Definition mpifuture.hh:163 │ │ │ │ │ -Dune::MPIFuture::MPIFuture │ │ │ │ │ -MPIFuture(V &&recv_data, U &&send_data, typename std::enable_if_t::value &&!std::is_void< U >::value > *=0) │ │ │ │ │ -Definition mpifuture.hh:107 │ │ │ │ │ -Dune::MPIFuture::get_send_data │ │ │ │ │ -S get_send_data() │ │ │ │ │ -Definition mpifuture.hh:168 │ │ │ │ │ -Dune::MPIFuture::MPIFuture │ │ │ │ │ -MPIFuture(MPIFuture &&f) │ │ │ │ │ -Definition mpifuture.hh:130 │ │ │ │ │ +Dune::className │ │ │ │ │ +std::string className() │ │ │ │ │ +Provide the demangled class name of a type T as a string. │ │ │ │ │ +Definition classname.hh:47 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00047.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpihelper.hh File Reference │ │ │ │ +dune-common: parametertreeparser.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,73 +65,55 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces
│ │ │ │ -
mpihelper.hh File Reference
│ │ │ │ +
parametertreeparser.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

Helpers for dealing with MPI. │ │ │ │ +

Various parser methods to get data into a ParameterTree object. │ │ │ │ More...

│ │ │ │ -
#include <cassert>
│ │ │ │ -#include <mutex>
│ │ │ │ -#include <mpi.h>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/visibility.hh>
│ │ │ │ -#include <dune/common/parallel/communication.hh>
│ │ │ │ -#include <dune/common/parallel/mpicommunication.hh>
│ │ │ │ -#include <dune/common/stdstreams.hh>
│ │ │ │ +
#include <istream>
│ │ │ │ +#include <string>
│ │ │ │ +#include <vector>
│ │ │ │ +#include <dune/common/parametertree.hh>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::FakeMPIHelper
 A fake mpi helper. More...
class  Dune::ParameterTreeParserError
 report parser error while reading ParameterTree More...
 
class  Dune::MPIHelper
 A real mpi helper. More...
class  Dune::HelpRequest
 exception thrown if the user wants to see help string More...
 
class  Dune::ParameterTreeParser
 Parsers to set up a ParameterTree from various input sources. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │

Detailed Description

│ │ │ │ -

Helpers for dealing with MPI.

│ │ │ │ -

Basically there are two helpers available:

│ │ │ │ -
FakeMPIHelper
│ │ │ │ -
A class adhering to the interface of MPIHelper that does not need MPI at all. This can be used to create a sequential program even if MPI is used to compile it.
│ │ │ │ -
MPIHelper
│ │ │ │ -
A real MPI helper. When the singleton gets instantiated MPI_Init will be called and before the program exits MPI_Finalize will be called.
│ │ │ │ -
│ │ │ │ -

Example of who to use these classes:

│ │ │ │ -

A program that is parallel if compiled with MPI and sequential otherwise:

int main(int argc, char** argv){
│ │ │ │ -
typedef Dune::MPIHelper MPIHelper;
│ │ │ │ -
MPIHelper::instance(argc, argv);
│ │ │ │ -
typename MPIHelper::MPICommunicator world =
│ │ │ │ -
MPIHelper::getCommunicator();
│ │ │ │ -
...
│ │ │ │ -
int main(int argc, char **argv)
Definition mpi_collective_benchmark.cc:297
│ │ │ │ -
A real mpi helper.
Definition mpihelper.hh:181
│ │ │ │ -

If one wants to have sequential program even if the code is compiled with mpi then one simply has to exchange the typedef with

typedef Dune::MPIHelper FakeMPIHelper;
│ │ │ │ -

.

│ │ │ │ -

For checking whether we really use MPI or just fake please use MPIHelper::isFake (this is also possible at compile time!)

│ │ │ │ +

Various parser methods to get data into a ParameterTree object.

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,63 +1,33 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ Classes | Namespaces │ │ │ │ │ -mpihelper.hh File Reference │ │ │ │ │ -Common » Parallel_Communication │ │ │ │ │ -Helpers for dealing with MPI. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +parametertreeparser.hh File Reference │ │ │ │ │ +Various parser methods to get data into a ParameterTree object. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::FakeMPIHelper │ │ │ │ │ -  A fake mpi helper. More... │ │ │ │ │ +class   Dune::ParameterTreeParserError │ │ │ │ │ +  report parser error while reading ParameterTree More... │ │ │ │ │   │ │ │ │ │ -class   Dune::MPIHelper │ │ │ │ │ -  A real mpi helper. More... │ │ │ │ │ +class   Dune::HelpRequest │ │ │ │ │ +  exception thrown if the user wants to see help string More... │ │ │ │ │ +  │ │ │ │ │ +class   Dune::ParameterTreeParser │ │ │ │ │ +  Parsers to set up a ParameterTree from various input sources. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Helpers for dealing with MPI. │ │ │ │ │ -Basically there are two helpers available: │ │ │ │ │ - FakeMPIHelper │ │ │ │ │ - A class adhering to the interface of MPIHelper that does not need MPI at │ │ │ │ │ - all. This can be used to create a sequential program even if MPI is used │ │ │ │ │ - to compile it. │ │ │ │ │ - MPIHelper │ │ │ │ │ - A real MPI helper. When the singleton gets instantiated MPI_Init will be │ │ │ │ │ - called and before the program exits MPI_Finalize will be called. │ │ │ │ │ -Example of who to use these classes: │ │ │ │ │ -A program that is parallel if compiled with MPI and sequential otherwise: │ │ │ │ │ -int main(int argc, char** argv){ │ │ │ │ │ -typedef Dune::MPIHelper MPIHelper; │ │ │ │ │ -MPIHelper::instance(argc, argv); │ │ │ │ │ -typename MPIHelper::MPICommunicator world = │ │ │ │ │ -MPIHelper::getCommunicator(); │ │ │ │ │ -... │ │ │ │ │ -main │ │ │ │ │ -int main(int argc, char **argv) │ │ │ │ │ -Definition mpi_collective_benchmark.cc:297 │ │ │ │ │ -Dune::MPIHelper │ │ │ │ │ -A real mpi helper. │ │ │ │ │ -Definition mpihelper.hh:181 │ │ │ │ │ -If one wants to have sequential program even if the code is compiled with mpi │ │ │ │ │ -then one simply has to exchange the typedef with │ │ │ │ │ -typedef Dune::MPIHelper FakeMPIHelper; │ │ │ │ │ -. │ │ │ │ │ -For checking whether we really use MPI or just fake please use MPIHelper:: │ │ │ │ │ -isFake (this is also possible at compile time!) │ │ │ │ │ +Various parser methods to get data into a ParameterTree object. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00047_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpihelper.hh Source File │ │ │ │ +dune-common: parametertreeparser.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,261 +70,96 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
mpihelper.hh
│ │ │ │ +
parametertreeparser.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PARALLEL_MPIHELPER_HH
│ │ │ │ -
6#define DUNE_COMMON_PARALLEL_MPIHELPER_HH
│ │ │ │ +
5#ifndef DUNE_PARAMETER_PARSER_HH
│ │ │ │ +
6#define DUNE_PARAMETER_PARSER_HH
│ │ │ │
7
│ │ │ │ -
8#include <cassert>
│ │ │ │ -
9#include <mutex>
│ │ │ │ -
10
│ │ │ │ -
11#if HAVE_MPI
│ │ │ │ -
12#include <mpi.h>
│ │ │ │ -
13#endif
│ │ │ │ -
14
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
19
│ │ │ │ -
20#if HAVE_MPI
│ │ │ │ - │ │ │ │ -
22#endif
│ │ │ │ -
23
│ │ │ │ -
24namespace Dune
│ │ │ │ -
25{
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
76 {
│ │ │ │ -
77 public:
│ │ │ │ -
82 constexpr static bool isFake = true;
│ │ │ │ -
83
│ │ │ │ - │ │ │ │ -
88
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
96 {
│ │ │ │ -
97 static MPICommunicator comm;
│ │ │ │ -
98 return comm;
│ │ │ │ -
99 }
│ │ │ │ -
│ │ │ │ -
100
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
108 {
│ │ │ │ -
109 return getCommunicator();
│ │ │ │ -
110 }
│ │ │ │ -
│ │ │ │ -
111
│ │ │ │ -
112
│ │ │ │ -
113
│ │ │ │ -
119 [[deprecated("getCollectionCommunication is deprecated. Use getCommunication instead.")]]
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
121 {
│ │ │ │ - │ │ │ │ -
123 }
│ │ │ │ -
│ │ │ │ +
12#include <istream>
│ │ │ │ +
13#include <string>
│ │ │ │ +
14#include <vector>
│ │ │ │ +
15
│ │ │ │ + │ │ │ │ + │ │ │ │ +
18
│ │ │ │ +
19namespace Dune {
│ │ │ │ +
20
│ │ │ │ + │ │ │ │ +
28 class HelpRequest : public Exception {};
│ │ │ │ +
29
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
35 {
│ │ │ │ +
36
│ │ │ │ +
37 static std::string ltrim(const std::string& s);
│ │ │ │ +
38 static std::string rtrim(const std::string& s);
│ │ │ │ +
39
│ │ │ │ +
40 public:
│ │ │ │ +
41
│ │ │ │ +
85
│ │ │ │ +
96 static void readINITree(std::istream& in, ParameterTree& pt,
│ │ │ │ +
97 bool overwrite);
│ │ │ │ +
98
│ │ │ │ +
105 static Dune::ParameterTree readINITree(std::istream& in);
│ │ │ │ +
106
│ │ │ │ +
107
│ │ │ │ +
120 static void readINITree(std::istream& in, ParameterTree& pt,
│ │ │ │ +
121 const std::string srcname = "stream",
│ │ │ │ +
122 bool overwrite = true);
│ │ │ │ +
123
│ │ │ │
124
│ │ │ │ - │ │ │ │ -
│ │ │ │ - │ │ │ │ -
127 {
│ │ │ │ - │ │ │ │ -
129 }
│ │ │ │ -
│ │ │ │ -
130
│ │ │ │ -
│ │ │ │ -
146 DUNE_EXPORT static FakeMPIHelper& instance([[maybe_unused]] int argc,
│ │ │ │ -
147 [[maybe_unused]] char** argv)
│ │ │ │ -
148 {
│ │ │ │ -
149 return instance();
│ │ │ │ -
150 }
│ │ │ │ +
135 static void readINITree(std::string file, ParameterTree& pt, bool overwrite = true);
│ │ │ │ +
136
│ │ │ │ +
143 static Dune::ParameterTree readINITree(const std::string& file);
│ │ │ │ +
144
│ │ │ │ +
146
│ │ │ │ +
158 static void readOptions(int argc, char* argv [], ParameterTree& pt);
│ │ │ │ +
159
│ │ │ │ +
177 static void readNamedOptions(int argc, char* argv[],
│ │ │ │ +
178 ParameterTree& pt,
│ │ │ │ +
179 std::vector<std::string> keywords,
│ │ │ │ +
180 unsigned int required = std::numeric_limits<unsigned int>::max(),
│ │ │ │ +
181 bool allow_more = true,
│ │ │ │ +
182 bool overwrite = true,
│ │ │ │ +
183 std::vector<std::string> help = std::vector<std::string>());
│ │ │ │ +
184
│ │ │ │ +
185 private:
│ │ │ │ +
186 static std::string generateHelpString(std::string progname, std::vector<std::string> keywords, unsigned int required, std::vector<std::string> help);
│ │ │ │ +
187 };
│ │ │ │
│ │ │ │ -
151
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
153 {
│ │ │ │ -
154 static FakeMPIHelper singleton;
│ │ │ │ -
155 return singleton;
│ │ │ │ -
156 }
│ │ │ │ -
│ │ │ │ -
157
│ │ │ │ -
161 int rank () const { return 0; }
│ │ │ │ -
165 int size () const { return 1; }
│ │ │ │ -
166
│ │ │ │ -
167 private:
│ │ │ │ -
168 FakeMPIHelper() {}
│ │ │ │ -
169 FakeMPIHelper(const FakeMPIHelper&);
│ │ │ │ -
170 FakeMPIHelper& operator=(const FakeMPIHelper);
│ │ │ │ -
171 };
│ │ │ │ -
│ │ │ │ -
172
│ │ │ │ -
173#if HAVE_MPI
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
181 {
│ │ │ │ -
182 public:
│ │ │ │ -
187 constexpr static bool isFake = false;
│ │ │ │
188
│ │ │ │ -
192 typedef MPI_Comm MPICommunicator;
│ │ │ │ -
193
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
201 {
│ │ │ │ -
202 return MPI_COMM_WORLD;
│ │ │ │ -
203 }
│ │ │ │ -
│ │ │ │ -
204
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
212 {
│ │ │ │ -
213 return MPI_COMM_SELF;
│ │ │ │ -
214 }
│ │ │ │ -
│ │ │ │ -
215
│ │ │ │ -
221 [[deprecated("getCollectionCommunication is deprecated. Use getCommunication instead.")]]
│ │ │ │ - │ │ │ │ -
│ │ │ │ - │ │ │ │ -
224 {
│ │ │ │ - │ │ │ │ -
226 }
│ │ │ │ -
│ │ │ │ -
227
│ │ │ │ - │ │ │ │ -
│ │ │ │ - │ │ │ │ -
230 {
│ │ │ │ - │ │ │ │ -
232 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
252 DUNE_EXPORT static MPIHelper& instance(int& argc, char**& argv)
│ │ │ │ -
253 {
│ │ │ │ -
254 return instance(&argc, &argv);
│ │ │ │ -
255 }
│ │ │ │ -
│ │ │ │ -
256
│ │ │ │ -
│ │ │ │ -
284 DUNE_EXPORT static MPIHelper& instance(int* argc = nullptr, char*** argv = nullptr)
│ │ │ │ -
285 {
│ │ │ │ -
286 assert((argc == nullptr) == (argv == nullptr));
│ │ │ │ -
287 static MPIHelper instance{argc, argv};
│ │ │ │ -
288 return instance;
│ │ │ │ -
289 }
│ │ │ │ -
│ │ │ │ -
290
│ │ │ │ -
294 int rank () const { return rank_; }
│ │ │ │ -
298 int size () const { return size_; }
│ │ │ │ -
299
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
302 {
│ │ │ │ -
303 int wasFinalized = -1;
│ │ │ │ -
304 MPI_Finalized( &wasFinalized );
│ │ │ │ -
305 if(!wasFinalized && initializedHere_)
│ │ │ │ -
306 {
│ │ │ │ -
307 MPI_Finalize();
│ │ │ │ -
308 dverb << "Called MPI_Finalize on p=" << rank_ << "!" <<std::endl;
│ │ │ │ -
309 }
│ │ │ │ -
310
│ │ │ │ -
311 }
│ │ │ │ -
│ │ │ │ -
312
│ │ │ │ -
313 private:
│ │ │ │ -
314 int rank_;
│ │ │ │ -
315 int size_;
│ │ │ │ -
316 bool initializedHere_;
│ │ │ │ -
317 void prevent_warning(int){}
│ │ │ │ -
318
│ │ │ │ -
320 MPIHelper(int* argc, char*** argv)
│ │ │ │ -
321 : initializedHere_(false)
│ │ │ │ -
322 {
│ │ │ │ -
323 int wasInitialized = -1;
│ │ │ │ -
324 MPI_Initialized( &wasInitialized );
│ │ │ │ -
325 if(!wasInitialized)
│ │ │ │ -
326 {
│ │ │ │ -
327 rank_ = -1;
│ │ │ │ -
328 size_ = -1;
│ │ │ │ -
329 static int is_initialized = MPI_Init(argc, argv);
│ │ │ │ -
330 prevent_warning(is_initialized);
│ │ │ │ -
331 initializedHere_ = true;
│ │ │ │ -
332 }
│ │ │ │ -
333
│ │ │ │ -
334 MPI_Comm_rank(MPI_COMM_WORLD,&rank_);
│ │ │ │ -
335 MPI_Comm_size(MPI_COMM_WORLD,&size_);
│ │ │ │ -
336
│ │ │ │ -
337 assert( rank_ >= 0 );
│ │ │ │ -
338 assert( size_ >= 1 );
│ │ │ │ -
339
│ │ │ │ -
340 dverb << "Called MPI_Init on p=" << rank_ << "!" << std::endl;
│ │ │ │ -
341 }
│ │ │ │ -
342
│ │ │ │ -
343 MPIHelper(const MPIHelper&);
│ │ │ │ -
344 MPIHelper& operator=(const MPIHelper);
│ │ │ │ -
345 };
│ │ │ │ -
│ │ │ │ -
346#else // !HAVE_MPI
│ │ │ │ -
347 // We do not have MPI therefore FakeMPIHelper
│ │ │ │ -
348 // is the MPIHelper
│ │ │ │ -
353 typedef FakeMPIHelper MPIHelper;
│ │ │ │ -
354
│ │ │ │ -
355#endif // !HAVE_MPI
│ │ │ │ -
356
│ │ │ │ -
357} // end namespace Dune
│ │ │ │ -
358
│ │ │ │ -
359#endif // DUNE_COMMON_PARALLEL_MPIHELPER_HH
│ │ │ │ -
Implements an utility class that provides collective communication methods for sequential programs.
│ │ │ │ -
Implements an utility class that provides MPI's collective communication methods.
│ │ │ │ -
Standard Dune debug streams.
│ │ │ │ -
A few common exception classes.
│ │ │ │ -
Definition of macros controlling symbol visibility at the ABI level.
│ │ │ │ -
#define DUNE_EXPORT
Export a symbol as part of the public ABI.
Definition visibility.hh:20
│ │ │ │ -
DVerbType dverb(std::cout)
Singleton of verbose debug stream.
Definition stdstreams.hh:117
│ │ │ │ +
189} // end namespace Dune
│ │ │ │ +
190
│ │ │ │ +
191#endif // DUNE_PARAMETER_PARSER_HH
│ │ │ │ +
A few common exception classes.
│ │ │ │ +
A hierarchical structure of string parameters.
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Definition communication.hh:46
│ │ │ │ -
Collective communication interface and sequential default implementation.
Definition communication.hh:100
│ │ │ │ -
A fake mpi helper.
Definition mpihelper.hh:76
│ │ │ │ -
static DUNE_EXPORT MPICommunicator getCommunicator()
get the default communicator
Definition mpihelper.hh:95
│ │ │ │ -
int size() const
return rank of process, i.e. one
Definition mpihelper.hh:165
│ │ │ │ -
static Communication< MPICommunicator > getCollectiveCommunication()
Definition mpihelper.hh:120
│ │ │ │ -
static MPICommunicator getLocalCommunicator()
get a local communicator
Definition mpihelper.hh:107
│ │ │ │ -
No_Comm MPICommunicator
The type of the mpi communicator.
Definition mpihelper.hh:87
│ │ │ │ -
static DUNE_EXPORT FakeMPIHelper & instance(int argc, char **argv)
Get the singleton instance of the helper.
Definition mpihelper.hh:146
│ │ │ │ -
static DUNE_EXPORT FakeMPIHelper & instance()
Definition mpihelper.hh:152
│ │ │ │ -
static Communication< MPICommunicator > getCommunication()
Definition mpihelper.hh:126
│ │ │ │ -
static constexpr bool isFake
Are we fake (i.e. pretend to have MPI support but are compiled without.)
Definition mpihelper.hh:82
│ │ │ │ -
int rank() const
return rank of process, i.e. zero
Definition mpihelper.hh:161
│ │ │ │ -
A real mpi helper.
Definition mpihelper.hh:181
│ │ │ │ -
int size() const
return number of processes
Definition mpihelper.hh:298
│ │ │ │ -
static constexpr bool isFake
Are we fake (i. e. pretend to have MPI support but are compiled without.
Definition mpihelper.hh:187
│ │ │ │ -
static DUNE_EXPORT MPIHelper & instance(int *argc=nullptr, char ***argv=nullptr)
Get the singleton instance of the helper.
Definition mpihelper.hh:284
│ │ │ │ -
static DUNE_EXPORT MPIHelper & instance(int &argc, char **&argv)
Get the singleton instance of the helper.
Definition mpihelper.hh:252
│ │ │ │ -
static Communication< MPICommunicator > getCommunication()
Definition mpihelper.hh:229
│ │ │ │ -
~MPIHelper()
calls MPI_Finalize
Definition mpihelper.hh:301
│ │ │ │ -
int rank() const
return rank of process
Definition mpihelper.hh:294
│ │ │ │ -
MPI_Comm MPICommunicator
The type of the mpi communicator.
Definition mpihelper.hh:192
│ │ │ │ -
static MPICommunicator getCommunicator()
get the default communicator
Definition mpihelper.hh:200
│ │ │ │ -
static MPICommunicator getLocalCommunicator()
get a local communicator
Definition mpihelper.hh:211
│ │ │ │ -
static Communication< MPICommunicator > getCollectiveCommunication()
Definition mpihelper.hh:223
│ │ │ │ +
Base class for Dune-Exceptions.
Definition exceptions.hh:96
│ │ │ │ +
Default exception class for range errors.
Definition exceptions.hh:254
│ │ │ │ +
Hierarchical structure of string parameters.
Definition parametertree.hh:37
│ │ │ │ +
report parser error while reading ParameterTree
Definition parametertreeparser.hh:22
│ │ │ │ +
exception thrown if the user wants to see help string
Definition parametertreeparser.hh:28
│ │ │ │ +
Parsers to set up a ParameterTree from various input sources.
Definition parametertreeparser.hh:35
│ │ │ │ +
static void readOptions(int argc, char *argv[], ParameterTree &pt)
parse command line options and build hierarchical ParameterTree structure
Definition parametertreeparser.cc:155
│ │ │ │ +
static void readINITree(std::istream &in, ParameterTree &pt, bool overwrite)
parse C++ stream
Definition parametertreeparser.cc:70
│ │ │ │ +
static void readNamedOptions(int argc, char *argv[], ParameterTree &pt, std::vector< std::string > keywords, unsigned int required=std::numeric_limits< unsigned int >::max(), bool allow_more=true, bool overwrite=true, std::vector< std::string > help=std::vector< std::string >())
read [named] command line options and build hierarchical ParameterTree structure
Definition parametertreeparser.cc:171
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,306 +1,116 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -mpihelper.hh │ │ │ │ │ +parametertreeparser.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PARALLEL_MPIHELPER_HH │ │ │ │ │ -6#define DUNE_COMMON_PARALLEL_MPIHELPER_HH │ │ │ │ │ +5#ifndef DUNE_PARAMETER_PARSER_HH │ │ │ │ │ +6#define DUNE_PARAMETER_PARSER_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ -9#include │ │ │ │ │ -10 │ │ │ │ │ -11#if HAVE_MPI │ │ │ │ │ -12#include │ │ │ │ │ -13#endif │ │ │ │ │ -14 │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18#include │ │ │ │ │ -19 │ │ │ │ │ -20#if HAVE_MPI │ │ │ │ │ -21#include │ │ │ │ │ -22#endif │ │ │ │ │ -23 │ │ │ │ │ -24namespace Dune │ │ │ │ │ -25{ │ │ │ │ │ -75 class FakeMPIHelper │ │ │ │ │ -76 { │ │ │ │ │ -77 public: │ │ │ │ │ -82 constexpr static bool isFake = true; │ │ │ │ │ -83 │ │ │ │ │ -87 typedef No_Comm MPICommunicator; │ │ │ │ │ -88 │ │ │ │ │ -95 DUNE_EXPORT static MPICommunicator getCommunicator () │ │ │ │ │ -96 { │ │ │ │ │ -97 static MPICommunicator comm; │ │ │ │ │ -98 return comm; │ │ │ │ │ -99 } │ │ │ │ │ -100 │ │ │ │ │ -107 static MPICommunicator getLocalCommunicator () │ │ │ │ │ -108 { │ │ │ │ │ -109 return getCommunicator(); │ │ │ │ │ -110 } │ │ │ │ │ -111 │ │ │ │ │ -112 │ │ │ │ │ -113 │ │ │ │ │ -119 [[deprecated("getCollectionCommunication is deprecated. Use │ │ │ │ │ -getCommunication instead.")]] │ │ │ │ │ -120 static Communication getCollectiveCommunication() │ │ │ │ │ -121 { │ │ │ │ │ -122 return Communication(getCommunicator()); │ │ │ │ │ -123 } │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14#include │ │ │ │ │ +15 │ │ │ │ │ +16#include │ │ │ │ │ +17#include │ │ │ │ │ +18 │ │ │ │ │ +19namespace Dune { │ │ │ │ │ +20 │ │ │ │ │ +22 class ParameterTreeParserError : public RangeError {}; │ │ │ │ │ +28 class HelpRequest : public Exception {}; │ │ │ │ │ +29 │ │ │ │ │ +34 class ParameterTreeParser │ │ │ │ │ +35 { │ │ │ │ │ +36 │ │ │ │ │ +37 static std::string ltrim(const std::string& s); │ │ │ │ │ +38 static std::string rtrim(const std::string& s); │ │ │ │ │ +39 │ │ │ │ │ +40 public: │ │ │ │ │ +41 │ │ │ │ │ +85 │ │ │ │ │ +96 static void readINITree(std::istream& in, ParameterTree& pt, │ │ │ │ │ +97 bool overwrite); │ │ │ │ │ +98 │ │ │ │ │ +105 static Dune::ParameterTree readINITree(std::istream& in); │ │ │ │ │ +106 │ │ │ │ │ +107 │ │ │ │ │ +120 static void readINITree(std::istream& in, ParameterTree& pt, │ │ │ │ │ +121 const std::string srcname = "stream", │ │ │ │ │ +122 bool overwrite = true); │ │ │ │ │ +123 │ │ │ │ │ 124 │ │ │ │ │ -125 static Communication │ │ │ │ │ -126 getCommunication() │ │ │ │ │ -127 { │ │ │ │ │ -128 return Communication(getCommunicator()); │ │ │ │ │ -129 } │ │ │ │ │ -130 │ │ │ │ │ -146 DUNE_EXPORT static FakeMPIHelper& instance([[maybe_unused]] int argc, │ │ │ │ │ -147 [[maybe_unused]] char** argv) │ │ │ │ │ -148 { │ │ │ │ │ -149 return instance(); │ │ │ │ │ -150 } │ │ │ │ │ -151 │ │ │ │ │ -152 DUNE_EXPORT static FakeMPIHelper& instance() │ │ │ │ │ -153 { │ │ │ │ │ -154 static FakeMPIHelper singleton; │ │ │ │ │ -155 return singleton; │ │ │ │ │ -156 } │ │ │ │ │ -157 │ │ │ │ │ -161 int rank () const { return 0; } │ │ │ │ │ -165 int size () const { return 1; } │ │ │ │ │ -166 │ │ │ │ │ -167 private: │ │ │ │ │ -168 FakeMPIHelper() {} │ │ │ │ │ -169 FakeMPIHelper(const FakeMPIHelper&); │ │ │ │ │ -170 FakeMPIHelper& operator=(const FakeMPIHelper); │ │ │ │ │ -171 }; │ │ │ │ │ -172 │ │ │ │ │ -173#if HAVE_MPI │ │ │ │ │ -180 class MPIHelper │ │ │ │ │ -181 { │ │ │ │ │ -182 public: │ │ │ │ │ -187 constexpr static bool isFake = false; │ │ │ │ │ +135 static void readINITree(std::string file, ParameterTree& pt, bool overwrite │ │ │ │ │ += true); │ │ │ │ │ +136 │ │ │ │ │ +143 static Dune::ParameterTree readINITree(const std::string& file); │ │ │ │ │ +144 │ │ │ │ │ +146 │ │ │ │ │ +158 static void readOptions(int argc, char* argv [], ParameterTree& pt); │ │ │ │ │ +159 │ │ │ │ │ +177 static void readNamedOptions(int argc, char* argv[], │ │ │ │ │ +178 ParameterTree& pt, │ │ │ │ │ +179 std::vector keywords, │ │ │ │ │ +180 unsigned int required = std::numeric_limits::max(), │ │ │ │ │ +181 bool allow_more = true, │ │ │ │ │ +182 bool overwrite = true, │ │ │ │ │ +183 std::vector help = std::vector()); │ │ │ │ │ +184 │ │ │ │ │ +185 private: │ │ │ │ │ +186 static std::string generateHelpString(std::string progname, std:: │ │ │ │ │ +vector keywords, unsigned int required, std::vector │ │ │ │ │ +help); │ │ │ │ │ +187 }; │ │ │ │ │ 188 │ │ │ │ │ -192 typedef MPI_Comm MPICommunicator; │ │ │ │ │ -193 │ │ │ │ │ -200 static MPICommunicator getCommunicator () │ │ │ │ │ -201 { │ │ │ │ │ -202 return MPI_COMM_WORLD; │ │ │ │ │ -203 } │ │ │ │ │ -204 │ │ │ │ │ -211 static MPICommunicator getLocalCommunicator () │ │ │ │ │ -212 { │ │ │ │ │ -213 return MPI_COMM_SELF; │ │ │ │ │ -214 } │ │ │ │ │ -215 │ │ │ │ │ -221 [[deprecated("getCollectionCommunication is deprecated. Use │ │ │ │ │ -getCommunication instead.")]] │ │ │ │ │ -222 static Communication │ │ │ │ │ -223 getCollectiveCommunication() │ │ │ │ │ -224 { │ │ │ │ │ -225 return Communication(getCommunicator()); │ │ │ │ │ -226 } │ │ │ │ │ -227 │ │ │ │ │ -228 static Communication │ │ │ │ │ -229 getCommunication() │ │ │ │ │ -230 { │ │ │ │ │ -231 return Communication(getCommunicator()); │ │ │ │ │ -232 } │ │ │ │ │ -252 DUNE_EXPORT static MPIHelper& instance(int& argc, char**& argv) │ │ │ │ │ -253 { │ │ │ │ │ -254 return instance(&argc, &argv); │ │ │ │ │ -255 } │ │ │ │ │ -256 │ │ │ │ │ -284 DUNE_EXPORT static MPIHelper& instance(int* argc = nullptr, char*** argv = │ │ │ │ │ -nullptr) │ │ │ │ │ -285 { │ │ │ │ │ -286 assert((argc == nullptr) == (argv == nullptr)); │ │ │ │ │ -287 static MPIHelper instance{argc, argv}; │ │ │ │ │ -288 return instance; │ │ │ │ │ -289 } │ │ │ │ │ -290 │ │ │ │ │ -294 int rank () const { return rank_; } │ │ │ │ │ -298 int size () const { return size_; } │ │ │ │ │ -299 │ │ │ │ │ -301 ~MPIHelper() │ │ │ │ │ -302 { │ │ │ │ │ -303 int wasFinalized = -1; │ │ │ │ │ -304 MPI_Finalized( &wasFinalized ); │ │ │ │ │ -305 if(!wasFinalized && initializedHere_) │ │ │ │ │ -306 { │ │ │ │ │ -307 MPI_Finalize(); │ │ │ │ │ -308 dverb << "Called MPI_Finalize on p=" << rank_ << "!" <= 0 ); │ │ │ │ │ -338 assert( size_ >= 1 ); │ │ │ │ │ -339 │ │ │ │ │ -340 dverb << "Called MPI_Init on p=" << rank_ << "!" << std::endl; │ │ │ │ │ -341 } │ │ │ │ │ -342 │ │ │ │ │ -343 MPIHelper(const MPIHelper&); │ │ │ │ │ -344 MPIHelper& operator=(const MPIHelper); │ │ │ │ │ -345 }; │ │ │ │ │ -346#else // !HAVE_MPI │ │ │ │ │ -347 // We do not have MPI therefore FakeMPIHelper │ │ │ │ │ -348 // is the MPIHelper │ │ │ │ │ -353 typedef FakeMPIHelper MPIHelper; │ │ │ │ │ -354 │ │ │ │ │ -355#endif // !HAVE_MPI │ │ │ │ │ -356 │ │ │ │ │ -357} // end namespace Dune │ │ │ │ │ -358 │ │ │ │ │ -359#endif // DUNE_COMMON_PARALLEL_MPIHELPER_HH │ │ │ │ │ -communication.hh │ │ │ │ │ -Implements an utility class that provides collective communication methods for │ │ │ │ │ -sequential programs. │ │ │ │ │ -mpicommunication.hh │ │ │ │ │ -Implements an utility class that provides MPI's collective communication │ │ │ │ │ -methods. │ │ │ │ │ -stdstreams.hh │ │ │ │ │ -Standard Dune debug streams. │ │ │ │ │ +189} // end namespace Dune │ │ │ │ │ +190 │ │ │ │ │ +191#endif // DUNE_PARAMETER_PARSER_HH │ │ │ │ │ exceptions.hh │ │ │ │ │ A few common exception classes. │ │ │ │ │ -visibility.hh │ │ │ │ │ -Definition of macros controlling symbol visibility at the ABI level. │ │ │ │ │ -DUNE_EXPORT │ │ │ │ │ -#define DUNE_EXPORT │ │ │ │ │ -Export a symbol as part of the public ABI. │ │ │ │ │ -Definition visibility.hh:20 │ │ │ │ │ -Dune::dverb │ │ │ │ │ -DVerbType dverb(std::cout) │ │ │ │ │ -Singleton of verbose debug stream. │ │ │ │ │ -Definition stdstreams.hh:117 │ │ │ │ │ +parametertree.hh │ │ │ │ │ +A hierarchical structure of string parameters. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::No_Comm │ │ │ │ │ -Definition communication.hh:46 │ │ │ │ │ -Dune::Communication │ │ │ │ │ -Collective communication interface and sequential default implementation. │ │ │ │ │ -Definition communication.hh:100 │ │ │ │ │ -Dune::FakeMPIHelper │ │ │ │ │ -A fake mpi helper. │ │ │ │ │ -Definition mpihelper.hh:76 │ │ │ │ │ -Dune::FakeMPIHelper::getCommunicator │ │ │ │ │ -static DUNE_EXPORT MPICommunicator getCommunicator() │ │ │ │ │ -get the default communicator │ │ │ │ │ -Definition mpihelper.hh:95 │ │ │ │ │ -Dune::FakeMPIHelper::size │ │ │ │ │ -int size() const │ │ │ │ │ -return rank of process, i.e. one │ │ │ │ │ -Definition mpihelper.hh:165 │ │ │ │ │ -Dune::FakeMPIHelper::getCollectiveCommunication │ │ │ │ │ -static Communication< MPICommunicator > getCollectiveCommunication() │ │ │ │ │ -Definition mpihelper.hh:120 │ │ │ │ │ -Dune::FakeMPIHelper::getLocalCommunicator │ │ │ │ │ -static MPICommunicator getLocalCommunicator() │ │ │ │ │ -get a local communicator │ │ │ │ │ -Definition mpihelper.hh:107 │ │ │ │ │ -Dune::FakeMPIHelper::MPICommunicator │ │ │ │ │ -No_Comm MPICommunicator │ │ │ │ │ -The type of the mpi communicator. │ │ │ │ │ -Definition mpihelper.hh:87 │ │ │ │ │ -Dune::FakeMPIHelper::instance │ │ │ │ │ -static DUNE_EXPORT FakeMPIHelper & instance(int argc, char **argv) │ │ │ │ │ -Get the singleton instance of the helper. │ │ │ │ │ -Definition mpihelper.hh:146 │ │ │ │ │ -Dune::FakeMPIHelper::instance │ │ │ │ │ -static DUNE_EXPORT FakeMPIHelper & instance() │ │ │ │ │ -Definition mpihelper.hh:152 │ │ │ │ │ -Dune::FakeMPIHelper::getCommunication │ │ │ │ │ -static Communication< MPICommunicator > getCommunication() │ │ │ │ │ -Definition mpihelper.hh:126 │ │ │ │ │ -Dune::FakeMPIHelper::isFake │ │ │ │ │ -static constexpr bool isFake │ │ │ │ │ -Are we fake (i.e. pretend to have MPI support but are compiled without.) │ │ │ │ │ -Definition mpihelper.hh:82 │ │ │ │ │ -Dune::FakeMPIHelper::rank │ │ │ │ │ -int rank() const │ │ │ │ │ -return rank of process, i.e. zero │ │ │ │ │ -Definition mpihelper.hh:161 │ │ │ │ │ -Dune::MPIHelper │ │ │ │ │ -A real mpi helper. │ │ │ │ │ -Definition mpihelper.hh:181 │ │ │ │ │ -Dune::MPIHelper::size │ │ │ │ │ -int size() const │ │ │ │ │ -return number of processes │ │ │ │ │ -Definition mpihelper.hh:298 │ │ │ │ │ -Dune::MPIHelper::isFake │ │ │ │ │ -static constexpr bool isFake │ │ │ │ │ -Are we fake (i. e. pretend to have MPI support but are compiled without. │ │ │ │ │ -Definition mpihelper.hh:187 │ │ │ │ │ -Dune::MPIHelper::instance │ │ │ │ │ -static DUNE_EXPORT MPIHelper & instance(int *argc=nullptr, char │ │ │ │ │ -***argv=nullptr) │ │ │ │ │ -Get the singleton instance of the helper. │ │ │ │ │ -Definition mpihelper.hh:284 │ │ │ │ │ -Dune::MPIHelper::instance │ │ │ │ │ -static DUNE_EXPORT MPIHelper & instance(int &argc, char **&argv) │ │ │ │ │ -Get the singleton instance of the helper. │ │ │ │ │ -Definition mpihelper.hh:252 │ │ │ │ │ -Dune::MPIHelper::getCommunication │ │ │ │ │ -static Communication< MPICommunicator > getCommunication() │ │ │ │ │ -Definition mpihelper.hh:229 │ │ │ │ │ -Dune::MPIHelper::~MPIHelper │ │ │ │ │ -~MPIHelper() │ │ │ │ │ -calls MPI_Finalize │ │ │ │ │ -Definition mpihelper.hh:301 │ │ │ │ │ -Dune::MPIHelper::rank │ │ │ │ │ -int rank() const │ │ │ │ │ -return rank of process │ │ │ │ │ -Definition mpihelper.hh:294 │ │ │ │ │ -Dune::MPIHelper::MPICommunicator │ │ │ │ │ -MPI_Comm MPICommunicator │ │ │ │ │ -The type of the mpi communicator. │ │ │ │ │ -Definition mpihelper.hh:192 │ │ │ │ │ -Dune::MPIHelper::getCommunicator │ │ │ │ │ -static MPICommunicator getCommunicator() │ │ │ │ │ -get the default communicator │ │ │ │ │ -Definition mpihelper.hh:200 │ │ │ │ │ -Dune::MPIHelper::getLocalCommunicator │ │ │ │ │ -static MPICommunicator getLocalCommunicator() │ │ │ │ │ -get a local communicator │ │ │ │ │ -Definition mpihelper.hh:211 │ │ │ │ │ -Dune::MPIHelper::getCollectiveCommunication │ │ │ │ │ -static Communication< MPICommunicator > getCollectiveCommunication() │ │ │ │ │ -Definition mpihelper.hh:223 │ │ │ │ │ +Dune::Exception │ │ │ │ │ +Base class for Dune-Exceptions. │ │ │ │ │ +Definition exceptions.hh:96 │ │ │ │ │ +Dune::RangeError │ │ │ │ │ +Default exception class for range errors. │ │ │ │ │ +Definition exceptions.hh:254 │ │ │ │ │ +Dune::ParameterTree │ │ │ │ │ +Hierarchical structure of string parameters. │ │ │ │ │ +Definition parametertree.hh:37 │ │ │ │ │ +Dune::ParameterTreeParserError │ │ │ │ │ +report parser error while reading ParameterTree │ │ │ │ │ +Definition parametertreeparser.hh:22 │ │ │ │ │ +Dune::HelpRequest │ │ │ │ │ +exception thrown if the user wants to see help string │ │ │ │ │ +Definition parametertreeparser.hh:28 │ │ │ │ │ +Dune::ParameterTreeParser │ │ │ │ │ +Parsers to set up a ParameterTree from various input sources. │ │ │ │ │ +Definition parametertreeparser.hh:35 │ │ │ │ │ +Dune::ParameterTreeParser::readOptions │ │ │ │ │ +static void readOptions(int argc, char *argv[], ParameterTree &pt) │ │ │ │ │ +parse command line options and build hierarchical ParameterTree structure │ │ │ │ │ +Definition parametertreeparser.cc:155 │ │ │ │ │ +Dune::ParameterTreeParser::readINITree │ │ │ │ │ +static void readINITree(std::istream &in, ParameterTree &pt, bool overwrite) │ │ │ │ │ +parse C++ stream │ │ │ │ │ +Definition parametertreeparser.cc:70 │ │ │ │ │ +Dune::ParameterTreeParser::readNamedOptions │ │ │ │ │ +static void readNamedOptions(int argc, char *argv[], ParameterTree &pt, std:: │ │ │ │ │ +vector< std::string > keywords, unsigned int required=std::numeric_limits< │ │ │ │ │ +unsigned int >::max(), bool allow_more=true, bool overwrite=true, std::vector< │ │ │ │ │ +std::string > help=std::vector< std::string >()) │ │ │ │ │ +read [named] command line options and build hierarchical ParameterTree │ │ │ │ │ +structure │ │ │ │ │ +Definition parametertreeparser.cc:171 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00050.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: indexset.hh File Reference │ │ │ │ +dune-common: copyableoptional.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,125 +65,45 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Enumerations | │ │ │ │ -Functions
│ │ │ │ - │ │ │ │ +Namespaces
│ │ │ │ +
copyableoptional.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

Provides a map between global and local indices. │ │ │ │ -More...

│ │ │ │ -
#include <algorithm>
│ │ │ │ -#include <cstdint>
│ │ │ │ +
#include <cassert>
│ │ │ │ #include <iostream>
│ │ │ │ -#include <dune/common/arraylist.hh>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/parallel/localindex.hh>
│ │ │ │ -#include <dune/common/parallel/mpitraits.hh>
│ │ │ │ +#include <memory>
│ │ │ │ +#include <optional>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <dune/common/typeutilities.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::IndexPair< TG, TL >
 A pair consisting of a global and local index. More...
 
class  Dune::InvalidIndexSetState
 Exception indicating that the index set is not in the expected state. More...
 
class  Dune::ParallelIndexSet< TG, TL, N >
 Manager class for the mapping between local indices and globally unique indices. More...
 
class  Dune::ParallelIndexSet< TG, TL, N >::iterator
 The iterator over the pairs. More...
 
class  Dune::GlobalLookupIndexSet< I >
 Decorates an index set with the possibility to find a global index that is mapped to a specific local. More...
 
struct  Dune::LocalIndexComparator< T >
 
struct  Dune::IndexSetSortFunctor< TG, TL >
class  Dune::CopyableOptional< Type >
 A copyable type wrapper that provides copy/move assignment operations for types that are only copy/move constructible. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Enumerations

enum  Dune::ParallelIndexSetState { Dune::GROUND │ │ │ │ -, Dune::RESIZE │ │ │ │ - }
 The states the index set can be in. More...
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

template<class TG , class TL >
std::ostream & Dune::operator<< (std::ostream &os, const IndexPair< TG, TL > &pair)
 Print an index pair.
 
template<class TG , class TL >
bool Dune::operator== (const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
 
template<class TG , class TL >
bool Dune::operator!= (const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
 
template<class TG , class TL >
bool Dune::operator< (const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
 
template<class TG , class TL >
bool Dune::operator> (const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
 
template<class TG , class TL >
bool Dune::operator<= (const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
 
template<class TG , class TL >
bool Dune::operator>= (const IndexPair< TG, TL > &, const IndexPair< TG, TL > &)
 
template<class TG , class TL >
bool Dune::operator== (const IndexPair< TG, TL > &, const TG &)
 
template<class TG , class TL >
bool Dune::operator!= (const IndexPair< TG, TL > &, const TG &)
 
template<class TG , class TL >
bool Dune::operator< (const IndexPair< TG, TL > &, const TG &)
 
template<class TG , class TL >
bool Dune::operator> (const IndexPair< TG, TL > &, const TG &)
 
template<class TG , class TL >
bool Dune::operator<= (const IndexPair< TG, TL > &, const TG &)
 
template<class TG , class TL >
bool Dune::operator>= (const IndexPair< TG, TL > &, const TG &)
 
template<class TG , class TL , int N>
std::ostream & Dune::operator<< (std::ostream &os, const ParallelIndexSet< TG, TL, N > &indexSet)
 Print an index set.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Provides a map between global and local indices.

│ │ │ │ -
Author
Markus Blatt
│ │ │ │ -
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,109 +1,26 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces | Enumerations | Functions │ │ │ │ │ -indexset.hh File Reference │ │ │ │ │ -Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ -Provides a map between global and local indices. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +copyableoptional.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ - class   Dune::IndexPair<_TG,_TL_> │ │ │ │ │ -  A pair consisting of a global and local index. More... │ │ │ │ │ -  │ │ │ │ │ - class   Dune::InvalidIndexSetState │ │ │ │ │ -  Exception indicating that the index set is not in the expected state. │ │ │ │ │ - More... │ │ │ │ │ -  │ │ │ │ │ - class   Dune::ParallelIndexSet<_TG,_TL,_N_> │ │ │ │ │ -  Manager class for the mapping between local indices and globally │ │ │ │ │ - unique indices. More... │ │ │ │ │ -  │ │ │ │ │ - class   Dune::ParallelIndexSet<_TG,_TL,_N_>::iterator │ │ │ │ │ -  The iterator over the pairs. More... │ │ │ │ │ -  │ │ │ │ │ - class   Dune::GlobalLookupIndexSet<_I_> │ │ │ │ │ -  Decorates an index set with the possibility to find a global index │ │ │ │ │ - that is mapped to a specific local. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::LocalIndexComparator<_T_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::IndexSetSortFunctor<_TG,_TL_> │ │ │ │ │ +class   Dune::CopyableOptional<_Type_> │ │ │ │ │ +  A copyable type wrapper that provides copy/move assignment operations │ │ │ │ │ + for types that are only copy/move constructible. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Enumerations │ │ │ │ │ -enum   Dune::ParallelIndexSetState { Dune::GROUND , Dune::RESIZE } │ │ │ │ │ -  The states the index set can be in. More... │ │ │ │ │ -  │ │ │ │ │ -Functions │ │ │ │ │ -template │ │ │ │ │ -std::ostream &  Dune::operator<< (std::ostream &os, const IndexPair< TG, TL > │ │ │ │ │ - &pair) │ │ │ │ │ -  Print an index pair. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::operator== (const IndexPair< TG, TL > &, const IndexPair< │ │ │ │ │ - TG, TL > &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::operator!= (const IndexPair< TG, TL > &, const IndexPair< │ │ │ │ │ - TG, TL > &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::operator< (const IndexPair< TG, TL > &, const IndexPair< │ │ │ │ │ - TG, TL > &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::operator> (const IndexPair< TG, TL > &, const IndexPair< │ │ │ │ │ - TG, TL > &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::operator<= (const IndexPair< TG, TL > &, const IndexPair< │ │ │ │ │ - TG, TL > &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::operator>= (const IndexPair< TG, TL > &, const IndexPair< │ │ │ │ │ - TG, TL > &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::operator== (const IndexPair< TG, TL > &, const TG &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::operator!= (const IndexPair< TG, TL > &, const TG &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::operator< (const IndexPair< TG, TL > &, const TG &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::operator> (const IndexPair< TG, TL > &, const TG &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::operator<= (const IndexPair< TG, TL > &, const TG &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::operator>= (const IndexPair< TG, TL > &, const TG &) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -std::ostream &  Dune::operator<< (std::ostream &os, const ParallelIndexSet< TG, │ │ │ │ │ - TL, N > &indexSet) │ │ │ │ │ -  Print an index set. │ │ │ │ │ -  │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Provides a map between global and local indices. │ │ │ │ │ - Author │ │ │ │ │ - Markus Blatt │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00050_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: indexset.hh Source File │ │ │ │ +dune-common: copyableoptional.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,964 +70,173 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
indexset.hh
│ │ │ │ +
copyableoptional.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PARALLEL_INDEXSET_HH
│ │ │ │ -
6#define DUNE_COMMON_PARALLEL_INDEXSET_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_COPYABLE_OPTIONAL_HH
│ │ │ │ +
6#define DUNE_COMMON_COPYABLE_OPTIONAL_HH
│ │ │ │
7
│ │ │ │ -
8#include <algorithm>
│ │ │ │ -
9#include <cstdint> // for uint32_t
│ │ │ │ -
10#include <iostream>
│ │ │ │ -
11
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
16
│ │ │ │ -
17namespace Dune
│ │ │ │ -
18{
│ │ │ │ -
28 // forward declarations
│ │ │ │ -
29
│ │ │ │ -
30 template<class TG, class TL>
│ │ │ │ -
31 class IndexPair;
│ │ │ │ -
32
│ │ │ │ -
38 template<class TG, class TL>
│ │ │ │ -
39 std::ostream& operator<<(std::ostream& os, const IndexPair<TG,TL>& pair);
│ │ │ │ +
8#include <cassert>
│ │ │ │ +
9#include <iostream>
│ │ │ │ +
10#include <memory>
│ │ │ │ +
11#include <optional>
│ │ │ │ +
12#include <type_traits>
│ │ │ │ +
13
│ │ │ │ + │ │ │ │ +
15
│ │ │ │ +
16namespace Dune {
│ │ │ │ +
17
│ │ │ │ +
32template <class Type>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
34 : public std::optional<Type>
│ │ │ │ +
35{
│ │ │ │ +
36 static_assert(std::is_copy_constructible_v<Type>);
│ │ │ │ +
37 static_assert(std::is_object_v<Type>);
│ │ │ │ +
38
│ │ │ │ +
39 using Base = std::optional<Type>;
│ │ │ │
40
│ │ │ │ -
41 template<class TG, class TL>
│ │ │ │ -
42 bool operator==(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ -
43
│ │ │ │ -
44 template<class TG, class TL>
│ │ │ │ -
45 bool operator!=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ -
46
│ │ │ │ -
47 template<class TG, class TL>
│ │ │ │ -
48 bool operator<(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ -
49
│ │ │ │ -
50 template<class TG, class TL>
│ │ │ │ -
51 bool operator>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ -
52
│ │ │ │ -
53 template<class TG, class TL>
│ │ │ │ -
54 bool operator<=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ -
55
│ │ │ │ -
56 template<class TG, class TL>
│ │ │ │ -
57 bool operator >=(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ -
58
│ │ │ │ -
59 template<class TG, class TL>
│ │ │ │ -
60 bool operator==(const IndexPair<TG,TL>&, const TG&);
│ │ │ │ -
61
│ │ │ │ -
62 template<class TG, class TL>
│ │ │ │ -
63 bool operator!=(const IndexPair<TG,TL>&, const TG&);
│ │ │ │ -
64
│ │ │ │ -
65 template<class TG, class TL>
│ │ │ │ -
66 bool operator<(const IndexPair<TG,TL>&, const TG&);
│ │ │ │ -
67
│ │ │ │ -
68 template<class TG, class TL>
│ │ │ │ -
69 bool operator>(const IndexPair<TG,TL>&, const TG&);
│ │ │ │ -
70
│ │ │ │ -
71 template<class TG, class TL>
│ │ │ │ -
72 bool operator<=(const IndexPair<TG,TL>&, const TG&);
│ │ │ │ -
73
│ │ │ │ -
74 template<class TG, class TL>
│ │ │ │ -
75 bool operator >=(const IndexPair<TG,TL>&, const TG&);
│ │ │ │ -
76
│ │ │ │ -
77 template<typename T>
│ │ │ │ -
78 struct MPITraits;
│ │ │ │ -
79
│ │ │ │ -
83 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
85 {
│ │ │ │ -
86 friend std::ostream& operator<<<>(std::ostream&, const IndexPair<TG,TL>&);
│ │ │ │ -
87 friend bool operator==<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ -
88 friend bool operator!=<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ -
89 friend bool operator< <>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ -
90 friend bool operator><>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ -
91 friend bool operator<=<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ -
92 friend bool operator>=<>(const IndexPair<TG,TL>&, const IndexPair<TG,TL>&);
│ │ │ │ -
93 friend bool operator==<>(const IndexPair<TG,TL>&, const TG &);
│ │ │ │ -
94 friend bool operator!=<>(const IndexPair<TG,TL>&, const TG &);
│ │ │ │ -
95 friend bool operator< <>(const IndexPair<TG,TL>&, const TG &);
│ │ │ │ -
96 friend bool operator> <>(const IndexPair<TG,TL>&, const TG &);
│ │ │ │ -
97 friend bool operator<=<>(const IndexPair<TG,TL>&, const TG &);
│ │ │ │ -
98 friend bool operator>=<>(const IndexPair<TG,TL>&, const TG &);
│ │ │ │ -
99 friend struct MPITraits<IndexPair<TG,TL> >;
│ │ │ │ -
100
│ │ │ │ -
101 public:
│ │ │ │ -
107 typedef TG GlobalIndex;
│ │ │ │ -
108
│ │ │ │ -
120 typedef TL LocalIndex;
│ │ │ │ -
121
│ │ │ │ - │ │ │ │ -
129
│ │ │ │ - │ │ │ │ - │ │ │ │ -
141
│ │ │ │ -
147 inline const GlobalIndex& global() const;
│ │ │ │ -
148
│ │ │ │ -
154 inline LocalIndex& local();
│ │ │ │ -
155
│ │ │ │ -
161 inline const LocalIndex& local() const;
│ │ │ │ -
162
│ │ │ │ -
168 inline void setLocal(int index);
│ │ │ │ -
169 private:
│ │ │ │ -
171 GlobalIndex global_;
│ │ │ │ - │ │ │ │ -
174 };
│ │ │ │ -
│ │ │ │ -
175
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
181 {
│ │ │ │ - │ │ │ │ -
190 RESIZE
│ │ │ │ -
200 };
│ │ │ │ -
│ │ │ │ -
201
│ │ │ │ - │ │ │ │ -
206
│ │ │ │ -
207 // Forward declaration
│ │ │ │ -
208 template<class I> class GlobalLookupIndexSet;
│ │ │ │ -
209
│ │ │ │ -
216 template<typename TG, typename TL, int N=100>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
218 {
│ │ │ │ -
219 friend class GlobalLookupIndexSet<ParallelIndexSet<TG,TL,N> >;
│ │ │ │ -
220
│ │ │ │ -
221 public:
│ │ │ │ -
226 typedef TG GlobalIndex;
│ │ │ │ -
227
│ │ │ │ -
239 typedef TL LocalIndex;
│ │ │ │ -
240
│ │ │ │ - │ │ │ │ -
245
│ │ │ │ -
252 constexpr static int arraySize = (N>0) ? N : 1;
│ │ │ │ -
253
│ │ │ │ -
│ │ │ │ -
255 class iterator :
│ │ │ │ -
256 public ArrayList<IndexPair,N>::iterator
│ │ │ │ -
257 {
│ │ │ │ -
258 typedef typename ArrayList<IndexPair,N>::iterator
│ │ │ │ - │ │ │ │ - │ │ │ │ -
261 public:
│ │ │ │ -
│ │ │ │ -
262 iterator(ParallelIndexSet<TG,TL,N>& indexSet, const Father& father)
│ │ │ │ -
263 : Father(father), indexSet_(&indexSet)
│ │ │ │ -
264 {}
│ │ │ │ -
│ │ │ │ -
265
│ │ │ │ -
266 private:
│ │ │ │ -
276 inline void markAsDeleted() const
│ │ │ │ -
277 {
│ │ │ │ -
278#ifndef NDEBUG
│ │ │ │ -
279 if(indexSet_->state_ != RESIZE)
│ │ │ │ -
280 DUNE_THROW(InvalidIndexSetState, "Indices can only be removed "
│ │ │ │ -
281 <<"while in RESIZE state!");
│ │ │ │ -
282#endif
│ │ │ │ -
283 Father::operator*().local().setState(DELETED);
│ │ │ │ -
284 }
│ │ │ │ -
285
│ │ │ │ -
287 ParallelIndexSet<TG,TL,N>* indexSet_;
│ │ │ │ -
288
│ │ │ │ -
289 };
│ │ │ │ -
│ │ │ │ -
290
│ │ │ │ -
291
│ │ │ │ -
292
│ │ │ │ -
294 typedef typename
│ │ │ │ - │ │ │ │ - │ │ │ │ -
297
│ │ │ │ - │ │ │ │ -
302
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
308 {
│ │ │ │ -
309 return state_;
│ │ │ │ -
310 }
│ │ │ │ -
│ │ │ │ -
311
│ │ │ │ - │ │ │ │ -
318
│ │ │ │ -
327 inline void add(const GlobalIndex& global);
│ │ │ │ -
328
│ │ │ │ -
337 inline void add(const GlobalIndex& global, const LocalIndex& local);
│ │ │ │ -
338
│ │ │ │ -
346 inline void markAsDeleted(const iterator& position);
│ │ │ │ -
347
│ │ │ │ -
360 void endResize();
│ │ │ │ -
361
│ │ │ │ -
372 inline IndexPair&
│ │ │ │ -
373 operator[](const GlobalIndex& global);
│ │ │ │ -
374
│ │ │ │ -
384 inline IndexPair&
│ │ │ │ -
385 at(const GlobalIndex& global);
│ │ │ │ -
386
│ │ │ │ -
396 inline bool
│ │ │ │ -
397 exists (const GlobalIndex& global) const;
│ │ │ │ -
398
│ │ │ │ -
409 inline const IndexPair&
│ │ │ │ -
410 operator[](const GlobalIndex& global) const;
│ │ │ │ -
411
│ │ │ │ -
421 inline const IndexPair&
│ │ │ │ -
422 at(const GlobalIndex& global) const;
│ │ │ │ -
423
│ │ │ │ -
428 inline iterator begin();
│ │ │ │ -
429
│ │ │ │ -
434 inline iterator end();
│ │ │ │ -
435
│ │ │ │ -
440 inline const_iterator begin() const;
│ │ │ │ -
441
│ │ │ │ -
446 inline const_iterator end() const;
│ │ │ │ -
447
│ │ │ │ -
457 inline void renumberLocal();
│ │ │ │ -
458
│ │ │ │ -
465 inline int seqNo() const;
│ │ │ │ -
466
│ │ │ │ -
471 inline size_t size() const;
│ │ │ │ -
472
│ │ │ │ -
473 private:
│ │ │ │ -
475 ArrayList<IndexPair,N> localIndices_;
│ │ │ │ -
477 ArrayList<IndexPair,N> newIndices_;
│ │ │ │ - │ │ │ │ -
481 int seqNo_;
│ │ │ │ -
483 bool deletedEntries_;
│ │ │ │ -
488 inline void merge();
│ │ │ │ -
489 };
│ │ │ │ -
│ │ │ │ -
490
│ │ │ │ -
491
│ │ │ │ -
497 template<class TG, class TL, int N>
│ │ │ │ -
498 std::ostream& operator<<(std::ostream& os, const ParallelIndexSet<TG,TL,N>& indexSet);
│ │ │ │ -
499
│ │ │ │ -
505 template<class I>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
507 {
│ │ │ │ -
508 public:
│ │ │ │ - │ │ │ │ -
513
│ │ │ │ - │ │ │ │ -
518
│ │ │ │ - │ │ │ │ -
523
│ │ │ │ - │ │ │ │ -
528
│ │ │ │ - │ │ │ │ -
530
│ │ │ │ -
537 GlobalLookupIndexSet(const ParallelIndexSet& indexset, std::size_t size);
│ │ │ │ -
538
│ │ │ │ - │ │ │ │ -
545
│ │ │ │ - │ │ │ │ -
550
│ │ │ │ -
560 inline const IndexPair&
│ │ │ │ -
561 operator[](const GlobalIndex& global) const;
│ │ │ │ -
562
│ │ │ │ -
566 inline const IndexPair*
│ │ │ │ -
567 pair(const std::size_t& local) const;
│ │ │ │ -
568
│ │ │ │ -
573 inline const_iterator begin() const;
│ │ │ │ -
574
│ │ │ │ -
579 inline const_iterator end() const;
│ │ │ │ -
580
│ │ │ │ -
587 inline int seqNo() const;
│ │ │ │ -
588
│ │ │ │ -
593 inline size_t size() const;
│ │ │ │ -
594 private:
│ │ │ │ -
598 const ParallelIndexSet& indexSet_;
│ │ │ │ -
599
│ │ │ │ -
603 std::size_t size_;
│ │ │ │ -
604
│ │ │ │ -
608 std::vector<const IndexPair*> indices_;
│ │ │ │ -
609
│ │ │ │ -
610 };
│ │ │ │ -
│ │ │ │ -
611
│ │ │ │ -
612
│ │ │ │ -
613 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
615 {
│ │ │ │ -
│ │ │ │ -
616 static bool compare([[maybe_unused]] const T& t1, [[maybe_unused]] const T& t2)
│ │ │ │ -
617 {
│ │ │ │ -
618 return false;
│ │ │ │ -
619 }
│ │ │ │ -
│ │ │ │ -
620 };
│ │ │ │ -
│ │ │ │ -
621
│ │ │ │ -
622 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
624 {
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
626 {
│ │ │ │ -
627 return i1.global()<i2.global() || (i1.global()==i2.global() &&
│ │ │ │ - │ │ │ │ -
629 i2.local()));
│ │ │ │ -
630 }
│ │ │ │ -
│ │ │ │ -
631 };
│ │ │ │ -
│ │ │ │ -
632
│ │ │ │ -
633
│ │ │ │ -
634
│ │ │ │ -
635 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ -
636 inline std::ostream& operator<<(std::ostream& os, const IndexPair<TG,TL>& pair)
│ │ │ │ -
637 {
│ │ │ │ -
638 os<<"{global="<<pair.global_<<", local="<<pair.local_<<"}";
│ │ │ │ -
639 return os;
│ │ │ │ -
640 }
│ │ │ │ -
│ │ │ │ -
641
│ │ │ │ -
642 template<class TG, class TL, int N>
│ │ │ │ -
│ │ │ │ -
643 inline std::ostream& operator<<(std::ostream& os, const ParallelIndexSet<TG,TL,N>& indexSet)
│ │ │ │ -
644 {
│ │ │ │ -
645 typedef typename ParallelIndexSet<TG,TL,N>::const_iterator Iterator;
│ │ │ │ -
646 Iterator end = indexSet.end();
│ │ │ │ -
647 os<<"{";
│ │ │ │ -
648 for(Iterator index = indexSet.begin(); index != end; ++index)
│ │ │ │ -
649 os<<*index<<" ";
│ │ │ │ -
650 os<<"}";
│ │ │ │ -
651 return os;
│ │ │ │ -
652
│ │ │ │ -
653 }
│ │ │ │ +
41public:
│ │ │ │ +
42
│ │ │ │ +
47 template <class T = Type,
│ │ │ │ +
48 std::enable_if_t<std::is_default_constructible_v<T>, int> = 0>
│ │ │ │ +
│ │ │ │ +
49 constexpr CopyableOptional ()
│ │ │ │ +
50 noexcept(std::is_nothrow_default_constructible_v<T>)
│ │ │ │ +
51 : Base{std::in_place}
│ │ │ │ +
52 {}
│ │ │ │ +
│ │ │ │ +
53
│ │ │ │ +
58 template <class T = Type,
│ │ │ │ +
59 disableCopyMove<CopyableOptional,T> = 0,
│ │ │ │ +
60 std::enable_if_t<std::is_constructible_v<Type,T&&>, int> = 0,
│ │ │ │ +
61 std::enable_if_t<std::is_convertible_v<T&&,Type>, int> = 0>
│ │ │ │ +
│ │ │ │ +
62 constexpr CopyableOptional (T&& value)
│ │ │ │ +
63 noexcept(std::is_nothrow_constructible_v<Type,T&&>)
│ │ │ │ +
64 : Base{std::in_place, std::forward<T>(value)}
│ │ │ │ +
65 {}
│ │ │ │ +
│ │ │ │ +
66
│ │ │ │ +
71 template <class T = Type,
│ │ │ │ + │ │ │ │ +
73 std::enable_if_t<std::is_constructible_v<Type,T&&>, int> = 0,
│ │ │ │ +
74 std::enable_if_t<not std::is_convertible_v<T&&,Type>, int> = 0>
│ │ │ │ +
│ │ │ │ +
75 explicit constexpr CopyableOptional (T&& value)
│ │ │ │ +
76 noexcept(std::is_nothrow_constructible_v<Type,T&&>)
│ │ │ │ +
77 : Base{std::in_place, std::forward<T>(value)}
│ │ │ │ +
78 {}
│ │ │ │
│ │ │ │ -
654
│ │ │ │ -
655 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ -
656 inline bool operator==(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
│ │ │ │ -
657 {
│ │ │ │ -
658 return a.global_==b.global_;
│ │ │ │ -
659 }
│ │ │ │ -
│ │ │ │ -
660
│ │ │ │ -
661 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ -
662 inline bool operator!=(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
│ │ │ │ -
663 {
│ │ │ │ -
664 return a.global_!=b.global_;
│ │ │ │ -
665 }
│ │ │ │ -
│ │ │ │ -
666
│ │ │ │ -
667 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ -
668 inline bool operator<(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
│ │ │ │ -
669 {
│ │ │ │ -
670 return a.global_<b.global_;
│ │ │ │ -
671 }
│ │ │ │ -
│ │ │ │ -
672
│ │ │ │ -
673 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ -
674 inline bool operator>(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
│ │ │ │ -
675 {
│ │ │ │ -
676 return a.global_>b.global_;
│ │ │ │ -
677 }
│ │ │ │ -
│ │ │ │ -
678
│ │ │ │ -
679 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ -
680 inline bool operator<=(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
│ │ │ │ -
681 {
│ │ │ │ -
682 return a.global_<=b.global_;
│ │ │ │ -
683 }
│ │ │ │ -
│ │ │ │ -
684
│ │ │ │ -
685 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ -
686 inline bool operator >=(const IndexPair<TG,TL>& a, const IndexPair<TG,TL>& b)
│ │ │ │ -
687 {
│ │ │ │ -
688 return a.global_>=b.global_;
│ │ │ │ -
689 }
│ │ │ │ -
│ │ │ │ -
690
│ │ │ │ -
691 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ -
692 inline bool operator==(const IndexPair<TG,TL>& a, const TG& b)
│ │ │ │ -
693 {
│ │ │ │ -
694 return a.global_==b;
│ │ │ │ -
695 }
│ │ │ │ -
│ │ │ │ -
696
│ │ │ │ -
697 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ -
698 inline bool operator!=(const IndexPair<TG,TL>& a, const TG& b)
│ │ │ │ -
699 {
│ │ │ │ -
700 return a.global_!=b;
│ │ │ │ -
701 }
│ │ │ │ -
│ │ │ │ -
702
│ │ │ │ -
703 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ -
704 inline bool operator<(const IndexPair<TG,TL>& a, const TG& b)
│ │ │ │ -
705 {
│ │ │ │ -
706 return a.global_<b;
│ │ │ │ -
707 }
│ │ │ │ -
│ │ │ │ -
708
│ │ │ │ -
709 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ -
710 inline bool operator>(const IndexPair<TG,TL>& a, const TG& b)
│ │ │ │ -
711 {
│ │ │ │ -
712 return a.global_>b;
│ │ │ │ -
713 }
│ │ │ │ -
│ │ │ │ -
714
│ │ │ │ -
715 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ -
716 inline bool operator<=(const IndexPair<TG,TL>& a, const TG& b)
│ │ │ │ -
717 {
│ │ │ │ -
718 return a.global_<=b;
│ │ │ │ -
719 }
│ │ │ │ -
│ │ │ │ -
720
│ │ │ │ -
721 template<class TG, class TL>
│ │ │ │ -
│ │ │ │ -
722 inline bool operator >=(const IndexPair<TG,TL>& a, const TG& b)
│ │ │ │ -
723 {
│ │ │ │ -
724 return a.global_>=b;
│ │ │ │ -
725 }
│ │ │ │ -
│ │ │ │ -
726
│ │ │ │ -
727#ifndef DOXYGEN
│ │ │ │ -
728
│ │ │ │ -
729 template<class TG, class TL>
│ │ │ │ -
730 IndexPair<TG,TL>::IndexPair(const TG& global, const TL& local)
│ │ │ │ -
731 : global_(global), local_(local){}
│ │ │ │ -
732
│ │ │ │ -
733 template<class TG, class TL>
│ │ │ │ -
734 IndexPair<TG,TL>::IndexPair(const TG& global)
│ │ │ │ -
735 : global_(global), local_(){}
│ │ │ │ -
736
│ │ │ │ -
737 template<class TG, class TL>
│ │ │ │ - │ │ │ │ -
739 : global_(), local_(){}
│ │ │ │ -
740
│ │ │ │ -
741 template<class TG, class TL>
│ │ │ │ -
742 inline const TG& IndexPair<TG,TL>::global() const {
│ │ │ │ -
743 return global_;
│ │ │ │ -
744 }
│ │ │ │ -
745
│ │ │ │ -
746 template<class TG, class TL>
│ │ │ │ -
747 inline TL& IndexPair<TG,TL>::local() {
│ │ │ │ -
748 return local_;
│ │ │ │ -
749 }
│ │ │ │ -
750
│ │ │ │ -
751 template<class TG, class TL>
│ │ │ │ -
752 inline const TL& IndexPair<TG,TL>::local() const {
│ │ │ │ -
753 return local_;
│ │ │ │ -
754 }
│ │ │ │ -
755
│ │ │ │ -
756 template<class TG, class TL>
│ │ │ │ -
757 inline void IndexPair<TG,TL>::setLocal(int local){
│ │ │ │ -
758 local_=local;
│ │ │ │ -
759 }
│ │ │ │ -
760
│ │ │ │ -
761 template<class TG, class TL, int N>
│ │ │ │ - │ │ │ │ -
763 : state_(GROUND), seqNo_(0), deletedEntries_()
│ │ │ │ -
764 {}
│ │ │ │ -
765
│ │ │ │ -
766 template<class TG, class TL, int N>
│ │ │ │ - │ │ │ │ -
768 {
│ │ │ │ -
769
│ │ │ │ -
770 // Checks in unproductive code
│ │ │ │ -
771#ifndef NDEBUG
│ │ │ │ -
772 if(state_!=GROUND)
│ │ │ │ -
773 DUNE_THROW(InvalidIndexSetState,
│ │ │ │ -
774 "IndexSet has to be in GROUND state, when "
│ │ │ │ -
775 << "beginResize() is called!");
│ │ │ │ -
776#endif
│ │ │ │ -
777
│ │ │ │ -
778 state_ = RESIZE;
│ │ │ │ -
779 deletedEntries_ = false;
│ │ │ │ -
780 }
│ │ │ │ -
781
│ │ │ │ -
782 template<class TG, class TL, int N>
│ │ │ │ -
783 inline void ParallelIndexSet<TG,TL,N>::add(const GlobalIndex& global)
│ │ │ │ -
784 {
│ │ │ │ -
785 // Checks in unproductive code
│ │ │ │ -
786#ifndef NDEBUG
│ │ │ │ -
787 if(state_ != RESIZE)
│ │ │ │ -
788 DUNE_THROW(InvalidIndexSetState, "Indices can only be added "
│ │ │ │ -
789 <<"while in RESIZE state!");
│ │ │ │ -
790#endif
│ │ │ │ -
791 newIndices_.push_back(IndexPair(global));
│ │ │ │ -
792 }
│ │ │ │ -
793
│ │ │ │ -
794 template<class TG, class TL, int N>
│ │ │ │ -
795 inline void ParallelIndexSet<TG,TL,N>::add(const TG& global, const TL& local)
│ │ │ │ -
796 {
│ │ │ │ -
797 // Checks in unproductive code
│ │ │ │ -
798#ifndef NDEBUG
│ │ │ │ -
799 if(state_ != RESIZE)
│ │ │ │ -
800 DUNE_THROW(InvalidIndexSetState, "Indices can only be added "
│ │ │ │ -
801 <<"while in RESIZE state!");
│ │ │ │ -
802#endif
│ │ │ │ -
803 newIndices_.push_back(IndexPair(global,local));
│ │ │ │ -
804 }
│ │ │ │ -
805
│ │ │ │ -
806 template<class TG, class TL, int N>
│ │ │ │ -
807 inline void ParallelIndexSet<TG,TL,N>::markAsDeleted(const iterator& global)
│ │ │ │ -
808 {
│ │ │ │ -
809 // Checks in unproductive code
│ │ │ │ -
810#ifndef NDEBUG
│ │ │ │ -
811 if(state_ != RESIZE)
│ │ │ │ -
812 DUNE_THROW(InvalidIndexSetState, "Indices can only be removed "
│ │ │ │ -
813 <<"while in RESIZE state!");
│ │ │ │ -
814#endif
│ │ │ │ -
815 deletedEntries_ = true;
│ │ │ │ -
816
│ │ │ │ -
817 global.markAsDeleted();
│ │ │ │ -
818 }
│ │ │ │ -
819
│ │ │ │ -
820 template<class TG, class TL, int N>
│ │ │ │ - │ │ │ │ -
822 // Checks in unproductive code
│ │ │ │ -
823#ifndef NDEBUG
│ │ │ │ -
824 if(state_ != RESIZE)
│ │ │ │ -
825 DUNE_THROW(InvalidIndexSetState, "endResize called while not "
│ │ │ │ -
826 <<"in RESIZE state!");
│ │ │ │ -
827#endif
│ │ │ │ -
828
│ │ │ │ -
829 std::sort(newIndices_.begin(), newIndices_.end(), IndexSetSortFunctor<TG,TL>());
│ │ │ │ -
830 merge();
│ │ │ │ -
831 seqNo_++;
│ │ │ │ -
832 state_ = GROUND;
│ │ │ │ -
833 }
│ │ │ │ -
834
│ │ │ │ -
835
│ │ │ │ -
836 template<class TG, class TL, int N>
│ │ │ │ -
837 inline void ParallelIndexSet<TG,TL,N>::merge(){
│ │ │ │ -
838 if(localIndices_.size()==0)
│ │ │ │ -
839 {
│ │ │ │ -
840 localIndices_=newIndices_;
│ │ │ │ -
841 newIndices_.clear();
│ │ │ │ -
842 }
│ │ │ │ -
843 else if(newIndices_.size()>0 || deletedEntries_)
│ │ │ │ -
844 {
│ │ │ │ -
845 ArrayList<IndexPair,N> tempPairs;
│ │ │ │ -
846
│ │ │ │ -
847 auto old = localIndices_.begin();
│ │ │ │ -
848 auto added = newIndices_.begin();
│ │ │ │ -
849 const auto endold = localIndices_.end();
│ │ │ │ -
850 const auto endadded = newIndices_.end();
│ │ │ │ -
851
│ │ │ │ -
852 while(old != endold && added!= endadded)
│ │ │ │ -
853 {
│ │ │ │ -
854 if(old->local().state()==DELETED) {
│ │ │ │ -
855 old.eraseToHere();
│ │ │ │ -
856 }
│ │ │ │ -
857 else
│ │ │ │ -
858 {
│ │ │ │ -
859 if(old->global() < added->global() ||
│ │ │ │ -
860 (old->global() == added->global()
│ │ │ │ -
861 && LocalIndexComparator<TL>::compare(old->local(),added->local())))
│ │ │ │ -
862 {
│ │ │ │ -
863 tempPairs.push_back(*old);
│ │ │ │ -
864 old.eraseToHere();
│ │ │ │ -
865 continue;
│ │ │ │ -
866 }else
│ │ │ │ -
867 {
│ │ │ │ -
868 tempPairs.push_back(*added);
│ │ │ │ -
869 added.eraseToHere();
│ │ │ │ -
870 }
│ │ │ │ -
871 }
│ │ │ │ -
872 }
│ │ │ │ -
873
│ │ │ │ -
874 while(old != endold)
│ │ │ │ -
875 {
│ │ │ │ -
876 if(old->local().state()!=DELETED) {
│ │ │ │ -
877 tempPairs.push_back(*old);
│ │ │ │ -
878 }
│ │ │ │ -
879 old.eraseToHere();
│ │ │ │ -
880 }
│ │ │ │ -
881
│ │ │ │ -
882 while(added!= endadded)
│ │ │ │ -
883 {
│ │ │ │ -
884 tempPairs.push_back(*added);
│ │ │ │ -
885 added.eraseToHere();
│ │ │ │ -
886 }
│ │ │ │ -
887 localIndices_ = tempPairs;
│ │ │ │ -
888 }
│ │ │ │ -
889 }
│ │ │ │ -
890
│ │ │ │ -
891
│ │ │ │ -
892 template<class TG, class TL, int N>
│ │ │ │ -
893 inline const IndexPair<TG,TL>&
│ │ │ │ -
894 ParallelIndexSet<TG,TL,N>::at(const TG& global) const
│ │ │ │ -
895 {
│ │ │ │ -
896 // perform a binary search
│ │ │ │ -
897 int low=0, high=localIndices_.size()-1, probe=-1;
│ │ │ │ -
898
│ │ │ │ -
899 while(low<high)
│ │ │ │ -
900 {
│ │ │ │ -
901 probe = (high + low) / 2;
│ │ │ │ -
902 if(global <= localIndices_[probe].global())
│ │ │ │ -
903 high = probe;
│ │ │ │ -
904 else
│ │ │ │ -
905 low = probe+1;
│ │ │ │ -
906 }
│ │ │ │ -
907
│ │ │ │ -
908 if(probe==-1)
│ │ │ │ -
909 DUNE_THROW(RangeError, "No entries!");
│ │ │ │ -
910
│ │ │ │ -
911 if( localIndices_[low].global() != global)
│ │ │ │ -
912 DUNE_THROW(RangeError, "Could not find entry of "<<global);
│ │ │ │ -
913 else
│ │ │ │ -
914 return localIndices_[low];
│ │ │ │ -
915 }
│ │ │ │ -
916
│ │ │ │ -
917 template<class TG, class TL, int N>
│ │ │ │ -
918 inline const IndexPair<TG,TL>&
│ │ │ │ -
919 ParallelIndexSet<TG,TL,N>::operator[](const TG& global) const
│ │ │ │ -
920 {
│ │ │ │ -
921 // perform a binary search
│ │ │ │ -
922 int low=0, high=localIndices_.size()-1, probe=-1;
│ │ │ │ -
923
│ │ │ │ -
924 while(low<high)
│ │ │ │ -
925 {
│ │ │ │ -
926 probe = (high + low) / 2;
│ │ │ │ -
927 if(global <= localIndices_[probe].global())
│ │ │ │ -
928 high = probe;
│ │ │ │ -
929 else
│ │ │ │ -
930 low = probe+1;
│ │ │ │ -
931 }
│ │ │ │ -
932
│ │ │ │ -
933 return localIndices_[low];
│ │ │ │ -
934 }
│ │ │ │ -
935 template<class TG, class TL, int N>
│ │ │ │ -
936 inline IndexPair<TG,TL>& ParallelIndexSet<TG,TL,N>::at(const TG& global)
│ │ │ │ -
937 {
│ │ │ │ -
938 // perform a binary search
│ │ │ │ -
939 int low=0, high=localIndices_.size()-1, probe=-1;
│ │ │ │ -
940
│ │ │ │ -
941 while(low<high)
│ │ │ │ -
942 {
│ │ │ │ -
943 probe = (high + low) / 2;
│ │ │ │ -
944 if(localIndices_[probe].global() >= global)
│ │ │ │ -
945 high = probe;
│ │ │ │ -
946 else
│ │ │ │ -
947 low = probe+1;
│ │ │ │ -
948 }
│ │ │ │ -
949
│ │ │ │ -
950 if(probe==-1)
│ │ │ │ -
951 DUNE_THROW(RangeError, "No entries!");
│ │ │ │ -
952
│ │ │ │ -
953 if( localIndices_[low].global() != global)
│ │ │ │ -
954 DUNE_THROW(RangeError, "Could not find entry of "<<global);
│ │ │ │ -
955 else
│ │ │ │ -
956 return localIndices_[low];
│ │ │ │ -
957 }
│ │ │ │ -
958
│ │ │ │ -
959 template<class TG, class TL, int N>
│ │ │ │ -
960 inline bool ParallelIndexSet<TG,TL,N>::exists (const TG& global) const
│ │ │ │ -
961 {
│ │ │ │ -
962 // perform a binary search
│ │ │ │ -
963 int low=0, high=localIndices_.size()-1, probe=-1;
│ │ │ │ -
964
│ │ │ │ -
965 while(low<high)
│ │ │ │ -
966 {
│ │ │ │ -
967 probe = (high + low) / 2;
│ │ │ │ -
968 if(localIndices_[probe].global() >= global)
│ │ │ │ -
969 high = probe;
│ │ │ │ -
970 else
│ │ │ │ -
971 low = probe+1;
│ │ │ │ -
972 }
│ │ │ │ -
973
│ │ │ │ -
974 if(probe==-1)
│ │ │ │ -
975 return false;
│ │ │ │ -
976
│ │ │ │ -
977 if( localIndices_[low].global() != global)
│ │ │ │ -
978 return false;
│ │ │ │ -
979 return true;
│ │ │ │ -
980 }
│ │ │ │ -
981
│ │ │ │ -
982 template<class TG, class TL, int N>
│ │ │ │ -
983 inline IndexPair<TG,TL>& ParallelIndexSet<TG,TL,N>::operator[](const TG& global)
│ │ │ │ -
984 {
│ │ │ │ -
985 // perform a binary search
│ │ │ │ -
986 int low=0, high=localIndices_.size()-1, probe=-1;
│ │ │ │ -
987
│ │ │ │ -
988 while(low<high)
│ │ │ │ -
989 {
│ │ │ │ -
990 probe = (high + low) / 2;
│ │ │ │ -
991 if(localIndices_[probe].global() >= global)
│ │ │ │ -
992 high = probe;
│ │ │ │ -
993 else
│ │ │ │ -
994 low = probe+1;
│ │ │ │ -
995 }
│ │ │ │ -
996
│ │ │ │ -
997 return localIndices_[low];
│ │ │ │ -
998 }
│ │ │ │ -
999 template<class TG, class TL, int N>
│ │ │ │ -
1000 inline typename ParallelIndexSet<TG,TL,N>::iterator
│ │ │ │ - │ │ │ │ -
1002 {
│ │ │ │ -
1003 return iterator(*this, localIndices_.begin());
│ │ │ │ -
1004 }
│ │ │ │ -
1005
│ │ │ │ -
1006
│ │ │ │ -
1007 template<class TG, class TL, int N>
│ │ │ │ -
1008 inline typename ParallelIndexSet<TG,TL,N>::iterator
│ │ │ │ - │ │ │ │ -
1010 {
│ │ │ │ -
1011 return iterator(*this,localIndices_.end());
│ │ │ │ -
1012 }
│ │ │ │ -
1013
│ │ │ │ -
1014 template<class TG, class TL, int N>
│ │ │ │ -
1015 inline typename ParallelIndexSet<TG,TL,N>::const_iterator
│ │ │ │ - │ │ │ │ -
1017 {
│ │ │ │ -
1018 return localIndices_.begin();
│ │ │ │ -
1019 }
│ │ │ │ -
1020
│ │ │ │ -
1021
│ │ │ │ -
1022 template<class TG, class TL, int N>
│ │ │ │ -
1023 inline typename ParallelIndexSet<TG,TL,N>::const_iterator
│ │ │ │ - │ │ │ │ -
1025 {
│ │ │ │ -
1026 return localIndices_.end();
│ │ │ │ -
1027 }
│ │ │ │ -
1028
│ │ │ │ -
1029 template<class TG, class TL, int N>
│ │ │ │ - │ │ │ │ -
1031#ifndef NDEBUG
│ │ │ │ -
1032 if(state_==RESIZE)
│ │ │ │ -
1033 DUNE_THROW(InvalidIndexSetState, "IndexSet has to be in "
│ │ │ │ -
1034 <<"GROUND state for renumberLocal()");
│ │ │ │ -
1035#endif
│ │ │ │ -
1036
│ │ │ │ -
1037 const auto end_ = end();
│ │ │ │ -
1038 uint32_t index=0;
│ │ │ │ -
1039
│ │ │ │ -
1040 for(auto pair=begin(); pair!=end_; index++, ++pair)
│ │ │ │ -
1041 pair->local()=index;
│ │ │ │ -
1042 }
│ │ │ │ -
1043
│ │ │ │ -
1044 template<class TG, class TL, int N>
│ │ │ │ -
1045 inline int ParallelIndexSet<TG,TL,N>::seqNo() const
│ │ │ │ -
1046 {
│ │ │ │ -
1047 return seqNo_;
│ │ │ │ -
1048 }
│ │ │ │ -
1049
│ │ │ │ -
1050 template<class TG, class TL, int N>
│ │ │ │ -
1051 inline size_t ParallelIndexSet<TG,TL,N>::size() const
│ │ │ │ -
1052 {
│ │ │ │ -
1053 return localIndices_.size();
│ │ │ │ -
1054 }
│ │ │ │ -
1055
│ │ │ │ -
1056 template<class I>
│ │ │ │ - │ │ │ │ -
1058 std::size_t size)
│ │ │ │ -
1059 : indexSet_(indexset), size_(size),
│ │ │ │ -
1060 indices_(size_, static_cast<const IndexPair*>(0))
│ │ │ │ -
1061 {
│ │ │ │ -
1062 const_iterator end_ = indexSet_.end();
│ │ │ │ -
1063
│ │ │ │ -
1064 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair) {
│ │ │ │ -
1065 assert(pair->local()<size_);
│ │ │ │ -
1066 indices_[pair->local()] = &(*pair);
│ │ │ │ -
1067 }
│ │ │ │ -
1068 }
│ │ │ │ -
1069
│ │ │ │ -
1070 template<class I>
│ │ │ │ - │ │ │ │ -
1072 : indexSet_(indexset), size_(0)
│ │ │ │ -
1073 {
│ │ │ │ -
1074 const_iterator end_ = indexSet_.end();
│ │ │ │ -
1075 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair)
│ │ │ │ -
1076 size_=std::max(size_,static_cast<std::size_t>(pair->local()));
│ │ │ │ -
1077
│ │ │ │ -
1078 indices_.resize(++size_, 0);
│ │ │ │ -
1079
│ │ │ │ -
1080 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair)
│ │ │ │ -
1081 indices_[pair->local()] = &(*pair);
│ │ │ │ -
1082 }
│ │ │ │ -
1083
│ │ │ │ -
1084 template<class I>
│ │ │ │ - │ │ │ │ -
1086 {}
│ │ │ │ -
1087
│ │ │ │ -
1088 template<class I>
│ │ │ │ -
1089 inline const IndexPair<typename I::GlobalIndex, typename I::LocalIndex>*
│ │ │ │ -
1090 GlobalLookupIndexSet<I>::pair(const std::size_t& local) const
│ │ │ │ -
1091 {
│ │ │ │ -
1092 return indices_[local];
│ │ │ │ -
1093 }
│ │ │ │ -
1094
│ │ │ │ -
1095 template<class I>
│ │ │ │ -
1096 inline const IndexPair<typename I::GlobalIndex, typename I::LocalIndex>&
│ │ │ │ -
1097 GlobalLookupIndexSet<I>::operator[](const GlobalIndex& global) const
│ │ │ │ -
1098 {
│ │ │ │ -
1099 return indexSet_[global];
│ │ │ │ -
1100 }
│ │ │ │ -
1101
│ │ │ │ -
1102 template<class I>
│ │ │ │ -
1103 typename I::const_iterator GlobalLookupIndexSet<I>::begin() const
│ │ │ │ -
1104 {
│ │ │ │ -
1105 return indexSet_.begin();
│ │ │ │ -
1106 }
│ │ │ │ -
1107
│ │ │ │ -
1108 template<class I>
│ │ │ │ -
1109 typename I::const_iterator GlobalLookupIndexSet<I>::end() const
│ │ │ │ -
1110 {
│ │ │ │ -
1111 return indexSet_.end();
│ │ │ │ -
1112 }
│ │ │ │ -
1113
│ │ │ │ -
1114 template<class I>
│ │ │ │ -
1115 inline size_t GlobalLookupIndexSet<I>::size() const
│ │ │ │ -
1116 {
│ │ │ │ -
1117 return size_;
│ │ │ │ -
1118 }
│ │ │ │ -
1119
│ │ │ │ -
1120 template<class I>
│ │ │ │ -
1121 inline int GlobalLookupIndexSet<I>::seqNo() const
│ │ │ │ -
1122 {
│ │ │ │ -
1123 return indexSet_.seqNo();
│ │ │ │ -
1124 }
│ │ │ │ -
1125
│ │ │ │ -
1126 template<typename TG, typename TL, int N, typename TG1, typename TL1, int N1>
│ │ │ │ -
1127 bool operator==(const ParallelIndexSet<TG,TL,N>& idxset,
│ │ │ │ -
1128 const ParallelIndexSet<TG1,TL1,N1>& idxset1)
│ │ │ │ -
1129 {
│ │ │ │ -
1130 if(idxset.size()!=idxset1.size())
│ │ │ │ -
1131 return false;
│ │ │ │ -
1132 typedef typename ParallelIndexSet<TG,TL,N>::const_iterator Iter;
│ │ │ │ -
1133 typedef typename ParallelIndexSet<TG1,TL1,N1>::const_iterator Iter1;
│ │ │ │ -
1134 Iter iter=idxset.begin();
│ │ │ │ -
1135 for(Iter1 iter1=idxset1.begin(); iter1 != idxset1.end(); ++iter, ++iter1) {
│ │ │ │ -
1136 if(iter1->global()!=iter->global())
│ │ │ │ -
1137 return false;
│ │ │ │ -
1138 typedef typename ParallelIndexSet<TG,TL,N>::LocalIndex PI;
│ │ │ │ -
1139 const PI& pi=iter->local(), pi1=iter1->local();
│ │ │ │ -
1140
│ │ │ │ -
1141 if(pi!=pi1)
│ │ │ │ -
1142 return false;
│ │ │ │ -
1143 }
│ │ │ │ -
1144 return true;
│ │ │ │ -
1145 }
│ │ │ │ -
1146
│ │ │ │ -
1147 template<typename TG, typename TL, int N, typename TG1, typename TL1, int N1>
│ │ │ │ -
1148 bool operator!=(const ParallelIndexSet<TG,TL,N>& idxset,
│ │ │ │ -
1149 const ParallelIndexSet<TG1,TL1,N1>& idxset1)
│ │ │ │ -
1150 {
│ │ │ │ -
1151 return !(idxset==idxset1);
│ │ │ │ -
1152 }
│ │ │ │ -
1153
│ │ │ │ -
1154
│ │ │ │ -
1155#endif // DOXYGEN
│ │ │ │ -
1156
│ │ │ │ -
1157}
│ │ │ │ -
1158
│ │ │ │ -
1159#endif // DUNE_COMMON_PARALLEL_INDEXSET_HH
│ │ │ │ -
Provides classes for use as the local index in ParallelIndexSet.
│ │ │ │ -
Traits classes for mapping types onto MPI_Datatype.
│ │ │ │ -
Implements a random-access container that can efficiently change size (similar to std::deque)
│ │ │ │ -
A few common exception classes.
│ │ │ │ -
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition bigunsignedint.hh:278
│ │ │ │ -
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator<(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition iteratorfacades.hh:638
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator>(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition iteratorfacades.hh:684
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator<=(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition iteratorfacades.hh:661
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition iteratorfacades.hh:238
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator>=(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition iteratorfacades.hh:706
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition iteratorfacades.hh:260
│ │ │ │ -
IndexPair & operator[](const GlobalIndex &global)
Find the index pair with a specific global id.
│ │ │ │ -
static constexpr int arraySize
The size of the individual arrays in the underlying ArrayList.
Definition indexset.hh:252
│ │ │ │ -
void beginResize()
Indicate that the index set is to be resized.
│ │ │ │ -
ParallelIndexSetState
The states the index set can be in.
Definition indexset.hh:181
│ │ │ │ -
void renumberLocal()
Renumbers the local index numbers.
│ │ │ │ -
bool exists(const GlobalIndex &global) const
Find the index pair with a specific global id.
│ │ │ │ -
size_t size() const
Get the total number (public and nonpublic) indices.
│ │ │ │ -
ArrayList< IndexPair, N >::const_iterator const_iterator
The constant iterator over the pairs.
Definition indexset.hh:296
│ │ │ │ -
bool operator()(const IndexPair< TG, TL > &i1, const IndexPair< TG, TL > &i2)
Definition indexset.hh:625
│ │ │ │ -
void add(const GlobalIndex &global)
Add an new index to the set.
│ │ │ │ -
const_iterator end() const
Get an iterator over the indices positioned after the last index.
│ │ │ │ -
const LocalIndex & local() const
Get the local index.
│ │ │ │ -
const IndexPair & at(const GlobalIndex &global) const
Find the index pair with a specific global id.
│ │ │ │ -
GlobalLookupIndexSet(const ParallelIndexSet &indexset)
Constructor.
│ │ │ │ -
TL LocalIndex
the type of the local index.
Definition indexset.hh:120
│ │ │ │ -
int seqNo() const
Get the internal sequence number.
│ │ │ │ -
static bool compare(const T &t1, const T &t2)
Definition indexset.hh:616
│ │ │ │ -
iterator begin()
Get an iterator over the indices positioned at the first index.
│ │ │ │ -
Dune::IndexPair< typename I::GlobalIndex, typename I::LocalIndex > IndexPair
Definition indexset.hh:529
│ │ │ │ -
iterator end()
Get an iterator over the indices positioned after the last index.
│ │ │ │ -
ParallelIndexSet::const_iterator const_iterator
The iterator over the index pairs.
Definition indexset.hh:527
│ │ │ │ -
const_iterator begin() const
Get an iterator over the indices positioned at the first index.
│ │ │ │ -
const IndexPair & operator[](const GlobalIndex &global) const
Find the index pair with a specific global id.
│ │ │ │ -
const ParallelIndexSetState & state()
Get the state the index set is in.
Definition indexset.hh:307
│ │ │ │ -
const_iterator begin() const
Get an iterator over the indices positioned at the first index.
│ │ │ │ -
const IndexPair & operator[](const GlobalIndex &global) const
Find the index pair with a specific global id.
│ │ │ │ -
IndexPair()
Construct a new Pair.
│ │ │ │ -
I ParallelIndexSet
The type of the index set.
Definition indexset.hh:512
│ │ │ │ -
TL LocalIndex
The type of the local index, e.g. ParallelLocalIndex.
Definition indexset.hh:239
│ │ │ │ -
void markAsDeleted(const iterator &position)
Mark an index as deleted.
│ │ │ │ -
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition indexset.hh:517
│ │ │ │ -
IndexPair(const GlobalIndex &global, const LocalIndex &local)
Constructs a new Pair.
│ │ │ │ -
void setLocal(int index)
Set the local index.
│ │ │ │ -
const GlobalIndex & global() const
Get the global index.
│ │ │ │ -
void add(const GlobalIndex &global, const LocalIndex &local)
Add an new index to the set.
│ │ │ │ -
const_iterator end() const
Get an iterator over the indices positioned after the last index.
│ │ │ │ -
IndexPair & at(const GlobalIndex &global)
Find the index pair with a specific global id.
│ │ │ │ -
ParallelIndexSet()
Constructor.
│ │ │ │ -
void endResize()
Indicate that the resizing finishes.
│ │ │ │ -
~GlobalLookupIndexSet()
Destructor.
│ │ │ │ -
const IndexPair * pair(const std::size_t &local) const
Get the index pair corresponding to a local index.
│ │ │ │ -
LocalIndex & local()
Get the local index.
│ │ │ │ -
size_t size() const
Get the total number (public and nonpublic) indices.
│ │ │ │ -
IndexPair(const GlobalIndex &global)
Constructs a new Pair.
│ │ │ │ -
TG GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition indexset.hh:226
│ │ │ │ -
TG GlobalIndex
the type of the global index.
Definition indexset.hh:107
│ │ │ │ -
int seqNo() const
Get the internal sequence number.
│ │ │ │ -
iterator(ParallelIndexSet< TG, TL, N > &indexSet, const Father &father)
Definition indexset.hh:262
│ │ │ │ -
GlobalLookupIndexSet(const ParallelIndexSet &indexset, std::size_t size)
Constructor.
│ │ │ │ -
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition indexset.hh:522
│ │ │ │ -
Dune::IndexPair< GlobalIndex, LocalIndex > IndexPair
The type of the pair stored.
Definition indexset.hh:244
│ │ │ │ -
@ RESIZE
Indicates that the index set is currently being resized.
Definition indexset.hh:190
│ │ │ │ -
@ GROUND
The default mode. Indicates that the index set is ready to be used.
Definition indexset.hh:186
│ │ │ │ -
@ DELETED
Definition localindex.hh:28
│ │ │ │ +
79
│ │ │ │ +
81 template <class... Args,
│ │ │ │ + │ │ │ │ +
83 std::enable_if_t<(sizeof...(Args) > 1), int> = 0,
│ │ │ │ +
84 std::enable_if_t<std::is_constructible_v<Type,Args&&...>, int> = 0>
│ │ │ │ +
│ │ │ │ +
85 constexpr CopyableOptional (Args&&... args)
│ │ │ │ +
86 noexcept(std::is_nothrow_constructible_v<Type,Args&&...>)
│ │ │ │ +
87 : Base{std::in_place, std::forward<Args>(args)...}
│ │ │ │ +
88 {}
│ │ │ │ +
│ │ │ │ +
89
│ │ │ │ +
91 constexpr CopyableOptional (const CopyableOptional&) = default;
│ │ │ │ +
92
│ │ │ │ +
94 constexpr CopyableOptional (CopyableOptional&&) = default;
│ │ │ │ +
95
│ │ │ │ +
97 ~CopyableOptional () = default;
│ │ │ │ +
98
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
101 noexcept(std::is_nothrow_copy_assignable_v<Type> ||
│ │ │ │ +
102 (!std::is_copy_assignable_v<Type> && std::is_nothrow_copy_constructible_v<Type>))
│ │ │ │ +
103 {
│ │ │ │ +
104 if constexpr(std::is_copy_assignable_v<Type>)
│ │ │ │ +
105 Base::operator=(that);
│ │ │ │ +
106 else {
│ │ │ │ +
107 // no self-assignment
│ │ │ │ +
108 if (this != std::addressof(that)) {
│ │ │ │ +
109 if (that)
│ │ │ │ +
110 Base::emplace(*that);
│ │ │ │ +
111 else
│ │ │ │ +
112 Base::reset();
│ │ │ │ +
113 }
│ │ │ │ +
114 }
│ │ │ │ +
115 return *this;
│ │ │ │ +
116 }
│ │ │ │ +
│ │ │ │ +
117
│ │ │ │ +
119 template <class T = Type,
│ │ │ │ +
120 std::enable_if_t<std::is_move_constructible_v<T>, int> = 0>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
122 noexcept(std::is_nothrow_move_assignable_v<Type> ||
│ │ │ │ +
123 (!std::is_move_assignable_v<Type> && std::is_nothrow_move_constructible_v<Type>))
│ │ │ │ +
124 {
│ │ │ │ +
125 if constexpr(std::is_move_assignable_v<Type>)
│ │ │ │ +
126 Base::operator=(std::move(that));
│ │ │ │ +
127 else {
│ │ │ │ +
128 // no self-assignment
│ │ │ │ +
129 if (this != std::addressof(that)) {
│ │ │ │ +
130 if (that)
│ │ │ │ +
131 Base::emplace(std::move(*that));
│ │ │ │ +
132 else
│ │ │ │ +
133 Base::reset();
│ │ │ │ +
134 }
│ │ │ │ +
135 }
│ │ │ │ +
136 return *this;
│ │ │ │ +
137 }
│ │ │ │ +
│ │ │ │ +
138
│ │ │ │ +
140 template <class T = Type,
│ │ │ │ +
141 std::enable_if_t<not std::is_same_v<std::decay_t<T>, CopyableOptional>, int> = 0,
│ │ │ │ +
142 std::enable_if_t<(std::is_assignable_v<Type&,T> || std::is_constructible_v<Type,T>), int> = 0>
│ │ │ │ +
│ │ │ │ +
143 constexpr CopyableOptional& operator= (T&& value)
│ │ │ │ +
144 noexcept(std::is_nothrow_assignable_v<Type&,T> ||
│ │ │ │ +
145 (!std::is_assignable_v<Type&,T> && std::is_nothrow_constructible_v<Type,T>))
│ │ │ │ +
146 {
│ │ │ │ +
147 if constexpr(std::is_assignable_v<Type&,T>)
│ │ │ │ +
148 Base::operator=(std::forward<T>(value));
│ │ │ │ +
149 else
│ │ │ │ +
150 Base::emplace(std::forward<T>(value));
│ │ │ │ +
151 return *this;
│ │ │ │ +
152 }
│ │ │ │ +
│ │ │ │ +
153};
│ │ │ │ +
│ │ │ │ +
154
│ │ │ │ +
155} // end namespace Dune
│ │ │ │ +
156
│ │ │ │ +
157#endif // DUNE_COMMON_COPYABLE_OPTIONAL_HH
│ │ │ │ +
Utilities for type computations, constraining overloads, ...
│ │ │ │ +
std::enable_if_t< not Impl::disableCopyMoveHelper< This, T... >::value, int > disableCopyMove
Helper to disable constructor as copy and move constructor.
Definition typeutilities.hh:45
│ │ │ │ +
STL namespace.
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition integersequence.hh:75
│ │ │ │ -
A random access iterator for the Dune::ArrayList class.
Definition arraylist.hh:255
│ │ │ │ -
A constant random access iterator for the Dune::ArrayList class.
Definition arraylist.hh:368
│ │ │ │ -
A dynamically growing random access list.
Definition arraylist.hh:62
│ │ │ │ -
ConstArrayListIterator< MemberType, N, A > const_iterator
A constant random access iterator.
Definition arraylist.hh:110
│ │ │ │ -
A traits class describing the mapping of types onto MPI_Datatypes.
Definition mpitraits.hh:41
│ │ │ │ -
Default exception if a function was called while the object is not in a valid state for that function...
Definition exceptions.hh:281
│ │ │ │ - │ │ │ │ -
A pair consisting of a global and local index.
Definition indexset.hh:85
│ │ │ │ -
Exception indicating that the index set is not in the expected state.
Definition indexset.hh:205
│ │ │ │ -
Decorates an index set with the possibility to find a global index that is mapped to a specific local...
Definition indexset.hh:507
│ │ │ │ -
Manager class for the mapping between local indices and globally unique indices.
Definition indexset.hh:218
│ │ │ │ -
The iterator over the pairs.
Definition indexset.hh:257
│ │ │ │ -
Definition indexset.hh:615
│ │ │ │ -
Definition indexset.hh:624
│ │ │ │ +
A copyable type wrapper that provides copy/move assignment operations for types that are only copy/mo...
Definition copyableoptional.hh:35
│ │ │ │ +
constexpr CopyableOptional(CopyableOptional &&)=default
Move construct the contained value.
│ │ │ │ +
constexpr CopyableOptional(T &&value) noexcept(std::is_nothrow_constructible_v< Type, T && >)
Construct the internal data from perfect forwarding of the passed arguments. Participates in overload...
Definition copyableoptional.hh:62
│ │ │ │ +
constexpr CopyableOptional & operator=(const CopyableOptional &that) noexcept(std::is_nothrow_copy_assignable_v< Type >||(!std::is_copy_assignable_v< Type > &&std::is_nothrow_copy_constructible_v< Type >))
Copy assignment in terms of copy constructor.
Definition copyableoptional.hh:100
│ │ │ │ +
constexpr CopyableOptional() noexcept(std::is_nothrow_default_constructible_v< T >)
Implementation of a default constructor, if the Type is itself default constructible....
Definition copyableoptional.hh:49
│ │ │ │ +
constexpr CopyableOptional(const CopyableOptional &)=default
Copy construct the contained value.
│ │ │ │ +
constexpr CopyableOptional(Args &&... args) noexcept(std::is_nothrow_constructible_v< Type, Args &&... >)
Construct the internal data from perfect forwarding of the passed arguments.
Definition copyableoptional.hh:85
│ │ │ │ +
~CopyableOptional()=default
Default destructor.
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,1122 +1,188 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -indexset.hh │ │ │ │ │ +copyableoptional.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PARALLEL_INDEXSET_HH │ │ │ │ │ -6#define DUNE_COMMON_PARALLEL_INDEXSET_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_COPYABLE_OPTIONAL_HH │ │ │ │ │ +6#define DUNE_COMMON_COPYABLE_OPTIONAL_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ -9#include // for uint32_t │ │ │ │ │ -10#include │ │ │ │ │ -11 │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16 │ │ │ │ │ -17namespace Dune │ │ │ │ │ -18{ │ │ │ │ │ -28 // forward declarations │ │ │ │ │ -29 │ │ │ │ │ -30 template │ │ │ │ │ -31 class IndexPair; │ │ │ │ │ -32 │ │ │ │ │ -38 template │ │ │ │ │ -39 std::ostream& operator<<(std::ostream& os, const IndexPair& pair); │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11#include │ │ │ │ │ +12#include │ │ │ │ │ +13 │ │ │ │ │ +14#include │ │ │ │ │ +15 │ │ │ │ │ +16namespace Dune { │ │ │ │ │ +17 │ │ │ │ │ +32template │ │ │ │ │ +33class CopyableOptional │ │ │ │ │ +34 : public std::optional │ │ │ │ │ +35{ │ │ │ │ │ +36 static_assert(std::is_copy_constructible_v); │ │ │ │ │ +37 static_assert(std::is_object_v); │ │ │ │ │ +38 │ │ │ │ │ +39 using Base = std::optional; │ │ │ │ │ 40 │ │ │ │ │ -41 template │ │ │ │ │ -42 bool operator==(const IndexPair&, const IndexPair&); │ │ │ │ │ -43 │ │ │ │ │ -44 template │ │ │ │ │ -45 bool operator!=(const IndexPair&, const IndexPair&); │ │ │ │ │ -46 │ │ │ │ │ -47 template │ │ │ │ │ -48 bool operator<(const IndexPair&, const IndexPair&); │ │ │ │ │ -49 │ │ │ │ │ -50 template │ │ │ │ │ -51 bool operator>(const IndexPair&, const IndexPair&); │ │ │ │ │ -52 │ │ │ │ │ -53 template │ │ │ │ │ -54 bool operator<=(const IndexPair&, const IndexPair&); │ │ │ │ │ -55 │ │ │ │ │ -56 template │ │ │ │ │ -57 bool operator_>=(const IndexPair&, const IndexPair&); │ │ │ │ │ -58 │ │ │ │ │ -59 template │ │ │ │ │ -60 bool operator==(const IndexPair&, const TG&); │ │ │ │ │ -61 │ │ │ │ │ -62 template │ │ │ │ │ -63 bool operator!=(const IndexPair&, const TG&); │ │ │ │ │ -64 │ │ │ │ │ -65 template │ │ │ │ │ -66 bool operator<(const IndexPair&, const TG&); │ │ │ │ │ -67 │ │ │ │ │ -68 template │ │ │ │ │ -69 bool operator>(const IndexPair&, const TG&); │ │ │ │ │ -70 │ │ │ │ │ -71 template │ │ │ │ │ -72 bool operator<=(const IndexPair&, const TG&); │ │ │ │ │ -73 │ │ │ │ │ -74 template │ │ │ │ │ -75 bool operator_>=(const IndexPair&, const TG&); │ │ │ │ │ -76 │ │ │ │ │ -77 template │ │ │ │ │ -78 struct MPITraits; │ │ │ │ │ +41public: │ │ │ │ │ +42 │ │ │ │ │ +47 template , int> = 0> │ │ │ │ │ +49 constexpr CopyableOptional () │ │ │ │ │ +50 noexcept(std::is_nothrow_default_constructible_v) │ │ │ │ │ +51 : Base{std::in_place} │ │ │ │ │ +52 {} │ │ │ │ │ +53 │ │ │ │ │ +58 template = 0, │ │ │ │ │ +60 std::enable_if_t, int> = 0, │ │ │ │ │ +61 std::enable_if_t, int> = 0> │ │ │ │ │ +62 constexpr CopyableOptional (T&& value) │ │ │ │ │ +63 noexcept(std::is_nothrow_constructible_v) │ │ │ │ │ +64 : Base{std::in_place, std::forward(value)} │ │ │ │ │ +65 {} │ │ │ │ │ +66 │ │ │ │ │ +71 template = 0, │ │ │ │ │ +73 std::enable_if_t, int> = 0, │ │ │ │ │ +74 std::enable_if_t, int> = 0> │ │ │ │ │ +75 explicit constexpr CopyableOptional (T&& value) │ │ │ │ │ +76 noexcept(std::is_nothrow_constructible_v) │ │ │ │ │ +77 : Base{std::in_place, std::forward(value)} │ │ │ │ │ +78 {} │ │ │ │ │ 79 │ │ │ │ │ -83 template │ │ │ │ │ -84 class IndexPair │ │ │ │ │ -85 { │ │ │ │ │ -86 friend std::ostream& operator<<<>(std::ostream&, const IndexPair&); │ │ │ │ │ -87 friend bool operator==<>(const IndexPair&, const IndexPair&); │ │ │ │ │ -88 friend bool operator!=<>(const IndexPair&, const IndexPair&); │ │ │ │ │ -89 friend bool operator< <>(const IndexPair&, const IndexPair&); │ │ │ │ │ -90 friend bool operator><>(const IndexPair&, const IndexPair&); │ │ │ │ │ -91 friend bool operator<=<>(const IndexPair&, const IndexPair&); │ │ │ │ │ -92 friend bool operator>=<>(const IndexPair&, const IndexPair&); │ │ │ │ │ -93 friend bool operator==<>(const IndexPair&, const TG &); │ │ │ │ │ -94 friend bool operator!=<>(const IndexPair&, const TG &); │ │ │ │ │ -95 friend bool operator< <>(const IndexPair&, const TG &); │ │ │ │ │ -96 friend bool operator> <>(const IndexPair&, const TG &); │ │ │ │ │ -97 friend bool operator<=<>(const IndexPair&, const TG &); │ │ │ │ │ -98 friend bool operator>=<>(const IndexPair&, const TG &); │ │ │ │ │ -99 friend struct MPITraits >; │ │ │ │ │ -100 │ │ │ │ │ -101 public: │ │ │ │ │ -107 typedef TG GlobalIndex; │ │ │ │ │ -108 │ │ │ │ │ -120 typedef TL LocalIndex; │ │ │ │ │ -121 │ │ │ │ │ -128 IndexPair(const GlobalIndex& global, const LocalIndex& local); │ │ │ │ │ -129 │ │ │ │ │ -133 IndexPair(); │ │ │ │ │ -140 IndexPair(const GlobalIndex& global); │ │ │ │ │ -141 │ │ │ │ │ -147 inline const GlobalIndex& global() const; │ │ │ │ │ -148 │ │ │ │ │ -154 inline LocalIndex& local(); │ │ │ │ │ -155 │ │ │ │ │ -161 inline const LocalIndex& local() const; │ │ │ │ │ -162 │ │ │ │ │ -168 inline void setLocal(int index); │ │ │ │ │ -169 private: │ │ │ │ │ -171 GlobalIndex global_; │ │ │ │ │ -173 LocalIndex local_; │ │ │ │ │ -174 }; │ │ │ │ │ -175 │ │ │ │ │ -180 enum ParallelIndexSetState │ │ │ │ │ -181 { │ │ │ │ │ -186 GROUND, │ │ │ │ │ -190 RESIZE │ │ │ │ │ -200 }; │ │ │ │ │ -201 │ │ │ │ │ -205 class InvalidIndexSetState : public InvalidStateException {}; │ │ │ │ │ -206 │ │ │ │ │ -207 // Forward declaration │ │ │ │ │ -208 template class GlobalLookupIndexSet; │ │ │ │ │ -209 │ │ │ │ │ -216 template │ │ │ │ │ -217 class ParallelIndexSet │ │ │ │ │ -218 { │ │ │ │ │ -219 friend class GlobalLookupIndexSet >; │ │ │ │ │ -220 │ │ │ │ │ -221 public: │ │ │ │ │ -226 typedef TG GlobalIndex; │ │ │ │ │ -227 │ │ │ │ │ -239 typedef TL LocalIndex; │ │ │ │ │ -240 │ │ │ │ │ -244 typedef Dune::IndexPair IndexPair; │ │ │ │ │ -245 │ │ │ │ │ -252 constexpr static int arraySize = (N>0) ? N : 1; │ │ │ │ │ -253 │ │ │ │ │ -255 class iterator : │ │ │ │ │ -256 public ArrayList::iterator │ │ │ │ │ -257 { │ │ │ │ │ -258 typedef typename ArrayList::iterator │ │ │ │ │ -259 Father; │ │ │ │ │ -260 friend class ParallelIndexSet; │ │ │ │ │ -261 public: │ │ │ │ │ -262 iterator(ParallelIndexSet& indexSet, const Father& father) │ │ │ │ │ -263 : Father(father), indexSet_(&indexSet) │ │ │ │ │ -264 {} │ │ │ │ │ -265 │ │ │ │ │ -266 private: │ │ │ │ │ -276 inline void markAsDeleted() const │ │ │ │ │ -277 { │ │ │ │ │ -278#ifndef NDEBUG │ │ │ │ │ -279 if(indexSet_->state_ != RESIZE) │ │ │ │ │ -280 DUNE_THROW(InvalidIndexSetState, "Indices can only be removed " │ │ │ │ │ -281 <<"while in RESIZE state!"); │ │ │ │ │ -282#endif │ │ │ │ │ -283 Father::operator*().local().setState(DELETED); │ │ │ │ │ -284 } │ │ │ │ │ -285 │ │ │ │ │ -287 ParallelIndexSet* indexSet_; │ │ │ │ │ -288 │ │ │ │ │ -289 }; │ │ │ │ │ -290 │ │ │ │ │ -291 │ │ │ │ │ -292 │ │ │ │ │ -294 typedef typename │ │ │ │ │ -295 ArrayList::const_iterator │ │ │ │ │ -296 const_iterator; │ │ │ │ │ -297 │ │ │ │ │ -301 ParallelIndexSet(); │ │ │ │ │ -302 │ │ │ │ │ -307 inline const ParallelIndexSetState& state() │ │ │ │ │ -308 { │ │ │ │ │ -309 return state_; │ │ │ │ │ -310 } │ │ │ │ │ -311 │ │ │ │ │ -317 void beginResize(); │ │ │ │ │ -318 │ │ │ │ │ -327 inline void add(const GlobalIndex& global); │ │ │ │ │ -328 │ │ │ │ │ -337 inline void add(const GlobalIndex& global, const LocalIndex& local); │ │ │ │ │ -338 │ │ │ │ │ -346 inline void markAsDeleted(const iterator& position); │ │ │ │ │ -347 │ │ │ │ │ -360 void endResize(); │ │ │ │ │ -361 │ │ │ │ │ -372 inline IndexPair& │ │ │ │ │ -373 operator[](const GlobalIndex& global); │ │ │ │ │ -374 │ │ │ │ │ -384 inline IndexPair& │ │ │ │ │ -385 at(const GlobalIndex& global); │ │ │ │ │ -386 │ │ │ │ │ -396 inline bool │ │ │ │ │ -397 exists (const GlobalIndex& global) const; │ │ │ │ │ -398 │ │ │ │ │ -409 inline const IndexPair& │ │ │ │ │ -410 operator[](const GlobalIndex& global) const; │ │ │ │ │ -411 │ │ │ │ │ -421 inline const IndexPair& │ │ │ │ │ -422 at(const GlobalIndex& global) const; │ │ │ │ │ -423 │ │ │ │ │ -428 inline iterator begin(); │ │ │ │ │ -429 │ │ │ │ │ -434 inline iterator end(); │ │ │ │ │ -435 │ │ │ │ │ -440 inline const_iterator begin() const; │ │ │ │ │ -441 │ │ │ │ │ -446 inline const_iterator end() const; │ │ │ │ │ -447 │ │ │ │ │ -457 inline void renumberLocal(); │ │ │ │ │ -458 │ │ │ │ │ -465 inline int seqNo() const; │ │ │ │ │ -466 │ │ │ │ │ -471 inline size_t size() const; │ │ │ │ │ -472 │ │ │ │ │ -473 private: │ │ │ │ │ -475 ArrayList localIndices_; │ │ │ │ │ -477 ArrayList newIndices_; │ │ │ │ │ -479 ParallelIndexSetState state_; │ │ │ │ │ -481 int seqNo_; │ │ │ │ │ -483 bool deletedEntries_; │ │ │ │ │ -488 inline void merge(); │ │ │ │ │ -489 }; │ │ │ │ │ -490 │ │ │ │ │ -491 │ │ │ │ │ -497 template │ │ │ │ │ -498 std::ostream& operator<<(std::ostream& os, const ParallelIndexSet& │ │ │ │ │ -indexSet); │ │ │ │ │ -499 │ │ │ │ │ -505 template │ │ │ │ │ -506 class GlobalLookupIndexSet │ │ │ │ │ -507 { │ │ │ │ │ -508 public: │ │ │ │ │ -512 typedef I ParallelIndexSet; │ │ │ │ │ -513 │ │ │ │ │ -517 typedef typename ParallelIndexSet::LocalIndex LocalIndex; │ │ │ │ │ -518 │ │ │ │ │ -522 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex; │ │ │ │ │ -523 │ │ │ │ │ -527 typedef typename ParallelIndexSet::const_iterator const_iterator; │ │ │ │ │ -528 │ │ │ │ │ -529 typedef Dune::IndexPair │ │ │ │ │ -IndexPair; │ │ │ │ │ -530 │ │ │ │ │ -537 GlobalLookupIndexSet(const ParallelIndexSet& indexset, std::size_t size); │ │ │ │ │ -538 │ │ │ │ │ -544 GlobalLookupIndexSet(const ParallelIndexSet& indexset); │ │ │ │ │ -545 │ │ │ │ │ -549 ~GlobalLookupIndexSet(); │ │ │ │ │ -550 │ │ │ │ │ -560 inline const IndexPair& │ │ │ │ │ -561 operator[](const GlobalIndex& global) const; │ │ │ │ │ -562 │ │ │ │ │ -566 inline const IndexPair* │ │ │ │ │ -567 pair(const std::size_t& local) const; │ │ │ │ │ -568 │ │ │ │ │ -573 inline const_iterator begin() const; │ │ │ │ │ -574 │ │ │ │ │ -579 inline const_iterator end() const; │ │ │ │ │ -580 │ │ │ │ │ -587 inline int seqNo() const; │ │ │ │ │ -588 │ │ │ │ │ -593 inline size_t size() const; │ │ │ │ │ -594 private: │ │ │ │ │ -598 const ParallelIndexSet& indexSet_; │ │ │ │ │ -599 │ │ │ │ │ -603 std::size_t size_; │ │ │ │ │ -604 │ │ │ │ │ -608 std::vector indices_; │ │ │ │ │ -609 │ │ │ │ │ -610 }; │ │ │ │ │ -611 │ │ │ │ │ -612 │ │ │ │ │ -613 template │ │ │ │ │ -614 struct LocalIndexComparator │ │ │ │ │ -615 { │ │ │ │ │ -616 static bool compare([[maybe_unused]] const T& t1, [[maybe_unused]] const T& │ │ │ │ │ -t2) │ │ │ │ │ -617 { │ │ │ │ │ -618 return false; │ │ │ │ │ -619 } │ │ │ │ │ -620 }; │ │ │ │ │ -621 │ │ │ │ │ -622 template │ │ │ │ │ -623 struct IndexSetSortFunctor │ │ │ │ │ -624 { │ │ │ │ │ -625 bool operator()(const IndexPair& i1, const IndexPair& i2) │ │ │ │ │ -626 { │ │ │ │ │ -627 return i1.global()::compare(i1.local(), │ │ │ │ │ -629 i2.local())); │ │ │ │ │ -630 } │ │ │ │ │ -631 }; │ │ │ │ │ -632 │ │ │ │ │ -633 │ │ │ │ │ -634 │ │ │ │ │ -635 template │ │ │ │ │ -636 inline std::ostream& operator<<(std::ostream& os, const IndexPair& │ │ │ │ │ -pair) │ │ │ │ │ -637 { │ │ │ │ │ -638 os<<"{global="< │ │ │ │ │ -643 inline std::ostream& operator<<(std::ostream& os, const │ │ │ │ │ -ParallelIndexSet& indexSet) │ │ │ │ │ -644 { │ │ │ │ │ -645 typedef typename ParallelIndexSet::const_iterator Iterator; │ │ │ │ │ -646 Iterator end = indexSet.end(); │ │ │ │ │ -647 os<<"{"; │ │ │ │ │ -648 for(Iterator index = indexSet.begin(); index != end; ++index) │ │ │ │ │ -649 os<<*index<<" "; │ │ │ │ │ -650 os<<"}"; │ │ │ │ │ -651 return os; │ │ │ │ │ -652 │ │ │ │ │ -653 } │ │ │ │ │ -654 │ │ │ │ │ -655 template │ │ │ │ │ -656 inline bool operator==(const IndexPair& a, const IndexPair& │ │ │ │ │ -b) │ │ │ │ │ -657 { │ │ │ │ │ -658 return a.global_==b.global_; │ │ │ │ │ -659 } │ │ │ │ │ -660 │ │ │ │ │ -661 template │ │ │ │ │ -662 inline bool operator!=(const IndexPair& a, const IndexPair& │ │ │ │ │ -b) │ │ │ │ │ -663 { │ │ │ │ │ -664 return a.global_!=b.global_; │ │ │ │ │ -665 } │ │ │ │ │ -666 │ │ │ │ │ -667 template │ │ │ │ │ -668 inline bool operator<(const IndexPair& a, const IndexPair& b) │ │ │ │ │ -669 { │ │ │ │ │ -670 return a.global_ │ │ │ │ │ -674 inline bool operator>(const IndexPair& a, const IndexPair& b) │ │ │ │ │ -675 { │ │ │ │ │ -676 return a.global_>b.global_; │ │ │ │ │ -677 } │ │ │ │ │ -678 │ │ │ │ │ -679 template │ │ │ │ │ -680 inline bool operator<=(const IndexPair& a, const IndexPair& │ │ │ │ │ -b) │ │ │ │ │ -681 { │ │ │ │ │ -682 return a.global_<=b.global_; │ │ │ │ │ -683 } │ │ │ │ │ -684 │ │ │ │ │ -685 template │ │ │ │ │ -686 inline bool operator_>=(const IndexPair& a, const IndexPair& │ │ │ │ │ -b) │ │ │ │ │ -687 { │ │ │ │ │ -688 return a.global_>=b.global_; │ │ │ │ │ -689 } │ │ │ │ │ -690 │ │ │ │ │ -691 template │ │ │ │ │ -692 inline bool operator==(const IndexPair& a, const TG& b) │ │ │ │ │ -693 { │ │ │ │ │ -694 return a.global_==b; │ │ │ │ │ -695 } │ │ │ │ │ -696 │ │ │ │ │ -697 template │ │ │ │ │ -698 inline bool operator!=(const IndexPair& a, const TG& b) │ │ │ │ │ -699 { │ │ │ │ │ -700 return a.global_!=b; │ │ │ │ │ -701 } │ │ │ │ │ -702 │ │ │ │ │ -703 template │ │ │ │ │ -704 inline bool operator<(const IndexPair& a, const TG& b) │ │ │ │ │ -705 { │ │ │ │ │ -706 return a.global_ │ │ │ │ │ -710 inline bool operator>(const IndexPair& a, const TG& b) │ │ │ │ │ -711 { │ │ │ │ │ -712 return a.global_>b; │ │ │ │ │ -713 } │ │ │ │ │ -714 │ │ │ │ │ -715 template │ │ │ │ │ -716 inline bool operator<=(const IndexPair& a, const TG& b) │ │ │ │ │ -717 { │ │ │ │ │ -718 return a.global_<=b; │ │ │ │ │ -719 } │ │ │ │ │ -720 │ │ │ │ │ -721 template │ │ │ │ │ -722 inline bool operator_>=(const IndexPair& a, const TG& b) │ │ │ │ │ -723 { │ │ │ │ │ -724 return a.global_>=b; │ │ │ │ │ -725 } │ │ │ │ │ -726 │ │ │ │ │ -727#ifndef DOXYGEN │ │ │ │ │ -728 │ │ │ │ │ -729 template │ │ │ │ │ -730 IndexPair::IndexPair(const TG& global, const TL& local) │ │ │ │ │ -731 : global_(global), local_(local){} │ │ │ │ │ -732 │ │ │ │ │ -733 template │ │ │ │ │ -734 IndexPair::IndexPair(const TG& global) │ │ │ │ │ -735 : global_(global), local_(){} │ │ │ │ │ -736 │ │ │ │ │ -737 template │ │ │ │ │ -738 IndexPair::IndexPair() │ │ │ │ │ -739 : global_(), local_(){} │ │ │ │ │ -740 │ │ │ │ │ -741 template │ │ │ │ │ -742 inline const TG& IndexPair::global() const { │ │ │ │ │ -743 return global_; │ │ │ │ │ -744 } │ │ │ │ │ -745 │ │ │ │ │ -746 template │ │ │ │ │ -747 inline TL& IndexPair::local() { │ │ │ │ │ -748 return local_; │ │ │ │ │ -749 } │ │ │ │ │ -750 │ │ │ │ │ -751 template │ │ │ │ │ -752 inline const TL& IndexPair::local() const { │ │ │ │ │ -753 return local_; │ │ │ │ │ -754 } │ │ │ │ │ -755 │ │ │ │ │ -756 template │ │ │ │ │ -757 inline void IndexPair::setLocal(int local){ │ │ │ │ │ -758 local_=local; │ │ │ │ │ -759 } │ │ │ │ │ -760 │ │ │ │ │ -761 template │ │ │ │ │ -762 ParallelIndexSet::ParallelIndexSet() │ │ │ │ │ -763 : state_(GROUND), seqNo_(0), deletedEntries_() │ │ │ │ │ -764 {} │ │ │ │ │ -765 │ │ │ │ │ -766 template │ │ │ │ │ -767 void ParallelIndexSet::beginResize() │ │ │ │ │ -768 { │ │ │ │ │ -769 │ │ │ │ │ -770 // Checks in unproductive code │ │ │ │ │ -771#ifndef NDEBUG │ │ │ │ │ -772 if(state_!=GROUND) │ │ │ │ │ -773 DUNE_THROW(InvalidIndexSetState, │ │ │ │ │ -774 "IndexSet has to be in GROUND state, when " │ │ │ │ │ -775 << "beginResize() is called!"); │ │ │ │ │ -776#endif │ │ │ │ │ -777 │ │ │ │ │ -778 state_ = RESIZE; │ │ │ │ │ -779 deletedEntries_ = false; │ │ │ │ │ -780 } │ │ │ │ │ -781 │ │ │ │ │ -782 template │ │ │ │ │ -783 inline void ParallelIndexSet::add(const GlobalIndex& global) │ │ │ │ │ -784 { │ │ │ │ │ -785 // Checks in unproductive code │ │ │ │ │ -786#ifndef NDEBUG │ │ │ │ │ -787 if(state_ != RESIZE) │ │ │ │ │ -788 DUNE_THROW(InvalidIndexSetState, "Indices can only be added " │ │ │ │ │ -789 <<"while in RESIZE state!"); │ │ │ │ │ -790#endif │ │ │ │ │ -791 newIndices_.push_back(IndexPair(global)); │ │ │ │ │ -792 } │ │ │ │ │ -793 │ │ │ │ │ -794 template │ │ │ │ │ -795 inline void ParallelIndexSet::add(const TG& global, const TL& │ │ │ │ │ -local) │ │ │ │ │ -796 { │ │ │ │ │ -797 // Checks in unproductive code │ │ │ │ │ -798#ifndef NDEBUG │ │ │ │ │ -799 if(state_ != RESIZE) │ │ │ │ │ -800 DUNE_THROW(InvalidIndexSetState, "Indices can only be added " │ │ │ │ │ -801 <<"while in RESIZE state!"); │ │ │ │ │ -802#endif │ │ │ │ │ -803 newIndices_.push_back(IndexPair(global,local)); │ │ │ │ │ -804 } │ │ │ │ │ -805 │ │ │ │ │ -806 template │ │ │ │ │ -807 inline void ParallelIndexSet::markAsDeleted(const iterator& │ │ │ │ │ -global) │ │ │ │ │ -808 { │ │ │ │ │ -809 // Checks in unproductive code │ │ │ │ │ -810#ifndef NDEBUG │ │ │ │ │ -811 if(state_ != RESIZE) │ │ │ │ │ -812 DUNE_THROW(InvalidIndexSetState, "Indices can only be removed " │ │ │ │ │ -813 <<"while in RESIZE state!"); │ │ │ │ │ -814#endif │ │ │ │ │ -815 deletedEntries_ = true; │ │ │ │ │ -816 │ │ │ │ │ -817 global.markAsDeleted(); │ │ │ │ │ -818 } │ │ │ │ │ -819 │ │ │ │ │ -820 template │ │ │ │ │ -821 void ParallelIndexSet::endResize() { │ │ │ │ │ -822 // Checks in unproductive code │ │ │ │ │ -823#ifndef NDEBUG │ │ │ │ │ -824 if(state_ != RESIZE) │ │ │ │ │ -825 DUNE_THROW(InvalidIndexSetState, "endResize called while not " │ │ │ │ │ -826 <<"in RESIZE state!"); │ │ │ │ │ -827#endif │ │ │ │ │ -828 │ │ │ │ │ -829 std::sort(newIndices_.begin(), newIndices_.end(), │ │ │ │ │ -IndexSetSortFunctor()); │ │ │ │ │ -830 merge(); │ │ │ │ │ -831 seqNo_++; │ │ │ │ │ -832 state_ = GROUND; │ │ │ │ │ -833 } │ │ │ │ │ -834 │ │ │ │ │ -835 │ │ │ │ │ -836 template │ │ │ │ │ -837 inline void ParallelIndexSet::merge(){ │ │ │ │ │ -838 if(localIndices_.size()==0) │ │ │ │ │ -839 { │ │ │ │ │ -840 localIndices_=newIndices_; │ │ │ │ │ -841 newIndices_.clear(); │ │ │ │ │ -842 } │ │ │ │ │ -843 else if(newIndices_.size()>0 || deletedEntries_) │ │ │ │ │ -844 { │ │ │ │ │ -845 ArrayList tempPairs; │ │ │ │ │ -846 │ │ │ │ │ -847 auto old = localIndices_.begin(); │ │ │ │ │ -848 auto added = newIndices_.begin(); │ │ │ │ │ -849 const auto endold = localIndices_.end(); │ │ │ │ │ -850 const auto endadded = newIndices_.end(); │ │ │ │ │ -851 │ │ │ │ │ -852 while(old != endold && added!= endadded) │ │ │ │ │ -853 { │ │ │ │ │ -854 if(old->local().state()==DELETED) { │ │ │ │ │ -855 old.eraseToHere(); │ │ │ │ │ -856 } │ │ │ │ │ -857 else │ │ │ │ │ -858 { │ │ │ │ │ -859 if(old->global() < added->global() || │ │ │ │ │ -860 (old->global() == added->global() │ │ │ │ │ -861 && LocalIndexComparator::compare(old->local(),added->local()))) │ │ │ │ │ -862 { │ │ │ │ │ -863 tempPairs.push_back(*old); │ │ │ │ │ -864 old.eraseToHere(); │ │ │ │ │ -865 continue; │ │ │ │ │ -866 }else │ │ │ │ │ -867 { │ │ │ │ │ -868 tempPairs.push_back(*added); │ │ │ │ │ -869 added.eraseToHere(); │ │ │ │ │ -870 } │ │ │ │ │ -871 } │ │ │ │ │ -872 } │ │ │ │ │ -873 │ │ │ │ │ -874 while(old != endold) │ │ │ │ │ -875 { │ │ │ │ │ -876 if(old->local().state()!=DELETED) { │ │ │ │ │ -877 tempPairs.push_back(*old); │ │ │ │ │ -878 } │ │ │ │ │ -879 old.eraseToHere(); │ │ │ │ │ -880 } │ │ │ │ │ -881 │ │ │ │ │ -882 while(added!= endadded) │ │ │ │ │ -883 { │ │ │ │ │ -884 tempPairs.push_back(*added); │ │ │ │ │ -885 added.eraseToHere(); │ │ │ │ │ -886 } │ │ │ │ │ -887 localIndices_ = tempPairs; │ │ │ │ │ -888 } │ │ │ │ │ -889 } │ │ │ │ │ -890 │ │ │ │ │ -891 │ │ │ │ │ -892 template │ │ │ │ │ -893 inline const IndexPair& │ │ │ │ │ -894 ParallelIndexSet::at(const TG& global) const │ │ │ │ │ -895 { │ │ │ │ │ -896 // perform a binary search │ │ │ │ │ -897 int low=0, high=localIndices_.size()-1, probe=-1; │ │ │ │ │ -898 │ │ │ │ │ -899 while(low │ │ │ │ │ -918 inline const IndexPair& │ │ │ │ │ -919 ParallelIndexSet::operator[](const TG& global) const │ │ │ │ │ -920 { │ │ │ │ │ -921 // perform a binary search │ │ │ │ │ -922 int low=0, high=localIndices_.size()-1, probe=-1; │ │ │ │ │ -923 │ │ │ │ │ -924 while(low │ │ │ │ │ -936 inline IndexPair& ParallelIndexSet::at(const TG& global) │ │ │ │ │ -937 { │ │ │ │ │ -938 // perform a binary search │ │ │ │ │ -939 int low=0, high=localIndices_.size()-1, probe=-1; │ │ │ │ │ -940 │ │ │ │ │ -941 while(low= global) │ │ │ │ │ -945 high = probe; │ │ │ │ │ -946 else │ │ │ │ │ -947 low = probe+1; │ │ │ │ │ -948 } │ │ │ │ │ -949 │ │ │ │ │ -950 if(probe==-1) │ │ │ │ │ -951 DUNE_THROW(RangeError, "No entries!"); │ │ │ │ │ -952 │ │ │ │ │ -953 if( localIndices_[low].global() != global) │ │ │ │ │ -954 DUNE_THROW(RangeError, "Could not find entry of "< │ │ │ │ │ -960 inline bool ParallelIndexSet::exists (const TG& global) const │ │ │ │ │ -961 { │ │ │ │ │ -962 // perform a binary search │ │ │ │ │ -963 int low=0, high=localIndices_.size()-1, probe=-1; │ │ │ │ │ -964 │ │ │ │ │ -965 while(low= global) │ │ │ │ │ -969 high = probe; │ │ │ │ │ -970 else │ │ │ │ │ -971 low = probe+1; │ │ │ │ │ -972 } │ │ │ │ │ -973 │ │ │ │ │ -974 if(probe==-1) │ │ │ │ │ -975 return false; │ │ │ │ │ -976 │ │ │ │ │ -977 if( localIndices_[low].global() != global) │ │ │ │ │ -978 return false; │ │ │ │ │ -979 return true; │ │ │ │ │ -980 } │ │ │ │ │ -981 │ │ │ │ │ -982 template │ │ │ │ │ -983 inline IndexPair& ParallelIndexSet::operator[](const TG& │ │ │ │ │ -global) │ │ │ │ │ -984 { │ │ │ │ │ -985 // perform a binary search │ │ │ │ │ -986 int low=0, high=localIndices_.size()-1, probe=-1; │ │ │ │ │ -987 │ │ │ │ │ -988 while(low= global) │ │ │ │ │ -992 high = probe; │ │ │ │ │ -993 else │ │ │ │ │ -994 low = probe+1; │ │ │ │ │ -995 } │ │ │ │ │ -996 │ │ │ │ │ -997 return localIndices_[low]; │ │ │ │ │ -998 } │ │ │ │ │ -999 template │ │ │ │ │ -1000 inline typename ParallelIndexSet::iterator │ │ │ │ │ -1001 ParallelIndexSet::begin() │ │ │ │ │ -1002 { │ │ │ │ │ -1003 return iterator(*this, localIndices_.begin()); │ │ │ │ │ -1004 } │ │ │ │ │ -1005 │ │ │ │ │ -1006 │ │ │ │ │ -1007 template │ │ │ │ │ -1008 inline typename ParallelIndexSet::iterator │ │ │ │ │ -1009 ParallelIndexSet::end() │ │ │ │ │ -1010 { │ │ │ │ │ -1011 return iterator(*this,localIndices_.end()); │ │ │ │ │ -1012 } │ │ │ │ │ -1013 │ │ │ │ │ -1014 template │ │ │ │ │ -1015 inline typename ParallelIndexSet::const_iterator │ │ │ │ │ -1016 ParallelIndexSet::begin() const │ │ │ │ │ -1017 { │ │ │ │ │ -1018 return localIndices_.begin(); │ │ │ │ │ -1019 } │ │ │ │ │ -1020 │ │ │ │ │ -1021 │ │ │ │ │ -1022 template │ │ │ │ │ -1023 inline typename ParallelIndexSet::const_iterator │ │ │ │ │ -1024 ParallelIndexSet::end() const │ │ │ │ │ -1025 { │ │ │ │ │ -1026 return localIndices_.end(); │ │ │ │ │ -1027 } │ │ │ │ │ -1028 │ │ │ │ │ -1029 template │ │ │ │ │ -1030 void ParallelIndexSet::renumberLocal(){ │ │ │ │ │ -1031#ifndef NDEBUG │ │ │ │ │ -1032 if(state_==RESIZE) │ │ │ │ │ -1033 DUNE_THROW(InvalidIndexSetState, "IndexSet has to be in " │ │ │ │ │ -1034 <<"GROUND state for renumberLocal()"); │ │ │ │ │ -1035#endif │ │ │ │ │ -1036 │ │ │ │ │ -1037 const auto end_ = end(); │ │ │ │ │ -1038 uint32_t index=0; │ │ │ │ │ -1039 │ │ │ │ │ -1040 for(auto pair=begin(); pair!=end_; index++, ++pair) │ │ │ │ │ -1041 pair->local()=index; │ │ │ │ │ -1042 } │ │ │ │ │ -1043 │ │ │ │ │ -1044 template │ │ │ │ │ -1045 inline int ParallelIndexSet::seqNo() const │ │ │ │ │ -1046 { │ │ │ │ │ -1047 return seqNo_; │ │ │ │ │ -1048 } │ │ │ │ │ -1049 │ │ │ │ │ -1050 template │ │ │ │ │ -1051 inline size_t ParallelIndexSet::size() const │ │ │ │ │ -1052 { │ │ │ │ │ -1053 return localIndices_.size(); │ │ │ │ │ -1054 } │ │ │ │ │ -1055 │ │ │ │ │ -1056 template │ │ │ │ │ -1057 GlobalLookupIndexSet::GlobalLookupIndexSet(const I& indexset, │ │ │ │ │ -1058 std::size_t size) │ │ │ │ │ -1059 : indexSet_(indexset), size_(size), │ │ │ │ │ -1060 indices_(size_, static_cast(0)) │ │ │ │ │ -1061 { │ │ │ │ │ -1062 const_iterator end_ = indexSet_.end(); │ │ │ │ │ -1063 │ │ │ │ │ -1064 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair) { │ │ │ │ │ -1065 assert(pair->local()local()] = &(*pair); │ │ │ │ │ -1067 } │ │ │ │ │ -1068 } │ │ │ │ │ -1069 │ │ │ │ │ -1070 template │ │ │ │ │ -1071 GlobalLookupIndexSet::GlobalLookupIndexSet(const I& indexset) │ │ │ │ │ -1072 : indexSet_(indexset), size_(0) │ │ │ │ │ -1073 { │ │ │ │ │ -1074 const_iterator end_ = indexSet_.end(); │ │ │ │ │ -1075 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair) │ │ │ │ │ -1076 size_=std::max(size_,static_cast(pair->local())); │ │ │ │ │ -1077 │ │ │ │ │ -1078 indices_.resize(++size_, 0); │ │ │ │ │ -1079 │ │ │ │ │ -1080 for(const_iterator pair = indexSet_.begin(); pair!=end_; ++pair) │ │ │ │ │ -1081 indices_[pair->local()] = &(*pair); │ │ │ │ │ -1082 } │ │ │ │ │ -1083 │ │ │ │ │ -1084 template │ │ │ │ │ -1085 GlobalLookupIndexSet::~GlobalLookupIndexSet() │ │ │ │ │ -1086 {} │ │ │ │ │ -1087 │ │ │ │ │ -1088 template │ │ │ │ │ -1089 inline const IndexPair* │ │ │ │ │ -1090 GlobalLookupIndexSet::pair(const std::size_t& local) const │ │ │ │ │ -1091 { │ │ │ │ │ -1092 return indices_[local]; │ │ │ │ │ -1093 } │ │ │ │ │ -1094 │ │ │ │ │ -1095 template │ │ │ │ │ -1096 inline const IndexPair& │ │ │ │ │ -1097 GlobalLookupIndexSet::operator[](const GlobalIndex& global) const │ │ │ │ │ -1098 { │ │ │ │ │ -1099 return indexSet_[global]; │ │ │ │ │ -1100 } │ │ │ │ │ -1101 │ │ │ │ │ -1102 template │ │ │ │ │ -1103 typename I::const_iterator GlobalLookupIndexSet::begin() const │ │ │ │ │ -1104 { │ │ │ │ │ -1105 return indexSet_.begin(); │ │ │ │ │ -1106 } │ │ │ │ │ -1107 │ │ │ │ │ -1108 template │ │ │ │ │ -1109 typename I::const_iterator GlobalLookupIndexSet::end() const │ │ │ │ │ -1110 { │ │ │ │ │ -1111 return indexSet_.end(); │ │ │ │ │ -1112 } │ │ │ │ │ -1113 │ │ │ │ │ -1114 template │ │ │ │ │ -1115 inline size_t GlobalLookupIndexSet::size() const │ │ │ │ │ -1116 { │ │ │ │ │ -1117 return size_; │ │ │ │ │ -1118 } │ │ │ │ │ -1119 │ │ │ │ │ -1120 template │ │ │ │ │ -1121 inline int GlobalLookupIndexSet::seqNo() const │ │ │ │ │ -1122 { │ │ │ │ │ -1123 return indexSet_.seqNo(); │ │ │ │ │ -1124 } │ │ │ │ │ -1125 │ │ │ │ │ -1126 template │ │ │ │ │ -1127 bool operator==(const ParallelIndexSet& idxset, │ │ │ │ │ -1128 const ParallelIndexSet& idxset1) │ │ │ │ │ -1129 { │ │ │ │ │ -1130 if(idxset.size()!=idxset1.size()) │ │ │ │ │ -1131 return false; │ │ │ │ │ -1132 typedef typename ParallelIndexSet::const_iterator Iter; │ │ │ │ │ -1133 typedef typename ParallelIndexSet::const_iterator Iter1; │ │ │ │ │ -1134 Iter iter=idxset.begin(); │ │ │ │ │ -1135 for(Iter1 iter1=idxset1.begin(); iter1 != idxset1.end(); ++iter, ++iter1) │ │ │ │ │ -{ │ │ │ │ │ -1136 if(iter1->global()!=iter->global()) │ │ │ │ │ -1137 return false; │ │ │ │ │ -1138 typedef typename ParallelIndexSet::LocalIndex PI; │ │ │ │ │ -1139 const PI& pi=iter->local(), pi1=iter1->local(); │ │ │ │ │ -1140 │ │ │ │ │ -1141 if(pi!=pi1) │ │ │ │ │ -1142 return false; │ │ │ │ │ -1143 } │ │ │ │ │ -1144 return true; │ │ │ │ │ -1145 } │ │ │ │ │ -1146 │ │ │ │ │ -1147 template │ │ │ │ │ -1148 bool operator!=(const ParallelIndexSet& idxset, │ │ │ │ │ -1149 const ParallelIndexSet& idxset1) │ │ │ │ │ -1150 { │ │ │ │ │ -1151 return !(idxset==idxset1); │ │ │ │ │ -1152 } │ │ │ │ │ -1153 │ │ │ │ │ -1154 │ │ │ │ │ -1155#endif // DOXYGEN │ │ │ │ │ -1156 │ │ │ │ │ -1157} │ │ │ │ │ -1158 │ │ │ │ │ -1159#endif // DUNE_COMMON_PARALLEL_INDEXSET_HH │ │ │ │ │ -localindex.hh │ │ │ │ │ -Provides classes for use as the local index in ParallelIndexSet. │ │ │ │ │ -mpitraits.hh │ │ │ │ │ -Traits classes for mapping types onto MPI_Datatype. │ │ │ │ │ -arraylist.hh │ │ │ │ │ -Implements a random-access container that can efficiently change size (similar │ │ │ │ │ -to std::deque) │ │ │ │ │ -exceptions.hh │ │ │ │ │ -A few common exception classes. │ │ │ │ │ -Dune::operator<< │ │ │ │ │ -std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:278 │ │ │ │ │ -DUNE_THROW │ │ │ │ │ -#define DUNE_THROW(E, m) │ │ │ │ │ -Definition exceptions.hh:218 │ │ │ │ │ -Dune::operator< │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator<(const │ │ │ │ │ -RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const │ │ │ │ │ -RandomAccessIteratorFacade< T2, V2, R2, D > &rhs) │ │ │ │ │ -Comparison operator. │ │ │ │ │ -Definition iteratorfacades.hh:638 │ │ │ │ │ -Dune::operator> │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator>(const │ │ │ │ │ -RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const │ │ │ │ │ -RandomAccessIteratorFacade< T2, V2, R2, D > &rhs) │ │ │ │ │ -Comparison operator. │ │ │ │ │ -Definition iteratorfacades.hh:684 │ │ │ │ │ -Dune::operator<= │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator<=(const │ │ │ │ │ -RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const │ │ │ │ │ -RandomAccessIteratorFacade< T2, V2, R2, D > &rhs) │ │ │ │ │ -Comparison operator. │ │ │ │ │ -Definition iteratorfacades.hh:661 │ │ │ │ │ -Dune::operator== │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator==(const │ │ │ │ │ -ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, │ │ │ │ │ -V2, R2, D > &rhs) │ │ │ │ │ -Checks for equality. │ │ │ │ │ -Definition iteratorfacades.hh:238 │ │ │ │ │ -Dune::operator>= │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator>=(const │ │ │ │ │ -RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const │ │ │ │ │ -RandomAccessIteratorFacade< T2, V2, R2, D > &rhs) │ │ │ │ │ -Comparison operator. │ │ │ │ │ -Definition iteratorfacades.hh:706 │ │ │ │ │ -Dune::operator!= │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator!=(const │ │ │ │ │ -ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, │ │ │ │ │ -V2, R2, D > &rhs) │ │ │ │ │ -Checks for inequality. │ │ │ │ │ -Definition iteratorfacades.hh:260 │ │ │ │ │ -Dune::ParallelIndexSet::operator[] │ │ │ │ │ -IndexPair & operator[](const GlobalIndex &global) │ │ │ │ │ -Find the index pair with a specific global id. │ │ │ │ │ -Dune::ParallelIndexSet::arraySize │ │ │ │ │ -static constexpr int arraySize │ │ │ │ │ -The size of the individual arrays in the underlying ArrayList. │ │ │ │ │ -Definition indexset.hh:252 │ │ │ │ │ -Dune::ParallelIndexSet::beginResize │ │ │ │ │ -void beginResize() │ │ │ │ │ -Indicate that the index set is to be resized. │ │ │ │ │ -Dune::ParallelIndexSetState │ │ │ │ │ -ParallelIndexSetState │ │ │ │ │ -The states the index set can be in. │ │ │ │ │ -Definition indexset.hh:181 │ │ │ │ │ -Dune::ParallelIndexSet::renumberLocal │ │ │ │ │ -void renumberLocal() │ │ │ │ │ -Renumbers the local index numbers. │ │ │ │ │ -Dune::ParallelIndexSet::exists │ │ │ │ │ -bool exists(const GlobalIndex &global) const │ │ │ │ │ -Find the index pair with a specific global id. │ │ │ │ │ -Dune::ParallelIndexSet::size │ │ │ │ │ -size_t size() const │ │ │ │ │ -Get the total number (public and nonpublic) indices. │ │ │ │ │ -Dune::ParallelIndexSet::const_iterator │ │ │ │ │ -ArrayList< IndexPair, N >::const_iterator const_iterator │ │ │ │ │ -The constant iterator over the pairs. │ │ │ │ │ -Definition indexset.hh:296 │ │ │ │ │ -Dune::IndexSetSortFunctor::operator() │ │ │ │ │ -bool operator()(const IndexPair< TG, TL > &i1, const IndexPair< TG, TL > &i2) │ │ │ │ │ -Definition indexset.hh:625 │ │ │ │ │ -Dune::ParallelIndexSet::add │ │ │ │ │ -void add(const GlobalIndex &global) │ │ │ │ │ -Add an new index to the set. │ │ │ │ │ -Dune::GlobalLookupIndexSet::end │ │ │ │ │ -const_iterator end() const │ │ │ │ │ -Get an iterator over the indices positioned after the last index. │ │ │ │ │ -Dune::IndexPair::local │ │ │ │ │ -const LocalIndex & local() const │ │ │ │ │ -Get the local index. │ │ │ │ │ -Dune::ParallelIndexSet::at │ │ │ │ │ -const IndexPair & at(const GlobalIndex &global) const │ │ │ │ │ -Find the index pair with a specific global id. │ │ │ │ │ -Dune::GlobalLookupIndexSet::GlobalLookupIndexSet │ │ │ │ │ -GlobalLookupIndexSet(const ParallelIndexSet &indexset) │ │ │ │ │ -Constructor. │ │ │ │ │ -Dune::IndexPair::LocalIndex │ │ │ │ │ -TL LocalIndex │ │ │ │ │ -the type of the local index. │ │ │ │ │ -Definition indexset.hh:120 │ │ │ │ │ -Dune::GlobalLookupIndexSet::seqNo │ │ │ │ │ -int seqNo() const │ │ │ │ │ -Get the internal sequence number. │ │ │ │ │ -Dune::LocalIndexComparator::compare │ │ │ │ │ -static bool compare(const T &t1, const T &t2) │ │ │ │ │ -Definition indexset.hh:616 │ │ │ │ │ -Dune::ParallelIndexSet::begin │ │ │ │ │ -iterator begin() │ │ │ │ │ -Get an iterator over the indices positioned at the first index. │ │ │ │ │ -Dune::GlobalLookupIndexSet::IndexPair │ │ │ │ │ -Dune::IndexPair< typename I::GlobalIndex, typename I::LocalIndex > IndexPair │ │ │ │ │ -Definition indexset.hh:529 │ │ │ │ │ -Dune::ParallelIndexSet::end │ │ │ │ │ -iterator end() │ │ │ │ │ -Get an iterator over the indices positioned after the last index. │ │ │ │ │ -Dune::GlobalLookupIndexSet::const_iterator │ │ │ │ │ -ParallelIndexSet::const_iterator const_iterator │ │ │ │ │ -The iterator over the index pairs. │ │ │ │ │ -Definition indexset.hh:527 │ │ │ │ │ -Dune::GlobalLookupIndexSet::begin │ │ │ │ │ -const_iterator begin() const │ │ │ │ │ -Get an iterator over the indices positioned at the first index. │ │ │ │ │ -Dune::ParallelIndexSet::operator[] │ │ │ │ │ -const IndexPair & operator[](const GlobalIndex &global) const │ │ │ │ │ -Find the index pair with a specific global id. │ │ │ │ │ -Dune::ParallelIndexSet::state │ │ │ │ │ -const ParallelIndexSetState & state() │ │ │ │ │ -Get the state the index set is in. │ │ │ │ │ -Definition indexset.hh:307 │ │ │ │ │ -Dune::ParallelIndexSet::begin │ │ │ │ │ -const_iterator begin() const │ │ │ │ │ -Get an iterator over the indices positioned at the first index. │ │ │ │ │ -Dune::GlobalLookupIndexSet::operator[] │ │ │ │ │ -const IndexPair & operator[](const GlobalIndex &global) const │ │ │ │ │ -Find the index pair with a specific global id. │ │ │ │ │ -Dune::IndexPair::IndexPair │ │ │ │ │ -IndexPair() │ │ │ │ │ -Construct a new Pair. │ │ │ │ │ -Dune::GlobalLookupIndexSet::ParallelIndexSet │ │ │ │ │ -I ParallelIndexSet │ │ │ │ │ -The type of the index set. │ │ │ │ │ -Definition indexset.hh:512 │ │ │ │ │ -Dune::ParallelIndexSet::LocalIndex │ │ │ │ │ -TL LocalIndex │ │ │ │ │ -The type of the local index, e.g. ParallelLocalIndex. │ │ │ │ │ -Definition indexset.hh:239 │ │ │ │ │ -Dune::ParallelIndexSet::markAsDeleted │ │ │ │ │ -void markAsDeleted(const iterator &position) │ │ │ │ │ -Mark an index as deleted. │ │ │ │ │ -Dune::GlobalLookupIndexSet::LocalIndex │ │ │ │ │ -ParallelIndexSet::LocalIndex LocalIndex │ │ │ │ │ -The type of the local index. │ │ │ │ │ -Definition indexset.hh:517 │ │ │ │ │ -Dune::IndexPair::IndexPair │ │ │ │ │ -IndexPair(const GlobalIndex &global, const LocalIndex &local) │ │ │ │ │ -Constructs a new Pair. │ │ │ │ │ -Dune::IndexPair::setLocal │ │ │ │ │ -void setLocal(int index) │ │ │ │ │ -Set the local index. │ │ │ │ │ -Dune::IndexPair::global │ │ │ │ │ -const GlobalIndex & global() const │ │ │ │ │ -Get the global index. │ │ │ │ │ -Dune::ParallelIndexSet::add │ │ │ │ │ -void add(const GlobalIndex &global, const LocalIndex &local) │ │ │ │ │ -Add an new index to the set. │ │ │ │ │ -Dune::ParallelIndexSet::end │ │ │ │ │ -const_iterator end() const │ │ │ │ │ -Get an iterator over the indices positioned after the last index. │ │ │ │ │ -Dune::ParallelIndexSet::at │ │ │ │ │ -IndexPair & at(const GlobalIndex &global) │ │ │ │ │ -Find the index pair with a specific global id. │ │ │ │ │ -Dune::ParallelIndexSet::ParallelIndexSet │ │ │ │ │ -ParallelIndexSet() │ │ │ │ │ -Constructor. │ │ │ │ │ -Dune::ParallelIndexSet::endResize │ │ │ │ │ -void endResize() │ │ │ │ │ -Indicate that the resizing finishes. │ │ │ │ │ -Dune::GlobalLookupIndexSet::~GlobalLookupIndexSet │ │ │ │ │ -~GlobalLookupIndexSet() │ │ │ │ │ -Destructor. │ │ │ │ │ -Dune::GlobalLookupIndexSet::pair │ │ │ │ │ -const IndexPair * pair(const std::size_t &local) const │ │ │ │ │ -Get the index pair corresponding to a local index. │ │ │ │ │ -Dune::IndexPair::local │ │ │ │ │ -LocalIndex & local() │ │ │ │ │ -Get the local index. │ │ │ │ │ -Dune::GlobalLookupIndexSet::size │ │ │ │ │ -size_t size() const │ │ │ │ │ -Get the total number (public and nonpublic) indices. │ │ │ │ │ -Dune::IndexPair::IndexPair │ │ │ │ │ -IndexPair(const GlobalIndex &global) │ │ │ │ │ -Constructs a new Pair. │ │ │ │ │ -Dune::ParallelIndexSet::GlobalIndex │ │ │ │ │ -TG GlobalIndex │ │ │ │ │ -the type of the global index. This type has to provide at least a operator< for │ │ │ │ │ -sorting. │ │ │ │ │ -Definition indexset.hh:226 │ │ │ │ │ -Dune::IndexPair::GlobalIndex │ │ │ │ │ -TG GlobalIndex │ │ │ │ │ -the type of the global index. │ │ │ │ │ -Definition indexset.hh:107 │ │ │ │ │ -Dune::ParallelIndexSet::seqNo │ │ │ │ │ -int seqNo() const │ │ │ │ │ -Get the internal sequence number. │ │ │ │ │ -Dune::ParallelIndexSet::iterator::iterator │ │ │ │ │ -iterator(ParallelIndexSet< TG, TL, N > &indexSet, const Father &father) │ │ │ │ │ -Definition indexset.hh:262 │ │ │ │ │ -Dune::GlobalLookupIndexSet::GlobalLookupIndexSet │ │ │ │ │ -GlobalLookupIndexSet(const ParallelIndexSet &indexset, std::size_t size) │ │ │ │ │ -Constructor. │ │ │ │ │ -Dune::GlobalLookupIndexSet::GlobalIndex │ │ │ │ │ -ParallelIndexSet::GlobalIndex GlobalIndex │ │ │ │ │ -The type of the global index. │ │ │ │ │ -Definition indexset.hh:522 │ │ │ │ │ -Dune::ParallelIndexSet::IndexPair │ │ │ │ │ -Dune::IndexPair< GlobalIndex, LocalIndex > IndexPair │ │ │ │ │ -The type of the pair stored. │ │ │ │ │ -Definition indexset.hh:244 │ │ │ │ │ -Dune::RESIZE │ │ │ │ │ -@ RESIZE │ │ │ │ │ -Indicates that the index set is currently being resized. │ │ │ │ │ -Definition indexset.hh:190 │ │ │ │ │ -Dune::GROUND │ │ │ │ │ -@ GROUND │ │ │ │ │ -The default mode. Indicates that the index set is ready to be used. │ │ │ │ │ -Definition indexset.hh:186 │ │ │ │ │ -Dune::DELETED │ │ │ │ │ -@ DELETED │ │ │ │ │ -Definition localindex.hh:28 │ │ │ │ │ +81 template = 0, │ │ │ │ │ +83 std::enable_if_t<(sizeof...(Args) > 1), int> = 0, │ │ │ │ │ +84 std::enable_if_t, int> = 0> │ │ │ │ │ +85 constexpr CopyableOptional (Args&&... args) │ │ │ │ │ +86 noexcept(std::is_nothrow_constructible_v) │ │ │ │ │ +87 : Base{std::in_place, std::forward(args)...} │ │ │ │ │ +88 {} │ │ │ │ │ +89 │ │ │ │ │ +91 constexpr CopyableOptional (const CopyableOptional&) = default; │ │ │ │ │ +92 │ │ │ │ │ +94 constexpr CopyableOptional (CopyableOptional&&) = default; │ │ │ │ │ +95 │ │ │ │ │ +97 ~CopyableOptional () = default; │ │ │ │ │ +98 │ │ │ │ │ +100 constexpr CopyableOptional& operator=_(const CopyableOptional& that) │ │ │ │ │ +101 noexcept(std::is_nothrow_copy_assignable_v || │ │ │ │ │ +102 (!std::is_copy_assignable_v && std::is_nothrow_copy_constructible_ │ │ │ │ │ +v)) │ │ │ │ │ +103 { │ │ │ │ │ +104 if constexpr(std::is_copy_assignable_v) │ │ │ │ │ +105 Base::operator=(that); │ │ │ │ │ +106 else { │ │ │ │ │ +107 // no self-assignment │ │ │ │ │ +108 if (this != std::addressof(that)) { │ │ │ │ │ +109 if (that) │ │ │ │ │ +110 Base::emplace(*that); │ │ │ │ │ +111 else │ │ │ │ │ +112 Base::reset(); │ │ │ │ │ +113 } │ │ │ │ │ +114 } │ │ │ │ │ +115 return *this; │ │ │ │ │ +116 } │ │ │ │ │ +117 │ │ │ │ │ +119 template , int> = 0> │ │ │ │ │ +121 constexpr CopyableOptional& operator=_(CopyableOptional&& that) │ │ │ │ │ +122 noexcept(std::is_nothrow_move_assignable_v || │ │ │ │ │ +123 (!std::is_move_assignable_v && std::is_nothrow_move_constructible_ │ │ │ │ │ +v)) │ │ │ │ │ +124 { │ │ │ │ │ +125 if constexpr(std::is_move_assignable_v) │ │ │ │ │ +126 Base::operator=(std::move(that)); │ │ │ │ │ +127 else { │ │ │ │ │ +128 // no self-assignment │ │ │ │ │ +129 if (this != std::addressof(that)) { │ │ │ │ │ +130 if (that) │ │ │ │ │ +131 Base::emplace(std::move(*that)); │ │ │ │ │ +132 else │ │ │ │ │ +133 Base::reset(); │ │ │ │ │ +134 } │ │ │ │ │ +135 } │ │ │ │ │ +136 return *this; │ │ │ │ │ +137 } │ │ │ │ │ +138 │ │ │ │ │ +140 template , CopyableOptional>, │ │ │ │ │ +int> = 0, │ │ │ │ │ +142 std::enable_if_t<(std::is_assignable_v || std::is_constructible_ │ │ │ │ │ +v), int> = 0> │ │ │ │ │ +143 constexpr CopyableOptional& operator= (T&& value) │ │ │ │ │ +144 noexcept(std::is_nothrow_assignable_v || │ │ │ │ │ +145 (!std::is_assignable_v && std::is_nothrow_constructible_ │ │ │ │ │ +v)) │ │ │ │ │ +146 { │ │ │ │ │ +147 if constexpr(std::is_assignable_v) │ │ │ │ │ +148 Base::operator=(std::forward(value)); │ │ │ │ │ +149 else │ │ │ │ │ +150 Base::emplace(std::forward(value)); │ │ │ │ │ +151 return *this; │ │ │ │ │ +152 } │ │ │ │ │ +153}; │ │ │ │ │ +154 │ │ │ │ │ +155} // end namespace Dune │ │ │ │ │ +156 │ │ │ │ │ +157#endif // DUNE_COMMON_COPYABLE_OPTIONAL_HH │ │ │ │ │ +typeutilities.hh │ │ │ │ │ +Utilities for type computations, constraining overloads, ... │ │ │ │ │ +Dune::disableCopyMove │ │ │ │ │ +std::enable_if_t< not Impl::disableCopyMoveHelper< This, T... >::value, int > │ │ │ │ │ +disableCopyMove │ │ │ │ │ +Helper to disable constructor as copy and move constructor. │ │ │ │ │ +Definition typeutilities.hh:45 │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::size │ │ │ │ │ -constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std:: │ │ │ │ │ -integer_sequence< T, II... >) │ │ │ │ │ -Return the size of the sequence. │ │ │ │ │ -Definition integersequence.hh:75 │ │ │ │ │ -Dune::ArrayListIterator │ │ │ │ │ -A random access iterator for the Dune::ArrayList class. │ │ │ │ │ -Definition arraylist.hh:255 │ │ │ │ │ -Dune::ConstArrayListIterator │ │ │ │ │ -A constant random access iterator for the Dune::ArrayList class. │ │ │ │ │ -Definition arraylist.hh:368 │ │ │ │ │ -Dune::ArrayList │ │ │ │ │ -A dynamically growing random access list. │ │ │ │ │ -Definition arraylist.hh:62 │ │ │ │ │ -Dune::ArrayList::const_iterator │ │ │ │ │ -ConstArrayListIterator< MemberType, N, A > const_iterator │ │ │ │ │ -A constant random access iterator. │ │ │ │ │ -Definition arraylist.hh:110 │ │ │ │ │ -Dune::MPITraits │ │ │ │ │ -A traits class describing the mapping of types onto MPI_Datatypes. │ │ │ │ │ -Definition mpitraits.hh:41 │ │ │ │ │ -Dune::InvalidStateException │ │ │ │ │ -Default exception if a function was called while the object is not in a valid │ │ │ │ │ -state for that function... │ │ │ │ │ -Definition exceptions.hh:281 │ │ │ │ │ -Dune::RandomAccessIteratorFacade<_ArrayListIterator<_T,_N,_A_>,_A::value_type, │ │ │ │ │ -A::value_type_&,_A::difference_type_>::operator* │ │ │ │ │ -Reference operator*() const │ │ │ │ │ -Dereferencing operator. │ │ │ │ │ -Definition iteratorfacades.hh:501 │ │ │ │ │ -Dune::IndexPair │ │ │ │ │ -A pair consisting of a global and local index. │ │ │ │ │ -Definition indexset.hh:85 │ │ │ │ │ -Dune::InvalidIndexSetState │ │ │ │ │ -Exception indicating that the index set is not in the expected state. │ │ │ │ │ -Definition indexset.hh:205 │ │ │ │ │ -Dune::GlobalLookupIndexSet │ │ │ │ │ -Decorates an index set with the possibility to find a global index that is │ │ │ │ │ -mapped to a specific local... │ │ │ │ │ -Definition indexset.hh:507 │ │ │ │ │ -Dune::ParallelIndexSet │ │ │ │ │ -Manager class for the mapping between local indices and globally unique │ │ │ │ │ -indices. │ │ │ │ │ -Definition indexset.hh:218 │ │ │ │ │ -Dune::ParallelIndexSet::iterator │ │ │ │ │ -The iterator over the pairs. │ │ │ │ │ -Definition indexset.hh:257 │ │ │ │ │ -Dune::LocalIndexComparator │ │ │ │ │ -Definition indexset.hh:615 │ │ │ │ │ -Dune::IndexSetSortFunctor │ │ │ │ │ -Definition indexset.hh:624 │ │ │ │ │ +Dune::CopyableOptional │ │ │ │ │ +A copyable type wrapper that provides copy/move assignment operations for types │ │ │ │ │ +that are only copy/mo... │ │ │ │ │ +Definition copyableoptional.hh:35 │ │ │ │ │ +Dune::CopyableOptional::CopyableOptional │ │ │ │ │ +constexpr CopyableOptional(CopyableOptional &&)=default │ │ │ │ │ +Move construct the contained value. │ │ │ │ │ +Dune::CopyableOptional::CopyableOptional │ │ │ │ │ +constexpr CopyableOptional(T &&value) noexcept(std::is_nothrow_constructible_v< │ │ │ │ │ +Type, T && >) │ │ │ │ │ +Construct the internal data from perfect forwarding of the passed arguments. │ │ │ │ │ +Participates in overload... │ │ │ │ │ +Definition copyableoptional.hh:62 │ │ │ │ │ +Dune::CopyableOptional::operator= │ │ │ │ │ +constexpr CopyableOptional & operator=(const CopyableOptional &that) noexcept │ │ │ │ │ +(std::is_nothrow_copy_assignable_v< Type >||(!std::is_copy_assignable_v< Type > │ │ │ │ │ +&&std::is_nothrow_copy_constructible_v< Type >)) │ │ │ │ │ +Copy assignment in terms of copy constructor. │ │ │ │ │ +Definition copyableoptional.hh:100 │ │ │ │ │ +Dune::CopyableOptional::CopyableOptional │ │ │ │ │ +constexpr CopyableOptional() noexcept(std::is_nothrow_default_constructible_v< │ │ │ │ │ +T >) │ │ │ │ │ +Implementation of a default constructor, if the Type is itself default │ │ │ │ │ +constructible.... │ │ │ │ │ +Definition copyableoptional.hh:49 │ │ │ │ │ +Dune::CopyableOptional::CopyableOptional │ │ │ │ │ +constexpr CopyableOptional(const CopyableOptional &)=default │ │ │ │ │ +Copy construct the contained value. │ │ │ │ │ +Dune::CopyableOptional::CopyableOptional │ │ │ │ │ +constexpr CopyableOptional(Args &&... args) noexcept(std::is_nothrow_ │ │ │ │ │ +constructible_v< Type, Args &&... >) │ │ │ │ │ +Construct the internal data from perfect forwarding of the passed arguments. │ │ │ │ │ +Definition copyableoptional.hh:85 │ │ │ │ │ +Dune::CopyableOptional::~CopyableOptional │ │ │ │ │ +~CopyableOptional()=default │ │ │ │ │ +Default destructor. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00053.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: indicessyncer.hh File Reference │ │ │ │ +dune-common: precision.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,87 +65,45 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ - │ │ │ │ +Namespaces
│ │ │ │ +
precision.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Class for adding missing indices of a distributed index set in a local communication. │ │ │ │ +

Various precision settings for calculations with FieldMatrix and FieldVector. │ │ │ │ More...

│ │ │ │ -
#include <algorithm>
│ │ │ │ -#include <cassert>
│ │ │ │ -#include <cmath>
│ │ │ │ -#include <functional>
│ │ │ │ -#include <limits>
│ │ │ │ -#include <map>
│ │ │ │ -#include <tuple>
│ │ │ │ -#include <mpi.h>
│ │ │ │ -#include <dune/common/stdstreams.hh>
│ │ │ │ -#include <dune/common/sllist.hh>
│ │ │ │ -#include <dune/common/parallel/indexset.hh>
│ │ │ │ -#include <dune/common/parallel/remoteindices.hh>
│ │ │ │ +
#include <stdlib.h>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::IndicesSyncer< T >
 Class for recomputing missing indices of a distributed index set. More...
class  Dune::FMatrixPrecision< ctype >
 Precisions for calculations with FieldMatrix and FieldVector. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

template<typename TG , typename TA >
bool Dune::operator< (const IndexPair< TG, ParallelLocalIndex< TA > > &i1, const std::pair< TG, TA > &i2)
 
template<typename TG , typename TA >
bool Dune::operator< (const std::pair< TG, TA > &i1, const IndexPair< TG, ParallelLocalIndex< TA > > &i2)
 
template<typename TG , typename TA >
bool Dune::operator== (const IndexPair< TG, ParallelLocalIndex< TA > > &i1, const std::pair< TG, TA > &i2)
 
template<typename TG , typename TA >
bool Dune::operator!= (const IndexPair< TG, ParallelLocalIndex< TA > > &i1, const std::pair< TG, TA > &i2)
 
template<typename TG , typename TA >
bool Dune::operator== (const std::pair< TG, TA > &i2, const IndexPair< TG, ParallelLocalIndex< TA > > &i1)
 
template<typename TG , typename TA >
bool Dune::operator!= (const std::pair< TG, TA > &i2, const IndexPair< TG, ParallelLocalIndex< TA > > &i1)
 
template<typename T , typename A , typename A1 >
void Dune::storeGlobalIndicesOfRemoteIndices (std::map< int, SLList< std::pair< typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &globalMap, const RemoteIndices< T, A1 > &remoteIndices)
 Stores the corresponding global indices of the remote index information.
 
template<typename T , typename A , typename A1 >
void Dune::repairLocalIndexPointers (std::map< int, SLList< std::pair< typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &globalMap, RemoteIndices< T, A1 > &remoteIndices, const T &indexSet)
 Repair the pointers to the local indices in the remote indices.
 
│ │ │ │

Detailed Description

│ │ │ │ -

Class for adding missing indices of a distributed index set in a local communication.

│ │ │ │ -
Author
Markus Blatt
│ │ │ │ +

Various precision settings for calculations with FieldMatrix and FieldVector.

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,78 +1,24 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -indicessyncer.hh File Reference │ │ │ │ │ -Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ -Class for adding missing indices of a distributed index set in a local │ │ │ │ │ -communication. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +precision.hh File Reference │ │ │ │ │ +Various precision settings for calculations with FieldMatrix and FieldVector. │ │ │ │ │ +More... │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::IndicesSyncer<_T_> │ │ │ │ │ -  Class for recomputing missing indices of a distributed index set. │ │ │ │ │ - More... │ │ │ │ │ +class   Dune::FMatrixPrecision<_ctype_> │ │ │ │ │ +  Precisions for calculations with FieldMatrix and FieldVector. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Functions │ │ │ │ │ -template │ │ │ │ │ -bool  Dune::operator< (const IndexPair< TG, ParallelLocalIndex< TA > > &i1, │ │ │ │ │ - const std::pair< TG, TA > &i2) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool  Dune::operator< (const std::pair< TG, TA > &i1, const IndexPair< TG, │ │ │ │ │ - ParallelLocalIndex< TA > > &i2) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool  Dune::operator== (const IndexPair< TG, ParallelLocalIndex< TA > > &i1, │ │ │ │ │ - const std::pair< TG, TA > &i2) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool  Dune::operator!= (const IndexPair< TG, ParallelLocalIndex< TA > > &i1, │ │ │ │ │ - const std::pair< TG, TA > &i2) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool  Dune::operator== (const std::pair< TG, TA > &i2, const IndexPair< TG, │ │ │ │ │ - ParallelLocalIndex< TA > > &i1) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -bool  Dune::operator!= (const std::pair< TG, TA > &i2, const IndexPair< TG, │ │ │ │ │ - ParallelLocalIndex< TA > > &i1) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void  Dune::storeGlobalIndicesOfRemoteIndices (std::map< int, SLList< std:: │ │ │ │ │ - pair< typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > │ │ │ │ │ - &globalMap, const RemoteIndices< T, A1 > &remoteIndices) │ │ │ │ │ -  Stores the corresponding global indices of the remote index information. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -void  Dune::repairLocalIndexPointers (std::map< int, SLList< std::pair< │ │ │ │ │ - typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > │ │ │ │ │ - &globalMap, RemoteIndices< T, A1 > &remoteIndices, const T &indexSet) │ │ │ │ │ -  Repair the pointers to the local indices in the remote indices. │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Class for adding missing indices of a distributed index set in a local │ │ │ │ │ -communication. │ │ │ │ │ - Author │ │ │ │ │ - Markus Blatt │ │ │ │ │ +Various precision settings for calculations with FieldMatrix and FieldVector. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00053_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: indicessyncer.hh Source File │ │ │ │ +dune-common: precision.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,1056 +70,66 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
indicessyncer.hh
│ │ │ │ +
precision.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PARALLEL_INDICESSYNCER_HH
│ │ │ │ -
6#define DUNE_COMMON_PARALLEL_INDICESSYNCER_HH
│ │ │ │ +
5#ifndef DUNE_PRECISION_HH
│ │ │ │ +
6#define DUNE_PRECISION_HH
│ │ │ │
7
│ │ │ │ -
8#if HAVE_MPI
│ │ │ │ -
9
│ │ │ │ -
10#include <algorithm>
│ │ │ │ -
11#include <cassert>
│ │ │ │ -
12#include <cmath>
│ │ │ │ -
13#include <functional>
│ │ │ │ -
14#include <limits>
│ │ │ │ -
15#include <map>
│ │ │ │ -
16#include <tuple>
│ │ │ │ -
17
│ │ │ │ -
18#include <mpi.h>
│ │ │ │ -
19
│ │ │ │ - │ │ │ │ -
21#include <dune/common/sllist.hh>
│ │ │ │ - │ │ │ │ - │ │ │ │ -
24
│ │ │ │ -
25namespace Dune
│ │ │ │ -
26{
│ │ │ │ -
43 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
45 {
│ │ │ │ -
46 public:
│ │ │ │ -
47
│ │ │ │ - │ │ │ │ +
12#include <stdlib.h>
│ │ │ │ +
13
│ │ │ │ +
14namespace Dune {
│ │ │ │ +
15
│ │ │ │ +
24 template <class ctype = double>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
26 public:
│ │ │ │ +
│ │ │ │ +
28 static ctype absolute_limit ()
│ │ │ │ +
29 {
│ │ │ │ +
30 return _absolute;
│ │ │ │ +
31 }
│ │ │ │ +
│ │ │ │ +
32
│ │ │ │ +
│ │ │ │ +
34 static void set_absolute_limit (ctype absthres)
│ │ │ │ +
35 {
│ │ │ │ +
36 _absolute = absthres;
│ │ │ │ +
37 }
│ │ │ │ +
│ │ │ │ +
38
│ │ │ │ +
39 private:
│ │ │ │ +
40 // just to demonstrate some state information
│ │ │ │ +
41 static ctype _absolute;
│ │ │ │ +
42 };
│ │ │ │ +
│ │ │ │ +
43
│ │ │ │ +
44 template <class ctype>
│ │ │ │ +
45 ctype FMatrixPrecision<ctype>::_absolute = 1E-80;
│ │ │ │ +
46
│ │ │ │ +
49} // end namespace
│ │ │ │
50
│ │ │ │ - │ │ │ │ -
53
│ │ │ │ - │ │ │ │ -
56
│ │ │ │ -
58 typedef typename ParallelIndexSet::LocalIndex::Attribute Attribute;
│ │ │ │ -
59
│ │ │ │ - │ │ │ │ -
64
│ │ │ │ - │ │ │ │ -
75 RemoteIndices& remoteIndices);
│ │ │ │ -
76
│ │ │ │ -
86 void sync();
│ │ │ │ -
87
│ │ │ │ -
100 template<typename T1>
│ │ │ │ -
101 void sync(T1& numberer, bool useFixedOrder = false);
│ │ │ │ -
102
│ │ │ │ -
103 private:
│ │ │ │ -
104
│ │ │ │ -
106 ParallelIndexSet& indexSet_;
│ │ │ │ -
107
│ │ │ │ -
109 RemoteIndices& remoteIndices_;
│ │ │ │ -
110
│ │ │ │ -
112 char** sendBuffers_;
│ │ │ │ -
113
│ │ │ │ -
115 char* receiveBuffer_;
│ │ │ │ -
116
│ │ │ │ -
118 std::size_t* sendBufferSizes_;
│ │ │ │ -
119
│ │ │ │ -
121 int receiveBufferSize_; // int because of MPI
│ │ │ │ -
122
│ │ │ │ -
126 struct MessageInformation
│ │ │ │ -
127 {
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
129 : publish(), pairs()
│ │ │ │ -
130 {}
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
137 int pairs;
│ │ │ │ -
138 };
│ │ │ │ -
139
│ │ │ │ -
143 class DefaultNumberer
│ │ │ │ -
144 {
│ │ │ │ -
145 public:
│ │ │ │ -
151 std::size_t operator()([[maybe_unused]] const GlobalIndex& global)
│ │ │ │ -
152 {
│ │ │ │ -
153 return std::numeric_limits<size_t>::max();
│ │ │ │ -
154 }
│ │ │ │ -
155 };
│ │ │ │ -
156
│ │ │ │ -
158 MPI_Datatype datatype_;
│ │ │ │ -
159
│ │ │ │ -
161 int rank_;
│ │ │ │ -
162
│ │ │ │ -
167 typedef SLList<std::pair<GlobalIndex,Attribute>, typename RemoteIndices::Allocator> GlobalIndexList;
│ │ │ │ -
168
│ │ │ │ -
170 typedef typename GlobalIndexList::ModifyIterator GlobalIndexModifier;
│ │ │ │ -
171
│ │ │ │ - │ │ │ │ -
176 GlobalIndexIterator;
│ │ │ │ -
177
│ │ │ │ -
179 typedef std::map<int, GlobalIndexList> GlobalIndicesMap;
│ │ │ │ -
180
│ │ │ │ -
189 GlobalIndicesMap globalMap_;
│ │ │ │ -
190
│ │ │ │ - │ │ │ │ -
195
│ │ │ │ -
199 typedef typename BoolList::iterator BoolIterator;
│ │ │ │ -
200
│ │ │ │ -
202 typedef typename BoolList::ModifyIterator BoolListModifier;
│ │ │ │ -
203
│ │ │ │ -
205 typedef std::map<int,BoolList> BoolMap;
│ │ │ │ -
206
│ │ │ │ -
211 BoolMap oldMap_;
│ │ │ │ -
212
│ │ │ │ -
214 std::map<int,MessageInformation> infoSend_;
│ │ │ │ -
215
│ │ │ │ -
217 typedef typename RemoteIndices::RemoteIndexList RemoteIndexList;
│ │ │ │ -
218
│ │ │ │ -
220 typedef typename RemoteIndexList::ModifyIterator RemoteIndexModifier;
│ │ │ │ -
221
│ │ │ │ - │ │ │ │ -
224
│ │ │ │ -
226 typedef typename RemoteIndexList::iterator RemoteIndexIterator;
│ │ │ │ -
227
│ │ │ │ -
229 typedef typename RemoteIndexList::const_iterator ConstRemoteIndexIterator;
│ │ │ │ -
230
│ │ │ │ -
232 typedef std::tuple<RemoteIndexModifier,GlobalIndexModifier,BoolListModifier,
│ │ │ │ -
233 const ConstRemoteIndexIterator> IteratorTuple;
│ │ │ │ -
234
│ │ │ │ -
242 class Iterators
│ │ │ │ -
243 {
│ │ │ │ -
244 friend class IndicesSyncer<T>;
│ │ │ │ -
245 public:
│ │ │ │ -
255 Iterators(RemoteIndexList& remoteIndices, GlobalIndexList& globalIndices,
│ │ │ │ -
256 BoolList& booleans);
│ │ │ │ -
257
│ │ │ │ -
261 Iterators();
│ │ │ │ -
262
│ │ │ │ - │ │ │ │ -
267
│ │ │ │ -
273 void insert(const RemoteIndex& index,
│ │ │ │ -
274 const std::pair<GlobalIndex,Attribute>& global);
│ │ │ │ -
275
│ │ │ │ -
280 RemoteIndex& remoteIndex() const;
│ │ │ │ -
281
│ │ │ │ -
286 std::pair<GlobalIndex,Attribute>& globalIndexPair() const;
│ │ │ │ -
287
│ │ │ │ - │ │ │ │ -
289
│ │ │ │ -
295 bool isOld() const;
│ │ │ │ -
296
│ │ │ │ -
306 void reset(RemoteIndexList& remoteIndices, GlobalIndexList& globalIndices,
│ │ │ │ -
307 BoolList& booleans);
│ │ │ │ -
308
│ │ │ │ -
314 bool isNotAtEnd() const;
│ │ │ │ -
315
│ │ │ │ -
321 bool isAtEnd() const;
│ │ │ │ -
322
│ │ │ │ -
323 private:
│ │ │ │ -
333 IteratorTuple iterators_;
│ │ │ │ -
334 };
│ │ │ │ -
335
│ │ │ │ -
337 typedef std::map<int,Iterators> IteratorsMap;
│ │ │ │ -
338
│ │ │ │ -
350 IteratorsMap iteratorsMap_;
│ │ │ │ -
351
│ │ │ │ -
353 void calculateMessageSizes();
│ │ │ │ -
354
│ │ │ │ -
362 void packAndSend(int destination, char* buffer, std::size_t bufferSize, MPI_Request& req);
│ │ │ │ -
363
│ │ │ │ -
370 template<typename T1>
│ │ │ │ -
371 void recvAndUnpack(T1& numberer, int hardSource, bool useHardSource);
│ │ │ │ -
372
│ │ │ │ -
376 void registerMessageDatatype();
│ │ │ │ -
377
│ │ │ │ -
381 void insertIntoRemoteIndexList(int process,
│ │ │ │ -
382 const std::pair<GlobalIndex,Attribute>& global,
│ │ │ │ -
383 char attribute);
│ │ │ │ -
384
│ │ │ │ -
388 void resetIteratorsMap();
│ │ │ │ -
389
│ │ │ │ -
394 bool checkReset();
│ │ │ │ -
395
│ │ │ │ -
404 bool checkReset(const Iterators& iterators, RemoteIndexList& rlist, GlobalIndexList& gList,
│ │ │ │ -
405 BoolList& bList);
│ │ │ │ -
406 };
│ │ │ │ -
│ │ │ │ -
407
│ │ │ │ -
408 template<typename TG, typename TA>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
410 const std::pair<TG,TA>& i2)
│ │ │ │ -
411 {
│ │ │ │ -
412 return i1.global() < i2.first ||
│ │ │ │ -
413 (i1.global() == i2.first && i1.local().attribute()<i2.second);
│ │ │ │ -
414 }
│ │ │ │ -
│ │ │ │ -
415
│ │ │ │ -
416 template<typename TG, typename TA>
│ │ │ │ -
│ │ │ │ -
417 bool operator<(const std::pair<TG,TA>& i1,
│ │ │ │ -
418 const IndexPair<TG,ParallelLocalIndex<TA> >& i2)
│ │ │ │ -
419 {
│ │ │ │ -
420 return i1.first < i2.global() ||
│ │ │ │ -
421 (i1.first == i2.global() && i1.second<i2.local().attribute());
│ │ │ │ -
422 }
│ │ │ │ -
│ │ │ │ -
423
│ │ │ │ -
424 template<typename TG, typename TA>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
426 const std::pair<TG,TA>& i2)
│ │ │ │ -
427 {
│ │ │ │ -
428 return (i1.global() == i2.first && i1.local().attribute()==i2.second);
│ │ │ │ -
429 }
│ │ │ │ -
│ │ │ │ -
430
│ │ │ │ -
431 template<typename TG, typename TA>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
433 const std::pair<TG,TA>& i2)
│ │ │ │ -
434 {
│ │ │ │ -
435 return (i1.global() != i2.first || i1.local().attribute()!=i2.second);
│ │ │ │ -
436 }
│ │ │ │ -
│ │ │ │ -
437
│ │ │ │ -
438 template<typename TG, typename TA>
│ │ │ │ -
│ │ │ │ -
439 bool operator==(const std::pair<TG,TA>& i2,
│ │ │ │ -
440 const IndexPair<TG,ParallelLocalIndex<TA> >& i1)
│ │ │ │ -
441 {
│ │ │ │ -
442 return (i1.global() == i2.first && i1.local().attribute()==i2.second);
│ │ │ │ -
443 }
│ │ │ │ -
│ │ │ │ -
444
│ │ │ │ -
445 template<typename TG, typename TA>
│ │ │ │ -
│ │ │ │ -
446 bool operator!=(const std::pair<TG,TA>& i2,
│ │ │ │ -
447 const IndexPair<TG,ParallelLocalIndex<TA> >& i1)
│ │ │ │ -
448 {
│ │ │ │ -
449 return (i1.global() != i2.first || i1.local().attribute()!=i2.second);
│ │ │ │ -
450 }
│ │ │ │ -
│ │ │ │ -
451
│ │ │ │ -
468 template<typename T, typename A, typename A1>
│ │ │ │ -
│ │ │ │ -
469 void storeGlobalIndicesOfRemoteIndices(std::map<int,SLList<std::pair<typename T::GlobalIndex, typename T::LocalIndex::Attribute>,A> >& globalMap,
│ │ │ │ -
470 const RemoteIndices<T,A1>& remoteIndices)
│ │ │ │ -
471 {
│ │ │ │ -
472 for(auto remote = remoteIndices.begin(), end =remoteIndices.end(); remote != end; ++remote) {
│ │ │ │ -
473 typedef typename RemoteIndices<T,A1>::RemoteIndexList RemoteIndexList;
│ │ │ │ - │ │ │ │ -
475 GlobalIndexList& global = globalMap[remote->first];
│ │ │ │ -
476 RemoteIndexList& rList = *(remote->second.first);
│ │ │ │ -
477
│ │ │ │ -
478 for(auto index = rList.begin(), riEnd = rList.end();
│ │ │ │ -
479 index != riEnd; ++index) {
│ │ │ │ -
480 global.push_back(std::make_pair(index->localIndexPair().global(),
│ │ │ │ -
481 index->localIndexPair().local().attribute()));
│ │ │ │ -
482 }
│ │ │ │ -
483 }
│ │ │ │ -
484 }
│ │ │ │ -
│ │ │ │ -
485
│ │ │ │ -
494 template<typename T, typename A, typename A1>
│ │ │ │ -
│ │ │ │ -
495 inline void repairLocalIndexPointers(std::map<int,
│ │ │ │ -
496 SLList<std::pair<typename T::GlobalIndex,
│ │ │ │ -
497 typename T::LocalIndex::Attribute>,A> >& globalMap,
│ │ │ │ -
498 RemoteIndices<T,A1>& remoteIndices,
│ │ │ │ -
499 const T& indexSet)
│ │ │ │ -
500 {
│ │ │ │ -
501 assert(globalMap.size()==static_cast<std::size_t>(remoteIndices.neighbours()));
│ │ │ │ -
502 // Repair pointers to index set in remote indices.
│ │ │ │ -
503 auto global = globalMap.begin();
│ │ │ │ -
504 auto end = remoteIndices.remoteIndices_.end();
│ │ │ │ -
505
│ │ │ │ -
506 for(auto remote = remoteIndices.remoteIndices_.begin(); remote != end; ++remote, ++global) {
│ │ │ │ -
507 assert(remote->first==global->first);
│ │ │ │ -
508 assert(remote->second.first->size() == global->second.size());
│ │ │ │ -
509
│ │ │ │ -
510 auto riEnd = remote->second.first->end();
│ │ │ │ -
511 auto rIndex = remote->second.first->begin();
│ │ │ │ -
512 auto gIndex = global->second.begin();
│ │ │ │ -
513 auto index = indexSet.begin();
│ │ │ │ -
514
│ │ │ │ -
515 assert(rIndex==riEnd || gIndex != global->second.end());
│ │ │ │ -
516 while(rIndex != riEnd) {
│ │ │ │ -
517 // Search for the index in the set.
│ │ │ │ -
518 assert(gIndex != global->second.end());
│ │ │ │ -
519
│ │ │ │ -
520 while(!(index->global() == gIndex->first
│ │ │ │ -
521 && index->local().attribute() == gIndex->second)) {
│ │ │ │ -
522 ++index;
│ │ │ │ -
523 // this is only needed for ALU, where there may exist
│ │ │ │ -
524 // more entries with the same global index in the remote index set
│ │ │ │ -
525 // than in the index set
│ │ │ │ -
526 if (index->global() > gIndex->first) {
│ │ │ │ -
527 index=indexSet.begin();
│ │ │ │ -
528 }
│ │ │ │ -
529 }
│ │ │ │ -
530
│ │ │ │ -
531 assert(index != indexSet.end() && *index == *gIndex);
│ │ │ │ -
532
│ │ │ │ -
533 rIndex->localIndex_ = &(*index);
│ │ │ │ -
534 ++index;
│ │ │ │ -
535 ++rIndex;
│ │ │ │ -
536 ++gIndex;
│ │ │ │ -
537 }
│ │ │ │ -
538 }
│ │ │ │ -
539 remoteIndices.sourceSeqNo_ = remoteIndices.source_->seqNo();
│ │ │ │ -
540 remoteIndices.destSeqNo_ = remoteIndices.target_->seqNo();
│ │ │ │ -
541 }
│ │ │ │ -
│ │ │ │ -
542
│ │ │ │ -
543 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
545 RemoteIndices& remoteIndices)
│ │ │ │ -
546 : indexSet_(indexSet), remoteIndices_(remoteIndices)
│ │ │ │ -
547 {
│ │ │ │ -
548 // index sets must match.
│ │ │ │ -
549 assert(remoteIndices.source_ == remoteIndices.target_);
│ │ │ │ -
550 assert(remoteIndices.source_ == &indexSet);
│ │ │ │ -
551 MPI_Comm_rank(remoteIndices_.communicator(), &rank_);
│ │ │ │ -
552 }
│ │ │ │ -
│ │ │ │ -
553
│ │ │ │ -
554 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
556 GlobalIndexList& globalIndices,
│ │ │ │ -
557 BoolList& booleans)
│ │ │ │ -
558 : iterators_(remoteIndices.beginModify(), globalIndices.beginModify(),
│ │ │ │ -
559 booleans.beginModify(), remoteIndices.end())
│ │ │ │ -
560 { }
│ │ │ │ -
│ │ │ │ -
561
│ │ │ │ -
562 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
564 : iterators_()
│ │ │ │ -
565 {}
│ │ │ │ -
│ │ │ │ -
566
│ │ │ │ -
567 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
569 {
│ │ │ │ -
570 ++(std::get<0>(iterators_));
│ │ │ │ -
571 ++(std::get<1>(iterators_));
│ │ │ │ -
572 ++(std::get<2>(iterators_));
│ │ │ │ -
573 return *this;
│ │ │ │ -
574 }
│ │ │ │ -
│ │ │ │ -
575
│ │ │ │ -
576 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
578 const std::pair<GlobalIndex,Attribute>& global)
│ │ │ │ -
579 {
│ │ │ │ -
580 std::get<0>(iterators_).insert(index);
│ │ │ │ -
581 std::get<1>(iterators_).insert(global);
│ │ │ │ -
582 std::get<2>(iterators_).insert(false);
│ │ │ │ -
583 }
│ │ │ │ -
│ │ │ │ -
584
│ │ │ │ -
585 template<typename T>
│ │ │ │ -
586 inline typename IndicesSyncer<T>::RemoteIndex&
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
588 {
│ │ │ │ -
589 return *(std::get<0>(iterators_));
│ │ │ │ -
590 }
│ │ │ │ -
│ │ │ │ -
591
│ │ │ │ -
592 template<typename T>
│ │ │ │ -
593 inline std::pair<typename IndicesSyncer<T>::GlobalIndex,typename IndicesSyncer<T>::Attribute>&
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
595 {
│ │ │ │ -
596 return *(std::get<1>(iterators_));
│ │ │ │ -
597 }
│ │ │ │ -
│ │ │ │ -
598
│ │ │ │ -
599 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
601 {
│ │ │ │ -
602 return *(std::get<2>(iterators_));
│ │ │ │ -
603 }
│ │ │ │ -
│ │ │ │ -
604
│ │ │ │ -
605 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
607 GlobalIndexList& globalIndices,
│ │ │ │ -
608 BoolList& booleans)
│ │ │ │ -
609 {
│ │ │ │ -
610 std::get<0>(iterators_) = remoteIndices.beginModify();
│ │ │ │ -
611 std::get<1>(iterators_) = globalIndices.beginModify();
│ │ │ │ -
612 std::get<2>(iterators_) = booleans.beginModify();
│ │ │ │ -
613 }
│ │ │ │ -
│ │ │ │ -
614
│ │ │ │ -
615 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
617 {
│ │ │ │ -
618 return std::get<0>(iterators_) != std::get<3>(iterators_);
│ │ │ │ -
619 }
│ │ │ │ -
│ │ │ │ -
620
│ │ │ │ -
621 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
623 {
│ │ │ │ -
624 return std::get<0>(iterators_) == std::get<3>(iterators_);
│ │ │ │ -
625 }
│ │ │ │ -
│ │ │ │ -
626
│ │ │ │ -
627 template<typename T>
│ │ │ │ - │ │ │ │ -
629 {
│ │ │ │ -
630 MPI_Datatype type[2] = {MPI_INT, MPI_INT};
│ │ │ │ -
631 int blocklength[2] = {1,1};
│ │ │ │ -
632 MPI_Aint displacement[2];
│ │ │ │ -
633 MPI_Aint base;
│ │ │ │ -
634
│ │ │ │ -
635 // Compute displacement
│ │ │ │ -
636 MessageInformation message;
│ │ │ │ -
637
│ │ │ │ -
638 MPI_Get_address( &(message.publish), displacement);
│ │ │ │ -
639 MPI_Get_address( &(message.pairs), displacement+1);
│ │ │ │ -
640
│ │ │ │ -
641 // Make the displacement relative
│ │ │ │ -
642 MPI_Get_address(&message, &base);
│ │ │ │ -
643 displacement[0] -= base;
│ │ │ │ -
644 displacement[1] -= base;
│ │ │ │ -
645
│ │ │ │ -
646 MPI_Type_create_struct( 2, blocklength, displacement, type, &datatype_);
│ │ │ │ -
647 MPI_Type_commit(&datatype_);
│ │ │ │ -
648 }
│ │ │ │ -
649
│ │ │ │ -
650 template<typename T>
│ │ │ │ -
651 void IndicesSyncer<T>::calculateMessageSizes()
│ │ │ │ -
652 {
│ │ │ │ -
653 auto iEnd = indexSet_.end();
│ │ │ │ -
654 auto collIter = remoteIndices_.template iterator<true>();
│ │ │ │ -
655
│ │ │ │ -
656 for(auto index = indexSet_.begin(); index != iEnd; ++index) {
│ │ │ │ -
657 collIter.advance(index->global(), index->local().attribute());
│ │ │ │ -
658 if(collIter.empty())
│ │ │ │ -
659 break;
│ │ │ │ -
660 int knownRemote=0;
│ │ │ │ -
661 auto end = collIter.end();
│ │ │ │ -
662
│ │ │ │ -
663 // Count the remote indices we know.
│ │ │ │ -
664 for(auto valid = collIter.begin(); valid != end; ++valid) {
│ │ │ │ -
665 ++knownRemote;
│ │ │ │ -
666 }
│ │ │ │ -
667
│ │ │ │ -
668 if(knownRemote>0) {
│ │ │ │ -
669 Dune::dverb<<rank_<<": publishing "<<knownRemote<<" for index "<<index->global()<< " for processes ";
│ │ │ │ -
670
│ │ │ │ -
671 // Update MessageInformation
│ │ │ │ -
672 for(auto valid = collIter.begin(); valid != end; ++valid) {
│ │ │ │ -
673 ++(infoSend_[valid.process()].publish);
│ │ │ │ -
674 (infoSend_[valid.process()].pairs) += knownRemote;
│ │ │ │ -
675 Dune::dverb<<valid.process()<<" ";
│ │ │ │ -
676 Dune::dverb<<"(publish="<<infoSend_[valid.process()].publish<<", pairs="<<infoSend_[valid.process()].pairs
│ │ │ │ -
677 <<") ";
│ │ │ │ -
678 }
│ │ │ │ -
679 Dune::dverb<<std::endl;
│ │ │ │ -
680 }
│ │ │ │ -
681 }
│ │ │ │ -
682
│ │ │ │ -
683 const auto end = infoSend_.end();
│ │ │ │ -
684
│ │ │ │ -
685 // Now determine the buffersizes needed for each neighbour using MPI_Pack_size
│ │ │ │ -
686 MessageInformation dummy;
│ │ │ │ -
687
│ │ │ │ -
688 auto messageIter= infoSend_.begin();
│ │ │ │ -
689 const auto rend = remoteIndices_.end();
│ │ │ │ -
690 int neighbour=0;
│ │ │ │ -
691
│ │ │ │ -
692 for(auto remote = remoteIndices_.begin(); remote != rend; ++remote, ++neighbour) {
│ │ │ │ -
693 MessageInformation* message;
│ │ │ │ -
694 MessageInformation recv;
│ │ │ │ -
695
│ │ │ │ -
696 if(messageIter != end && messageIter->first==remote->first) {
│ │ │ │ -
697 // We want to send message information to that process
│ │ │ │ -
698 message = const_cast<MessageInformation*>(&(messageIter->second));
│ │ │ │ -
699 ++messageIter;
│ │ │ │ -
700 }else
│ │ │ │ -
701 // We do not want to send information but the other process might.
│ │ │ │ -
702 message = &dummy;
│ │ │ │ -
703
│ │ │ │ -
704 sendBufferSizes_[neighbour]=0;
│ │ │ │ -
705 int tsize;
│ │ │ │ -
706 // The number of indices published
│ │ │ │ -
707 MPI_Pack_size(1, MPI_INT,remoteIndices_.communicator(), &tsize);
│ │ │ │ -
708 sendBufferSizes_[neighbour] += tsize;
│ │ │ │ -
709
│ │ │ │ -
710 for(int i=0; i < message->publish; ++i) {
│ │ │ │ -
711 // The global index
│ │ │ │ -
712 MPI_Pack_size(1, MPITraits<GlobalIndex>::getType(), remoteIndices_.communicator(), &tsize);
│ │ │ │ -
713 sendBufferSizes_[neighbour] += tsize;
│ │ │ │ -
714 // The attribute in the local index
│ │ │ │ -
715 MPI_Pack_size(1, MPI_CHAR, remoteIndices_.communicator(), &tsize);
│ │ │ │ -
716 sendBufferSizes_[neighbour] += tsize;
│ │ │ │ -
717 // The number of corresponding remote indices
│ │ │ │ -
718 MPI_Pack_size(1, MPI_INT, remoteIndices_.communicator(), &tsize);
│ │ │ │ -
719 sendBufferSizes_[neighbour] += tsize;
│ │ │ │ -
720 }
│ │ │ │ -
721 for(int i=0; i < message->pairs; ++i) {
│ │ │ │ -
722 // The process of the remote index
│ │ │ │ -
723 MPI_Pack_size(1, MPI_INT, remoteIndices_.communicator(), &tsize);
│ │ │ │ -
724 sendBufferSizes_[neighbour] += tsize;
│ │ │ │ -
725 // The attribute of the remote index
│ │ │ │ -
726 MPI_Pack_size(1, MPI_CHAR, remoteIndices_.communicator(), &tsize);
│ │ │ │ -
727 sendBufferSizes_[neighbour] += tsize;
│ │ │ │ -
728 }
│ │ │ │ -
729
│ │ │ │ -
730 Dune::dverb<<rank_<<": Buffer (neighbour="<<remote->first<<") size is "<< sendBufferSizes_[neighbour]<<" for publish="<<message->publish<<" pairs="<<message->pairs<<std::endl;
│ │ │ │ -
731 }
│ │ │ │ -
732
│ │ │ │ -
733 }
│ │ │ │ -
734
│ │ │ │ -
735 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
737 {
│ │ │ │ -
738 DefaultNumberer numberer;
│ │ │ │ -
739 sync(numberer);
│ │ │ │ -
740 }
│ │ │ │ -
│ │ │ │ -
741
│ │ │ │ -
742 template<typename T>
│ │ │ │ -
743 template<typename T1>
│ │ │ │ -
│ │ │ │ -
744 void IndicesSyncer<T>::sync(T1& numberer, bool useFixedOrder)
│ │ │ │ -
745 {
│ │ │ │ -
746 // The pointers to the local indices in the remote indices
│ │ │ │ -
747 // will become invalid due to the resorting of the index set.
│ │ │ │ -
748 // Therefore store the corresponding global indices.
│ │ │ │ -
749 // Mark all indices as not added
│ │ │ │ -
750 const auto end = remoteIndices_.end();
│ │ │ │ -
751
│ │ │ │ -
752 // Number of neighbours might change during the syncing.
│ │ │ │ -
753 // save the old neighbours
│ │ │ │ -
754 std::size_t noOldNeighbours = remoteIndices_.neighbours();
│ │ │ │ -
755 int* oldNeighbours = new int[noOldNeighbours];
│ │ │ │ -
756 sendBufferSizes_ = new std::size_t[noOldNeighbours];
│ │ │ │ -
757 std::size_t neighbourI = 0;
│ │ │ │ -
758
│ │ │ │ -
759 for(auto remote = remoteIndices_.begin(); remote != end; ++remote, ++neighbourI) {
│ │ │ │ -
760 oldNeighbours[neighbourI] = remote->first;
│ │ │ │ -
761
│ │ │ │ -
762 // Make sure we only have one remote index list.
│ │ │ │ -
763 assert(remote->second.first==remote->second.second);
│ │ │ │ -
764
│ │ │ │ -
765 RemoteIndexList& rList = *(remote->second.first);
│ │ │ │ -
766
│ │ │ │ -
767 // Store the corresponding global indices.
│ │ │ │ -
768 GlobalIndexList& global = globalMap_[remote->first];
│ │ │ │ -
769 BoolList& added = oldMap_[remote->first];
│ │ │ │ -
770 auto riEnd = rList.end();
│ │ │ │ -
771
│ │ │ │ -
772 for(auto index = rList.begin();
│ │ │ │ -
773 index != riEnd; ++index) {
│ │ │ │ -
774 global.push_back(std::make_pair(index->localIndexPair().global(),
│ │ │ │ -
775 index->localIndexPair().local().attribute()));
│ │ │ │ -
776 added.push_back(true);
│ │ │ │ -
777 }
│ │ │ │ -
778
│ │ │ │ -
779 Iterators iterators(rList, global, added);
│ │ │ │ -
780 iteratorsMap_.insert(std::make_pair(remote->first, iterators));
│ │ │ │ -
781 assert(checkReset(iteratorsMap_[remote->first], rList,global,added));
│ │ │ │ -
782 }
│ │ │ │ -
783
│ │ │ │ -
784 // Exchange indices with each neighbour
│ │ │ │ -
785 calculateMessageSizes();
│ │ │ │ -
786
│ │ │ │ -
787 // Allocate the buffers
│ │ │ │ -
788 receiveBufferSize_=1;
│ │ │ │ -
789 sendBuffers_ = new char*[noOldNeighbours];
│ │ │ │ -
790
│ │ │ │ -
791 for(std::size_t i=0; i<noOldNeighbours; ++i) {
│ │ │ │ -
792 sendBuffers_[i] = new char[sendBufferSizes_[i]];
│ │ │ │ -
793 receiveBufferSize_ = std::max(receiveBufferSize_, static_cast<int>(sendBufferSizes_[i]));
│ │ │ │ -
794 }
│ │ │ │ -
795
│ │ │ │ -
796 receiveBuffer_=new char[receiveBufferSize_];
│ │ │ │ -
797
│ │ │ │ -
798 indexSet_.beginResize();
│ │ │ │ -
799
│ │ │ │ -
800 Dune::dverb<<rank_<<": Neighbours: ";
│ │ │ │ -
801
│ │ │ │ -
802 for(std::size_t i = 0; i<noOldNeighbours; ++i)
│ │ │ │ -
803 Dune::dverb<<oldNeighbours[i]<<" ";
│ │ │ │ -
804
│ │ │ │ -
805 Dune::dverb<<std::endl;
│ │ │ │ -
806
│ │ │ │ -
807 MPI_Request* requests = new MPI_Request[noOldNeighbours];
│ │ │ │ -
808 MPI_Status* statuses = new MPI_Status[noOldNeighbours];
│ │ │ │ -
809
│ │ │ │ -
810 // Pack Message data and start the sends
│ │ │ │ -
811 for(std::size_t i = 0; i<noOldNeighbours; ++i)
│ │ │ │ -
812 packAndSend(oldNeighbours[i], sendBuffers_[i], sendBufferSizes_[i], requests[i]);
│ │ │ │ -
813
│ │ │ │ -
814 // Probe for incoming messages, receive and unpack them
│ │ │ │ -
815 for(std::size_t i = 0; i<noOldNeighbours; ++i)
│ │ │ │ -
816 recvAndUnpack(numberer, oldNeighbours[i], useFixedOrder);
│ │ │ │ -
817 // }else{
│ │ │ │ -
818 // recvAndUnpack(oldNeighbours[i], numberer);
│ │ │ │ -
819 // packAndSend(oldNeighbours[i]);
│ │ │ │ -
820 // }
│ │ │ │ -
821 // }
│ │ │ │ -
822
│ │ │ │ -
823 delete[] receiveBuffer_;
│ │ │ │ -
824
│ │ │ │ -
825 // Wait for the completion of the sends
│ │ │ │ -
826 // Wait for completion of sends
│ │ │ │ -
827 if(MPI_SUCCESS!=MPI_Waitall(noOldNeighbours, requests, statuses)) {
│ │ │ │ -
828 std::cerr<<": MPI_Error occurred while sending message"<<std::endl;
│ │ │ │ -
829 for(std::size_t i=0; i< noOldNeighbours; i++)
│ │ │ │ -
830 if(MPI_SUCCESS!=statuses[i].MPI_ERROR)
│ │ │ │ -
831 std::cerr<<"Destination "<<statuses[i].MPI_SOURCE<<" error code: "<<statuses[i].MPI_ERROR<<std::endl;
│ │ │ │ -
832 }
│ │ │ │ -
833
│ │ │ │ -
834 delete[] statuses;
│ │ │ │ -
835 delete[] requests;
│ │ │ │ -
836
│ │ │ │ -
837 for(std::size_t i=0; i<noOldNeighbours; ++i)
│ │ │ │ -
838 delete[] sendBuffers_[i];
│ │ │ │ -
839
│ │ │ │ -
840 delete[] sendBuffers_;
│ │ │ │ -
841 delete[] sendBufferSizes_;
│ │ │ │ -
842
│ │ │ │ -
843 // No need for the iterator tuples any more
│ │ │ │ -
844 iteratorsMap_.clear();
│ │ │ │ -
845
│ │ │ │ -
846 indexSet_.endResize();
│ │ │ │ -
847
│ │ │ │ -
848 delete[] oldNeighbours;
│ │ │ │ -
849
│ │ │ │ -
850 repairLocalIndexPointers(globalMap_, remoteIndices_, indexSet_);
│ │ │ │ -
851
│ │ │ │ -
852 oldMap_.clear();
│ │ │ │ -
853 globalMap_.clear();
│ │ │ │ -
854
│ │ │ │ -
855 // update the sequence number
│ │ │ │ -
856 remoteIndices_.sourceSeqNo_ = remoteIndices_.destSeqNo_ = indexSet_.seqNo();
│ │ │ │ -
857 }
│ │ │ │ -
│ │ │ │ -
858
│ │ │ │ -
859 template<typename T>
│ │ │ │ -
860 void IndicesSyncer<T>::packAndSend(int destination, char* buffer, std::size_t bufferSize, MPI_Request& request)
│ │ │ │ -
861 {
│ │ │ │ -
862 auto iEnd = indexSet_.end();
│ │ │ │ -
863 int bpos = 0;
│ │ │ │ -
864 int published = 0;
│ │ │ │ -
865 int pairs = 0;
│ │ │ │ -
866
│ │ │ │ -
867 assert(checkReset());
│ │ │ │ -
868
│ │ │ │ -
869 // Pack the number of indices we publish
│ │ │ │ -
870 MPI_Pack(&(infoSend_[destination].publish), 1, MPI_INT, buffer, bufferSize, &bpos,
│ │ │ │ -
871 remoteIndices_.communicator());
│ │ │ │ -
872
│ │ │ │ -
873 for(auto index = indexSet_.begin(); index != iEnd; ++index) {
│ │ │ │ -
874 // Search for corresponding remote indices in all iterator tuples
│ │ │ │ -
875 auto iteratorsEnd = iteratorsMap_.end();
│ │ │ │ -
876
│ │ │ │ -
877 // advance all iterators to a position with global index >= index->global()
│ │ │ │ -
878 for(auto iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; ++iterators) {
│ │ │ │ -
879 while(iterators->second.isNotAtEnd() &&
│ │ │ │ -
880 iterators->second.globalIndexPair().first < index->global())
│ │ │ │ -
881 ++(iterators->second);
│ │ │ │ -
882 assert(!iterators->second.isNotAtEnd() || iterators->second.globalIndexPair().first >= index->global());
│ │ │ │ -
883 }
│ │ │ │ -
884
│ │ │ │ -
885 // Add all remote indices positioned at global which were already present before calling sync
│ │ │ │ -
886 // to the message.
│ │ │ │ -
887 // Count how many remote indices we will send
│ │ │ │ -
888 int indices = 0;
│ │ │ │ -
889 bool knownRemote = false; // Is the remote process supposed to know this index?
│ │ │ │ -
890
│ │ │ │ -
891 for(auto iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; ++iterators)
│ │ │ │ -
892 {
│ │ │ │ -
893 std::pair<GlobalIndex,Attribute> p;
│ │ │ │ -
894 if (iterators->second.isNotAtEnd())
│ │ │ │ -
895 {
│ │ │ │ -
896 p = iterators->second.globalIndexPair();
│ │ │ │ -
897 }
│ │ │ │ -
898
│ │ │ │ -
899 if(iterators->second.isNotAtEnd() && iterators->second.isOld()
│ │ │ │ -
900 && iterators->second.globalIndexPair().first == index->global()) {
│ │ │ │ -
901 indices++;
│ │ │ │ -
902 if(destination == iterators->first)
│ │ │ │ -
903 knownRemote = true;
│ │ │ │ -
904 }
│ │ │ │ -
905 }
│ │ │ │ -
906
│ │ │ │ -
907 if(!knownRemote)
│ │ │ │ -
908 // We do not need to send any indices
│ │ │ │ -
909 continue;
│ │ │ │ -
910
│ │ │ │ -
911 Dune::dverb<<rank_<<": sending "<<indices<<" for index "<<index->global()<<" to "<<destination<<std::endl;
│ │ │ │ -
912
│ │ │ │ -
913
│ │ │ │ -
914 // Pack the global index, the attribute and the number
│ │ │ │ -
915 MPI_Pack(const_cast<GlobalIndex*>(&(index->global())), 1, MPITraits<GlobalIndex>::getType(), buffer, bufferSize, &bpos,
│ │ │ │ -
916 remoteIndices_.communicator());
│ │ │ │ -
917
│ │ │ │ -
918 char attr = index->local().attribute();
│ │ │ │ -
919 MPI_Pack(&attr, 1, MPI_CHAR, buffer, bufferSize, &bpos,
│ │ │ │ -
920 remoteIndices_.communicator());
│ │ │ │ -
921
│ │ │ │ -
922 // Pack the number of remote indices we send.
│ │ │ │ -
923 MPI_Pack(&indices, 1, MPI_INT, buffer, bufferSize, &bpos,
│ │ │ │ -
924 remoteIndices_.communicator());
│ │ │ │ -
925
│ │ │ │ -
926 // Pack the information about the remote indices
│ │ │ │ -
927 for(auto iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; ++iterators)
│ │ │ │ -
928 if(iterators->second.isNotAtEnd() && iterators->second.isOld()
│ │ │ │ -
929 && iterators->second.globalIndexPair().first == index->global()) {
│ │ │ │ -
930 int process = iterators->first;
│ │ │ │ -
931
│ │ │ │ -
932 ++pairs;
│ │ │ │ -
933 assert(pairs <= infoSend_[destination].pairs);
│ │ │ │ -
934 MPI_Pack(&process, 1, MPI_INT, buffer, bufferSize, &bpos,
│ │ │ │ -
935 remoteIndices_.communicator());
│ │ │ │ -
936 char attr2 = iterators->second.remoteIndex().attribute();
│ │ │ │ -
937
│ │ │ │ -
938 MPI_Pack(&attr2, 1, MPI_CHAR, buffer, bufferSize, &bpos,
│ │ │ │ -
939 remoteIndices_.communicator());
│ │ │ │ -
940 --indices;
│ │ │ │ -
941 }
│ │ │ │ -
942 assert(indices==0);
│ │ │ │ -
943 ++published;
│ │ │ │ -
944 Dune::dvverb<<" (publish="<<published<<", pairs="<<pairs<<")"<<std::endl;
│ │ │ │ -
945 assert(published <= infoSend_[destination].publish);
│ │ │ │ -
946 }
│ │ │ │ -
947
│ │ │ │ -
948 // Make sure we send all expected entries
│ │ │ │ -
949 assert(published == infoSend_[destination].publish);
│ │ │ │ -
950 assert(pairs == infoSend_[destination].pairs);
│ │ │ │ -
951 resetIteratorsMap();
│ │ │ │ -
952
│ │ │ │ -
953 Dune::dverb << rank_<<": Sending message of "<<bpos<<" bytes to "<<destination<<std::endl;
│ │ │ │ -
954
│ │ │ │ -
955 MPI_Issend(buffer, bpos, MPI_PACKED, destination, 345, remoteIndices_.communicator(),&request);
│ │ │ │ -
956 }
│ │ │ │ -
957
│ │ │ │ -
958 template<typename T>
│ │ │ │ -
959 inline void IndicesSyncer<T>::insertIntoRemoteIndexList(int process,
│ │ │ │ -
960 const std::pair<GlobalIndex,Attribute>& globalPair,
│ │ │ │ -
961 char attribute)
│ │ │ │ -
962 {
│ │ │ │ -
963 Dune::dverb<<"Inserting from "<<process<<" "<<globalPair.first<<", "<<
│ │ │ │ -
964 globalPair.second<<" "<<attribute<<std::endl;
│ │ │ │ -
965
│ │ │ │ -
966 resetIteratorsMap();
│ │ │ │ -
967
│ │ │ │ -
968 // There might be cases where there no remote indices for that process yet
│ │ │ │ -
969 typename IteratorsMap::iterator found = iteratorsMap_.find(process);
│ │ │ │ -
970
│ │ │ │ -
971 if( found == iteratorsMap_.end() ) {
│ │ │ │ -
972 Dune::dverb<<"Discovered new neighbour "<<process<<std::endl;
│ │ │ │ -
973 RemoteIndexList* rlist = new RemoteIndexList();
│ │ │ │ -
974 remoteIndices_.remoteIndices_.insert(std::make_pair(process,std::make_pair(rlist,rlist)));
│ │ │ │ -
975 Iterators iterators = Iterators(*rlist, globalMap_[process], oldMap_[process]);
│ │ │ │ -
976 found = iteratorsMap_.insert(std::make_pair(process, iterators)).first;
│ │ │ │ -
977 }
│ │ │ │ -
978
│ │ │ │ -
979 Iterators& iterators = found->second;
│ │ │ │ -
980
│ │ │ │ -
981 // Search for the remote index
│ │ │ │ -
982 while(iterators.isNotAtEnd() && iterators.globalIndexPair() < globalPair) {
│ │ │ │ -
983 // Increment all iterators
│ │ │ │ -
984 ++iterators;
│ │ │ │ -
985
│ │ │ │ -
986 }
│ │ │ │ -
987
│ │ │ │ -
988 if(iterators.isAtEnd() || iterators.globalIndexPair() != globalPair) {
│ │ │ │ -
989 // The entry is not yet known
│ │ │ │ -
990 // Insert in the list and do not change the first iterator.
│ │ │ │ -
991 iterators.insert(RemoteIndex(Attribute(attribute)),globalPair);
│ │ │ │ -
992 return;
│ │ │ │ -
993 }
│ │ │ │ -
994
│ │ │ │ -
995 // Global indices match
│ │ │ │ -
996 bool indexIsThere=false;
│ │ │ │ -
997 for(Iterators tmpIterators = iterators;
│ │ │ │ -
998 !tmpIterators.isAtEnd() && tmpIterators.globalIndexPair() == globalPair;
│ │ │ │ -
999 ++tmpIterators)
│ │ │ │ -
1000 //entry already exists with the same attribute
│ │ │ │ -
1001 if(tmpIterators.globalIndexPair().second == attribute) {
│ │ │ │ -
1002 indexIsThere=true;
│ │ │ │ -
1003 break;
│ │ │ │ -
1004 }
│ │ │ │ -
1005
│ │ │ │ -
1006 if(!indexIsThere)
│ │ │ │ -
1007 // The entry is not yet known
│ │ │ │ -
1008 // Insert in the list and do not change the first iterator.
│ │ │ │ -
1009 iterators.insert(RemoteIndex(Attribute(attribute)),globalPair);
│ │ │ │ -
1010 }
│ │ │ │ -
1011
│ │ │ │ -
1012 template<typename T>
│ │ │ │ -
1013 template<typename T1>
│ │ │ │ -
1014 void IndicesSyncer<T>::recvAndUnpack(T1& numberer, int hardSource, bool useHardSource)
│ │ │ │ -
1015 {
│ │ │ │ -
1016 const ParallelIndexSet& constIndexSet = indexSet_;
│ │ │ │ -
1017 auto iEnd = constIndexSet.end();
│ │ │ │ -
1018 auto index = constIndexSet.begin();
│ │ │ │ -
1019 int bpos = 0;
│ │ │ │ -
1020 int publish;
│ │ │ │ -
1021
│ │ │ │ -
1022 assert(checkReset());
│ │ │ │ -
1023
│ │ │ │ -
1024 MPI_Status status;
│ │ │ │ -
1025
│ │ │ │ -
1026 // We have to determine the message size and source before the receive
│ │ │ │ -
1027
│ │ │ │ -
1028 MPI_Probe(useHardSource ? hardSource : MPI_ANY_SOURCE, 345, remoteIndices_.communicator(), &status);
│ │ │ │ -
1029
│ │ │ │ -
1030 int source=status.MPI_SOURCE;
│ │ │ │ -
1031 int count;
│ │ │ │ -
1032 MPI_Get_count(&status, MPI_PACKED, &count);
│ │ │ │ -
1033
│ │ │ │ -
1034 Dune::dvverb<<rank_<<": Receiving message from "<< source<<" with "<<count<<" bytes"<<std::endl;
│ │ │ │ -
1035
│ │ │ │ -
1036 if(count>receiveBufferSize_) {
│ │ │ │ -
1037 receiveBufferSize_=count;
│ │ │ │ -
1038 delete[] receiveBuffer_;
│ │ │ │ -
1039 receiveBuffer_ = new char[receiveBufferSize_];
│ │ │ │ -
1040 }
│ │ │ │ -
1041
│ │ │ │ -
1042 MPI_Recv(receiveBuffer_, count, MPI_PACKED, source, 345, remoteIndices_.communicator(), &status);
│ │ │ │ -
1043
│ │ │ │ -
1044 // How many global entries were published?
│ │ │ │ -
1045 MPI_Unpack(receiveBuffer_, count, &bpos, &publish, 1, MPI_INT, remoteIndices_.communicator());
│ │ │ │ -
1046
│ │ │ │ -
1047 // Now unpack the remote indices and add them.
│ │ │ │ -
1048 while(publish>0) {
│ │ │ │ -
1049
│ │ │ │ -
1050 // Unpack information about the local index on the source process
│ │ │ │ -
1051 GlobalIndex global; // global index of the current entry
│ │ │ │ -
1052 char sourceAttribute; // Attribute on the source process
│ │ │ │ -
1053 int pairs;
│ │ │ │ -
1054
│ │ │ │ -
1055 MPI_Unpack(receiveBuffer_, count, &bpos, &global, 1, MPITraits<GlobalIndex>::getType(),
│ │ │ │ -
1056 remoteIndices_.communicator());
│ │ │ │ -
1057 MPI_Unpack(receiveBuffer_, count, &bpos, &sourceAttribute, 1, MPI_CHAR,
│ │ │ │ -
1058 remoteIndices_.communicator());
│ │ │ │ -
1059 MPI_Unpack(receiveBuffer_, count, &bpos, &pairs, 1, MPI_INT,
│ │ │ │ -
1060 remoteIndices_.communicator());
│ │ │ │ -
1061
│ │ │ │ -
1062 // Insert the entry on the remote process to our
│ │ │ │ -
1063 // remote index list
│ │ │ │ -
1064 SLList<std::pair<int,Attribute> > sourceAttributeList;
│ │ │ │ -
1065 sourceAttributeList.push_back(std::make_pair(source,Attribute(sourceAttribute)));
│ │ │ │ -
1066#ifndef NDEBUG
│ │ │ │ -
1067 bool foundSelf = false;
│ │ │ │ -
1068#endif
│ │ │ │ -
1069 Attribute myAttribute=Attribute();
│ │ │ │ -
1070
│ │ │ │ -
1071 // Unpack the remote indices
│ │ │ │ -
1072 for(; pairs>0; --pairs) {
│ │ │ │ -
1073 // Unpack the process id that knows the index
│ │ │ │ -
1074 int process;
│ │ │ │ -
1075 char attribute;
│ │ │ │ -
1076 MPI_Unpack(receiveBuffer_, count, &bpos, &process, 1, MPI_INT,
│ │ │ │ -
1077 remoteIndices_.communicator());
│ │ │ │ -
1078 // Unpack the attribute
│ │ │ │ -
1079 MPI_Unpack(receiveBuffer_, count, &bpos, &attribute, 1, MPI_CHAR,
│ │ │ │ -
1080 remoteIndices_.communicator());
│ │ │ │ -
1081
│ │ │ │ -
1082 if(process==rank_) {
│ │ │ │ -
1083#ifndef NDEBUG
│ │ │ │ -
1084 foundSelf=true;
│ │ │ │ -
1085#endif
│ │ │ │ -
1086 myAttribute=Attribute(attribute);
│ │ │ │ -
1087 // Now we know the local attribute of the global index
│ │ │ │ -
1088 //Only add the index if it is unknown.
│ │ │ │ -
1089 // Do we know that global index already?
│ │ │ │ -
1090 auto pos = std::lower_bound(index, iEnd, IndexPair(global));
│ │ │ │ -
1091
│ │ │ │ -
1092 if(pos == iEnd || pos->global() != global) {
│ │ │ │ -
1093 // no entry with this global index
│ │ │ │ -
1094 indexSet_.add(global,
│ │ │ │ -
1095 ParallelLocalIndex<Attribute>(numberer(global),
│ │ │ │ -
1096 myAttribute, true));
│ │ │ │ -
1097 Dune::dvverb << "Adding "<<global<<" "<<myAttribute<<std::endl;
│ │ │ │ -
1098 continue;
│ │ │ │ -
1099 }
│ │ │ │ -
1100
│ │ │ │ -
1101 // because of above the global indices match. Add only if the attribute is different
│ │ │ │ -
1102 bool indexIsThere = false;
│ │ │ │ -
1103 index=pos;
│ │ │ │ -
1104
│ │ │ │ -
1105 for(; pos->global()==global; ++pos)
│ │ │ │ -
1106 if(pos->local().attribute() == myAttribute) {
│ │ │ │ -
1107 Dune::dvverb<<"found "<<global<<" "<<myAttribute<<std::endl;
│ │ │ │ -
1108 indexIsThere = true;
│ │ │ │ -
1109 break;
│ │ │ │ -
1110 }
│ │ │ │ -
1111
│ │ │ │ -
1112 if(!indexIsThere) {
│ │ │ │ -
1113 indexSet_.add(global,
│ │ │ │ -
1114 ParallelLocalIndex<Attribute>(numberer(global),
│ │ │ │ -
1115 myAttribute, true));
│ │ │ │ -
1116 Dune::dvverb << "Adding "<<global<<" "<<myAttribute<<std::endl;
│ │ │ │ -
1117 }
│ │ │ │ -
1118
│ │ │ │ -
1119 }else{
│ │ │ │ -
1120 sourceAttributeList.push_back(std::make_pair(process,Attribute(attribute)));
│ │ │ │ -
1121 }
│ │ │ │ -
1122 }
│ │ │ │ -
1123 assert(foundSelf);
│ │ │ │ -
1124 // Insert remote indices
│ │ │ │ -
1125 typedef typename SLList<std::pair<int,Attribute> >::const_iterator Iter;
│ │ │ │ -
1126 for(Iter i=sourceAttributeList.begin(), end=sourceAttributeList.end();
│ │ │ │ -
1127 i!=end; ++i)
│ │ │ │ -
1128 insertIntoRemoteIndexList(i->first, std::make_pair(global, myAttribute),
│ │ │ │ -
1129 i->second);
│ │ │ │ -
1130 --publish;
│ │ │ │ -
1131 }
│ │ │ │ -
1132
│ │ │ │ -
1133 resetIteratorsMap();
│ │ │ │ -
1134 }
│ │ │ │ -
1135
│ │ │ │ -
1136 template<typename T>
│ │ │ │ -
1137 void IndicesSyncer<T>::resetIteratorsMap(){
│ │ │ │ -
1138
│ │ │ │ -
1139 // Reset iterators in all tuples.
│ │ │ │ -
1140 const auto remoteEnd = remoteIndices_.remoteIndices_.end();
│ │ │ │ -
1141 auto iterators = iteratorsMap_.begin();
│ │ │ │ -
1142 auto global = globalMap_.begin();
│ │ │ │ -
1143 auto added = oldMap_.begin();
│ │ │ │ -
1144
│ │ │ │ -
1145 for(auto remote = remoteIndices_.remoteIndices_.begin();
│ │ │ │ -
1146 remote != remoteEnd; ++remote, ++global, ++added, ++iterators) {
│ │ │ │ -
1147 iterators->second.reset(*(remote->second.first), global->second, added->second);
│ │ │ │ -
1148 }
│ │ │ │ -
1149 }
│ │ │ │ -
1150
│ │ │ │ -
1151 template<typename T>
│ │ │ │ -
1152 bool IndicesSyncer<T>::checkReset(const Iterators& iterators, RemoteIndexList& rList, GlobalIndexList& gList,
│ │ │ │ -
1153 BoolList& bList){
│ │ │ │ -
1154
│ │ │ │ -
1155 if(std::get<0>(iterators.iterators_) != rList.begin())
│ │ │ │ -
1156 return false;
│ │ │ │ -
1157 if(std::get<1>(iterators.iterators_) != gList.begin())
│ │ │ │ -
1158 return false;
│ │ │ │ -
1159 if(std::get<2>(iterators.iterators_) != bList.begin())
│ │ │ │ -
1160 return false;
│ │ │ │ -
1161 return true;
│ │ │ │ -
1162 }
│ │ │ │ -
1163
│ │ │ │ -
1164
│ │ │ │ -
1165 template<typename T>
│ │ │ │ -
1166 bool IndicesSyncer<T>::checkReset(){
│ │ │ │ -
1167
│ │ │ │ -
1168 // Reset iterators in all tuples.
│ │ │ │ -
1169 const auto remoteEnd = remoteIndices_.remoteIndices_.end();
│ │ │ │ -
1170 auto iterators = iteratorsMap_.begin();
│ │ │ │ -
1171 auto global = globalMap_.begin();
│ │ │ │ -
1172 auto added = oldMap_.begin();
│ │ │ │ -
1173 bool ret = true;
│ │ │ │ -
1174
│ │ │ │ -
1175 for(auto remote = remoteIndices_.remoteIndices_.begin();
│ │ │ │ -
1176 remote != remoteEnd; ++remote, ++global, ++added, ++iterators) {
│ │ │ │ -
1177 if(!checkReset(iterators->second, *(remote->second.first), global->second,
│ │ │ │ -
1178 added->second))
│ │ │ │ -
1179 ret=false;
│ │ │ │ -
1180 }
│ │ │ │ -
1181 return ret;
│ │ │ │ -
1182 }
│ │ │ │ -
1183}
│ │ │ │ -
1184
│ │ │ │ -
1185#endif // HAVE_MPI
│ │ │ │ -
1186#endif // DUNE_COMMON_PARALLEL_INDICESSYNCER_HH
│ │ │ │ -
Provides a map between global and local indices.
│ │ │ │ -
Classes describing a distributed indexset.
│ │ │ │ -
Standard Dune debug streams.
│ │ │ │ -
Implements a singly linked list together with the necessary iterators.
│ │ │ │ -
void push_back(const MemberType &item)
Add a new entry to the end of the list.
Definition sllist.hh:643
│ │ │ │ -
SLListIterator< T, A > iterator
The mutable iterator of the list.
Definition sllist.hh:69
│ │ │ │ -
iterator end()
Get an iterator pointing to the end of the list.
Definition sllist.hh:774
│ │ │ │ -
ModifyIterator beginModify()
Get an iterator capable of deleting and inserting elements.
Definition sllist.hh:787
│ │ │ │ -
SLListConstIterator< RemoteIndex, Allocator > const_iterator
The constant iterator of the list.
Definition sllist.hh:74
│ │ │ │ -
SLListModifyIterator< T, A > ModifyIterator
The type of the iterator capable of deletion and insertion.
Definition sllist.hh:103
│ │ │ │ -
iterator begin()
Get an iterator pointing to the first element in the list.
Definition sllist.hh:762
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator<(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition iteratorfacades.hh:638
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition iteratorfacades.hh:238
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition iteratorfacades.hh:260
│ │ │ │ -
Iterators()
Default constructor.
Definition indicessyncer.hh:563
│ │ │ │ -
Dune::RemoteIndices< ParallelIndexSet > RemoteIndices
Type of the remote indices.
Definition indicessyncer.hh:63
│ │ │ │ -
bool isOld() const
Was this entry already in the remote index list before the sync process?
Definition indicessyncer.hh:600
│ │ │ │ -
int publish
The number of indices we publish for the other process.
Definition indicessyncer.hh:132
│ │ │ │ -
void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &globalMap, RemoteIndices< T, A1 > &remoteIndices, const T &indexSet)
Repair the pointers to the local indices in the remote indices.
Definition indicessyncer.hh:495
│ │ │ │ -
bool isAtEnd() const
Are we at the end of the list?
Definition indicessyncer.hh:622
│ │ │ │ -
MPI_Comm communicator() const
Get the mpi communicator used.
Definition remoteindices.hh:1695
│ │ │ │ -
ParallelIndexSet::GlobalIndex GlobalIndex
Type of the global index used in the index set.
Definition indicessyncer.hh:55
│ │ │ │ -
int pairs
The number of pairs (attribute and process number) we publish to the neighbour process.
Definition indicessyncer.hh:137
│ │ │ │ -
const_iterator end() const
Get an iterator over all remote index lists.
Definition remoteindices.hh:1528
│ │ │ │ -
Attribute & attribute() const
│ │ │ │ -
Iterators & operator++()
Increment all iterators.
Definition indicessyncer.hh:568
│ │ │ │ -
ParallelIndexSet::LocalIndex::Attribute Attribute
Type of the attribute used in the index set.
Definition indicessyncer.hh:58
│ │ │ │ -
std::pair< GlobalIndex, Attribute > & globalIndexPair() const
Get the global index of the remote index at current position.
Definition indicessyncer.hh:594
│ │ │ │ -
IndicesSyncer(ParallelIndexSet &indexSet, RemoteIndices &remoteIndices)
Constructor.
Definition indicessyncer.hh:544
│ │ │ │ -
void reset(RemoteIndexList &remoteIndices, GlobalIndexList &globalIndices, BoolList &booleans)
Reset all the underlying iterators.
Definition indicessyncer.hh:606
│ │ │ │ -
std::size_t operator()(const GlobalIndex &global)
Provide the local index, always std::numeric_limits<size_t>::max()
Definition indicessyncer.hh:151
│ │ │ │ -
T ParallelIndexSet
The type of the index set.
Definition indicessyncer.hh:49
│ │ │ │ -
bool isNotAtEnd() const
Are we not at the end of the list?
Definition indicessyncer.hh:616
│ │ │ │ -
int neighbours() const
Get the number of processors we share indices with.
Definition remoteindices.hh:1445
│ │ │ │ -
TG GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition indexset.hh:226
│ │ │ │ -
void storeGlobalIndicesOfRemoteIndices(std::map< int, SLList< std::pair< typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &globalMap, const RemoteIndices< T, A1 > &remoteIndices)
Stores the corresponding global indices of the remote index information.
Definition indicessyncer.hh:469
│ │ │ │ -
void sync()
Sync the index set.
Definition indicessyncer.hh:736
│ │ │ │ -
int seqNo() const
Get the internal sequence number.
│ │ │ │ -
ParallelIndexSet::IndexPair IndexPair
The type of the index pair.
Definition indicessyncer.hh:52
│ │ │ │ -
const_iterator begin() const
Get an iterator over all remote index lists.
Definition remoteindices.hh:1521
│ │ │ │ -
RemoteIndex & remoteIndex() const
Get the remote index at current position.
Definition indicessyncer.hh:587
│ │ │ │ -
MessageInformation()
Definition indicessyncer.hh:128
│ │ │ │ -
void insert(const RemoteIndex &index, const std::pair< GlobalIndex, Attribute > &global)
Insert a new remote index to the underlying remote index list.
Definition indicessyncer.hh:577
│ │ │ │ -
DVVerbType dvverb(std::cout)
stream for very verbose output.
Definition stdstreams.hh:96
│ │ │ │ -
DVerbType dverb(std::cout)
Singleton of verbose debug stream.
Definition stdstreams.hh:117
│ │ │ │ +
51#endif
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
static MPI_Datatype getType()
Definition mpitraits.hh:48
│ │ │ │ -
A pair consisting of a global and local index.
Definition indexset.hh:85
│ │ │ │ -
Class for recomputing missing indices of a distributed index set.
Definition indicessyncer.hh:45
│ │ │ │ -
An index present on the local process with an additional attribute flag.
Definition plocalindex.hh:52
│ │ │ │ -
The indices present on remote processes.
Definition remoteindices.hh:190
│ │ │ │ -
typename std::allocator_traits< A >::template rebind_alloc< RemoteIndex > Allocator
The type of the allocator for the remote index list.
Definition remoteindices.hh:238
│ │ │ │ -
Information about an index residing on another processor.
Definition remoteindices.hh:74
│ │ │ │ -
A mutable iterator for the SLList.
Definition sllist.hh:271
│ │ │ │ -
A single linked list.
Definition sllist.hh:44
│ │ │ │ +
Precisions for calculations with FieldMatrix and FieldVector.
Definition precision.hh:25
│ │ │ │ +
static ctype absolute_limit()
return threshold to declare matrix singular
Definition precision.hh:28
│ │ │ │ +
static void set_absolute_limit(ctype absthres)
set singular threshold
Definition precision.hh:34
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,1211 +1,60 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -indicessyncer.hh │ │ │ │ │ +precision.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PARALLEL_INDICESSYNCER_HH │ │ │ │ │ -6#define DUNE_COMMON_PARALLEL_INDICESSYNCER_HH │ │ │ │ │ +5#ifndef DUNE_PRECISION_HH │ │ │ │ │ +6#define DUNE_PRECISION_HH │ │ │ │ │ 7 │ │ │ │ │ -8#if HAVE_MPI │ │ │ │ │ -9 │ │ │ │ │ -10#include │ │ │ │ │ -11#include │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17 │ │ │ │ │ -18#include │ │ │ │ │ -19 │ │ │ │ │ -20#include │ │ │ │ │ -21#include │ │ │ │ │ -22#include │ │ │ │ │ -23#include │ │ │ │ │ -24 │ │ │ │ │ -25namespace Dune │ │ │ │ │ -26{ │ │ │ │ │ -43 template │ │ │ │ │ -44 class IndicesSyncer │ │ │ │ │ -45 { │ │ │ │ │ -46 public: │ │ │ │ │ -47 │ │ │ │ │ -49 typedef T ParallelIndexSet; │ │ │ │ │ +12#include │ │ │ │ │ +13 │ │ │ │ │ +14namespace Dune { │ │ │ │ │ +15 │ │ │ │ │ +24 template │ │ │ │ │ +25 class FMatrixPrecision { │ │ │ │ │ +26 public: │ │ │ │ │ +28 static ctype absolute_limit () │ │ │ │ │ +29 { │ │ │ │ │ +30 return _absolute; │ │ │ │ │ +31 } │ │ │ │ │ +32 │ │ │ │ │ +34 static void set_absolute_limit (ctype absthres) │ │ │ │ │ +35 { │ │ │ │ │ +36 _absolute = absthres; │ │ │ │ │ +37 } │ │ │ │ │ +38 │ │ │ │ │ +39 private: │ │ │ │ │ +40 // just to demonstrate some state information │ │ │ │ │ +41 static ctype _absolute; │ │ │ │ │ +42 }; │ │ │ │ │ +43 │ │ │ │ │ +44 template │ │ │ │ │ +45 ctype FMatrixPrecision::_absolute = 1E-80; │ │ │ │ │ +46 │ │ │ │ │ +49} // end namespace │ │ │ │ │ 50 │ │ │ │ │ -52 typedef typename ParallelIndexSet::IndexPair IndexPair; │ │ │ │ │ -53 │ │ │ │ │ -55 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex; │ │ │ │ │ -56 │ │ │ │ │ -58 typedef typename ParallelIndexSet::LocalIndex::Attribute Attribute; │ │ │ │ │ -59 │ │ │ │ │ -63 typedef Dune::RemoteIndices RemoteIndices; │ │ │ │ │ -64 │ │ │ │ │ -74 IndicesSyncer(ParallelIndexSet& indexSet, │ │ │ │ │ -75 RemoteIndices& remoteIndices); │ │ │ │ │ -76 │ │ │ │ │ -86 void sync(); │ │ │ │ │ -87 │ │ │ │ │ -100 template │ │ │ │ │ -101 void sync(T1& numberer, bool useFixedOrder = false); │ │ │ │ │ -102 │ │ │ │ │ -103 private: │ │ │ │ │ -104 │ │ │ │ │ -106 ParallelIndexSet& indexSet_; │ │ │ │ │ -107 │ │ │ │ │ -109 RemoteIndices& remoteIndices_; │ │ │ │ │ -110 │ │ │ │ │ -112 char** sendBuffers_; │ │ │ │ │ -113 │ │ │ │ │ -115 char* receiveBuffer_; │ │ │ │ │ -116 │ │ │ │ │ -118 std::size_t* sendBufferSizes_; │ │ │ │ │ -119 │ │ │ │ │ -121 int receiveBufferSize_; // int because of MPI │ │ │ │ │ -122 │ │ │ │ │ -126 struct MessageInformation │ │ │ │ │ -127 { │ │ │ │ │ -128 MessageInformation() │ │ │ │ │ -129 : publish(), pairs() │ │ │ │ │ -130 {} │ │ │ │ │ -132 int publish; │ │ │ │ │ -137 int pairs; │ │ │ │ │ -138 }; │ │ │ │ │ -139 │ │ │ │ │ -143 class DefaultNumberer │ │ │ │ │ -144 { │ │ │ │ │ -145 public: │ │ │ │ │ -151 std::size_t operator()([[maybe_unused]] const GlobalIndex& global) │ │ │ │ │ -152 { │ │ │ │ │ -153 return std::numeric_limits::max(); │ │ │ │ │ -154 } │ │ │ │ │ -155 }; │ │ │ │ │ -156 │ │ │ │ │ -158 MPI_Datatype datatype_; │ │ │ │ │ -159 │ │ │ │ │ -161 int rank_; │ │ │ │ │ -162 │ │ │ │ │ -167 typedef SLList, typename RemoteIndices:: │ │ │ │ │ -Allocator> GlobalIndexList; │ │ │ │ │ -168 │ │ │ │ │ -170 typedef typename GlobalIndexList::ModifyIterator GlobalIndexModifier; │ │ │ │ │ -171 │ │ │ │ │ -175 typedef typename SLList:: │ │ │ │ │ -iterator │ │ │ │ │ -176 GlobalIndexIterator; │ │ │ │ │ -177 │ │ │ │ │ -179 typedef std::map GlobalIndicesMap; │ │ │ │ │ -180 │ │ │ │ │ -189 GlobalIndicesMap globalMap_; │ │ │ │ │ -190 │ │ │ │ │ -194 typedef SLList BoolList; │ │ │ │ │ -195 │ │ │ │ │ -199 typedef typename BoolList::iterator BoolIterator; │ │ │ │ │ -200 │ │ │ │ │ -202 typedef typename BoolList::ModifyIterator BoolListModifier; │ │ │ │ │ -203 │ │ │ │ │ -205 typedef std::map BoolMap; │ │ │ │ │ -206 │ │ │ │ │ -211 BoolMap oldMap_; │ │ │ │ │ -212 │ │ │ │ │ -214 std::map infoSend_; │ │ │ │ │ -215 │ │ │ │ │ -217 typedef typename RemoteIndices::RemoteIndexList RemoteIndexList; │ │ │ │ │ -218 │ │ │ │ │ -220 typedef typename RemoteIndexList::ModifyIterator RemoteIndexModifier; │ │ │ │ │ -221 │ │ │ │ │ -223 typedef Dune::RemoteIndex RemoteIndex; │ │ │ │ │ -224 │ │ │ │ │ -226 typedef typename RemoteIndexList::iterator RemoteIndexIterator; │ │ │ │ │ -227 │ │ │ │ │ -229 typedef typename RemoteIndexList::const_iterator ConstRemoteIndexIterator; │ │ │ │ │ -230 │ │ │ │ │ -232 typedef std:: │ │ │ │ │ -tuple IteratorTuple; │ │ │ │ │ -234 │ │ │ │ │ -242 class Iterators │ │ │ │ │ -243 { │ │ │ │ │ -244 friend class IndicesSyncer; │ │ │ │ │ -245 public: │ │ │ │ │ -255 Iterators(RemoteIndexList& remoteIndices, GlobalIndexList& globalIndices, │ │ │ │ │ -256 BoolList& booleans); │ │ │ │ │ -257 │ │ │ │ │ -261 Iterators(); │ │ │ │ │ -262 │ │ │ │ │ -266 Iterators& operator++(); │ │ │ │ │ -267 │ │ │ │ │ -273 void insert(const RemoteIndex& index, │ │ │ │ │ -274 const std::pair& global); │ │ │ │ │ -275 │ │ │ │ │ -280 RemoteIndex& remoteIndex() const; │ │ │ │ │ -281 │ │ │ │ │ -286 std::pair& globalIndexPair() const; │ │ │ │ │ -287 │ │ │ │ │ -288 Attribute& attribute() const; │ │ │ │ │ -289 │ │ │ │ │ -295 bool isOld() const; │ │ │ │ │ -296 │ │ │ │ │ -306 void reset(RemoteIndexList& remoteIndices, GlobalIndexList& globalIndices, │ │ │ │ │ -307 BoolList& booleans); │ │ │ │ │ -308 │ │ │ │ │ -314 bool isNotAtEnd() const; │ │ │ │ │ -315 │ │ │ │ │ -321 bool isAtEnd() const; │ │ │ │ │ -322 │ │ │ │ │ -323 private: │ │ │ │ │ -333 IteratorTuple iterators_; │ │ │ │ │ -334 }; │ │ │ │ │ -335 │ │ │ │ │ -337 typedef std::map IteratorsMap; │ │ │ │ │ -338 │ │ │ │ │ -350 IteratorsMap iteratorsMap_; │ │ │ │ │ -351 │ │ │ │ │ -353 void calculateMessageSizes(); │ │ │ │ │ -354 │ │ │ │ │ -362 void packAndSend(int destination, char* buffer, std::size_t bufferSize, │ │ │ │ │ -MPI_Request& req); │ │ │ │ │ -363 │ │ │ │ │ -370 template │ │ │ │ │ -371 void recvAndUnpack(T1& numberer, int hardSource, bool useHardSource); │ │ │ │ │ -372 │ │ │ │ │ -376 void registerMessageDatatype(); │ │ │ │ │ -377 │ │ │ │ │ -381 void insertIntoRemoteIndexList(int process, │ │ │ │ │ -382 const std::pair& global, │ │ │ │ │ -383 char attribute); │ │ │ │ │ -384 │ │ │ │ │ -388 void resetIteratorsMap(); │ │ │ │ │ -389 │ │ │ │ │ -394 bool checkReset(); │ │ │ │ │ -395 │ │ │ │ │ -404 bool checkReset(const Iterators& iterators, RemoteIndexList& rlist, │ │ │ │ │ -GlobalIndexList& gList, │ │ │ │ │ -405 BoolList& bList); │ │ │ │ │ -406 }; │ │ │ │ │ -407 │ │ │ │ │ -408 template │ │ │ │ │ -409 bool operator<(const IndexPair >& i1, │ │ │ │ │ -410 const std::pair& i2) │ │ │ │ │ -411 { │ │ │ │ │ -412 return i1.global() < i2.first || │ │ │ │ │ -413 (i1.global() == i2.first && i1.local().attribute() │ │ │ │ │ -417 bool operator<(const std::pair& i1, │ │ │ │ │ -418 const IndexPair >& i2) │ │ │ │ │ -419 { │ │ │ │ │ -420 return i1.first < i2.global() || │ │ │ │ │ -421 (i1.first == i2.global() && i1.second │ │ │ │ │ -425 bool operator==(const IndexPair >& i1, │ │ │ │ │ -426 const std::pair& i2) │ │ │ │ │ -427 { │ │ │ │ │ -428 return (i1.global() == i2.first && i1.local().attribute()==i2.second); │ │ │ │ │ -429 } │ │ │ │ │ -430 │ │ │ │ │ -431 template │ │ │ │ │ -432 bool operator!=(const IndexPair >& i1, │ │ │ │ │ -433 const std::pair& i2) │ │ │ │ │ -434 { │ │ │ │ │ -435 return (i1.global() != i2.first || i1.local().attribute()!=i2.second); │ │ │ │ │ -436 } │ │ │ │ │ -437 │ │ │ │ │ -438 template │ │ │ │ │ -439 bool operator==(const std::pair& i2, │ │ │ │ │ -440 const IndexPair >& i1) │ │ │ │ │ -441 { │ │ │ │ │ -442 return (i1.global() == i2.first && i1.local().attribute()==i2.second); │ │ │ │ │ -443 } │ │ │ │ │ -444 │ │ │ │ │ -445 template │ │ │ │ │ -446 bool operator!=(const std::pair& i2, │ │ │ │ │ -447 const IndexPair >& i1) │ │ │ │ │ -448 { │ │ │ │ │ -449 return (i1.global() != i2.first || i1.local().attribute()!=i2.second); │ │ │ │ │ -450 } │ │ │ │ │ -451 │ │ │ │ │ -468 template │ │ │ │ │ -469 void storeGlobalIndicesOfRemoteIndices(std::map,A> >& │ │ │ │ │ -globalMap, │ │ │ │ │ -470 const RemoteIndices& remoteIndices) │ │ │ │ │ -471 { │ │ │ │ │ -472 for(auto remote = remoteIndices.begin(), end =remoteIndices.end(); remote │ │ │ │ │ -!= end; ++remote) { │ │ │ │ │ -473 typedef typename RemoteIndices::RemoteIndexList RemoteIndexList; │ │ │ │ │ -474 typedef SLList,A> GlobalIndexList; │ │ │ │ │ -475 GlobalIndexList& global = globalMap[remote->first]; │ │ │ │ │ -476 RemoteIndexList& rList = *(remote->second.first); │ │ │ │ │ -477 │ │ │ │ │ -478 for(auto index = rList.begin(), riEnd = rList.end(); │ │ │ │ │ -479 index != riEnd; ++index) { │ │ │ │ │ -480 global.push_back(std::make_pair(index->localIndexPair().global(), │ │ │ │ │ -481 index->localIndexPair().local().attribute())); │ │ │ │ │ -482 } │ │ │ │ │ -483 } │ │ │ │ │ -484 } │ │ │ │ │ -485 │ │ │ │ │ -494 template │ │ │ │ │ -495 inline void repairLocalIndexPointers(std::map,A> >& globalMap, │ │ │ │ │ -498 RemoteIndices& remoteIndices, │ │ │ │ │ -499 const T& indexSet) │ │ │ │ │ -500 { │ │ │ │ │ -501 assert(globalMap.size()==static_cast(remoteIndices.neighbours │ │ │ │ │ -())); │ │ │ │ │ -502 // Repair pointers to index set in remote indices. │ │ │ │ │ -503 auto global = globalMap.begin(); │ │ │ │ │ -504 auto end = remoteIndices.remoteIndices_.end(); │ │ │ │ │ -505 │ │ │ │ │ -506 for(auto remote = remoteIndices.remoteIndices_.begin(); remote != end; │ │ │ │ │ -++remote, ++global) { │ │ │ │ │ -507 assert(remote->first==global->first); │ │ │ │ │ -508 assert(remote->second.first->size() == global->second.size()); │ │ │ │ │ -509 │ │ │ │ │ -510 auto riEnd = remote->second.first->end(); │ │ │ │ │ -511 auto rIndex = remote->second.first->begin(); │ │ │ │ │ -512 auto gIndex = global->second.begin(); │ │ │ │ │ -513 auto index = indexSet.begin(); │ │ │ │ │ -514 │ │ │ │ │ -515 assert(rIndex==riEnd || gIndex != global->second.end()); │ │ │ │ │ -516 while(rIndex != riEnd) { │ │ │ │ │ -517 // Search for the index in the set. │ │ │ │ │ -518 assert(gIndex != global->second.end()); │ │ │ │ │ -519 │ │ │ │ │ -520 while(!(index->global() == gIndex->first │ │ │ │ │ -521 && index->local().attribute() == gIndex->second)) { │ │ │ │ │ -522 ++index; │ │ │ │ │ -523 // this is only needed for ALU, where there may exist │ │ │ │ │ -524 // more entries with the same global index in the remote index set │ │ │ │ │ -525 // than in the index set │ │ │ │ │ -526 if (index->global() > gIndex->first) { │ │ │ │ │ -527 index=indexSet.begin(); │ │ │ │ │ -528 } │ │ │ │ │ -529 } │ │ │ │ │ -530 │ │ │ │ │ -531 assert(index != indexSet.end() && *index == *gIndex); │ │ │ │ │ -532 │ │ │ │ │ -533 rIndex->localIndex_ = &(*index); │ │ │ │ │ -534 ++index; │ │ │ │ │ -535 ++rIndex; │ │ │ │ │ -536 ++gIndex; │ │ │ │ │ -537 } │ │ │ │ │ -538 } │ │ │ │ │ -539 remoteIndices.sourceSeqNo_ = remoteIndices.source_->seqNo(); │ │ │ │ │ -540 remoteIndices.destSeqNo_ = remoteIndices.target_->seqNo(); │ │ │ │ │ -541 } │ │ │ │ │ -542 │ │ │ │ │ -543 template │ │ │ │ │ -544 IndicesSyncer::IndicesSyncer(ParallelIndexSet& indexSet, │ │ │ │ │ -545 RemoteIndices& remoteIndices) │ │ │ │ │ -546 : indexSet_(indexSet), remoteIndices_(remoteIndices) │ │ │ │ │ -547 { │ │ │ │ │ -548 // index sets must match. │ │ │ │ │ -549 assert(remoteIndices.source_ == remoteIndices.target_); │ │ │ │ │ -550 assert(remoteIndices.source_ == &indexSet); │ │ │ │ │ -551 MPI_Comm_rank(remoteIndices_.communicator(), &rank_); │ │ │ │ │ -552 } │ │ │ │ │ -553 │ │ │ │ │ -554 template │ │ │ │ │ -555 IndicesSyncer::Iterators::Iterators(RemoteIndexList& remoteIndices, │ │ │ │ │ -556 GlobalIndexList& globalIndices, │ │ │ │ │ -557 BoolList& booleans) │ │ │ │ │ -558 : iterators_(remoteIndices.beginModify(), globalIndices.beginModify(), │ │ │ │ │ -559 booleans.beginModify(), remoteIndices.end()) │ │ │ │ │ -560 { } │ │ │ │ │ -561 │ │ │ │ │ -562 template │ │ │ │ │ -563 IndicesSyncer::Iterators::Iterators() │ │ │ │ │ -564 : iterators_() │ │ │ │ │ -565 {} │ │ │ │ │ -566 │ │ │ │ │ -567 template │ │ │ │ │ -568 inline typename IndicesSyncer::Iterators& IndicesSyncer::Iterators:: │ │ │ │ │ -operator++() │ │ │ │ │ -569 { │ │ │ │ │ -570 ++(std::get<0>(iterators_)); │ │ │ │ │ -571 ++(std::get<1>(iterators_)); │ │ │ │ │ -572 ++(std::get<2>(iterators_)); │ │ │ │ │ -573 return *this; │ │ │ │ │ -574 } │ │ │ │ │ -575 │ │ │ │ │ -576 template │ │ │ │ │ -577 inline void IndicesSyncer::Iterators::insert(const RemoteIndex & index, │ │ │ │ │ -578 const std::pair& global) │ │ │ │ │ -579 { │ │ │ │ │ -580 std::get<0>(iterators_).insert(index); │ │ │ │ │ -581 std::get<1>(iterators_).insert(global); │ │ │ │ │ -582 std::get<2>(iterators_).insert(false); │ │ │ │ │ -583 } │ │ │ │ │ -584 │ │ │ │ │ -585 template │ │ │ │ │ -586 inline typename IndicesSyncer::RemoteIndex& │ │ │ │ │ -587 IndicesSyncer::Iterators::remoteIndex() const │ │ │ │ │ -588 { │ │ │ │ │ -589 return *(std::get<0>(iterators_)); │ │ │ │ │ -590 } │ │ │ │ │ -591 │ │ │ │ │ -592 template │ │ │ │ │ -593 inline std::pair::GlobalIndex,typename │ │ │ │ │ -IndicesSyncer::Attribute>& │ │ │ │ │ -594 IndicesSyncer::Iterators::globalIndexPair() const │ │ │ │ │ -595 { │ │ │ │ │ -596 return *(std::get<1>(iterators_)); │ │ │ │ │ -597 } │ │ │ │ │ -598 │ │ │ │ │ -599 template │ │ │ │ │ -600 inline bool IndicesSyncer::Iterators::isOld() const │ │ │ │ │ -601 { │ │ │ │ │ -602 return *(std::get<2>(iterators_)); │ │ │ │ │ -603 } │ │ │ │ │ -604 │ │ │ │ │ -605 template │ │ │ │ │ -606 inline void IndicesSyncer::Iterators::reset(RemoteIndexList& │ │ │ │ │ -remoteIndices, │ │ │ │ │ -607 GlobalIndexList& globalIndices, │ │ │ │ │ -608 BoolList& booleans) │ │ │ │ │ -609 { │ │ │ │ │ -610 std::get<0>(iterators_) = remoteIndices.beginModify(); │ │ │ │ │ -611 std::get<1>(iterators_) = globalIndices.beginModify(); │ │ │ │ │ -612 std::get<2>(iterators_) = booleans.beginModify(); │ │ │ │ │ -613 } │ │ │ │ │ -614 │ │ │ │ │ -615 template │ │ │ │ │ -616 inline bool IndicesSyncer::Iterators::isNotAtEnd() const │ │ │ │ │ -617 { │ │ │ │ │ -618 return std::get<0>(iterators_) != std::get<3>(iterators_); │ │ │ │ │ -619 } │ │ │ │ │ -620 │ │ │ │ │ -621 template │ │ │ │ │ -622 inline bool IndicesSyncer::Iterators::isAtEnd() const │ │ │ │ │ -623 { │ │ │ │ │ -624 return std::get<0>(iterators_) == std::get<3>(iterators_); │ │ │ │ │ -625 } │ │ │ │ │ -626 │ │ │ │ │ -627 template │ │ │ │ │ -628 void IndicesSyncer::registerMessageDatatype() │ │ │ │ │ -629 { │ │ │ │ │ -630 MPI_Datatype type[2] = {MPI_INT, MPI_INT}; │ │ │ │ │ -631 int blocklength[2] = {1,1}; │ │ │ │ │ -632 MPI_Aint displacement[2]; │ │ │ │ │ -633 MPI_Aint base; │ │ │ │ │ -634 │ │ │ │ │ -635 // Compute displacement │ │ │ │ │ -636 MessageInformation message; │ │ │ │ │ -637 │ │ │ │ │ -638 MPI_Get_address( &(message.publish), displacement); │ │ │ │ │ -639 MPI_Get_address( &(message.pairs), displacement+1); │ │ │ │ │ -640 │ │ │ │ │ -641 // Make the displacement relative │ │ │ │ │ -642 MPI_Get_address(&message, &base); │ │ │ │ │ -643 displacement[0] -= base; │ │ │ │ │ -644 displacement[1] -= base; │ │ │ │ │ -645 │ │ │ │ │ -646 MPI_Type_create_struct( 2, blocklength, displacement, type, &datatype_); │ │ │ │ │ -647 MPI_Type_commit(&datatype_); │ │ │ │ │ -648 } │ │ │ │ │ -649 │ │ │ │ │ -650 template │ │ │ │ │ -651 void IndicesSyncer::calculateMessageSizes() │ │ │ │ │ -652 { │ │ │ │ │ -653 auto iEnd = indexSet_.end(); │ │ │ │ │ -654 auto collIter = remoteIndices_.template iterator(); │ │ │ │ │ -655 │ │ │ │ │ -656 for(auto index = indexSet_.begin(); index != iEnd; ++index) { │ │ │ │ │ -657 collIter.advance(index->global(), index->local().attribute()); │ │ │ │ │ -658 if(collIter.empty()) │ │ │ │ │ -659 break; │ │ │ │ │ -660 int knownRemote=0; │ │ │ │ │ -661 auto end = collIter.end(); │ │ │ │ │ -662 │ │ │ │ │ -663 // Count the remote indices we know. │ │ │ │ │ -664 for(auto valid = collIter.begin(); valid != end; ++valid) { │ │ │ │ │ -665 ++knownRemote; │ │ │ │ │ -666 } │ │ │ │ │ -667 │ │ │ │ │ -668 if(knownRemote>0) { │ │ │ │ │ -669 Dune::dverb<global()<< " for processes "; │ │ │ │ │ -670 │ │ │ │ │ -671 // Update MessageInformation │ │ │ │ │ -672 for(auto valid = collIter.begin(); valid != end; ++valid) { │ │ │ │ │ -673 ++(infoSend_[valid.process()].publish); │ │ │ │ │ -674 (infoSend_[valid.process()].pairs) += knownRemote; │ │ │ │ │ -675 Dune::dverb<first==remote->first) { │ │ │ │ │ -697 // We want to send message information to that process │ │ │ │ │ -698 message = const_cast(&(messageIter->second)); │ │ │ │ │ -699 ++messageIter; │ │ │ │ │ -700 }else │ │ │ │ │ -701 // We do not want to send information but the other process might. │ │ │ │ │ -702 message = &dummy; │ │ │ │ │ -703 │ │ │ │ │ -704 sendBufferSizes_[neighbour]=0; │ │ │ │ │ -705 int tsize; │ │ │ │ │ -706 // The number of indices published │ │ │ │ │ -707 MPI_Pack_size(1, MPI_INT,remoteIndices_.communicator(), &tsize); │ │ │ │ │ -708 sendBufferSizes_[neighbour] += tsize; │ │ │ │ │ -709 │ │ │ │ │ -710 for(int i=0; i < message->publish; ++i) { │ │ │ │ │ -711 // The global index │ │ │ │ │ -712 MPI_Pack_size(1, MPITraits::getType(), │ │ │ │ │ -remoteIndices_.communicator(), &tsize); │ │ │ │ │ -713 sendBufferSizes_[neighbour] += tsize; │ │ │ │ │ -714 // The attribute in the local index │ │ │ │ │ -715 MPI_Pack_size(1, MPI_CHAR, remoteIndices_.communicator(), &tsize); │ │ │ │ │ -716 sendBufferSizes_[neighbour] += tsize; │ │ │ │ │ -717 // The number of corresponding remote indices │ │ │ │ │ -718 MPI_Pack_size(1, MPI_INT, remoteIndices_.communicator(), &tsize); │ │ │ │ │ -719 sendBufferSizes_[neighbour] += tsize; │ │ │ │ │ -720 } │ │ │ │ │ -721 for(int i=0; i < message->pairs; ++i) { │ │ │ │ │ -722 // The process of the remote index │ │ │ │ │ -723 MPI_Pack_size(1, MPI_INT, remoteIndices_.communicator(), &tsize); │ │ │ │ │ -724 sendBufferSizes_[neighbour] += tsize; │ │ │ │ │ -725 // The attribute of the remote index │ │ │ │ │ -726 MPI_Pack_size(1, MPI_CHAR, remoteIndices_.communicator(), &tsize); │ │ │ │ │ -727 sendBufferSizes_[neighbour] += tsize; │ │ │ │ │ -728 } │ │ │ │ │ -729 │ │ │ │ │ -730 Dune::dverb< │ │ │ │ │ -860 void IndicesSyncer::packAndSend(int destination, char* buffer, std:: │ │ │ │ │ -size_t bufferSize, MPI_Request& request) │ │ │ │ │ -861 { │ │ │ │ │ -862 auto iEnd = indexSet_.end(); │ │ │ │ │ -863 int bpos = 0; │ │ │ │ │ -864 int published = 0; │ │ │ │ │ -865 int pairs = 0; │ │ │ │ │ -866 │ │ │ │ │ -867 assert(checkReset()); │ │ │ │ │ -868 │ │ │ │ │ -869 // Pack the number of indices we publish │ │ │ │ │ -870 MPI_Pack(&(infoSend_[destination].publish), 1, MPI_INT, buffer, bufferSize, │ │ │ │ │ -&bpos, │ │ │ │ │ -871 remoteIndices_.communicator()); │ │ │ │ │ -872 │ │ │ │ │ -873 for(auto index = indexSet_.begin(); index != iEnd; ++index) { │ │ │ │ │ -874 // Search for corresponding remote indices in all iterator tuples │ │ │ │ │ -875 auto iteratorsEnd = iteratorsMap_.end(); │ │ │ │ │ -876 │ │ │ │ │ -877 // advance all iterators to a position with global index >= index->global() │ │ │ │ │ -878 for(auto iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; │ │ │ │ │ -++iterators) { │ │ │ │ │ -879 while(iterators->second.isNotAtEnd() && │ │ │ │ │ -880 iterators->second.globalIndexPair().first < index->global()) │ │ │ │ │ -881 ++(iterators->second); │ │ │ │ │ -882 assert(!iterators->second.isNotAtEnd() || iterators->second.globalIndexPair │ │ │ │ │ -().first >= index->global()); │ │ │ │ │ -883 } │ │ │ │ │ -884 │ │ │ │ │ -885 // Add all remote indices positioned at global which were already present │ │ │ │ │ -before calling sync │ │ │ │ │ -886 // to the message. │ │ │ │ │ -887 // Count how many remote indices we will send │ │ │ │ │ -888 int indices = 0; │ │ │ │ │ -889 bool knownRemote = false; // Is the remote process supposed to know this │ │ │ │ │ -index? │ │ │ │ │ -890 │ │ │ │ │ -891 for(auto iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; │ │ │ │ │ -++iterators) │ │ │ │ │ -892 { │ │ │ │ │ -893 std::pair p; │ │ │ │ │ -894 if (iterators->second.isNotAtEnd()) │ │ │ │ │ -895 { │ │ │ │ │ -896 p = iterators->second.globalIndexPair(); │ │ │ │ │ -897 } │ │ │ │ │ -898 │ │ │ │ │ -899 if(iterators->second.isNotAtEnd() && iterators->second.isOld() │ │ │ │ │ -900 && iterators->second.globalIndexPair().first == index->global()) { │ │ │ │ │ -901 indices++; │ │ │ │ │ -902 if(destination == iterators->first) │ │ │ │ │ -903 knownRemote = true; │ │ │ │ │ -904 } │ │ │ │ │ -905 } │ │ │ │ │ -906 │ │ │ │ │ -907 if(!knownRemote) │ │ │ │ │ -908 // We do not need to send any indices │ │ │ │ │ -909 continue; │ │ │ │ │ -910 │ │ │ │ │ -911 Dune::dverb<global │ │ │ │ │ -()<<" to "<(&(index->global())), 1, │ │ │ │ │ -MPITraits::getType(), buffer, bufferSize, &bpos, │ │ │ │ │ -916 remoteIndices_.communicator()); │ │ │ │ │ -917 │ │ │ │ │ -918 char attr = index->local().attribute(); │ │ │ │ │ -919 MPI_Pack(&attr, 1, MPI_CHAR, buffer, bufferSize, &bpos, │ │ │ │ │ -920 remoteIndices_.communicator()); │ │ │ │ │ -921 │ │ │ │ │ -922 // Pack the number of remote indices we send. │ │ │ │ │ -923 MPI_Pack(&indices, 1, MPI_INT, buffer, bufferSize, &bpos, │ │ │ │ │ -924 remoteIndices_.communicator()); │ │ │ │ │ -925 │ │ │ │ │ -926 // Pack the information about the remote indices │ │ │ │ │ -927 for(auto iterators = iteratorsMap_.begin(); iteratorsEnd != iterators; │ │ │ │ │ -++iterators) │ │ │ │ │ -928 if(iterators->second.isNotAtEnd() && iterators->second.isOld() │ │ │ │ │ -929 && iterators->second.globalIndexPair().first == index->global()) { │ │ │ │ │ -930 int process = iterators->first; │ │ │ │ │ -931 │ │ │ │ │ -932 ++pairs; │ │ │ │ │ -933 assert(pairs <= infoSend_[destination].pairs); │ │ │ │ │ -934 MPI_Pack(&process, 1, MPI_INT, buffer, bufferSize, &bpos, │ │ │ │ │ -935 remoteIndices_.communicator()); │ │ │ │ │ -936 char attr2 = iterators->second.remoteIndex().attribute(); │ │ │ │ │ -937 │ │ │ │ │ -938 MPI_Pack(&attr2, 1, MPI_CHAR, buffer, bufferSize, &bpos, │ │ │ │ │ -939 remoteIndices_.communicator()); │ │ │ │ │ -940 --indices; │ │ │ │ │ -941 } │ │ │ │ │ -942 assert(indices==0); │ │ │ │ │ -943 ++published; │ │ │ │ │ -944 Dune::dvverb<<" (publish="< │ │ │ │ │ -959 inline void IndicesSyncer::insertIntoRemoteIndexList(int process, │ │ │ │ │ -960 const std::pair& globalPair, │ │ │ │ │ -961 char attribute) │ │ │ │ │ -962 { │ │ │ │ │ -963 Dune::dverb<<"Inserting from "<second; │ │ │ │ │ -980 │ │ │ │ │ -981 // Search for the remote index │ │ │ │ │ -982 while(iterators.isNotAtEnd() && iterators.globalIndexPair() < globalPair) { │ │ │ │ │ -983 // Increment all iterators │ │ │ │ │ -984 ++iterators; │ │ │ │ │ -985 │ │ │ │ │ -986 } │ │ │ │ │ -987 │ │ │ │ │ -988 if(iterators.isAtEnd() || iterators.globalIndexPair() != globalPair) { │ │ │ │ │ -989 // The entry is not yet known │ │ │ │ │ -990 // Insert in the list and do not change the first iterator. │ │ │ │ │ -991 iterators.insert(RemoteIndex(Attribute(attribute)),globalPair); │ │ │ │ │ -992 return; │ │ │ │ │ -993 } │ │ │ │ │ -994 │ │ │ │ │ -995 // Global indices match │ │ │ │ │ -996 bool indexIsThere=false; │ │ │ │ │ -997 for(Iterators tmpIterators = iterators; │ │ │ │ │ -998 !tmpIterators.isAtEnd() && tmpIterators.globalIndexPair() == globalPair; │ │ │ │ │ -999 ++tmpIterators) │ │ │ │ │ -1000 //entry already exists with the same attribute │ │ │ │ │ -1001 if(tmpIterators.globalIndexPair().second == attribute) { │ │ │ │ │ -1002 indexIsThere=true; │ │ │ │ │ -1003 break; │ │ │ │ │ -1004 } │ │ │ │ │ -1005 │ │ │ │ │ -1006 if(!indexIsThere) │ │ │ │ │ -1007 // The entry is not yet known │ │ │ │ │ -1008 // Insert in the list and do not change the first iterator. │ │ │ │ │ -1009 iterators.insert(RemoteIndex(Attribute(attribute)),globalPair); │ │ │ │ │ -1010 } │ │ │ │ │ -1011 │ │ │ │ │ -1012 template │ │ │ │ │ -1013 template │ │ │ │ │ -1014 void IndicesSyncer::recvAndUnpack(T1& numberer, int hardSource, bool │ │ │ │ │ -useHardSource) │ │ │ │ │ -1015 { │ │ │ │ │ -1016 const ParallelIndexSet& constIndexSet = indexSet_; │ │ │ │ │ -1017 auto iEnd = constIndexSet.end(); │ │ │ │ │ -1018 auto index = constIndexSet.begin(); │ │ │ │ │ -1019 int bpos = 0; │ │ │ │ │ -1020 int publish; │ │ │ │ │ -1021 │ │ │ │ │ -1022 assert(checkReset()); │ │ │ │ │ -1023 │ │ │ │ │ -1024 MPI_Status status; │ │ │ │ │ -1025 │ │ │ │ │ -1026 // We have to determine the message size and source before the receive │ │ │ │ │ -1027 │ │ │ │ │ -1028 MPI_Probe(useHardSource ? hardSource : MPI_ANY_SOURCE, 345, │ │ │ │ │ -remoteIndices_.communicator(), &status); │ │ │ │ │ -1029 │ │ │ │ │ -1030 int source=status.MPI_SOURCE; │ │ │ │ │ -1031 int count; │ │ │ │ │ -1032 MPI_Get_count(&status, MPI_PACKED, &count); │ │ │ │ │ -1033 │ │ │ │ │ -1034 Dune::dvverb<receiveBufferSize_) { │ │ │ │ │ -1037 receiveBufferSize_=count; │ │ │ │ │ -1038 delete[] receiveBuffer_; │ │ │ │ │ -1039 receiveBuffer_ = new char[receiveBufferSize_]; │ │ │ │ │ -1040 } │ │ │ │ │ -1041 │ │ │ │ │ -1042 MPI_Recv(receiveBuffer_, count, MPI_PACKED, source, 345, │ │ │ │ │ -remoteIndices_.communicator(), &status); │ │ │ │ │ -1043 │ │ │ │ │ -1044 // How many global entries were published? │ │ │ │ │ -1045 MPI_Unpack(receiveBuffer_, count, &bpos, &publish, 1, MPI_INT, │ │ │ │ │ -remoteIndices_.communicator()); │ │ │ │ │ -1046 │ │ │ │ │ -1047 // Now unpack the remote indices and add them. │ │ │ │ │ -1048 while(publish>0) { │ │ │ │ │ -1049 │ │ │ │ │ -1050 // Unpack information about the local index on the source process │ │ │ │ │ -1051 GlobalIndex global; // global index of the current entry │ │ │ │ │ -1052 char sourceAttribute; // Attribute on the source process │ │ │ │ │ -1053 int pairs; │ │ │ │ │ -1054 │ │ │ │ │ -1055 MPI_Unpack(receiveBuffer_, count, &bpos, &global, 1, │ │ │ │ │ -MPITraits::getType(), │ │ │ │ │ -1056 remoteIndices_.communicator()); │ │ │ │ │ -1057 MPI_Unpack(receiveBuffer_, count, &bpos, &sourceAttribute, 1, MPI_CHAR, │ │ │ │ │ -1058 remoteIndices_.communicator()); │ │ │ │ │ -1059 MPI_Unpack(receiveBuffer_, count, &bpos, &pairs, 1, MPI_INT, │ │ │ │ │ -1060 remoteIndices_.communicator()); │ │ │ │ │ -1061 │ │ │ │ │ -1062 // Insert the entry on the remote process to our │ │ │ │ │ -1063 // remote index list │ │ │ │ │ -1064 SLList > sourceAttributeList; │ │ │ │ │ -1065 sourceAttributeList.push_back(std::make_pair(source,Attribute │ │ │ │ │ -(sourceAttribute))); │ │ │ │ │ -1066#ifndef NDEBUG │ │ │ │ │ -1067 bool foundSelf = false; │ │ │ │ │ -1068#endif │ │ │ │ │ -1069 Attribute myAttribute=Attribute(); │ │ │ │ │ -1070 │ │ │ │ │ -1071 // Unpack the remote indices │ │ │ │ │ -1072 for(; pairs>0; --pairs) { │ │ │ │ │ -1073 // Unpack the process id that knows the index │ │ │ │ │ -1074 int process; │ │ │ │ │ -1075 char attribute; │ │ │ │ │ -1076 MPI_Unpack(receiveBuffer_, count, &bpos, &process, 1, MPI_INT, │ │ │ │ │ -1077 remoteIndices_.communicator()); │ │ │ │ │ -1078 // Unpack the attribute │ │ │ │ │ -1079 MPI_Unpack(receiveBuffer_, count, &bpos, &attribute, 1, MPI_CHAR, │ │ │ │ │ -1080 remoteIndices_.communicator()); │ │ │ │ │ -1081 │ │ │ │ │ -1082 if(process==rank_) { │ │ │ │ │ -1083#ifndef NDEBUG │ │ │ │ │ -1084 foundSelf=true; │ │ │ │ │ -1085#endif │ │ │ │ │ -1086 myAttribute=Attribute(attribute); │ │ │ │ │ -1087 // Now we know the local attribute of the global index │ │ │ │ │ -1088 //Only add the index if it is unknown. │ │ │ │ │ -1089 // Do we know that global index already? │ │ │ │ │ -1090 auto pos = std::lower_bound(index, iEnd, IndexPair(global)); │ │ │ │ │ -1091 │ │ │ │ │ -1092 if(pos == iEnd || pos->global() != global) { │ │ │ │ │ -1093 // no entry with this global index │ │ │ │ │ -1094 indexSet_.add(global, │ │ │ │ │ -1095 ParallelLocalIndex(numberer(global), │ │ │ │ │ -1096 myAttribute, true)); │ │ │ │ │ -1097 Dune::dvverb << "Adding "<global()==global; ++pos) │ │ │ │ │ -1106 if(pos->local().attribute() == myAttribute) { │ │ │ │ │ -1107 Dune::dvverb<<"found "<(numberer(global), │ │ │ │ │ -1115 myAttribute, true)); │ │ │ │ │ -1116 Dune::dvverb << "Adding "< >::const_iterator Iter; │ │ │ │ │ -1126 for(Iter i=sourceAttributeList.begin(), end=sourceAttributeList.end(); │ │ │ │ │ -1127 i!=end; ++i) │ │ │ │ │ -1128 insertIntoRemoteIndexList(i->first, std::make_pair(global, myAttribute), │ │ │ │ │ -1129 i->second); │ │ │ │ │ -1130 --publish; │ │ │ │ │ -1131 } │ │ │ │ │ -1132 │ │ │ │ │ -1133 resetIteratorsMap(); │ │ │ │ │ -1134 } │ │ │ │ │ -1135 │ │ │ │ │ -1136 template │ │ │ │ │ -1137 void IndicesSyncer::resetIteratorsMap(){ │ │ │ │ │ -1138 │ │ │ │ │ -1139 // Reset iterators in all tuples. │ │ │ │ │ -1140 const auto remoteEnd = remoteIndices_.remoteIndices_.end(); │ │ │ │ │ -1141 auto iterators = iteratorsMap_.begin(); │ │ │ │ │ -1142 auto global = globalMap_.begin(); │ │ │ │ │ -1143 auto added = oldMap_.begin(); │ │ │ │ │ -1144 │ │ │ │ │ -1145 for(auto remote = remoteIndices_.remoteIndices_.begin(); │ │ │ │ │ -1146 remote != remoteEnd; ++remote, ++global, ++added, ++iterators) { │ │ │ │ │ -1147 iterators->second.reset(*(remote->second.first), global->second, added- │ │ │ │ │ ->second); │ │ │ │ │ -1148 } │ │ │ │ │ -1149 } │ │ │ │ │ -1150 │ │ │ │ │ -1151 template │ │ │ │ │ -1152 bool IndicesSyncer::checkReset(const Iterators& iterators, │ │ │ │ │ -RemoteIndexList& rList, GlobalIndexList& gList, │ │ │ │ │ -1153 BoolList& bList){ │ │ │ │ │ -1154 │ │ │ │ │ -1155 if(std::get<0>(iterators.iterators_) != rList.begin()) │ │ │ │ │ -1156 return false; │ │ │ │ │ -1157 if(std::get<1>(iterators.iterators_) != gList.begin()) │ │ │ │ │ -1158 return false; │ │ │ │ │ -1159 if(std::get<2>(iterators.iterators_) != bList.begin()) │ │ │ │ │ -1160 return false; │ │ │ │ │ -1161 return true; │ │ │ │ │ -1162 } │ │ │ │ │ -1163 │ │ │ │ │ -1164 │ │ │ │ │ -1165 template │ │ │ │ │ -1166 bool IndicesSyncer::checkReset(){ │ │ │ │ │ -1167 │ │ │ │ │ -1168 // Reset iterators in all tuples. │ │ │ │ │ -1169 const auto remoteEnd = remoteIndices_.remoteIndices_.end(); │ │ │ │ │ -1170 auto iterators = iteratorsMap_.begin(); │ │ │ │ │ -1171 auto global = globalMap_.begin(); │ │ │ │ │ -1172 auto added = oldMap_.begin(); │ │ │ │ │ -1173 bool ret = true; │ │ │ │ │ -1174 │ │ │ │ │ -1175 for(auto remote = remoteIndices_.remoteIndices_.begin(); │ │ │ │ │ -1176 remote != remoteEnd; ++remote, ++global, ++added, ++iterators) { │ │ │ │ │ -1177 if(!checkReset(iterators->second, *(remote->second.first), global->second, │ │ │ │ │ -1178 added->second)) │ │ │ │ │ -1179 ret=false; │ │ │ │ │ -1180 } │ │ │ │ │ -1181 return ret; │ │ │ │ │ -1182 } │ │ │ │ │ -1183} │ │ │ │ │ -1184 │ │ │ │ │ -1185#endif // HAVE_MPI │ │ │ │ │ -1186#endif // DUNE_COMMON_PARALLEL_INDICESSYNCER_HH │ │ │ │ │ -indexset.hh │ │ │ │ │ -Provides a map between global and local indices. │ │ │ │ │ -remoteindices.hh │ │ │ │ │ -Classes describing a distributed indexset. │ │ │ │ │ -stdstreams.hh │ │ │ │ │ -Standard Dune debug streams. │ │ │ │ │ -sllist.hh │ │ │ │ │ -Implements a singly linked list together with the necessary iterators. │ │ │ │ │ -Dune::SLList::push_back │ │ │ │ │ -void push_back(const MemberType &item) │ │ │ │ │ -Add a new entry to the end of the list. │ │ │ │ │ -Definition sllist.hh:643 │ │ │ │ │ -Dune::SLList::iterator │ │ │ │ │ -SLListIterator< T, A > iterator │ │ │ │ │ -The mutable iterator of the list. │ │ │ │ │ -Definition sllist.hh:69 │ │ │ │ │ -Dune::SLList::end │ │ │ │ │ -iterator end() │ │ │ │ │ -Get an iterator pointing to the end of the list. │ │ │ │ │ -Definition sllist.hh:774 │ │ │ │ │ -Dune::SLList::beginModify │ │ │ │ │ -ModifyIterator beginModify() │ │ │ │ │ -Get an iterator capable of deleting and inserting elements. │ │ │ │ │ -Definition sllist.hh:787 │ │ │ │ │ -Dune::SLList<_RemoteIndex,_Allocator_>::const_iterator │ │ │ │ │ -SLListConstIterator< RemoteIndex, Allocator > const_iterator │ │ │ │ │ -The constant iterator of the list. │ │ │ │ │ -Definition sllist.hh:74 │ │ │ │ │ -Dune::SLList::ModifyIterator │ │ │ │ │ -SLListModifyIterator< T, A > ModifyIterator │ │ │ │ │ -The type of the iterator capable of deletion and insertion. │ │ │ │ │ -Definition sllist.hh:103 │ │ │ │ │ -Dune::SLList::begin │ │ │ │ │ -iterator begin() │ │ │ │ │ -Get an iterator pointing to the first element in the list. │ │ │ │ │ -Definition sllist.hh:762 │ │ │ │ │ -Dune::operator< │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator<(const │ │ │ │ │ -RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const │ │ │ │ │ -RandomAccessIteratorFacade< T2, V2, R2, D > &rhs) │ │ │ │ │ -Comparison operator. │ │ │ │ │ -Definition iteratorfacades.hh:638 │ │ │ │ │ -Dune::operator== │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator==(const │ │ │ │ │ -ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, │ │ │ │ │ -V2, R2, D > &rhs) │ │ │ │ │ -Checks for equality. │ │ │ │ │ -Definition iteratorfacades.hh:238 │ │ │ │ │ -Dune::operator!= │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator!=(const │ │ │ │ │ -ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, │ │ │ │ │ -V2, R2, D > &rhs) │ │ │ │ │ -Checks for inequality. │ │ │ │ │ -Definition iteratorfacades.hh:260 │ │ │ │ │ -Dune::IndicesSyncer::Iterators::Iterators │ │ │ │ │ -Iterators() │ │ │ │ │ -Default constructor. │ │ │ │ │ -Definition indicessyncer.hh:563 │ │ │ │ │ -Dune::IndicesSyncer::RemoteIndices │ │ │ │ │ -Dune::RemoteIndices< ParallelIndexSet > RemoteIndices │ │ │ │ │ -Type of the remote indices. │ │ │ │ │ -Definition indicessyncer.hh:63 │ │ │ │ │ -Dune::IndicesSyncer::Iterators::isOld │ │ │ │ │ -bool isOld() const │ │ │ │ │ -Was this entry already in the remote index list before the sync process? │ │ │ │ │ -Definition indicessyncer.hh:600 │ │ │ │ │ -Dune::IndicesSyncer::MessageInformation::publish │ │ │ │ │ -int publish │ │ │ │ │ -The number of indices we publish for the other process. │ │ │ │ │ -Definition indicessyncer.hh:132 │ │ │ │ │ -Dune::repairLocalIndexPointers │ │ │ │ │ -void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename T:: │ │ │ │ │ -GlobalIndex, typename T::LocalIndex::Attribute >, A > > &globalMap, │ │ │ │ │ -RemoteIndices< T, A1 > &remoteIndices, const T &indexSet) │ │ │ │ │ -Repair the pointers to the local indices in the remote indices. │ │ │ │ │ -Definition indicessyncer.hh:495 │ │ │ │ │ -Dune::IndicesSyncer::Iterators::isAtEnd │ │ │ │ │ -bool isAtEnd() const │ │ │ │ │ -Are we at the end of the list? │ │ │ │ │ -Definition indicessyncer.hh:622 │ │ │ │ │ -Dune::RemoteIndices::communicator │ │ │ │ │ -MPI_Comm communicator() const │ │ │ │ │ -Get the mpi communicator used. │ │ │ │ │ -Definition remoteindices.hh:1695 │ │ │ │ │ -Dune::IndicesSyncer::GlobalIndex │ │ │ │ │ -ParallelIndexSet::GlobalIndex GlobalIndex │ │ │ │ │ -Type of the global index used in the index set. │ │ │ │ │ -Definition indicessyncer.hh:55 │ │ │ │ │ -Dune::IndicesSyncer::MessageInformation::pairs │ │ │ │ │ -int pairs │ │ │ │ │ -The number of pairs (attribute and process number) we publish to the neighbour │ │ │ │ │ -process. │ │ │ │ │ -Definition indicessyncer.hh:137 │ │ │ │ │ -Dune::RemoteIndices::end │ │ │ │ │ -const_iterator end() const │ │ │ │ │ -Get an iterator over all remote index lists. │ │ │ │ │ -Definition remoteindices.hh:1528 │ │ │ │ │ -Dune::IndicesSyncer::Iterators::attribute │ │ │ │ │ -Attribute & attribute() const │ │ │ │ │ -Dune::IndicesSyncer::Iterators::operator++ │ │ │ │ │ -Iterators & operator++() │ │ │ │ │ -Increment all iterators. │ │ │ │ │ -Definition indicessyncer.hh:568 │ │ │ │ │ -Dune::IndicesSyncer::Attribute │ │ │ │ │ -ParallelIndexSet::LocalIndex::Attribute Attribute │ │ │ │ │ -Type of the attribute used in the index set. │ │ │ │ │ -Definition indicessyncer.hh:58 │ │ │ │ │ -Dune::IndicesSyncer::Iterators::globalIndexPair │ │ │ │ │ -std::pair< GlobalIndex, Attribute > & globalIndexPair() const │ │ │ │ │ -Get the global index of the remote index at current position. │ │ │ │ │ -Definition indicessyncer.hh:594 │ │ │ │ │ -Dune::IndicesSyncer::IndicesSyncer │ │ │ │ │ -IndicesSyncer(ParallelIndexSet &indexSet, RemoteIndices &remoteIndices) │ │ │ │ │ -Constructor. │ │ │ │ │ -Definition indicessyncer.hh:544 │ │ │ │ │ -Dune::IndicesSyncer::Iterators::reset │ │ │ │ │ -void reset(RemoteIndexList &remoteIndices, GlobalIndexList &globalIndices, │ │ │ │ │ -BoolList &booleans) │ │ │ │ │ -Reset all the underlying iterators. │ │ │ │ │ -Definition indicessyncer.hh:606 │ │ │ │ │ -Dune::IndicesSyncer::DefaultNumberer::operator() │ │ │ │ │ -std::size_t operator()(const GlobalIndex &global) │ │ │ │ │ -Provide the local index, always std::numeric_limits::max() │ │ │ │ │ -Definition indicessyncer.hh:151 │ │ │ │ │ -Dune::IndicesSyncer::ParallelIndexSet │ │ │ │ │ -T ParallelIndexSet │ │ │ │ │ -The type of the index set. │ │ │ │ │ -Definition indicessyncer.hh:49 │ │ │ │ │ -Dune::IndicesSyncer::Iterators::isNotAtEnd │ │ │ │ │ -bool isNotAtEnd() const │ │ │ │ │ -Are we not at the end of the list? │ │ │ │ │ -Definition indicessyncer.hh:616 │ │ │ │ │ -Dune::RemoteIndices::neighbours │ │ │ │ │ -int neighbours() const │ │ │ │ │ -Get the number of processors we share indices with. │ │ │ │ │ -Definition remoteindices.hh:1445 │ │ │ │ │ -Dune::ParallelIndexSet::GlobalIndex │ │ │ │ │ -TG GlobalIndex │ │ │ │ │ -the type of the global index. This type has to provide at least a operator< for │ │ │ │ │ -sorting. │ │ │ │ │ -Definition indexset.hh:226 │ │ │ │ │ -Dune::storeGlobalIndicesOfRemoteIndices │ │ │ │ │ -void storeGlobalIndicesOfRemoteIndices(std::map< int, SLList< std::pair< │ │ │ │ │ -typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &globalMap, │ │ │ │ │ -const RemoteIndices< T, A1 > &remoteIndices) │ │ │ │ │ -Stores the corresponding global indices of the remote index information. │ │ │ │ │ -Definition indicessyncer.hh:469 │ │ │ │ │ -Dune::IndicesSyncer::sync │ │ │ │ │ -void sync() │ │ │ │ │ -Sync the index set. │ │ │ │ │ -Definition indicessyncer.hh:736 │ │ │ │ │ -Dune::ParallelIndexSet::seqNo │ │ │ │ │ -int seqNo() const │ │ │ │ │ -Get the internal sequence number. │ │ │ │ │ -Dune::IndicesSyncer::IndexPair │ │ │ │ │ -ParallelIndexSet::IndexPair IndexPair │ │ │ │ │ -The type of the index pair. │ │ │ │ │ -Definition indicessyncer.hh:52 │ │ │ │ │ -Dune::RemoteIndices::begin │ │ │ │ │ -const_iterator begin() const │ │ │ │ │ -Get an iterator over all remote index lists. │ │ │ │ │ -Definition remoteindices.hh:1521 │ │ │ │ │ -Dune::IndicesSyncer::Iterators::remoteIndex │ │ │ │ │ -RemoteIndex & remoteIndex() const │ │ │ │ │ -Get the remote index at current position. │ │ │ │ │ -Definition indicessyncer.hh:587 │ │ │ │ │ -Dune::IndicesSyncer::MessageInformation::MessageInformation │ │ │ │ │ -MessageInformation() │ │ │ │ │ -Definition indicessyncer.hh:128 │ │ │ │ │ -Dune::IndicesSyncer::Iterators::insert │ │ │ │ │ -void insert(const RemoteIndex &index, const std::pair< GlobalIndex, Attribute > │ │ │ │ │ -&global) │ │ │ │ │ -Insert a new remote index to the underlying remote index list. │ │ │ │ │ -Definition indicessyncer.hh:577 │ │ │ │ │ -Dune::dvverb │ │ │ │ │ -DVVerbType dvverb(std::cout) │ │ │ │ │ -stream for very verbose output. │ │ │ │ │ -Definition stdstreams.hh:96 │ │ │ │ │ -Dune::dverb │ │ │ │ │ -DVerbType dverb(std::cout) │ │ │ │ │ -Singleton of verbose debug stream. │ │ │ │ │ -Definition stdstreams.hh:117 │ │ │ │ │ +51#endif │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::MPITraits::getType │ │ │ │ │ -static MPI_Datatype getType() │ │ │ │ │ -Definition mpitraits.hh:48 │ │ │ │ │ -Dune::IndexPair │ │ │ │ │ -A pair consisting of a global and local index. │ │ │ │ │ -Definition indexset.hh:85 │ │ │ │ │ -Dune::IndicesSyncer │ │ │ │ │ -Class for recomputing missing indices of a distributed index set. │ │ │ │ │ -Definition indicessyncer.hh:45 │ │ │ │ │ -Dune::ParallelLocalIndex │ │ │ │ │ -An index present on the local process with an additional attribute flag. │ │ │ │ │ -Definition plocalindex.hh:52 │ │ │ │ │ -Dune::RemoteIndices │ │ │ │ │ -The indices present on remote processes. │ │ │ │ │ -Definition remoteindices.hh:190 │ │ │ │ │ -Dune::RemoteIndices::Allocator │ │ │ │ │ -typename std::allocator_traits< A >::template rebind_alloc< RemoteIndex > │ │ │ │ │ -Allocator │ │ │ │ │ -The type of the allocator for the remote index list. │ │ │ │ │ -Definition remoteindices.hh:238 │ │ │ │ │ -Dune::RemoteIndex │ │ │ │ │ -Information about an index residing on another processor. │ │ │ │ │ -Definition remoteindices.hh:74 │ │ │ │ │ -Dune::SLListIterator │ │ │ │ │ -A mutable iterator for the SLList. │ │ │ │ │ -Definition sllist.hh:271 │ │ │ │ │ -Dune::SLList │ │ │ │ │ -A single linked list. │ │ │ │ │ -Definition sllist.hh:44 │ │ │ │ │ +Dune::FMatrixPrecision │ │ │ │ │ +Precisions for calculations with FieldMatrix and FieldVector. │ │ │ │ │ +Definition precision.hh:25 │ │ │ │ │ +Dune::FMatrixPrecision::absolute_limit │ │ │ │ │ +static ctype absolute_limit() │ │ │ │ │ +return threshold to declare matrix singular │ │ │ │ │ +Definition precision.hh:28 │ │ │ │ │ +Dune::FMatrixPrecision::set_absolute_limit │ │ │ │ │ +static void set_absolute_limit(ctype absthres) │ │ │ │ │ +set singular threshold │ │ │ │ │ +Definition precision.hh:34 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00056.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: remoteindices.hh File Reference │ │ │ │ +dune-common: matvectraits.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,90 +65,43 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Functions
│ │ │ │ - │ │ │ │ +Namespaces
│ │ │ │ +
matvectraits.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Classes describing a distributed indexset. │ │ │ │ +

Documentation of the traits classes you need to write for each implementation of DenseVector or DenseMatrix. │ │ │ │ More...

│ │ │ │ -
#include <cassert>
│ │ │ │ -#include <iostream>
│ │ │ │ -#include <ostream>
│ │ │ │ -#include <map>
│ │ │ │ -#include <memory>
│ │ │ │ -#include <set>
│ │ │ │ -#include <tuple>
│ │ │ │ -#include <utility>
│ │ │ │ -#include <vector>
│ │ │ │ -#include <mpi.h>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/sllist.hh>
│ │ │ │ -#include <dune/common/stdstreams.hh>
│ │ │ │ -#include <dune/common/parallel/indexset.hh>
│ │ │ │ -#include <dune/common/parallel/mpitraits.hh>
│ │ │ │ -#include <dune/common/parallel/plocalindex.hh>
│ │ │ │ -
│ │ │ │ + │ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::MPITraits< IndexPair< TG, ParallelLocalIndex< TA > > >
 
class  Dune::RemoteIndex< T1, T2 >
 Information about an index residing on another processor. More...
 
class  Dune::RemoteIndices< T, A >
 The indices present on remote processes. More...
 
class  Dune::RemoteIndexListModifier< T, A, mode >
 Modifier for adding and/or deleting remote indices from the remote index list. More...
 
class  Dune::RemoteIndexListModifier< T, A, mode >::InvalidPosition
 
class  Dune::CollectiveIterator< T, A >
 A collective iterator for moving over the remote indices for all processes collectively. More...
 
class  Dune::CollectiveIterator< T, A >::iterator
 Iterator over the valid underlying iterators. More...
struct  Dune::DenseMatVecTraits< T >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

template<typename T1 , typename T2 >
std::ostream & Dune::operator<< (std::ostream &os, const RemoteIndex< T1, T2 > &index)
 
template<class T , class A >
std::ostream & Dune::operator<< (std::ostream &os, const RemoteIndices< T, A > &indices)
 
template<typename TG , typename TA >
std::ostream & Dune::operator<< (std::ostream &os, const RemoteIndex< TG, TA > &index)
 
│ │ │ │

Detailed Description

│ │ │ │ -

Classes describing a distributed indexset.

│ │ │ │ -
Author
Markus Blatt
│ │ │ │ +

Documentation of the traits classes you need to write for each implementation of DenseVector or DenseMatrix.

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,73 +1,23 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -remoteindices.hh File Reference │ │ │ │ │ -Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ -Classes describing a distributed indexset. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +matvectraits.hh File Reference │ │ │ │ │ +Documentation of the traits classes you need to write for each implementation │ │ │ │ │ +of DenseVector or DenseMatrix. More... │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::MPITraits<_IndexPair<_TG,_ParallelLocalIndex<_TA_>_>_> │ │ │ │ │ -  │ │ │ │ │ -class   Dune::RemoteIndex<_T1,_T2_> │ │ │ │ │ -  Information about an index residing on another processor. More... │ │ │ │ │ -  │ │ │ │ │ -class   Dune::RemoteIndices<_T,_A_> │ │ │ │ │ -  The indices present on remote processes. More... │ │ │ │ │ -  │ │ │ │ │ -class   Dune::RemoteIndexListModifier<_T,_A,_mode_> │ │ │ │ │ -  Modifier for adding and/or deleting remote indices from the remote │ │ │ │ │ - index list. More... │ │ │ │ │ -  │ │ │ │ │ -class   Dune::RemoteIndexListModifier<_T,_A,_mode_>::InvalidPosition │ │ │ │ │ -  │ │ │ │ │ -class   Dune::CollectiveIterator<_T,_A_> │ │ │ │ │ -  A collective iterator for moving over the remote indices for all │ │ │ │ │ - processes collectively. More... │ │ │ │ │ -  │ │ │ │ │ -class   Dune::CollectiveIterator<_T,_A_>::iterator │ │ │ │ │ -  Iterator over the valid underlying iterators. More... │ │ │ │ │ +struct   Dune::DenseMatVecTraits<_T_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Functions │ │ │ │ │ -template │ │ │ │ │ -std::ostream &  Dune::operator<< (std::ostream &os, const RemoteIndex< T1, T2 > │ │ │ │ │ - &index) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -std::ostream &  Dune::operator<< (std::ostream &os, const RemoteIndices< T, A > │ │ │ │ │ - &indices) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ -std::ostream &  Dune::operator<< (std::ostream &os, const RemoteIndex< TG, TA > │ │ │ │ │ - &index) │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Classes describing a distributed indexset. │ │ │ │ │ - Author │ │ │ │ │ - Markus Blatt │ │ │ │ │ +Documentation of the traits classes you need to write for each implementation │ │ │ │ │ +of DenseVector or DenseMatrix. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00056_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: remoteindices.hh Source File │ │ │ │ +dune-common: matvectraits.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,1698 +70,41 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
remoteindices.hh
│ │ │ │ +
matvectraits.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PARALLEL_REMOTEINDICES_HH
│ │ │ │ -
6#define DUNE_COMMON_PARALLEL_REMOTEINDICES_HH
│ │ │ │ +
5#ifndef DUNE_MATVECTRAITS_HH
│ │ │ │ +
6#define DUNE_MATVECTRAITS_HH
│ │ │ │
7
│ │ │ │ -
8#if HAVE_MPI
│ │ │ │ -
9
│ │ │ │ -
10#include <cassert>
│ │ │ │ -
11#include <iostream>
│ │ │ │ -
12#include <ostream>
│ │ │ │ -
13#include <map>
│ │ │ │ -
14#include <memory>
│ │ │ │ -
15#include <set>
│ │ │ │ -
16#include <tuple>
│ │ │ │ -
17#include <utility>
│ │ │ │ -
18#include <vector>
│ │ │ │ -
19
│ │ │ │ -
20#include <mpi.h>
│ │ │ │ -
21
│ │ │ │ - │ │ │ │ -
23#include <dune/common/sllist.hh>
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
28
│ │ │ │ -
29namespace Dune {
│ │ │ │ -
41 template<typename TG, typename TA>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
43 {
│ │ │ │ -
44 public:
│ │ │ │ -
45 inline static MPI_Datatype getType();
│ │ │ │ -
46 private:
│ │ │ │ -
47 static MPI_Datatype type;
│ │ │ │ -
48 };
│ │ │ │ -
│ │ │ │ -
49
│ │ │ │ -
50
│ │ │ │ -
51 template<typename T, typename A>
│ │ │ │ -
52 class RemoteIndices;
│ │ │ │ -
53
│ │ │ │ -
54 template<typename T1, typename T2>
│ │ │ │ -
55 class RemoteIndex;
│ │ │ │ -
56
│ │ │ │ -
57 // forward declaration needed for friend declaration.
│ │ │ │ -
58 template<typename T>
│ │ │ │ -
59 class IndicesSyncer;
│ │ │ │ -
60
│ │ │ │ -
61 template<typename T1, typename T2>
│ │ │ │ -
62 std::ostream& operator<<(std::ostream& os, const RemoteIndex<T1,T2>& index);
│ │ │ │ -
63
│ │ │ │ -
64
│ │ │ │ -
65 template<typename T, typename A, bool mode>
│ │ │ │ - │ │ │ │ -
67
│ │ │ │ -
68
│ │ │ │ -
72 template<typename T1, typename T2>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
74 {
│ │ │ │ -
75 template<typename T>
│ │ │ │ -
76 friend class IndicesSyncer;
│ │ │ │ -
77
│ │ │ │ -
78 template<typename T, typename A, typename A1>
│ │ │ │ -
79 friend void repairLocalIndexPointers(std::map<int,SLList<std::pair<typename T::GlobalIndex, typename T::LocalIndex::Attribute>,A> >&,
│ │ │ │ - │ │ │ │ -
81 const T&);
│ │ │ │ -
82
│ │ │ │ -
83 template<typename T, typename A, bool mode>
│ │ │ │ - │ │ │ │ -
85
│ │ │ │ -
86 public:
│ │ │ │ -
91 typedef T1 GlobalIndex;
│ │ │ │ -
100 typedef T2 Attribute;
│ │ │ │ -
101
│ │ │ │ - │ │ │ │ - │ │ │ │ -
107
│ │ │ │ -
112 const Attribute attribute() const;
│ │ │ │ -
113
│ │ │ │ -
119 const PairType& localIndexPair() const;
│ │ │ │ -
120
│ │ │ │ -
124 RemoteIndex();
│ │ │ │ -
125
│ │ │ │ -
126
│ │ │ │ -
132 RemoteIndex(const T2& attribute,
│ │ │ │ -
133 const PairType* local);
│ │ │ │ -
134
│ │ │ │ -
135
│ │ │ │ -
141 RemoteIndex(const T2& attribute);
│ │ │ │ -
142
│ │ │ │ -
143 bool operator==(const RemoteIndex& ri) const;
│ │ │ │ -
144
│ │ │ │ -
145 bool operator!=(const RemoteIndex& ri) const;
│ │ │ │ -
146 private:
│ │ │ │ -
148 const PairType* localIndex_;
│ │ │ │ -
149
│ │ │ │ -
151 char attribute_;
│ │ │ │ -
152 };
│ │ │ │ -
│ │ │ │ -
153
│ │ │ │ -
154 template<class T, class A>
│ │ │ │ -
155 std::ostream& operator<<(std::ostream& os, const RemoteIndices<T,A>& indices);
│ │ │ │ -
156
│ │ │ │ -
157 class InterfaceBuilder;
│ │ │ │ -
158
│ │ │ │ -
159 template<class T, class A>
│ │ │ │ -
160 class CollectiveIterator;
│ │ │ │ -
161
│ │ │ │ -
162 // forward declaration needed for friend declaration.
│ │ │ │ -
163 template<class T>
│ │ │ │ -
164 class IndicesSyncer;
│ │ │ │ -
165
│ │ │ │ -
166 // forward declaration needed for friend declaration.
│ │ │ │ -
167 template<typename T1, typename T2>
│ │ │ │ - │ │ │ │ -
169
│ │ │ │ -
170
│ │ │ │ -
187 template<class T, class A=std::allocator<RemoteIndex<typename T::GlobalIndex,
│ │ │ │ -
188 typename T::LocalIndex::Attribute> > >
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
190 {
│ │ │ │ -
191 friend class InterfaceBuilder;
│ │ │ │ -
192 friend class IndicesSyncer<T>;
│ │ │ │ -
193 template<typename T1, typename A2, typename A1>
│ │ │ │ -
194 friend void repairLocalIndexPointers(std::map<int,SLList<std::pair<typename T1::GlobalIndex, typename T1::LocalIndex::Attribute>,A2> >&,
│ │ │ │ - │ │ │ │ -
196 const T1&);
│ │ │ │ -
197
│ │ │ │ -
198 template<class G, class T1, class T2>
│ │ │ │ - │ │ │ │ -
200 friend std::ostream& operator<<<>(std::ostream&, const RemoteIndices<T>&);
│ │ │ │ -
201
│ │ │ │ -
202 public:
│ │ │ │ -
203
│ │ │ │ - │ │ │ │ -
208
│ │ │ │ - │ │ │ │ -
212
│ │ │ │ - │ │ │ │ -
217
│ │ │ │ -
218
│ │ │ │ - │ │ │ │ -
223
│ │ │ │ -
227 typedef typename LocalIndex::Attribute Attribute;
│ │ │ │ -
228
│ │ │ │ - │ │ │ │ -
233
│ │ │ │ -
234
│ │ │ │ -
238 using Allocator = typename std::allocator_traits<A>::template rebind_alloc<RemoteIndex>;
│ │ │ │ -
239
│ │ │ │ - │ │ │ │ - │ │ │ │ -
243
│ │ │ │ -
245 typedef std::map<int, std::pair<RemoteIndexList*,RemoteIndexList*> >
│ │ │ │ - │ │ │ │ -
247
│ │ │ │ -
248 typedef typename RemoteIndexMap::const_iterator const_iterator;
│ │ │ │ -
249
│ │ │ │ -
267 inline RemoteIndices(const ParallelIndexSet& source, const ParallelIndexSet& destination,
│ │ │ │ -
268 const MPI_Comm& comm, const std::vector<int>& neighbours=std::vector<int>(), bool includeSelf=false);
│ │ │ │ -
269
│ │ │ │ - │ │ │ │ -
271
│ │ │ │ -
279 void setIncludeSelf(bool includeSelf);
│ │ │ │ -
280
│ │ │ │ -
297 void setIndexSets(const ParallelIndexSet& source, const ParallelIndexSet& destination,
│ │ │ │ -
298 const MPI_Comm& comm, const std::vector<int>& neighbours=std::vector<int>());
│ │ │ │ -
299
│ │ │ │ -
300 template<typename C>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
302 {
│ │ │ │ -
303 neighbourIds.clear();
│ │ │ │ -
304 neighbourIds.insert(neighbours.begin(), neighbours.end());
│ │ │ │ -
305
│ │ │ │ -
306 }
│ │ │ │ -
│ │ │ │ -
307
│ │ │ │ -
│ │ │ │ -
308 const std::set<int>& getNeighbours() const
│ │ │ │ -
309 {
│ │ │ │ -
310 return neighbourIds;
│ │ │ │ -
311 }
│ │ │ │ -
│ │ │ │ -
312
│ │ │ │ - │ │ │ │ -
317
│ │ │ │ -
327 template<bool ignorePublic>
│ │ │ │ -
328 void rebuild();
│ │ │ │ -
329
│ │ │ │ -
330 bool operator==(const RemoteIndices& ri) const;
│ │ │ │ -
331
│ │ │ │ -
339 inline bool isSynced() const;
│ │ │ │ -
340
│ │ │ │ -
344 inline MPI_Comm communicator() const;
│ │ │ │ -
345
│ │ │ │ -
360 template<bool mode, bool send>
│ │ │ │ - │ │ │ │ -
362
│ │ │ │ -
369 inline const_iterator find(int proc) const;
│ │ │ │ -
370
│ │ │ │ -
375 inline const_iterator begin() const;
│ │ │ │ -
376
│ │ │ │ -
381 inline const_iterator end() const;
│ │ │ │ -
382
│ │ │ │ -
386 template<bool send>
│ │ │ │ -
387 inline CollectiveIteratorT iterator() const;
│ │ │ │ -
388
│ │ │ │ -
392 inline void free();
│ │ │ │ -
393
│ │ │ │ -
398 inline int neighbours() const;
│ │ │ │ -
399
│ │ │ │ -
401 inline const ParallelIndexSet& sourceIndexSet() const;
│ │ │ │ -
402
│ │ │ │ -
404 inline const ParallelIndexSet& destinationIndexSet() const;
│ │ │ │ -
405
│ │ │ │ -
406 private:
│ │ │ │ -
408 RemoteIndices(const RemoteIndices&) = delete;
│ │ │ │ -
409
│ │ │ │ -
411 const ParallelIndexSet* source_;
│ │ │ │ -
412
│ │ │ │ -
414 const ParallelIndexSet* target_;
│ │ │ │ -
415
│ │ │ │ -
417 MPI_Comm comm_;
│ │ │ │ -
418
│ │ │ │ -
421 std::set<int> neighbourIds;
│ │ │ │ -
422
│ │ │ │ -
424 const static int commTag_=333;
│ │ │ │ -
425
│ │ │ │ -
430 int sourceSeqNo_;
│ │ │ │ -
431
│ │ │ │ -
436 int destSeqNo_;
│ │ │ │ -
437
│ │ │ │ -
441 bool publicIgnored;
│ │ │ │ -
442
│ │ │ │ -
446 bool firstBuild;
│ │ │ │ -
447
│ │ │ │ -
448 /*
│ │ │ │ -
449 * @brief If true, sending from indices of the processor to other
│ │ │ │ -
450 * indices on the same processor is enabled even if the same indexset is used
│ │ │ │ -
451 * on both the
│ │ │ │ -
452 * sending and receiving side.
│ │ │ │ -
453 */
│ │ │ │ -
454 bool includeSelf;
│ │ │ │ -
455
│ │ │ │ - │ │ │ │ -
458 PairType;
│ │ │ │ -
459
│ │ │ │ -
466 RemoteIndexMap remoteIndices_;
│ │ │ │ -
467
│ │ │ │ -
478 template<bool ignorePublic>
│ │ │ │ -
479 inline void buildRemote(bool includeSelf);
│ │ │ │ -
480
│ │ │ │ -
486 inline int noPublic(const ParallelIndexSet& indexSet);
│ │ │ │ -
487
│ │ │ │ -
499 template<bool ignorePublic>
│ │ │ │ -
500 inline void packEntries(PairType** myPairs, const ParallelIndexSet& indexSet,
│ │ │ │ -
501 char* p_out, MPI_Datatype type, int bufferSize,
│ │ │ │ -
502 int* position, int n);
│ │ │ │ -
503
│ │ │ │ -
517 inline void unpackIndices(RemoteIndexList& remote, int remoteEntries,
│ │ │ │ -
518 PairType** local, int localEntries, char* p_in,
│ │ │ │ -
519 MPI_Datatype type, int* position, int bufferSize,
│ │ │ │ -
520 bool fromOurself);
│ │ │ │ -
521
│ │ │ │ -
522 inline void unpackIndices(RemoteIndexList& send, RemoteIndexList& receive,
│ │ │ │ -
523 int remoteEntries, PairType** localSource,
│ │ │ │ -
524 int localSourceEntries, PairType** localDest,
│ │ │ │ -
525 int localDestEntries, char* p_in,
│ │ │ │ -
526 MPI_Datatype type, int* position, int bufferSize);
│ │ │ │ -
527
│ │ │ │ -
528 void unpackCreateRemote(char* p_in, PairType** sourcePairs, PairType** DestPairs,
│ │ │ │ -
529 int remoteProc, int sourcePublish, int destPublish,
│ │ │ │ -
530 int bufferSize, bool sendTwo, bool fromOurSelf=false);
│ │ │ │ -
531 };
│ │ │ │ -
│ │ │ │ -
532
│ │ │ │ -
548 template<class T, class A, bool mode>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
550 {
│ │ │ │ -
551
│ │ │ │ -
552 template<typename T1, typename A1>
│ │ │ │ -
553 friend class RemoteIndices;
│ │ │ │ -
554
│ │ │ │ -
555 public:
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
557 {};
│ │ │ │ -
│ │ │ │ -
558
│ │ │ │ -
567 constexpr static bool MODIFYINDEXSET = mode;
│ │ │ │ -
568
│ │ │ │ - │ │ │ │ -
573
│ │ │ │ - │ │ │ │ -
578
│ │ │ │ - │ │ │ │ -
583
│ │ │ │ -
587 typedef typename LocalIndex::Attribute Attribute;
│ │ │ │ -
588
│ │ │ │ - │ │ │ │ -
593
│ │ │ │ -
597 typedef A Allocator;
│ │ │ │ -
598
│ │ │ │ - │ │ │ │ - │ │ │ │ -
602
│ │ │ │ - │ │ │ │ -
607
│ │ │ │ - │ │ │ │ -
612
│ │ │ │ -
626 void insert(const RemoteIndex& index);
│ │ │ │ -
627
│ │ │ │ -
628
│ │ │ │ -
643 void insert(const RemoteIndex& index, const GlobalIndex& global);
│ │ │ │ -
644
│ │ │ │ -
652 bool remove(const GlobalIndex& global);
│ │ │ │ -
653
│ │ │ │ - │ │ │ │ -
667
│ │ │ │ -
668
│ │ │ │ - │ │ │ │ -
670
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
676 : glist_()
│ │ │ │ -
677 {}
│ │ │ │ -
│ │ │ │ -
678
│ │ │ │ -
679 private:
│ │ │ │ -
680
│ │ │ │ - │ │ │ │ -
687 RemoteIndexList& rList);
│ │ │ │ -
688
│ │ │ │ -
689 typedef SLList<GlobalIndex,Allocator> GlobalList;
│ │ │ │ -
690 typedef typename GlobalList::ModifyIterator GlobalModifyIterator;
│ │ │ │ -
691 RemoteIndexList* rList_;
│ │ │ │ -
692 const ParallelIndexSet* indexSet_;
│ │ │ │ -
693 GlobalList glist_;
│ │ │ │ -
694 ModifyIterator iter_;
│ │ │ │ -
695 GlobalModifyIterator giter_;
│ │ │ │ -
696 ConstIterator end_;
│ │ │ │ -
697 bool first_;
│ │ │ │ -
698 GlobalIndex last_;
│ │ │ │ -
699 };
│ │ │ │ -
│ │ │ │ -
700
│ │ │ │ -
705 template<class T, class A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
707 {
│ │ │ │ -
708
│ │ │ │ -
712 typedef T ParallelIndexSet;
│ │ │ │ -
713
│ │ │ │ -
717 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex;
│ │ │ │ -
718
│ │ │ │ -
722 typedef typename ParallelIndexSet::LocalIndex LocalIndex;
│ │ │ │ -
723
│ │ │ │ -
727 typedef typename LocalIndex::Attribute Attribute;
│ │ │ │ -
728
│ │ │ │ - │ │ │ │ -
731
│ │ │ │ -
733 using Allocator = typename std::allocator_traits<A>::template rebind_alloc<RemoteIndex>;
│ │ │ │ -
734
│ │ │ │ - │ │ │ │ -
737
│ │ │ │ -
739 typedef std::map<int,std::pair<typename RemoteIndexList::const_iterator,
│ │ │ │ -
740 const typename RemoteIndexList::const_iterator> >
│ │ │ │ -
741 Map;
│ │ │ │ -
742
│ │ │ │ -
743 public:
│ │ │ │ -
744
│ │ │ │ -
746 typedef std::map<int, std::pair<RemoteIndexList*,RemoteIndexList*> >
│ │ │ │ - │ │ │ │ -
748
│ │ │ │ -
754 inline CollectiveIterator(const RemoteIndexMap& map_, bool send);
│ │ │ │ -
755
│ │ │ │ -
764 inline void advance(const GlobalIndex& global);
│ │ │ │ -
765
│ │ │ │ -
775 inline void advance(const GlobalIndex& global, const Attribute& attribute);
│ │ │ │ -
776
│ │ │ │ - │ │ │ │ -
778
│ │ │ │ -
782 inline bool empty() const;
│ │ │ │ -
783
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
791 {
│ │ │ │ -
792 public:
│ │ │ │ -
793 typedef typename Map::iterator RealIterator;
│ │ │ │ -
794 typedef typename Map::iterator ConstRealIterator;
│ │ │ │ -
795
│ │ │ │ -
796
│ │ │ │ -
│ │ │ │ -
798 iterator(const RealIterator& iter, const ConstRealIterator& end, GlobalIndex& index)
│ │ │ │ -
799 : iter_(iter), end_(end), index_(index), hasAttribute(false)
│ │ │ │ -
800 {
│ │ │ │ -
801 // Move to the first valid entry
│ │ │ │ -
802 while(iter_!=end_ && iter_->second.first->localIndexPair().global()!=index_)
│ │ │ │ -
803 ++iter_;
│ │ │ │ -
804 }
│ │ │ │ -
│ │ │ │ -
805
│ │ │ │ -
│ │ │ │ -
806 iterator(const RealIterator& iter, const ConstRealIterator& end, GlobalIndex index,
│ │ │ │ -
807 Attribute attribute)
│ │ │ │ -
808 : iter_(iter), end_(end), index_(index), attribute_(attribute), hasAttribute(true)
│ │ │ │ -
809 {
│ │ │ │ -
810 // Move to the first valid entry or the end
│ │ │ │ -
811 while(iter_!=end_ && (iter_->second.first->localIndexPair().global()!=index_
│ │ │ │ -
812 || iter_->second.first->localIndexPair().local().attribute()!=attribute))
│ │ │ │ -
813 ++iter_;
│ │ │ │ -
814 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
816 iterator(const iterator& other)
│ │ │ │ -
817 : iter_(other.iter_), end_(other.end_), index_(other.index_)
│ │ │ │ -
818 { }
│ │ │ │ -
│ │ │ │ -
819
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
822 {
│ │ │ │ -
823 ++iter_;
│ │ │ │ -
824 // If entry is not valid move on
│ │ │ │ -
825 while(iter_!=end_ && (iter_->second.first->localIndexPair().global()!=index_ ||
│ │ │ │ -
826 (hasAttribute &&
│ │ │ │ -
827 iter_->second.first->localIndexPair().local().attribute()!=attribute_)))
│ │ │ │ -
828 ++iter_;
│ │ │ │ -
829 assert(iter_==end_ ||
│ │ │ │ -
830 (iter_->second.first->localIndexPair().global()==index_));
│ │ │ │ -
831 assert(iter_==end_ || !hasAttribute ||
│ │ │ │ -
832 (iter_->second.first->localIndexPair().local().attribute()==attribute_));
│ │ │ │ -
833 return *this;
│ │ │ │ -
834 }
│ │ │ │ -
│ │ │ │ -
835
│ │ │ │ -
│ │ │ │ -
837 const RemoteIndex& operator*() const
│ │ │ │ -
838 {
│ │ │ │ -
839 return *(iter_->second.first);
│ │ │ │ -
840 }
│ │ │ │ -
│ │ │ │ -
841
│ │ │ │ -
│ │ │ │ -
843 int process() const
│ │ │ │ -
844 {
│ │ │ │ -
845 return iter_->first;
│ │ │ │ -
846 }
│ │ │ │ -
│ │ │ │ -
847
│ │ │ │ -
│ │ │ │ -
849 const RemoteIndex* operator->() const
│ │ │ │ -
850 {
│ │ │ │ -
851 return iter_->second.first.operator->();
│ │ │ │ -
852 }
│ │ │ │ -
│ │ │ │ -
853
│ │ │ │ -
│ │ │ │ -
855 bool operator==(const iterator& other) const
│ │ │ │ -
856 {
│ │ │ │ -
857 return other.iter_==iter_;
│ │ │ │ -
858 }
│ │ │ │ -
│ │ │ │ -
859
│ │ │ │ -
│ │ │ │ -
861 bool operator!=(const iterator& other) const
│ │ │ │ -
862 {
│ │ │ │ -
863 return other.iter_!=iter_;
│ │ │ │ -
864 }
│ │ │ │ -
│ │ │ │ -
865
│ │ │ │ -
866 private:
│ │ │ │ -
867 iterator();
│ │ │ │ -
868
│ │ │ │ -
869 RealIterator iter_;
│ │ │ │ -
870 RealIterator end_;
│ │ │ │ -
871 GlobalIndex index_;
│ │ │ │ -
872 Attribute attribute_;
│ │ │ │ -
873 bool hasAttribute;
│ │ │ │ -
874 };
│ │ │ │ -
│ │ │ │ -
875
│ │ │ │ -
876 iterator begin();
│ │ │ │ -
877
│ │ │ │ -
878 iterator end();
│ │ │ │ -
879
│ │ │ │ -
880 private:
│ │ │ │ -
881
│ │ │ │ -
882 Map map_;
│ │ │ │ -
883 GlobalIndex index_;
│ │ │ │ -
884 Attribute attribute_;
│ │ │ │ -
885 bool noattribute;
│ │ │ │ -
886 };
│ │ │ │ -
│ │ │ │ -
887
│ │ │ │ -
888 template<typename TG, typename TA>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
890 {
│ │ │ │ -
891 if(type==MPI_DATATYPE_NULL) {
│ │ │ │ -
892 int length[2] = {1, 1};
│ │ │ │ -
893 MPI_Aint base;
│ │ │ │ -
894 MPI_Aint disp[2];
│ │ │ │ -
895 MPI_Datatype types[2] = {MPITraits<TG>::getType(),
│ │ │ │ - │ │ │ │ - │ │ │ │ -
898 MPI_Get_address(&rep, &base); // lower bound of the datatype
│ │ │ │ -
899 MPI_Get_address(&(rep.global_), &disp[0]);
│ │ │ │ -
900 MPI_Get_address(&(rep.local_), &disp[1]);
│ │ │ │ -
901 for (MPI_Aint& d : disp)
│ │ │ │ -
902 d -= base;
│ │ │ │ -
903
│ │ │ │ -
904 MPI_Datatype tmp;
│ │ │ │ -
905 MPI_Type_create_struct(2, length, disp, types, &tmp);
│ │ │ │ -
906
│ │ │ │ -
907 MPI_Type_create_resized(tmp, 0, sizeof(IndexPair<TG,ParallelLocalIndex<TA> >), &type);
│ │ │ │ -
908 MPI_Type_commit(&type);
│ │ │ │ -
909
│ │ │ │ -
910 MPI_Type_free(&tmp);
│ │ │ │ -
911 }
│ │ │ │ -
912 return type;
│ │ │ │ -
913 }
│ │ │ │ -
│ │ │ │ -
914
│ │ │ │ -
915 template<typename TG, typename TA>
│ │ │ │ -
916 MPI_Datatype MPITraits<IndexPair<TG,ParallelLocalIndex<TA> > >::type=MPI_DATATYPE_NULL;
│ │ │ │ -
917
│ │ │ │ -
918 template<typename T1, typename T2>
│ │ │ │ -
│ │ │ │ -
919 RemoteIndex<T1,T2>::RemoteIndex(const T2& attribute, const PairType* local)
│ │ │ │ -
920 : localIndex_(local), attribute_(static_cast<std::underlying_type_t<T2>>(attribute))
│ │ │ │ -
921 {}
│ │ │ │ -
│ │ │ │ -
922
│ │ │ │ -
923 template<typename T1, typename T2>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
925 : localIndex_(0), attribute_(static_cast<std::underlying_type_t<T2>>(attribute))
│ │ │ │ -
926 {}
│ │ │ │ -
│ │ │ │ -
927
│ │ │ │ -
928 template<typename T1, typename T2>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
930 : localIndex_(0), attribute_()
│ │ │ │ -
931 {}
│ │ │ │ -
│ │ │ │ -
932 template<typename T1, typename T2>
│ │ │ │ -
│ │ │ │ -
933 inline bool RemoteIndex<T1,T2>::operator==(const RemoteIndex& ri) const
│ │ │ │ -
934 {
│ │ │ │ -
935 return localIndex_==ri.localIndex_ && attribute_==ri.attribute_;
│ │ │ │ -
936 }
│ │ │ │ -
│ │ │ │ -
937
│ │ │ │ -
938 template<typename T1, typename T2>
│ │ │ │ -
│ │ │ │ -
939 inline bool RemoteIndex<T1,T2>::operator!=(const RemoteIndex& ri) const
│ │ │ │ -
940 {
│ │ │ │ -
941 return localIndex_!=ri.localIndex_ || attribute_!=ri.attribute_;
│ │ │ │ -
942 }
│ │ │ │ -
│ │ │ │ -
943
│ │ │ │ -
944 template<typename T1, typename T2>
│ │ │ │ -
│ │ │ │ -
945 inline const T2 RemoteIndex<T1,T2>::attribute() const
│ │ │ │ -
946 {
│ │ │ │ -
947 return T2(attribute_);
│ │ │ │ -
948 }
│ │ │ │ -
│ │ │ │ -
949
│ │ │ │ -
950 template<typename T1, typename T2>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
952 {
│ │ │ │ -
953 return *localIndex_;
│ │ │ │ -
954 }
│ │ │ │ -
│ │ │ │ -
955
│ │ │ │ -
956 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
958 const ParallelIndexSet& destination,
│ │ │ │ -
959 const MPI_Comm& comm,
│ │ │ │ -
960 const std::vector<int>& neighbours,
│ │ │ │ -
961 bool includeSelf_)
│ │ │ │ -
962 : source_(&source), target_(&destination), comm_(comm),
│ │ │ │ -
963 sourceSeqNo_(-1), destSeqNo_(-1), publicIgnored(false), firstBuild(true),
│ │ │ │ -
964 includeSelf(includeSelf_)
│ │ │ │ -
965 {
│ │ │ │ - │ │ │ │ -
967 }
│ │ │ │ -
│ │ │ │ -
968
│ │ │ │ -
969 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
971 {
│ │ │ │ -
972 includeSelf=b;
│ │ │ │ -
973 }
│ │ │ │ -
│ │ │ │ -
974
│ │ │ │ -
975 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
977 : source_(0), target_(0), sourceSeqNo_(-1),
│ │ │ │ -
978 destSeqNo_(-1), publicIgnored(false), firstBuild(true),
│ │ │ │ -
979 includeSelf(false)
│ │ │ │ -
980 {}
│ │ │ │ -
│ │ │ │ -
981
│ │ │ │ -
982 template<class T, typename A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
984 const ParallelIndexSet& destination,
│ │ │ │ -
985 const MPI_Comm& comm,
│ │ │ │ -
986 const std::vector<int>& neighbours)
│ │ │ │ -
987 {
│ │ │ │ -
988 free();
│ │ │ │ -
989 source_ = &source;
│ │ │ │ -
990 target_ = &destination;
│ │ │ │ -
991 comm_ = comm;
│ │ │ │ -
992 firstBuild = true;
│ │ │ │ -
993 setNeighbours(neighbours);
│ │ │ │ -
994 }
│ │ │ │ -
│ │ │ │ -
995
│ │ │ │ -
996 template<typename T, typename A>
│ │ │ │ - │ │ │ │ -
│ │ │ │ - │ │ │ │ -
999 {
│ │ │ │ -
1000 return *source_;
│ │ │ │ -
1001 }
│ │ │ │ -
│ │ │ │ -
1002
│ │ │ │ -
1003
│ │ │ │ -
1004 template<typename T, typename A>
│ │ │ │ - │ │ │ │ -
│ │ │ │ - │ │ │ │ -
1007 {
│ │ │ │ -
1008 return *target_;
│ │ │ │ -
1009 }
│ │ │ │ -
│ │ │ │ -
1010
│ │ │ │ -
1011
│ │ │ │ -
1012 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1014 {
│ │ │ │ -
1015 free();
│ │ │ │ -
1016 }
│ │ │ │ -
│ │ │ │ -
1017
│ │ │ │ -
1018 template<typename T, typename A>
│ │ │ │ -
1019 template<bool ignorePublic>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1021 const ParallelIndexSet& indexSet,
│ │ │ │ -
1022 char* p_out, MPI_Datatype type,
│ │ │ │ -
1023 int bufferSize,
│ │ │ │ -
1024 int *position,
│ │ │ │ -
1025 [[maybe_unused]] int n)
│ │ │ │ -
1026 {
│ │ │ │ -
1027 // fill with own indices
│ │ │ │ -
1028 const auto end = indexSet.end();
│ │ │ │ -
1029
│ │ │ │ -
1030 //Now pack the source indices
│ │ │ │ -
1031 int i=0;
│ │ │ │ -
1032 for(auto index = indexSet.begin(); index != end; ++index)
│ │ │ │ -
1033 if(ignorePublic || index->local().isPublic()) {
│ │ │ │ -
1034
│ │ │ │ -
1035 MPI_Pack(const_cast<PairType*>(&(*index)), 1,
│ │ │ │ -
1036 type,
│ │ │ │ -
1037 p_out, bufferSize, position, comm_);
│ │ │ │ -
1038 pairs[i++] = const_cast<PairType*>(&(*index));
│ │ │ │ -
1039
│ │ │ │ -
1040 }
│ │ │ │ -
1041 assert(i==n);
│ │ │ │ -
1042 }
│ │ │ │ -
│ │ │ │ -
1043
│ │ │ │ -
1044 template<typename T, typename A>
│ │ │ │ -
1045 inline int RemoteIndices<T,A>::noPublic(const ParallelIndexSet& indexSet)
│ │ │ │ -
1046 {
│ │ │ │ -
1047
│ │ │ │ -
1048 int noPublic=0;
│ │ │ │ -
1049
│ │ │ │ -
1050 const auto end=indexSet.end();
│ │ │ │ -
1051 for(auto index=indexSet.begin(); index!=end; ++index)
│ │ │ │ -
1052 if(index->local().isPublic())
│ │ │ │ -
1053 noPublic++;
│ │ │ │ -
1054
│ │ │ │ -
1055 return noPublic;
│ │ │ │ -
1056
│ │ │ │ -
1057 }
│ │ │ │ -
1058
│ │ │ │ -
1059
│ │ │ │ -
1060 template<typename T, typename A>
│ │ │ │ -
1061 inline void RemoteIndices<T,A>::unpackCreateRemote(char* p_in, PairType** sourcePairs,
│ │ │ │ -
1062 PairType** destPairs, int remoteProc,
│ │ │ │ -
1063 int sourcePublish, int destPublish,
│ │ │ │ -
1064 int bufferSize, bool sendTwo,
│ │ │ │ -
1065 bool fromOurSelf)
│ │ │ │ -
1066 {
│ │ │ │ -
1067
│ │ │ │ -
1068 // unpack the number of indices we received
│ │ │ │ -
1069 int noRemoteSource=-1, noRemoteDest=-1;
│ │ │ │ -
1070 char twoIndexSets=0;
│ │ │ │ -
1071 int position=0;
│ │ │ │ -
1072 // Did we receive two index sets?
│ │ │ │ -
1073 MPI_Unpack(p_in, bufferSize, &position, &twoIndexSets, 1, MPI_CHAR, comm_);
│ │ │ │ -
1074 // The number of source indices received
│ │ │ │ -
1075 MPI_Unpack(p_in, bufferSize, &position, &noRemoteSource, 1, MPI_INT, comm_);
│ │ │ │ -
1076 // The number of destination indices received
│ │ │ │ -
1077 MPI_Unpack(p_in, bufferSize, &position, &noRemoteDest, 1, MPI_INT, comm_);
│ │ │ │ -
1078
│ │ │ │ -
1079
│ │ │ │ -
1080 // Indices for which we receive
│ │ │ │ -
1081 RemoteIndexList* receive= new RemoteIndexList();
│ │ │ │ -
1082 // Indices for which we send
│ │ │ │ -
1083 RemoteIndexList* send=0;
│ │ │ │ -
1084
│ │ │ │ -
1085 MPI_Datatype type= MPITraits<PairType>::getType();
│ │ │ │ -
1086
│ │ │ │ -
1087 if(!twoIndexSets) {
│ │ │ │ -
1088 if(sendTwo) {
│ │ │ │ -
1089 send = new RemoteIndexList();
│ │ │ │ -
1090 // Create both remote index sets simultaneously
│ │ │ │ -
1091 unpackIndices(*send, *receive, noRemoteSource, sourcePairs, sourcePublish,
│ │ │ │ -
1092 destPairs, destPublish, p_in, type, &position, bufferSize);
│ │ │ │ -
1093 }else{
│ │ │ │ -
1094 // we only need one list
│ │ │ │ -
1095 unpackIndices(*receive, noRemoteSource, sourcePairs, sourcePublish,
│ │ │ │ -
1096 p_in, type, &position, bufferSize, fromOurSelf);
│ │ │ │ -
1097 send=receive;
│ │ │ │ -
1098 }
│ │ │ │ -
1099 }else{
│ │ │ │ -
1100
│ │ │ │ -
1101 int oldPos=position;
│ │ │ │ -
1102 // Two index sets received
│ │ │ │ -
1103 unpackIndices(*receive, noRemoteSource, destPairs, destPublish,
│ │ │ │ -
1104 p_in, type, &position, bufferSize, fromOurSelf);
│ │ │ │ -
1105 if(!sendTwo)
│ │ │ │ -
1106 //unpack source entries again as destination entries
│ │ │ │ -
1107 position=oldPos;
│ │ │ │ -
1108
│ │ │ │ -
1109 send = new RemoteIndexList();
│ │ │ │ -
1110 unpackIndices(*send, noRemoteDest, sourcePairs, sourcePublish,
│ │ │ │ -
1111 p_in, type, &position, bufferSize, fromOurSelf);
│ │ │ │ -
1112 }
│ │ │ │ -
1113
│ │ │ │ -
1114 if(receive->empty() && send->empty()) {
│ │ │ │ -
1115 if(send==receive) {
│ │ │ │ -
1116 delete send;
│ │ │ │ -
1117 }else{
│ │ │ │ -
1118 delete send;
│ │ │ │ -
1119 delete receive;
│ │ │ │ -
1120 }
│ │ │ │ -
1121 }else{
│ │ │ │ -
1122 remoteIndices_.insert(std::make_pair(remoteProc,
│ │ │ │ -
1123 std::make_pair(send,receive)));
│ │ │ │ -
1124 }
│ │ │ │ -
1125 }
│ │ │ │ -
1126
│ │ │ │ -
1127
│ │ │ │ -
1128 template<typename T, typename A>
│ │ │ │ -
1129 template<bool ignorePublic>
│ │ │ │ -
1130 inline void RemoteIndices<T,A>::buildRemote(bool includeSelf_)
│ │ │ │ -
1131 {
│ │ │ │ -
1132 // Processor configuration
│ │ │ │ -
1133 int rank, procs;
│ │ │ │ -
1134 MPI_Comm_rank(comm_, &rank);
│ │ │ │ -
1135 MPI_Comm_size(comm_, &procs);
│ │ │ │ -
1136
│ │ │ │ -
1137 // number of local indices to publish
│ │ │ │ -
1138 // The indices of the destination will be send.
│ │ │ │ -
1139 int sourcePublish, destPublish;
│ │ │ │ -
1140
│ │ │ │ -
1141 // Do we need to send two index sets?
│ │ │ │ -
1142 char sendTwo = (source_ != target_);
│ │ │ │ -
1143
│ │ │ │ -
1144 if(procs==1 && !(sendTwo || includeSelf_))
│ │ │ │ -
1145 // Nothing to communicate
│ │ │ │ -
1146 return;
│ │ │ │ -
1147
│ │ │ │ -
1148 sourcePublish = (ignorePublic) ? source_->size() : noPublic(*source_);
│ │ │ │ -
1149
│ │ │ │ -
1150 if(sendTwo)
│ │ │ │ -
1151 destPublish = (ignorePublic) ? target_->size() : noPublic(*target_);
│ │ │ │ -
1152 else
│ │ │ │ -
1153 // we only need to send one set of indices
│ │ │ │ -
1154 destPublish = 0;
│ │ │ │ -
1155
│ │ │ │ -
1156 int maxPublish, publish=sourcePublish+destPublish;
│ │ │ │ -
1157
│ │ │ │ -
1158 // Calculate maximum number of indices send
│ │ │ │ -
1159 MPI_Allreduce(&publish, &maxPublish, 1, MPI_INT, MPI_MAX, comm_);
│ │ │ │ -
1160
│ │ │ │ -
1161 // allocate buffers
│ │ │ │ -
1162 PairType** destPairs;
│ │ │ │ -
1163 PairType** sourcePairs = new PairType*[sourcePublish>0 ? sourcePublish : 1];
│ │ │ │ -
1164
│ │ │ │ -
1165 if(sendTwo)
│ │ │ │ -
1166 destPairs = new PairType*[destPublish>0 ? destPublish : 1];
│ │ │ │ -
1167 else
│ │ │ │ -
1168 destPairs=sourcePairs;
│ │ │ │ -
1169
│ │ │ │ -
1170 char** buffer = new char*[2];
│ │ │ │ -
1171 int bufferSize;
│ │ │ │ -
1172 int position=0;
│ │ │ │ -
1173 int intSize;
│ │ │ │ -
1174 int charSize;
│ │ │ │ -
1175
│ │ │ │ -
1176 // calculate buffer size
│ │ │ │ -
1177 MPI_Datatype type = MPITraits<PairType>::getType();
│ │ │ │ -
1178
│ │ │ │ -
1179 MPI_Pack_size(maxPublish, type, comm_,
│ │ │ │ -
1180 &bufferSize);
│ │ │ │ -
1181 MPI_Pack_size(1, MPI_INT, comm_,
│ │ │ │ -
1182 &intSize);
│ │ │ │ -
1183 MPI_Pack_size(1, MPI_CHAR, comm_,
│ │ │ │ -
1184 &charSize);
│ │ │ │ -
1185 // Our message will contain the following:
│ │ │ │ -
1186 // a bool whether two index sets where sent
│ │ │ │ -
1187 // the size of the source and the dest indexset,
│ │ │ │ -
1188 // then the source and destination indices
│ │ │ │ -
1189 bufferSize += 2 * intSize + charSize;
│ │ │ │ -
1190
│ │ │ │ -
1191 if(bufferSize<=0) bufferSize=1;
│ │ │ │ -
1192
│ │ │ │ -
1193 buffer[0] = new char[bufferSize];
│ │ │ │ -
1194 buffer[1] = new char[bufferSize];
│ │ │ │ -
1195
│ │ │ │ -
1196
│ │ │ │ -
1197 // pack entries into buffer[0], p_out below!
│ │ │ │ -
1198 MPI_Pack(&sendTwo, 1, MPI_CHAR, buffer[0], bufferSize, &position,
│ │ │ │ -
1199 comm_);
│ │ │ │ -
1200
│ │ │ │ -
1201 // The number of indices we send for each index set
│ │ │ │ -
1202 MPI_Pack(&sourcePublish, 1, MPI_INT, buffer[0], bufferSize, &position,
│ │ │ │ -
1203 comm_);
│ │ │ │ -
1204 MPI_Pack(&destPublish, 1, MPI_INT, buffer[0], bufferSize, &position,
│ │ │ │ -
1205 comm_);
│ │ │ │ -
1206
│ │ │ │ -
1207 // Now pack the source indices and setup the destination pairs
│ │ │ │ -
1208 packEntries<ignorePublic>(sourcePairs, *source_, buffer[0], type,
│ │ │ │ -
1209 bufferSize, &position, sourcePublish);
│ │ │ │ -
1210 // If necessary send the dest indices and setup the source pairs
│ │ │ │ -
1211 if(sendTwo)
│ │ │ │ -
1212 packEntries<ignorePublic>(destPairs, *target_, buffer[0], type,
│ │ │ │ -
1213 bufferSize, &position, destPublish);
│ │ │ │ -
1214
│ │ │ │ -
1215
│ │ │ │ -
1216 // Update remote indices for ourself
│ │ │ │ -
1217 if(sendTwo|| includeSelf_)
│ │ │ │ -
1218 unpackCreateRemote(buffer[0], sourcePairs, destPairs, rank, sourcePublish,
│ │ │ │ -
1219 destPublish, bufferSize, sendTwo, includeSelf_);
│ │ │ │ -
1220
│ │ │ │ -
1221 neighbourIds.erase(rank);
│ │ │ │ -
1222
│ │ │ │ -
1223 if(neighbourIds.size()==0)
│ │ │ │ -
1224 {
│ │ │ │ -
1225 Dune::dvverb<<rank<<": Sending messages in a ring"<<std::endl;
│ │ │ │ -
1226 // send messages in ring
│ │ │ │ -
1227 for(int proc=1; proc<procs; proc++) {
│ │ │ │ -
1228 // pointers to the current input and output buffers
│ │ │ │ -
1229 char* p_out = buffer[1-(proc%2)];
│ │ │ │ -
1230 char* p_in = buffer[proc%2];
│ │ │ │ -
1231
│ │ │ │ -
1232 MPI_Status status;
│ │ │ │ -
1233 if(rank%2==0) {
│ │ │ │ -
1234 MPI_Ssend(p_out, bufferSize, MPI_PACKED, (rank+1)%procs,
│ │ │ │ -
1235 commTag_, comm_);
│ │ │ │ -
1236 MPI_Recv(p_in, bufferSize, MPI_PACKED, (rank+procs-1)%procs,
│ │ │ │ -
1237 commTag_, comm_, &status);
│ │ │ │ -
1238 }else{
│ │ │ │ -
1239 MPI_Recv(p_in, bufferSize, MPI_PACKED, (rank+procs-1)%procs,
│ │ │ │ -
1240 commTag_, comm_, &status);
│ │ │ │ -
1241 MPI_Ssend(p_out, bufferSize, MPI_PACKED, (rank+1)%procs,
│ │ │ │ -
1242 commTag_, comm_);
│ │ │ │ -
1243 }
│ │ │ │ -
1244
│ │ │ │ -
1245
│ │ │ │ -
1246 // The process these indices are from
│ │ │ │ -
1247 int remoteProc = (rank+procs-proc)%procs;
│ │ │ │ -
1248
│ │ │ │ -
1249 unpackCreateRemote(p_in, sourcePairs, destPairs, remoteProc, sourcePublish,
│ │ │ │ -
1250 destPublish, bufferSize, sendTwo);
│ │ │ │ -
1251
│ │ │ │ -
1252 }
│ │ │ │ -
1253
│ │ │ │ -
1254 }
│ │ │ │ -
1255 else
│ │ │ │ -
1256 {
│ │ │ │ -
1257 MPI_Request* requests=new MPI_Request[neighbourIds.size()];
│ │ │ │ -
1258 MPI_Request* req=requests;
│ │ │ │ -
1259
│ │ │ │ -
1260 typedef typename std::set<int>::size_type size_type;
│ │ │ │ -
1261 size_type noNeighbours=neighbourIds.size();
│ │ │ │ -
1262
│ │ │ │ -
1263 // setup sends
│ │ │ │ -
1264 for(std::set<int>::iterator neighbour=neighbourIds.begin();
│ │ │ │ -
1265 neighbour!= neighbourIds.end(); ++neighbour) {
│ │ │ │ -
1266 // Only send the information to the neighbouring processors
│ │ │ │ -
1267 MPI_Issend(buffer[0], position , MPI_PACKED, *neighbour, commTag_, comm_, req++);
│ │ │ │ -
1268 }
│ │ │ │ -
1269
│ │ │ │ -
1270 //Test for received messages
│ │ │ │ -
1271
│ │ │ │ -
1272 for(size_type received=0; received <noNeighbours; ++received)
│ │ │ │ -
1273 {
│ │ │ │ -
1274 MPI_Status status;
│ │ │ │ -
1275 // probe for next message
│ │ │ │ -
1276 MPI_Probe(MPI_ANY_SOURCE, commTag_, comm_, &status);
│ │ │ │ -
1277 int remoteProc=status.MPI_SOURCE;
│ │ │ │ -
1278 int size;
│ │ │ │ -
1279 MPI_Get_count(&status, MPI_PACKED, &size);
│ │ │ │ -
1280 // receive message
│ │ │ │ -
1281 MPI_Recv(buffer[1], size, MPI_PACKED, remoteProc,
│ │ │ │ -
1282 commTag_, comm_, &status);
│ │ │ │ -
1283
│ │ │ │ -
1284 unpackCreateRemote(buffer[1], sourcePairs, destPairs, remoteProc, sourcePublish,
│ │ │ │ -
1285 destPublish, bufferSize, sendTwo);
│ │ │ │ -
1286 }
│ │ │ │ -
1287 // wait for completion of pending requests
│ │ │ │ -
1288 MPI_Status* statuses = new MPI_Status[neighbourIds.size()];
│ │ │ │ -
1289
│ │ │ │ -
1290 if(int(MPI_ERR_IN_STATUS)==MPI_Waitall(neighbourIds.size(), requests, statuses)) {
│ │ │ │ -
1291 for(size_type i=0; i < neighbourIds.size(); ++i)
│ │ │ │ -
1292 if(statuses[i].MPI_ERROR!=MPI_SUCCESS) {
│ │ │ │ -
1293 std::cerr<<rank<<": MPI_Error occurred while receiving message."<<std::endl;
│ │ │ │ -
1294 MPI_Abort(comm_, 999);
│ │ │ │ -
1295 }
│ │ │ │ -
1296 }
│ │ │ │ -
1297 delete[] requests;
│ │ │ │ -
1298 delete[] statuses;
│ │ │ │ -
1299 }
│ │ │ │ -
1300
│ │ │ │ -
1301
│ │ │ │ -
1302 // delete allocated memory
│ │ │ │ -
1303 if(destPairs!=sourcePairs)
│ │ │ │ -
1304 delete[] destPairs;
│ │ │ │ -
1305
│ │ │ │ -
1306 delete[] sourcePairs;
│ │ │ │ -
1307 delete[] buffer[0];
│ │ │ │ -
1308 delete[] buffer[1];
│ │ │ │ -
1309 delete[] buffer;
│ │ │ │ -
1310 }
│ │ │ │ -
1311
│ │ │ │ -
1312 template<typename T, typename A>
│ │ │ │ -
1313 inline void RemoteIndices<T,A>::unpackIndices(RemoteIndexList& remote,
│ │ │ │ -
1314 int remoteEntries,
│ │ │ │ -
1315 PairType** local,
│ │ │ │ -
1316 int localEntries,
│ │ │ │ -
1317 char* p_in,
│ │ │ │ -
1318 MPI_Datatype type,
│ │ │ │ -
1319 int* position,
│ │ │ │ -
1320 int bufferSize,
│ │ │ │ -
1321 bool fromOurSelf)
│ │ │ │ -
1322 {
│ │ │ │ -
1323 if(remoteEntries==0)
│ │ │ │ -
1324 return;
│ │ │ │ -
1325
│ │ │ │ -
1326 PairType index;
│ │ │ │ -
1327 MPI_Unpack(p_in, bufferSize, position, &index, 1,
│ │ │ │ -
1328 type, comm_);
│ │ │ │ -
1329 GlobalIndex oldGlobal=index.global();
│ │ │ │ -
1330 int n_in=0, localIndex=0;
│ │ │ │ -
1331
│ │ │ │ -
1332 //Check if we know the global index
│ │ │ │ -
1333 while(localIndex<localEntries) {
│ │ │ │ -
1334 if(local[localIndex]->global()==index.global()) {
│ │ │ │ -
1335 int oldLocalIndex=localIndex;
│ │ │ │ -
1336
│ │ │ │ -
1337 while(localIndex<localEntries &&
│ │ │ │ -
1338 local[localIndex]->global()==index.global()) {
│ │ │ │ -
1339 if(!fromOurSelf || index.local().attribute() !=
│ │ │ │ -
1340 local[localIndex]->local().attribute())
│ │ │ │ -
1341 // if index is from us it has to have a different attribute
│ │ │ │ -
1342 remote.push_back(RemoteIndex(index.local().attribute(),
│ │ │ │ -
1343 local[localIndex]));
│ │ │ │ -
1344 localIndex++;
│ │ │ │ -
1345 }
│ │ │ │ -
1346
│ │ │ │ -
1347 // unpack next remote index
│ │ │ │ -
1348 if((++n_in) < remoteEntries) {
│ │ │ │ -
1349 MPI_Unpack(p_in, bufferSize, position, &index, 1,
│ │ │ │ -
1350 type, comm_);
│ │ │ │ -
1351 if(index.global()==oldGlobal)
│ │ │ │ -
1352 // Restart comparison for the same global indices
│ │ │ │ -
1353 localIndex=oldLocalIndex;
│ │ │ │ -
1354 else
│ │ │ │ -
1355 oldGlobal=index.global();
│ │ │ │ -
1356 }else{
│ │ │ │ -
1357 // No more received indices
│ │ │ │ -
1358 break;
│ │ │ │ -
1359 }
│ │ │ │ -
1360 continue;
│ │ │ │ -
1361 }
│ │ │ │ -
1362
│ │ │ │ -
1363 if (local[localIndex]->global()<index.global()) {
│ │ │ │ -
1364 // compare with next entry in our list
│ │ │ │ -
1365 ++localIndex;
│ │ │ │ -
1366 }else{
│ │ │ │ -
1367 // We do not know the index, unpack next
│ │ │ │ -
1368 if((++n_in) < remoteEntries) {
│ │ │ │ -
1369 MPI_Unpack(p_in, bufferSize, position, &index, 1,
│ │ │ │ -
1370 type, comm_);
│ │ │ │ -
1371 oldGlobal=index.global();
│ │ │ │ -
1372 }else
│ │ │ │ -
1373 // No more received indices
│ │ │ │ -
1374 break;
│ │ │ │ -
1375 }
│ │ │ │ -
1376 }
│ │ │ │ -
1377
│ │ │ │ -
1378 // Unpack the other received indices without doing anything
│ │ │ │ -
1379 while(++n_in < remoteEntries)
│ │ │ │ -
1380 MPI_Unpack(p_in, bufferSize, position, &index, 1,
│ │ │ │ -
1381 type, comm_);
│ │ │ │ -
1382 }
│ │ │ │ -
1383
│ │ │ │ -
1384
│ │ │ │ -
1385 template<typename T, typename A>
│ │ │ │ -
1386 inline void RemoteIndices<T,A>::unpackIndices(RemoteIndexList& send,
│ │ │ │ -
1387 RemoteIndexList& receive,
│ │ │ │ -
1388 int remoteEntries,
│ │ │ │ -
1389 PairType** localSource,
│ │ │ │ -
1390 int localSourceEntries,
│ │ │ │ -
1391 PairType** localDest,
│ │ │ │ -
1392 int localDestEntries,
│ │ │ │ -
1393 char* p_in,
│ │ │ │ -
1394 MPI_Datatype type,
│ │ │ │ -
1395 int* position,
│ │ │ │ -
1396 int bufferSize)
│ │ │ │ -
1397 {
│ │ │ │ -
1398 int n_in=0, sourceIndex=0, destIndex=0;
│ │ │ │ -
1399
│ │ │ │ -
1400 //Check if we know the global index
│ │ │ │ -
1401 while(n_in<remoteEntries && (sourceIndex<localSourceEntries || destIndex<localDestEntries)) {
│ │ │ │ -
1402 // Unpack next index
│ │ │ │ -
1403 PairType index;
│ │ │ │ -
1404 MPI_Unpack(p_in, bufferSize, position, &index, 1,
│ │ │ │ -
1405 type, comm_);
│ │ │ │ -
1406 n_in++;
│ │ │ │ -
1407
│ │ │ │ -
1408 // Advance until global index in localSource and localDest are >= than the one in the unpacked index
│ │ │ │ -
1409 while(sourceIndex<localSourceEntries && localSource[sourceIndex]->global()<index.global())
│ │ │ │ -
1410 sourceIndex++;
│ │ │ │ -
1411
│ │ │ │ -
1412 while(destIndex<localDestEntries && localDest[destIndex]->global()<index.global())
│ │ │ │ -
1413 destIndex++;
│ │ │ │ -
1414
│ │ │ │ -
1415 // Add a remote index if we found the global index.
│ │ │ │ -
1416 if(sourceIndex<localSourceEntries && localSource[sourceIndex]->global()==index.global())
│ │ │ │ -
1417 send.push_back(RemoteIndex(index.local().attribute(),
│ │ │ │ -
1418 localSource[sourceIndex]));
│ │ │ │ -
1419
│ │ │ │ -
1420 if(destIndex < localDestEntries && localDest[destIndex]->global() == index.global())
│ │ │ │ -
1421 receive.push_back(RemoteIndex(index.local().attribute(),
│ │ │ │ -
1422 localDest[sourceIndex]));
│ │ │ │ -
1423 }
│ │ │ │ -
1424
│ │ │ │ -
1425 }
│ │ │ │ -
1426
│ │ │ │ -
1427 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1429 {
│ │ │ │ -
1430 auto lend = remoteIndices_.end();
│ │ │ │ -
1431 for(auto lists=remoteIndices_.begin(); lists != lend; ++lists) {
│ │ │ │ -
1432 if(lists->second.first==lists->second.second) {
│ │ │ │ -
1433 // there is only one remote index list.
│ │ │ │ -
1434 delete lists->second.first;
│ │ │ │ -
1435 }else{
│ │ │ │ -
1436 delete lists->second.first;
│ │ │ │ -
1437 delete lists->second.second;
│ │ │ │ -
1438 }
│ │ │ │ -
1439 }
│ │ │ │ -
1440 remoteIndices_.clear();
│ │ │ │ -
1441 firstBuild=true;
│ │ │ │ -
1442 }
│ │ │ │ -
│ │ │ │ -
1443
│ │ │ │ -
1444 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1446 {
│ │ │ │ -
1447 return remoteIndices_.size();
│ │ │ │ -
1448 }
│ │ │ │ -
│ │ │ │ -
1449
│ │ │ │ -
1450 template<typename T, typename A>
│ │ │ │ -
1451 template<bool ignorePublic>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1453 {
│ │ │ │ -
1454 // Test whether a rebuild is Needed.
│ │ │ │ -
1455 if(firstBuild ||
│ │ │ │ -
1456 ignorePublic!=publicIgnored || !
│ │ │ │ -
1457 isSynced()) {
│ │ │ │ -
1458 free();
│ │ │ │ -
1459
│ │ │ │ -
1460 buildRemote<ignorePublic>(includeSelf);
│ │ │ │ -
1461
│ │ │ │ -
1462 sourceSeqNo_ = source_->seqNo();
│ │ │ │ -
1463 destSeqNo_ = target_->seqNo();
│ │ │ │ -
1464 firstBuild=false;
│ │ │ │ -
1465 publicIgnored=ignorePublic;
│ │ │ │ -
1466 }
│ │ │ │ -
1467
│ │ │ │ -
1468
│ │ │ │ -
1469 }
│ │ │ │ -
│ │ │ │ -
1470
│ │ │ │ -
1471 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1473 {
│ │ │ │ -
1474 return sourceSeqNo_==source_->seqNo() && destSeqNo_ ==target_->seqNo();
│ │ │ │ -
1475 }
│ │ │ │ -
│ │ │ │ -
1476
│ │ │ │ -
1477 template<typename T, typename A>
│ │ │ │ -
1478 template<bool mode, bool send>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1480 {
│ │ │ │ -
1481
│ │ │ │ -
1482 // The user are on their own now!
│ │ │ │ -
1483 // We assume they know what they are doing and just set the
│ │ │ │ -
1484 // remote indices to synced status.
│ │ │ │ -
1485 sourceSeqNo_ = source_->seqNo();
│ │ │ │ -
1486 destSeqNo_ = target_->seqNo();
│ │ │ │ -
1487
│ │ │ │ -
1488 typename RemoteIndexMap::iterator found = remoteIndices_.find(process);
│ │ │ │ -
1489
│ │ │ │ -
1490 if(found == remoteIndices_.end())
│ │ │ │ -
1491 {
│ │ │ │ -
1492 if(source_ != target_)
│ │ │ │ -
1493 found = remoteIndices_.insert(found, std::make_pair(process,
│ │ │ │ -
1494 std::make_pair(new RemoteIndexList(),
│ │ │ │ -
1495 new RemoteIndexList())));
│ │ │ │ -
1496 else{
│ │ │ │ -
1497 RemoteIndexList* rlist = new RemoteIndexList();
│ │ │ │ -
1498 found = remoteIndices_.insert(found,
│ │ │ │ -
1499 std::make_pair(process,
│ │ │ │ -
1500 std::make_pair(rlist, rlist)));
│ │ │ │ -
1501 }
│ │ │ │ -
1502 }
│ │ │ │ -
1503
│ │ │ │ -
1504 firstBuild = false;
│ │ │ │ -
1505
│ │ │ │ -
1506 if(send)
│ │ │ │ -
1507 return RemoteIndexListModifier<T,A,mode>(*source_, *(found->second.first));
│ │ │ │ -
1508 else
│ │ │ │ -
1509 return RemoteIndexListModifier<T,A,mode>(*target_, *(found->second.second));
│ │ │ │ -
1510 }
│ │ │ │ -
│ │ │ │ -
1511
│ │ │ │ -
1512 template<typename T, typename A>
│ │ │ │ - │ │ │ │ -
│ │ │ │ - │ │ │ │ -
1515 {
│ │ │ │ -
1516 return remoteIndices_.find(proc);
│ │ │ │ -
1517 }
│ │ │ │ -
│ │ │ │ -
1518
│ │ │ │ -
1519 template<typename T, typename A>
│ │ │ │ - │ │ │ │ -
│ │ │ │ - │ │ │ │ -
1522 {
│ │ │ │ -
1523 return remoteIndices_.begin();
│ │ │ │ -
1524 }
│ │ │ │ -
│ │ │ │ -
1525
│ │ │ │ -
1526 template<typename T, typename A>
│ │ │ │ - │ │ │ │ -
│ │ │ │ - │ │ │ │ -
1529 {
│ │ │ │ -
1530 return remoteIndices_.end();
│ │ │ │ -
1531 }
│ │ │ │ -
│ │ │ │ -
1532
│ │ │ │ -
1533
│ │ │ │ -
1534 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1536 {
│ │ │ │ -
1537 if(neighbours()!=ri.neighbours())
│ │ │ │ -
1538 return false;
│ │ │ │ -
1539
│ │ │ │ -
1540 const auto rend = remoteIndices_.end();
│ │ │ │ -
1541
│ │ │ │ -
1542 for(auto rindex = remoteIndices_.begin(), rindex1=ri.remoteIndices_.begin(); rindex!=rend; ++rindex, ++rindex1) {
│ │ │ │ -
1543 if(rindex->first != rindex1->first)
│ │ │ │ -
1544 return false;
│ │ │ │ -
1545 if(*(rindex->second.first) != *(rindex1->second.first))
│ │ │ │ -
1546 return false;
│ │ │ │ -
1547 if(*(rindex->second.second) != *(rindex1->second.second))
│ │ │ │ -
1548 return false;
│ │ │ │ -
1549 }
│ │ │ │ -
1550 return true;
│ │ │ │ -
1551 }
│ │ │ │ -
│ │ │ │ -
1552
│ │ │ │ -
1553 template<class T, class A, bool mode>
│ │ │ │ - │ │ │ │ -
1555 RemoteIndexList& rList)
│ │ │ │ -
1556 : rList_(&rList), indexSet_(&indexSet), iter_(rList.beginModify()), end_(rList.end()), first_(true)
│ │ │ │ -
1557 {
│ │ │ │ -
1558 if(MODIFYINDEXSET) {
│ │ │ │ -
1559 assert(indexSet_);
│ │ │ │ -
1560 for(ConstIterator iter=iter_; iter != end_; ++iter)
│ │ │ │ -
1561 glist_.push_back(iter->localIndexPair().global());
│ │ │ │ -
1562 giter_ = glist_.beginModify();
│ │ │ │ -
1563 }
│ │ │ │ -
1564 }
│ │ │ │ -
1565
│ │ │ │ -
1566 template<typename T, typename A, bool mode>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1568 : rList_(other.rList_), indexSet_(other.indexSet_),
│ │ │ │ -
1569 glist_(other.glist_), iter_(other.iter_), giter_(other.giter_), end_(other.end_),
│ │ │ │ -
1570 first_(other.first_), last_(other.last_)
│ │ │ │ -
1571 {}
│ │ │ │ -
│ │ │ │ -
1572
│ │ │ │ -
1573 template<typename T, typename A, bool mode>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1575 {
│ │ │ │ -
1576 if(MODIFYINDEXSET) {
│ │ │ │ -
1577 // repair pointers to local index set.
│ │ │ │ -
1578#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ -
1579 if(indexSet_->state()!=GROUND)
│ │ │ │ -
1580 DUNE_THROW(InvalidIndexSetState, "Index has to be in ground mode for repairing pointers to indices");
│ │ │ │ -
1581#endif
│ │ │ │ -
1582 auto giter = glist_.begin();
│ │ │ │ -
1583 auto index = indexSet_->begin();
│ │ │ │ -
1584
│ │ │ │ -
1585 for(auto iter=rList_->begin(); iter != end_; ++iter) {
│ │ │ │ -
1586 while(index->global()<*giter) {
│ │ │ │ -
1587 ++index;
│ │ │ │ -
1588#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ -
1589 if(index == indexSet_->end())
│ │ │ │ -
1590 DUNE_THROW(InvalidPosition, "No such global index in set!");
│ │ │ │ -
1591#endif
│ │ │ │ -
1592 }
│ │ │ │ -
1593
│ │ │ │ -
1594#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ -
1595 if(index->global() != *giter)
│ │ │ │ -
1596 DUNE_THROW(InvalidPosition, "No such global index in set!");
│ │ │ │ -
1597#endif
│ │ │ │ -
1598 iter->localIndex_ = &(*index);
│ │ │ │ -
1599 }
│ │ │ │ -
1600 }
│ │ │ │ -
1601 }
│ │ │ │ -
│ │ │ │ -
1602
│ │ │ │ -
1603 template<typename T, typename A, bool mode>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1605 {
│ │ │ │ -
1606 static_assert(!mode,"Not allowed if the mode indicates that new indices"
│ │ │ │ -
1607 "might be added to the underlying index set. Use "
│ │ │ │ -
1608 "insert(const RemoteIndex&, const GlobalIndex&) instead");
│ │ │ │ -
1609
│ │ │ │ -
1610#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ -
1611 if(!first_ && index.localIndexPair().global()<last_)
│ │ │ │ -
1612 DUNE_THROW(InvalidPosition, "Modification of remote indices have to occur with ascending global index.");
│ │ │ │ -
1613#endif
│ │ │ │ -
1614 // Move to the correct position
│ │ │ │ -
1615 while(iter_ != end_ && iter_->localIndexPair().global() < index.localIndexPair().global()) {
│ │ │ │ -
1616 ++iter_;
│ │ │ │ -
1617 }
│ │ │ │ -
1618
│ │ │ │ -
1619 // No duplicate entries allowed
│ │ │ │ -
1620 assert(iter_==end_ || iter_->localIndexPair().global() != index.localIndexPair().global());
│ │ │ │ -
1621 iter_.insert(index);
│ │ │ │ -
1622 last_ = index.localIndexPair().global();
│ │ │ │ -
1623 first_ = false;
│ │ │ │ -
1624 }
│ │ │ │ -
│ │ │ │ -
1625
│ │ │ │ -
1626 template<typename T, typename A, bool mode>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1628 {
│ │ │ │ -
1629 static_assert(mode,"Not allowed if the mode indicates that no new indices"
│ │ │ │ -
1630 "might be added to the underlying index set. Use "
│ │ │ │ -
1631 "insert(const RemoteIndex&) instead");
│ │ │ │ -
1632#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ -
1633 if(!first_ && global<last_)
│ │ │ │ -
1634 DUNE_THROW(InvalidPosition, "Modification of remote indices have to occur with ascending global index.");
│ │ │ │ -
1635#endif
│ │ │ │ -
1636 // Move to the correct position
│ │ │ │ -
1637 while(iter_ != end_ && *giter_ < global) {
│ │ │ │ -
1638 ++giter_;
│ │ │ │ -
1639 ++iter_;
│ │ │ │ -
1640 }
│ │ │ │ -
1641
│ │ │ │ -
1642 // No duplicate entries allowed
│ │ │ │ -
1643 assert(iter_->localIndexPair().global() != global);
│ │ │ │ -
1644 iter_.insert(index);
│ │ │ │ -
1645 giter_.insert(global);
│ │ │ │ -
1646
│ │ │ │ -
1647 last_ = global;
│ │ │ │ -
1648 first_ = false;
│ │ │ │ -
1649 }
│ │ │ │ -
│ │ │ │ -
1650
│ │ │ │ -
1651 template<typename T, typename A, bool mode>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1653 {
│ │ │ │ -
1654#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ -
1655 if(!first_ && global<last_)
│ │ │ │ -
1656 DUNE_THROW(InvalidPosition, "Modification of remote indices have to occur with ascending global index.");
│ │ │ │ -
1657#endif
│ │ │ │ -
1658
│ │ │ │ -
1659 bool found= false;
│ │ │ │ -
1660
│ │ │ │ -
1661 if(MODIFYINDEXSET) {
│ │ │ │ -
1662 // Move to the correct position
│ │ │ │ -
1663 while(iter_!=end_ && *giter_< global) {
│ │ │ │ -
1664 ++giter_;
│ │ │ │ -
1665 ++iter_;
│ │ │ │ -
1666 }
│ │ │ │ -
1667 if(*giter_ == global) {
│ │ │ │ -
1668 giter_.remove();
│ │ │ │ -
1669 iter_.remove();
│ │ │ │ -
1670 found=true;
│ │ │ │ -
1671 }
│ │ │ │ -
1672 }else{
│ │ │ │ -
1673 while(iter_!=end_ && iter_->localIndexPair().global() < global)
│ │ │ │ -
1674 ++iter_;
│ │ │ │ -
1675
│ │ │ │ -
1676 if(iter_->localIndexPair().global()==global) {
│ │ │ │ -
1677 iter_.remove();
│ │ │ │ -
1678 found = true;
│ │ │ │ -
1679 }
│ │ │ │ -
1680 }
│ │ │ │ -
1681
│ │ │ │ -
1682 last_ = global;
│ │ │ │ -
1683 first_ = false;
│ │ │ │ -
1684 return found;
│ │ │ │ -
1685 }
│ │ │ │ -
│ │ │ │ -
1686
│ │ │ │ -
1687 template<typename T, typename A>
│ │ │ │ -
1688 template<bool send>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1690 {
│ │ │ │ -
1691 return CollectiveIterator<T,A>(remoteIndices_, send);
│ │ │ │ -
1692 }
│ │ │ │ -
│ │ │ │ -
1693
│ │ │ │ -
1694 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ -
1695 inline MPI_Comm RemoteIndices<T,A>::communicator() const
│ │ │ │ -
1696 {
│ │ │ │ -
1697 return comm_;
│ │ │ │ -
1698
│ │ │ │ -
1699 }
│ │ │ │ -
│ │ │ │ -
1700
│ │ │ │ -
1701 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1703 {
│ │ │ │ -
1704
│ │ │ │ -
1705 const auto end = pmap.end();
│ │ │ │ -
1706 for(auto process = pmap.begin(); process != end; ++process) {
│ │ │ │ -
1707 const RemoteIndexList* list = send ? process->second.first : process->second.second;
│ │ │ │ -
1708 using ri_iterator = typename RemoteIndexList::const_iterator;
│ │ │ │ -
1709 map_.insert(std::make_pair(process->first,
│ │ │ │ -
1710 std::pair<ri_iterator, const ri_iterator>(list->begin(), list->end())));
│ │ │ │ -
1711 }
│ │ │ │ -
1712 }
│ │ │ │ -
│ │ │ │ -
1713
│ │ │ │ -
1714 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ -
1715 inline void CollectiveIterator<T,A>::advance(const GlobalIndex& index)
│ │ │ │ -
1716 {
│ │ │ │ -
1717 const auto end = map_.end();
│ │ │ │ -
1718
│ │ │ │ -
1719 for(auto iter = map_.begin(); iter != end;) {
│ │ │ │ -
1720 // Step the iterator until we are >= index
│ │ │ │ -
1721 typename RemoteIndexList::const_iterator current = iter->second.first;
│ │ │ │ -
1722 typename RemoteIndexList::const_iterator rend = iter->second.second;
│ │ │ │ -
1723 RemoteIndex remoteIndex;
│ │ │ │ -
1724 if(current != rend)
│ │ │ │ -
1725 remoteIndex = *current;
│ │ │ │ -
1726
│ │ │ │ -
1727 while(iter->second.first!=iter->second.second && iter->second.first->localIndexPair().global()<index)
│ │ │ │ -
1728 ++(iter->second.first);
│ │ │ │ -
1729
│ │ │ │ -
1730 // erase from the map if there are no more entries.
│ │ │ │ -
1731 if(iter->second.first == iter->second.second)
│ │ │ │ -
1732 map_.erase(iter++);
│ │ │ │ -
1733 else{
│ │ │ │ -
1734 ++iter;
│ │ │ │ -
1735 }
│ │ │ │ -
1736 }
│ │ │ │ -
1737 index_=index;
│ │ │ │ -
1738 noattribute=true;
│ │ │ │ -
1739 }
│ │ │ │ -
│ │ │ │ -
1740
│ │ │ │ -
1741 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ -
1742 inline void CollectiveIterator<T,A>::advance(const GlobalIndex& index,
│ │ │ │ -
1743 const Attribute& attribute)
│ │ │ │ -
1744 {
│ │ │ │ -
1745 const auto end = map_.end();
│ │ │ │ -
1746
│ │ │ │ -
1747 for(auto iter = map_.begin(); iter != end;) {
│ │ │ │ -
1748 // Step the iterator until we are >= index
│ │ │ │ -
1749 typename RemoteIndexList::const_iterator current = iter->second.first;
│ │ │ │ -
1750 typename RemoteIndexList::const_iterator rend = iter->second.second;
│ │ │ │ -
1751 RemoteIndex remoteIndex;
│ │ │ │ -
1752 if(current != rend)
│ │ │ │ -
1753 remoteIndex = *current;
│ │ │ │ -
1754
│ │ │ │ -
1755 // Move to global index or bigger
│ │ │ │ -
1756 while(iter->second.first!=iter->second.second && iter->second.first->localIndexPair().global()<index)
│ │ │ │ -
1757 ++(iter->second.first);
│ │ │ │ -
1758
│ │ │ │ -
1759 // move to attribute or bigger
│ │ │ │ -
1760 while(iter->second.first!=iter->second.second
│ │ │ │ -
1761 && iter->second.first->localIndexPair().global()==index
│ │ │ │ -
1762 && iter->second.first->localIndexPair().local().attribute()<attribute)
│ │ │ │ -
1763 ++(iter->second.first);
│ │ │ │ -
1764
│ │ │ │ -
1765 // erase from the map if there are no more entries.
│ │ │ │ -
1766 if(iter->second.first == iter->second.second)
│ │ │ │ -
1767 map_.erase(iter++);
│ │ │ │ -
1768 else{
│ │ │ │ -
1769 ++iter;
│ │ │ │ -
1770 }
│ │ │ │ -
1771 }
│ │ │ │ -
1772 index_=index;
│ │ │ │ -
1773 attribute_=attribute;
│ │ │ │ -
1774 noattribute=false;
│ │ │ │ -
1775 }
│ │ │ │ -
│ │ │ │ -
1776
│ │ │ │ -
1777 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1779 {
│ │ │ │ -
1780 const auto end = map_.end();
│ │ │ │ -
1781
│ │ │ │ -
1782 for(auto iter = map_.begin(); iter != end;) {
│ │ │ │ -
1783 // Step the iterator until we are >= index
│ │ │ │ -
1784 auto current = iter->second.first;
│ │ │ │ -
1785 auto rend = iter->second.second;
│ │ │ │ -
1786
│ │ │ │ -
1787 // move all iterators pointing to the current global index to next value
│ │ │ │ -
1788 if(iter->second.first->localIndexPair().global()==index_ &&
│ │ │ │ -
1789 (noattribute || iter->second.first->localIndexPair().local().attribute() == attribute_))
│ │ │ │ -
1790 ++(iter->second.first);
│ │ │ │ -
1791
│ │ │ │ -
1792 // erase from the map if there are no more entries.
│ │ │ │ -
1793 if(iter->second.first == iter->second.second)
│ │ │ │ -
1794 map_.erase(iter++);
│ │ │ │ -
1795 else{
│ │ │ │ -
1796 ++iter;
│ │ │ │ -
1797 }
│ │ │ │ -
1798 }
│ │ │ │ -
1799 return *this;
│ │ │ │ -
1800 }
│ │ │ │ -
│ │ │ │ -
1801
│ │ │ │ -
1802 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1804 {
│ │ │ │ -
1805 return map_.empty();
│ │ │ │ -
1806 }
│ │ │ │ -
│ │ │ │ -
1807
│ │ │ │ -
1808 template<typename T, typename A>
│ │ │ │ -
1809 inline typename CollectiveIterator<T,A>::iterator
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1811 {
│ │ │ │ -
1812 if(noattribute)
│ │ │ │ -
1813 return iterator(map_.begin(), map_.end(), index_);
│ │ │ │ -
1814 else
│ │ │ │ -
1815 return iterator(map_.begin(), map_.end(), index_,
│ │ │ │ -
1816 attribute_);
│ │ │ │ -
1817 }
│ │ │ │ -
│ │ │ │ -
1818
│ │ │ │ -
1819 template<typename T, typename A>
│ │ │ │ -
1820 inline typename CollectiveIterator<T,A>::iterator
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
1822 {
│ │ │ │ -
1823 return iterator(map_.end(), map_.end(), index_);
│ │ │ │ -
1824 }
│ │ │ │ -
│ │ │ │ -
1825
│ │ │ │ -
1826 template<typename TG, typename TA>
│ │ │ │ -
│ │ │ │ -
1827 inline std::ostream& operator<<(std::ostream& os, const RemoteIndex<TG,TA>& index)
│ │ │ │ -
1828 {
│ │ │ │ -
1829 os<<"[global="<<index.localIndexPair().global()<<", remote attribute="<<index.attribute()<<" local attribute="<<index.localIndexPair().local().attribute()<<"]";
│ │ │ │ -
1830 return os;
│ │ │ │ -
1831 }
│ │ │ │ -
│ │ │ │ -
1832
│ │ │ │ -
1833 template<typename T, typename A>
│ │ │ │ -
│ │ │ │ -
1834 inline std::ostream& operator<<(std::ostream& os, const RemoteIndices<T,A>& indices)
│ │ │ │ -
1835 {
│ │ │ │ -
1836 int rank;
│ │ │ │ -
1837 MPI_Comm_rank(indices.comm_, &rank);
│ │ │ │ -
1838 const auto rend = indices.remoteIndices_.end();
│ │ │ │ -
1839
│ │ │ │ -
1840 for(auto rindex = indices.remoteIndices_.begin(); rindex!=rend; ++rindex) {
│ │ │ │ -
1841 os<<rank<<": Process "<<rindex->first<<":";
│ │ │ │ -
1842
│ │ │ │ -
1843 if(!rindex->second.first->empty()) {
│ │ │ │ -
1844 os<<" send:";
│ │ │ │ -
1845
│ │ │ │ -
1846 const auto send= rindex->second.first->end();
│ │ │ │ -
1847
│ │ │ │ -
1848 for(auto index = rindex->second.first->begin();
│ │ │ │ -
1849 index != send; ++index)
│ │ │ │ -
1850 os<<*index<<" ";
│ │ │ │ -
1851 os<<std::endl;
│ │ │ │ -
1852 }
│ │ │ │ -
1853 if(!rindex->second.second->empty()) {
│ │ │ │ -
1854 os<<rank<<": Process "<<rindex->first<<": "<<"receive: ";
│ │ │ │ -
1855
│ │ │ │ -
1856 for(const auto& index : *(rindex->second.second))
│ │ │ │ -
1857 os << index << " ";
│ │ │ │ -
1858 }
│ │ │ │ -
1859 os<<std::endl<<std::flush;
│ │ │ │ -
1860 }
│ │ │ │ -
1861 return os;
│ │ │ │ -
1862 }
│ │ │ │ -
│ │ │ │ -
1864}
│ │ │ │ -
1865
│ │ │ │ -
1866#endif // HAVE_MPI
│ │ │ │ -
1867#endif // DUNE_COMMON_PARALLEL_REMOTEINDICES_HH
│ │ │ │ -
Provides a map between global and local indices.
│ │ │ │ -
Provides classes for use as the local index in ParallelIndexSet for distributed computing.
│ │ │ │ -
Traits classes for mapping types onto MPI_Datatype.
│ │ │ │ -
Standard Dune debug streams.
│ │ │ │ -
Implements a singly linked list together with the necessary iterators.
│ │ │ │ -
A few common exception classes.
│ │ │ │ -
iterator end()
Get an iterator pointing to the end of the list.
Definition sllist.hh:774
│ │ │ │ -
SLListConstIterator< RemoteIndex, Allocator > const_iterator
The constant iterator of the list.
Definition sllist.hh:74
│ │ │ │ -
SLListModifyIterator< GlobalIndex, Allocator > ModifyIterator
The type of the iterator capable of deletion and insertion.
Definition sllist.hh:103
│ │ │ │ -
iterator begin()
Get an iterator pointing to the first element in the list.
Definition sllist.hh:762
│ │ │ │ -
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition bigunsignedint.hh:278
│ │ │ │ -
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ -
void repairLocalIndexPointers()
Repair the pointers to the local index pairs.
Definition remoteindices.hh:1574
│ │ │ │ -
const Attribute attribute() const
Get the attribute of the index on the remote process.
Definition remoteindices.hh:945
│ │ │ │ -
RemoteIndices()
Definition remoteindices.hh:976
│ │ │ │ -
CollectiveIterator & operator++()
Definition remoteindices.hh:1778
│ │ │ │ -
void setIndexSets(const ParallelIndexSet &source, const ParallelIndexSet &destination, const MPI_Comm &comm, const std::vector< int > &neighbours=std::vector< int >())
Set the index sets and communicator we work with.
Definition remoteindices.hh:983
│ │ │ │ -
void free()
Free the index lists.
Definition remoteindices.hh:1428
│ │ │ │ -
void insert(const RemoteIndex &index)
Insert an index to the list.
Definition remoteindices.hh:1604
│ │ │ │ -
iterator end()
Definition remoteindices.hh:1821
│ │ │ │ -
void rebuild()
Rebuilds the set of remote indices.
Definition remoteindices.hh:1452
│ │ │ │ -
bool operator==(const RemoteIndex &ri) const
Definition remoteindices.hh:933
│ │ │ │ -
MPI_Comm communicator() const
Get the mpi communicator used.
Definition remoteindices.hh:1695
│ │ │ │ -
CollectiveIteratorT iterator() const
Get an iterator for collectively iterating over the remote indices of all remote processes.
Definition remoteindices.hh:1689
│ │ │ │ -
void setIncludeSelf(bool includeSelf)
Tell whether sending from indices of the processor to other indices on the same processor is enabled ...
Definition remoteindices.hh:970
│ │ │ │ -
CollectiveIterator(const RemoteIndexMap &map_, bool send)
Constructor.
Definition remoteindices.hh:1702
│ │ │ │ -
iterator begin()
Get an iterator over the indices positioned at the first index.
│ │ │ │ -
iterator end()
Get an iterator over the indices positioned after the last index.
│ │ │ │ -
const_iterator end() const
Get an iterator over all remote index lists.
Definition remoteindices.hh:1528
│ │ │ │ -
bool operator==(const RemoteIndices &ri) const
Definition remoteindices.hh:1535
│ │ │ │ -
bool empty() const
Checks whether there are still iterators in the map.
Definition remoteindices.hh:1803
│ │ │ │ -
RemoteIndexListModifier< T, A, mode > getModifier(int process)
Get a modifier for a remote index list.
Definition remoteindices.hh:1479
│ │ │ │ -
void advance(const GlobalIndex &global)
Advances all underlying iterators.
Definition remoteindices.hh:1715
│ │ │ │ -
const PairType & localIndexPair() const
Get the corresponding local index pair.
Definition remoteindices.hh:951
│ │ │ │ -
const ParallelIndexSet & sourceIndexSet() const
Get the index set at the source.
Definition remoteindices.hh:998
│ │ │ │ -
~RemoteIndices()
Destructor.
Definition remoteindices.hh:1013
│ │ │ │ -
TL LocalIndex
The type of the local index, e.g. ParallelLocalIndex.
Definition indexset.hh:239
│ │ │ │ -
bool remove(const GlobalIndex &global)
Remove a remote index.
Definition remoteindices.hh:1652
│ │ │ │ -
const GlobalIndex & global() const
Get the global index.
│ │ │ │ -
RemoteIndex()
Parameterless Constructor.
Definition remoteindices.hh:929
│ │ │ │ -
int neighbours() const
Get the number of processors we share indices with.
Definition remoteindices.hh:1445
│ │ │ │ -
LocalIndex & local()
Get the local index.
│ │ │ │ -
TG GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition indexset.hh:226
│ │ │ │ -
const ParallelIndexSet & destinationIndexSet() const
Get the index set at destination.
Definition remoteindices.hh:1006
│ │ │ │ -
const_iterator find(int proc) const
Find an iterator over the remote index lists of a specific process.
Definition remoteindices.hh:1514
│ │ │ │ -
bool isSynced() const
Checks whether the remote indices are synced with the indexsets.
Definition remoteindices.hh:1472
│ │ │ │ -
bool operator!=(const RemoteIndex &ri) const
Definition remoteindices.hh:939
│ │ │ │ -
const_iterator begin() const
Get an iterator over all remote index lists.
Definition remoteindices.hh:1521
│ │ │ │ -
iterator begin()
Definition remoteindices.hh:1810
│ │ │ │ -
@ GROUND
The default mode. Indicates that the index set is ready to be used.
Definition indexset.hh:186
│ │ │ │ -
DVVerbType dvverb(std::cout)
stream for very verbose output.
Definition stdstreams.hh:96
│ │ │ │ -
STL namespace.
│ │ │ │ +
12namespace Dune {
│ │ │ │ +
13
│ │ │ │ +
22
│ │ │ │ +
24
│ │ │ │ +
26
│ │ │ │ +
30 template<class T>
│ │ │ │ + │ │ │ │ +
32
│ │ │ │ +
33} // end namespace Dune
│ │ │ │ +
34
│ │ │ │ +
35#endif // DUNE_FTRAITS_HH
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition integersequence.hh:75
│ │ │ │ -
A traits class describing the mapping of types onto MPI_Datatypes.
Definition mpitraits.hh:41
│ │ │ │ -
static MPI_Datatype getType()
Definition mpitraits.hh:48
│ │ │ │ -
Default exception class for range errors.
Definition exceptions.hh:254
│ │ │ │ -
A pair consisting of a global and local index.
Definition indexset.hh:85
│ │ │ │ -
Exception indicating that the index set is not in the expected state.
Definition indexset.hh:205
│ │ │ │ -
Manager class for the mapping between local indices and globally unique indices.
Definition indexset.hh:218
│ │ │ │ -
Class for recomputing missing indices of a distributed index set.
Definition indicessyncer.hh:45
│ │ │ │ -
Base class of all classes representing a communication interface.
Definition parallel/interface.hh:44
│ │ │ │ -
An index present on the local process with an additional attribute flag.
Definition plocalindex.hh:52
│ │ │ │ -
The indices present on remote processes.
Definition remoteindices.hh:190
│ │ │ │ -
const std::set< int > & getNeighbours() const
Definition remoteindices.hh:308
│ │ │ │ -
Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex
Type of the remote indices we manage.
Definition remoteindices.hh:232
│ │ │ │ -
friend void fillIndexSetHoles(const G &graph, Dune::OwnerOverlapCopyCommunication< T1, T2 > &oocomm)
│ │ │ │ -
friend void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename T1::GlobalIndex, typename T1::LocalIndex::Attribute >, A2 > > &, RemoteIndices< T1, A1 > &, const T1 &)
│ │ │ │ -
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition remoteindices.hh:216
│ │ │ │ -
T ParallelIndexSet
Type of the index set we use, e.g. ParallelLocalIndexSet.
Definition remoteindices.hh:207
│ │ │ │ -
LocalIndex::Attribute Attribute
The type of the attribute.
Definition remoteindices.hh:227
│ │ │ │ -
std::map< int, std::pair< RemoteIndexList *, RemoteIndexList * > > RemoteIndexMap
The type of the map from rank to remote index list.
Definition remoteindices.hh:246
│ │ │ │ -
void setNeighbours(const C &neighbours)
Definition remoteindices.hh:301
│ │ │ │ -
Dune::SLList< RemoteIndex, Allocator > RemoteIndexList
The type of the remote index list.
Definition remoteindices.hh:242
│ │ │ │ -
CollectiveIterator< T, A > CollectiveIteratorT
The type of the collective iterator over all remote indices.
Definition remoteindices.hh:211
│ │ │ │ -
typename std::allocator_traits< A >::template rebind_alloc< RemoteIndex > Allocator
The type of the allocator for the remote index list.
Definition remoteindices.hh:238
│ │ │ │ -
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition remoteindices.hh:222
│ │ │ │ -
RemoteIndexMap::const_iterator const_iterator
Definition remoteindices.hh:248
│ │ │ │ -
Information about an index residing on another processor.
Definition remoteindices.hh:74
│ │ │ │ -
friend void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &, RemoteIndices< T, A1 > &, const T &)
│ │ │ │ -
T1 GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition remoteindices.hh:91
│ │ │ │ -
T2 Attribute
The type of the attributes. Normally this will be an enumeration like.
Definition remoteindices.hh:100
│ │ │ │ -
IndexPair< GlobalIndex, ParallelLocalIndex< Attribute > > PairType
The type of the index pair.
Definition remoteindices.hh:106
│ │ │ │ -
Modifier for adding and/or deleting remote indices from the remote index list.
Definition remoteindices.hh:550
│ │ │ │ -
Dune::SLList< RemoteIndex, Allocator > RemoteIndexList
The type of the remote index list.
Definition remoteindices.hh:601
│ │ │ │ -
A Allocator
The type of the allocator for the remote index list.
Definition remoteindices.hh:597
│ │ │ │ -
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition remoteindices.hh:577
│ │ │ │ -
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition remoteindices.hh:582
│ │ │ │ -
RemoteIndexList::const_iterator ConstIterator
The type of the remote index list iterator.
Definition remoteindices.hh:611
│ │ │ │ -
SLListModifyIterator< RemoteIndex, Allocator > ModifyIterator
The type of the modifying iterator of the remote index list.
Definition remoteindices.hh:606
│ │ │ │ -
T ParallelIndexSet
Type of the index set we use.
Definition remoteindices.hh:572
│ │ │ │ -
RemoteIndexListModifier()
Default constructor.
Definition remoteindices.hh:675
│ │ │ │ -
LocalIndex::Attribute Attribute
The type of the attribute.
Definition remoteindices.hh:587
│ │ │ │ -
Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex
Type of the remote indices we manage.
Definition remoteindices.hh:592
│ │ │ │ -
static constexpr bool MODIFYINDEXSET
If true the index set corresponding to the remote indices might get modified.
Definition remoteindices.hh:567
│ │ │ │ -
A collective iterator for moving over the remote indices for all processes collectively.
Definition remoteindices.hh:707
│ │ │ │ -
std::map< int, std::pair< RemoteIndexList *, RemoteIndexList * > > RemoteIndexMap
The type of the map from rank to remote index list.
Definition remoteindices.hh:747
│ │ │ │ -
Definition remoteindices.hh:168
│ │ │ │ -
Definition remoteindices.hh:557
│ │ │ │ -
Iterator over the valid underlying iterators.
Definition remoteindices.hh:791
│ │ │ │ -
iterator(const RealIterator &iter, const ConstRealIterator &end, GlobalIndex &index)
Definition remoteindices.hh:798
│ │ │ │ -
iterator(const iterator &other)
Definition remoteindices.hh:816
│ │ │ │ -
const RemoteIndex & operator*() const
Definition remoteindices.hh:837
│ │ │ │ -
Map::iterator ConstRealIterator
Definition remoteindices.hh:794
│ │ │ │ -
iterator & operator++()
Definition remoteindices.hh:821
│ │ │ │ -
const RemoteIndex * operator->() const
Definition remoteindices.hh:849
│ │ │ │ -
bool operator==(const iterator &other) const
Definition remoteindices.hh:855
│ │ │ │ -
int process() const
Definition remoteindices.hh:843
│ │ │ │ -
iterator(const RealIterator &iter, const ConstRealIterator &end, GlobalIndex index, Attribute attribute)
Definition remoteindices.hh:806
│ │ │ │ -
bool operator!=(const iterator &other) const
Definition remoteindices.hh:861
│ │ │ │ -
Map::iterator RealIterator
Definition remoteindices.hh:793
│ │ │ │ -
A constant iterator for the SLList.
Definition sllist.hh:371
│ │ │ │ -
A mutable iterator for the SLList.
Definition sllist.hh:429
│ │ │ │ -
A single linked list.
Definition sllist.hh:44
│ │ │ │ +
Definition matvectraits.hh:31
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,1930 +1,34 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -remoteindices.hh │ │ │ │ │ +matvectraits.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PARALLEL_REMOTEINDICES_HH │ │ │ │ │ -6#define DUNE_COMMON_PARALLEL_REMOTEINDICES_HH │ │ │ │ │ +5#ifndef DUNE_MATVECTRAITS_HH │ │ │ │ │ +6#define DUNE_MATVECTRAITS_HH │ │ │ │ │ 7 │ │ │ │ │ -8#if HAVE_MPI │ │ │ │ │ -9 │ │ │ │ │ -10#include │ │ │ │ │ -11#include │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18#include │ │ │ │ │ -19 │ │ │ │ │ -20#include │ │ │ │ │ -21 │ │ │ │ │ -22#include │ │ │ │ │ -23#include │ │ │ │ │ -24#include │ │ │ │ │ -25#include │ │ │ │ │ -26#include │ │ │ │ │ -27#include │ │ │ │ │ -28 │ │ │ │ │ -29namespace Dune { │ │ │ │ │ -41 template │ │ │ │ │ -42 class MPITraits > > │ │ │ │ │ -43 { │ │ │ │ │ -44 public: │ │ │ │ │ -45 inline static MPI_Datatype getType(); │ │ │ │ │ -46 private: │ │ │ │ │ -47 static MPI_Datatype type; │ │ │ │ │ -48 }; │ │ │ │ │ -49 │ │ │ │ │ -50 │ │ │ │ │ -51 template │ │ │ │ │ -52 class RemoteIndices; │ │ │ │ │ -53 │ │ │ │ │ -54 template │ │ │ │ │ -55 class RemoteIndex; │ │ │ │ │ -56 │ │ │ │ │ -57 // forward declaration needed for friend declaration. │ │ │ │ │ -58 template │ │ │ │ │ -59 class IndicesSyncer; │ │ │ │ │ -60 │ │ │ │ │ -61 template │ │ │ │ │ -62 std::ostream& operator<<(std::ostream& os, const RemoteIndex& index); │ │ │ │ │ -63 │ │ │ │ │ -64 │ │ │ │ │ -65 template │ │ │ │ │ -66 class RemoteIndexListModifier; │ │ │ │ │ -67 │ │ │ │ │ -68 │ │ │ │ │ -72 template │ │ │ │ │ -73 class RemoteIndex │ │ │ │ │ -74 { │ │ │ │ │ -75 template │ │ │ │ │ -76 friend class IndicesSyncer; │ │ │ │ │ -77 │ │ │ │ │ -78 template │ │ │ │ │ -79 friend void repairLocalIndexPointers(std::map,A> >&, │ │ │ │ │ -80 RemoteIndices&, │ │ │ │ │ -81 const T&); │ │ │ │ │ -82 │ │ │ │ │ -83 template │ │ │ │ │ -84 friend class RemoteIndexListModifier; │ │ │ │ │ -85 │ │ │ │ │ -86 public: │ │ │ │ │ -91 typedef T1 GlobalIndex; │ │ │ │ │ -100 typedef T2 Attribute; │ │ │ │ │ -101 │ │ │ │ │ -105 typedef IndexPair > │ │ │ │ │ -106 PairType; │ │ │ │ │ -107 │ │ │ │ │ -112 const Attribute attribute() const; │ │ │ │ │ -113 │ │ │ │ │ -119 const PairType& localIndexPair() const; │ │ │ │ │ -120 │ │ │ │ │ -124 RemoteIndex(); │ │ │ │ │ -125 │ │ │ │ │ -126 │ │ │ │ │ -132 RemoteIndex(const T2& attribute, │ │ │ │ │ -133 const PairType* local); │ │ │ │ │ -134 │ │ │ │ │ -135 │ │ │ │ │ -141 RemoteIndex(const T2& attribute); │ │ │ │ │ -142 │ │ │ │ │ -143 bool operator==(const RemoteIndex& ri) const; │ │ │ │ │ -144 │ │ │ │ │ -145 bool operator!=(const RemoteIndex& ri) const; │ │ │ │ │ -146 private: │ │ │ │ │ -148 const PairType* localIndex_; │ │ │ │ │ -149 │ │ │ │ │ -151 char attribute_; │ │ │ │ │ -152 }; │ │ │ │ │ -153 │ │ │ │ │ -154 template │ │ │ │ │ -155 std::ostream& operator<<(std::ostream& os, const RemoteIndices& │ │ │ │ │ -indices); │ │ │ │ │ -156 │ │ │ │ │ -157 class InterfaceBuilder; │ │ │ │ │ -158 │ │ │ │ │ -159 template │ │ │ │ │ -160 class CollectiveIterator; │ │ │ │ │ -161 │ │ │ │ │ -162 // forward declaration needed for friend declaration. │ │ │ │ │ -163 template │ │ │ │ │ -164 class IndicesSyncer; │ │ │ │ │ -165 │ │ │ │ │ -166 // forward declaration needed for friend declaration. │ │ │ │ │ -167 template │ │ │ │ │ -168 class OwnerOverlapCopyCommunication; │ │ │ │ │ -169 │ │ │ │ │ -170 │ │ │ │ │ -187 template > > │ │ │ │ │ -189 class RemoteIndices │ │ │ │ │ -190 { │ │ │ │ │ -191 friend class InterfaceBuilder; │ │ │ │ │ -192 friend class IndicesSyncer; │ │ │ │ │ -193 template │ │ │ │ │ -194 friend void repairLocalIndexPointers(std::map,A2> >&, │ │ │ │ │ -195 RemoteIndices&, │ │ │ │ │ -196 const T1&); │ │ │ │ │ -197 │ │ │ │ │ -198 template │ │ │ │ │ -199 friend void fillIndexSetHoles(const G& graph, Dune:: │ │ │ │ │ -OwnerOverlapCopyCommunication& oocomm); │ │ │ │ │ -200 friend std::ostream& operator<<<>(std::ostream&, const RemoteIndices&); │ │ │ │ │ -201 │ │ │ │ │ -202 public: │ │ │ │ │ -203 │ │ │ │ │ -207 typedef T ParallelIndexSet; │ │ │ │ │ -208 │ │ │ │ │ -211 typedef CollectiveIterator CollectiveIteratorT; │ │ │ │ │ -212 │ │ │ │ │ -216 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex; │ │ │ │ │ -217 │ │ │ │ │ -218 │ │ │ │ │ -222 typedef typename ParallelIndexSet::LocalIndex LocalIndex; │ │ │ │ │ -223 │ │ │ │ │ -227 typedef typename LocalIndex::Attribute Attribute; │ │ │ │ │ -228 │ │ │ │ │ -232 typedef Dune::RemoteIndex RemoteIndex; │ │ │ │ │ -233 │ │ │ │ │ -234 │ │ │ │ │ -238 using Allocator = typename std::allocator_traits::template rebind_ │ │ │ │ │ -alloc; │ │ │ │ │ -239 │ │ │ │ │ -241 typedef Dune::SLList │ │ │ │ │ -242 RemoteIndexList; │ │ │ │ │ -243 │ │ │ │ │ -245 typedef std::map > │ │ │ │ │ -246 RemoteIndexMap; │ │ │ │ │ -247 │ │ │ │ │ -248 typedef typename RemoteIndexMap::const_iterator const_iterator; │ │ │ │ │ -249 │ │ │ │ │ -267 inline RemoteIndices(const ParallelIndexSet& source, const │ │ │ │ │ -ParallelIndexSet& destination, │ │ │ │ │ -268 const MPI_Comm& comm, const std::vector& neighbours=std::vector │ │ │ │ │ -(), bool includeSelf=false); │ │ │ │ │ -269 │ │ │ │ │ -270 RemoteIndices(); │ │ │ │ │ -271 │ │ │ │ │ -279 void setIncludeSelf(bool includeSelf); │ │ │ │ │ -280 │ │ │ │ │ -297 void setIndexSets(const ParallelIndexSet& source, const ParallelIndexSet& │ │ │ │ │ -destination, │ │ │ │ │ -298 const MPI_Comm& comm, const std::vector& neighbours=std::vector │ │ │ │ │ -()); │ │ │ │ │ -299 │ │ │ │ │ -300 template │ │ │ │ │ -301 void setNeighbours(const C& neighbours) │ │ │ │ │ -302 { │ │ │ │ │ -303 neighbourIds.clear(); │ │ │ │ │ -304 neighbourIds.insert(neighbours.begin(), neighbours.end()); │ │ │ │ │ -305 │ │ │ │ │ -306 } │ │ │ │ │ -307 │ │ │ │ │ -308 const std::set& getNeighbours() const │ │ │ │ │ -309 { │ │ │ │ │ -310 return neighbourIds; │ │ │ │ │ -311 } │ │ │ │ │ -312 │ │ │ │ │ -316 ~RemoteIndices(); │ │ │ │ │ -317 │ │ │ │ │ -327 template │ │ │ │ │ -328 void rebuild(); │ │ │ │ │ -329 │ │ │ │ │ -330 bool operator==(const RemoteIndices& ri) const; │ │ │ │ │ -331 │ │ │ │ │ -339 inline bool isSynced() const; │ │ │ │ │ -340 │ │ │ │ │ -344 inline MPI_Comm communicator() const; │ │ │ │ │ -345 │ │ │ │ │ -360 template │ │ │ │ │ -361 inline RemoteIndexListModifier getModifier(int process); │ │ │ │ │ -362 │ │ │ │ │ -369 inline const_iterator find(int proc) const; │ │ │ │ │ -370 │ │ │ │ │ -375 inline const_iterator begin() const; │ │ │ │ │ -376 │ │ │ │ │ -381 inline const_iterator end() const; │ │ │ │ │ -382 │ │ │ │ │ -386 template │ │ │ │ │ -387 inline CollectiveIteratorT iterator() const; │ │ │ │ │ -388 │ │ │ │ │ -392 inline void free(); │ │ │ │ │ -393 │ │ │ │ │ -398 inline int neighbours() const; │ │ │ │ │ -399 │ │ │ │ │ -401 inline const ParallelIndexSet& sourceIndexSet() const; │ │ │ │ │ -402 │ │ │ │ │ -404 inline const ParallelIndexSet& destinationIndexSet() const; │ │ │ │ │ -405 │ │ │ │ │ -406 private: │ │ │ │ │ -408 RemoteIndices(const RemoteIndices&) = delete; │ │ │ │ │ -409 │ │ │ │ │ -411 const ParallelIndexSet* source_; │ │ │ │ │ -412 │ │ │ │ │ -414 const ParallelIndexSet* target_; │ │ │ │ │ -415 │ │ │ │ │ -417 MPI_Comm comm_; │ │ │ │ │ -418 │ │ │ │ │ -421 std::set neighbourIds; │ │ │ │ │ -422 │ │ │ │ │ -424 const static int commTag_=333; │ │ │ │ │ -425 │ │ │ │ │ -430 int sourceSeqNo_; │ │ │ │ │ -431 │ │ │ │ │ -436 int destSeqNo_; │ │ │ │ │ -437 │ │ │ │ │ -441 bool publicIgnored; │ │ │ │ │ -442 │ │ │ │ │ -446 bool firstBuild; │ │ │ │ │ -447 │ │ │ │ │ -448 /* │ │ │ │ │ -449 * @brief If true, sending from indices of the processor to other │ │ │ │ │ -450 * indices on the same processor is enabled even if the same indexset is │ │ │ │ │ -used │ │ │ │ │ -451 * on both the │ │ │ │ │ -452 * sending and receiving side. │ │ │ │ │ -453 */ │ │ │ │ │ -454 bool includeSelf; │ │ │ │ │ -455 │ │ │ │ │ -457 typedef IndexPair │ │ │ │ │ -458 PairType; │ │ │ │ │ -459 │ │ │ │ │ -466 RemoteIndexMap remoteIndices_; │ │ │ │ │ -467 │ │ │ │ │ -478 template │ │ │ │ │ -479 inline void buildRemote(bool includeSelf); │ │ │ │ │ -480 │ │ │ │ │ -486 inline int noPublic(const ParallelIndexSet& indexSet); │ │ │ │ │ -487 │ │ │ │ │ -499 template │ │ │ │ │ -500 inline void packEntries(PairType** myPairs, const ParallelIndexSet& │ │ │ │ │ -indexSet, │ │ │ │ │ -501 char* p_out, MPI_Datatype type, int bufferSize, │ │ │ │ │ -502 int* position, int n); │ │ │ │ │ -503 │ │ │ │ │ -517 inline void unpackIndices(RemoteIndexList& remote, int remoteEntries, │ │ │ │ │ -518 PairType** local, int localEntries, char* p_in, │ │ │ │ │ -519 MPI_Datatype type, int* position, int bufferSize, │ │ │ │ │ -520 bool fromOurself); │ │ │ │ │ -521 │ │ │ │ │ -522 inline void unpackIndices(RemoteIndexList& send, RemoteIndexList& receive, │ │ │ │ │ -523 int remoteEntries, PairType** localSource, │ │ │ │ │ -524 int localSourceEntries, PairType** localDest, │ │ │ │ │ -525 int localDestEntries, char* p_in, │ │ │ │ │ -526 MPI_Datatype type, int* position, int bufferSize); │ │ │ │ │ -527 │ │ │ │ │ -528 void unpackCreateRemote(char* p_in, PairType** sourcePairs, PairType** │ │ │ │ │ -DestPairs, │ │ │ │ │ -529 int remoteProc, int sourcePublish, int destPublish, │ │ │ │ │ -530 int bufferSize, bool sendTwo, bool fromOurSelf=false); │ │ │ │ │ -531 }; │ │ │ │ │ -532 │ │ │ │ │ -548 template │ │ │ │ │ -549 class RemoteIndexListModifier │ │ │ │ │ -550 { │ │ │ │ │ -551 │ │ │ │ │ -552 template │ │ │ │ │ -553 friend class RemoteIndices; │ │ │ │ │ -554 │ │ │ │ │ -555 public: │ │ │ │ │ -556 class InvalidPosition : public RangeError │ │ │ │ │ -557 {}; │ │ │ │ │ -558 │ │ │ │ │ -567 constexpr static bool MODIFYINDEXSET = mode; │ │ │ │ │ -568 │ │ │ │ │ -572 typedef T ParallelIndexSet; │ │ │ │ │ -573 │ │ │ │ │ -577 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex; │ │ │ │ │ -578 │ │ │ │ │ -582 typedef typename ParallelIndexSet::LocalIndex LocalIndex; │ │ │ │ │ -583 │ │ │ │ │ -587 typedef typename LocalIndex::Attribute Attribute; │ │ │ │ │ -588 │ │ │ │ │ -592 typedef Dune::RemoteIndex RemoteIndex; │ │ │ │ │ -593 │ │ │ │ │ -597 typedef A Allocator; │ │ │ │ │ -598 │ │ │ │ │ -600 typedef Dune::SLList │ │ │ │ │ -601 RemoteIndexList; │ │ │ │ │ -602 │ │ │ │ │ -606 typedef SLListModifyIterator ModifyIterator; │ │ │ │ │ -607 │ │ │ │ │ -611 typedef typename RemoteIndexList::const_iterator ConstIterator; │ │ │ │ │ -612 │ │ │ │ │ -626 void insert(const RemoteIndex& index); │ │ │ │ │ -627 │ │ │ │ │ -628 │ │ │ │ │ -643 void insert(const RemoteIndex& index, const GlobalIndex& global); │ │ │ │ │ -644 │ │ │ │ │ -652 bool remove(const GlobalIndex& global); │ │ │ │ │ -653 │ │ │ │ │ -666 void repairLocalIndexPointers(); │ │ │ │ │ -667 │ │ │ │ │ -668 │ │ │ │ │ -669 RemoteIndexListModifier(const RemoteIndexListModifier&); │ │ │ │ │ -670 │ │ │ │ │ -675 RemoteIndexListModifier() │ │ │ │ │ -676 : glist_() │ │ │ │ │ -677 {} │ │ │ │ │ -678 │ │ │ │ │ -679 private: │ │ │ │ │ -680 │ │ │ │ │ -686 RemoteIndexListModifier(const ParallelIndexSet& indexSet, │ │ │ │ │ -687 RemoteIndexList& rList); │ │ │ │ │ -688 │ │ │ │ │ -689 typedef SLList GlobalList; │ │ │ │ │ -690 typedef typename GlobalList::ModifyIterator GlobalModifyIterator; │ │ │ │ │ -691 RemoteIndexList* rList_; │ │ │ │ │ -692 const ParallelIndexSet* indexSet_; │ │ │ │ │ -693 GlobalList glist_; │ │ │ │ │ -694 ModifyIterator iter_; │ │ │ │ │ -695 GlobalModifyIterator giter_; │ │ │ │ │ -696 ConstIterator end_; │ │ │ │ │ -697 bool first_; │ │ │ │ │ -698 GlobalIndex last_; │ │ │ │ │ -699 }; │ │ │ │ │ -700 │ │ │ │ │ -705 template │ │ │ │ │ -706 class CollectiveIterator │ │ │ │ │ -707 { │ │ │ │ │ -708 │ │ │ │ │ -712 typedef T ParallelIndexSet; │ │ │ │ │ -713 │ │ │ │ │ -717 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex; │ │ │ │ │ -718 │ │ │ │ │ -722 typedef typename ParallelIndexSet::LocalIndex LocalIndex; │ │ │ │ │ -723 │ │ │ │ │ -727 typedef typename LocalIndex::Attribute Attribute; │ │ │ │ │ -728 │ │ │ │ │ -730 typedef Dune::RemoteIndex RemoteIndex; │ │ │ │ │ -731 │ │ │ │ │ -733 using Allocator = typename std::allocator_traits::template rebind_ │ │ │ │ │ -alloc; │ │ │ │ │ -734 │ │ │ │ │ -736 typedef Dune::SLList RemoteIndexList; │ │ │ │ │ -737 │ │ │ │ │ -739 typedef std::map > │ │ │ │ │ -741 Map; │ │ │ │ │ -742 │ │ │ │ │ -743 public: │ │ │ │ │ -744 │ │ │ │ │ -746 typedef std::map > │ │ │ │ │ -747 RemoteIndexMap; │ │ │ │ │ -748 │ │ │ │ │ -754 inline CollectiveIterator(const RemoteIndexMap& map_, bool send); │ │ │ │ │ -755 │ │ │ │ │ -764 inline void advance(const GlobalIndex& global); │ │ │ │ │ -765 │ │ │ │ │ -775 inline void advance(const GlobalIndex& global, const Attribute& attribute); │ │ │ │ │ -776 │ │ │ │ │ -777 CollectiveIterator& operator++(); │ │ │ │ │ -778 │ │ │ │ │ -782 inline bool empty() const; │ │ │ │ │ -783 │ │ │ │ │ -790 class iterator │ │ │ │ │ -791 { │ │ │ │ │ -792 public: │ │ │ │ │ -793 typedef typename Map::iterator RealIterator; │ │ │ │ │ -794 typedef typename Map::iterator ConstRealIterator; │ │ │ │ │ -795 │ │ │ │ │ -796 │ │ │ │ │ -798 iterator(const RealIterator& iter, const ConstRealIterator& end, │ │ │ │ │ -GlobalIndex& index) │ │ │ │ │ -799 : iter_(iter), end_(end), index_(index), hasAttribute(false) │ │ │ │ │ -800 { │ │ │ │ │ -801 // Move to the first valid entry │ │ │ │ │ -802 while(iter_!=end_ && iter_->second.first->localIndexPair().global()!=index_ │ │ │ │ │ -) │ │ │ │ │ -803 ++iter_; │ │ │ │ │ -804 } │ │ │ │ │ -805 │ │ │ │ │ -806 iterator(const RealIterator& iter, const ConstRealIterator& end, │ │ │ │ │ -GlobalIndex index, │ │ │ │ │ -807 Attribute attribute) │ │ │ │ │ -808 : iter_(iter), end_(end), index_(index), attribute_(attribute), │ │ │ │ │ -hasAttribute(true) │ │ │ │ │ -809 { │ │ │ │ │ -810 // Move to the first valid entry or the end │ │ │ │ │ -811 while(iter_!=end_ && (iter_->second.first->localIndexPair().global │ │ │ │ │ -()!=index_ │ │ │ │ │ -812 || iter_->second.first->localIndexPair().local().attribute()!=attribute)) │ │ │ │ │ -813 ++iter_; │ │ │ │ │ -814 } │ │ │ │ │ -816 iterator(const iterator& other) │ │ │ │ │ -817 : iter_(other.iter_), end_(other.end_), index_(other.index_) │ │ │ │ │ -818 { } │ │ │ │ │ -819 │ │ │ │ │ -821 iterator& operator++() │ │ │ │ │ -822 { │ │ │ │ │ -823 ++iter_; │ │ │ │ │ -824 // If entry is not valid move on │ │ │ │ │ -825 while(iter_!=end_ && (iter_->second.first->localIndexPair().global │ │ │ │ │ -()!=index_ || │ │ │ │ │ -826 (hasAttribute && │ │ │ │ │ -827 iter_->second.first->localIndexPair().local().attribute()!=attribute_))) │ │ │ │ │ -828 ++iter_; │ │ │ │ │ -829 assert(iter_==end_ || │ │ │ │ │ -830 (iter_->second.first->localIndexPair().global()==index_)); │ │ │ │ │ -831 assert(iter_==end_ || !hasAttribute || │ │ │ │ │ -832 (iter_->second.first->localIndexPair().local().attribute()==attribute_)); │ │ │ │ │ -833 return *this; │ │ │ │ │ -834 } │ │ │ │ │ -835 │ │ │ │ │ -837 const RemoteIndex& operator*() const │ │ │ │ │ -838 { │ │ │ │ │ -839 return *(iter_->second.first); │ │ │ │ │ -840 } │ │ │ │ │ -841 │ │ │ │ │ -843 int process() const │ │ │ │ │ -844 { │ │ │ │ │ -845 return iter_->first; │ │ │ │ │ -846 } │ │ │ │ │ -847 │ │ │ │ │ -849 const RemoteIndex* operator->() const │ │ │ │ │ -850 { │ │ │ │ │ -851 return iter_->second.first.operator->(); │ │ │ │ │ -852 } │ │ │ │ │ -853 │ │ │ │ │ -855 bool operator==(const iterator& other) const │ │ │ │ │ -856 { │ │ │ │ │ -857 return other.iter_==iter_; │ │ │ │ │ -858 } │ │ │ │ │ -859 │ │ │ │ │ -861 bool operator!=(const iterator& other) const │ │ │ │ │ -862 { │ │ │ │ │ -863 return other.iter_!=iter_; │ │ │ │ │ -864 } │ │ │ │ │ -865 │ │ │ │ │ -866 private: │ │ │ │ │ -867 iterator(); │ │ │ │ │ -868 │ │ │ │ │ -869 RealIterator iter_; │ │ │ │ │ -870 RealIterator end_; │ │ │ │ │ -871 GlobalIndex index_; │ │ │ │ │ -872 Attribute attribute_; │ │ │ │ │ -873 bool hasAttribute; │ │ │ │ │ -874 }; │ │ │ │ │ -875 │ │ │ │ │ -876 iterator begin(); │ │ │ │ │ -877 │ │ │ │ │ -878 iterator end(); │ │ │ │ │ -879 │ │ │ │ │ -880 private: │ │ │ │ │ -881 │ │ │ │ │ -882 Map map_; │ │ │ │ │ -883 GlobalIndex index_; │ │ │ │ │ -884 Attribute attribute_; │ │ │ │ │ -885 bool noattribute; │ │ │ │ │ -886 }; │ │ │ │ │ -887 │ │ │ │ │ -888 template │ │ │ │ │ -889 MPI_Datatype MPITraits > >::getType() │ │ │ │ │ -890 { │ │ │ │ │ -891 if(type==MPI_DATATYPE_NULL) { │ │ │ │ │ -892 int length[2] = {1, 1}; │ │ │ │ │ -893 MPI_Aint base; │ │ │ │ │ -894 MPI_Aint disp[2]; │ │ │ │ │ -895 MPI_Datatype types[2] = {MPITraits::getType(), │ │ │ │ │ -896 MPITraits >::getType()}; │ │ │ │ │ -897 IndexPair > rep; │ │ │ │ │ -898 MPI_Get_address(&rep, &base); // lower bound of the datatype │ │ │ │ │ -899 MPI_Get_address(&(rep.global_), &disp[0]); │ │ │ │ │ -900 MPI_Get_address(&(rep.local_), &disp[1]); │ │ │ │ │ -901 for (MPI_Aint& d : disp) │ │ │ │ │ -902 d -= base; │ │ │ │ │ -903 │ │ │ │ │ -904 MPI_Datatype tmp; │ │ │ │ │ -905 MPI_Type_create_struct(2, length, disp, types, &tmp); │ │ │ │ │ -906 │ │ │ │ │ -907 MPI_Type_create_resized(tmp, 0, sizeof(IndexPair │ │ │ │ │ ->), &type); │ │ │ │ │ -908 MPI_Type_commit(&type); │ │ │ │ │ -909 │ │ │ │ │ -910 MPI_Type_free(&tmp); │ │ │ │ │ -911 } │ │ │ │ │ -912 return type; │ │ │ │ │ -913 } │ │ │ │ │ -914 │ │ │ │ │ -915 template │ │ │ │ │ -916 MPI_Datatype MPITraits > >::type=MPI_ │ │ │ │ │ -DATATYPE_NULL; │ │ │ │ │ -917 │ │ │ │ │ -918 template │ │ │ │ │ -919 RemoteIndex::RemoteIndex(const T2& attribute, const PairType* local) │ │ │ │ │ -920 : localIndex_(local), attribute_(static_cast> │ │ │ │ │ -(attribute)) │ │ │ │ │ -921 {} │ │ │ │ │ -922 │ │ │ │ │ -923 template │ │ │ │ │ -924 RemoteIndex::RemoteIndex(const T2& attribute) │ │ │ │ │ -925 : localIndex_(0), attribute_(static_cast> │ │ │ │ │ -(attribute)) │ │ │ │ │ -926 {} │ │ │ │ │ -927 │ │ │ │ │ -928 template │ │ │ │ │ -929 RemoteIndex::RemoteIndex() │ │ │ │ │ -930 : localIndex_(0), attribute_() │ │ │ │ │ -931 {} │ │ │ │ │ -932 template │ │ │ │ │ -933 inline bool RemoteIndex::operator==(const RemoteIndex& ri) const │ │ │ │ │ -934 { │ │ │ │ │ -935 return localIndex_==ri.localIndex_ && attribute_==ri.attribute_; │ │ │ │ │ -936 } │ │ │ │ │ -937 │ │ │ │ │ -938 template │ │ │ │ │ -939 inline bool RemoteIndex::operator!=(const RemoteIndex& ri) const │ │ │ │ │ -940 { │ │ │ │ │ -941 return localIndex_!=ri.localIndex_ || attribute_!=ri.attribute_; │ │ │ │ │ -942 } │ │ │ │ │ -943 │ │ │ │ │ -944 template │ │ │ │ │ -945 inline const T2 RemoteIndex::attribute() const │ │ │ │ │ -946 { │ │ │ │ │ -947 return T2(attribute_); │ │ │ │ │ -948 } │ │ │ │ │ -949 │ │ │ │ │ -950 template │ │ │ │ │ -951 inline const IndexPair >& RemoteIndex:: │ │ │ │ │ -localIndexPair() const │ │ │ │ │ -952 { │ │ │ │ │ -953 return *localIndex_; │ │ │ │ │ -954 } │ │ │ │ │ -955 │ │ │ │ │ -956 template │ │ │ │ │ -957 inline RemoteIndices::RemoteIndices(const ParallelIndexSet& source, │ │ │ │ │ -958 const ParallelIndexSet& destination, │ │ │ │ │ -959 const MPI_Comm& comm, │ │ │ │ │ -960 const std::vector& neighbours, │ │ │ │ │ -961 bool includeSelf_) │ │ │ │ │ -962 : source_(&source), target_(&destination), comm_(comm), │ │ │ │ │ -963 sourceSeqNo_(-1), destSeqNo_(-1), publicIgnored(false), firstBuild(true), │ │ │ │ │ -964 includeSelf(includeSelf_) │ │ │ │ │ -965 { │ │ │ │ │ -966 setNeighbours(neighbours); │ │ │ │ │ -967 } │ │ │ │ │ -968 │ │ │ │ │ -969 template │ │ │ │ │ -970 void RemoteIndices::setIncludeSelf(bool b) │ │ │ │ │ -971 { │ │ │ │ │ -972 includeSelf=b; │ │ │ │ │ -973 } │ │ │ │ │ -974 │ │ │ │ │ -975 template │ │ │ │ │ -976 RemoteIndices::RemoteIndices() │ │ │ │ │ -977 : source_(0), target_(0), sourceSeqNo_(-1), │ │ │ │ │ -978 destSeqNo_(-1), publicIgnored(false), firstBuild(true), │ │ │ │ │ -979 includeSelf(false) │ │ │ │ │ -980 {} │ │ │ │ │ -981 │ │ │ │ │ -982 template │ │ │ │ │ -983 void RemoteIndices::setIndexSets(const ParallelIndexSet& source, │ │ │ │ │ -984 const ParallelIndexSet& destination, │ │ │ │ │ -985 const MPI_Comm& comm, │ │ │ │ │ -986 const std::vector& neighbours) │ │ │ │ │ -987 { │ │ │ │ │ -988 free(); │ │ │ │ │ -989 source_ = &source; │ │ │ │ │ -990 target_ = &destination; │ │ │ │ │ -991 comm_ = comm; │ │ │ │ │ -992 firstBuild = true; │ │ │ │ │ -993 setNeighbours(neighbours); │ │ │ │ │ -994 } │ │ │ │ │ -995 │ │ │ │ │ -996 template │ │ │ │ │ -997 const typename RemoteIndices::ParallelIndexSet& │ │ │ │ │ -998 RemoteIndices::sourceIndexSet() const │ │ │ │ │ -999 { │ │ │ │ │ -1000 return *source_; │ │ │ │ │ -1001 } │ │ │ │ │ -1002 │ │ │ │ │ -1003 │ │ │ │ │ -1004 template │ │ │ │ │ -1005 const typename RemoteIndices::ParallelIndexSet& │ │ │ │ │ -1006 RemoteIndices::destinationIndexSet() const │ │ │ │ │ -1007 { │ │ │ │ │ -1008 return *target_; │ │ │ │ │ -1009 } │ │ │ │ │ -1010 │ │ │ │ │ -1011 │ │ │ │ │ -1012 template │ │ │ │ │ -1013 RemoteIndices::~RemoteIndices() │ │ │ │ │ -1014 { │ │ │ │ │ -1015 free(); │ │ │ │ │ -1016 } │ │ │ │ │ -1017 │ │ │ │ │ -1018 template │ │ │ │ │ -1019 template │ │ │ │ │ -1020 inline void RemoteIndices::packEntries │ │ │ │ │ -(IndexPair** pairs, │ │ │ │ │ -1021 const ParallelIndexSet& indexSet, │ │ │ │ │ -1022 char* p_out, MPI_Datatype type, │ │ │ │ │ -1023 int bufferSize, │ │ │ │ │ -1024 int *position, │ │ │ │ │ -1025 [[maybe_unused]] int n) │ │ │ │ │ -1026 { │ │ │ │ │ -1027 // fill with own indices │ │ │ │ │ -1028 const auto end = indexSet.end(); │ │ │ │ │ -1029 │ │ │ │ │ -1030 //Now pack the source indices │ │ │ │ │ -1031 int i=0; │ │ │ │ │ -1032 for(auto index = indexSet.begin(); index != end; ++index) │ │ │ │ │ -1033 if(ignorePublic || index->local().isPublic()) { │ │ │ │ │ -1034 │ │ │ │ │ -1035 MPI_Pack(const_cast(&(*index)), 1, │ │ │ │ │ -1036 type, │ │ │ │ │ -1037 p_out, bufferSize, position, comm_); │ │ │ │ │ -1038 pairs[i++] = const_cast(&(*index)); │ │ │ │ │ -1039 │ │ │ │ │ -1040 } │ │ │ │ │ -1041 assert(i==n); │ │ │ │ │ -1042 } │ │ │ │ │ -1043 │ │ │ │ │ -1044 template │ │ │ │ │ -1045 inline int RemoteIndices::noPublic(const ParallelIndexSet& indexSet) │ │ │ │ │ -1046 { │ │ │ │ │ -1047 │ │ │ │ │ -1048 int noPublic=0; │ │ │ │ │ -1049 │ │ │ │ │ -1050 const auto end=indexSet.end(); │ │ │ │ │ -1051 for(auto index=indexSet.begin(); index!=end; ++index) │ │ │ │ │ -1052 if(index->local().isPublic()) │ │ │ │ │ -1053 noPublic++; │ │ │ │ │ -1054 │ │ │ │ │ -1055 return noPublic; │ │ │ │ │ -1056 │ │ │ │ │ -1057 } │ │ │ │ │ -1058 │ │ │ │ │ -1059 │ │ │ │ │ -1060 template │ │ │ │ │ -1061 inline void RemoteIndices::unpackCreateRemote(char* p_in, PairType** │ │ │ │ │ -sourcePairs, │ │ │ │ │ -1062 PairType** destPairs, int remoteProc, │ │ │ │ │ -1063 int sourcePublish, int destPublish, │ │ │ │ │ -1064 int bufferSize, bool sendTwo, │ │ │ │ │ -1065 bool fromOurSelf) │ │ │ │ │ -1066 { │ │ │ │ │ -1067 │ │ │ │ │ -1068 // unpack the number of indices we received │ │ │ │ │ -1069 int noRemoteSource=-1, noRemoteDest=-1; │ │ │ │ │ -1070 char twoIndexSets=0; │ │ │ │ │ -1071 int position=0; │ │ │ │ │ -1072 // Did we receive two index sets? │ │ │ │ │ -1073 MPI_Unpack(p_in, bufferSize, &position, &twoIndexSets, 1, MPI_CHAR, comm_ │ │ │ │ │ -); │ │ │ │ │ -1074 // The number of source indices received │ │ │ │ │ -1075 MPI_Unpack(p_in, bufferSize, &position, &noRemoteSource, 1, MPI_INT, comm_ │ │ │ │ │ -); │ │ │ │ │ -1076 // The number of destination indices received │ │ │ │ │ -1077 MPI_Unpack(p_in, bufferSize, &position, &noRemoteDest, 1, MPI_INT, comm_); │ │ │ │ │ -1078 │ │ │ │ │ -1079 │ │ │ │ │ -1080 // Indices for which we receive │ │ │ │ │ -1081 RemoteIndexList* receive= new RemoteIndexList(); │ │ │ │ │ -1082 // Indices for which we send │ │ │ │ │ -1083 RemoteIndexList* send=0; │ │ │ │ │ -1084 │ │ │ │ │ -1085 MPI_Datatype type= MPITraits::getType(); │ │ │ │ │ -1086 │ │ │ │ │ -1087 if(!twoIndexSets) { │ │ │ │ │ -1088 if(sendTwo) { │ │ │ │ │ -1089 send = new RemoteIndexList(); │ │ │ │ │ -1090 // Create both remote index sets simultaneously │ │ │ │ │ -1091 unpackIndices(*send, *receive, noRemoteSource, sourcePairs, sourcePublish, │ │ │ │ │ -1092 destPairs, destPublish, p_in, type, &position, bufferSize); │ │ │ │ │ -1093 }else{ │ │ │ │ │ -1094 // we only need one list │ │ │ │ │ -1095 unpackIndices(*receive, noRemoteSource, sourcePairs, sourcePublish, │ │ │ │ │ -1096 p_in, type, &position, bufferSize, fromOurSelf); │ │ │ │ │ -1097 send=receive; │ │ │ │ │ -1098 } │ │ │ │ │ -1099 }else{ │ │ │ │ │ -1100 │ │ │ │ │ -1101 int oldPos=position; │ │ │ │ │ -1102 // Two index sets received │ │ │ │ │ -1103 unpackIndices(*receive, noRemoteSource, destPairs, destPublish, │ │ │ │ │ -1104 p_in, type, &position, bufferSize, fromOurSelf); │ │ │ │ │ -1105 if(!sendTwo) │ │ │ │ │ -1106 //unpack source entries again as destination entries │ │ │ │ │ -1107 position=oldPos; │ │ │ │ │ -1108 │ │ │ │ │ -1109 send = new RemoteIndexList(); │ │ │ │ │ -1110 unpackIndices(*send, noRemoteDest, sourcePairs, sourcePublish, │ │ │ │ │ -1111 p_in, type, &position, bufferSize, fromOurSelf); │ │ │ │ │ -1112 } │ │ │ │ │ -1113 │ │ │ │ │ -1114 if(receive->empty() && send->empty()) { │ │ │ │ │ -1115 if(send==receive) { │ │ │ │ │ -1116 delete send; │ │ │ │ │ -1117 }else{ │ │ │ │ │ -1118 delete send; │ │ │ │ │ -1119 delete receive; │ │ │ │ │ -1120 } │ │ │ │ │ -1121 }else{ │ │ │ │ │ -1122 remoteIndices_.insert(std::make_pair(remoteProc, │ │ │ │ │ -1123 std::make_pair(send,receive))); │ │ │ │ │ -1124 } │ │ │ │ │ -1125 } │ │ │ │ │ -1126 │ │ │ │ │ -1127 │ │ │ │ │ -1128 template │ │ │ │ │ -1129 template │ │ │ │ │ -1130 inline void RemoteIndices::buildRemote(bool includeSelf_) │ │ │ │ │ -1131 { │ │ │ │ │ -1132 // Processor configuration │ │ │ │ │ -1133 int rank, procs; │ │ │ │ │ -1134 MPI_Comm_rank(comm_, &rank); │ │ │ │ │ -1135 MPI_Comm_size(comm_, &procs); │ │ │ │ │ -1136 │ │ │ │ │ -1137 // number of local indices to publish │ │ │ │ │ -1138 // The indices of the destination will be send. │ │ │ │ │ -1139 int sourcePublish, destPublish; │ │ │ │ │ -1140 │ │ │ │ │ -1141 // Do we need to send two index sets? │ │ │ │ │ -1142 char sendTwo = (source_ != target_); │ │ │ │ │ -1143 │ │ │ │ │ -1144 if(procs==1 && !(sendTwo || includeSelf_)) │ │ │ │ │ -1145 // Nothing to communicate │ │ │ │ │ -1146 return; │ │ │ │ │ -1147 │ │ │ │ │ -1148 sourcePublish = (ignorePublic) ? source_->size() : noPublic(*source_); │ │ │ │ │ -1149 │ │ │ │ │ -1150 if(sendTwo) │ │ │ │ │ -1151 destPublish = (ignorePublic) ? target_->size() : noPublic(*target_); │ │ │ │ │ -1152 else │ │ │ │ │ -1153 // we only need to send one set of indices │ │ │ │ │ -1154 destPublish = 0; │ │ │ │ │ -1155 │ │ │ │ │ -1156 int maxPublish, publish=sourcePublish+destPublish; │ │ │ │ │ -1157 │ │ │ │ │ -1158 // Calculate maximum number of indices send │ │ │ │ │ -1159 MPI_Allreduce(&publish, &maxPublish, 1, MPI_INT, MPI_MAX, comm_); │ │ │ │ │ -1160 │ │ │ │ │ -1161 // allocate buffers │ │ │ │ │ -1162 PairType** destPairs; │ │ │ │ │ -1163 PairType** sourcePairs = new PairType*[sourcePublish>0 ? sourcePublish : │ │ │ │ │ -1]; │ │ │ │ │ -1164 │ │ │ │ │ -1165 if(sendTwo) │ │ │ │ │ -1166 destPairs = new PairType*[destPublish>0 ? destPublish : 1]; │ │ │ │ │ -1167 else │ │ │ │ │ -1168 destPairs=sourcePairs; │ │ │ │ │ -1169 │ │ │ │ │ -1170 char** buffer = new char*[2]; │ │ │ │ │ -1171 int bufferSize; │ │ │ │ │ -1172 int position=0; │ │ │ │ │ -1173 int intSize; │ │ │ │ │ -1174 int charSize; │ │ │ │ │ -1175 │ │ │ │ │ -1176 // calculate buffer size │ │ │ │ │ -1177 MPI_Datatype type = MPITraits::getType(); │ │ │ │ │ -1178 │ │ │ │ │ -1179 MPI_Pack_size(maxPublish, type, comm_, │ │ │ │ │ -1180 &bufferSize); │ │ │ │ │ -1181 MPI_Pack_size(1, MPI_INT, comm_, │ │ │ │ │ -1182 &intSize); │ │ │ │ │ -1183 MPI_Pack_size(1, MPI_CHAR, comm_, │ │ │ │ │ -1184 &charSize); │ │ │ │ │ -1185 // Our message will contain the following: │ │ │ │ │ -1186 // a bool whether two index sets where sent │ │ │ │ │ -1187 // the size of the source and the dest indexset, │ │ │ │ │ -1188 // then the source and destination indices │ │ │ │ │ -1189 bufferSize += 2 * intSize + charSize; │ │ │ │ │ -1190 │ │ │ │ │ -1191 if(bufferSize<=0) bufferSize=1; │ │ │ │ │ -1192 │ │ │ │ │ -1193 buffer[0] = new char[bufferSize]; │ │ │ │ │ -1194 buffer[1] = new char[bufferSize]; │ │ │ │ │ -1195 │ │ │ │ │ -1196 │ │ │ │ │ -1197 // pack entries into buffer[0], p_out below! │ │ │ │ │ -1198 MPI_Pack(&sendTwo, 1, MPI_CHAR, buffer[0], bufferSize, &position, │ │ │ │ │ -1199 comm_); │ │ │ │ │ -1200 │ │ │ │ │ -1201 // The number of indices we send for each index set │ │ │ │ │ -1202 MPI_Pack(&sourcePublish, 1, MPI_INT, buffer[0], bufferSize, &position, │ │ │ │ │ -1203 comm_); │ │ │ │ │ -1204 MPI_Pack(&destPublish, 1, MPI_INT, buffer[0], bufferSize, &position, │ │ │ │ │ -1205 comm_); │ │ │ │ │ -1206 │ │ │ │ │ -1207 // Now pack the source indices and setup the destination pairs │ │ │ │ │ -1208 packEntries(sourcePairs, *source_, buffer[0], type, │ │ │ │ │ -1209 bufferSize, &position, sourcePublish); │ │ │ │ │ -1210 // If necessary send the dest indices and setup the source pairs │ │ │ │ │ -1211 if(sendTwo) │ │ │ │ │ -1212 packEntries(destPairs, *target_, buffer[0], type, │ │ │ │ │ -1213 bufferSize, &position, destPublish); │ │ │ │ │ -1214 │ │ │ │ │ -1215 │ │ │ │ │ -1216 // Update remote indices for ourself │ │ │ │ │ -1217 if(sendTwo|| includeSelf_) │ │ │ │ │ -1218 unpackCreateRemote(buffer[0], sourcePairs, destPairs, rank, sourcePublish, │ │ │ │ │ -1219 destPublish, bufferSize, sendTwo, includeSelf_); │ │ │ │ │ -1220 │ │ │ │ │ -1221 neighbourIds.erase(rank); │ │ │ │ │ -1222 │ │ │ │ │ -1223 if(neighbourIds.size()==0) │ │ │ │ │ -1224 { │ │ │ │ │ -1225 Dune::dvverb<::size_type size_type; │ │ │ │ │ -1261 size_type noNeighbours=neighbourIds.size(); │ │ │ │ │ -1262 │ │ │ │ │ -1263 // setup sends │ │ │ │ │ -1264 for(std::set::iterator neighbour=neighbourIds.begin(); │ │ │ │ │ -1265 neighbour!= neighbourIds.end(); ++neighbour) { │ │ │ │ │ -1266 // Only send the information to the neighbouring processors │ │ │ │ │ -1267 MPI_Issend(buffer[0], position , MPI_PACKED, *neighbour, commTag_, comm_, │ │ │ │ │ -req++); │ │ │ │ │ -1268 } │ │ │ │ │ -1269 │ │ │ │ │ -1270 //Test for received messages │ │ │ │ │ -1271 │ │ │ │ │ -1272 for(size_type received=0; received │ │ │ │ │ -1313 inline void RemoteIndices::unpackIndices(RemoteIndexList& remote, │ │ │ │ │ -1314 int remoteEntries, │ │ │ │ │ -1315 PairType** local, │ │ │ │ │ -1316 int localEntries, │ │ │ │ │ -1317 char* p_in, │ │ │ │ │ -1318 MPI_Datatype type, │ │ │ │ │ -1319 int* position, │ │ │ │ │ -1320 int bufferSize, │ │ │ │ │ -1321 bool fromOurSelf) │ │ │ │ │ -1322 { │ │ │ │ │ -1323 if(remoteEntries==0) │ │ │ │ │ -1324 return; │ │ │ │ │ -1325 │ │ │ │ │ -1326 PairType index; │ │ │ │ │ -1327 MPI_Unpack(p_in, bufferSize, position, &index, 1, │ │ │ │ │ -1328 type, comm_); │ │ │ │ │ -1329 GlobalIndex oldGlobal=index.global(); │ │ │ │ │ -1330 int n_in=0, localIndex=0; │ │ │ │ │ -1331 │ │ │ │ │ -1332 //Check if we know the global index │ │ │ │ │ -1333 while(localIndexglobal()==index.global()) { │ │ │ │ │ -1335 int oldLocalIndex=localIndex; │ │ │ │ │ -1336 │ │ │ │ │ -1337 while(localIndexglobal()==index.global()) { │ │ │ │ │ -1339 if(!fromOurSelf || index.local().attribute() != │ │ │ │ │ -1340 local[localIndex]->local().attribute()) │ │ │ │ │ -1341 // if index is from us it has to have a different attribute │ │ │ │ │ -1342 remote.push_back(RemoteIndex(index.local().attribute(), │ │ │ │ │ -1343 local[localIndex])); │ │ │ │ │ -1344 localIndex++; │ │ │ │ │ -1345 } │ │ │ │ │ -1346 │ │ │ │ │ -1347 // unpack next remote index │ │ │ │ │ -1348 if((++n_in) < remoteEntries) { │ │ │ │ │ -1349 MPI_Unpack(p_in, bufferSize, position, &index, 1, │ │ │ │ │ -1350 type, comm_); │ │ │ │ │ -1351 if(index.global()==oldGlobal) │ │ │ │ │ -1352 // Restart comparison for the same global indices │ │ │ │ │ -1353 localIndex=oldLocalIndex; │ │ │ │ │ -1354 else │ │ │ │ │ -1355 oldGlobal=index.global(); │ │ │ │ │ -1356 }else{ │ │ │ │ │ -1357 // No more received indices │ │ │ │ │ -1358 break; │ │ │ │ │ -1359 } │ │ │ │ │ -1360 continue; │ │ │ │ │ -1361 } │ │ │ │ │ -1362 │ │ │ │ │ -1363 if (local[localIndex]->global() │ │ │ │ │ -1386 inline void RemoteIndices::unpackIndices(RemoteIndexList& send, │ │ │ │ │ -1387 RemoteIndexList& receive, │ │ │ │ │ -1388 int remoteEntries, │ │ │ │ │ -1389 PairType** localSource, │ │ │ │ │ -1390 int localSourceEntries, │ │ │ │ │ -1391 PairType** localDest, │ │ │ │ │ -1392 int localDestEntries, │ │ │ │ │ -1393 char* p_in, │ │ │ │ │ -1394 MPI_Datatype type, │ │ │ │ │ -1395 int* position, │ │ │ │ │ -1396 int bufferSize) │ │ │ │ │ -1397 { │ │ │ │ │ -1398 int n_in=0, sourceIndex=0, destIndex=0; │ │ │ │ │ -1399 │ │ │ │ │ -1400 //Check if we know the global index │ │ │ │ │ -1401 while(n_in= than the │ │ │ │ │ -one in the unpacked index │ │ │ │ │ -1409 while(sourceIndexglobal │ │ │ │ │ -()global │ │ │ │ │ -()global │ │ │ │ │ -()==index.global()) │ │ │ │ │ -1417 send.push_back(RemoteIndex(index.local().attribute(), │ │ │ │ │ -1418 localSource[sourceIndex])); │ │ │ │ │ -1419 │ │ │ │ │ -1420 if(destIndex < localDestEntries && localDest[destIndex]->global() == │ │ │ │ │ -index.global()) │ │ │ │ │ -1421 receive.push_back(RemoteIndex(index.local().attribute(), │ │ │ │ │ -1422 localDest[sourceIndex])); │ │ │ │ │ -1423 } │ │ │ │ │ -1424 │ │ │ │ │ -1425 } │ │ │ │ │ -1426 │ │ │ │ │ -1427 template │ │ │ │ │ -1428 inline void RemoteIndices::free() │ │ │ │ │ -1429 { │ │ │ │ │ -1430 auto lend = remoteIndices_.end(); │ │ │ │ │ -1431 for(auto lists=remoteIndices_.begin(); lists != lend; ++lists) { │ │ │ │ │ -1432 if(lists->second.first==lists->second.second) { │ │ │ │ │ -1433 // there is only one remote index list. │ │ │ │ │ -1434 delete lists->second.first; │ │ │ │ │ -1435 }else{ │ │ │ │ │ -1436 delete lists->second.first; │ │ │ │ │ -1437 delete lists->second.second; │ │ │ │ │ -1438 } │ │ │ │ │ -1439 } │ │ │ │ │ -1440 remoteIndices_.clear(); │ │ │ │ │ -1441 firstBuild=true; │ │ │ │ │ -1442 } │ │ │ │ │ -1443 │ │ │ │ │ -1444 template │ │ │ │ │ -1445 inline int RemoteIndices::neighbours() const │ │ │ │ │ -1446 { │ │ │ │ │ -1447 return remoteIndices_.size(); │ │ │ │ │ -1448 } │ │ │ │ │ -1449 │ │ │ │ │ -1450 template │ │ │ │ │ -1451 template │ │ │ │ │ -1452 inline void RemoteIndices::rebuild() │ │ │ │ │ -1453 { │ │ │ │ │ -1454 // Test whether a rebuild is Needed. │ │ │ │ │ -1455 if(firstBuild || │ │ │ │ │ -1456 ignorePublic!=publicIgnored || ! │ │ │ │ │ -1457 isSynced()) { │ │ │ │ │ -1458 free(); │ │ │ │ │ -1459 │ │ │ │ │ -1460 buildRemote(includeSelf); │ │ │ │ │ -1461 │ │ │ │ │ -1462 sourceSeqNo_ = source_->seqNo(); │ │ │ │ │ -1463 destSeqNo_ = target_->seqNo(); │ │ │ │ │ -1464 firstBuild=false; │ │ │ │ │ -1465 publicIgnored=ignorePublic; │ │ │ │ │ -1466 } │ │ │ │ │ -1467 │ │ │ │ │ -1468 │ │ │ │ │ -1469 } │ │ │ │ │ -1470 │ │ │ │ │ -1471 template │ │ │ │ │ -1472 inline bool RemoteIndices::isSynced() const │ │ │ │ │ -1473 { │ │ │ │ │ -1474 return sourceSeqNo_==source_->seqNo() && destSeqNo_ ==target_->seqNo(); │ │ │ │ │ -1475 } │ │ │ │ │ -1476 │ │ │ │ │ -1477 template │ │ │ │ │ -1478 template │ │ │ │ │ -1479 RemoteIndexListModifier RemoteIndices::getModifier(int │ │ │ │ │ -process) │ │ │ │ │ -1480 { │ │ │ │ │ -1481 │ │ │ │ │ -1482 // The user are on their own now! │ │ │ │ │ -1483 // We assume they know what they are doing and just set the │ │ │ │ │ -1484 // remote indices to synced status. │ │ │ │ │ -1485 sourceSeqNo_ = source_->seqNo(); │ │ │ │ │ -1486 destSeqNo_ = target_->seqNo(); │ │ │ │ │ -1487 │ │ │ │ │ -1488 typename RemoteIndexMap::iterator found = remoteIndices_.find(process); │ │ │ │ │ -1489 │ │ │ │ │ -1490 if(found == remoteIndices_.end()) │ │ │ │ │ -1491 { │ │ │ │ │ -1492 if(source_ != target_) │ │ │ │ │ -1493 found = remoteIndices_.insert(found, std::make_pair(process, │ │ │ │ │ -1494 std::make_pair(new RemoteIndexList(), │ │ │ │ │ -1495 new RemoteIndexList()))); │ │ │ │ │ -1496 else{ │ │ │ │ │ -1497 RemoteIndexList* rlist = new RemoteIndexList(); │ │ │ │ │ -1498 found = remoteIndices_.insert(found, │ │ │ │ │ -1499 std::make_pair(process, │ │ │ │ │ -1500 std::make_pair(rlist, rlist))); │ │ │ │ │ -1501 } │ │ │ │ │ -1502 } │ │ │ │ │ -1503 │ │ │ │ │ -1504 firstBuild = false; │ │ │ │ │ -1505 │ │ │ │ │ -1506 if(send) │ │ │ │ │ -1507 return RemoteIndexListModifier(*source_, *(found- │ │ │ │ │ ->second.first)); │ │ │ │ │ -1508 else │ │ │ │ │ -1509 return RemoteIndexListModifier(*target_, *(found- │ │ │ │ │ ->second.second)); │ │ │ │ │ -1510 } │ │ │ │ │ -1511 │ │ │ │ │ -1512 template │ │ │ │ │ -1513 inline typename RemoteIndices::const_iterator │ │ │ │ │ -1514 RemoteIndices::find(int proc) const │ │ │ │ │ -1515 { │ │ │ │ │ -1516 return remoteIndices_.find(proc); │ │ │ │ │ -1517 } │ │ │ │ │ -1518 │ │ │ │ │ -1519 template │ │ │ │ │ -1520 inline typename RemoteIndices::const_iterator │ │ │ │ │ -1521 RemoteIndices::begin() const │ │ │ │ │ -1522 { │ │ │ │ │ -1523 return remoteIndices_.begin(); │ │ │ │ │ -1524 } │ │ │ │ │ -1525 │ │ │ │ │ -1526 template │ │ │ │ │ -1527 inline typename RemoteIndices::const_iterator │ │ │ │ │ -1528 RemoteIndices::end() const │ │ │ │ │ -1529 { │ │ │ │ │ -1530 return remoteIndices_.end(); │ │ │ │ │ -1531 } │ │ │ │ │ -1532 │ │ │ │ │ -1533 │ │ │ │ │ -1534 template │ │ │ │ │ -1535 bool RemoteIndices::operator==(const RemoteIndices& ri) const │ │ │ │ │ -1536 { │ │ │ │ │ -1537 if(neighbours()!=ri.neighbours()) │ │ │ │ │ -1538 return false; │ │ │ │ │ -1539 │ │ │ │ │ -1540 const auto rend = remoteIndices_.end(); │ │ │ │ │ -1541 │ │ │ │ │ -1542 for(auto rindex = remoteIndices_.begin(), rindex1=ri.remoteIndices_.begin │ │ │ │ │ -(); rindex!=rend; ++rindex, ++rindex1) { │ │ │ │ │ -1543 if(rindex->first != rindex1->first) │ │ │ │ │ -1544 return false; │ │ │ │ │ -1545 if(*(rindex->second.first) != *(rindex1->second.first)) │ │ │ │ │ -1546 return false; │ │ │ │ │ -1547 if(*(rindex->second.second) != *(rindex1->second.second)) │ │ │ │ │ -1548 return false; │ │ │ │ │ -1549 } │ │ │ │ │ -1550 return true; │ │ │ │ │ -1551 } │ │ │ │ │ -1552 │ │ │ │ │ -1553 template │ │ │ │ │ -1554 RemoteIndexListModifier::RemoteIndexListModifier(const │ │ │ │ │ -ParallelIndexSet& indexSet, │ │ │ │ │ -1555 RemoteIndexList& rList) │ │ │ │ │ -1556 : rList_(&rList), indexSet_(&indexSet), iter_(rList.beginModify()), end_ │ │ │ │ │ -(rList.end()), first_(true) │ │ │ │ │ -1557 { │ │ │ │ │ -1558 if(MODIFYINDEXSET) { │ │ │ │ │ -1559 assert(indexSet_); │ │ │ │ │ -1560 for(ConstIterator iter=iter_; iter != end_; ++iter) │ │ │ │ │ -1561 glist_.push_back(iter->localIndexPair().global()); │ │ │ │ │ -1562 giter_ = glist_.beginModify(); │ │ │ │ │ -1563 } │ │ │ │ │ -1564 } │ │ │ │ │ -1565 │ │ │ │ │ -1566 template │ │ │ │ │ -1567 RemoteIndexListModifier::RemoteIndexListModifier(const │ │ │ │ │ -RemoteIndexListModifier& other) │ │ │ │ │ -1568 : rList_(other.rList_), indexSet_(other.indexSet_), │ │ │ │ │ -1569 glist_(other.glist_), iter_(other.iter_), giter_(other.giter_), end_ │ │ │ │ │ -(other.end_), │ │ │ │ │ -1570 first_(other.first_), last_(other.last_) │ │ │ │ │ -1571 {} │ │ │ │ │ -1572 │ │ │ │ │ -1573 template │ │ │ │ │ -1574 inline void RemoteIndexListModifier::repairLocalIndexPointers() │ │ │ │ │ -1575 { │ │ │ │ │ -1576 if(MODIFYINDEXSET) { │ │ │ │ │ -1577 // repair pointers to local index set. │ │ │ │ │ -1578#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ -1579 if(indexSet_->state()!=GROUND) │ │ │ │ │ -1580 DUNE_THROW(InvalidIndexSetState, "Index has to be in ground mode for │ │ │ │ │ -repairing pointers to indices"); │ │ │ │ │ -1581#endif │ │ │ │ │ -1582 auto giter = glist_.begin(); │ │ │ │ │ -1583 auto index = indexSet_->begin(); │ │ │ │ │ -1584 │ │ │ │ │ -1585 for(auto iter=rList_->begin(); iter != end_; ++iter) { │ │ │ │ │ -1586 while(index->global()<*giter) { │ │ │ │ │ -1587 ++index; │ │ │ │ │ -1588#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ -1589 if(index == indexSet_->end()) │ │ │ │ │ -1590 DUNE_THROW(InvalidPosition, "No such global index in set!"); │ │ │ │ │ -1591#endif │ │ │ │ │ -1592 } │ │ │ │ │ -1593 │ │ │ │ │ -1594#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ -1595 if(index->global() != *giter) │ │ │ │ │ -1596 DUNE_THROW(InvalidPosition, "No such global index in set!"); │ │ │ │ │ -1597#endif │ │ │ │ │ -1598 iter->localIndex_ = &(*index); │ │ │ │ │ -1599 } │ │ │ │ │ -1600 } │ │ │ │ │ -1601 } │ │ │ │ │ -1602 │ │ │ │ │ -1603 template │ │ │ │ │ -1604 inline void RemoteIndexListModifier::insert(const RemoteIndex& │ │ │ │ │ -index) │ │ │ │ │ -1605 { │ │ │ │ │ -1606 static_assert(!mode,"Not allowed if the mode indicates that new indices" │ │ │ │ │ -1607 "might be added to the underlying index set. Use " │ │ │ │ │ -1608 "insert(const RemoteIndex&, const GlobalIndex&) instead"); │ │ │ │ │ -1609 │ │ │ │ │ -1610#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ -1611 if(!first_ && index.localIndexPair().global()localIndexPair().global() < │ │ │ │ │ -index.localIndexPair().global()) { │ │ │ │ │ -1616 ++iter_; │ │ │ │ │ -1617 } │ │ │ │ │ -1618 │ │ │ │ │ -1619 // No duplicate entries allowed │ │ │ │ │ -1620 assert(iter_==end_ || iter_->localIndexPair().global() != │ │ │ │ │ -index.localIndexPair().global()); │ │ │ │ │ -1621 iter_.insert(index); │ │ │ │ │ -1622 last_ = index.localIndexPair().global(); │ │ │ │ │ -1623 first_ = false; │ │ │ │ │ -1624 } │ │ │ │ │ -1625 │ │ │ │ │ -1626 template │ │ │ │ │ -1627 inline void RemoteIndexListModifier::insert(const RemoteIndex& │ │ │ │ │ -index, const GlobalIndex& global) │ │ │ │ │ -1628 { │ │ │ │ │ -1629 static_assert(mode,"Not allowed if the mode indicates that no new indices" │ │ │ │ │ -1630 "might be added to the underlying index set. Use " │ │ │ │ │ -1631 "insert(const RemoteIndex&) instead"); │ │ │ │ │ -1632#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ -1633 if(!first_ && globallocalIndexPair().global() != global); │ │ │ │ │ -1644 iter_.insert(index); │ │ │ │ │ -1645 giter_.insert(global); │ │ │ │ │ -1646 │ │ │ │ │ -1647 last_ = global; │ │ │ │ │ -1648 first_ = false; │ │ │ │ │ -1649 } │ │ │ │ │ -1650 │ │ │ │ │ -1651 template │ │ │ │ │ -1652 bool RemoteIndexListModifier::remove(const GlobalIndex& global) │ │ │ │ │ -1653 { │ │ │ │ │ -1654#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ -1655 if(!first_ && globallocalIndexPair().global() < global) │ │ │ │ │ -1674 ++iter_; │ │ │ │ │ -1675 │ │ │ │ │ -1676 if(iter_->localIndexPair().global()==global) { │ │ │ │ │ -1677 iter_.remove(); │ │ │ │ │ -1678 found = true; │ │ │ │ │ -1679 } │ │ │ │ │ -1680 } │ │ │ │ │ -1681 │ │ │ │ │ -1682 last_ = global; │ │ │ │ │ -1683 first_ = false; │ │ │ │ │ -1684 return found; │ │ │ │ │ -1685 } │ │ │ │ │ -1686 │ │ │ │ │ -1687 template │ │ │ │ │ -1688 template │ │ │ │ │ -1689 inline typename RemoteIndices::CollectiveIteratorT │ │ │ │ │ -RemoteIndices::iterator() const │ │ │ │ │ -1690 { │ │ │ │ │ -1691 return CollectiveIterator(remoteIndices_, send); │ │ │ │ │ -1692 } │ │ │ │ │ -1693 │ │ │ │ │ -1694 template │ │ │ │ │ -1695 inline MPI_Comm RemoteIndices::communicator() const │ │ │ │ │ -1696 { │ │ │ │ │ -1697 return comm_; │ │ │ │ │ -1698 │ │ │ │ │ -1699 } │ │ │ │ │ -1700 │ │ │ │ │ -1701 template │ │ │ │ │ -1702 CollectiveIterator::CollectiveIterator(const RemoteIndexMap& pmap, │ │ │ │ │ -bool send) │ │ │ │ │ -1703 { │ │ │ │ │ -1704 │ │ │ │ │ -1705 const auto end = pmap.end(); │ │ │ │ │ -1706 for(auto process = pmap.begin(); process != end; ++process) { │ │ │ │ │ -1707 const RemoteIndexList* list = send ? process->second.first : process- │ │ │ │ │ ->second.second; │ │ │ │ │ -1708 using ri_iterator = typename RemoteIndexList::const_iterator; │ │ │ │ │ -1709 map_.insert(std::make_pair(process->first, │ │ │ │ │ -1710 std::pair(list->begin(), list->end()))); │ │ │ │ │ -1711 } │ │ │ │ │ -1712 } │ │ │ │ │ -1713 │ │ │ │ │ -1714 template │ │ │ │ │ -1715 inline void CollectiveIterator::advance(const GlobalIndex& index) │ │ │ │ │ -1716 { │ │ │ │ │ -1717 const auto end = map_.end(); │ │ │ │ │ -1718 │ │ │ │ │ -1719 for(auto iter = map_.begin(); iter != end;) { │ │ │ │ │ -1720 // Step the iterator until we are >= index │ │ │ │ │ -1721 typename RemoteIndexList::const_iterator current = iter->second.first; │ │ │ │ │ -1722 typename RemoteIndexList::const_iterator rend = iter->second.second; │ │ │ │ │ -1723 RemoteIndex remoteIndex; │ │ │ │ │ -1724 if(current != rend) │ │ │ │ │ -1725 remoteIndex = *current; │ │ │ │ │ -1726 │ │ │ │ │ -1727 while(iter->second.first!=iter->second.second && iter->second.first- │ │ │ │ │ ->localIndexPair().global()second.first); │ │ │ │ │ -1729 │ │ │ │ │ -1730 // erase from the map if there are no more entries. │ │ │ │ │ -1731 if(iter->second.first == iter->second.second) │ │ │ │ │ -1732 map_.erase(iter++); │ │ │ │ │ -1733 else{ │ │ │ │ │ -1734 ++iter; │ │ │ │ │ -1735 } │ │ │ │ │ -1736 } │ │ │ │ │ -1737 index_=index; │ │ │ │ │ -1738 noattribute=true; │ │ │ │ │ -1739 } │ │ │ │ │ -1740 │ │ │ │ │ -1741 template │ │ │ │ │ -1742 inline void CollectiveIterator::advance(const GlobalIndex& index, │ │ │ │ │ -1743 const Attribute& attribute) │ │ │ │ │ -1744 { │ │ │ │ │ -1745 const auto end = map_.end(); │ │ │ │ │ -1746 │ │ │ │ │ -1747 for(auto iter = map_.begin(); iter != end;) { │ │ │ │ │ -1748 // Step the iterator until we are >= index │ │ │ │ │ -1749 typename RemoteIndexList::const_iterator current = iter->second.first; │ │ │ │ │ -1750 typename RemoteIndexList::const_iterator rend = iter->second.second; │ │ │ │ │ -1751 RemoteIndex remoteIndex; │ │ │ │ │ -1752 if(current != rend) │ │ │ │ │ -1753 remoteIndex = *current; │ │ │ │ │ -1754 │ │ │ │ │ -1755 // Move to global index or bigger │ │ │ │ │ -1756 while(iter->second.first!=iter->second.second && iter->second.first- │ │ │ │ │ ->localIndexPair().global()second.first); │ │ │ │ │ -1758 │ │ │ │ │ -1759 // move to attribute or bigger │ │ │ │ │ -1760 while(iter->second.first!=iter->second.second │ │ │ │ │ -1761 && iter->second.first->localIndexPair().global()==index │ │ │ │ │ -1762 && iter->second.first->localIndexPair().local().attribute()second.first); │ │ │ │ │ -1764 │ │ │ │ │ -1765 // erase from the map if there are no more entries. │ │ │ │ │ -1766 if(iter->second.first == iter->second.second) │ │ │ │ │ -1767 map_.erase(iter++); │ │ │ │ │ -1768 else{ │ │ │ │ │ -1769 ++iter; │ │ │ │ │ -1770 } │ │ │ │ │ -1771 } │ │ │ │ │ -1772 index_=index; │ │ │ │ │ -1773 attribute_=attribute; │ │ │ │ │ -1774 noattribute=false; │ │ │ │ │ -1775 } │ │ │ │ │ -1776 │ │ │ │ │ -1777 template │ │ │ │ │ -1778 inline CollectiveIterator& CollectiveIterator::operator++() │ │ │ │ │ -1779 { │ │ │ │ │ -1780 const auto end = map_.end(); │ │ │ │ │ -1781 │ │ │ │ │ -1782 for(auto iter = map_.begin(); iter != end;) { │ │ │ │ │ -1783 // Step the iterator until we are >= index │ │ │ │ │ -1784 auto current = iter->second.first; │ │ │ │ │ -1785 auto rend = iter->second.second; │ │ │ │ │ -1786 │ │ │ │ │ -1787 // move all iterators pointing to the current global index to next value │ │ │ │ │ -1788 if(iter->second.first->localIndexPair().global()==index_ && │ │ │ │ │ -1789 (noattribute || iter->second.first->localIndexPair().local().attribute() │ │ │ │ │ -== attribute_)) │ │ │ │ │ -1790 ++(iter->second.first); │ │ │ │ │ -1791 │ │ │ │ │ -1792 // erase from the map if there are no more entries. │ │ │ │ │ -1793 if(iter->second.first == iter->second.second) │ │ │ │ │ -1794 map_.erase(iter++); │ │ │ │ │ -1795 else{ │ │ │ │ │ -1796 ++iter; │ │ │ │ │ -1797 } │ │ │ │ │ -1798 } │ │ │ │ │ -1799 return *this; │ │ │ │ │ -1800 } │ │ │ │ │ -1801 │ │ │ │ │ -1802 template │ │ │ │ │ -1803 inline bool CollectiveIterator::empty() const │ │ │ │ │ -1804 { │ │ │ │ │ -1805 return map_.empty(); │ │ │ │ │ -1806 } │ │ │ │ │ -1807 │ │ │ │ │ -1808 template │ │ │ │ │ -1809 inline typename CollectiveIterator::iterator │ │ │ │ │ -1810 CollectiveIterator::begin() │ │ │ │ │ -1811 { │ │ │ │ │ -1812 if(noattribute) │ │ │ │ │ -1813 return iterator(map_.begin(), map_.end(), index_); │ │ │ │ │ -1814 else │ │ │ │ │ -1815 return iterator(map_.begin(), map_.end(), index_, │ │ │ │ │ -1816 attribute_); │ │ │ │ │ -1817 } │ │ │ │ │ -1818 │ │ │ │ │ -1819 template │ │ │ │ │ -1820 inline typename CollectiveIterator::iterator │ │ │ │ │ -1821 CollectiveIterator::end() │ │ │ │ │ -1822 { │ │ │ │ │ -1823 return iterator(map_.end(), map_.end(), index_); │ │ │ │ │ -1824 } │ │ │ │ │ -1825 │ │ │ │ │ -1826 template │ │ │ │ │ -1827 inline std::ostream& operator<<(std::ostream& os, const │ │ │ │ │ -RemoteIndex& index) │ │ │ │ │ -1828 { │ │ │ │ │ -1829 os<<"[global="< │ │ │ │ │ -1834 inline std::ostream& operator<<(std::ostream& os, const │ │ │ │ │ -RemoteIndices& indices) │ │ │ │ │ -1835 { │ │ │ │ │ -1836 int rank; │ │ │ │ │ -1837 MPI_Comm_rank(indices.comm_, &rank); │ │ │ │ │ -1838 const auto rend = indices.remoteIndices_.end(); │ │ │ │ │ -1839 │ │ │ │ │ -1840 for(auto rindex = indices.remoteIndices_.begin(); rindex!=rend; ++rindex) │ │ │ │ │ -{ │ │ │ │ │ -1841 os<first<<":"; │ │ │ │ │ -1842 │ │ │ │ │ -1843 if(!rindex->second.first->empty()) { │ │ │ │ │ -1844 os<<" send:"; │ │ │ │ │ -1845 │ │ │ │ │ -1846 const auto send= rindex->second.first->end(); │ │ │ │ │ -1847 │ │ │ │ │ -1848 for(auto index = rindex->second.first->begin(); │ │ │ │ │ -1849 index != send; ++index) │ │ │ │ │ -1850 os<<*index<<" "; │ │ │ │ │ -1851 os<second.second->empty()) { │ │ │ │ │ -1854 os<first<<": "<<"receive: "; │ │ │ │ │ -1855 │ │ │ │ │ -1856 for(const auto& index : *(rindex->second.second)) │ │ │ │ │ -1857 os << index << " "; │ │ │ │ │ -1858 } │ │ │ │ │ -1859 os<::const_iterator │ │ │ │ │ -SLListConstIterator< RemoteIndex, Allocator > const_iterator │ │ │ │ │ -The constant iterator of the list. │ │ │ │ │ -Definition sllist.hh:74 │ │ │ │ │ -Dune::SLList<_GlobalIndex,_Allocator_>::ModifyIterator │ │ │ │ │ -SLListModifyIterator< GlobalIndex, Allocator > ModifyIterator │ │ │ │ │ -The type of the iterator capable of deletion and insertion. │ │ │ │ │ -Definition sllist.hh:103 │ │ │ │ │ -Dune::SLList::begin │ │ │ │ │ -iterator begin() │ │ │ │ │ -Get an iterator pointing to the first element in the list. │ │ │ │ │ -Definition sllist.hh:762 │ │ │ │ │ -Dune::operator<< │ │ │ │ │ -std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:278 │ │ │ │ │ -DUNE_THROW │ │ │ │ │ -#define DUNE_THROW(E, m) │ │ │ │ │ -Definition exceptions.hh:218 │ │ │ │ │ -Dune::RemoteIndexListModifier::repairLocalIndexPointers │ │ │ │ │ -void repairLocalIndexPointers() │ │ │ │ │ -Repair the pointers to the local index pairs. │ │ │ │ │ -Definition remoteindices.hh:1574 │ │ │ │ │ -Dune::RemoteIndex::attribute │ │ │ │ │ -const Attribute attribute() const │ │ │ │ │ -Get the attribute of the index on the remote process. │ │ │ │ │ -Definition remoteindices.hh:945 │ │ │ │ │ -Dune::RemoteIndices::RemoteIndices │ │ │ │ │ -RemoteIndices() │ │ │ │ │ -Definition remoteindices.hh:976 │ │ │ │ │ -Dune::CollectiveIterator::operator++ │ │ │ │ │ -CollectiveIterator & operator++() │ │ │ │ │ -Definition remoteindices.hh:1778 │ │ │ │ │ -Dune::RemoteIndices::setIndexSets │ │ │ │ │ -void setIndexSets(const ParallelIndexSet &source, const ParallelIndexSet │ │ │ │ │ -&destination, const MPI_Comm &comm, const std::vector< int > &neighbours=std:: │ │ │ │ │ -vector< int >()) │ │ │ │ │ -Set the index sets and communicator we work with. │ │ │ │ │ -Definition remoteindices.hh:983 │ │ │ │ │ -Dune::RemoteIndices::free │ │ │ │ │ -void free() │ │ │ │ │ -Free the index lists. │ │ │ │ │ -Definition remoteindices.hh:1428 │ │ │ │ │ -Dune::RemoteIndexListModifier::insert │ │ │ │ │ -void insert(const RemoteIndex &index) │ │ │ │ │ -Insert an index to the list. │ │ │ │ │ -Definition remoteindices.hh:1604 │ │ │ │ │ -Dune::CollectiveIterator::end │ │ │ │ │ -iterator end() │ │ │ │ │ -Definition remoteindices.hh:1821 │ │ │ │ │ -Dune::RemoteIndices::rebuild │ │ │ │ │ -void rebuild() │ │ │ │ │ -Rebuilds the set of remote indices. │ │ │ │ │ -Definition remoteindices.hh:1452 │ │ │ │ │ -Dune::RemoteIndex::operator== │ │ │ │ │ -bool operator==(const RemoteIndex &ri) const │ │ │ │ │ -Definition remoteindices.hh:933 │ │ │ │ │ -Dune::RemoteIndices::communicator │ │ │ │ │ -MPI_Comm communicator() const │ │ │ │ │ -Get the mpi communicator used. │ │ │ │ │ -Definition remoteindices.hh:1695 │ │ │ │ │ -Dune::RemoteIndices::iterator │ │ │ │ │ -CollectiveIteratorT iterator() const │ │ │ │ │ -Get an iterator for collectively iterating over the remote indices of all │ │ │ │ │ -remote processes. │ │ │ │ │ -Definition remoteindices.hh:1689 │ │ │ │ │ -Dune::RemoteIndices::setIncludeSelf │ │ │ │ │ -void setIncludeSelf(bool includeSelf) │ │ │ │ │ -Tell whether sending from indices of the processor to other indices on the same │ │ │ │ │ -processor is enabled ... │ │ │ │ │ -Definition remoteindices.hh:970 │ │ │ │ │ -Dune::CollectiveIterator::CollectiveIterator │ │ │ │ │ -CollectiveIterator(const RemoteIndexMap &map_, bool send) │ │ │ │ │ -Constructor. │ │ │ │ │ -Definition remoteindices.hh:1702 │ │ │ │ │ -Dune::ParallelIndexSet::begin │ │ │ │ │ -iterator begin() │ │ │ │ │ -Get an iterator over the indices positioned at the first index. │ │ │ │ │ -Dune::ParallelIndexSet::end │ │ │ │ │ -iterator end() │ │ │ │ │ -Get an iterator over the indices positioned after the last index. │ │ │ │ │ -Dune::RemoteIndices::end │ │ │ │ │ -const_iterator end() const │ │ │ │ │ -Get an iterator over all remote index lists. │ │ │ │ │ -Definition remoteindices.hh:1528 │ │ │ │ │ -Dune::RemoteIndices::operator== │ │ │ │ │ -bool operator==(const RemoteIndices &ri) const │ │ │ │ │ -Definition remoteindices.hh:1535 │ │ │ │ │ -Dune::CollectiveIterator::empty │ │ │ │ │ -bool empty() const │ │ │ │ │ -Checks whether there are still iterators in the map. │ │ │ │ │ -Definition remoteindices.hh:1803 │ │ │ │ │ -Dune::RemoteIndices::getModifier │ │ │ │ │ -RemoteIndexListModifier< T, A, mode > getModifier(int process) │ │ │ │ │ -Get a modifier for a remote index list. │ │ │ │ │ -Definition remoteindices.hh:1479 │ │ │ │ │ -Dune::CollectiveIterator::advance │ │ │ │ │ -void advance(const GlobalIndex &global) │ │ │ │ │ -Advances all underlying iterators. │ │ │ │ │ -Definition remoteindices.hh:1715 │ │ │ │ │ -Dune::RemoteIndex::localIndexPair │ │ │ │ │ -const PairType & localIndexPair() const │ │ │ │ │ -Get the corresponding local index pair. │ │ │ │ │ -Definition remoteindices.hh:951 │ │ │ │ │ -Dune::RemoteIndices::sourceIndexSet │ │ │ │ │ -const ParallelIndexSet & sourceIndexSet() const │ │ │ │ │ -Get the index set at the source. │ │ │ │ │ -Definition remoteindices.hh:998 │ │ │ │ │ -Dune::RemoteIndices::~RemoteIndices │ │ │ │ │ -~RemoteIndices() │ │ │ │ │ -Destructor. │ │ │ │ │ -Definition remoteindices.hh:1013 │ │ │ │ │ -Dune::ParallelIndexSet::LocalIndex │ │ │ │ │ -TL LocalIndex │ │ │ │ │ -The type of the local index, e.g. ParallelLocalIndex. │ │ │ │ │ -Definition indexset.hh:239 │ │ │ │ │ -Dune::RemoteIndexListModifier::remove │ │ │ │ │ -bool remove(const GlobalIndex &global) │ │ │ │ │ -Remove a remote index. │ │ │ │ │ -Definition remoteindices.hh:1652 │ │ │ │ │ -Dune::IndexPair::global │ │ │ │ │ -const GlobalIndex & global() const │ │ │ │ │ -Get the global index. │ │ │ │ │ -Dune::RemoteIndex::RemoteIndex │ │ │ │ │ -RemoteIndex() │ │ │ │ │ -Parameterless Constructor. │ │ │ │ │ -Definition remoteindices.hh:929 │ │ │ │ │ -Dune::RemoteIndices::neighbours │ │ │ │ │ -int neighbours() const │ │ │ │ │ -Get the number of processors we share indices with. │ │ │ │ │ -Definition remoteindices.hh:1445 │ │ │ │ │ -Dune::IndexPair::local │ │ │ │ │ -LocalIndex & local() │ │ │ │ │ -Get the local index. │ │ │ │ │ -Dune::ParallelIndexSet::GlobalIndex │ │ │ │ │ -TG GlobalIndex │ │ │ │ │ -the type of the global index. This type has to provide at least a operator< for │ │ │ │ │ -sorting. │ │ │ │ │ -Definition indexset.hh:226 │ │ │ │ │ -Dune::RemoteIndices::destinationIndexSet │ │ │ │ │ -const ParallelIndexSet & destinationIndexSet() const │ │ │ │ │ -Get the index set at destination. │ │ │ │ │ -Definition remoteindices.hh:1006 │ │ │ │ │ -Dune::RemoteIndices::find │ │ │ │ │ -const_iterator find(int proc) const │ │ │ │ │ -Find an iterator over the remote index lists of a specific process. │ │ │ │ │ -Definition remoteindices.hh:1514 │ │ │ │ │ -Dune::RemoteIndices::isSynced │ │ │ │ │ -bool isSynced() const │ │ │ │ │ -Checks whether the remote indices are synced with the indexsets. │ │ │ │ │ -Definition remoteindices.hh:1472 │ │ │ │ │ -Dune::RemoteIndex::operator!= │ │ │ │ │ -bool operator!=(const RemoteIndex &ri) const │ │ │ │ │ -Definition remoteindices.hh:939 │ │ │ │ │ -Dune::RemoteIndices::begin │ │ │ │ │ -const_iterator begin() const │ │ │ │ │ -Get an iterator over all remote index lists. │ │ │ │ │ -Definition remoteindices.hh:1521 │ │ │ │ │ -Dune::CollectiveIterator::begin │ │ │ │ │ -iterator begin() │ │ │ │ │ -Definition remoteindices.hh:1810 │ │ │ │ │ -Dune::GROUND │ │ │ │ │ -@ GROUND │ │ │ │ │ -The default mode. Indicates that the index set is ready to be used. │ │ │ │ │ -Definition indexset.hh:186 │ │ │ │ │ -Dune::dvverb │ │ │ │ │ -DVVerbType dvverb(std::cout) │ │ │ │ │ -stream for very verbose output. │ │ │ │ │ -Definition stdstreams.hh:96 │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ +12namespace Dune { │ │ │ │ │ +13 │ │ │ │ │ +22 │ │ │ │ │ +24 │ │ │ │ │ +26 │ │ │ │ │ +30 template │ │ │ │ │ +31 struct DenseMatVecTraits {}; │ │ │ │ │ +32 │ │ │ │ │ +33} // end namespace Dune │ │ │ │ │ +34 │ │ │ │ │ +35#endif // DUNE_FTRAITS_HH │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::size │ │ │ │ │ -constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std:: │ │ │ │ │ -integer_sequence< T, II... >) │ │ │ │ │ -Return the size of the sequence. │ │ │ │ │ -Definition integersequence.hh:75 │ │ │ │ │ -Dune::MPITraits │ │ │ │ │ -A traits class describing the mapping of types onto MPI_Datatypes. │ │ │ │ │ -Definition mpitraits.hh:41 │ │ │ │ │ -Dune::MPITraits::getType │ │ │ │ │ -static MPI_Datatype getType() │ │ │ │ │ -Definition mpitraits.hh:48 │ │ │ │ │ -Dune::RangeError │ │ │ │ │ -Default exception class for range errors. │ │ │ │ │ -Definition exceptions.hh:254 │ │ │ │ │ -Dune::IndexPair │ │ │ │ │ -A pair consisting of a global and local index. │ │ │ │ │ -Definition indexset.hh:85 │ │ │ │ │ -Dune::InvalidIndexSetState │ │ │ │ │ -Exception indicating that the index set is not in the expected state. │ │ │ │ │ -Definition indexset.hh:205 │ │ │ │ │ -Dune::ParallelIndexSet │ │ │ │ │ -Manager class for the mapping between local indices and globally unique │ │ │ │ │ -indices. │ │ │ │ │ -Definition indexset.hh:218 │ │ │ │ │ -Dune::IndicesSyncer │ │ │ │ │ -Class for recomputing missing indices of a distributed index set. │ │ │ │ │ -Definition indicessyncer.hh:45 │ │ │ │ │ -Dune::InterfaceBuilder │ │ │ │ │ -Base class of all classes representing a communication interface. │ │ │ │ │ -Definition parallel/interface.hh:44 │ │ │ │ │ -Dune::ParallelLocalIndex │ │ │ │ │ -An index present on the local process with an additional attribute flag. │ │ │ │ │ -Definition plocalindex.hh:52 │ │ │ │ │ -Dune::RemoteIndices │ │ │ │ │ -The indices present on remote processes. │ │ │ │ │ -Definition remoteindices.hh:190 │ │ │ │ │ -Dune::RemoteIndices::getNeighbours │ │ │ │ │ -const std::set< int > & getNeighbours() const │ │ │ │ │ -Definition remoteindices.hh:308 │ │ │ │ │ -Dune::RemoteIndices::RemoteIndex │ │ │ │ │ -Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex │ │ │ │ │ -Type of the remote indices we manage. │ │ │ │ │ -Definition remoteindices.hh:232 │ │ │ │ │ -Dune::RemoteIndices::fillIndexSetHoles │ │ │ │ │ -friend void fillIndexSetHoles(const G &graph, Dune:: │ │ │ │ │ -OwnerOverlapCopyCommunication< T1, T2 > &oocomm) │ │ │ │ │ -Dune::RemoteIndices::repairLocalIndexPointers │ │ │ │ │ -friend void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename │ │ │ │ │ -T1::GlobalIndex, typename T1::LocalIndex::Attribute >, A2 > > &, RemoteIndices< │ │ │ │ │ -T1, A1 > &, const T1 &) │ │ │ │ │ -Dune::RemoteIndices::GlobalIndex │ │ │ │ │ -ParallelIndexSet::GlobalIndex GlobalIndex │ │ │ │ │ -The type of the global index. │ │ │ │ │ -Definition remoteindices.hh:216 │ │ │ │ │ -Dune::RemoteIndices::ParallelIndexSet │ │ │ │ │ -T ParallelIndexSet │ │ │ │ │ -Type of the index set we use, e.g. ParallelLocalIndexSet. │ │ │ │ │ -Definition remoteindices.hh:207 │ │ │ │ │ -Dune::RemoteIndices::Attribute │ │ │ │ │ -LocalIndex::Attribute Attribute │ │ │ │ │ -The type of the attribute. │ │ │ │ │ -Definition remoteindices.hh:227 │ │ │ │ │ -Dune::RemoteIndices::RemoteIndexMap │ │ │ │ │ -std::map< int, std::pair< RemoteIndexList *, RemoteIndexList * > > │ │ │ │ │ -RemoteIndexMap │ │ │ │ │ -The type of the map from rank to remote index list. │ │ │ │ │ -Definition remoteindices.hh:246 │ │ │ │ │ -Dune::RemoteIndices::setNeighbours │ │ │ │ │ -void setNeighbours(const C &neighbours) │ │ │ │ │ -Definition remoteindices.hh:301 │ │ │ │ │ -Dune::RemoteIndices::RemoteIndexList │ │ │ │ │ -Dune::SLList< RemoteIndex, Allocator > RemoteIndexList │ │ │ │ │ -The type of the remote index list. │ │ │ │ │ -Definition remoteindices.hh:242 │ │ │ │ │ -Dune::RemoteIndices::CollectiveIteratorT │ │ │ │ │ -CollectiveIterator< T, A > CollectiveIteratorT │ │ │ │ │ -The type of the collective iterator over all remote indices. │ │ │ │ │ -Definition remoteindices.hh:211 │ │ │ │ │ -Dune::RemoteIndices::Allocator │ │ │ │ │ -typename std::allocator_traits< A >::template rebind_alloc< RemoteIndex > │ │ │ │ │ -Allocator │ │ │ │ │ -The type of the allocator for the remote index list. │ │ │ │ │ -Definition remoteindices.hh:238 │ │ │ │ │ -Dune::RemoteIndices::LocalIndex │ │ │ │ │ -ParallelIndexSet::LocalIndex LocalIndex │ │ │ │ │ -The type of the local index. │ │ │ │ │ -Definition remoteindices.hh:222 │ │ │ │ │ -Dune::RemoteIndices::const_iterator │ │ │ │ │ -RemoteIndexMap::const_iterator const_iterator │ │ │ │ │ -Definition remoteindices.hh:248 │ │ │ │ │ -Dune::RemoteIndex │ │ │ │ │ -Information about an index residing on another processor. │ │ │ │ │ -Definition remoteindices.hh:74 │ │ │ │ │ -Dune::RemoteIndex::repairLocalIndexPointers │ │ │ │ │ -friend void repairLocalIndexPointers(std::map< int, SLList< std::pair< typename │ │ │ │ │ -T::GlobalIndex, typename T::LocalIndex::Attribute >, A > > &, RemoteIndices< T, │ │ │ │ │ -A1 > &, const T &) │ │ │ │ │ -Dune::RemoteIndex::GlobalIndex │ │ │ │ │ -T1 GlobalIndex │ │ │ │ │ -the type of the global index. This type has to provide at least a operator< for │ │ │ │ │ -sorting. │ │ │ │ │ -Definition remoteindices.hh:91 │ │ │ │ │ -Dune::RemoteIndex::Attribute │ │ │ │ │ -T2 Attribute │ │ │ │ │ -The type of the attributes. Normally this will be an enumeration like. │ │ │ │ │ -Definition remoteindices.hh:100 │ │ │ │ │ -Dune::RemoteIndex::PairType │ │ │ │ │ -IndexPair< GlobalIndex, ParallelLocalIndex< Attribute > > PairType │ │ │ │ │ -The type of the index pair. │ │ │ │ │ -Definition remoteindices.hh:106 │ │ │ │ │ -Dune::RemoteIndexListModifier │ │ │ │ │ -Modifier for adding and/or deleting remote indices from the remote index list. │ │ │ │ │ -Definition remoteindices.hh:550 │ │ │ │ │ -Dune::RemoteIndexListModifier::RemoteIndexList │ │ │ │ │ -Dune::SLList< RemoteIndex, Allocator > RemoteIndexList │ │ │ │ │ -The type of the remote index list. │ │ │ │ │ -Definition remoteindices.hh:601 │ │ │ │ │ -Dune::RemoteIndexListModifier::Allocator │ │ │ │ │ -A Allocator │ │ │ │ │ -The type of the allocator for the remote index list. │ │ │ │ │ -Definition remoteindices.hh:597 │ │ │ │ │ -Dune::RemoteIndexListModifier::GlobalIndex │ │ │ │ │ -ParallelIndexSet::GlobalIndex GlobalIndex │ │ │ │ │ -The type of the global index. │ │ │ │ │ -Definition remoteindices.hh:577 │ │ │ │ │ -Dune::RemoteIndexListModifier::LocalIndex │ │ │ │ │ -ParallelIndexSet::LocalIndex LocalIndex │ │ │ │ │ -The type of the local index. │ │ │ │ │ -Definition remoteindices.hh:582 │ │ │ │ │ -Dune::RemoteIndexListModifier::ConstIterator │ │ │ │ │ -RemoteIndexList::const_iterator ConstIterator │ │ │ │ │ -The type of the remote index list iterator. │ │ │ │ │ -Definition remoteindices.hh:611 │ │ │ │ │ -Dune::RemoteIndexListModifier::ModifyIterator │ │ │ │ │ -SLListModifyIterator< RemoteIndex, Allocator > ModifyIterator │ │ │ │ │ -The type of the modifying iterator of the remote index list. │ │ │ │ │ -Definition remoteindices.hh:606 │ │ │ │ │ -Dune::RemoteIndexListModifier::ParallelIndexSet │ │ │ │ │ -T ParallelIndexSet │ │ │ │ │ -Type of the index set we use. │ │ │ │ │ -Definition remoteindices.hh:572 │ │ │ │ │ -Dune::RemoteIndexListModifier::RemoteIndexListModifier │ │ │ │ │ -RemoteIndexListModifier() │ │ │ │ │ -Default constructor. │ │ │ │ │ -Definition remoteindices.hh:675 │ │ │ │ │ -Dune::RemoteIndexListModifier::Attribute │ │ │ │ │ -LocalIndex::Attribute Attribute │ │ │ │ │ -The type of the attribute. │ │ │ │ │ -Definition remoteindices.hh:587 │ │ │ │ │ -Dune::RemoteIndexListModifier::RemoteIndex │ │ │ │ │ -Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex │ │ │ │ │ -Type of the remote indices we manage. │ │ │ │ │ -Definition remoteindices.hh:592 │ │ │ │ │ -Dune::RemoteIndexListModifier::MODIFYINDEXSET │ │ │ │ │ -static constexpr bool MODIFYINDEXSET │ │ │ │ │ -If true the index set corresponding to the remote indices might get modified. │ │ │ │ │ -Definition remoteindices.hh:567 │ │ │ │ │ -Dune::CollectiveIterator │ │ │ │ │ -A collective iterator for moving over the remote indices for all processes │ │ │ │ │ -collectively. │ │ │ │ │ -Definition remoteindices.hh:707 │ │ │ │ │ -Dune::CollectiveIterator::RemoteIndexMap │ │ │ │ │ -std::map< int, std::pair< RemoteIndexList *, RemoteIndexList * > > │ │ │ │ │ -RemoteIndexMap │ │ │ │ │ -The type of the map from rank to remote index list. │ │ │ │ │ -Definition remoteindices.hh:747 │ │ │ │ │ -Dune::OwnerOverlapCopyCommunication │ │ │ │ │ -Definition remoteindices.hh:168 │ │ │ │ │ -Dune::RemoteIndexListModifier::InvalidPosition │ │ │ │ │ -Definition remoteindices.hh:557 │ │ │ │ │ -Dune::CollectiveIterator::iterator │ │ │ │ │ -Iterator over the valid underlying iterators. │ │ │ │ │ -Definition remoteindices.hh:791 │ │ │ │ │ -Dune::CollectiveIterator::iterator::iterator │ │ │ │ │ -iterator(const RealIterator &iter, const ConstRealIterator &end, GlobalIndex │ │ │ │ │ -&index) │ │ │ │ │ -Definition remoteindices.hh:798 │ │ │ │ │ -Dune::CollectiveIterator::iterator::iterator │ │ │ │ │ -iterator(const iterator &other) │ │ │ │ │ -Definition remoteindices.hh:816 │ │ │ │ │ -Dune::CollectiveIterator::iterator::operator* │ │ │ │ │ -const RemoteIndex & operator*() const │ │ │ │ │ -Definition remoteindices.hh:837 │ │ │ │ │ -Dune::CollectiveIterator::iterator::ConstRealIterator │ │ │ │ │ -Map::iterator ConstRealIterator │ │ │ │ │ -Definition remoteindices.hh:794 │ │ │ │ │ -Dune::CollectiveIterator::iterator::operator++ │ │ │ │ │ -iterator & operator++() │ │ │ │ │ -Definition remoteindices.hh:821 │ │ │ │ │ -Dune::CollectiveIterator::iterator::operator-> │ │ │ │ │ -const RemoteIndex * operator->() const │ │ │ │ │ -Definition remoteindices.hh:849 │ │ │ │ │ -Dune::CollectiveIterator::iterator::operator== │ │ │ │ │ -bool operator==(const iterator &other) const │ │ │ │ │ -Definition remoteindices.hh:855 │ │ │ │ │ -Dune::CollectiveIterator::iterator::process │ │ │ │ │ -int process() const │ │ │ │ │ -Definition remoteindices.hh:843 │ │ │ │ │ -Dune::CollectiveIterator::iterator::iterator │ │ │ │ │ -iterator(const RealIterator &iter, const ConstRealIterator &end, GlobalIndex │ │ │ │ │ -index, Attribute attribute) │ │ │ │ │ -Definition remoteindices.hh:806 │ │ │ │ │ -Dune::CollectiveIterator::iterator::operator!= │ │ │ │ │ -bool operator!=(const iterator &other) const │ │ │ │ │ -Definition remoteindices.hh:861 │ │ │ │ │ -Dune::CollectiveIterator::iterator::RealIterator │ │ │ │ │ -Map::iterator RealIterator │ │ │ │ │ -Definition remoteindices.hh:793 │ │ │ │ │ -Dune::SLListConstIterator │ │ │ │ │ -A constant iterator for the SLList. │ │ │ │ │ -Definition sllist.hh:371 │ │ │ │ │ -Dune::SLListModifyIterator │ │ │ │ │ -A mutable iterator for the SLList. │ │ │ │ │ -Definition sllist.hh:429 │ │ │ │ │ -Dune::SLList │ │ │ │ │ -A single linked list. │ │ │ │ │ -Definition sllist.hh:44 │ │ │ │ │ +Dune::DenseMatVecTraits │ │ │ │ │ +Definition matvectraits.hh:31 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00059.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpi_collective_benchmark.cc File Reference │ │ │ │ +dune-common: enumset.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,336 +65,77 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Functions | │ │ │ │ -Variables
│ │ │ │ -
mpi_collective_benchmark.cc File Reference
│ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
enumset.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <chrono>
│ │ │ │ -#include <functional>
│ │ │ │ -#include <iostream>
│ │ │ │ -#include <iomanip>
│ │ │ │ -#include <string>
│ │ │ │ -#include <thread>
│ │ │ │ -#include <tuple>
│ │ │ │ -#include <vector>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/timer.hh>
│ │ │ │ -#include <dune/common/parametertree.hh>
│ │ │ │ -#include <dune/common/parametertreeparser.hh>
│ │ │ │ -#include <dune/common/parallel/future.hh>
│ │ │ │ -#include <dune/common/parallel/mpihelper.hh>
│ │ │ │ -
│ │ │ │ + │ │ │ │ +

Classes for building sets out of enumeration values. │ │ │ │ +More...

│ │ │ │ +
#include <iostream>
│ │ │ │ +
│ │ │ │ +

Go to the source code of this file.

│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

class  Dune::EmptySet< TA >
 An empty set. More...
 
class  Dune::AllSet< TA >
 A set containing everything. More...
 
class  Dune::EnumItem< TA, item >
 A set consisting only of one item. More...
 
class  Dune::EnumRange< TA, from, end >
 A set representing a range including the borders. More...
 
class  Dune::NegateSet< S >
 The negation of a set. An item is contained in the set if and only if it is not contained in the negated set. More...
 
class  Dune::Combine< TI1, TI2, TA >
 A set combining two other sets. More...
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ Functions

template<class CC >
void communicate (CC &cc)
 
template<class CC >
Dune::Future< void > startCommunication (CC &cc)
 
template<class CC >
double runBlocking (CC &cc)
 
template<class CC >
double runNonblockingWait (CC &cc)
 
std::tuple< double, double > runNonblockingSleep (decltype(Dune::MPIHelper::getCommunication())&cc, std::chrono::duration< double > wait_time)
 
std::tuple< double, double > runNonblockingActive (decltype(Dune::MPIHelper::getCommunication())&cc, std::chrono::duration< double > wait_time)
 
std::tuple< double, double > determineOverlap (std::function< std::tuple< double, double >(std::chrono::duration< double >)> fun)
 
void printHeader ()
 
void run (int s)
 
int main (int argc, char **argv)
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ -Variables

Dune::ParameterTree options
 Benchmark for measure the possible overlap of computation and communication at MPI collective communications.
 
std::vector< std::string > all_methods
 
template<typename TA , int i>
std::ostream & Dune::operator<< (std::ostream &os, const EnumItem< TA, i > &)
 
template<typename TA , int from, int to>
std::ostream & Dune::operator<< (std::ostream &os, const EnumRange< TA, from, to > &)
 
template<class TI1 , class TI2 >
Combine< TI1, TI2, typename TI1::Type > Dune::combine (const TI1 &set1, const TI2 &set2)
 
template<class TI1 , class TI2 , class T >
std::ostream & Dune::operator<< (std::ostream &os, const Combine< TI1, TI2, T > &)
 
│ │ │ │ -

Function Documentation

│ │ │ │ - │ │ │ │ -

◆ communicate()

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -template<class CC >
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
void communicate (CC & cc)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ determineOverlap()

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
std::tuple< double, double > determineOverlap (std::function< std::tuple< double, double >(std::chrono::duration< double >)> fun)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ main()

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
int main (int argc,
char ** argv 
)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ printHeader()

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
void printHeader ()
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ run()

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
void run (int s)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ runBlocking()

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -template<class CC >
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
double runBlocking (CC & cc)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ runNonblockingActive()

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
std::tuple< double, double > runNonblockingActive (decltype(Dune::MPIHelper::getCommunication())& cc,
std::chrono::duration< double > wait_time 
)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ runNonblockingSleep()

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
std::tuple< double, double > runNonblockingSleep (decltype(Dune::MPIHelper::getCommunication())& cc,
std::chrono::duration< double > wait_time 
)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ runNonblockingWait()

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -template<class CC >
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
double runNonblockingWait (CC & cc)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ startCommunication()

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -template<class CC >
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
Dune::Future< void > startCommunication (CC & cc)
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ -

Variable Documentation

│ │ │ │ - │ │ │ │ -

◆ all_methods

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
std::vector<std::string> all_methods
│ │ │ │ -
│ │ │ │ -Initial value:
= {"allreduce",
│ │ │ │ -
"barrier",
│ │ │ │ -
"broadcast",
│ │ │ │ -
"gather",
│ │ │ │ -
"allgather",
│ │ │ │ -
"scatter"}
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

◆ options

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
Dune::ParameterTree options
│ │ │ │ -
│ │ │ │ - │ │ │ │ -

Benchmark for measure the possible overlap of computation and communication at MPI collective communications.

│ │ │ │ -

This benchmark is inspired by the sandia micro benchmark: W. Lawry, C. Wilson, A. Maccabe, R. Brightwell. COMB: A Portable Benchmark Suite for Assessing MPI Overlap. In Proceedings of the IEEE International Conference on Cluster Computing (CLUSTER 2002), p. 472, 2002. http://www.cs.sandia.gov/smb/overhead.html

│ │ │ │ -

The following communication times are measured: Blocking: Blocking call. E.g. MPI_Allreduce Nonblocking_wait (NB_Wait): Nonblocking (e.g. MPI_Iallreduce) call directly followed by MPI_Wait. Nonblocking_sleep (NB_Sleep): Nonblocking call followed by a busy wait until the work time has passed. Then MPI_Wait. Nonblocking_active (NB_active): Nonblocking call followed by a basy wait where in every iteration MPI_Test is called until the work time has passed. The MPI_wait.

│ │ │ │ -

The overhead is computed as the time for the Nonblocking call plus the time for MPI_Wait. The iteration time is the time for the whole communication. The available part of the communication time(avail(%)) is computed as 1-(overhead/base_t), where base_t is the time for calling the method with wait time = 0. The overhead is determined by increasing the work time successive until it is the dominant factor in the iteration time. Then the overhead is computed as iter_t-work_t.

│ │ │ │ -

Usage: mpirun ./mpi_collective_benchmark [options]

│ │ │ │ -

options: -method: default: allreduce. possible methods: allreduce, barrier, broadcast, gather, allgather, scatter -iterations: default: 10000. Number of iterations for measure the time for one communication -allMethods: default:0. If 1 iterates over all available methods -startSize: default: n, where n is the size of MPI_COMM_WORLD. runs the benchmark for different communicator sizes, starting with startSize. After every run the size is doubled. Finally one run is made for the whole communicator. -verbose: default: 0. If 1 prints intermediate information while determining the overhead. -threshold: default: 2. The threshold when the work time is the dominant factor in the iteration time. (Similar to the threshold in the sandia benchmark) -nohdr: default: 0. Suppress output of the header.

│ │ │ │ -

options can be set either in the options.ini file or can be pass at the command-line (-key value).

│ │ │ │ -

To get a good 'available' value for the NB_sleep communication, some MPI implementation need to spawn an extra thread. With MPICH you can activate this by setting the environment variable MPI_ASYNC_PROGRESS to 1, with IntelMPI the variable is called I_MPI_ASYNC_PROGRESS. (https://software.intel.com/en-us/mpi-developer-reference-linux-asynchronous-progress-control)

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ +

Detailed Description

│ │ │ │ +

Classes for building sets out of enumeration values.

│ │ │ │ +
Author
Markus Blatt
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,152 +1,58 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ - * benchmark │ │ │ │ │ -Functions | Variables │ │ │ │ │ -mpi_collective_benchmark.cc File Reference │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +enumset.hh File Reference │ │ │ │ │ +Classes for building sets out of enumeration values. More... │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -Functions │ │ │ │ │ -template │ │ │ │ │ - void  communicate (CC &cc) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - Dune::Future< void >  startCommunication (CC &cc) │ │ │ │ │ +Go_to_the_source_code_of_this_file. │ │ │ │ │ +Classes │ │ │ │ │ +class   Dune::EmptySet<_TA_> │ │ │ │ │ +  An empty set. More... │ │ │ │ │ +  │ │ │ │ │ +class   Dune::AllSet<_TA_> │ │ │ │ │ +  A set containing everything. More... │ │ │ │ │ +  │ │ │ │ │ +class   Dune::EnumItem<_TA,_item_> │ │ │ │ │ +  A set consisting only of one item. More... │ │ │ │ │ +  │ │ │ │ │ +class   Dune::EnumRange<_TA,_from,_end_> │ │ │ │ │ +  A set representing a range including the borders. More... │ │ │ │ │ +  │ │ │ │ │ +class   Dune::NegateSet<_S_> │ │ │ │ │ +  The negation of a set. An item is contained in the set if and only if │ │ │ │ │ + it is not contained in the negated set. More... │ │ │ │ │ +  │ │ │ │ │ +class   Dune::Combine<_TI1,_TI2,_TA_> │ │ │ │ │ +  A set combining two other sets. More... │ │ │ │ │ +  │ │ │ │ │ +Namespaces │ │ │ │ │ +namespace   Dune │ │ │ │ │ +  Dune namespace. │ │ │ │ │   │ │ │ │ │ -template │ │ │ │ │ - double  runBlocking (CC &cc) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - double  runNonblockingWait (CC &cc) │ │ │ │ │ -  │ │ │ │ │ -std::tuple< double, double >  runNonblockingSleep (decltype(Dune::MPIHelper:: │ │ │ │ │ - getCommunication())&cc, std::chrono::duration< │ │ │ │ │ - double > wait_time) │ │ │ │ │ -  │ │ │ │ │ -std::tuple< double, double >  runNonblockingActive (decltype(Dune::MPIHelper:: │ │ │ │ │ - getCommunication())&cc, std::chrono::duration< │ │ │ │ │ - double > wait_time) │ │ │ │ │ -  │ │ │ │ │ -std::tuple< double, double >  determineOverlap (std::function< std::tuple< │ │ │ │ │ - double, double >(std::chrono::duration< double │ │ │ │ │ - >)> fun) │ │ │ │ │ -  │ │ │ │ │ - void  printHeader () │ │ │ │ │ -  │ │ │ │ │ - void  run (int s) │ │ │ │ │ -  │ │ │ │ │ - int  main (int argc, char **argv) │ │ │ │ │ -  │ │ │ │ │ -Variables │ │ │ │ │ - Dune::ParameterTree  options │ │ │ │ │ - Benchmark for measure the possible overlap of │ │ │ │ │ -  computation and communication at MPI collective │ │ │ │ │ - communications. │ │ │ │ │ -  │ │ │ │ │ -std::vector< std::string >  all_methods │ │ │ │ │ -  │ │ │ │ │ -***** Function Documentation ***** │ │ │ │ │ -***** ◆ communicate() ***** │ │ │ │ │ -template │ │ │ │ │ -void communicate ( CC &  cc ) │ │ │ │ │ -***** ◆ determineOverlap() ***** │ │ │ │ │ -std::tuple< double, double > std::function< std::tuple< double, │ │ │ │ │ -determineOverlap ( double >(std::chrono::duration< double fun ) │ │ │ │ │ - >)>  │ │ │ │ │ -***** ◆ main() ***** │ │ │ │ │ -int main ( int  argc, │ │ │ │ │ - char **  argv  │ │ │ │ │ - ) │ │ │ │ │ -***** ◆ printHeader() ***** │ │ │ │ │ -void printHeader ( ) │ │ │ │ │ -***** ◆ run() ***** │ │ │ │ │ -void run ( int  s ) │ │ │ │ │ -***** ◆ runBlocking() ***** │ │ │ │ │ -template │ │ │ │ │ -double runBlocking ( CC &  cc ) │ │ │ │ │ -***** ◆ runNonblockingActive() ***** │ │ │ │ │ -std::tuple< double, double > ( decltype(Dune::MPIHelper:: cc, │ │ │ │ │ -runNonblockingActive getCommunication())&  │ │ │ │ │ - std::chrono::duration< double >  wait_time  │ │ │ │ │ - ) │ │ │ │ │ -***** ◆ runNonblockingSleep() ***** │ │ │ │ │ -std::tuple< double, double > ( decltype(Dune::MPIHelper:: cc, │ │ │ │ │ -runNonblockingSleep getCommunication())&  │ │ │ │ │ - std::chrono::duration< double >  wait_time  │ │ │ │ │ - ) │ │ │ │ │ -***** ◆ runNonblockingWait() ***** │ │ │ │ │ -template │ │ │ │ │ -double runNonblockingWait ( CC &  cc ) │ │ │ │ │ -***** ◆ startCommunication() ***** │ │ │ │ │ -template │ │ │ │ │ -Dune::Future< void > startCommunication ( CC &  cc ) │ │ │ │ │ -***** Variable Documentation ***** │ │ │ │ │ -***** ◆ all_methods ***** │ │ │ │ │ -std::vector all_methods │ │ │ │ │ -Initial value: │ │ │ │ │ -= {"allreduce", │ │ │ │ │ -"barrier", │ │ │ │ │ -"broadcast", │ │ │ │ │ -"gather", │ │ │ │ │ -"allgather", │ │ │ │ │ -"scatter"} │ │ │ │ │ -***** ◆ options ***** │ │ │ │ │ -Dune::ParameterTree options │ │ │ │ │ -Benchmark for measure the possible overlap of computation and communication at │ │ │ │ │ -MPI collective communications. │ │ │ │ │ -This benchmark is inspired by the sandia micro benchmark: W. Lawry, C. Wilson, │ │ │ │ │ -A. Maccabe, R. Brightwell. COMB: A Portable Benchmark Suite for Assessing MPI │ │ │ │ │ -Overlap. In Proceedings of the IEEE International Conference on Cluster │ │ │ │ │ -Computing (CLUSTER 2002), p. 472, 2002. http://www.cs.sandia.gov/smb/ │ │ │ │ │ -overhead.html │ │ │ │ │ -The following communication times are measured: Blocking: Blocking call. E.g. │ │ │ │ │ -MPI_Allreduce Nonblocking_wait (NB_Wait): Nonblocking (e.g. MPI_Iallreduce) │ │ │ │ │ -call directly followed by MPI_Wait. Nonblocking_sleep (NB_Sleep): Nonblocking │ │ │ │ │ -call followed by a busy wait until the work time has passed. Then MPI_Wait. │ │ │ │ │ -Nonblocking_active (NB_active): Nonblocking call followed by a basy wait where │ │ │ │ │ -in every iteration MPI_Test is called until the work time has passed. The MPI_ │ │ │ │ │ -wait. │ │ │ │ │ -The overhead is computed as the time for the Nonblocking call plus the time for │ │ │ │ │ -MPI_Wait. The iteration time is the time for the whole communication. The │ │ │ │ │ -available part of the communication time(avail(%)) is computed as 1-(overhead/ │ │ │ │ │ -base_t), where base_t is the time for calling the method with wait time = 0. │ │ │ │ │ -The overhead is determined by increasing the work time successive until it is │ │ │ │ │ -the dominant factor in the iteration time. Then the overhead is computed as │ │ │ │ │ -iter_t-work_t. │ │ │ │ │ -Usage: mpirun ./mpi_collective_benchmark [options] │ │ │ │ │ -options: -method: default: allreduce. possible methods: allreduce, barrier, │ │ │ │ │ -broadcast, gather, allgather, scatter -iterations: default: 10000. Number of │ │ │ │ │ -iterations for measure the time for one communication -allMethods: default:0. │ │ │ │ │ -If 1 iterates over all available methods -startSize: default: n, where n is the │ │ │ │ │ -size of MPI_COMM_WORLD. runs the benchmark for different communicator sizes, │ │ │ │ │ -starting with startSize. After every run the size is doubled. Finally one run │ │ │ │ │ -is made for the whole communicator. -verbose: default: 0. If 1 prints │ │ │ │ │ -intermediate information while determining the overhead. -threshold: default: │ │ │ │ │ -2. The threshold when the work time is the dominant factor in the iteration │ │ │ │ │ -time. (Similar to the threshold in the sandia benchmark) -nohdr: default: 0. │ │ │ │ │ -Suppress output of the header. │ │ │ │ │ -options can be set either in the options.ini file or can be pass at the │ │ │ │ │ -command-line (-key value). │ │ │ │ │ -To get a good 'available' value for the NB_sleep communication, some MPI │ │ │ │ │ -implementation need to spawn an extra thread. With MPICH you can activate this │ │ │ │ │ -by setting the environment variable MPI_ASYNC_PROGRESS to 1, with IntelMPI the │ │ │ │ │ -variable is called I_MPI_ASYNC_PROGRESS. (https://software.intel.com/en-us/mpi- │ │ │ │ │ -developer-reference-linux-asynchronous-progress-control) │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ + std::ostream &  Dune::operator<< (std::ostream &os, const │ │ │ │ │ + EnumItem< TA, i > &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + std::ostream &  Dune::operator<< (std::ostream &os, const │ │ │ │ │ + EnumRange< TA, from, to > &) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +Combine< TI1, TI2, typename TI1::Type Dune::combine (const TI1 &set1, const TI2 │ │ │ │ │ + >  &set2) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + std::ostream &  Dune::operator<< (std::ostream &os, const │ │ │ │ │ + Combine< TI1, TI2, T > &) │ │ │ │ │ +  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Classes for building sets out of enumeration values. │ │ │ │ │ + Author │ │ │ │ │ + Markus Blatt │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00062.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: communication.hh File Reference │ │ │ │ +dune-common: singleton.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,71 +65,46 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces | │ │ │ │ -Typedefs | │ │ │ │ -Functions
│ │ │ │ -
communication.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
singleton.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Implements an utility class that provides collective communication methods for sequential programs. │ │ │ │ +

Useful wrapper for creating singletons. │ │ │ │ More...

│ │ │ │ -
#include <iostream>
│ │ │ │ -#include <complex>
│ │ │ │ -#include <algorithm>
│ │ │ │ -#include <vector>
│ │ │ │ -#include <dune/common/binaryfunctions.hh>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/parallel/future.hh>
│ │ │ │ +
#include <dune/common/visibility.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

struct  Dune::No_Comm
 
class  Dune::Communication< Communicator >
 Collective communication interface and sequential default implementation. More...
class  Dune::Singleton< T >
 An adapter to turn a class into a singleton. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Typedefs

template<class T >
using Dune::CollectiveCommunication = Communication< T >
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

bool Dune::operator== (const No_Comm &, const No_Comm &)
 Comparison operator for MPI compatibility.
 
bool Dune::operator!= (const No_Comm &, const No_Comm &)
 Comparison operator for MPI compatibility.
 
│ │ │ │

Detailed Description

│ │ │ │ -

Implements an utility class that provides collective communication methods for sequential programs.

│ │ │ │ -

An abstraction to the basic methods of parallel communication, following the message-passing paradigm.

│ │ │ │ +

Useful wrapper for creating singletons.

│ │ │ │ +

Inspired by the article CodeGuru: A Leak-Free Singleton class

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,49 +1,24 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces | Typedefs | Functions │ │ │ │ │ -communication.hh File Reference │ │ │ │ │ -Common » Parallel_Communication │ │ │ │ │ -Implements an utility class that provides collective communication methods for │ │ │ │ │ -sequential programs. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +singleton.hh File Reference │ │ │ │ │ +Useful wrapper for creating singletons. More... │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct   Dune::No_Comm │ │ │ │ │ -  │ │ │ │ │ - class   Dune::Communication<_Communicator_> │ │ │ │ │ -  Collective communication interface and sequential default │ │ │ │ │ - implementation. More... │ │ │ │ │ +class   Dune::Singleton<_T_> │ │ │ │ │ +  An adapter to turn a class into a singleton. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Typedefs │ │ │ │ │ -template │ │ │ │ │ -using  Dune::CollectiveCommunication = Communication< T > │ │ │ │ │ -  │ │ │ │ │ -Functions │ │ │ │ │ -bool  Dune::operator== (const No_Comm &, const No_Comm &) │ │ │ │ │ -  Comparison operator for MPI compatibility. │ │ │ │ │ -  │ │ │ │ │ -bool  Dune::operator!= (const No_Comm &, const No_Comm &) │ │ │ │ │ -  Comparison operator for MPI compatibility. │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Implements an utility class that provides collective communication methods for │ │ │ │ │ -sequential programs. │ │ │ │ │ -An abstraction to the basic methods of parallel communication, following the │ │ │ │ │ -message-passing paradigm. │ │ │ │ │ +Useful wrapper for creating singletons. │ │ │ │ │ +Inspired by the article CodeGuru:_A_Leak-Free_Singleton_class │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00062_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: communication.hh Source File │ │ │ │ +dune-common: singleton.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,417 +70,66 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
communication.hh
│ │ │ │ +
singleton.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PARALLEL_COMMUNICATION_HH
│ │ │ │ -
6#define DUNE_COMMON_PARALLEL_COMMUNICATION_HH
│ │ │ │ -
14#include <iostream>
│ │ │ │ -
15#include <complex>
│ │ │ │ -
16#include <algorithm>
│ │ │ │ -
17#include <vector>
│ │ │ │ -
18
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
22
│ │ │ │ -
42namespace Dune
│ │ │ │ -
43{
│ │ │ │ -
44
│ │ │ │ -
45 /* define some type that definitely differs from MPI_Comm */
│ │ │ │ -
46 struct No_Comm {};
│ │ │ │ -
47
│ │ │ │ -
│ │ │ │ -
52 inline bool operator==(const No_Comm&, const No_Comm&)
│ │ │ │ -
53 {
│ │ │ │ -
54 return true;
│ │ │ │ -
55 }
│ │ │ │ -
│ │ │ │ -
56
│ │ │ │ -
│ │ │ │ -
61 inline bool operator!=(const No_Comm&, const No_Comm&)
│ │ │ │ -
62 {
│ │ │ │ -
63 return false;
│ │ │ │ -
64 }
│ │ │ │ -
│ │ │ │ +
5#ifndef DUNE_SINGLETON_HH
│ │ │ │ +
6#define DUNE_SINGLETON_HH
│ │ │ │ +
7
│ │ │ │ + │ │ │ │ +
9
│ │ │ │ +
17namespace Dune
│ │ │ │ +
18{
│ │ │ │ +
54 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
56 {
│ │ │ │ +
57 protected:
│ │ │ │ +
58 /* @brief Protected constructor. */
│ │ │ │ +
59 Singleton() = default;
│ │ │ │ +
60
│ │ │ │ +
61 public:
│ │ │ │ +
62
│ │ │ │ +
63 Singleton(const Singleton&) = delete;
│ │ │ │ +
64 void operator=(const Singleton&) = delete;
│ │ │ │
65
│ │ │ │ -
98 template<typename Communicator>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
100 {
│ │ │ │ -
101 public:
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
104 {}
│ │ │ │ -
│ │ │ │ -
105
│ │ │ │ -
│ │ │ │ -
110 Communication (const Communicator&)
│ │ │ │ -
111 {}
│ │ │ │ -
│ │ │ │ -
112
│ │ │ │ -
│ │ │ │ -
114 int rank () const
│ │ │ │ -
115 {
│ │ │ │ -
116 return 0;
│ │ │ │ -
117 }
│ │ │ │ -
│ │ │ │ -
118
│ │ │ │ -
│ │ │ │ -
120 operator No_Comm() const
│ │ │ │ -
121 {
│ │ │ │ -
122 return {};
│ │ │ │ -
123 }
│ │ │ │ -
│ │ │ │ -
124
│ │ │ │ -
│ │ │ │ -
126 int size () const
│ │ │ │ -
127 {
│ │ │ │ -
128 return 1;
│ │ │ │ -
129 }
│ │ │ │ -
│ │ │ │ -
130
│ │ │ │ -
134 template<class T>
│ │ │ │ -
│ │ │ │ -
135 int send([[maybe_unused]] const T& data,
│ │ │ │ -
136 [[maybe_unused]] int dest_rank,
│ │ │ │ -
137 [[maybe_unused]] int tag)
│ │ │ │ -
138 {
│ │ │ │ -
139 DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
│ │ │ │ -
140 }
│ │ │ │ -
│ │ │ │ -
141
│ │ │ │ -
145 template<class T>
│ │ │ │ -
│ │ │ │ -
146 PseudoFuture<T> isend([[maybe_unused]] const T&& data,
│ │ │ │ -
147 [[maybe_unused]] int dest_rank,
│ │ │ │ -
148 [[maybe_unused]] int tag)
│ │ │ │ -
149 {
│ │ │ │ -
150 DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
│ │ │ │ -
151 }
│ │ │ │ -
│ │ │ │ -
152
│ │ │ │ -
156 template<class T>
│ │ │ │ -
│ │ │ │ -
157 T recv([[maybe_unused]] T&& data,
│ │ │ │ -
158 [[maybe_unused]] int source_rank,
│ │ │ │ -
159 [[maybe_unused]] int tag,
│ │ │ │ -
160 [[maybe_unused]] void* status = 0)
│ │ │ │ -
161 {
│ │ │ │ -
162 DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
│ │ │ │ -
163 }
│ │ │ │ -
│ │ │ │ -
164
│ │ │ │ -
168 template<class T>
│ │ │ │ -
│ │ │ │ -
169 PseudoFuture<T> irecv([[maybe_unused]] T&& data,
│ │ │ │ -
170 [[maybe_unused]] int source_rank,
│ │ │ │ -
171 [[maybe_unused]] int tag)
│ │ │ │ -
172 {
│ │ │ │ -
173 DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
│ │ │ │ -
174 }
│ │ │ │ -
│ │ │ │ -
175
│ │ │ │ -
176 template<class T>
│ │ │ │ -
│ │ │ │ -
177 T rrecv([[maybe_unused]] T&& data,
│ │ │ │ -
178 [[maybe_unused]] int source_rank,
│ │ │ │ -
179 [[maybe_unused]] int tag,
│ │ │ │ -
180 [[maybe_unused]] void* status = 0) const
│ │ │ │ -
181 {
│ │ │ │ -
182 DUNE_THROW(ParallelError, "This method is not supported in sequential programs");
│ │ │ │ -
183 }
│ │ │ │ -
│ │ │ │ -
187 template<typename T>
│ │ │ │ -
│ │ │ │ -
188 T sum (const T& in) const
│ │ │ │ -
189 {
│ │ │ │ -
190 return in;
│ │ │ │ -
191 }
│ │ │ │ -
│ │ │ │ -
192
│ │ │ │ -
198 template<typename T>
│ │ │ │ -
│ │ │ │ -
199 int sum ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const
│ │ │ │ -
200 {
│ │ │ │ -
201 return 0;
│ │ │ │ -
202 }
│ │ │ │ -
│ │ │ │ -
203
│ │ │ │ -
207 template<typename T>
│ │ │ │ -
│ │ │ │ -
208 T prod (const T& in) const
│ │ │ │ -
209 {
│ │ │ │ -
210 return in;
│ │ │ │ -
211 }
│ │ │ │ -
│ │ │ │ -
212
│ │ │ │ -
218 template<typename T>
│ │ │ │ -
│ │ │ │ -
219 int prod ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const
│ │ │ │ -
220 {
│ │ │ │ -
221 return 0;
│ │ │ │ -
222 }
│ │ │ │ -
│ │ │ │ -
223
│ │ │ │ -
227 template<typename T>
│ │ │ │ -
│ │ │ │ -
228 T min (const T& in) const
│ │ │ │ -
229 {
│ │ │ │ -
230 return in;
│ │ │ │ -
231 }
│ │ │ │ -
│ │ │ │ -
232
│ │ │ │ -
238 template<typename T>
│ │ │ │ -
│ │ │ │ -
239 int min ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const
│ │ │ │ -
240 {
│ │ │ │ -
241 return 0;
│ │ │ │ -
242 }
│ │ │ │ -
│ │ │ │ -
243
│ │ │ │ -
247 template<typename T>
│ │ │ │ -
│ │ │ │ -
248 T max (const T& in) const
│ │ │ │ -
249 {
│ │ │ │ -
250 return in;
│ │ │ │ -
251 }
│ │ │ │ -
│ │ │ │ -
252
│ │ │ │ -
258 template<typename T>
│ │ │ │ -
│ │ │ │ -
259 int max ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const
│ │ │ │ -
260 {
│ │ │ │ -
261 return 0;
│ │ │ │ -
262 }
│ │ │ │ -
│ │ │ │ -
263
│ │ │ │ -
│ │ │ │ -
267 int barrier () const
│ │ │ │ -
268 {
│ │ │ │ -
269 return 0;
│ │ │ │ -
270 }
│ │ │ │ -
│ │ │ │ -
271
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
276 {
│ │ │ │ -
277 return {true}; // return a valid future
│ │ │ │ -
278 }
│ │ │ │ -
│ │ │ │ -
279
│ │ │ │ -
283 template<typename T>
│ │ │ │ -
│ │ │ │ -
284 int broadcast ([[maybe_unused]] T* inout,
│ │ │ │ -
285 [[maybe_unused]] int len,
│ │ │ │ -
286 [[maybe_unused]] int root) const
│ │ │ │ -
287 {
│ │ │ │ -
288 return 0;
│ │ │ │ -
289 }
│ │ │ │ -
│ │ │ │ -
290
│ │ │ │ -
294 template<class T>
│ │ │ │ -
│ │ │ │ -
295 PseudoFuture<T> ibroadcast(T&& data, int root) const{
│ │ │ │ -
296 return {std::forward<T>(data)};
│ │ │ │ -
297 }
│ │ │ │ -
│ │ │ │ -
298
│ │ │ │ -
299
│ │ │ │ -
312 template<typename T>
│ │ │ │ -
│ │ │ │ -
313 int gather (const T* in, T* out, int len, [[maybe_unused]] int root) const // note out must have same size as in
│ │ │ │ -
314 {
│ │ │ │ -
315 for (int i=0; i<len; i++)
│ │ │ │ -
316 out[i] = in[i];
│ │ │ │ -
317 return 0;
│ │ │ │ -
318 }
│ │ │ │ -
│ │ │ │ -
319
│ │ │ │ -
323 template<class TIN, class TOUT = std::vector<TIN>>
│ │ │ │ -
│ │ │ │ -
324 PseudoFuture<TOUT> igather(TIN&& data_in, TOUT&& data_out, int root){
│ │ │ │ -
325 *(data_out.begin()) = std::forward<TIN>(data_in);
│ │ │ │ -
326 return {std::forward<TOUT>(data_out)};
│ │ │ │ -
327 }
│ │ │ │ -
│ │ │ │ -
328
│ │ │ │ -
329
│ │ │ │ -
349 template<typename T>
│ │ │ │ -
│ │ │ │ -
350 int gatherv (const T* in,
│ │ │ │ -
351 int sendDataLen,
│ │ │ │ -
352 T* out,
│ │ │ │ -
353 [[maybe_unused]] int* recvDataLen,
│ │ │ │ -
354 int* displ,
│ │ │ │ -
355 [[maybe_unused]] int root) const
│ │ │ │ -
356 {
│ │ │ │ -
357 for (int i=*displ; i<sendDataLen; i++)
│ │ │ │ -
358 out[i] = in[i];
│ │ │ │ -
359 return 0;
│ │ │ │ -
360 }
│ │ │ │ -
│ │ │ │ -
361
│ │ │ │ -
375 template<typename T>
│ │ │ │ -
│ │ │ │ -
376 int scatter (const T* sendData, T* recvData, int len, [[maybe_unused]] int root) const // note out must have same size as in
│ │ │ │ -
377 {
│ │ │ │ -
378 for (int i=0; i<len; i++)
│ │ │ │ -
379 recvData[i] = sendData[i];
│ │ │ │ -
380 return 0;
│ │ │ │ -
381 }
│ │ │ │ -
│ │ │ │ -
382
│ │ │ │ -
386 template<class TIN, class TOUT = TIN>
│ │ │ │ -
│ │ │ │ -
387 PseudoFuture<TOUT> iscatter(TIN&& data_in, TOUT&& data_out, int root){
│ │ │ │ -
388 data_out = *(std::forward<TIN>(data_in).begin());
│ │ │ │ -
389 return {std::forward<TOUT>(data_out)};
│ │ │ │ -
390 }
│ │ │ │ -
│ │ │ │ -
391
│ │ │ │ -
410 template<typename T>
│ │ │ │ -
│ │ │ │ -
411 int scatterv (const T* sendData,int* sendDataLen, int* displ, T* recvData,
│ │ │ │ -
412 [[maybe_unused]] int recvDataLen, [[maybe_unused]] int root) const
│ │ │ │ -
413 {
│ │ │ │ -
414 for (int i=*displ; i<*sendDataLen; i++)
│ │ │ │ -
415 recvData[i] = sendData[i];
│ │ │ │ -
416 return 0;
│ │ │ │ -
417 }
│ │ │ │ -
│ │ │ │ -
418
│ │ │ │ -
432 template<typename T>
│ │ │ │ -
│ │ │ │ -
433 int allgather(const T* sbuf, int count, T* rbuf) const
│ │ │ │ -
434 {
│ │ │ │ -
435 for(const T* end=sbuf+count; sbuf < end; ++sbuf, ++rbuf)
│ │ │ │ -
436 *rbuf=*sbuf;
│ │ │ │ -
437 return 0;
│ │ │ │ -
438 }
│ │ │ │ -
│ │ │ │ -
439
│ │ │ │ -
444 template<class TIN, class TOUT = TIN>
│ │ │ │ -
│ │ │ │ -
445 PseudoFuture<TOUT> iallgather(TIN&& data_in, TOUT&& data_out){
│ │ │ │ -
446 return {std::forward<TOUT>(data_out)};
│ │ │ │ -
447 }
│ │ │ │ -
│ │ │ │ -
448
│ │ │ │ -
465 template<typename T>
│ │ │ │ -
│ │ │ │ -
466 int allgatherv (const T* in, int sendDataLen, T* out, [[maybe_unused]] int* recvDataLen, int* displ) const
│ │ │ │ -
467 {
│ │ │ │ -
468 for (int i=*displ; i<sendDataLen; i++)
│ │ │ │ -
469 out[i] = in[i];
│ │ │ │ -
470 return 0;
│ │ │ │ -
471 }
│ │ │ │ -
│ │ │ │ -
472
│ │ │ │ -
485 template<typename BinaryFunction, typename Type>
│ │ │ │ -
│ │ │ │ -
486 int allreduce([[maybe_unused]] Type* inout, [[maybe_unused]] int len) const
│ │ │ │ -
487 {
│ │ │ │ -
488 return 0;
│ │ │ │ -
489 }
│ │ │ │ -
│ │ │ │ -
490
│ │ │ │ -
495 template<class BinaryFunction, class TIN, class TOUT = TIN>
│ │ │ │ -
│ │ │ │ -
496 PseudoFuture<TOUT> iallreduce(TIN&& data_in, TOUT&& data_out){
│ │ │ │ -
497 data_out = std::forward<TIN>(data_in);
│ │ │ │ -
498 return {std::forward<TOUT>(data_out)};
│ │ │ │ -
499 }
│ │ │ │ -
│ │ │ │ -
500
│ │ │ │ -
505 template<class BinaryFunction, class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
507 return {std::forward<T>(data)};
│ │ │ │ -
508 }
│ │ │ │ -
│ │ │ │ -
509
│ │ │ │ -
510
│ │ │ │ -
524 template<typename BinaryFunction, typename Type>
│ │ │ │ -
│ │ │ │ -
525 int allreduce(const Type* in, Type* out, int len) const
│ │ │ │ -
526 {
│ │ │ │ -
527 std::copy(in, in+len, out);
│ │ │ │ -
528 return 0;
│ │ │ │ -
529 }
│ │ │ │ -
│ │ │ │ -
530
│ │ │ │ -
531 };
│ │ │ │ -
│ │ │ │ -
532
│ │ │ │ -
538 template<class T>
│ │ │ │ - │ │ │ │ -
540 [[deprecated("CollectiveCommunication is deprecated. Use Communication instead.")]]
│ │ │ │ - │ │ │ │ -
542}
│ │ │ │ -
543
│ │ │ │ -
544#endif // DUNE_COMMON_PARALLEL_COMMUNICATION_HH
│ │ │ │ - │ │ │ │ -
helper classes to provide unique types for standard functions
│ │ │ │ -
A few common exception classes.
│ │ │ │ -
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition iteratorfacades.hh:238
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition iteratorfacades.hh:260
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
71 {
│ │ │ │ +
72 static T instance_;
│ │ │ │ +
73 return instance_;
│ │ │ │ +
74 }
│ │ │ │ +
│ │ │ │ +
75 };
│ │ │ │ +
│ │ │ │ +
76
│ │ │ │ +
77} // namespace Dune
│ │ │ │ +
78
│ │ │ │ +
79#endif
│ │ │ │ +
Definition of macros controlling symbol visibility at the ABI level.
│ │ │ │ +
#define DUNE_EXPORT
Export a symbol as part of the public ABI.
Definition visibility.hh:20
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Default exception if an error in the parallel communication of the program occurred.
Definition exceptions.hh:287
│ │ │ │ -
Definition communication.hh:46
│ │ │ │ -
Collective communication interface and sequential default implementation.
Definition communication.hh:100
│ │ │ │ -
PseudoFuture< TOUT > iallreduce(TIN &&data_in, TOUT &&data_out)
Compute something over all processes nonblocking.
Definition communication.hh:496
│ │ │ │ -
int send(const T &data, int dest_rank, int tag)
Sends the data to the dest_rank.
Definition communication.hh:135
│ │ │ │ -
int allreduce(const Type *in, Type *out, int len) const
Compute something over all processes for each component of an array and return the result in every pr...
Definition communication.hh:525
│ │ │ │ -
T max(const T &in) const
Compute the maximum of the argument over all processes and return the result in every process....
Definition communication.hh:248
│ │ │ │ -
int rank() const
Return rank, is between 0 and size()-1.
Definition communication.hh:114
│ │ │ │ -
T sum(const T &in) const
Compute the sum of the argument over all processes and return the result in every process....
Definition communication.hh:188
│ │ │ │ -
int scatterv(const T *sendData, int *sendDataLen, int *displ, T *recvData, int recvDataLen, int root) const
Scatter arrays of variable length from a root to all other tasks.
Definition communication.hh:411
│ │ │ │ -
int prod(T *inout, int len) const
Compute the product over all processes for each component of an array and return the result in every ...
Definition communication.hh:219
│ │ │ │ -
T recv(T &&data, int source_rank, int tag, void *status=0)
Receives the data from the source_rank.
Definition communication.hh:157
│ │ │ │ -
PseudoFuture< T > isend(const T &&data, int dest_rank, int tag)
Sends the data to the dest_rank nonblocking.
Definition communication.hh:146
│ │ │ │ -
PseudoFuture< void > ibarrier() const
Nonblocking barrier.
Definition communication.hh:275
│ │ │ │ -
int allreduce(Type *inout, int len) const
Compute something over all processes for each component of an array and return the result in every pr...
Definition communication.hh:486
│ │ │ │ -
int size() const
Number of processes in set, is greater than 0.
Definition communication.hh:126
│ │ │ │ -
int sum(T *inout, int len) const
Compute the sum over all processes for each component of an array and return the result in every proc...
Definition communication.hh:199
│ │ │ │ -
int allgatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int *displ) const
Gathers data of variable length from all tasks and distribute it to all.
Definition communication.hh:466
│ │ │ │ -
T min(const T &in) const
Compute the minimum of the argument over all processes and return the result in every process....
Definition communication.hh:228
│ │ │ │ -
PseudoFuture< T > irecv(T &&data, int source_rank, int tag)
Receives the data from the source_rank nonblocking.
Definition communication.hh:169
│ │ │ │ -
int gatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int *displ, int root) const
Gather arrays of variable size on root task.
Definition communication.hh:350
│ │ │ │ -
PseudoFuture< T > ibroadcast(T &&data, int root) const
Distribute an array from the process with rank root to all other processes nonblocking.
Definition communication.hh:295
│ │ │ │ -
int allgather(const T *sbuf, int count, T *rbuf) const
Gathers data from all tasks and distribute it to all.
Definition communication.hh:433
│ │ │ │ -
int scatter(const T *sendData, T *recvData, int len, int root) const
Scatter array from a root to all other task.
Definition communication.hh:376
│ │ │ │ -
int gather(const T *in, T *out, int len, int root) const
Gather arrays on root task.
Definition communication.hh:313
│ │ │ │ -
PseudoFuture< T > iallreduce(T &&data)
Compute something over all processes nonblocking and in-place.
Definition communication.hh:506
│ │ │ │ -
Communication(const Communicator &)
Constructor with a given communicator.
Definition communication.hh:110
│ │ │ │ -
int max(T *inout, int len) const
Compute the maximum over all processes for each component of an array and return the result in every ...
Definition communication.hh:259
│ │ │ │ -
T prod(const T &in) const
Compute the product of the argument over all processes and return the result in every process....
Definition communication.hh:208
│ │ │ │ -
int broadcast(T *inout, int len, int root) const
Distribute an array from the process with rank root to all other processes.
Definition communication.hh:284
│ │ │ │ -
T rrecv(T &&data, int source_rank, int tag, void *status=0) const
Definition communication.hh:177
│ │ │ │ -
PseudoFuture< TOUT > iscatter(TIN &&data_in, TOUT &&data_out, int root)
Scatter array from a root to all other task nonblocking.
Definition communication.hh:387
│ │ │ │ -
int min(T *inout, int len) const
Compute the minimum over all processes for each component of an array and return the result in every ...
Definition communication.hh:239
│ │ │ │ -
int barrier() const
Wait until all processes have arrived at this point in the program.
Definition communication.hh:267
│ │ │ │ -
PseudoFuture< TOUT > igather(TIN &&data_in, TOUT &&data_out, int root)
Gather arrays on root task nonblocking.
Definition communication.hh:324
│ │ │ │ -
PseudoFuture< TOUT > iallgather(TIN &&data_in, TOUT &&data_out)
Gathers data from all tasks and distribute it to all nonblocking.
Definition communication.hh:445
│ │ │ │ -
Communication()
Construct default object.
Definition communication.hh:103
│ │ │ │ -
A wrapper-class for a object which is ready immediately.
Definition future.hh:124
│ │ │ │ +
An adapter to turn a class into a singleton.
Definition singleton.hh:56
│ │ │ │ +
Singleton()=default
│ │ │ │ +
Singleton(const Singleton &)=delete
│ │ │ │ +
void operator=(const Singleton &)=delete
│ │ │ │ +
static DUNE_EXPORT T & instance()
Get the instance of the singleton.
Definition singleton.hh:70
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,480 +1,66 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -communication.hh │ │ │ │ │ +singleton.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PARALLEL_COMMUNICATION_HH │ │ │ │ │ -6#define DUNE_COMMON_PARALLEL_COMMUNICATION_HH │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18 │ │ │ │ │ -19#include │ │ │ │ │ -20#include │ │ │ │ │ -21#include │ │ │ │ │ -22 │ │ │ │ │ -42namespace Dune │ │ │ │ │ -43{ │ │ │ │ │ -44 │ │ │ │ │ -45 /* define some type that definitely differs from MPI_Comm */ │ │ │ │ │ -46 struct No_Comm {}; │ │ │ │ │ -47 │ │ │ │ │ -52 inline bool operator==(const No_Comm&, const No_Comm&) │ │ │ │ │ -53 { │ │ │ │ │ -54 return true; │ │ │ │ │ -55 } │ │ │ │ │ -56 │ │ │ │ │ -61 inline bool operator!=(const No_Comm&, const No_Comm&) │ │ │ │ │ -62 { │ │ │ │ │ -63 return false; │ │ │ │ │ -64 } │ │ │ │ │ +5#ifndef DUNE_SINGLETON_HH │ │ │ │ │ +6#define DUNE_SINGLETON_HH │ │ │ │ │ +7 │ │ │ │ │ +8#include │ │ │ │ │ +9 │ │ │ │ │ +17namespace Dune │ │ │ │ │ +18{ │ │ │ │ │ +54 template │ │ │ │ │ +55 class Singleton │ │ │ │ │ +56 { │ │ │ │ │ +57 protected: │ │ │ │ │ +58 /* @brief Protected constructor. */ │ │ │ │ │ +59 Singleton() = default; │ │ │ │ │ +60 │ │ │ │ │ +61 public: │ │ │ │ │ +62 │ │ │ │ │ +63 Singleton(const Singleton&) = delete; │ │ │ │ │ +64 void operator=(const Singleton&) = delete; │ │ │ │ │ 65 │ │ │ │ │ -98 template │ │ │ │ │ -99 class Communication │ │ │ │ │ -100 { │ │ │ │ │ -101 public: │ │ │ │ │ -103 Communication() │ │ │ │ │ -104 {} │ │ │ │ │ -105 │ │ │ │ │ -110 Communication (const Communicator&) │ │ │ │ │ -111 {} │ │ │ │ │ -112 │ │ │ │ │ -114 int rank () const │ │ │ │ │ -115 { │ │ │ │ │ -116 return 0; │ │ │ │ │ -117 } │ │ │ │ │ -118 │ │ │ │ │ -120 operator No_Comm() const │ │ │ │ │ -121 { │ │ │ │ │ -122 return {}; │ │ │ │ │ -123 } │ │ │ │ │ -124 │ │ │ │ │ -126 int size () const │ │ │ │ │ -127 { │ │ │ │ │ -128 return 1; │ │ │ │ │ -129 } │ │ │ │ │ -130 │ │ │ │ │ -134 template │ │ │ │ │ -135 int send([[maybe_unused]] const T& data, │ │ │ │ │ -136 [[maybe_unused]] int dest_rank, │ │ │ │ │ -137 [[maybe_unused]] int tag) │ │ │ │ │ -138 { │ │ │ │ │ -139 DUNE_THROW(ParallelError, "This method is not supported in sequential │ │ │ │ │ -programs"); │ │ │ │ │ -140 } │ │ │ │ │ -141 │ │ │ │ │ -145 template │ │ │ │ │ -146 PseudoFuture isend([[maybe_unused]] const T&& data, │ │ │ │ │ -147 [[maybe_unused]] int dest_rank, │ │ │ │ │ -148 [[maybe_unused]] int tag) │ │ │ │ │ -149 { │ │ │ │ │ -150 DUNE_THROW(ParallelError, "This method is not supported in sequential │ │ │ │ │ -programs"); │ │ │ │ │ -151 } │ │ │ │ │ -152 │ │ │ │ │ -156 template │ │ │ │ │ -157 T recv([[maybe_unused]] T&& data, │ │ │ │ │ -158 [[maybe_unused]] int source_rank, │ │ │ │ │ -159 [[maybe_unused]] int tag, │ │ │ │ │ -160 [[maybe_unused]] void* status = 0) │ │ │ │ │ -161 { │ │ │ │ │ -162 DUNE_THROW(ParallelError, "This method is not supported in sequential │ │ │ │ │ -programs"); │ │ │ │ │ -163 } │ │ │ │ │ -164 │ │ │ │ │ -168 template │ │ │ │ │ -169 PseudoFuture irecv([[maybe_unused]] T&& data, │ │ │ │ │ -170 [[maybe_unused]] int source_rank, │ │ │ │ │ -171 [[maybe_unused]] int tag) │ │ │ │ │ -172 { │ │ │ │ │ -173 DUNE_THROW(ParallelError, "This method is not supported in sequential │ │ │ │ │ -programs"); │ │ │ │ │ -174 } │ │ │ │ │ -175 │ │ │ │ │ -176 template │ │ │ │ │ -177 T rrecv([[maybe_unused]] T&& data, │ │ │ │ │ -178 [[maybe_unused]] int source_rank, │ │ │ │ │ -179 [[maybe_unused]] int tag, │ │ │ │ │ -180 [[maybe_unused]] void* status = 0) const │ │ │ │ │ -181 { │ │ │ │ │ -182 DUNE_THROW(ParallelError, "This method is not supported in sequential │ │ │ │ │ -programs"); │ │ │ │ │ -183 } │ │ │ │ │ -187 template │ │ │ │ │ -188 T sum (const T& in) const │ │ │ │ │ -189 { │ │ │ │ │ -190 return in; │ │ │ │ │ -191 } │ │ │ │ │ -192 │ │ │ │ │ -198 template │ │ │ │ │ -199 int sum ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const │ │ │ │ │ -200 { │ │ │ │ │ -201 return 0; │ │ │ │ │ -202 } │ │ │ │ │ -203 │ │ │ │ │ -207 template │ │ │ │ │ -208 T prod (const T& in) const │ │ │ │ │ -209 { │ │ │ │ │ -210 return in; │ │ │ │ │ -211 } │ │ │ │ │ -212 │ │ │ │ │ -218 template │ │ │ │ │ -219 int prod ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const │ │ │ │ │ -220 { │ │ │ │ │ -221 return 0; │ │ │ │ │ -222 } │ │ │ │ │ -223 │ │ │ │ │ -227 template │ │ │ │ │ -228 T min (const T& in) const │ │ │ │ │ -229 { │ │ │ │ │ -230 return in; │ │ │ │ │ -231 } │ │ │ │ │ -232 │ │ │ │ │ -238 template │ │ │ │ │ -239 int min ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const │ │ │ │ │ -240 { │ │ │ │ │ -241 return 0; │ │ │ │ │ -242 } │ │ │ │ │ -243 │ │ │ │ │ -247 template │ │ │ │ │ -248 T max (const T& in) const │ │ │ │ │ -249 { │ │ │ │ │ -250 return in; │ │ │ │ │ -251 } │ │ │ │ │ -252 │ │ │ │ │ -258 template │ │ │ │ │ -259 int max ([[maybe_unused]] T* inout, [[maybe_unused]] int len) const │ │ │ │ │ -260 { │ │ │ │ │ -261 return 0; │ │ │ │ │ -262 } │ │ │ │ │ -263 │ │ │ │ │ -267 int barrier () const │ │ │ │ │ -268 { │ │ │ │ │ -269 return 0; │ │ │ │ │ -270 } │ │ │ │ │ -271 │ │ │ │ │ -275 PseudoFuture ibarrier () const │ │ │ │ │ -276 { │ │ │ │ │ -277 return {true}; // return a valid future │ │ │ │ │ -278 } │ │ │ │ │ -279 │ │ │ │ │ -283 template │ │ │ │ │ -284 int broadcast ([[maybe_unused]] T* inout, │ │ │ │ │ -285 [[maybe_unused]] int len, │ │ │ │ │ -286 [[maybe_unused]] int root) const │ │ │ │ │ -287 { │ │ │ │ │ -288 return 0; │ │ │ │ │ -289 } │ │ │ │ │ -290 │ │ │ │ │ -294 template │ │ │ │ │ -295 PseudoFuture ibroadcast(T&& data, int root) const{ │ │ │ │ │ -296 return {std::forward(data)}; │ │ │ │ │ -297 } │ │ │ │ │ -298 │ │ │ │ │ -299 │ │ │ │ │ -312 template │ │ │ │ │ -313 int gather (const T* in, T* out, int len, [[maybe_unused]] int root) const │ │ │ │ │ -// note out must have same size as in │ │ │ │ │ -314 { │ │ │ │ │ -315 for (int i=0; i> │ │ │ │ │ -324 PseudoFuture igather(TIN&& data_in, TOUT&& data_out, int root){ │ │ │ │ │ -325 *(data_out.begin()) = std::forward(data_in); │ │ │ │ │ -326 return {std::forward(data_out)}; │ │ │ │ │ -327 } │ │ │ │ │ -328 │ │ │ │ │ -329 │ │ │ │ │ -349 template │ │ │ │ │ -350 int gatherv (const T* in, │ │ │ │ │ -351 int sendDataLen, │ │ │ │ │ -352 T* out, │ │ │ │ │ -353 [[maybe_unused]] int* recvDataLen, │ │ │ │ │ -354 int* displ, │ │ │ │ │ -355 [[maybe_unused]] int root) const │ │ │ │ │ -356 { │ │ │ │ │ -357 for (int i=*displ; i │ │ │ │ │ -376 int scatter (const T* sendData, T* recvData, int len, [[maybe_unused]] int │ │ │ │ │ -root) const // note out must have same size as in │ │ │ │ │ -377 { │ │ │ │ │ -378 for (int i=0; i │ │ │ │ │ -387 PseudoFuture iscatter(TIN&& data_in, TOUT&& data_out, int root){ │ │ │ │ │ -388 data_out = *(std::forward(data_in).begin()); │ │ │ │ │ -389 return {std::forward(data_out)}; │ │ │ │ │ -390 } │ │ │ │ │ -391 │ │ │ │ │ -410 template │ │ │ │ │ -411 int scatterv (const T* sendData,int* sendDataLen, int* displ, T* recvData, │ │ │ │ │ -412 [[maybe_unused]] int recvDataLen, [[maybe_unused]] int root) const │ │ │ │ │ -413 { │ │ │ │ │ -414 for (int i=*displ; i<*sendDataLen; i++) │ │ │ │ │ -415 recvData[i] = sendData[i]; │ │ │ │ │ -416 return 0; │ │ │ │ │ -417 } │ │ │ │ │ -418 │ │ │ │ │ -432 template │ │ │ │ │ -433 int allgather(const T* sbuf, int count, T* rbuf) const │ │ │ │ │ -434 { │ │ │ │ │ -435 for(const T* end=sbuf+count; sbuf < end; ++sbuf, ++rbuf) │ │ │ │ │ -436 *rbuf=*sbuf; │ │ │ │ │ -437 return 0; │ │ │ │ │ -438 } │ │ │ │ │ -439 │ │ │ │ │ -444 template │ │ │ │ │ -445 PseudoFuture iallgather(TIN&& data_in, TOUT&& data_out){ │ │ │ │ │ -446 return {std::forward(data_out)}; │ │ │ │ │ -447 } │ │ │ │ │ -448 │ │ │ │ │ -465 template │ │ │ │ │ -466 int allgatherv (const T* in, int sendDataLen, T* out, [[maybe_unused]] int* │ │ │ │ │ -recvDataLen, int* displ) const │ │ │ │ │ -467 { │ │ │ │ │ -468 for (int i=*displ; i │ │ │ │ │ -486 int allreduce([[maybe_unused]] Type* inout, [[maybe_unused]] int len) const │ │ │ │ │ -487 { │ │ │ │ │ -488 return 0; │ │ │ │ │ -489 } │ │ │ │ │ -490 │ │ │ │ │ -495 template │ │ │ │ │ -496 PseudoFuture iallreduce(TIN&& data_in, TOUT&& data_out){ │ │ │ │ │ -497 data_out = std::forward(data_in); │ │ │ │ │ -498 return {std::forward(data_out)}; │ │ │ │ │ -499 } │ │ │ │ │ -500 │ │ │ │ │ -505 template │ │ │ │ │ -506 PseudoFuture iallreduce(T&& data){ │ │ │ │ │ -507 return {std::forward(data)}; │ │ │ │ │ -508 } │ │ │ │ │ -509 │ │ │ │ │ -510 │ │ │ │ │ -524 template │ │ │ │ │ -525 int allreduce(const Type* in, Type* out, int len) const │ │ │ │ │ -526 { │ │ │ │ │ -527 std::copy(in, in+len, out); │ │ │ │ │ -528 return 0; │ │ │ │ │ -529 } │ │ │ │ │ -530 │ │ │ │ │ -531 }; │ │ │ │ │ -532 │ │ │ │ │ -538 template │ │ │ │ │ -539 using CollectiveCommunication │ │ │ │ │ -540 [[deprecated("CollectiveCommunication is deprecated. Use Communication │ │ │ │ │ -instead.")]] │ │ │ │ │ -541 = Communication; │ │ │ │ │ -542} │ │ │ │ │ -543 │ │ │ │ │ -544#endif // DUNE_COMMON_PARALLEL_COMMUNICATION_HH │ │ │ │ │ -future.hh │ │ │ │ │ -binaryfunctions.hh │ │ │ │ │ -helper classes to provide unique types for standard functions │ │ │ │ │ -exceptions.hh │ │ │ │ │ -A few common exception classes. │ │ │ │ │ -DUNE_THROW │ │ │ │ │ -#define DUNE_THROW(E, m) │ │ │ │ │ -Definition exceptions.hh:218 │ │ │ │ │ -Dune::operator== │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator==(const │ │ │ │ │ -ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, │ │ │ │ │ -V2, R2, D > &rhs) │ │ │ │ │ -Checks for equality. │ │ │ │ │ -Definition iteratorfacades.hh:238 │ │ │ │ │ -Dune::operator!= │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator!=(const │ │ │ │ │ -ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, │ │ │ │ │ -V2, R2, D > &rhs) │ │ │ │ │ -Checks for inequality. │ │ │ │ │ -Definition iteratorfacades.hh:260 │ │ │ │ │ +70 DUNE_EXPORT static T& instance() │ │ │ │ │ +71 { │ │ │ │ │ +72 static T instance_; │ │ │ │ │ +73 return instance_; │ │ │ │ │ +74 } │ │ │ │ │ +75 }; │ │ │ │ │ +76 │ │ │ │ │ +77} // namespace Dune │ │ │ │ │ +78 │ │ │ │ │ +79#endif │ │ │ │ │ +visibility.hh │ │ │ │ │ +Definition of macros controlling symbol visibility at the ABI level. │ │ │ │ │ +DUNE_EXPORT │ │ │ │ │ +#define DUNE_EXPORT │ │ │ │ │ +Export a symbol as part of the public ABI. │ │ │ │ │ +Definition visibility.hh:20 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::ParallelError │ │ │ │ │ -Default exception if an error in the parallel communication of the program │ │ │ │ │ -occurred. │ │ │ │ │ -Definition exceptions.hh:287 │ │ │ │ │ -Dune::No_Comm │ │ │ │ │ -Definition communication.hh:46 │ │ │ │ │ -Dune::Communication │ │ │ │ │ -Collective communication interface and sequential default implementation. │ │ │ │ │ -Definition communication.hh:100 │ │ │ │ │ -Dune::Communication::iallreduce │ │ │ │ │ -PseudoFuture< TOUT > iallreduce(TIN &&data_in, TOUT &&data_out) │ │ │ │ │ -Compute something over all processes nonblocking. │ │ │ │ │ -Definition communication.hh:496 │ │ │ │ │ -Dune::Communication::send │ │ │ │ │ -int send(const T &data, int dest_rank, int tag) │ │ │ │ │ -Sends the data to the dest_rank. │ │ │ │ │ -Definition communication.hh:135 │ │ │ │ │ -Dune::Communication::allreduce │ │ │ │ │ -int allreduce(const Type *in, Type *out, int len) const │ │ │ │ │ -Compute something over all processes for each component of an array and return │ │ │ │ │ -the result in every pr... │ │ │ │ │ -Definition communication.hh:525 │ │ │ │ │ -Dune::Communication::max │ │ │ │ │ -T max(const T &in) const │ │ │ │ │ -Compute the maximum of the argument over all processes and return the result in │ │ │ │ │ -every process.... │ │ │ │ │ -Definition communication.hh:248 │ │ │ │ │ -Dune::Communication::rank │ │ │ │ │ -int rank() const │ │ │ │ │ -Return rank, is between 0 and size()-1. │ │ │ │ │ -Definition communication.hh:114 │ │ │ │ │ -Dune::Communication::sum │ │ │ │ │ -T sum(const T &in) const │ │ │ │ │ -Compute the sum of the argument over all processes and return the result in │ │ │ │ │ -every process.... │ │ │ │ │ -Definition communication.hh:188 │ │ │ │ │ -Dune::Communication::scatterv │ │ │ │ │ -int scatterv(const T *sendData, int *sendDataLen, int *displ, T *recvData, int │ │ │ │ │ -recvDataLen, int root) const │ │ │ │ │ -Scatter arrays of variable length from a root to all other tasks. │ │ │ │ │ -Definition communication.hh:411 │ │ │ │ │ -Dune::Communication::prod │ │ │ │ │ -int prod(T *inout, int len) const │ │ │ │ │ -Compute the product over all processes for each component of an array and │ │ │ │ │ -return the result in every ... │ │ │ │ │ -Definition communication.hh:219 │ │ │ │ │ -Dune::Communication::recv │ │ │ │ │ -T recv(T &&data, int source_rank, int tag, void *status=0) │ │ │ │ │ -Receives the data from the source_rank. │ │ │ │ │ -Definition communication.hh:157 │ │ │ │ │ -Dune::Communication::isend │ │ │ │ │ -PseudoFuture< T > isend(const T &&data, int dest_rank, int tag) │ │ │ │ │ -Sends the data to the dest_rank nonblocking. │ │ │ │ │ -Definition communication.hh:146 │ │ │ │ │ -Dune::Communication::ibarrier │ │ │ │ │ -PseudoFuture< void > ibarrier() const │ │ │ │ │ -Nonblocking barrier. │ │ │ │ │ -Definition communication.hh:275 │ │ │ │ │ -Dune::Communication::allreduce │ │ │ │ │ -int allreduce(Type *inout, int len) const │ │ │ │ │ -Compute something over all processes for each component of an array and return │ │ │ │ │ -the result in every pr... │ │ │ │ │ -Definition communication.hh:486 │ │ │ │ │ -Dune::Communication::size │ │ │ │ │ -int size() const │ │ │ │ │ -Number of processes in set, is greater than 0. │ │ │ │ │ -Definition communication.hh:126 │ │ │ │ │ -Dune::Communication::sum │ │ │ │ │ -int sum(T *inout, int len) const │ │ │ │ │ -Compute the sum over all processes for each component of an array and return │ │ │ │ │ -the result in every proc... │ │ │ │ │ -Definition communication.hh:199 │ │ │ │ │ -Dune::Communication::allgatherv │ │ │ │ │ -int allgatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int │ │ │ │ │ -*displ) const │ │ │ │ │ -Gathers data of variable length from all tasks and distribute it to all. │ │ │ │ │ -Definition communication.hh:466 │ │ │ │ │ -Dune::Communication::min │ │ │ │ │ -T min(const T &in) const │ │ │ │ │ -Compute the minimum of the argument over all processes and return the result in │ │ │ │ │ -every process.... │ │ │ │ │ -Definition communication.hh:228 │ │ │ │ │ -Dune::Communication::irecv │ │ │ │ │ -PseudoFuture< T > irecv(T &&data, int source_rank, int tag) │ │ │ │ │ -Receives the data from the source_rank nonblocking. │ │ │ │ │ -Definition communication.hh:169 │ │ │ │ │ -Dune::Communication::gatherv │ │ │ │ │ -int gatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int *displ, │ │ │ │ │ -int root) const │ │ │ │ │ -Gather arrays of variable size on root task. │ │ │ │ │ -Definition communication.hh:350 │ │ │ │ │ -Dune::Communication::ibroadcast │ │ │ │ │ -PseudoFuture< T > ibroadcast(T &&data, int root) const │ │ │ │ │ -Distribute an array from the process with rank root to all other processes │ │ │ │ │ -nonblocking. │ │ │ │ │ -Definition communication.hh:295 │ │ │ │ │ -Dune::Communication::allgather │ │ │ │ │ -int allgather(const T *sbuf, int count, T *rbuf) const │ │ │ │ │ -Gathers data from all tasks and distribute it to all. │ │ │ │ │ -Definition communication.hh:433 │ │ │ │ │ -Dune::Communication::scatter │ │ │ │ │ -int scatter(const T *sendData, T *recvData, int len, int root) const │ │ │ │ │ -Scatter array from a root to all other task. │ │ │ │ │ -Definition communication.hh:376 │ │ │ │ │ -Dune::Communication::gather │ │ │ │ │ -int gather(const T *in, T *out, int len, int root) const │ │ │ │ │ -Gather arrays on root task. │ │ │ │ │ -Definition communication.hh:313 │ │ │ │ │ -Dune::Communication::iallreduce │ │ │ │ │ -PseudoFuture< T > iallreduce(T &&data) │ │ │ │ │ -Compute something over all processes nonblocking and in-place. │ │ │ │ │ -Definition communication.hh:506 │ │ │ │ │ -Dune::Communication::Communication │ │ │ │ │ -Communication(const Communicator &) │ │ │ │ │ -Constructor with a given communicator. │ │ │ │ │ -Definition communication.hh:110 │ │ │ │ │ -Dune::Communication::max │ │ │ │ │ -int max(T *inout, int len) const │ │ │ │ │ -Compute the maximum over all processes for each component of an array and │ │ │ │ │ -return the result in every ... │ │ │ │ │ -Definition communication.hh:259 │ │ │ │ │ -Dune::Communication::prod │ │ │ │ │ -T prod(const T &in) const │ │ │ │ │ -Compute the product of the argument over all processes and return the result in │ │ │ │ │ -every process.... │ │ │ │ │ -Definition communication.hh:208 │ │ │ │ │ -Dune::Communication::broadcast │ │ │ │ │ -int broadcast(T *inout, int len, int root) const │ │ │ │ │ -Distribute an array from the process with rank root to all other processes. │ │ │ │ │ -Definition communication.hh:284 │ │ │ │ │ -Dune::Communication::rrecv │ │ │ │ │ -T rrecv(T &&data, int source_rank, int tag, void *status=0) const │ │ │ │ │ -Definition communication.hh:177 │ │ │ │ │ -Dune::Communication::iscatter │ │ │ │ │ -PseudoFuture< TOUT > iscatter(TIN &&data_in, TOUT &&data_out, int root) │ │ │ │ │ -Scatter array from a root to all other task nonblocking. │ │ │ │ │ -Definition communication.hh:387 │ │ │ │ │ -Dune::Communication::min │ │ │ │ │ -int min(T *inout, int len) const │ │ │ │ │ -Compute the minimum over all processes for each component of an array and │ │ │ │ │ -return the result in every ... │ │ │ │ │ -Definition communication.hh:239 │ │ │ │ │ -Dune::Communication::barrier │ │ │ │ │ -int barrier() const │ │ │ │ │ -Wait until all processes have arrived at this point in the program. │ │ │ │ │ -Definition communication.hh:267 │ │ │ │ │ -Dune::Communication::igather │ │ │ │ │ -PseudoFuture< TOUT > igather(TIN &&data_in, TOUT &&data_out, int root) │ │ │ │ │ -Gather arrays on root task nonblocking. │ │ │ │ │ -Definition communication.hh:324 │ │ │ │ │ -Dune::Communication::iallgather │ │ │ │ │ -PseudoFuture< TOUT > iallgather(TIN &&data_in, TOUT &&data_out) │ │ │ │ │ -Gathers data from all tasks and distribute it to all nonblocking. │ │ │ │ │ -Definition communication.hh:445 │ │ │ │ │ -Dune::Communication::Communication │ │ │ │ │ -Communication() │ │ │ │ │ -Construct default object. │ │ │ │ │ -Definition communication.hh:103 │ │ │ │ │ -Dune::PseudoFuture │ │ │ │ │ -A wrapper-class for a object which is ready immediately. │ │ │ │ │ -Definition future.hh:124 │ │ │ │ │ +Dune::Singleton │ │ │ │ │ +An adapter to turn a class into a singleton. │ │ │ │ │ +Definition singleton.hh:56 │ │ │ │ │ +Dune::Singleton::Singleton │ │ │ │ │ +Singleton()=default │ │ │ │ │ +Dune::Singleton::Singleton │ │ │ │ │ +Singleton(const Singleton &)=delete │ │ │ │ │ +Dune::Singleton::operator= │ │ │ │ │ +void operator=(const Singleton &)=delete │ │ │ │ │ +Dune::Singleton::instance │ │ │ │ │ +static DUNE_EXPORT T & instance() │ │ │ │ │ +Get the instance of the singleton. │ │ │ │ │ +Definition singleton.hh:70 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00065.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: plocalindex.hh File Reference │ │ │ │ +dune-common: path.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,68 +65,61 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ Namespaces | │ │ │ │ Functions
│ │ │ │ - │ │ │ │ +
path.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

Provides classes for use as the local index in ParallelIndexSet for distributed computing. │ │ │ │ +

Utilities for handling filesystem paths. │ │ │ │ More...

│ │ │ │ -
#include <iostream>
│ │ │ │ -#include <mpi.h>
│ │ │ │ -#include <dune/common/parallel/indexset.hh>
│ │ │ │ -#include <dune/common/parallel/localindex.hh>
│ │ │ │ -#include <dune/common/parallel/mpitraits.hh>
│ │ │ │ +
#include <string>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

class  Dune::ParallelLocalIndex< T >
 An index present on the local process with an additional attribute flag. More...
 
struct  Dune::LocalIndexComparator< ParallelLocalIndex< T > >
 
class  Dune::MPITraits< ParallelLocalIndex< T > >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

template<class T >
std::ostream & Dune::operator<< (std::ostream &os, const ParallelLocalIndex< T > &index)
 Print the local index to a stream.
 
template<typename T >
bool Dune::operator== (const ParallelLocalIndex< T > &p1, const ParallelLocalIndex< T > &p2)
 
template<typename T >
bool Dune::operator!= (const ParallelLocalIndex< T > &p1, const ParallelLocalIndex< T > &p2)
 
std::string Dune::concatPaths (const std::string &base, const std::string &p)
 concatenate two paths
 
std::string Dune::processPath (const std::string &p)
 sanitize a path for further processing
 
bool Dune::pathIndicatesDirectory (const std::string &p)
 check whether the given path indicates that it is a directory
 
std::string Dune::prettyPath (const std::string &p, bool isDirectory)
 pretty print path
 
std::string Dune::prettyPath (const std::string &p)
 pretty print path
 
std::string Dune::relativePath (const std::string &newbase, const std::string &p)
 compute a relative path between two paths
 
│ │ │ │

Detailed Description

│ │ │ │ -

Provides classes for use as the local index in ParallelIndexSet for distributed computing.

│ │ │ │ -
Author
Markus Blatt
│ │ │ │ +

Utilities for handling filesystem paths.

│ │ │ │ +
Author
Jö Fahlke jorri.nosp@m.t@jo.nosp@m.rrit..nosp@m.de
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── encoding │ │ │ │ │ @@ -1 +1 @@ │ │ │ │ │ -us-ascii │ │ │ │ │ +utf-8 │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,52 +1,42 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -plocalindex.hh File Reference │ │ │ │ │ -Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ -Provides classes for use as the local index in ParallelIndexSet for distributed │ │ │ │ │ -computing. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +path.hh File Reference │ │ │ │ │ +Common » Utilities » Filesystem_Paths │ │ │ │ │ +Utilities for handling filesystem paths. More... │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ -Classes │ │ │ │ │ - class   Dune::ParallelLocalIndex<_T_> │ │ │ │ │ -  An index present on the local process with an additional attribute │ │ │ │ │ - flag. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::LocalIndexComparator<_ParallelLocalIndex<_T_>_> │ │ │ │ │ -  │ │ │ │ │ - class   Dune::MPITraits<_ParallelLocalIndex<_T_>_> │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -std::ostream &  Dune::operator<< (std::ostream &os, const ParallelLocalIndex< T │ │ │ │ │ - > &index) │ │ │ │ │ -  Print the local index to a stream. │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::operator== (const ParallelLocalIndex< T > &p1, const │ │ │ │ │ - ParallelLocalIndex< T > &p2) │ │ │ │ │ -  │ │ │ │ │ -template │ │ │ │ │ - bool  Dune::operator!= (const ParallelLocalIndex< T > &p1, const │ │ │ │ │ - ParallelLocalIndex< T > &p2) │ │ │ │ │ +std::string  Dune::concatPaths (const std::string &base, const std::string &p) │ │ │ │ │ +  concatenate two paths │ │ │ │ │ +  │ │ │ │ │ +std::string  Dune::processPath (const std::string &p) │ │ │ │ │ +  sanitize a path for further processing │ │ │ │ │ +  │ │ │ │ │ + bool  Dune::pathIndicatesDirectory (const std::string &p) │ │ │ │ │ +  check whether the given path indicates that it is a directory │ │ │ │ │ +  │ │ │ │ │ +std::string  Dune::prettyPath (const std::string &p, bool isDirectory) │ │ │ │ │ +  pretty print path │ │ │ │ │ +  │ │ │ │ │ +std::string  Dune::prettyPath (const std::string &p) │ │ │ │ │ +  pretty print path │ │ │ │ │ +  │ │ │ │ │ +std::string  Dune::relativePath (const std::string &newbase, const std::string │ │ │ │ │ + &p) │ │ │ │ │ +  compute a relative path between two paths │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Provides classes for use as the local index in ParallelIndexSet for distributed │ │ │ │ │ -computing. │ │ │ │ │ +Utilities for handling filesystem paths. │ │ │ │ │ Author │ │ │ │ │ - Markus Blatt │ │ │ │ │ + Jö Fahlke jorri.nosp@m.t@jo.nosp@m.rrit..nosp@m.de │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00065_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: plocalindex.hh Source File │ │ │ │ +dune-common: path.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,309 +70,58 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
plocalindex.hh
│ │ │ │ +
path.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PARALLEL_PLOCALINDEX_HH
│ │ │ │ -
6#define DUNE_COMMON_PARALLEL_PLOCALINDEX_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_PATH_HH
│ │ │ │ +
6#define DUNE_COMMON_PATH_HH
│ │ │ │
7
│ │ │ │ -
8#include <iostream>
│ │ │ │ +
8#include <string>
│ │ │ │
9
│ │ │ │ -
10#if HAVE_MPI
│ │ │ │ -
11#include <mpi.h>
│ │ │ │ -
12#endif
│ │ │ │ -
13
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
17
│ │ │ │ -
18namespace Dune
│ │ │ │ -
19{
│ │ │ │ -
20
│ │ │ │ -
21
│ │ │ │ -
32 template<class T> class ParallelLocalIndex;
│ │ │ │ -
33
│ │ │ │ -
39 template<class T>
│ │ │ │ -
│ │ │ │ -
40 std::ostream& operator<<(std::ostream& os, const ParallelLocalIndex<T>& index)
│ │ │ │ -
41 {
│ │ │ │ -
42 os<<"{local="<<index.localIndex_<<", attr="<<T(index.attribute_)<<", public="
│ │ │ │ -
43 <<(index.public_ ? true : false)<<"}";
│ │ │ │ -
44 return os;
│ │ │ │ -
45 }
│ │ │ │ -
│ │ │ │ -
46
│ │ │ │ -
50 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
52 {
│ │ │ │ -
53#if HAVE_MPI
│ │ │ │ -
54 // friend declaration needed for MPITraits
│ │ │ │ -
55 friend struct MPITraits<ParallelLocalIndex<T> >;
│ │ │ │ -
56#endif
│ │ │ │ -
57 friend std::ostream& operator<< <>(std::ostream& os, const ParallelLocalIndex<T>& index);
│ │ │ │ -
58
│ │ │ │ -
59 public:
│ │ │ │ -
67 typedef T Attribute;
│ │ │ │ - │ │ │ │ -
77
│ │ │ │ -
86 ParallelLocalIndex(size_t localIndex, const Attribute& attribute, bool isPublic=true);
│ │ │ │ - │ │ │ │ -
93
│ │ │ │ -
94#if 0
│ │ │ │ - │ │ │ │ -
105#endif
│ │ │ │ -
106
│ │ │ │ -
111 inline const Attribute attribute() const;
│ │ │ │ +
10namespace Dune {
│ │ │ │ +
23
│ │ │ │ +
51 std::string concatPaths(const std::string& base, const std::string& p);
│ │ │ │ +
52
│ │ │ │ +
54
│ │ │ │ +
98 std::string processPath(const std::string& p);
│ │ │ │ +
99
│ │ │ │ +
101
│ │ │ │ +
109 bool pathIndicatesDirectory(const std::string& p);
│ │ │ │ +
110
│ │ │ │
112
│ │ │ │ -
117 inline void setAttribute(const Attribute& attribute);
│ │ │ │ -
118
│ │ │ │ -
123 inline size_t local() const;
│ │ │ │ -
124
│ │ │ │ -
128 inline operator size_t() const;
│ │ │ │ -
129
│ │ │ │ -
135 inline ParallelLocalIndex<Attribute>& operator=(size_t index);
│ │ │ │ -
136
│ │ │ │ -
141 inline bool isPublic() const;
│ │ │ │ -
142
│ │ │ │ -
147 inline LocalIndexState state() const;
│ │ │ │ -
148
│ │ │ │ -
153 inline void setState(const LocalIndexState& state);
│ │ │ │ +
151 std::string prettyPath(const std::string& p, bool isDirectory);
│ │ │ │ +
152
│ │ │ │
154
│ │ │ │ -
155 private:
│ │ │ │ -
157 size_t localIndex_;
│ │ │ │ -
158
│ │ │ │ -
160 char attribute_;
│ │ │ │ +
160 std::string prettyPath(const std::string& p);
│ │ │ │
161
│ │ │ │ -
163 char public_;
│ │ │ │ -
164
│ │ │ │ -
171 char state_;
│ │ │ │ -
172
│ │ │ │ -
173 };
│ │ │ │ -
│ │ │ │ -
174
│ │ │ │ -
175 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
177 const ParallelLocalIndex<T>& p2)
│ │ │ │ -
178 {
│ │ │ │ -
179 if(p1.local()!=p2.local())
│ │ │ │ -
180 return false;
│ │ │ │ -
181 if(p1.attribute()!=p2.attribute())
│ │ │ │ -
182 return false;
│ │ │ │ -
183 if(p1.isPublic()!=p2.isPublic())
│ │ │ │ -
184 return false;
│ │ │ │ -
185 return true;
│ │ │ │ -
186 }
│ │ │ │ -
│ │ │ │ -
187 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
189 const ParallelLocalIndex<T>& p2)
│ │ │ │ -
190 {
│ │ │ │ -
191 return !(p1==p2);
│ │ │ │ -
192 }
│ │ │ │ -
│ │ │ │ -
193
│ │ │ │ -
194
│ │ │ │ -
195 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
197 {
│ │ │ │ -
│ │ │ │ -
198 static bool compare(const ParallelLocalIndex<T>& t1,
│ │ │ │ -
199 const ParallelLocalIndex<T>& t2){
│ │ │ │ -
200 return t1.attribute()<t2.attribute();
│ │ │ │ -
201 }
│ │ │ │ -
│ │ │ │ -
202 };
│ │ │ │ -
│ │ │ │ -
203
│ │ │ │ -
204
│ │ │ │ -
205#if HAVE_MPI
│ │ │ │ -
206
│ │ │ │ -
208 template<typename T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
210 {
│ │ │ │ -
211 public:
│ │ │ │ -
212 static MPI_Datatype getType();
│ │ │ │ -
213 private:
│ │ │ │ -
214 static MPI_Datatype type;
│ │ │ │ -
215
│ │ │ │ -
216 };
│ │ │ │ -
│ │ │ │ -
217
│ │ │ │ -
218#endif
│ │ │ │ -
219
│ │ │ │ -
220 template<class T>
│ │ │ │ -
│ │ │ │ -
221 ParallelLocalIndex<T>::ParallelLocalIndex(const T& attribute, bool isPublic)
│ │ │ │ -
222 : localIndex_(0), attribute_(static_cast<char>(attribute)),
│ │ │ │ -
223 public_(static_cast<char>(isPublic)), state_(static_cast<char>(VALID))
│ │ │ │ -
224 {}
│ │ │ │ -
│ │ │ │ -
225
│ │ │ │ -
226
│ │ │ │ -
227 template<class T>
│ │ │ │ -
│ │ │ │ -
228 ParallelLocalIndex<T>::ParallelLocalIndex(size_t local, const T& attribute, bool isPublic)
│ │ │ │ -
229 : localIndex_(local), attribute_(static_cast<char>(attribute)),
│ │ │ │ -
230 public_(static_cast<char>(isPublic)), state_(static_cast<char>(VALID))
│ │ │ │ -
231 {}
│ │ │ │ -
│ │ │ │ -
232
│ │ │ │ -
233 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
235 : localIndex_(0), attribute_(), public_(static_cast<char>(false)),
│ │ │ │ -
236 state_(static_cast<char>(VALID))
│ │ │ │ -
237 {}
│ │ │ │ -
│ │ │ │ -
238
│ │ │ │ -
239 template<class T>
│ │ │ │ -
│ │ │ │ -
240 inline const T ParallelLocalIndex<T>::attribute() const
│ │ │ │ -
241 {
│ │ │ │ -
242 return T(attribute_);
│ │ │ │ -
243 }
│ │ │ │ -
│ │ │ │ -
244
│ │ │ │ -
245 template<class T>
│ │ │ │ -
246 inline void
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
248 {
│ │ │ │ -
249 attribute_ = attribute;
│ │ │ │ -
250 }
│ │ │ │ -
│ │ │ │ -
251
│ │ │ │ -
252 template<class T>
│ │ │ │ -
│ │ │ │ -
253 inline size_t ParallelLocalIndex<T>::local() const
│ │ │ │ -
254 {
│ │ │ │ -
255 return localIndex_;
│ │ │ │ -
256 }
│ │ │ │ -
│ │ │ │ -
257
│ │ │ │ -
258 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
260 {
│ │ │ │ -
261 return localIndex_;
│ │ │ │ -
262 }
│ │ │ │ -
│ │ │ │ -
263
│ │ │ │ -
264 template<class T>
│ │ │ │ - │ │ │ │ -
│ │ │ │ - │ │ │ │ -
267 {
│ │ │ │ -
268 localIndex_=index;
│ │ │ │ -
269 return *this;
│ │ │ │ -
270 }
│ │ │ │ -
│ │ │ │ -
271
│ │ │ │ -
272 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
274 {
│ │ │ │ -
275 return static_cast<bool>(public_);
│ │ │ │ -
276 }
│ │ │ │ -
│ │ │ │ -
277
│ │ │ │ -
278 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
280 {
│ │ │ │ -
281 return LocalIndexState(state_);
│ │ │ │ -
282 }
│ │ │ │ -
│ │ │ │ -
283
│ │ │ │ -
284 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
286 {
│ │ │ │ -
287 state_=static_cast<char>(state);
│ │ │ │ -
288 }
│ │ │ │ -
│ │ │ │ -
289
│ │ │ │ -
290#if HAVE_MPI
│ │ │ │ -
291
│ │ │ │ -
292 template<typename T>
│ │ │ │ -
│ │ │ │ -
293 MPI_Datatype MPITraits<ParallelLocalIndex<T> >::getType()
│ │ │ │ -
294 {
│ │ │ │ -
295
│ │ │ │ -
296 if(type==MPI_DATATYPE_NULL) {
│ │ │ │ -
297 int length = 1;
│ │ │ │ -
298 MPI_Aint base, disp;
│ │ │ │ -
299 MPI_Datatype types[1] = {MPITraits<char>::getType()};
│ │ │ │ - │ │ │ │ -
301 MPI_Get_address(&rep, &base);
│ │ │ │ -
302 MPI_Get_address(&(rep.attribute_), &disp);
│ │ │ │ -
303 disp -= base;
│ │ │ │ -
304
│ │ │ │ -
305 MPI_Datatype tmp;
│ │ │ │ -
306 MPI_Type_create_struct(1, &length, &disp, types, &tmp);
│ │ │ │ -
307
│ │ │ │ -
308 MPI_Type_create_resized(tmp, 0, sizeof(ParallelLocalIndex<T>), &type);
│ │ │ │ -
309 MPI_Type_commit(&type);
│ │ │ │ -
310
│ │ │ │ -
311 MPI_Type_free(&tmp);
│ │ │ │ -
312 }
│ │ │ │ -
313 return type;
│ │ │ │ -
314 }
│ │ │ │ -
│ │ │ │ -
315
│ │ │ │ -
316 template<typename T>
│ │ │ │ -
317 MPI_Datatype MPITraits<ParallelLocalIndex<T> >::type = MPI_DATATYPE_NULL;
│ │ │ │ -
318
│ │ │ │ -
319#endif // HAVE_MPI
│ │ │ │ -
320
│ │ │ │ -
321
│ │ │ │ -
323} // namespace Dune
│ │ │ │ -
324
│ │ │ │ -
325#endif // DUNE_COMMON_PARALLEL_PLOCALINDEX_HH
│ │ │ │ -
Provides a map between global and local indices.
│ │ │ │ -
Provides classes for use as the local index in ParallelIndexSet.
│ │ │ │ -
Traits classes for mapping types onto MPI_Datatype.
│ │ │ │ -
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition bigunsignedint.hh:278
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition iteratorfacades.hh:238
│ │ │ │ -
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition iteratorfacades.hh:260
│ │ │ │ -
bool isPublic() const
Check whether the index might also be known other processes.
Definition plocalindex.hh:273
│ │ │ │ -
void setAttribute(const Attribute &attribute)
Set the attribute of the index.
Definition plocalindex.hh:247
│ │ │ │ -
size_t local() const
get the local index.
Definition plocalindex.hh:253
│ │ │ │ -
LocalIndexState
The states available for the local indices.
Definition localindex.hh:28
│ │ │ │ -
void setState(const LocalIndexState &state)
Set the state.
Definition plocalindex.hh:285
│ │ │ │ -
ParallelLocalIndex< Attribute > & operator=(size_t index)
Assign a new local index.
Definition plocalindex.hh:266
│ │ │ │ -
LocalIndexState state() const
Get the state.
Definition plocalindex.hh:279
│ │ │ │ -
ParallelLocalIndex()
Parameterless constructor.
Definition plocalindex.hh:234
│ │ │ │ -
const Attribute attribute() const
Get the attribute of the index.
Definition plocalindex.hh:240
│ │ │ │ -
@ VALID
Definition localindex.hh:28
│ │ │ │ +
163
│ │ │ │ +
179 std::string relativePath(const std::string& newbase, const std::string& p);
│ │ │ │ +
180
│ │ │ │ +
182}
│ │ │ │ +
183
│ │ │ │ +
184#endif // DUNE_COMMON_PATH_HH
│ │ │ │ +
std::string processPath(const std::string &p)
sanitize a path for further processing
Definition path.cc:37
│ │ │ │ +
bool pathIndicatesDirectory(const std::string &p)
check whether the given path indicates that it is a directory
Definition path.cc:111
│ │ │ │ +
std::string prettyPath(const std::string &p, bool isDirectory)
pretty print path
Definition path.cc:122
│ │ │ │ +
std::string relativePath(const std::string &newbase, const std::string &p)
compute a relative path between two paths
Definition path.cc:149
│ │ │ │ +
std::string concatPaths(const std::string &base, const std::string &p)
concatenate two paths
Definition path.cc:28
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
A traits class describing the mapping of types onto MPI_Datatypes.
Definition mpitraits.hh:41
│ │ │ │ -
static MPI_Datatype getType()
Definition mpitraits.hh:48
│ │ │ │ -
Definition indexset.hh:615
│ │ │ │ -
An index present on the local process with an additional attribute flag.
Definition plocalindex.hh:52
│ │ │ │ -
T Attribute
The type of the attributes. Normally this will be an enumeration like.
Definition plocalindex.hh:67
│ │ │ │ -
static bool compare(const ParallelLocalIndex< T > &t1, const ParallelLocalIndex< T > &t2)
Definition plocalindex.hh:198
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,328 +1,65 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -plocalindex.hh │ │ │ │ │ +path.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PARALLEL_PLOCALINDEX_HH │ │ │ │ │ -6#define DUNE_COMMON_PARALLEL_PLOCALINDEX_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_PATH_HH │ │ │ │ │ +6#define DUNE_COMMON_PATH_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ +8#include │ │ │ │ │ 9 │ │ │ │ │ -10#if HAVE_MPI │ │ │ │ │ -11#include │ │ │ │ │ -12#endif │ │ │ │ │ -13 │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17 │ │ │ │ │ -18namespace Dune │ │ │ │ │ -19{ │ │ │ │ │ -20 │ │ │ │ │ -21 │ │ │ │ │ -32 template class ParallelLocalIndex; │ │ │ │ │ -33 │ │ │ │ │ -39 template │ │ │ │ │ -40 std::ostream& operator<<(std::ostream& os, const ParallelLocalIndex& │ │ │ │ │ -index) │ │ │ │ │ -41 { │ │ │ │ │ -42 os<<"{local="< │ │ │ │ │ -51 class ParallelLocalIndex │ │ │ │ │ -52 { │ │ │ │ │ -53#if HAVE_MPI │ │ │ │ │ -54 // friend declaration needed for MPITraits │ │ │ │ │ -55 friend struct MPITraits >; │ │ │ │ │ -56#endif │ │ │ │ │ -57 friend std::ostream& operator<< <>(std::ostream& os, const │ │ │ │ │ -ParallelLocalIndex& index); │ │ │ │ │ -58 │ │ │ │ │ -59 public: │ │ │ │ │ -67 typedef T Attribute; │ │ │ │ │ -76 ParallelLocalIndex(const Attribute& attribute, bool isPublic); │ │ │ │ │ -77 │ │ │ │ │ -86 ParallelLocalIndex(size_t localIndex, const Attribute& attribute, bool │ │ │ │ │ -isPublic=true); │ │ │ │ │ -92 ParallelLocalIndex(); │ │ │ │ │ -93 │ │ │ │ │ -94#if 0 │ │ │ │ │ -104 ParallelLocalIndex(const Attribute& attribute, size_t local, bool │ │ │ │ │ -isPublic); │ │ │ │ │ -105#endif │ │ │ │ │ -106 │ │ │ │ │ -111 inline const Attribute attribute() const; │ │ │ │ │ +10namespace Dune { │ │ │ │ │ +23 │ │ │ │ │ +51 std::string concatPaths(const std::string& base, const std::string& p); │ │ │ │ │ +52 │ │ │ │ │ +54 │ │ │ │ │ +98 std::string processPath(const std::string& p); │ │ │ │ │ +99 │ │ │ │ │ +101 │ │ │ │ │ +109 bool pathIndicatesDirectory(const std::string& p); │ │ │ │ │ +110 │ │ │ │ │ 112 │ │ │ │ │ -117 inline void setAttribute(const Attribute& attribute); │ │ │ │ │ -118 │ │ │ │ │ -123 inline size_t local() const; │ │ │ │ │ -124 │ │ │ │ │ -128 inline operator size_t() const; │ │ │ │ │ -129 │ │ │ │ │ -135 inline ParallelLocalIndex& operator=(size_t index); │ │ │ │ │ -136 │ │ │ │ │ -141 inline bool isPublic() const; │ │ │ │ │ -142 │ │ │ │ │ -147 inline LocalIndexState state() const; │ │ │ │ │ -148 │ │ │ │ │ -153 inline void setState(const LocalIndexState& state); │ │ │ │ │ +151 std::string prettyPath(const std::string& p, bool isDirectory); │ │ │ │ │ +152 │ │ │ │ │ 154 │ │ │ │ │ -155 private: │ │ │ │ │ -157 size_t localIndex_; │ │ │ │ │ -158 │ │ │ │ │ -160 char attribute_; │ │ │ │ │ +160 std::string prettyPath(const std::string& p); │ │ │ │ │ 161 │ │ │ │ │ -163 char public_; │ │ │ │ │ -164 │ │ │ │ │ -171 char state_; │ │ │ │ │ -172 │ │ │ │ │ -173 }; │ │ │ │ │ -174 │ │ │ │ │ -175 template │ │ │ │ │ -176 bool operator==(const ParallelLocalIndex& p1, │ │ │ │ │ -177 const ParallelLocalIndex& p2) │ │ │ │ │ -178 { │ │ │ │ │ -179 if(p1.local()!=p2.local()) │ │ │ │ │ -180 return false; │ │ │ │ │ -181 if(p1.attribute()!=p2.attribute()) │ │ │ │ │ -182 return false; │ │ │ │ │ -183 if(p1.isPublic()!=p2.isPublic()) │ │ │ │ │ -184 return false; │ │ │ │ │ -185 return true; │ │ │ │ │ -186 } │ │ │ │ │ -187 template │ │ │ │ │ -188 bool operator!=(const ParallelLocalIndex& p1, │ │ │ │ │ -189 const ParallelLocalIndex& p2) │ │ │ │ │ -190 { │ │ │ │ │ -191 return !(p1==p2); │ │ │ │ │ -192 } │ │ │ │ │ -193 │ │ │ │ │ -194 │ │ │ │ │ -195 template │ │ │ │ │ -196 struct LocalIndexComparator > │ │ │ │ │ -197 { │ │ │ │ │ -198 static bool compare(const ParallelLocalIndex& t1, │ │ │ │ │ -199 const ParallelLocalIndex& t2){ │ │ │ │ │ -200 return t1.attribute() │ │ │ │ │ -209 class MPITraits > │ │ │ │ │ -210 { │ │ │ │ │ -211 public: │ │ │ │ │ -212 static MPI_Datatype getType(); │ │ │ │ │ -213 private: │ │ │ │ │ -214 static MPI_Datatype type; │ │ │ │ │ -215 │ │ │ │ │ -216 }; │ │ │ │ │ -217 │ │ │ │ │ -218#endif │ │ │ │ │ -219 │ │ │ │ │ -220 template │ │ │ │ │ -221 ParallelLocalIndex::ParallelLocalIndex(const T& attribute, bool │ │ │ │ │ -isPublic) │ │ │ │ │ -222 : localIndex_(0), attribute_(static_cast(attribute)), │ │ │ │ │ -223 public_(static_cast(isPublic)), state_(static_cast(VALID)) │ │ │ │ │ -224 {} │ │ │ │ │ -225 │ │ │ │ │ -226 │ │ │ │ │ -227 template │ │ │ │ │ -228 ParallelLocalIndex::ParallelLocalIndex(size_t local, const T& attribute, │ │ │ │ │ -bool isPublic) │ │ │ │ │ -229 : localIndex_(local), attribute_(static_cast(attribute)), │ │ │ │ │ -230 public_(static_cast(isPublic)), state_(static_cast(VALID)) │ │ │ │ │ -231 {} │ │ │ │ │ -232 │ │ │ │ │ -233 template │ │ │ │ │ -234 ParallelLocalIndex::ParallelLocalIndex() │ │ │ │ │ -235 : localIndex_(0), attribute_(), public_(static_cast(false)), │ │ │ │ │ -236 state_(static_cast(VALID)) │ │ │ │ │ -237 {} │ │ │ │ │ -238 │ │ │ │ │ -239 template │ │ │ │ │ -240 inline const T ParallelLocalIndex::attribute() const │ │ │ │ │ -241 { │ │ │ │ │ -242 return T(attribute_); │ │ │ │ │ -243 } │ │ │ │ │ -244 │ │ │ │ │ -245 template │ │ │ │ │ -246 inline void │ │ │ │ │ -247 ParallelLocalIndex::setAttribute(const Attribute& attribute) │ │ │ │ │ -248 { │ │ │ │ │ -249 attribute_ = attribute; │ │ │ │ │ -250 } │ │ │ │ │ -251 │ │ │ │ │ -252 template │ │ │ │ │ -253 inline size_t ParallelLocalIndex::local() const │ │ │ │ │ -254 { │ │ │ │ │ -255 return localIndex_; │ │ │ │ │ -256 } │ │ │ │ │ -257 │ │ │ │ │ -258 template │ │ │ │ │ -259 inline ParallelLocalIndex::operator size_t() const │ │ │ │ │ -260 { │ │ │ │ │ -261 return localIndex_; │ │ │ │ │ -262 } │ │ │ │ │ -263 │ │ │ │ │ -264 template │ │ │ │ │ -265 inline ParallelLocalIndex& │ │ │ │ │ -266 ParallelLocalIndex::operator=(size_t index) │ │ │ │ │ -267 { │ │ │ │ │ -268 localIndex_=index; │ │ │ │ │ -269 return *this; │ │ │ │ │ -270 } │ │ │ │ │ -271 │ │ │ │ │ -272 template │ │ │ │ │ -273 inline bool ParallelLocalIndex::isPublic() const │ │ │ │ │ -274 { │ │ │ │ │ -275 return static_cast(public_); │ │ │ │ │ -276 } │ │ │ │ │ -277 │ │ │ │ │ -278 template │ │ │ │ │ -279 inline LocalIndexState ParallelLocalIndex::state() const │ │ │ │ │ -280 { │ │ │ │ │ -281 return LocalIndexState(state_); │ │ │ │ │ -282 } │ │ │ │ │ -283 │ │ │ │ │ -284 template │ │ │ │ │ -285 inline void ParallelLocalIndex::setState(const LocalIndexState& state) │ │ │ │ │ -286 { │ │ │ │ │ -287 state_=static_cast(state); │ │ │ │ │ -288 } │ │ │ │ │ -289 │ │ │ │ │ -290#if HAVE_MPI │ │ │ │ │ -291 │ │ │ │ │ -292 template │ │ │ │ │ -293 MPI_Datatype MPITraits >::getType() │ │ │ │ │ -294 { │ │ │ │ │ -295 │ │ │ │ │ -296 if(type==MPI_DATATYPE_NULL) { │ │ │ │ │ -297 int length = 1; │ │ │ │ │ -298 MPI_Aint base, disp; │ │ │ │ │ -299 MPI_Datatype types[1] = {MPITraits::getType()}; │ │ │ │ │ -300 ParallelLocalIndex rep; │ │ │ │ │ -301 MPI_Get_address(&rep, &base); │ │ │ │ │ -302 MPI_Get_address(&(rep.attribute_), &disp); │ │ │ │ │ -303 disp -= base; │ │ │ │ │ -304 │ │ │ │ │ -305 MPI_Datatype tmp; │ │ │ │ │ -306 MPI_Type_create_struct(1, &length, &disp, types, &tmp); │ │ │ │ │ -307 │ │ │ │ │ -308 MPI_Type_create_resized(tmp, 0, sizeof(ParallelLocalIndex), &type); │ │ │ │ │ -309 MPI_Type_commit(&type); │ │ │ │ │ -310 │ │ │ │ │ -311 MPI_Type_free(&tmp); │ │ │ │ │ -312 } │ │ │ │ │ -313 return type; │ │ │ │ │ -314 } │ │ │ │ │ -315 │ │ │ │ │ -316 template │ │ │ │ │ -317 MPI_Datatype MPITraits >::type = MPI_DATATYPE_NULL; │ │ │ │ │ -318 │ │ │ │ │ -319#endif // HAVE_MPI │ │ │ │ │ -320 │ │ │ │ │ -321 │ │ │ │ │ -323} // namespace Dune │ │ │ │ │ -324 │ │ │ │ │ -325#endif // DUNE_COMMON_PARALLEL_PLOCALINDEX_HH │ │ │ │ │ -indexset.hh │ │ │ │ │ -Provides a map between global and local indices. │ │ │ │ │ -localindex.hh │ │ │ │ │ -Provides classes for use as the local index in ParallelIndexSet. │ │ │ │ │ -mpitraits.hh │ │ │ │ │ -Traits classes for mapping types onto MPI_Datatype. │ │ │ │ │ -Dune::operator<< │ │ │ │ │ -std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ -Definition bigunsignedint.hh:278 │ │ │ │ │ -Dune::operator== │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator==(const │ │ │ │ │ -ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, │ │ │ │ │ -V2, R2, D > &rhs) │ │ │ │ │ -Checks for equality. │ │ │ │ │ -Definition iteratorfacades.hh:238 │ │ │ │ │ -Dune::operator!= │ │ │ │ │ -EnableIfInterOperable< T1, T2, bool >::type operator!=(const │ │ │ │ │ -ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, │ │ │ │ │ -V2, R2, D > &rhs) │ │ │ │ │ -Checks for inequality. │ │ │ │ │ -Definition iteratorfacades.hh:260 │ │ │ │ │ -Dune::ParallelLocalIndex::isPublic │ │ │ │ │ -bool isPublic() const │ │ │ │ │ -Check whether the index might also be known other processes. │ │ │ │ │ -Definition plocalindex.hh:273 │ │ │ │ │ -Dune::ParallelLocalIndex::setAttribute │ │ │ │ │ -void setAttribute(const Attribute &attribute) │ │ │ │ │ -Set the attribute of the index. │ │ │ │ │ -Definition plocalindex.hh:247 │ │ │ │ │ -Dune::ParallelLocalIndex::local │ │ │ │ │ -size_t local() const │ │ │ │ │ -get the local index. │ │ │ │ │ -Definition plocalindex.hh:253 │ │ │ │ │ -Dune::LocalIndexState │ │ │ │ │ -LocalIndexState │ │ │ │ │ -The states available for the local indices. │ │ │ │ │ -Definition localindex.hh:28 │ │ │ │ │ -Dune::ParallelLocalIndex::setState │ │ │ │ │ -void setState(const LocalIndexState &state) │ │ │ │ │ -Set the state. │ │ │ │ │ -Definition plocalindex.hh:285 │ │ │ │ │ -Dune::ParallelLocalIndex::operator= │ │ │ │ │ -ParallelLocalIndex< Attribute > & operator=(size_t index) │ │ │ │ │ -Assign a new local index. │ │ │ │ │ -Definition plocalindex.hh:266 │ │ │ │ │ -Dune::ParallelLocalIndex::state │ │ │ │ │ -LocalIndexState state() const │ │ │ │ │ -Get the state. │ │ │ │ │ -Definition plocalindex.hh:279 │ │ │ │ │ -Dune::ParallelLocalIndex::ParallelLocalIndex │ │ │ │ │ -ParallelLocalIndex() │ │ │ │ │ -Parameterless constructor. │ │ │ │ │ -Definition plocalindex.hh:234 │ │ │ │ │ -Dune::ParallelLocalIndex::attribute │ │ │ │ │ -const Attribute attribute() const │ │ │ │ │ -Get the attribute of the index. │ │ │ │ │ -Definition plocalindex.hh:240 │ │ │ │ │ -Dune::VALID │ │ │ │ │ -@ VALID │ │ │ │ │ -Definition localindex.hh:28 │ │ │ │ │ +163 │ │ │ │ │ +179 std::string relativePath(const std::string& newbase, const std::string& p); │ │ │ │ │ +180 │ │ │ │ │ +182} │ │ │ │ │ +183 │ │ │ │ │ +184#endif // DUNE_COMMON_PATH_HH │ │ │ │ │ +Dune::processPath │ │ │ │ │ +std::string processPath(const std::string &p) │ │ │ │ │ +sanitize a path for further processing │ │ │ │ │ +Definition path.cc:37 │ │ │ │ │ +Dune::pathIndicatesDirectory │ │ │ │ │ +bool pathIndicatesDirectory(const std::string &p) │ │ │ │ │ +check whether the given path indicates that it is a directory │ │ │ │ │ +Definition path.cc:111 │ │ │ │ │ +Dune::prettyPath │ │ │ │ │ +std::string prettyPath(const std::string &p, bool isDirectory) │ │ │ │ │ +pretty print path │ │ │ │ │ +Definition path.cc:122 │ │ │ │ │ +Dune::relativePath │ │ │ │ │ +std::string relativePath(const std::string &newbase, const std::string &p) │ │ │ │ │ +compute a relative path between two paths │ │ │ │ │ +Definition path.cc:149 │ │ │ │ │ +Dune::concatPaths │ │ │ │ │ +std::string concatPaths(const std::string &base, const std::string &p) │ │ │ │ │ +concatenate two paths │ │ │ │ │ +Definition path.cc:28 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::MPITraits │ │ │ │ │ -A traits class describing the mapping of types onto MPI_Datatypes. │ │ │ │ │ -Definition mpitraits.hh:41 │ │ │ │ │ -Dune::MPITraits::getType │ │ │ │ │ -static MPI_Datatype getType() │ │ │ │ │ -Definition mpitraits.hh:48 │ │ │ │ │ -Dune::LocalIndexComparator │ │ │ │ │ -Definition indexset.hh:615 │ │ │ │ │ -Dune::ParallelLocalIndex │ │ │ │ │ -An index present on the local process with an additional attribute flag. │ │ │ │ │ -Definition plocalindex.hh:52 │ │ │ │ │ -Dune::ParallelLocalIndex::Attribute │ │ │ │ │ -T Attribute │ │ │ │ │ -The type of the attributes. Normally this will be an enumeration like. │ │ │ │ │ -Definition plocalindex.hh:67 │ │ │ │ │ -Dune::LocalIndexComparator<_ParallelLocalIndex<_T_>_>::compare │ │ │ │ │ -static bool compare(const ParallelLocalIndex< T > &t1, const │ │ │ │ │ -ParallelLocalIndex< T > &t2) │ │ │ │ │ -Definition plocalindex.hh:198 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00068.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpidata.hh File Reference │ │ │ │ +dune-common: stdthread.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,62 +65,69 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ Namespaces | │ │ │ │ +Macros | │ │ │ │ Functions
│ │ │ │ -
mpidata.hh File Reference
│ │ │ │ +
stdthread.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ -

Interface class to translate objects to a MPI_Datatype, void* and size used for MPI calls. │ │ │ │ -More...

│ │ │ │ -
#include <vector>
│ │ │ │ -#include <string>
│ │ │ │ -#include <type_traits>
│ │ │ │ -#include <dune/common/typetraits.hh>
│ │ │ │ -#include <dune/common/std/type_traits.hh>
│ │ │ │ -#include <dune/common/parallel/mpitraits.hh>
│ │ │ │ -
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

struct  Dune::MPIData< T, Enable >
 
struct  Dune::MPIData< void >
 
struct  Dune::MPIData< T, std::void_t< std::tuple< decltype(std::declval< T >().data()), decltype(std::declval< T >().size()), typename std::decay_t< T >::value_type > > >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Macros

#define DUNE_ASSERT_CALL_ONCE()    ::Dune::assertCallOnce(__FILE__, __LINE__, __func__)
 Make sure call_once() works and provide a helpful error message otherwise.
 
│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ Functions

template<class T >
auto Dune::getMPIData (T &t)
 
void Dune::doAssertCallOnce (const char *file, int line, const char *function)
 
void Dune::assertCallOnce (const char *file=nullptr, int line=-1, const char *function=nullptr)
 Make sure call_once() works and provide a helpful error message otherwise.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Interface class to translate objects to a MPI_Datatype, void* and size used for MPI calls.

│ │ │ │ -

Furthermore it can be used to resize the object if possible. This makes it possible to receive a message with variable size. See Communication::rrecv.

│ │ │ │ -

To 'register' a new dynamic type for MPI communication specialize MPIData or overload getMPIData.

│ │ │ │ -
│ │ │ │ +

Macro Definition Documentation

│ │ │ │ + │ │ │ │ +

◆ DUNE_ASSERT_CALL_ONCE

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_ASSERT_CALL_ONCE()    ::Dune::assertCallOnce(__FILE__, __LINE__, __func__)
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

Make sure call_once() works and provide a helpful error message otherwise.

│ │ │ │ +

This calls assertCallOnce() and automatically provides information about the caller in the error message.

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,45 +1,36 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces | Functions │ │ │ │ │ -mpidata.hh File Reference │ │ │ │ │ -Common » Parallel_Communication │ │ │ │ │ -Interface class to translate objects to a MPI_Datatype, void* and size used for │ │ │ │ │ -MPI calls. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Macros | Functions │ │ │ │ │ +stdthread.hh File Reference │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ -Classes │ │ │ │ │ -struct   Dune::MPIData<_T,_Enable_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::MPIData<_void_> │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::MPIData<_T,_std::void_t<_std::tuple<_decltype(std::declval<_T_> │ │ │ │ │ - ().data()),_decltype(std::declval<_T_>().size()),_typename_std::decay_ │ │ │ │ │ - t<_T_>::value_type_>_>_> │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ +Macros │ │ │ │ │ +#define  DUNE_ASSERT_CALL_ONCE()    ::Dune::assertCallOnce(__FILE__, __LINE__, │ │ │ │ │ + __func__) │ │ │ │ │ +  Make sure call_once() works and provide a helpful error message │ │ │ │ │ + otherwise. │ │ │ │ │ +  │ │ │ │ │ Functions │ │ │ │ │ -template │ │ │ │ │ -auto  Dune::getMPIData (T &t) │ │ │ │ │ +void  Dune::doAssertCallOnce (const char *file, int line, const char *function) │ │ │ │ │ +  │ │ │ │ │ +void  Dune::assertCallOnce (const char *file=nullptr, int line=-1, const char │ │ │ │ │ + *function=nullptr) │ │ │ │ │ +  Make sure call_once() works and provide a helpful error message │ │ │ │ │ + otherwise. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Interface class to translate objects to a MPI_Datatype, void* and size used for │ │ │ │ │ -MPI calls. │ │ │ │ │ -Furthermore it can be used to resize the object if possible. This makes it │ │ │ │ │ -possible to receive a message with variable size. See Communication::rrecv. │ │ │ │ │ -To 'register' a new dynamic type for MPI communication specialize MPIData or │ │ │ │ │ -overload getMPIData. │ │ │ │ │ +***** Macro Definition Documentation ***** │ │ │ │ │ +***** ◆ DUNE_ASSERT_CALL_ONCE ***** │ │ │ │ │ +#define DUNE_ASSERT_CALL_ONCE ( )     ::Dune::assertCallOnce(__FILE__, __LINE_ │ │ │ │ │ + _, __func__) │ │ │ │ │ +Make sure call_once() works and provide a helpful error message otherwise. │ │ │ │ │ +This calls assertCallOnce() and automatically provides information about the │ │ │ │ │ +caller in the error message. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00068_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpidata.hh Source File │ │ │ │ +dune-common: stdthread.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,197 +70,58 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
mpidata.hh
│ │ │ │ +
stdthread.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │
5
│ │ │ │ -
6#ifndef DUNE_COMMON_PARALLEL_MPIDATA_HH
│ │ │ │ -
7#define DUNE_COMMON_PARALLEL_MPIDATA_HH
│ │ │ │ +
6#ifndef DUNE_COMMON_STDTHREAD_HH
│ │ │ │ +
7#define DUNE_COMMON_STDTHREAD_HH
│ │ │ │
8
│ │ │ │ -
9#if HAVE_MPI
│ │ │ │ -
10
│ │ │ │ -
11#include <vector>
│ │ │ │ -
12#include <string>
│ │ │ │ -
13#include <type_traits>
│ │ │ │ +
9namespace Dune
│ │ │ │ +
10{
│ │ │ │ +
11
│ │ │ │ +
12 // used internally by assertCallOnce for the actual check
│ │ │ │ +
13 void doAssertCallOnce(const char *file, int line, const char *function);
│ │ │ │
14
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
18
│ │ │ │ -
38namespace Dune{
│ │ │ │ -
39
│ │ │ │ -
40 template<class, class = void>
│ │ │ │ -
41 struct MPIData;
│ │ │ │ -
42
│ │ │ │ -
43 template<class T>
│ │ │ │ -
│ │ │ │ -
44 auto getMPIData(T& t){
│ │ │ │ -
45 return MPIData<T>(t);
│ │ │ │ -
46 }
│ │ │ │ -
│ │ │ │ -
47
│ │ │ │ -
48 // Default implementation for static datatypes
│ │ │ │ -
49 template<class T, class Enable>
│ │ │ │ -
│ │ │ │ -
50 struct MPIData
│ │ │ │ -
51 {
│ │ │ │ -
52 friend auto getMPIData<T>(T&);
│ │ │ │ -
53 protected:
│ │ │ │ - │ │ │ │ -
55
│ │ │ │ -
│ │ │ │ -
56 MPIData(T& t)
│ │ │ │ -
57 : data_(t)
│ │ │ │ -
58 {}
│ │ │ │ -
│ │ │ │ -
59
│ │ │ │ -
60 public:
│ │ │ │ -
│ │ │ │ -
61 void* ptr() const {
│ │ │ │ -
62 return (void*)&data_;
│ │ │ │ -
63 }
│ │ │ │ -
│ │ │ │ -
64
│ │ │ │ -
65 // indicates whether the datatype can be resized
│ │ │ │ -
66 static constexpr bool static_size = true;
│ │ │ │ -
67
│ │ │ │ -
│ │ │ │ -
68 int size() const{
│ │ │ │ -
69 return 1;
│ │ │ │ -
70 }
│ │ │ │ -
│ │ │ │ -
71
│ │ │ │ -
│ │ │ │ -
72 MPI_Datatype type() const {
│ │ │ │ -
73 return MPITraits<std::decay_t<T>>::getType();
│ │ │ │ -
74 }
│ │ │ │ -
│ │ │ │ -
75 };
│ │ │ │ -
│ │ │ │ -
76
│ │ │ │ -
77 // dummy implementation for void
│ │ │ │ -
78 template<>
│ │ │ │ -
│ │ │ │ -
79 struct MPIData<void>{
│ │ │ │ -
80 protected:
│ │ │ │ - │ │ │ │ -
82
│ │ │ │ -
83 public:
│ │ │ │ -
│ │ │ │ -
84 void* ptr(){
│ │ │ │ -
85 return nullptr;
│ │ │ │ -
86 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
87 int size(){
│ │ │ │ -
88 return 0;
│ │ │ │ -
89 }
│ │ │ │ -
│ │ │ │ -
90 void get(){}
│ │ │ │ -
│ │ │ │ -
91 MPI_Datatype type() const{
│ │ │ │ -
92 return MPI_INT;
│ │ │ │ -
93 }
│ │ │ │ +
17
│ │ │ │ +
│ │ │ │ +
35 inline void assertCallOnce(const char *file = nullptr, int line = -1,
│ │ │ │ +
36 const char *function = nullptr)
│ │ │ │ +
37 {
│ │ │ │ +
38 // make sure to call this only the first time this function is invoked
│ │ │ │ +
39 [[maybe_unused]] static const bool works
│ │ │ │ +
40 = (doAssertCallOnce(file, line, function), true);
│ │ │ │ +
41 }
│ │ │ │
│ │ │ │ -
94 };
│ │ │ │ -
│ │ │ │ -
95
│ │ │ │ -
96 // specializations:
│ │ │ │ -
97 // std::vector of static sized elements or std::string
│ │ │ │ -
98 template<class T>
│ │ │ │ -
│ │ │ │ -
99 struct MPIData<T, std::void_t<std::tuple<decltype(std::declval<T>().data()),
│ │ │ │ -
100 decltype(std::declval<T>().size()),
│ │ │ │ -
101 typename std::decay_t<T>::value_type>>>{
│ │ │ │ -
102 private:
│ │ │ │ -
103 template<class U>
│ │ │ │ -
104 using hasResizeOp = decltype(std::declval<U>().resize(0));
│ │ │ │ -
105
│ │ │ │ -
106 protected:
│ │ │ │ -
107 friend auto getMPIData<T>(T&);
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
109 : data_(t)
│ │ │ │ -
110 {}
│ │ │ │ -
│ │ │ │ -
111 public:
│ │ │ │ -
112 static constexpr bool static_size = std::is_const<T>::value || !Std::is_detected_v<hasResizeOp, T>;
│ │ │ │ -
│ │ │ │ -
113 void* ptr() {
│ │ │ │ -
114 return (void*) data_.data();
│ │ │ │ -
115 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
116 int size() {
│ │ │ │ -
117 return data_.size();
│ │ │ │ -
118 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
119 MPI_Datatype type() const{
│ │ │ │ - │ │ │ │ -
121 }
│ │ │ │ -
│ │ │ │ -
122
│ │ │ │ -
123 template<class S = T>
│ │ │ │ -
│ │ │ │ -
124 auto /*void*/ resize(int size)
│ │ │ │ -
125 -> std::enable_if_t<!std::is_const<S>::value || !Std::is_detected_v<hasResizeOp, S>>
│ │ │ │ -
126 {
│ │ │ │ -
127 data_.resize(size);
│ │ │ │ -
128 }
│ │ │ │ -
│ │ │ │ -
129
│ │ │ │ -
130 protected:
│ │ │ │ - │ │ │ │ -
132 };
│ │ │ │ -
│ │ │ │ -
133
│ │ │ │ -
134}
│ │ │ │ -
135
│ │ │ │ -
140#endif // HAVE_MPI
│ │ │ │ -
141#endif // DUNE_COMMON_PARALLEL_MPIDATA_HH
│ │ │ │ -
Traits classes for mapping types onto MPI_Datatype.
│ │ │ │ -
Traits for type conversions and type information.
│ │ │ │ - │ │ │ │ -
typename Impl::voider< Types... >::type void_t
Is void for all valid input types. The workhorse for C++11 SFINAE-techniques.
Definition typetraits.hh:40
│ │ │ │ -
STL namespace.
│ │ │ │ +
42
│ │ │ │ +
45
│ │ │ │ +
│ │ │ │ +
49#define DUNE_ASSERT_CALL_ONCE() \
│ │ │ │ +
50 ::Dune::assertCallOnce(__FILE__, __LINE__, __func__)
│ │ │ │ +
│ │ │ │ +
51
│ │ │ │ +
52} // namespace Dune
│ │ │ │ +
53
│ │ │ │ +
54#endif // DUNE_COMMON_STDTHREAD_HH
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
auto getMPIData(T &t)
Definition mpidata.hh:44
│ │ │ │ -
A traits class describing the mapping of types onto MPI_Datatypes.
Definition mpitraits.hh:41
│ │ │ │ -
Definition mpidata.hh:51
│ │ │ │ -
T & data_
Definition mpidata.hh:54
│ │ │ │ -
MPI_Datatype type() const
Definition mpidata.hh:72
│ │ │ │ -
void * ptr() const
Definition mpidata.hh:61
│ │ │ │ -
int size() const
Definition mpidata.hh:68
│ │ │ │ -
static constexpr bool static_size
Definition mpidata.hh:66
│ │ │ │ -
MPIData(T &t)
Definition mpidata.hh:56
│ │ │ │ -
void get()
Definition mpidata.hh:90
│ │ │ │ -
MPIData()
Definition mpidata.hh:81
│ │ │ │ -
int size()
Definition mpidata.hh:87
│ │ │ │ -
void * ptr()
Definition mpidata.hh:84
│ │ │ │ -
MPI_Datatype type() const
Definition mpidata.hh:91
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
auto resize(int size) -> std::enable_if_t<!std::is_const< S >::value||!Std::is_detected_v< hasResizeOp, S > >
Definition mpidata.hh:124
│ │ │ │ - │ │ │ │ +
void assertCallOnce(const char *file=nullptr, int line=-1, const char *function=nullptr)
Make sure call_once() works and provide a helpful error message otherwise.
Definition stdthread.hh:35
│ │ │ │ +
void doAssertCallOnce(const char *file, int line, const char *function)
Definition stdthread.cc:38
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,218 +1,52 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -mpidata.hh │ │ │ │ │ +stdthread.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ 5 │ │ │ │ │ -6#ifndef DUNE_COMMON_PARALLEL_MPIDATA_HH │ │ │ │ │ -7#define DUNE_COMMON_PARALLEL_MPIDATA_HH │ │ │ │ │ +6#ifndef DUNE_COMMON_STDTHREAD_HH │ │ │ │ │ +7#define DUNE_COMMON_STDTHREAD_HH │ │ │ │ │ 8 │ │ │ │ │ -9#if HAVE_MPI │ │ │ │ │ -10 │ │ │ │ │ -11#include │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ +9namespace Dune │ │ │ │ │ +10{ │ │ │ │ │ +11 │ │ │ │ │ +12 // used internally by assertCallOnce for the actual check │ │ │ │ │ +13 void doAssertCallOnce(const char *file, int line, const char *function); │ │ │ │ │ 14 │ │ │ │ │ -15#include │ │ │ │ │ -16#include │ │ │ │ │ -17#include │ │ │ │ │ -18 │ │ │ │ │ -38namespace Dune{ │ │ │ │ │ -39 │ │ │ │ │ -40 template │ │ │ │ │ -41 struct MPIData; │ │ │ │ │ +17 │ │ │ │ │ +35 inline void assertCallOnce(const char *file = nullptr, int line = -1, │ │ │ │ │ +36 const char *function = nullptr) │ │ │ │ │ +37 { │ │ │ │ │ +38 // make sure to call this only the first time this function is invoked │ │ │ │ │ +39 [[maybe_unused]] static const bool works │ │ │ │ │ +40 = (doAssertCallOnce(file, line, function), true); │ │ │ │ │ +41 } │ │ │ │ │ 42 │ │ │ │ │ -43 template │ │ │ │ │ -44 auto getMPIData(T& t){ │ │ │ │ │ -45 return MPIData(t); │ │ │ │ │ -46 } │ │ │ │ │ -47 │ │ │ │ │ -48 // Default implementation for static datatypes │ │ │ │ │ -49 template │ │ │ │ │ -50 struct MPIData │ │ │ │ │ -51 { │ │ │ │ │ -52 friend auto getMPIData(T&); │ │ │ │ │ -53 protected: │ │ │ │ │ -54 T& data_; │ │ │ │ │ -55 │ │ │ │ │ -56 MPIData(T& t) │ │ │ │ │ -57 : data_(t) │ │ │ │ │ -58 {} │ │ │ │ │ -59 │ │ │ │ │ -60 public: │ │ │ │ │ -61 void* ptr() const { │ │ │ │ │ -62 return (void*)&data_; │ │ │ │ │ -63 } │ │ │ │ │ -64 │ │ │ │ │ -65 // indicates whether the datatype can be resized │ │ │ │ │ -66 static constexpr bool static_size = true; │ │ │ │ │ -67 │ │ │ │ │ -68 int size() const{ │ │ │ │ │ -69 return 1; │ │ │ │ │ -70 } │ │ │ │ │ -71 │ │ │ │ │ -72 MPI_Datatype type() const { │ │ │ │ │ -73 return MPITraits>::getType(); │ │ │ │ │ -74 } │ │ │ │ │ -75 }; │ │ │ │ │ -76 │ │ │ │ │ -77 // dummy implementation for void │ │ │ │ │ -78 template<> │ │ │ │ │ -79 struct MPIData{ │ │ │ │ │ -80 protected: │ │ │ │ │ -81 MPIData() {} │ │ │ │ │ -82 │ │ │ │ │ -83 public: │ │ │ │ │ -84 void* ptr(){ │ │ │ │ │ -85 return nullptr; │ │ │ │ │ -86 } │ │ │ │ │ -87 int size(){ │ │ │ │ │ -88 return 0; │ │ │ │ │ -89 } │ │ │ │ │ -90 void get(){} │ │ │ │ │ -91 MPI_Datatype type() const{ │ │ │ │ │ -92 return MPI_INT; │ │ │ │ │ -93 } │ │ │ │ │ -94 }; │ │ │ │ │ -95 │ │ │ │ │ -96 // specializations: │ │ │ │ │ -97 // std::vector of static sized elements or std::string │ │ │ │ │ -98 template │ │ │ │ │ -99 struct MPIData().data()), │ │ │ │ │ -100 decltype(std::declval().size()), │ │ │ │ │ -101 typename std::decay_t::value_type>>>{ │ │ │ │ │ -102 private: │ │ │ │ │ -103 template │ │ │ │ │ -104 using hasResizeOp = decltype(std::declval().resize(0)); │ │ │ │ │ -105 │ │ │ │ │ -106 protected: │ │ │ │ │ -107 friend auto getMPIData(T&); │ │ │ │ │ -108 MPIData(T& t) │ │ │ │ │ -109 : data_(t) │ │ │ │ │ -110 {} │ │ │ │ │ -111 public: │ │ │ │ │ -112 static constexpr bool static_size = std::is_const::value || !Std::is_ │ │ │ │ │ -detected_v; │ │ │ │ │ -113 void* ptr() { │ │ │ │ │ -114 return (void*) data_.data(); │ │ │ │ │ -115 } │ │ │ │ │ -116 int size() { │ │ │ │ │ -117 return data_.size(); │ │ │ │ │ -118 } │ │ │ │ │ -119 MPI_Datatype type() const{ │ │ │ │ │ -120 return MPITraits::value_type>::getType(); │ │ │ │ │ -121 } │ │ │ │ │ -122 │ │ │ │ │ -123 template │ │ │ │ │ -124 auto /*void*/ resize(int size) │ │ │ │ │ -125 -> std::enable_if_t::value || !Std::is_detected_ │ │ │ │ │ -v> │ │ │ │ │ -126 { │ │ │ │ │ -127 data_.resize(size); │ │ │ │ │ -128 } │ │ │ │ │ -129 │ │ │ │ │ -130 protected: │ │ │ │ │ -131 T& data_; │ │ │ │ │ -132 }; │ │ │ │ │ -133 │ │ │ │ │ -134} │ │ │ │ │ -135 │ │ │ │ │ -140#endif // HAVE_MPI │ │ │ │ │ -141#endif // DUNE_COMMON_PARALLEL_MPIDATA_HH │ │ │ │ │ -mpitraits.hh │ │ │ │ │ -Traits classes for mapping types onto MPI_Datatype. │ │ │ │ │ -typetraits.hh │ │ │ │ │ -Traits for type conversions and type information. │ │ │ │ │ -type_traits.hh │ │ │ │ │ -Dune::void_t │ │ │ │ │ -typename Impl::voider< Types... >::type void_t │ │ │ │ │ -Is void for all valid input types. The workhorse for C++11 SFINAE-techniques. │ │ │ │ │ -Definition typetraits.hh:40 │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ +45 │ │ │ │ │ +49#define DUNE_ASSERT_CALL_ONCE() \ │ │ │ │ │ +50 ::Dune::assertCallOnce(__FILE__, __LINE__, __func__) │ │ │ │ │ +51 │ │ │ │ │ +52} // namespace Dune │ │ │ │ │ +53 │ │ │ │ │ +54#endif // DUNE_COMMON_STDTHREAD_HH │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::getMPIData │ │ │ │ │ -auto getMPIData(T &t) │ │ │ │ │ -Definition mpidata.hh:44 │ │ │ │ │ -Dune::MPITraits │ │ │ │ │ -A traits class describing the mapping of types onto MPI_Datatypes. │ │ │ │ │ -Definition mpitraits.hh:41 │ │ │ │ │ -Dune::MPIData │ │ │ │ │ -Definition mpidata.hh:51 │ │ │ │ │ -Dune::MPIData::data_ │ │ │ │ │ -T & data_ │ │ │ │ │ -Definition mpidata.hh:54 │ │ │ │ │ -Dune::MPIData::type │ │ │ │ │ -MPI_Datatype type() const │ │ │ │ │ -Definition mpidata.hh:72 │ │ │ │ │ -Dune::MPIData::ptr │ │ │ │ │ -void * ptr() const │ │ │ │ │ -Definition mpidata.hh:61 │ │ │ │ │ -Dune::MPIData::size │ │ │ │ │ -int size() const │ │ │ │ │ -Definition mpidata.hh:68 │ │ │ │ │ -Dune::MPIData::static_size │ │ │ │ │ -static constexpr bool static_size │ │ │ │ │ -Definition mpidata.hh:66 │ │ │ │ │ -Dune::MPIData::MPIData │ │ │ │ │ -MPIData(T &t) │ │ │ │ │ -Definition mpidata.hh:56 │ │ │ │ │ -Dune::MPIData<_void_>::get │ │ │ │ │ -void get() │ │ │ │ │ -Definition mpidata.hh:90 │ │ │ │ │ -Dune::MPIData<_void_>::MPIData │ │ │ │ │ -MPIData() │ │ │ │ │ -Definition mpidata.hh:81 │ │ │ │ │ -Dune::MPIData<_void_>::size │ │ │ │ │ -int size() │ │ │ │ │ -Definition mpidata.hh:87 │ │ │ │ │ -Dune::MPIData<_void_>::ptr │ │ │ │ │ -void * ptr() │ │ │ │ │ -Definition mpidata.hh:84 │ │ │ │ │ -Dune::MPIData<_void_>::type │ │ │ │ │ -MPI_Datatype type() const │ │ │ │ │ -Definition mpidata.hh:91 │ │ │ │ │ -Dune::MPIData<_T,_std::void_t<_std::tuple<_decltype(std::declval<_T_>().data │ │ │ │ │ -()),_decltype(std::declval<_T_>().size()),_typename_std::decay_t<_T_>::value_ │ │ │ │ │ -type_>_>_>::MPIData │ │ │ │ │ -MPIData(T &t) │ │ │ │ │ -Definition mpidata.hh:108 │ │ │ │ │ -Dune::MPIData<_T,_std::void_t<_std::tuple<_decltype(std::declval<_T_>().data │ │ │ │ │ -()),_decltype(std::declval<_T_>().size()),_typename_std::decay_t<_T_>::value_ │ │ │ │ │ -type_>_>_>::ptr │ │ │ │ │ -void * ptr() │ │ │ │ │ -Definition mpidata.hh:113 │ │ │ │ │ -Dune::MPIData<_T,_std::void_t<_std::tuple<_decltype(std::declval<_T_>().data │ │ │ │ │ -()),_decltype(std::declval<_T_>().size()),_typename_std::decay_t<_T_>::value_ │ │ │ │ │ -type_>_>_>::size │ │ │ │ │ -int size() │ │ │ │ │ -Definition mpidata.hh:116 │ │ │ │ │ -Dune::MPIData<_T,_std::void_t<_std::tuple<_decltype(std::declval<_T_>().data │ │ │ │ │ -()),_decltype(std::declval<_T_>().size()),_typename_std::decay_t<_T_>::value_ │ │ │ │ │ -type_>_>_>::data_ │ │ │ │ │ -T & data_ │ │ │ │ │ -Definition mpidata.hh:131 │ │ │ │ │ -Dune::MPIData<_T,_std::void_t<_std::tuple<_decltype(std::declval<_T_>().data │ │ │ │ │ -()),_decltype(std::declval<_T_>().size()),_typename_std::decay_t<_T_>::value_ │ │ │ │ │ -type_>_>_>::resize │ │ │ │ │ -auto resize(int size) -> std::enable_if_t::value||!Std::is_ │ │ │ │ │ -detected_v< hasResizeOp, S > > │ │ │ │ │ -Definition mpidata.hh:124 │ │ │ │ │ -Dune::MPIData<_T,_std::void_t<_std::tuple<_decltype(std::declval<_T_>().data │ │ │ │ │ -()),_decltype(std::declval<_T_>().size()),_typename_std::decay_t<_T_>::value_ │ │ │ │ │ -type_>_>_>::type │ │ │ │ │ -MPI_Datatype type() const │ │ │ │ │ -Definition mpidata.hh:119 │ │ │ │ │ +Dune::assertCallOnce │ │ │ │ │ +void assertCallOnce(const char *file=nullptr, int line=-1, const char │ │ │ │ │ +*function=nullptr) │ │ │ │ │ +Make sure call_once() works and provide a helpful error message otherwise. │ │ │ │ │ +Definition stdthread.hh:35 │ │ │ │ │ +Dune::doAssertCallOnce │ │ │ │ │ +void doAssertCallOnce(const char *file, int line, const char *function) │ │ │ │ │ +Definition stdthread.cc:38 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00071.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpiguard.hh File Reference │ │ │ │ +dune-common: fmatrixev.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,53 +65,72 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ -Namespaces
│ │ │ │ -
mpiguard.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
fmatrixev.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Implements a MPIGuard which detects an error on a remote process. │ │ │ │ +

Eigenvalue computations for the FieldMatrix class. │ │ │ │ More...

│ │ │ │ -
#include <mpi.h>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/parallel/communication.hh>
│ │ │ │ -#include <dune/common/parallel/mpicommunication.hh>
│ │ │ │ -#include <dune/common/parallel/mpihelper.hh>
│ │ │ │ +
#include <algorithm>
│ │ │ │ +#include <iostream>
│ │ │ │ +#include <cmath>
│ │ │ │ +#include <cassert>
│ │ │ │ +#include <dune-common-config.hh>
│ │ │ │ +#include <dune/common/exceptions.hh>
│ │ │ │ +#include <dune/common/fvector.hh>
│ │ │ │ +#include <dune/common/fmatrix.hh>
│ │ │ │ +#include <dune/common/math.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

class  Dune::MPIGuardError
 This exception is thrown if the MPIGuard detects an error on a remote process. More...
 
class  Dune::MPIGuard
 detects a thrown exception and communicates to all other processes More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::FMatrixHelp
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

template<int dim, typename K >
static void Dune::FMatrixHelp::eigenValues (const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues)
 calculates the eigenvalues of a symmetric field matrix
 
template<int dim, typename K >
static void Dune::FMatrixHelp::eigenValuesVectors (const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors)
 calculates the eigenvalues and eigenvectors of a symmetric field matrix
 
template<int dim, typename K >
static void Dune::FMatrixHelp::eigenValuesLapack (const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues)
 calculates the eigenvalues of a symmetric field matrix
 
template<int dim, typename K >
static void Dune::FMatrixHelp::eigenValuesVectorsLapack (const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors)
 calculates the eigenvalues and -vectors of a symmetric field matrix
 
template<int dim, typename K , class C >
static void Dune::FMatrixHelp::eigenValuesNonSym (const FieldMatrix< K, dim, dim > &matrix, FieldVector< C, dim > &eigenValues)
 calculates the eigenvalues of a non-symmetric field matrix
 
│ │ │ │

Detailed Description

│ │ │ │ -

Implements a MPIGuard which detects an error on a remote process.

│ │ │ │ -
Author
Christian Engwer
│ │ │ │ +

Eigenvalue computations for the FieldMatrix class.

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,36 +1,59 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -mpiguard.hh File Reference │ │ │ │ │ -Common » Parallel_Communication │ │ │ │ │ -Implements a MPIGuard which detects an error on a remote process. More... │ │ │ │ │ -#include │ │ │ │ │ +Namespaces | Functions │ │ │ │ │ +fmatrixev.hh File Reference │ │ │ │ │ +Eigenvalue computations for the FieldMatrix class. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ -Classes │ │ │ │ │ -class   Dune::MPIGuardError │ │ │ │ │ -  This exception is thrown if the MPIGuard detects an error on a remote │ │ │ │ │ - process. More... │ │ │ │ │ -  │ │ │ │ │ -class   Dune::MPIGuard │ │ │ │ │ -  detects a thrown exception and communicates to all other processes │ │ │ │ │ - More... │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ +namespace   Dune::FMatrixHelp │ │ │ │ │ +  │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ +static void  Dune::FMatrixHelp::eigenValues (const FieldMatrix< K, dim, dim > │ │ │ │ │ + &matrix, FieldVector< K, dim > &eigenValues) │ │ │ │ │ +  calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +static void  Dune::FMatrixHelp::eigenValuesVectors (const FieldMatrix< K, dim, │ │ │ │ │ + dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, │ │ │ │ │ + dim, dim > &eigenVectors) │ │ │ │ │ +  calculates the eigenvalues and eigenvectors of a symmetric field │ │ │ │ │ + matrix │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +static void  Dune::FMatrixHelp::eigenValuesLapack (const FieldMatrix< K, dim, │ │ │ │ │ + dim > &matrix, FieldVector< K, dim > &eigenValues) │ │ │ │ │ +  calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +static void  Dune::FMatrixHelp::eigenValuesVectorsLapack (const FieldMatrix< K, │ │ │ │ │ + dim, dim > &matrix, FieldVector< K, dim > &eigenValues, │ │ │ │ │ + FieldMatrix< K, dim, dim > &eigenVectors) │ │ │ │ │ +  calculates the eigenvalues and -vectors of a symmetric field │ │ │ │ │ + matrix │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +static void  Dune::FMatrixHelp::eigenValuesNonSym (const FieldMatrix< K, dim, │ │ │ │ │ + dim > &matrix, FieldVector< C, dim > &eigenValues) │ │ │ │ │ +  calculates the eigenvalues of a non-symmetric field matrix │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Implements a MPIGuard which detects an error on a remote process. │ │ │ │ │ - Author │ │ │ │ │ - Christian Engwer │ │ │ │ │ +Eigenvalue computations for the FieldMatrix class. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00071_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpiguard.hh Source File │ │ │ │ +dune-common: fmatrixev.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,216 +70,645 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
mpiguard.hh
│ │ │ │ +
fmatrixev.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5
│ │ │ │ -
13#ifndef DUNE_COMMON_PARALLEL_MPIGUARD_HH
│ │ │ │ -
14#define DUNE_COMMON_PARALLEL_MPIGUARD_HH
│ │ │ │ -
15
│ │ │ │ -
16#if HAVE_MPI
│ │ │ │ -
17#include <mpi.h>
│ │ │ │ -
18#endif
│ │ │ │ -
19
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ +
5#ifndef DUNE_FMATRIXEIGENVALUES_HH
│ │ │ │ +
6#define DUNE_FMATRIXEIGENVALUES_HH
│ │ │ │ +
7
│ │ │ │ +
12#include <algorithm>
│ │ │ │ +
13#include <iostream>
│ │ │ │ +
14#include <cmath>
│ │ │ │ +
15#include <cassert>
│ │ │ │ +
16
│ │ │ │ +
17#include <dune-common-config.hh> // HAVE_LAPACK
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
21#include <dune/common/math.hh>
│ │ │ │ +
22
│ │ │ │ +
23namespace Dune {
│ │ │ │
24
│ │ │ │ -
25namespace Dune
│ │ │ │ -
26{
│ │ │ │ -
27
│ │ │ │ -
28#ifndef DOXYGEN
│ │ │ │ -
29
│ │ │ │ -
30 /*
│ │ │ │ -
31 Interface class for the communication needed by MPIGuard
│ │ │ │ -
32 */
│ │ │ │ -
33 struct GuardCommunicator
│ │ │ │ -
34 {
│ │ │ │ -
35 // cleanup
│ │ │ │ -
36 virtual ~GuardCommunicator() {};
│ │ │ │ -
37 // all the communication methods we need
│ │ │ │ -
38 virtual int rank() = 0;
│ │ │ │ -
39 virtual int size() = 0;
│ │ │ │ -
40 virtual int sum(int i) = 0;
│ │ │ │ -
41 // create a new GuardCommunicator pointer
│ │ │ │ -
42 template <class C>
│ │ │ │ -
43 static GuardCommunicator * create(const Communication<C> & c);
│ │ │ │ -
44#if HAVE_MPI
│ │ │ │ -
45 inline
│ │ │ │ -
46 static GuardCommunicator * create(const MPI_Comm & c);
│ │ │ │ -
47#endif
│ │ │ │ -
48 };
│ │ │ │ +
30 namespace FMatrixHelp {
│ │ │ │ +
31
│ │ │ │ +
32#if HAVE_LAPACK
│ │ │ │ +
33 // defined in fmatrixev.cc
│ │ │ │ +
34 extern void eigenValuesLapackCall(
│ │ │ │ +
35 const char* jobz, const char* uplo, const long
│ │ │ │ +
36 int* n, double* a, const long int* lda, double* w,
│ │ │ │ +
37 double* work, const long int* lwork, long int* info);
│ │ │ │ +
38
│ │ │ │ +
39 extern void eigenValuesNonsymLapackCall(
│ │ │ │ +
40 const char* jobvl, const char* jobvr, const long
│ │ │ │ +
41 int* n, double* a, const long int* lda, double* wr, double* wi, double* vl,
│ │ │ │ +
42 const long int* ldvl, double* vr, const long int* ldvr, double* work,
│ │ │ │ +
43 const long int* lwork, long int* info);
│ │ │ │ +
44
│ │ │ │ +
45 extern void eigenValuesLapackCall(
│ │ │ │ +
46 const char* jobz, const char* uplo, const long
│ │ │ │ +
47 int* n, float* a, const long int* lda, float* w,
│ │ │ │ +
48 float* work, const long int* lwork, long int* info);
│ │ │ │
49
│ │ │ │ -
50 namespace {
│ │ │ │ -
51 /*
│ │ │ │ -
52 templated implementation of different communication classes
│ │ │ │ -
53 */
│ │ │ │ -
54 // the default class will always fail, due to the missing implementation of "sum"
│ │ │ │ -
55 template <class Imp>
│ │ │ │ -
56 struct GenericGuardCommunicator
│ │ │ │ -
57 : public GuardCommunicator
│ │ │ │ -
58 {};
│ │ │ │ -
59 // specialization for Communication
│ │ │ │ -
60 template <class T>
│ │ │ │ -
61 struct GenericGuardCommunicator< Communication<T> >
│ │ │ │ -
62 : public GuardCommunicator
│ │ │ │ -
63 {
│ │ │ │ -
64 const Communication<T> comm;
│ │ │ │ -
65 GenericGuardCommunicator(const Communication<T> & c) :
│ │ │ │ -
66 comm(c) {}
│ │ │ │ -
67 int rank() override { return comm.rank(); };
│ │ │ │ -
68 int size() override { return comm.size(); };
│ │ │ │ -
69 int sum(int i) override { return comm.sum(i); }
│ │ │ │ -
70 };
│ │ │ │ +
50 extern void eigenValuesNonsymLapackCall(
│ │ │ │ +
51 const char* jobvl, const char* jobvr, const long
│ │ │ │ +
52 int* n, float* a, const long int* lda, float* wr, float* wi, float* vl,
│ │ │ │ +
53 const long int* ldvl, float* vr, const long int* ldvr, float* work,
│ │ │ │ +
54 const long int* lwork, long int* info);
│ │ │ │ +
55
│ │ │ │ +
56#endif
│ │ │ │ +
57
│ │ │ │ +
58 namespace Impl {
│ │ │ │ +
59 //internal tag to activate/disable code for eigenvector calculation at compile time
│ │ │ │ +
60 enum Jobs { OnlyEigenvalues=0, EigenvaluesEigenvectors=1 };
│ │ │ │ +
61
│ │ │ │ +
62 //internal dummy used if only eigenvalues are to be calculated
│ │ │ │ +
63 template<typename K, int dim>
│ │ │ │ +
64 using EVDummy = FieldMatrix<K, dim, dim>;
│ │ │ │ +
65
│ │ │ │ +
66 //compute the cross-product of two vectors
│ │ │ │ +
67 template<typename K>
│ │ │ │ +
68 inline FieldVector<K,3> crossProduct(const FieldVector<K,3>& vec0, const FieldVector<K,3>& vec1) {
│ │ │ │ +
69 return {vec0[1]*vec1[2] - vec0[2]*vec1[1], vec0[2]*vec1[0] - vec0[0]*vec1[2], vec0[0]*vec1[1] - vec0[1]*vec1[0]};
│ │ │ │ +
70 }
│ │ │ │
71
│ │ │ │ -
72#if HAVE_MPI
│ │ │ │ -
73 // specialization for MPI_Comm
│ │ │ │ -
74 template <>
│ │ │ │ -
75 struct GenericGuardCommunicator<MPI_Comm>
│ │ │ │ -
76 : public GenericGuardCommunicator< Communication<MPI_Comm> >
│ │ │ │ -
77 {
│ │ │ │ -
78 GenericGuardCommunicator(const MPI_Comm & c) :
│ │ │ │ -
79 GenericGuardCommunicator< Communication<MPI_Comm> >(
│ │ │ │ -
80 Communication<MPI_Comm>(c)) {}
│ │ │ │ -
81 };
│ │ │ │ -
82#endif
│ │ │ │ -
83 } // anonymous namespace
│ │ │ │ -
84
│ │ │ │ -
85 template<class C>
│ │ │ │ -
86 GuardCommunicator * GuardCommunicator::create(const Communication<C> & comm)
│ │ │ │ -
87 {
│ │ │ │ -
88 return new GenericGuardCommunicator< Communication<C> >(comm);
│ │ │ │ -
89 }
│ │ │ │ +
72 template <typename K>
│ │ │ │ +
73 static void eigenValues2dImpl(const FieldMatrix<K, 2, 2>& matrix,
│ │ │ │ +
74 FieldVector<K, 2>& eigenvalues)
│ │ │ │ +
75 {
│ │ │ │ +
76 using std::sqrt;
│ │ │ │ +
77 const K p = 0.5 * (matrix[0][0] + matrix [1][1]);
│ │ │ │ +
78 const K p2 = p - matrix[1][1];
│ │ │ │ +
79 K q = p2 * p2 + matrix[1][0] * matrix[0][1];
│ │ │ │ +
80 if( q < 0 && q > -1e-14 ) q = 0;
│ │ │ │ +
81 if (q < 0)
│ │ │ │ +
82 {
│ │ │ │ +
83 std::cout << matrix << std::endl;
│ │ │ │ +
84 // Complex eigenvalues are either caused by non-symmetric matrices or by round-off errors
│ │ │ │ +
85 DUNE_THROW(MathError, "Complex eigenvalue detected (which this implementation cannot handle).");
│ │ │ │ +
86 }
│ │ │ │ +
87
│ │ │ │ +
88 // get square root
│ │ │ │ +
89 q = sqrt(q);
│ │ │ │
90
│ │ │ │ -
91#if HAVE_MPI
│ │ │ │ -
92 GuardCommunicator * GuardCommunicator::create(const MPI_Comm & comm)
│ │ │ │ -
93 {
│ │ │ │ -
94 return new GenericGuardCommunicator< Communication<MPI_Comm> >(comm);
│ │ │ │ -
95 }
│ │ │ │ -
96#endif
│ │ │ │ -
97
│ │ │ │ -
98#endif
│ │ │ │ -
99
│ │ │ │ -
103 class MPIGuardError : public ParallelError {};
│ │ │ │ -
104
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
138 {
│ │ │ │ -
139 GuardCommunicator * comm_;
│ │ │ │ -
140 bool active_;
│ │ │ │ -
141
│ │ │ │ -
142 // we don't want to copy this class
│ │ │ │ -
143 MPIGuard (const MPIGuard &);
│ │ │ │ -
144
│ │ │ │ -
145 public:
│ │ │ │ -
│ │ │ │ -
150 MPIGuard (bool active=true) :
│ │ │ │ -
151 comm_(GuardCommunicator::create(
│ │ │ │ -
152 MPIHelper::getCommunication())),
│ │ │ │ -
153 active_(active)
│ │ │ │ -
154 {}
│ │ │ │ -
│ │ │ │ -
155
│ │ │ │ -
│ │ │ │ -
161 MPIGuard (MPIHelper & m, bool active=true) :
│ │ │ │ -
162 comm_(GuardCommunicator::create(
│ │ │ │ -
163 m.getCommunication())),
│ │ │ │ -
164 active_(active)
│ │ │ │ -
165 {}
│ │ │ │ -
│ │ │ │ -
166
│ │ │ │ -
177 template <class C>
│ │ │ │ -
│ │ │ │ -
178 MPIGuard (const C & comm, bool active=true) :
│ │ │ │ -
179 comm_(GuardCommunicator::create(comm)),
│ │ │ │ -
180 active_(active)
│ │ │ │ -
181 {}
│ │ │ │ -
│ │ │ │ -
182
│ │ │ │ -
183#if HAVE_MPI
│ │ │ │ -
│ │ │ │ -
184 MPIGuard (const MPI_Comm & comm, bool active=true) :
│ │ │ │ -
185 comm_(GuardCommunicator::create(comm)),
│ │ │ │ -
186 active_(active)
│ │ │ │ -
187 {}
│ │ │ │ -
│ │ │ │ -
188#endif
│ │ │ │ +
91 // store eigenvalues in ascending order
│ │ │ │ +
92 eigenvalues[0] = p - q;
│ │ │ │ +
93 eigenvalues[1] = p + q;
│ │ │ │ +
94 }
│ │ │ │ +
95
│ │ │ │ +
96 /*
│ │ │ │ +
97 This implementation was adapted from the pseudo-code (Python?) implementation found on
│ │ │ │ +
98 http://en.wikipedia.org/wiki/Eigenvalue_algorithm (retrieved late August 2014).
│ │ │ │ +
99 Wikipedia claims to have taken it from
│ │ │ │ +
100 Smith, Oliver K. (April 1961), Eigenvalues of a symmetric 3 × 3 matrix.,
│ │ │ │ +
101 Communications of the ACM 4 (4): 168, doi:10.1145/355578.366316
│ │ │ │ +
102 */
│ │ │ │ +
103 template <typename K>
│ │ │ │ +
104 static K eigenValues3dImpl(const FieldMatrix<K, 3, 3>& matrix,
│ │ │ │ +
105 FieldVector<K, 3>& eigenvalues)
│ │ │ │ +
106 {
│ │ │ │ +
107 using std::sqrt;
│ │ │ │ +
108 using std::acos;
│ │ │ │ +
109 using real_type = typename FieldTraits<K>::real_type;
│ │ │ │ +
110 const K pi = MathematicalConstants<K>::pi();
│ │ │ │ +
111 K p1 = matrix[0][1]*matrix[0][1] + matrix[0][2]*matrix[0][2] + matrix[1][2]*matrix[1][2];
│ │ │ │ +
112
│ │ │ │ +
113 if (p1 <= std::numeric_limits<K>::epsilon()) {
│ │ │ │ +
114 // A is diagonal.
│ │ │ │ +
115 eigenvalues[0] = matrix[0][0];
│ │ │ │ +
116 eigenvalues[1] = matrix[1][1];
│ │ │ │ +
117 eigenvalues[2] = matrix[2][2];
│ │ │ │ +
118 std::sort(eigenvalues.begin(), eigenvalues.end());
│ │ │ │ +
119
│ │ │ │ +
120 return 0.0;
│ │ │ │ +
121 }
│ │ │ │ +
122 else
│ │ │ │ +
123 {
│ │ │ │ +
124 // q = trace(A)/3
│ │ │ │ +
125 K q = 0;
│ │ │ │ +
126 for (int i=0; i<3; i++)
│ │ │ │ +
127 q += matrix[i][i] / 3.0;
│ │ │ │ +
128
│ │ │ │ +
129 K p2 = (matrix[0][0] - q)*(matrix[0][0] - q) + (matrix[1][1] - q)*(matrix[1][1] - q) + (matrix[2][2] - q)*(matrix[2][2] - q) + 2.0 * p1;
│ │ │ │ +
130 K p = sqrt(p2 / 6);
│ │ │ │ +
131 // B = (1 / p) * (A - q * I); // I is the identity matrix
│ │ │ │ +
132 FieldMatrix<K,3,3> B;
│ │ │ │ +
133 for (int i=0; i<3; i++)
│ │ │ │ +
134 for (int j=0; j<3; j++)
│ │ │ │ +
135 B[i][j] = (real_type(1.0)/p) * (matrix[i][j] - q*(i==j));
│ │ │ │ +
136
│ │ │ │ +
137 K r = B.determinant() / 2.0;
│ │ │ │ +
138
│ │ │ │ +
139 /*In exact arithmetic for a symmetric matrix -1 <= r <= 1
│ │ │ │ +
140 but computation error can leave it slightly outside this range.
│ │ │ │ +
141 acos(z) function requires |z| <= 1, but will fail silently
│ │ │ │ +
142 and return NaN if the input is larger than 1 in magnitude.
│ │ │ │ +
143 Thus r is clamped to [-1,1].*/
│ │ │ │ +
144 using std::clamp;
│ │ │ │ +
145 r = clamp<K>(r, -1.0, 1.0);
│ │ │ │ +
146 K phi = acos(r) / 3.0;
│ │ │ │ +
147
│ │ │ │ +
148 // the eigenvalues satisfy eig[2] <= eig[1] <= eig[0]
│ │ │ │ +
149 eigenvalues[2] = q + 2 * p * cos(phi);
│ │ │ │ +
150 eigenvalues[0] = q + 2 * p * cos(phi + (2*pi/3));
│ │ │ │ +
151 eigenvalues[1] = 3 * q - eigenvalues[0] - eigenvalues[2]; // since trace(matrix) = eig1 + eig2 + eig3
│ │ │ │ +
152
│ │ │ │ +
153 return r;
│ │ │ │ +
154 }
│ │ │ │ +
155 }
│ │ │ │ +
156
│ │ │ │ +
157 //see https://www.geometrictools.com/Documentation/RobustEigenSymmetric3x3.pdf
│ │ │ │ +
158 //Robustly compute a right-handed orthonormal set {u, v, evec0}.
│ │ │ │ +
159 template<typename K>
│ │ │ │ +
160 void orthoComp(const FieldVector<K,3>& evec0, FieldVector<K,3>& u, FieldVector<K,3>& v) {
│ │ │ │ +
161 using std::abs;
│ │ │ │ +
162 if(abs(evec0[0]) > abs(evec0[1])) {
│ │ │ │ +
163 //The component of maximum absolute value is either evec0[0] or evec0[2].
│ │ │ │ +
164 FieldVector<K,2> temp = {evec0[0], evec0[2]};
│ │ │ │ +
165 auto L = 1.0 / temp.two_norm();
│ │ │ │ +
166 u = L * FieldVector<K,3>({-evec0[2], 0.0, evec0[0]});
│ │ │ │ +
167 }
│ │ │ │ +
168 else {
│ │ │ │ +
169 //The component of maximum absolute value is either evec0[1] or evec0[2].
│ │ │ │ +
170 FieldVector<K,2> temp = {evec0[1], evec0[2]};
│ │ │ │ +
171 auto L = 1.0 / temp.two_norm();
│ │ │ │ +
172 u = L * FieldVector<K,3>({0.0, evec0[2], -evec0[1]});
│ │ │ │ +
173 }
│ │ │ │ +
174 v = crossProduct(evec0, u);
│ │ │ │ +
175 }
│ │ │ │ +
176
│ │ │ │ +
177 //see https://www.geometrictools.com/Documentation/RobustEigenSymmetric3x3.pdf
│ │ │ │ +
178 template<typename K>
│ │ │ │ +
179 void eig0(const FieldMatrix<K,3,3>& matrix, K eval0, FieldVector<K,3>& evec0) {
│ │ │ │ +
180 /* Compute a unit-length eigenvector for eigenvalue[i0]. The
│ │ │ │ +
181 matrix is rank 2, so two of the rows are linearly independent.
│ │ │ │ +
182 For a robust computation of the eigenvector, select the two
│ │ │ │ +
183 rows whose cross product has largest length of all pairs of
│ │ │ │ +
184 rows. */
│ │ │ │ +
185 using Vector = FieldVector<K,3>;
│ │ │ │ +
186 Vector row0 = {matrix[0][0]-eval0, matrix[0][1], matrix[0][2]};
│ │ │ │ +
187 Vector row1 = {matrix[1][0], matrix[1][1]-eval0, matrix[1][2]};
│ │ │ │ +
188 Vector row2 = {matrix[2][0], matrix[2][1], matrix[2][2]-eval0};
│ │ │ │
189
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
193 {
│ │ │ │ -
194 if (active_)
│ │ │ │ -
195 {
│ │ │ │ -
196 active_ = false;
│ │ │ │ -
197 finalize(false);
│ │ │ │ -
198 }
│ │ │ │ -
199 delete comm_;
│ │ │ │ -
200 }
│ │ │ │ -
│ │ │ │ -
201
│ │ │ │ -
│ │ │ │ -
206 void reactivate() {
│ │ │ │ -
207 if (active_ == true)
│ │ │ │ -
208 finalize();
│ │ │ │ -
209 active_ = true;
│ │ │ │ -
210 }
│ │ │ │ -
│ │ │ │ -
211
│ │ │ │ -
│ │ │ │ -
222 void finalize(bool success = true)
│ │ │ │ -
223 {
│ │ │ │ -
224 int result = success ? 0 : 1;
│ │ │ │ -
225 bool was_active = active_;
│ │ │ │ -
226 active_ = false;
│ │ │ │ -
227 result = comm_->sum(result);
│ │ │ │ -
228 if (result>0 && was_active)
│ │ │ │ -
229 {
│ │ │ │ -
230 DUNE_THROW(MPIGuardError, "Terminating process "
│ │ │ │ -
231 << comm_->rank() << " due to "
│ │ │ │ -
232 << result << " remote error(s)");
│ │ │ │ -
233 }
│ │ │ │ -
234 }
│ │ │ │ -
│ │ │ │ -
235 };
│ │ │ │ -
│ │ │ │ -
236
│ │ │ │ -
237}
│ │ │ │ -
238
│ │ │ │ -
239#endif // DUNE_COMMON_PARALLEL_MPIGUARD_HH
│ │ │ │ -
Helpers for dealing with MPI.
│ │ │ │ -
Implements an utility class that provides collective communication methods for sequential programs.
│ │ │ │ -
Implements an utility class that provides MPI's collective communication methods.
│ │ │ │ -
A few common exception classes.
│ │ │ │ +
190 Vector r0xr1 = crossProduct(row0, row1);
│ │ │ │ +
191 Vector r0xr2 = crossProduct(row0, row2);
│ │ │ │ +
192 Vector r1xr2 = crossProduct(row1, row2);
│ │ │ │ +
193 auto d0 = r0xr1.two_norm();
│ │ │ │ +
194 auto d1 = r0xr2.two_norm();
│ │ │ │ +
195 auto d2 = r1xr2.two_norm();
│ │ │ │ +
196
│ │ │ │ +
197 auto dmax = d0 ;
│ │ │ │ +
198 int imax = 0;
│ │ │ │ +
199 if(d1>dmax) {
│ │ │ │ +
200 dmax = d1;
│ │ │ │ +
201 imax = 1;
│ │ │ │ +
202 }
│ │ │ │ +
203 if(d2>dmax)
│ │ │ │ +
204 imax = 2;
│ │ │ │ +
205
│ │ │ │ +
206 if(imax == 0)
│ │ │ │ +
207 evec0 = r0xr1 / d0;
│ │ │ │ +
208 else if(imax == 1)
│ │ │ │ +
209 evec0 = r0xr2 / d1;
│ │ │ │ +
210 else
│ │ │ │ +
211 evec0 = r1xr2 / d2;
│ │ │ │ +
212 }
│ │ │ │ +
213
│ │ │ │ +
214 //see https://www.geometrictools.com/Documentation/RobustEigenSymmetric3x3.pdf
│ │ │ │ +
215 template<typename K>
│ │ │ │ +
216 void eig1(const FieldMatrix<K,3,3>& matrix, const FieldVector<K,3>& evec0, FieldVector<K,3>& evec1, K eval1) {
│ │ │ │ +
217 using Vector = FieldVector<K,3>;
│ │ │ │ +
218
│ │ │ │ +
219 //Robustly compute a right-handed orthonormal set {u, v, evec0}.
│ │ │ │ +
220 Vector u,v;
│ │ │ │ +
221 orthoComp(evec0, u, v);
│ │ │ │ +
222
│ │ │ │ +
223 /* Let e be eval1 and let E be a corresponding eigenvector which
│ │ │ │ +
224 is a solution to the linear system (A - e*I)*E = 0. The matrix
│ │ │ │ +
225 (A - e*I) is 3x3, not invertible (so infinitely many
│ │ │ │ +
226 solutions), and has rank 2 when eval1 and eval are different.
│ │ │ │ +
227 It has rank 1 when eval1 and eval2 are equal. Numerically, it
│ │ │ │ +
228 is difficult to compute robustly the rank of a matrix. Instead,
│ │ │ │ +
229 the 3x3 linear system is reduced to a 2x2 system as follows.
│ │ │ │ +
230 Define the 3x2 matrix J = [u,v] whose columns are the u and v
│ │ │ │ +
231 computed previously. Define the 2x1 vector X = J*E. The 2x2
│ │ │ │ +
232 system is 0 = M * X = (J^T * (A - e*I) * J) * X where J^T is
│ │ │ │ +
233 the transpose of J and M = J^T * (A - e*I) * J is a 2x2 matrix.
│ │ │ │ +
234 The system may be written as
│ │ │ │ +
235 +- -++- -+ +- -+
│ │ │ │ +
236 | U^T*A*U - e U^T*A*V || x0 | = e * | x0 |
│ │ │ │ +
237 | V^T*A*U V^T*A*V - e || x1 | | x1 |
│ │ │ │ +
238 +- -++ -+ +- -+
│ │ │ │ +
239 where X has row entries x0 and x1. */
│ │ │ │ +
240
│ │ │ │ +
241 Vector Au, Av;
│ │ │ │ +
242 matrix.mv(u, Au);
│ │ │ │ +
243 matrix.mv(v, Av);
│ │ │ │ +
244
│ │ │ │ +
245 auto m00 = u.dot(Au) - eval1;
│ │ │ │ +
246 auto m01 = u.dot(Av);
│ │ │ │ +
247 auto m11 = v.dot(Av) - eval1;
│ │ │ │ +
248
│ │ │ │ +
249 /* For robustness, choose the largest-length row of M to compute
│ │ │ │ +
250 the eigenvector. The 2-tuple of coefficients of U and V in the
│ │ │ │ +
251 assignments to eigenvector[1] lies on a circle, and U and V are
│ │ │ │ +
252 unit length and perpendicular, so eigenvector[1] is unit length
│ │ │ │ +
253 (within numerical tolerance). */
│ │ │ │ +
254 using std::abs, std::sqrt, std::max;
│ │ │ │ +
255 auto absM00 = abs(m00);
│ │ │ │ +
256 auto absM01 = abs(m01);
│ │ │ │ +
257 auto absM11 = abs(m11);
│ │ │ │ +
258 if(absM00 >= absM11) {
│ │ │ │ +
259 auto maxAbsComp = max(absM00, absM01);
│ │ │ │ +
260 if(maxAbsComp > 0.0) {
│ │ │ │ +
261 if(absM00 >= absM01) {
│ │ │ │ +
262 m01 /= m00;
│ │ │ │ +
263 m00 = 1.0 / sqrt(1.0 + m01*m01);
│ │ │ │ +
264 m01 *= m00;
│ │ │ │ +
265 }
│ │ │ │ +
266 else {
│ │ │ │ +
267 m00 /= m01;
│ │ │ │ +
268 m01 = 1.0 / sqrt(1.0 + m00*m00);
│ │ │ │ +
269 m00 *= m01;
│ │ │ │ +
270 }
│ │ │ │ +
271 evec1 = m01*u - m00*v;
│ │ │ │ +
272 }
│ │ │ │ +
273 else
│ │ │ │ +
274 evec1 = u;
│ │ │ │ +
275 }
│ │ │ │ +
276 else {
│ │ │ │ +
277 auto maxAbsComp = max(absM11, absM01);
│ │ │ │ +
278 if(maxAbsComp > 0.0) {
│ │ │ │ +
279 if(absM11 >= absM01) {
│ │ │ │ +
280 m01 /= m11;
│ │ │ │ +
281 m11 = 1.0 / sqrt(1.0 + m01*m01);
│ │ │ │ +
282 m01 *= m11;
│ │ │ │ +
283 }
│ │ │ │ +
284 else {
│ │ │ │ +
285 m11 /= m01;
│ │ │ │ +
286 m01 = 1.0 / sqrt(1.0 + m11*m11);
│ │ │ │ +
287 m11 *= m01;
│ │ │ │ +
288 }
│ │ │ │ +
289 evec1 = m11*u - m01*v;
│ │ │ │ +
290 }
│ │ │ │ +
291 else
│ │ │ │ +
292 evec1 = u;
│ │ │ │ +
293 }
│ │ │ │ +
294 }
│ │ │ │ +
295
│ │ │ │ +
296 // 1d specialization
│ │ │ │ +
297 template<Jobs Tag, typename K>
│ │ │ │ +
298 static void eigenValuesVectorsImpl(const FieldMatrix<K, 1, 1>& matrix,
│ │ │ │ +
299 FieldVector<K, 1>& eigenValues,
│ │ │ │ +
300 FieldMatrix<K, 1, 1>& eigenVectors)
│ │ │ │ +
301 {
│ │ │ │ +
302 eigenValues[0] = matrix[0][0];
│ │ │ │ +
303 if constexpr(Tag==EigenvaluesEigenvectors)
│ │ │ │ +
304 eigenVectors[0] = {1.0};
│ │ │ │ +
305 }
│ │ │ │ +
306
│ │ │ │ +
307
│ │ │ │ +
308 // 2d specialization
│ │ │ │ +
309 template <Jobs Tag, typename K>
│ │ │ │ +
310 static void eigenValuesVectorsImpl(const FieldMatrix<K, 2, 2>& matrix,
│ │ │ │ +
311 FieldVector<K, 2>& eigenValues,
│ │ │ │ +
312 FieldMatrix<K, 2, 2>& eigenVectors)
│ │ │ │ +
313 {
│ │ │ │ +
314 // Compute eigen values
│ │ │ │ +
315 Impl::eigenValues2dImpl(matrix, eigenValues);
│ │ │ │ +
316
│ │ │ │ +
317 // Compute eigenvectors by exploiting the Cayley–Hamilton theorem.
│ │ │ │ +
318 // If λ_1, λ_2 are the eigenvalues, then (A - λ_1I )(A - λ_2I ) = (A - λ_2I )(A - λ_1I ) = 0,
│ │ │ │ +
319 // so the columns of (A - λ_2I ) are annihilated by (A - λ_1I ) and vice versa.
│ │ │ │ +
320 // Assuming neither matrix is zero, the columns of each must include eigenvectors
│ │ │ │ +
321 // for the other eigenvalue. (If either matrix is zero, then A is a multiple of the
│ │ │ │ +
322 // identity and any non-zero vector is an eigenvector.)
│ │ │ │ +
323 // From: https://en.wikipedia.org/wiki/Eigenvalue_algorithm#2x2_matrices
│ │ │ │ +
324 if constexpr(Tag==EigenvaluesEigenvectors) {
│ │ │ │ +
325
│ │ │ │ +
326 // Special casing for multiples of the identity
│ │ │ │ +
327 FieldMatrix<K,2,2> temp = matrix;
│ │ │ │ +
328 temp[0][0] -= eigenValues[0];
│ │ │ │ +
329 temp[1][1] -= eigenValues[0];
│ │ │ │ +
330 if(temp.infinity_norm() <= 1e-14) {
│ │ │ │ +
331 eigenVectors[0] = {1.0, 0.0};
│ │ │ │ +
332 eigenVectors[1] = {0.0, 1.0};
│ │ │ │ +
333 }
│ │ │ │ +
334 else {
│ │ │ │ +
335 // The columns of A - λ_2I are eigenvectors for λ_1, or zero.
│ │ │ │ +
336 // Take the column with the larger norm to avoid zero columns.
│ │ │ │ +
337 FieldVector<K,2> ev0 = {matrix[0][0]-eigenValues[1], matrix[1][0]};
│ │ │ │ +
338 FieldVector<K,2> ev1 = {matrix[0][1], matrix[1][1]-eigenValues[1]};
│ │ │ │ +
339 eigenVectors[0] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm() : ev1/ev1.two_norm();
│ │ │ │ +
340
│ │ │ │ +
341 // The columns of A - λ_1I are eigenvectors for λ_2, or zero.
│ │ │ │ +
342 // Take the column with the larger norm to avoid zero columns.
│ │ │ │ +
343 ev0 = {matrix[0][0]-eigenValues[0], matrix[1][0]};
│ │ │ │ +
344 ev1 = {matrix[0][1], matrix[1][1]-eigenValues[0]};
│ │ │ │ +
345 eigenVectors[1] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm() : ev1/ev1.two_norm();
│ │ │ │ +
346 }
│ │ │ │ +
347 }
│ │ │ │ +
348 }
│ │ │ │ +
349
│ │ │ │ +
350 // 3d specialization
│ │ │ │ +
351 template <Jobs Tag, typename K>
│ │ │ │ +
352 static void eigenValuesVectorsImpl(const FieldMatrix<K, 3, 3>& matrix,
│ │ │ │ +
353 FieldVector<K, 3>& eigenValues,
│ │ │ │ +
354 FieldMatrix<K, 3, 3>& eigenVectors)
│ │ │ │ +
355 {
│ │ │ │ +
356 using Vector = FieldVector<K,3>;
│ │ │ │ +
357 using Matrix = FieldMatrix<K,3,3>;
│ │ │ │ +
358
│ │ │ │ +
359 //compute eigenvalues
│ │ │ │ +
360 /* Precondition the matrix by factoring out the maximum absolute
│ │ │ │ +
361 value of the components. This guards against floating-point
│ │ │ │ +
362 overflow when computing the eigenvalues.*/
│ │ │ │ +
363 using std::isnormal;
│ │ │ │ +
364 K maxAbsElement = (isnormal(matrix.infinity_norm())) ? matrix.infinity_norm() : K(1.0);
│ │ │ │ +
365 Matrix scaledMatrix = matrix / maxAbsElement;
│ │ │ │ +
366 K r = Impl::eigenValues3dImpl(scaledMatrix, eigenValues);
│ │ │ │ +
367
│ │ │ │ +
368 if constexpr(Tag==EigenvaluesEigenvectors) {
│ │ │ │ +
369 K offDiagNorm = Vector{scaledMatrix[0][1],scaledMatrix[0][2],scaledMatrix[1][2]}.two_norm2();
│ │ │ │ +
370 if (offDiagNorm <= std::numeric_limits<K>::epsilon())
│ │ │ │ +
371 {
│ │ │ │ +
372 eigenValues = {scaledMatrix[0][0], scaledMatrix[1][1], scaledMatrix[2][2]};
│ │ │ │ +
373 eigenVectors = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}};
│ │ │ │ +
374
│ │ │ │ +
375 // Use bubble sort to jointly sort eigenvalues and eigenvectors
│ │ │ │ +
376 // such that eigenvalues are ascending
│ │ │ │ +
377 if (eigenValues[0] > eigenValues[1])
│ │ │ │ +
378 {
│ │ │ │ +
379 std::swap(eigenValues[0], eigenValues[1]);
│ │ │ │ +
380 std::swap(eigenVectors[0], eigenVectors[1]);
│ │ │ │ +
381 }
│ │ │ │ +
382 if (eigenValues[1] > eigenValues[2])
│ │ │ │ +
383 {
│ │ │ │ +
384 std::swap(eigenValues[1], eigenValues[2]);
│ │ │ │ +
385 std::swap(eigenVectors[1], eigenVectors[2]);
│ │ │ │ +
386 }
│ │ │ │ +
387 if (eigenValues[0] > eigenValues[1])
│ │ │ │ +
388 {
│ │ │ │ +
389 std::swap(eigenValues[0], eigenValues[1]);
│ │ │ │ +
390 std::swap(eigenVectors[0], eigenVectors[1]);
│ │ │ │ +
391 }
│ │ │ │ +
392 }
│ │ │ │ +
393 else {
│ │ │ │ +
394 /*Compute the eigenvectors so that the set
│ │ │ │ +
395 [evec[0], evec[1], evec[2]] is right handed and
│ │ │ │ +
396 orthonormal. */
│ │ │ │ +
397
│ │ │ │ +
398 Matrix evec(0.0);
│ │ │ │ +
399 Vector eval(eigenValues);
│ │ │ │ +
400 if(r >= 0) {
│ │ │ │ +
401 Impl::eig0(scaledMatrix, eval[2], evec[2]);
│ │ │ │ +
402 Impl::eig1(scaledMatrix, evec[2], evec[1], eval[1]);
│ │ │ │ +
403 evec[0] = Impl::crossProduct(evec[1], evec[2]);
│ │ │ │ +
404 }
│ │ │ │ +
405 else {
│ │ │ │ +
406 Impl::eig0(scaledMatrix, eval[0], evec[0]);
│ │ │ │ +
407 Impl::eig1(scaledMatrix, evec[0], evec[1], eval[1]);
│ │ │ │ +
408 evec[2] = Impl::crossProduct(evec[0], evec[1]);
│ │ │ │ +
409 }
│ │ │ │ +
410 //sort eval/evec-pairs in ascending order
│ │ │ │ +
411 using EVPair = std::pair<K, Vector>;
│ │ │ │ +
412 std::vector<EVPair> pairs;
│ │ │ │ +
413 for(std::size_t i=0; i<=2; ++i)
│ │ │ │ +
414 pairs.push_back(EVPair(eval[i], evec[i]));
│ │ │ │ +
415 auto comp = [](EVPair x, EVPair y){ return x.first < y.first; };
│ │ │ │ +
416 std::sort(pairs.begin(), pairs.end(), comp);
│ │ │ │ +
417 for(std::size_t i=0; i<=2; ++i){
│ │ │ │ +
418 eigenValues[i] = pairs[i].first;
│ │ │ │ +
419 eigenVectors[i] = pairs[i].second;
│ │ │ │ +
420 }
│ │ │ │ +
421 }
│ │ │ │ +
422 }
│ │ │ │ +
423 //The preconditioning scaled the matrix, which scales the eigenvalues. Revert the scaling.
│ │ │ │ +
424 eigenValues *= maxAbsElement;
│ │ │ │ +
425 }
│ │ │ │ +
426
│ │ │ │ +
427 // forwarding to LAPACK with corresponding tag
│ │ │ │ +
428 template <Jobs Tag, int dim, typename K>
│ │ │ │ +
429 static void eigenValuesVectorsLapackImpl(const FieldMatrix<K, dim, dim>& matrix,
│ │ │ │ +
430 FieldVector<K, dim>& eigenValues,
│ │ │ │ +
431 FieldMatrix<K, dim, dim>& eigenVectors)
│ │ │ │ +
432 {
│ │ │ │ +
433 {
│ │ │ │ +
434#if HAVE_LAPACK
│ │ │ │ +
435 /*Lapack uses a proprietary tag to determine whether both eigenvalues and
│ │ │ │ +
436 -vectors ('v') or only eigenvalues ('n') should be calculated */
│ │ │ │ +
437 const char jobz = "nv"[Tag];
│ │ │ │ +
438
│ │ │ │ +
439 const long int N = dim ;
│ │ │ │ +
440 const char uplo = 'u'; // use upper triangular matrix
│ │ │ │ +
441
│ │ │ │ +
442 // length of matrix vector, LWORK >= max(1,3*N-1)
│ │ │ │ +
443 const long int lwork = 3*N -1 ;
│ │ │ │ +
444
│ │ │ │ +
445 constexpr bool isKLapackType = std::is_same_v<K,double> || std::is_same_v<K,float>;
│ │ │ │ +
446 using LapackNumType = std::conditional_t<isKLapackType, K, double>;
│ │ │ │ +
447
│ │ │ │ +
448 // matrix to put into dsyev
│ │ │ │ +
449 LapackNumType matrixVector[dim * dim];
│ │ │ │ +
450
│ │ │ │ +
451 // copy matrix
│ │ │ │ +
452 int row = 0;
│ │ │ │ +
453 for(int i=0; i<dim; ++i)
│ │ │ │ +
454 {
│ │ │ │ +
455 for(int j=0; j<dim; ++j, ++row)
│ │ │ │ +
456 {
│ │ │ │ +
457 matrixVector[ row ] = matrix[ i ][ j ];
│ │ │ │ +
458 }
│ │ │ │ +
459 }
│ │ │ │ +
460
│ │ │ │ +
461 // working memory
│ │ │ │ +
462 LapackNumType workSpace[lwork];
│ │ │ │ +
463
│ │ │ │ +
464 // return value information
│ │ │ │ +
465 long int info = 0;
│ │ │ │ +
466 LapackNumType* ev;
│ │ │ │ +
467 if constexpr (isKLapackType){
│ │ │ │ +
468 ev = &eigenValues[0];
│ │ │ │ +
469 }else{
│ │ │ │ +
470 ev = new LapackNumType[dim];
│ │ │ │ +
471 }
│ │ │ │ +
472
│ │ │ │ +
473 // call LAPACK routine (see fmatrixev.cc)
│ │ │ │ +
474 eigenValuesLapackCall(&jobz, &uplo, &N, &matrixVector[0], &N,
│ │ │ │ +
475 ev, &workSpace[0], &lwork, &info);
│ │ │ │ +
476
│ │ │ │ +
477 if constexpr (!isKLapackType){
│ │ │ │ +
478 for(size_t i=0;i<dim;++i)
│ │ │ │ +
479 eigenValues[i] = ev[i];
│ │ │ │ +
480 delete[] ev;
│ │ │ │ +
481 }
│ │ │ │ +
482
│ │ │ │ +
483 // restore eigenvectors matrix
│ │ │ │ +
484 if (Tag==Jobs::EigenvaluesEigenvectors){
│ │ │ │ +
485 row = 0;
│ │ │ │ +
486 for(int i=0; i<dim; ++i)
│ │ │ │ +
487 {
│ │ │ │ +
488 for(int j=0; j<dim; ++j, ++row)
│ │ │ │ +
489 {
│ │ │ │ +
490 eigenVectors[ i ][ j ] = matrixVector[ row ];
│ │ │ │ +
491 }
│ │ │ │ +
492 }
│ │ │ │ +
493 }
│ │ │ │ +
494
│ │ │ │ +
495 if( info != 0 )
│ │ │ │ +
496 {
│ │ │ │ +
497 std::cerr << "For matrix " << matrix << " eigenvalue calculation failed! " << std::endl;
│ │ │ │ +
498 DUNE_THROW(InvalidStateException,"eigenValues: Eigenvalue calculation failed!");
│ │ │ │ +
499 }
│ │ │ │ +
500#else
│ │ │ │ +
501 DUNE_THROW(NotImplemented,"LAPACK not found!");
│ │ │ │ +
502#endif
│ │ │ │ +
503 }
│ │ │ │ +
504 }
│ │ │ │ +
505
│ │ │ │ +
506 // generic specialization
│ │ │ │ +
507 template <Jobs Tag, int dim, typename K>
│ │ │ │ +
508 static void eigenValuesVectorsImpl(const FieldMatrix<K, dim, dim>& matrix,
│ │ │ │ +
509 FieldVector<K, dim>& eigenValues,
│ │ │ │ +
510 FieldMatrix<K, dim, dim>& eigenVectors)
│ │ │ │ +
511 {
│ │ │ │ +
512 eigenValuesVectorsLapackImpl<Tag>(matrix,eigenValues,eigenVectors);
│ │ │ │ +
513 }
│ │ │ │ +
514 } //namespace Impl
│ │ │ │ +
515
│ │ │ │ +
523 template <int dim, typename K>
│ │ │ │ +
│ │ │ │ +
524 static void eigenValues(const FieldMatrix<K, dim, dim>& matrix,
│ │ │ │ + │ │ │ │ +
526 {
│ │ │ │ + │ │ │ │ +
528 Impl::eigenValuesVectorsImpl<Impl::Jobs::OnlyEigenvalues>(matrix, eigenValues, dummy);
│ │ │ │ +
529 }
│ │ │ │ +
│ │ │ │ +
530
│ │ │ │ +
539 template <int dim, typename K>
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ +
542 FieldMatrix<K, dim, dim>& eigenVectors)
│ │ │ │ +
543 {
│ │ │ │ +
544 Impl::eigenValuesVectorsImpl<Impl::Jobs::EigenvaluesEigenvectors>(matrix, eigenValues, eigenVectors);
│ │ │ │ +
545 }
│ │ │ │ +
│ │ │ │ +
546
│ │ │ │ +
554 template <int dim, typename K>
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ +
557 {
│ │ │ │ + │ │ │ │ +
559 Impl::eigenValuesVectorsLapackImpl<Impl::Jobs::EigenvaluesEigenvectors>(matrix, eigenValues, dummy);
│ │ │ │ +
560 }
│ │ │ │ +
│ │ │ │ +
561
│ │ │ │ +
570 template <int dim, typename K>
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ +
573 FieldMatrix<K, dim, dim>& eigenVectors)
│ │ │ │ +
574 {
│ │ │ │ +
575 Impl::eigenValuesVectorsLapackImpl<Impl::Jobs::EigenvaluesEigenvectors>(matrix, eigenValues, eigenVectors);
│ │ │ │ +
576 }
│ │ │ │ +
│ │ │ │ +
577
│ │ │ │ +
585 template <int dim, typename K, class C>
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ +
588 {
│ │ │ │ +
589#if HAVE_LAPACK
│ │ │ │ +
590 {
│ │ │ │ +
591 const long int N = dim ;
│ │ │ │ +
592 const char jobvl = 'n';
│ │ │ │ +
593 const char jobvr = 'n';
│ │ │ │ +
594
│ │ │ │ +
595 constexpr bool isKLapackType = std::is_same_v<K,double> || std::is_same_v<K,float>;
│ │ │ │ +
596 using LapackNumType = std::conditional_t<isKLapackType, K, double>;
│ │ │ │ +
597
│ │ │ │ +
598 // matrix to put into dgeev
│ │ │ │ +
599 LapackNumType matrixVector[dim * dim];
│ │ │ │ +
600
│ │ │ │ +
601 // copy matrix
│ │ │ │ +
602 int row = 0;
│ │ │ │ +
603 for(int i=0; i<dim; ++i)
│ │ │ │ +
604 {
│ │ │ │ +
605 for(int j=0; j<dim; ++j, ++row)
│ │ │ │ +
606 {
│ │ │ │ +
607 matrixVector[ row ] = matrix[ i ][ j ];
│ │ │ │ +
608 }
│ │ │ │ +
609 }
│ │ │ │ +
610
│ │ │ │ +
611 // working memory
│ │ │ │ +
612 LapackNumType eigenR[dim];
│ │ │ │ +
613 LapackNumType eigenI[dim];
│ │ │ │ +
614 LapackNumType work[3*dim];
│ │ │ │ +
615
│ │ │ │ +
616 // return value information
│ │ │ │ +
617 long int info = 0;
│ │ │ │ +
618 const long int lwork = 3*dim;
│ │ │ │ +
619
│ │ │ │ +
620 // call LAPACK routine (see fmatrixev_ext.cc)
│ │ │ │ +
621 eigenValuesNonsymLapackCall(&jobvl, &jobvr, &N, &matrixVector[0], &N,
│ │ │ │ +
622 &eigenR[0], &eigenI[0], nullptr, &N, nullptr, &N, &work[0],
│ │ │ │ +
623 &lwork, &info);
│ │ │ │ +
624
│ │ │ │ +
625 if( info != 0 )
│ │ │ │ +
626 {
│ │ │ │ +
627 std::cerr << "For matrix " << matrix << " eigenvalue calculation failed! " << std::endl;
│ │ │ │ +
628 DUNE_THROW(InvalidStateException,"eigenValues: Eigenvalue calculation failed!");
│ │ │ │ +
629 }
│ │ │ │ +
630 for (int i=0; i<N; ++i) {
│ │ │ │ +
631 eigenValues[i].real = eigenR[i];
│ │ │ │ +
632 eigenValues[i].imag = eigenI[i];
│ │ │ │ +
633 }
│ │ │ │ +
634 }
│ │ │ │ +
635#else
│ │ │ │ +
636 DUNE_THROW(NotImplemented,"LAPACK not found!");
│ │ │ │ +
637#endif
│ │ │ │ +
638 }
│ │ │ │ +
│ │ │ │ +
639 } // end namespace FMatrixHelp
│ │ │ │ +
640
│ │ │ │ +
643} // end namespace Dune
│ │ │ │ +
644#endif
│ │ │ │ +
A few common exception classes.
│ │ │ │ +
Implements a matrix constructed from a given type representing a field and compile-time given number ...
│ │ │ │ +
Some useful basic math stuff.
│ │ │ │ +
Implements a vector constructed from a given type representing a field and a compile-time given size.
│ │ │ │ +
constexpr auto max
Function object that returns the greater of the given values.
Definition hybridutilities.hh:484
│ │ │ │
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Default exception if an error in the parallel communication of the program occurred.
Definition exceptions.hh:287
│ │ │ │ -
This exception is thrown if the MPIGuard detects an error on a remote process.
Definition mpiguard.hh:103
│ │ │ │ -
detects a thrown exception and communicates to all other processes
Definition mpiguard.hh:138
│ │ │ │ -
void reactivate()
reactivate the guard.
Definition mpiguard.hh:206
│ │ │ │ -
void finalize(bool success=true)
stop the guard.
Definition mpiguard.hh:222
│ │ │ │ -
~MPIGuard()
destroy the guard and check for undetected exceptions
Definition mpiguard.hh:192
│ │ │ │ -
MPIGuard(const C &comm, bool active=true)
create an MPIGuard operating on an arbitrary communicator.
Definition mpiguard.hh:178
│ │ │ │ -
MPIGuard(const MPI_Comm &comm, bool active=true)
Definition mpiguard.hh:184
│ │ │ │ -
MPIGuard(bool active=true)
create an MPIGuard operating on the Communicator of the global Dune::MPIHelper
Definition mpiguard.hh:150
│ │ │ │ -
MPIGuard(MPIHelper &m, bool active=true)
create an MPIGuard operating on the Communicator of a special Dune::MPIHelper m
Definition mpiguard.hh:161
│ │ │ │ -
A real mpi helper.
Definition mpihelper.hh:181
│ │ │ │ +
static void eigenValuesNonSym(const FieldMatrix< K, dim, dim > &matrix, FieldVector< C, dim > &eigenValues)
calculates the eigenvalues of a non-symmetric field matrix
Definition fmatrixev.hh:586
│ │ │ │ +
static void eigenValues(const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues)
calculates the eigenvalues of a symmetric field matrix
Definition fmatrixev.hh:524
│ │ │ │ +
static void eigenValuesLapack(const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues)
calculates the eigenvalues of a symmetric field matrix
Definition fmatrixev.hh:555
│ │ │ │ +
static void eigenValuesVectors(const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors)
calculates the eigenvalues and eigenvectors of a symmetric field matrix
Definition fmatrixev.hh:540
│ │ │ │ +
static void eigenValuesVectorsLapack(const FieldMatrix< K, dim, dim > &matrix, FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors)
calculates the eigenvalues and -vectors of a symmetric field matrix
Definition fmatrixev.hh:571
│ │ │ │ +
A dense n x m matrix.
Definition fmatrix.hh:117
│ │ │ │ +
vector space out of a tensor product of fields.
Definition fvector.hh:91
│ │ │ │ +
Default exception for dummy implementations.
Definition exceptions.hh:263
│ │ │ │ +
Default exception if a function was called while the object is not in a valid state for that function...
Definition exceptions.hh:281
│ │ │ │ +
T real_type
export the type representing the real type of the field
Definition ftraits.hh:30
│ │ │ │ +
static const Field pi()
Archimedes' constant.
Definition math.hh:48
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,231 +1,710 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -mpiguard.hh │ │ │ │ │ +fmatrixev.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5 │ │ │ │ │ -13#ifndef DUNE_COMMON_PARALLEL_MPIGUARD_HH │ │ │ │ │ -14#define DUNE_COMMON_PARALLEL_MPIGUARD_HH │ │ │ │ │ -15 │ │ │ │ │ -16#if HAVE_MPI │ │ │ │ │ -17#include │ │ │ │ │ -18#endif │ │ │ │ │ -19 │ │ │ │ │ -20#include │ │ │ │ │ -21#include │ │ │ │ │ -22#include │ │ │ │ │ -23#include │ │ │ │ │ +5#ifndef DUNE_FMATRIXEIGENVALUES_HH │ │ │ │ │ +6#define DUNE_FMATRIXEIGENVALUES_HH │ │ │ │ │ +7 │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14#include │ │ │ │ │ +15#include │ │ │ │ │ +16 │ │ │ │ │ +17#include // HAVE_LAPACK │ │ │ │ │ +18#include │ │ │ │ │ +19#include │ │ │ │ │ +20#include │ │ │ │ │ +21#include │ │ │ │ │ +22 │ │ │ │ │ +23namespace Dune { │ │ │ │ │ 24 │ │ │ │ │ -25namespace Dune │ │ │ │ │ -26{ │ │ │ │ │ -27 │ │ │ │ │ -28#ifndef DOXYGEN │ │ │ │ │ -29 │ │ │ │ │ -30 /* │ │ │ │ │ -31 Interface class for the communication needed by MPIGuard │ │ │ │ │ -32 */ │ │ │ │ │ -33 struct GuardCommunicator │ │ │ │ │ -34 { │ │ │ │ │ -35 // cleanup │ │ │ │ │ -36 virtual ~GuardCommunicator() {}; │ │ │ │ │ -37 // all the communication methods we need │ │ │ │ │ -38 virtual int rank() = 0; │ │ │ │ │ -39 virtual int size() = 0; │ │ │ │ │ -40 virtual int sum(int i) = 0; │ │ │ │ │ -41 // create a new GuardCommunicator pointer │ │ │ │ │ -42 template │ │ │ │ │ -43 static GuardCommunicator * create(const Communication & c); │ │ │ │ │ -44#if HAVE_MPI │ │ │ │ │ -45 inline │ │ │ │ │ -46 static GuardCommunicator * create(const MPI_Comm & c); │ │ │ │ │ -47#endif │ │ │ │ │ -48 }; │ │ │ │ │ +30 namespace FMatrixHelp { │ │ │ │ │ +31 │ │ │ │ │ +32#if HAVE_LAPACK │ │ │ │ │ +33 // defined in fmatrixev.cc │ │ │ │ │ +34 extern void eigenValuesLapackCall( │ │ │ │ │ +35 const char* jobz, const char* uplo, const long │ │ │ │ │ +36 int* n, double* a, const long int* lda, double* w, │ │ │ │ │ +37 double* work, const long int* lwork, long int* info); │ │ │ │ │ +38 │ │ │ │ │ +39 extern void eigenValuesNonsymLapackCall( │ │ │ │ │ +40 const char* jobvl, const char* jobvr, const long │ │ │ │ │ +41 int* n, double* a, const long int* lda, double* wr, double* wi, double* vl, │ │ │ │ │ +42 const long int* ldvl, double* vr, const long int* ldvr, double* work, │ │ │ │ │ +43 const long int* lwork, long int* info); │ │ │ │ │ +44 │ │ │ │ │ +45 extern void eigenValuesLapackCall( │ │ │ │ │ +46 const char* jobz, const char* uplo, const long │ │ │ │ │ +47 int* n, float* a, const long int* lda, float* w, │ │ │ │ │ +48 float* work, const long int* lwork, long int* info); │ │ │ │ │ 49 │ │ │ │ │ -50 namespace { │ │ │ │ │ -51 /* │ │ │ │ │ -52 templated implementation of different communication classes │ │ │ │ │ -53 */ │ │ │ │ │ -54 // the default class will always fail, due to the missing implementation of │ │ │ │ │ -"sum" │ │ │ │ │ -55 template │ │ │ │ │ -56 struct GenericGuardCommunicator │ │ │ │ │ -57 : public GuardCommunicator │ │ │ │ │ -58 {}; │ │ │ │ │ -59 // specialization for Communication │ │ │ │ │ -60 template │ │ │ │ │ -61 struct GenericGuardCommunicator< Communication > │ │ │ │ │ -62 : public GuardCommunicator │ │ │ │ │ -63 { │ │ │ │ │ -64 const Communication comm; │ │ │ │ │ -65 GenericGuardCommunicator(const Communication & c) : │ │ │ │ │ -66 comm(c) {} │ │ │ │ │ -67 int rank() override { return comm.rank(); }; │ │ │ │ │ -68 int size() override { return comm.size(); }; │ │ │ │ │ -69 int sum(int i) override { return comm.sum(i); } │ │ │ │ │ -70 }; │ │ │ │ │ +50 extern void eigenValuesNonsymLapackCall( │ │ │ │ │ +51 const char* jobvl, const char* jobvr, const long │ │ │ │ │ +52 int* n, float* a, const long int* lda, float* wr, float* wi, float* vl, │ │ │ │ │ +53 const long int* ldvl, float* vr, const long int* ldvr, float* work, │ │ │ │ │ +54 const long int* lwork, long int* info); │ │ │ │ │ +55 │ │ │ │ │ +56#endif │ │ │ │ │ +57 │ │ │ │ │ +58 namespace Impl { │ │ │ │ │ +59 //internal tag to activate/disable code for eigenvector calculation at │ │ │ │ │ +compile time │ │ │ │ │ +60 enum Jobs { OnlyEigenvalues=0, EigenvaluesEigenvectors=1 }; │ │ │ │ │ +61 │ │ │ │ │ +62 //internal dummy used if only eigenvalues are to be calculated │ │ │ │ │ +63 template │ │ │ │ │ +64 using EVDummy = FieldMatrix; │ │ │ │ │ +65 │ │ │ │ │ +66 //compute the cross-product of two vectors │ │ │ │ │ +67 template │ │ │ │ │ +68 inline FieldVector crossProduct(const FieldVector& vec0, const │ │ │ │ │ +FieldVector& vec1) { │ │ │ │ │ +69 return {vec0[1]*vec1[2] - vec0[2]*vec1[1], vec0[2]*vec1[0] - vec0[0]*vec1 │ │ │ │ │ +[2], vec0[0]*vec1[1] - vec0[1]*vec1[0]}; │ │ │ │ │ +70 } │ │ │ │ │ 71 │ │ │ │ │ -72#if HAVE_MPI │ │ │ │ │ -73 // specialization for MPI_Comm │ │ │ │ │ -74 template <> │ │ │ │ │ -75 struct GenericGuardCommunicator │ │ │ │ │ -76 : public GenericGuardCommunicator< Communication > │ │ │ │ │ -77 { │ │ │ │ │ -78 GenericGuardCommunicator(const MPI_Comm & c) : │ │ │ │ │ -79 GenericGuardCommunicator< Communication >( │ │ │ │ │ -80 Communication(c)) {} │ │ │ │ │ -81 }; │ │ │ │ │ -82#endif │ │ │ │ │ -83 } // anonymous namespace │ │ │ │ │ -84 │ │ │ │ │ -85 template │ │ │ │ │ -86 GuardCommunicator * GuardCommunicator::create(const Communication & comm) │ │ │ │ │ -87 { │ │ │ │ │ -88 return new GenericGuardCommunicator< Communication >(comm); │ │ │ │ │ -89 } │ │ │ │ │ +72 template │ │ │ │ │ +73 static void eigenValues2dImpl(const FieldMatrix& matrix, │ │ │ │ │ +74 FieldVector& eigenvalues) │ │ │ │ │ +75 { │ │ │ │ │ +76 using std::sqrt; │ │ │ │ │ +77 const K p = 0.5 * (matrix[0][0] + matrix [1][1]); │ │ │ │ │ +78 const K p2 = p - matrix[1][1]; │ │ │ │ │ +79 K q = p2 * p2 + matrix[1][0] * matrix[0][1]; │ │ │ │ │ +80 if( q < 0 && q > -1e-14 ) q = 0; │ │ │ │ │ +81 if (q < 0) │ │ │ │ │ +82 { │ │ │ │ │ +83 std::cout << matrix << std::endl; │ │ │ │ │ +84 // Complex eigenvalues are either caused by non-symmetric matrices or by │ │ │ │ │ +round-off errors │ │ │ │ │ +85 DUNE_THROW(MathError, "Complex eigenvalue detected (which this │ │ │ │ │ +implementation cannot handle)."); │ │ │ │ │ +86 } │ │ │ │ │ +87 │ │ │ │ │ +88 // get square root │ │ │ │ │ +89 q = sqrt(q); │ │ │ │ │ 90 │ │ │ │ │ -91#if HAVE_MPI │ │ │ │ │ -92 GuardCommunicator * GuardCommunicator::create(const MPI_Comm & comm) │ │ │ │ │ -93 { │ │ │ │ │ -94 return new GenericGuardCommunicator< Communication >(comm); │ │ │ │ │ -95 } │ │ │ │ │ -96#endif │ │ │ │ │ -97 │ │ │ │ │ -98#endif │ │ │ │ │ -99 │ │ │ │ │ -103 class MPIGuardError : public ParallelError {}; │ │ │ │ │ -104 │ │ │ │ │ -137 class MPIGuard │ │ │ │ │ -138 { │ │ │ │ │ -139 GuardCommunicator * comm_; │ │ │ │ │ -140 bool active_; │ │ │ │ │ -141 │ │ │ │ │ -142 // we don't want to copy this class │ │ │ │ │ -143 MPIGuard (const MPIGuard &); │ │ │ │ │ -144 │ │ │ │ │ -145 public: │ │ │ │ │ -150 MPIGuard (bool active=true) : │ │ │ │ │ -151 comm_(GuardCommunicator::create( │ │ │ │ │ -152 MPIHelper::getCommunication())), │ │ │ │ │ -153 active_(active) │ │ │ │ │ -154 {} │ │ │ │ │ -155 │ │ │ │ │ -161 MPIGuard (MPIHelper & m, bool active=true) : │ │ │ │ │ -162 comm_(GuardCommunicator::create( │ │ │ │ │ -163 m.getCommunication())), │ │ │ │ │ -164 active_(active) │ │ │ │ │ -165 {} │ │ │ │ │ -166 │ │ │ │ │ -177 template │ │ │ │ │ -178 MPIGuard (const C & comm, bool active=true) : │ │ │ │ │ -179 comm_(GuardCommunicator::create(comm)), │ │ │ │ │ -180 active_(active) │ │ │ │ │ -181 {} │ │ │ │ │ -182 │ │ │ │ │ -183#if HAVE_MPI │ │ │ │ │ -184 MPIGuard (const MPI_Comm & comm, bool active=true) : │ │ │ │ │ -185 comm_(GuardCommunicator::create(comm)), │ │ │ │ │ -186 active_(active) │ │ │ │ │ -187 {} │ │ │ │ │ -188#endif │ │ │ │ │ +91 // store eigenvalues in ascending order │ │ │ │ │ +92 eigenvalues[0] = p - q; │ │ │ │ │ +93 eigenvalues[1] = p + q; │ │ │ │ │ +94 } │ │ │ │ │ +95 │ │ │ │ │ +96 /* │ │ │ │ │ +97 This implementation was adapted from the pseudo-code (Python?) │ │ │ │ │ +implementation found on │ │ │ │ │ +98 http://en.wikipedia.org/wiki/Eigenvalue_algorithm (retrieved late August │ │ │ │ │ +2014). │ │ │ │ │ +99 Wikipedia claims to have taken it from │ │ │ │ │ +100 Smith, Oliver K. (April 1961), Eigenvalues of a symmetric 3 × 3 matrix., │ │ │ │ │ +101 Communications of the ACM 4 (4): 168, doi:10.1145/355578.366316 │ │ │ │ │ +102 */ │ │ │ │ │ +103 template │ │ │ │ │ +104 static K eigenValues3dImpl(const FieldMatrix& matrix, │ │ │ │ │ +105 FieldVector& eigenvalues) │ │ │ │ │ +106 { │ │ │ │ │ +107 using std::sqrt; │ │ │ │ │ +108 using std::acos; │ │ │ │ │ +109 using real_type = typename FieldTraits::real_type; │ │ │ │ │ +110 const K pi = MathematicalConstants::pi(); │ │ │ │ │ +111 K p1 = matrix[0][1]*matrix[0][1] + matrix[0][2]*matrix[0][2] + matrix[1] │ │ │ │ │ +[2]*matrix[1][2]; │ │ │ │ │ +112 │ │ │ │ │ +113 if (p1 <= std::numeric_limits::epsilon()) { │ │ │ │ │ +114 // A is diagonal. │ │ │ │ │ +115 eigenvalues[0] = matrix[0][0]; │ │ │ │ │ +116 eigenvalues[1] = matrix[1][1]; │ │ │ │ │ +117 eigenvalues[2] = matrix[2][2]; │ │ │ │ │ +118 std::sort(eigenvalues.begin(), eigenvalues.end()); │ │ │ │ │ +119 │ │ │ │ │ +120 return 0.0; │ │ │ │ │ +121 } │ │ │ │ │ +122 else │ │ │ │ │ +123 { │ │ │ │ │ +124 // q = trace(A)/3 │ │ │ │ │ +125 K q = 0; │ │ │ │ │ +126 for (int i=0; i<3; i++) │ │ │ │ │ +127 q += matrix[i][i] / 3.0; │ │ │ │ │ +128 │ │ │ │ │ +129 K p2 = (matrix[0][0] - q)*(matrix[0][0] - q) + (matrix[1][1] - q)*(matrix │ │ │ │ │ +[1][1] - q) + (matrix[2][2] - q)*(matrix[2][2] - q) + 2.0 * p1; │ │ │ │ │ +130 K p = sqrt(p2 / 6); │ │ │ │ │ +131 // B = (1 / p) * (A - q * I); // I is the identity matrix │ │ │ │ │ +132 FieldMatrix B; │ │ │ │ │ +133 for (int i=0; i<3; i++) │ │ │ │ │ +134 for (int j=0; j<3; j++) │ │ │ │ │ +135 B[i][j] = (real_type(1.0)/p) * (matrix[i][j] - q*(i==j)); │ │ │ │ │ +136 │ │ │ │ │ +137 K r = B.determinant() / 2.0; │ │ │ │ │ +138 │ │ │ │ │ +139 /*In exact arithmetic for a symmetric matrix -1 <= r <= 1 │ │ │ │ │ +140 but computation error can leave it slightly outside this range. │ │ │ │ │ +141 acos(z) function requires |z| <= 1, but will fail silently │ │ │ │ │ +142 and return NaN if the input is larger than 1 in magnitude. │ │ │ │ │ +143 Thus r is clamped to [-1,1].*/ │ │ │ │ │ +144 using std::clamp; │ │ │ │ │ +145 r = clamp(r, -1.0, 1.0); │ │ │ │ │ +146 K phi = acos(r) / 3.0; │ │ │ │ │ +147 │ │ │ │ │ +148 // the eigenvalues satisfy eig[2] <= eig[1] <= eig[0] │ │ │ │ │ +149 eigenvalues[2] = q + 2 * p * cos(phi); │ │ │ │ │ +150 eigenvalues[0] = q + 2 * p * cos(phi + (2*pi/3)); │ │ │ │ │ +151 eigenvalues[1] = 3 * q - eigenvalues[0] - eigenvalues[2]; // since trace │ │ │ │ │ +(matrix) = eig1 + eig2 + eig3 │ │ │ │ │ +152 │ │ │ │ │ +153 return r; │ │ │ │ │ +154 } │ │ │ │ │ +155 } │ │ │ │ │ +156 │ │ │ │ │ +157 //see https://www.geometrictools.com/Documentation/ │ │ │ │ │ +RobustEigenSymmetric3x3.pdf │ │ │ │ │ +158 //Robustly compute a right-handed orthonormal set {u, v, evec0}. │ │ │ │ │ +159 template │ │ │ │ │ +160 void orthoComp(const FieldVector& evec0, FieldVector& u, │ │ │ │ │ +FieldVector& v) { │ │ │ │ │ +161 using std::abs; │ │ │ │ │ +162 if(abs(evec0[0]) > abs(evec0[1])) { │ │ │ │ │ +163 //The component of maximum absolute value is either evec0[0] or evec0[2]. │ │ │ │ │ +164 FieldVector temp = {evec0[0], evec0[2]}; │ │ │ │ │ +165 auto L = 1.0 / temp.two_norm(); │ │ │ │ │ +166 u = L * FieldVector({-evec0[2], 0.0, evec0[0]}); │ │ │ │ │ +167 } │ │ │ │ │ +168 else { │ │ │ │ │ +169 //The component of maximum absolute value is either evec0[1] or evec0[2]. │ │ │ │ │ +170 FieldVector temp = {evec0[1], evec0[2]}; │ │ │ │ │ +171 auto L = 1.0 / temp.two_norm(); │ │ │ │ │ +172 u = L * FieldVector({0.0, evec0[2], -evec0[1]}); │ │ │ │ │ +173 } │ │ │ │ │ +174 v = crossProduct(evec0, u); │ │ │ │ │ +175 } │ │ │ │ │ +176 │ │ │ │ │ +177 //see https://www.geometrictools.com/Documentation/ │ │ │ │ │ +RobustEigenSymmetric3x3.pdf │ │ │ │ │ +178 template │ │ │ │ │ +179 void eig0(const FieldMatrix& matrix, K eval0, FieldVector& │ │ │ │ │ +evec0) { │ │ │ │ │ +180 /* Compute a unit-length eigenvector for eigenvalue[i0]. The │ │ │ │ │ +181 matrix is rank 2, so two of the rows are linearly independent. │ │ │ │ │ +182 For a robust computation of the eigenvector, select the two │ │ │ │ │ +183 rows whose cross product has largest length of all pairs of │ │ │ │ │ +184 rows. */ │ │ │ │ │ +185 using Vector = FieldVector; │ │ │ │ │ +186 Vector row0 = {matrix[0][0]-eval0, matrix[0][1], matrix[0][2]}; │ │ │ │ │ +187 Vector row1 = {matrix[1][0], matrix[1][1]-eval0, matrix[1][2]}; │ │ │ │ │ +188 Vector row2 = {matrix[2][0], matrix[2][1], matrix[2][2]-eval0}; │ │ │ │ │ 189 │ │ │ │ │ -192 ~MPIGuard() │ │ │ │ │ -193 { │ │ │ │ │ -194 if (active_) │ │ │ │ │ -195 { │ │ │ │ │ -196 active_ = false; │ │ │ │ │ -197 finalize(false); │ │ │ │ │ -198 } │ │ │ │ │ -199 delete comm_; │ │ │ │ │ -200 } │ │ │ │ │ -201 │ │ │ │ │ -206 void reactivate() { │ │ │ │ │ -207 if (active_ == true) │ │ │ │ │ -208 finalize(); │ │ │ │ │ -209 active_ = true; │ │ │ │ │ -210 } │ │ │ │ │ -211 │ │ │ │ │ -222 void finalize(bool success = true) │ │ │ │ │ -223 { │ │ │ │ │ -224 int result = success ? 0 : 1; │ │ │ │ │ -225 bool was_active = active_; │ │ │ │ │ -226 active_ = false; │ │ │ │ │ -227 result = comm_->sum(result); │ │ │ │ │ -228 if (result>0 && was_active) │ │ │ │ │ -229 { │ │ │ │ │ -230 DUNE_THROW(MPIGuardError, "Terminating process " │ │ │ │ │ -231 << comm_->rank() << " due to " │ │ │ │ │ -232 << result << " remote error(s)"); │ │ │ │ │ -233 } │ │ │ │ │ -234 } │ │ │ │ │ -235 }; │ │ │ │ │ -236 │ │ │ │ │ -237} │ │ │ │ │ -238 │ │ │ │ │ -239#endif // DUNE_COMMON_PARALLEL_MPIGUARD_HH │ │ │ │ │ -mpihelper.hh │ │ │ │ │ -Helpers for dealing with MPI. │ │ │ │ │ -communication.hh │ │ │ │ │ -Implements an utility class that provides collective communication methods for │ │ │ │ │ -sequential programs. │ │ │ │ │ -mpicommunication.hh │ │ │ │ │ -Implements an utility class that provides MPI's collective communication │ │ │ │ │ -methods. │ │ │ │ │ +190 Vector r0xr1 = crossProduct(row0, row1); │ │ │ │ │ +191 Vector r0xr2 = crossProduct(row0, row2); │ │ │ │ │ +192 Vector r1xr2 = crossProduct(row1, row2); │ │ │ │ │ +193 auto d0 = r0xr1.two_norm(); │ │ │ │ │ +194 auto d1 = r0xr2.two_norm(); │ │ │ │ │ +195 auto d2 = r1xr2.two_norm(); │ │ │ │ │ +196 │ │ │ │ │ +197 auto dmax = d0 ; │ │ │ │ │ +198 int imax = 0; │ │ │ │ │ +199 if(d1>dmax) { │ │ │ │ │ +200 dmax = d1; │ │ │ │ │ +201 imax = 1; │ │ │ │ │ +202 } │ │ │ │ │ +203 if(d2>dmax) │ │ │ │ │ +204 imax = 2; │ │ │ │ │ +205 │ │ │ │ │ +206 if(imax == 0) │ │ │ │ │ +207 evec0 = r0xr1 / d0; │ │ │ │ │ +208 else if(imax == 1) │ │ │ │ │ +209 evec0 = r0xr2 / d1; │ │ │ │ │ +210 else │ │ │ │ │ +211 evec0 = r1xr2 / d2; │ │ │ │ │ +212 } │ │ │ │ │ +213 │ │ │ │ │ +214 //see https://www.geometrictools.com/Documentation/ │ │ │ │ │ +RobustEigenSymmetric3x3.pdf │ │ │ │ │ +215 template │ │ │ │ │ +216 void eig1(const FieldMatrix& matrix, const FieldVector& evec0, │ │ │ │ │ +FieldVector& evec1, K eval1) { │ │ │ │ │ +217 using Vector = FieldVector; │ │ │ │ │ +218 │ │ │ │ │ +219 //Robustly compute a right-handed orthonormal set {u, v, evec0}. │ │ │ │ │ +220 Vector u,v; │ │ │ │ │ +221 orthoComp(evec0, u, v); │ │ │ │ │ +222 │ │ │ │ │ +223 /* Let e be eval1 and let E be a corresponding eigenvector which │ │ │ │ │ +224 is a solution to the linear system (A - e*I)*E = 0. The matrix │ │ │ │ │ +225 (A - e*I) is 3x3, not invertible (so infinitely many │ │ │ │ │ +226 solutions), and has rank 2 when eval1 and eval are different. │ │ │ │ │ +227 It has rank 1 when eval1 and eval2 are equal. Numerically, it │ │ │ │ │ +228 is difficult to compute robustly the rank of a matrix. Instead, │ │ │ │ │ +229 the 3x3 linear system is reduced to a 2x2 system as follows. │ │ │ │ │ +230 Define the 3x2 matrix J = [u,v] whose columns are the u and v │ │ │ │ │ +231 computed previously. Define the 2x1 vector X = J*E. The 2x2 │ │ │ │ │ +232 system is 0 = M * X = (J^T * (A - e*I) * J) * X where J^T is │ │ │ │ │ +233 the transpose of J and M = J^T * (A - e*I) * J is a 2x2 matrix. │ │ │ │ │ +234 The system may be written as │ │ │ │ │ +235 +- -++- -+ +- -+ │ │ │ │ │ +236 | U^T*A*U - e U^T*A*V || x0 | = e * | x0 | │ │ │ │ │ +237 | V^T*A*U V^T*A*V - e || x1 | | x1 | │ │ │ │ │ +238 +- -++ -+ +- -+ │ │ │ │ │ +239 where X has row entries x0 and x1. */ │ │ │ │ │ +240 │ │ │ │ │ +241 Vector Au, Av; │ │ │ │ │ +242 matrix.mv(u, Au); │ │ │ │ │ +243 matrix.mv(v, Av); │ │ │ │ │ +244 │ │ │ │ │ +245 auto m00 = u.dot(Au) - eval1; │ │ │ │ │ +246 auto m01 = u.dot(Av); │ │ │ │ │ +247 auto m11 = v.dot(Av) - eval1; │ │ │ │ │ +248 │ │ │ │ │ +249 /* For robustness, choose the largest-length row of M to compute │ │ │ │ │ +250 the eigenvector. The 2-tuple of coefficients of U and V in the │ │ │ │ │ +251 assignments to eigenvector[1] lies on a circle, and U and V are │ │ │ │ │ +252 unit length and perpendicular, so eigenvector[1] is unit length │ │ │ │ │ +253 (within numerical tolerance). */ │ │ │ │ │ +254 using std::abs, std::sqrt, std::max; │ │ │ │ │ +255 auto absM00 = abs(m00); │ │ │ │ │ +256 auto absM01 = abs(m01); │ │ │ │ │ +257 auto absM11 = abs(m11); │ │ │ │ │ +258 if(absM00 >= absM11) { │ │ │ │ │ +259 auto maxAbsComp = max(absM00, absM01); │ │ │ │ │ +260 if(maxAbsComp > 0.0) { │ │ │ │ │ +261 if(absM00 >= absM01) { │ │ │ │ │ +262 m01 /= m00; │ │ │ │ │ +263 m00 = 1.0 / sqrt(1.0 + m01*m01); │ │ │ │ │ +264 m01 *= m00; │ │ │ │ │ +265 } │ │ │ │ │ +266 else { │ │ │ │ │ +267 m00 /= m01; │ │ │ │ │ +268 m01 = 1.0 / sqrt(1.0 + m00*m00); │ │ │ │ │ +269 m00 *= m01; │ │ │ │ │ +270 } │ │ │ │ │ +271 evec1 = m01*u - m00*v; │ │ │ │ │ +272 } │ │ │ │ │ +273 else │ │ │ │ │ +274 evec1 = u; │ │ │ │ │ +275 } │ │ │ │ │ +276 else { │ │ │ │ │ +277 auto maxAbsComp = max(absM11, absM01); │ │ │ │ │ +278 if(maxAbsComp > 0.0) { │ │ │ │ │ +279 if(absM11 >= absM01) { │ │ │ │ │ +280 m01 /= m11; │ │ │ │ │ +281 m11 = 1.0 / sqrt(1.0 + m01*m01); │ │ │ │ │ +282 m01 *= m11; │ │ │ │ │ +283 } │ │ │ │ │ +284 else { │ │ │ │ │ +285 m11 /= m01; │ │ │ │ │ +286 m01 = 1.0 / sqrt(1.0 + m11*m11); │ │ │ │ │ +287 m11 *= m01; │ │ │ │ │ +288 } │ │ │ │ │ +289 evec1 = m11*u - m01*v; │ │ │ │ │ +290 } │ │ │ │ │ +291 else │ │ │ │ │ +292 evec1 = u; │ │ │ │ │ +293 } │ │ │ │ │ +294 } │ │ │ │ │ +295 │ │ │ │ │ +296 // 1d specialization │ │ │ │ │ +297 template │ │ │ │ │ +298 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ +299 FieldVector& eigenValues, │ │ │ │ │ +300 FieldMatrix& eigenVectors) │ │ │ │ │ +301 { │ │ │ │ │ +302 eigenValues[0] = matrix[0][0]; │ │ │ │ │ +303 if constexpr(Tag==EigenvaluesEigenvectors) │ │ │ │ │ +304 eigenVectors[0] = {1.0}; │ │ │ │ │ +305 } │ │ │ │ │ +306 │ │ │ │ │ +307 │ │ │ │ │ +308 // 2d specialization │ │ │ │ │ +309 template │ │ │ │ │ +310 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ +311 FieldVector& eigenValues, │ │ │ │ │ +312 FieldMatrix& eigenVectors) │ │ │ │ │ +313 { │ │ │ │ │ +314 // Compute eigen values │ │ │ │ │ +315 Impl::eigenValues2dImpl(matrix, eigenValues); │ │ │ │ │ +316 │ │ │ │ │ +317 // Compute eigenvectors by exploiting the Cayley–Hamilton theorem. │ │ │ │ │ +318 // If λ_1, λ_2 are the eigenvalues, then (A - λ_1I )(A - λ_2I ) = (A - │ │ │ │ │ +λ_2I )(A - λ_1I ) = 0, │ │ │ │ │ +319 // so the columns of (A - λ_2I ) are annihilated by (A - λ_1I ) and vice │ │ │ │ │ +versa. │ │ │ │ │ +320 // Assuming neither matrix is zero, the columns of each must include │ │ │ │ │ +eigenvectors │ │ │ │ │ +321 // for the other eigenvalue. (If either matrix is zero, then A is a │ │ │ │ │ +multiple of the │ │ │ │ │ +322 // identity and any non-zero vector is an eigenvector.) │ │ │ │ │ +323 // From: https://en.wikipedia.org/wiki/Eigenvalue_algorithm#2x2_matrices │ │ │ │ │ +324 if constexpr(Tag==EigenvaluesEigenvectors) { │ │ │ │ │ +325 │ │ │ │ │ +326 // Special casing for multiples of the identity │ │ │ │ │ +327 FieldMatrix temp = matrix; │ │ │ │ │ +328 temp[0][0] -= eigenValues[0]; │ │ │ │ │ +329 temp[1][1] -= eigenValues[0]; │ │ │ │ │ +330 if(temp.infinity_norm() <= 1e-14) { │ │ │ │ │ +331 eigenVectors[0] = {1.0, 0.0}; │ │ │ │ │ +332 eigenVectors[1] = {0.0, 1.0}; │ │ │ │ │ +333 } │ │ │ │ │ +334 else { │ │ │ │ │ +335 // The columns of A - λ_2I are eigenvectors for λ_1, or zero. │ │ │ │ │ +336 // Take the column with the larger norm to avoid zero columns. │ │ │ │ │ +337 FieldVector ev0 = {matrix[0][0]-eigenValues[1], matrix[1][0]}; │ │ │ │ │ +338 FieldVector ev1 = {matrix[0][1], matrix[1][1]-eigenValues[1]}; │ │ │ │ │ +339 eigenVectors[0] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm() │ │ │ │ │ +: ev1/ev1.two_norm(); │ │ │ │ │ +340 │ │ │ │ │ +341 // The columns of A - λ_1I are eigenvectors for λ_2, or zero. │ │ │ │ │ +342 // Take the column with the larger norm to avoid zero columns. │ │ │ │ │ +343 ev0 = {matrix[0][0]-eigenValues[0], matrix[1][0]}; │ │ │ │ │ +344 ev1 = {matrix[0][1], matrix[1][1]-eigenValues[0]}; │ │ │ │ │ +345 eigenVectors[1] = (ev0.two_norm2() >= ev1.two_norm2()) ? ev0/ev0.two_norm() │ │ │ │ │ +: ev1/ev1.two_norm(); │ │ │ │ │ +346 } │ │ │ │ │ +347 } │ │ │ │ │ +348 } │ │ │ │ │ +349 │ │ │ │ │ +350 // 3d specialization │ │ │ │ │ +351 template │ │ │ │ │ +352 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ +353 FieldVector& eigenValues, │ │ │ │ │ +354 FieldMatrix& eigenVectors) │ │ │ │ │ +355 { │ │ │ │ │ +356 using Vector = FieldVector; │ │ │ │ │ +357 using Matrix = FieldMatrix; │ │ │ │ │ +358 │ │ │ │ │ +359 //compute eigenvalues │ │ │ │ │ +360 /* Precondition the matrix by factoring out the maximum absolute │ │ │ │ │ +361 value of the components. This guards against floating-point │ │ │ │ │ +362 overflow when computing the eigenvalues.*/ │ │ │ │ │ +363 using std::isnormal; │ │ │ │ │ +364 K maxAbsElement = (isnormal(matrix.infinity_norm())) ? matrix.infinity_norm │ │ │ │ │ +() : K(1.0); │ │ │ │ │ +365 Matrix scaledMatrix = matrix / maxAbsElement; │ │ │ │ │ +366 K r = Impl::eigenValues3dImpl(scaledMatrix, eigenValues); │ │ │ │ │ +367 │ │ │ │ │ +368 if constexpr(Tag==EigenvaluesEigenvectors) { │ │ │ │ │ +369 K offDiagNorm = Vector{scaledMatrix[0][1],scaledMatrix[0][2],scaledMatrix │ │ │ │ │ +[1][2]}.two_norm2(); │ │ │ │ │ +370 if (offDiagNorm <= std::numeric_limits::epsilon()) │ │ │ │ │ +371 { │ │ │ │ │ +372 eigenValues = {scaledMatrix[0][0], scaledMatrix[1][1], scaledMatrix[2][2]}; │ │ │ │ │ +373 eigenVectors = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}; │ │ │ │ │ +374 │ │ │ │ │ +375 // Use bubble sort to jointly sort eigenvalues and eigenvectors │ │ │ │ │ +376 // such that eigenvalues are ascending │ │ │ │ │ +377 if (eigenValues[0] > eigenValues[1]) │ │ │ │ │ +378 { │ │ │ │ │ +379 std::swap(eigenValues[0], eigenValues[1]); │ │ │ │ │ +380 std::swap(eigenVectors[0], eigenVectors[1]); │ │ │ │ │ +381 } │ │ │ │ │ +382 if (eigenValues[1] > eigenValues[2]) │ │ │ │ │ +383 { │ │ │ │ │ +384 std::swap(eigenValues[1], eigenValues[2]); │ │ │ │ │ +385 std::swap(eigenVectors[1], eigenVectors[2]); │ │ │ │ │ +386 } │ │ │ │ │ +387 if (eigenValues[0] > eigenValues[1]) │ │ │ │ │ +388 { │ │ │ │ │ +389 std::swap(eigenValues[0], eigenValues[1]); │ │ │ │ │ +390 std::swap(eigenVectors[0], eigenVectors[1]); │ │ │ │ │ +391 } │ │ │ │ │ +392 } │ │ │ │ │ +393 else { │ │ │ │ │ +394 /*Compute the eigenvectors so that the set │ │ │ │ │ +395 [evec[0], evec[1], evec[2]] is right handed and │ │ │ │ │ +396 orthonormal. */ │ │ │ │ │ +397 │ │ │ │ │ +398 Matrix evec(0.0); │ │ │ │ │ +399 Vector eval(eigenValues); │ │ │ │ │ +400 if(r >= 0) { │ │ │ │ │ +401 Impl::eig0(scaledMatrix, eval[2], evec[2]); │ │ │ │ │ +402 Impl::eig1(scaledMatrix, evec[2], evec[1], eval[1]); │ │ │ │ │ +403 evec[0] = Impl::crossProduct(evec[1], evec[2]); │ │ │ │ │ +404 } │ │ │ │ │ +405 else { │ │ │ │ │ +406 Impl::eig0(scaledMatrix, eval[0], evec[0]); │ │ │ │ │ +407 Impl::eig1(scaledMatrix, evec[0], evec[1], eval[1]); │ │ │ │ │ +408 evec[2] = Impl::crossProduct(evec[0], evec[1]); │ │ │ │ │ +409 } │ │ │ │ │ +410 //sort eval/evec-pairs in ascending order │ │ │ │ │ +411 using EVPair = std::pair; │ │ │ │ │ +412 std::vector pairs; │ │ │ │ │ +413 for(std::size_t i=0; i<=2; ++i) │ │ │ │ │ +414 pairs.push_back(EVPair(eval[i], evec[i])); │ │ │ │ │ +415 auto comp = [](EVPair x, EVPair y){ return x.first < y.first; }; │ │ │ │ │ +416 std::sort(pairs.begin(), pairs.end(), comp); │ │ │ │ │ +417 for(std::size_t i=0; i<=2; ++i){ │ │ │ │ │ +418 eigenValues[i] = pairs[i].first; │ │ │ │ │ +419 eigenVectors[i] = pairs[i].second; │ │ │ │ │ +420 } │ │ │ │ │ +421 } │ │ │ │ │ +422 } │ │ │ │ │ +423 //The preconditioning scaled the matrix, which scales the eigenvalues. │ │ │ │ │ +Revert the scaling. │ │ │ │ │ +424 eigenValues *= maxAbsElement; │ │ │ │ │ +425 } │ │ │ │ │ +426 │ │ │ │ │ +427 // forwarding to LAPACK with corresponding tag │ │ │ │ │ +428 template │ │ │ │ │ +429 static void eigenValuesVectorsLapackImpl(const FieldMatrix& │ │ │ │ │ +matrix, │ │ │ │ │ +430 FieldVector& eigenValues, │ │ │ │ │ +431 FieldMatrix& eigenVectors) │ │ │ │ │ +432 { │ │ │ │ │ +433 { │ │ │ │ │ +434#if HAVE_LAPACK │ │ │ │ │ +435 /*Lapack uses a proprietary tag to determine whether both eigenvalues and │ │ │ │ │ +436 -vectors ('v') or only eigenvalues ('n') should be calculated */ │ │ │ │ │ +437 const char jobz = "nv"[Tag]; │ │ │ │ │ +438 │ │ │ │ │ +439 const long int N = dim ; │ │ │ │ │ +440 const char uplo = 'u'; // use upper triangular matrix │ │ │ │ │ +441 │ │ │ │ │ +442 // length of matrix vector, LWORK >= max(1,3*N-1) │ │ │ │ │ +443 const long int lwork = 3*N -1 ; │ │ │ │ │ +444 │ │ │ │ │ +445 constexpr bool isKLapackType = std::is_same_v || std::is_same_ │ │ │ │ │ +v; │ │ │ │ │ +446 using LapackNumType = std::conditional_t; │ │ │ │ │ +447 │ │ │ │ │ +448 // matrix to put into dsyev │ │ │ │ │ +449 LapackNumType matrixVector[dim * dim]; │ │ │ │ │ +450 │ │ │ │ │ +451 // copy matrix │ │ │ │ │ +452 int row = 0; │ │ │ │ │ +453 for(int i=0; i │ │ │ │ │ +508 static void eigenValuesVectorsImpl(const FieldMatrix& matrix, │ │ │ │ │ +509 FieldVector& eigenValues, │ │ │ │ │ +510 FieldMatrix& eigenVectors) │ │ │ │ │ +511 { │ │ │ │ │ +512 eigenValuesVectorsLapackImpl(matrix,eigenValues,eigenVectors); │ │ │ │ │ +513 } │ │ │ │ │ +514 } //namespace Impl │ │ │ │ │ +515 │ │ │ │ │ +523 template │ │ │ │ │ +524 static void eigenValues(const FieldMatrix& matrix, │ │ │ │ │ +525 FieldVector& eigenValues) │ │ │ │ │ +526 { │ │ │ │ │ +527 Impl::EVDummy dummy; │ │ │ │ │ +528 Impl::eigenValuesVectorsImpl(matrix, │ │ │ │ │ +eigenValues, dummy); │ │ │ │ │ +529 } │ │ │ │ │ +530 │ │ │ │ │ +539 template │ │ │ │ │ +540 static void eigenValuesVectors(const FieldMatrix& matrix, │ │ │ │ │ +541 FieldVector& eigenValues, │ │ │ │ │ +542 FieldMatrix& eigenVectors) │ │ │ │ │ +543 { │ │ │ │ │ +544 Impl::eigenValuesVectorsImpl(matrix, │ │ │ │ │ +eigenValues, eigenVectors); │ │ │ │ │ +545 } │ │ │ │ │ +546 │ │ │ │ │ +554 template │ │ │ │ │ +555 static void eigenValuesLapack(const FieldMatrix& matrix, │ │ │ │ │ +556 FieldVector& eigenValues) │ │ │ │ │ +557 { │ │ │ │ │ +558 Impl::EVDummy dummy; │ │ │ │ │ +559 Impl::eigenValuesVectorsLapackImpl │ │ │ │ │ +(matrix, eigenValues, dummy); │ │ │ │ │ +560 } │ │ │ │ │ +561 │ │ │ │ │ +570 template │ │ │ │ │ +571 static void eigenValuesVectorsLapack(const FieldMatrix& │ │ │ │ │ +matrix, │ │ │ │ │ +572 FieldVector& eigenValues, │ │ │ │ │ +573 FieldMatrix& eigenVectors) │ │ │ │ │ +574 { │ │ │ │ │ +575 Impl::eigenValuesVectorsLapackImpl │ │ │ │ │ +(matrix, eigenValues, eigenVectors); │ │ │ │ │ +576 } │ │ │ │ │ +577 │ │ │ │ │ +585 template │ │ │ │ │ +586 static void eigenValuesNonSym(const FieldMatrix& matrix, │ │ │ │ │ +587 FieldVector& eigenValues) │ │ │ │ │ +588 { │ │ │ │ │ +589#if HAVE_LAPACK │ │ │ │ │ +590 { │ │ │ │ │ +591 const long int N = dim ; │ │ │ │ │ +592 const char jobvl = 'n'; │ │ │ │ │ +593 const char jobvr = 'n'; │ │ │ │ │ +594 │ │ │ │ │ +595 constexpr bool isKLapackType = std::is_same_v || std::is_same_ │ │ │ │ │ +v; │ │ │ │ │ +596 using LapackNumType = std::conditional_t; │ │ │ │ │ +597 │ │ │ │ │ +598 // matrix to put into dgeev │ │ │ │ │ +599 LapackNumType matrixVector[dim * dim]; │ │ │ │ │ +600 │ │ │ │ │ +601 // copy matrix │ │ │ │ │ +602 int row = 0; │ │ │ │ │ +603 for(int i=0; i &matrix, │ │ │ │ │ +FieldVector< C, dim > &eigenValues) │ │ │ │ │ +calculates the eigenvalues of a non-symmetric field matrix │ │ │ │ │ +Definition fmatrixev.hh:586 │ │ │ │ │ +Dune::FMatrixHelp::eigenValues │ │ │ │ │ +static void eigenValues(const FieldMatrix< K, dim, dim > &matrix, FieldVector< │ │ │ │ │ +K, dim > &eigenValues) │ │ │ │ │ +calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ +Definition fmatrixev.hh:524 │ │ │ │ │ +Dune::FMatrixHelp::eigenValuesLapack │ │ │ │ │ +static void eigenValuesLapack(const FieldMatrix< K, dim, dim > &matrix, │ │ │ │ │ +FieldVector< K, dim > &eigenValues) │ │ │ │ │ +calculates the eigenvalues of a symmetric field matrix │ │ │ │ │ +Definition fmatrixev.hh:555 │ │ │ │ │ +Dune::FMatrixHelp::eigenValuesVectors │ │ │ │ │ +static void eigenValuesVectors(const FieldMatrix< K, dim, dim > &matrix, │ │ │ │ │ +FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors) │ │ │ │ │ +calculates the eigenvalues and eigenvectors of a symmetric field matrix │ │ │ │ │ +Definition fmatrixev.hh:540 │ │ │ │ │ +Dune::FMatrixHelp::eigenValuesVectorsLapack │ │ │ │ │ +static void eigenValuesVectorsLapack(const FieldMatrix< K, dim, dim > &matrix, │ │ │ │ │ +FieldVector< K, dim > &eigenValues, FieldMatrix< K, dim, dim > &eigenVectors) │ │ │ │ │ +calculates the eigenvalues and -vectors of a symmetric field matrix │ │ │ │ │ +Definition fmatrixev.hh:571 │ │ │ │ │ +Dune::FieldMatrix │ │ │ │ │ +A dense n x m matrix. │ │ │ │ │ +Definition fmatrix.hh:117 │ │ │ │ │ +Dune::FieldVector │ │ │ │ │ +vector space out of a tensor product of fields. │ │ │ │ │ +Definition fvector.hh:91 │ │ │ │ │ +Dune::NotImplemented │ │ │ │ │ +Default exception for dummy implementations. │ │ │ │ │ +Definition exceptions.hh:263 │ │ │ │ │ +Dune::InvalidStateException │ │ │ │ │ +Default exception if a function was called while the object is not in a valid │ │ │ │ │ +state for that function... │ │ │ │ │ +Definition exceptions.hh:281 │ │ │ │ │ +Dune::FieldTraits::real_type │ │ │ │ │ +T real_type │ │ │ │ │ +export the type representing the real type of the field │ │ │ │ │ +Definition ftraits.hh:30 │ │ │ │ │ +Dune::StandardMathematicalConstants<_Field_>::pi │ │ │ │ │ +static const Field pi() │ │ │ │ │ +Archimedes' constant. │ │ │ │ │ +Definition math.hh:48 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00074.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: parmetis.hh File Reference │ │ │ │ +dune-common: hybridutilities.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,23 +65,123 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
parmetis.hh File Reference
│ │ │ │ +
│ │ │ │ +Classes | │ │ │ │ +Namespaces | │ │ │ │ +Functions | │ │ │ │ +Variables
│ │ │ │ +
hybridutilities.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ - │ │ │ │ +
#include <tuple>
│ │ │ │ +#include <utility>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │ +#include <dune/common/typeutilities.hh>
│ │ │ │ +#include <dune/common/fvector.hh>
│ │ │ │ +#include <dune/common/indices.hh>
│ │ │ │ +#include <dune/common/rangeutilities.hh>
│ │ │ │ +
│ │ │ │

Go to the source code of this file.

│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

class  Dune::Hybrid::HybridFunctor< Functor >
 Adapter of a hybrid functor that maintains results hybrid. More...
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::Hybrid
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Functions

template<class T >
constexpr auto Dune::Hybrid::size (const T &t)
 Size query.
 
template<class Container , class Index >
constexpr decltype(auto) Dune::Hybrid::elementAt (Container &&c, Index &&i)
 Get element at given position from container.
 
template<class Begin , class End >
constexpr auto Dune::Hybrid::integralRange (const Begin &begin, const End &end)
 Create an integral range.
 
template<class End >
constexpr auto Dune::Hybrid::integralRange (const End &end)
 Create an integral range starting from 0.
 
template<class Range , class F >
constexpr void Dune::Hybrid::forEach (Range &&range, F &&f)
 Range based for loop.
 
template<class Range , class T , class F >
constexpr T Dune::Hybrid::accumulate (Range &&range, T value, F &&f)
 Accumulate values.
 
template<class Condition , class IfFunc , class ElseFunc >
decltype(auto) Dune::Hybrid::ifElse (const Condition &condition, IfFunc &&ifFunc, ElseFunc &&elseFunc)
 A conditional expression.
 
template<class Condition , class IfFunc >
void Dune::Hybrid::ifElse (const Condition &condition, IfFunc &&ifFunc)
 A conditional expression.
 
template<class Functor >
constexpr HybridFunctor< Functor > Dune::Hybrid::hybridFunctor (const Functor &)
 Returns an HybridFunctor adaptor.
 
template<class T1 , class T2 >
constexpr auto Dune::Hybrid::equals (T1 &&t1, T2 &&t2)
 Equality comparison.
 
template<class Cases , class Value , class Branches , class ElseBranch >
constexpr decltype(auto) Dune::Hybrid::switchCases (const Cases &cases, const Value &value, Branches &&branches, ElseBranch &&elseBranch)
 Switch statement.
 
template<class Cases , class Value , class Branches >
constexpr void Dune::Hybrid::switchCases (const Cases &cases, const Value &value, Branches &&branches)
 Switch statement.
 
template<class T , class Value , class Branches >
constexpr void Dune::Hybrid::switchCases (IntegralRange< T > range, const Value &value, Branches &&branches)
 Switch statement.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Variables

constexpr auto Dune::Hybrid::max = hybridFunctor(Impl::Max{})
 Function object that returns the greater of the given values.
 
constexpr auto Dune::Hybrid::min = hybridFunctor(Impl::Min{})
 Function object that returns the smaller of the given values.
 
constexpr auto Dune::Hybrid::plus = hybridFunctor(std::plus<>{})
 Function object for performing addition.
 
constexpr auto Dune::Hybrid::minus = hybridFunctor(std::minus<>{})
 Function object for performing subtraction.
 
constexpr auto Dune::Hybrid::equal_to = hybridFunctor(std::equal_to<>{})
 Function object for performing equality comparison.
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,11 +1,113 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -parmetis.hh File Reference │ │ │ │ │ +Classes | Namespaces | Functions | Variables │ │ │ │ │ +hybridutilities.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ +Classes │ │ │ │ │ +class   Dune::Hybrid::HybridFunctor<_Functor_> │ │ │ │ │ +  Adapter of a hybrid functor that maintains results hybrid. More... │ │ │ │ │ +  │ │ │ │ │ +Namespaces │ │ │ │ │ +namespace   Dune │ │ │ │ │ +  Dune namespace. │ │ │ │ │ +  │ │ │ │ │ +namespace   Dune::Hybrid │ │ │ │ │ +  │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ + constexpr auto  Dune::Hybrid::size (const T &t) │ │ │ │ │ +  Size query. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr decltype(auto)  Dune::Hybrid::elementAt (Container &&c, │ │ │ │ │ + Index &&i) │ │ │ │ │ +  Get element at given position from │ │ │ │ │ + container. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr auto  Dune::Hybrid::integralRange (const Begin │ │ │ │ │ + &begin, const End &end) │ │ │ │ │ +  Create an integral range. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr auto  Dune::Hybrid::integralRange (const End │ │ │ │ │ + &end) │ │ │ │ │ +  Create an integral range starting from 0. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr void  Dune::Hybrid::forEach (Range &&range, F │ │ │ │ │ + &&f) │ │ │ │ │ +  Range based for loop. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr T  Dune::Hybrid::accumulate (Range &&range, T │ │ │ │ │ + value, F &&f) │ │ │ │ │ +  Accumulate values. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + decltype(auto)  Dune::Hybrid::ifElse (const Condition │ │ │ │ │ + &condition, IfFunc &&ifFunc, ElseFunc │ │ │ │ │ + &&elseFunc) │ │ │ │ │ +  A conditional expression. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + void  Dune::Hybrid::ifElse (const Condition │ │ │ │ │ + &condition, IfFunc &&ifFunc) │ │ │ │ │ +  A conditional expression. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +constexpr HybridFunctor< Functor >  Dune::Hybrid::hybridFunctor (const Functor │ │ │ │ │ + &) │ │ │ │ │ +  Returns an HybridFunctor adaptor. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr auto  Dune::Hybrid::equals (T1 &&t1, T2 &&t2) │ │ │ │ │ +  Equality comparison. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr decltype(auto)  Dune::Hybrid::switchCases (const Cases │ │ │ │ │ + &cases, const Value &value, Branches │ │ │ │ │ + &&branches, ElseBranch &&elseBranch) │ │ │ │ │ +  Switch statement. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr void  Dune::Hybrid::switchCases (const Cases │ │ │ │ │ + &cases, const Value &value, Branches │ │ │ │ │ + &&branches) │ │ │ │ │ +  Switch statement. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + constexpr void  Dune::Hybrid::switchCases (IntegralRange< T │ │ │ │ │ + > range, const Value &value, Branches │ │ │ │ │ + &&branches) │ │ │ │ │ +  Switch statement. │ │ │ │ │ +  │ │ │ │ │ +Variables │ │ │ │ │ +constexpr auto  Dune::Hybrid::max = hybridFunctor(Impl::Max{}) │ │ │ │ │ +  Function object that returns the greater of the given values. │ │ │ │ │ +  │ │ │ │ │ +constexpr auto  Dune::Hybrid::min = hybridFunctor(Impl::Min{}) │ │ │ │ │ +  Function object that returns the smaller of the given values. │ │ │ │ │ +  │ │ │ │ │ +constexpr auto  Dune::Hybrid::plus = hybridFunctor(std::plus<>{}) │ │ │ │ │ +  Function object for performing addition. │ │ │ │ │ +  │ │ │ │ │ +constexpr auto  Dune::Hybrid::minus = hybridFunctor(std::minus<>{}) │ │ │ │ │ +  Function object for performing subtraction. │ │ │ │ │ +  │ │ │ │ │ +constexpr auto  Dune::Hybrid::equal_to = hybridFunctor(std::equal_to<>{}) │ │ │ │ │ +  Function object for performing equality comparison. │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00074_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: parmetis.hh Source File │ │ │ │ +dune-common: hybridutilities.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,65 +70,466 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
parmetis.hh
│ │ │ │ +
hybridutilities.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_PARMETIS_HH
│ │ │ │ -
6#define DUNE_PARMETIS_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_HYBRIDUTILITIES_HH
│ │ │ │ +
6#define DUNE_COMMON_HYBRIDUTILITIES_HH
│ │ │ │
7
│ │ │ │ -
15#if HAVE_PARMETIS
│ │ │ │ +
8#include <tuple>
│ │ │ │ +
9#include <utility>
│ │ │ │ +
10
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │
16
│ │ │ │ -
17#if HAVE_MPI
│ │ │ │ -
18#include <mpi.h>
│ │ │ │ -
19#endif
│ │ │ │ -
20
│ │ │ │ -
21#if HAVE_PTSCOTCH_PARMETIS
│ │ │ │ -
22extern "C" {
│ │ │ │ -
23 #include <ptscotch.h>
│ │ │ │ -
24}
│ │ │ │ -
25#endif
│ │ │ │ -
26
│ │ │ │ -
27extern "C" {
│ │ │ │ -
28 #include <parmetis.h>
│ │ │ │ -
29}
│ │ │ │ -
30
│ │ │ │ -
31namespace Dune::ParMetis {
│ │ │ │ -
32
│ │ │ │ -
33#if defined(REALTYPEWIDTH)
│ │ │ │ -
34 using real_t = ::real_t;
│ │ │ │ -
35#else
│ │ │ │ -
36 using real_t = float;
│ │ │ │ -
37#endif
│ │ │ │ -
38
│ │ │ │ -
39#if defined(IDXTYPEWIDTH)
│ │ │ │ -
40 using idx_t = ::idx_t;
│ │ │ │ -
41#elif HAVE_PTSCOTCH_PARMETIS
│ │ │ │ -
42 using idx_t = SCOTCH_Num;
│ │ │ │ -
43#else
│ │ │ │ -
44 using idx_t = int;
│ │ │ │ -
45#endif
│ │ │ │ +
17
│ │ │ │ +
18
│ │ │ │ +
19namespace Dune {
│ │ │ │ +
│ │ │ │ +
20namespace Hybrid {
│ │ │ │ +
21
│ │ │ │ +
22namespace Impl {
│ │ │ │ +
23
│ │ │ │ +
24 // Try if std::tuple_size is implemented for class
│ │ │ │ +
25 template<class T>
│ │ │ │ +
26 constexpr auto size(const T&, const PriorityTag<2>&)
│ │ │ │ +
27 -> decltype(std::integral_constant<std::size_t,std::tuple_size<T>::value>())
│ │ │ │ +
28 {
│ │ │ │ +
29 return {};
│ │ │ │ +
30 }
│ │ │ │ +
31
│ │ │ │ +
32 // Try if there's a static constexpr size() method
│ │ │ │ +
33 template<class T>
│ │ │ │ +
34 constexpr auto size(const T&, const PriorityTag<1>&)
│ │ │ │ +
35 -> decltype(std::integral_constant<std::size_t,T::size()>())
│ │ │ │ +
36 {
│ │ │ │ +
37 return {};
│ │ │ │ +
38 }
│ │ │ │ +
39
│ │ │ │ +
40 // As a last resort try if there's a non-static size()
│ │ │ │ +
41 template<class T>
│ │ │ │ +
42 constexpr auto size(const T& t, const PriorityTag<0>&)
│ │ │ │ +
43 {
│ │ │ │ +
44 return t.size();
│ │ │ │ +
45 }
│ │ │ │
46
│ │ │ │ -
47} // end namespace Dune::ParMetis
│ │ │ │ +
47} // namespace Impl
│ │ │ │
48
│ │ │ │ -
49#endif // HAVE_PARMETIS
│ │ │ │ -
50#endif // DUNE_PARMETIS_HH
│ │ │ │ -
typename FieldTraits< Type >::real_type real_t
Convenient access to FieldTraits<Type>::real_type.
Definition typetraits.hh:301
│ │ │ │ +
49
│ │ │ │ +
50
│ │ │ │ +
72template<class T>
│ │ │ │ +
│ │ │ │ +
73constexpr auto size(const T& t)
│ │ │ │ +
74{
│ │ │ │ +
75 return Impl::size(t, PriorityTag<42>());
│ │ │ │ +
76}
│ │ │ │ +
│ │ │ │ +
77
│ │ │ │ +
78
│ │ │ │ +
79
│ │ │ │ +
80namespace Impl {
│ │ │ │ +
81
│ │ │ │ +
82 template<class Container, class Index,
│ │ │ │ +
83 std::enable_if_t<IsTuple<std::decay_t<Container>>::value, int> = 0>
│ │ │ │ +
84 constexpr decltype(auto) elementAt(Container&& c, Index&&, PriorityTag<2>)
│ │ │ │ +
85 {
│ │ │ │ +
86 return std::get<std::decay_t<Index>::value>(c);
│ │ │ │ +
87 }
│ │ │ │ +
88
│ │ │ │ +
89 template<class T, T... t, class Index>
│ │ │ │ +
90 constexpr decltype(auto) elementAt(std::integer_sequence<T, t...> c, Index, PriorityTag<1>)
│ │ │ │ +
91 {
│ │ │ │ +
92 return Dune::integerSequenceEntry(c, std::integral_constant<std::size_t, Index::value>());
│ │ │ │ +
93 }
│ │ │ │ +
94
│ │ │ │ +
95 template<class Container, class Index>
│ │ │ │ +
96 constexpr decltype(auto) elementAt(Container&& c, Index&& i, PriorityTag<0>)
│ │ │ │ +
97 {
│ │ │ │ +
98 return c[i];
│ │ │ │ +
99 }
│ │ │ │ +
100
│ │ │ │ +
101} // namespace Impl
│ │ │ │ +
102
│ │ │ │ +
103
│ │ │ │ +
104
│ │ │ │ +
125template<class Container, class Index>
│ │ │ │ +
│ │ │ │ +
126constexpr decltype(auto) elementAt(Container&& c, Index&& i)
│ │ │ │ +
127{
│ │ │ │ +
128 return Impl::elementAt(std::forward<Container>(c), std::forward<Index>(i), PriorityTag<42>());
│ │ │ │ +
129}
│ │ │ │ +
│ │ │ │ +
130
│ │ │ │ +
131
│ │ │ │ +
132
│ │ │ │ +
133namespace Impl {
│ │ │ │ +
134
│ │ │ │ +
135 template<class Begin, class End,
│ │ │ │ +
136 std::enable_if_t<IsIntegralConstant<Begin>::value and IsIntegralConstant<End>::value, int> = 0>
│ │ │ │ +
137 constexpr auto integralRange(const Begin& /*begin*/, const End& /*end*/, const PriorityTag<1>&)
│ │ │ │ +
138 {
│ │ │ │ +
139 static_assert(Begin::value <= End::value, "You cannot create an integralRange where end<begin");
│ │ │ │ + │ │ │ │ +
141 }
│ │ │ │ +
142
│ │ │ │ +
143 template<class Begin, class End>
│ │ │ │ +
144 constexpr auto integralRange(const Begin& begin, const End& end, const PriorityTag<0>&)
│ │ │ │ +
145 {
│ │ │ │ +
146 assert(begin<=end && "You cannot create an integralRange where end<begin");
│ │ │ │ +
147 return Dune::IntegralRange<End>(begin, end);
│ │ │ │ +
148 }
│ │ │ │ +
149
│ │ │ │ +
150} // namespace Impl
│ │ │ │ +
151
│ │ │ │ +
152
│ │ │ │ +
153
│ │ │ │ +
171template<class Begin, class End>
│ │ │ │ +
│ │ │ │ +
172constexpr auto integralRange(const Begin& begin, const End& end)
│ │ │ │ +
173{
│ │ │ │ +
174 return Impl::integralRange(begin, end, PriorityTag<42>());
│ │ │ │ +
175}
│ │ │ │ +
│ │ │ │ +
176
│ │ │ │ +
190template<class End>
│ │ │ │ +
│ │ │ │ +
191constexpr auto integralRange(const End& end)
│ │ │ │ +
192{
│ │ │ │ +
193 return Impl::integralRange(Dune::Indices::_0, end, PriorityTag<42>());
│ │ │ │ +
194}
│ │ │ │ +
│ │ │ │ +
195
│ │ │ │ +
196
│ │ │ │ +
197
│ │ │ │ +
198namespace Impl {
│ │ │ │ +
199
│ │ │ │ +
200 template<class T>
│ │ │ │ +
201 constexpr void evaluateFoldExpression(std::initializer_list<T>&&)
│ │ │ │ +
202 {}
│ │ │ │ +
203
│ │ │ │ +
204 template<class Range, class F, class Index, Index... i>
│ │ │ │ +
205 constexpr void forEachIndex(Range&& range, F&& f, std::integer_sequence<Index, i...>)
│ │ │ │ +
206 {
│ │ │ │ +
207 evaluateFoldExpression<int>({(f(Hybrid::elementAt(range, std::integral_constant<Index,i>())), 0)...});
│ │ │ │ +
208 }
│ │ │ │ +
209
│ │ │ │ +
210 template<class F, class Index, Index... i>
│ │ │ │ +
211 constexpr void forEach(std::integer_sequence<Index, i...> /*range*/, F&& f, PriorityTag<2>)
│ │ │ │ +
212 {
│ │ │ │ +
213 evaluateFoldExpression<int>({(f(std::integral_constant<Index,i>()), 0)...});
│ │ │ │ +
214 }
│ │ │ │ +
215
│ │ │ │ +
216
│ │ │ │ +
217 template<class Range, class F,
│ │ │ │ +
218 std::enable_if_t<IsIntegralConstant<decltype(Hybrid::size(std::declval<Range>()))>::value, int> = 0>
│ │ │ │ +
219 constexpr void forEach(Range&& range, F&& f, PriorityTag<1>)
│ │ │ │ +
220 {
│ │ │ │ +
221 auto size = Hybrid::size(range);
│ │ │ │ +
222 auto indices = std::make_index_sequence<size>();
│ │ │ │ +
223 (forEachIndex)(std::forward<Range>(range), std::forward<F>(f), indices);
│ │ │ │ +
224 }
│ │ │ │ +
225
│ │ │ │ +
226 template<class Range, class F>
│ │ │ │ +
227 constexpr void forEach(Range&& range, F&& f, PriorityTag<0>)
│ │ │ │ +
228 {
│ │ │ │ +
229 for(auto&& e : range)
│ │ │ │ +
230 f(e);
│ │ │ │ +
231 }
│ │ │ │ +
232
│ │ │ │ +
233} // namespace Impl
│ │ │ │ +
234
│ │ │ │ +
235
│ │ │ │ +
236
│ │ │ │ +
255template<class Range, class F>
│ │ │ │ +
│ │ │ │ +
256constexpr void forEach(Range&& range, F&& f)
│ │ │ │ +
257{
│ │ │ │ +
258 Impl::forEach(std::forward<Range>(range), std::forward<F>(f), PriorityTag<42>());
│ │ │ │ +
259}
│ │ │ │ +
│ │ │ │ +
260
│ │ │ │ +
261
│ │ │ │ +
262
│ │ │ │ +
278template<class Range, class T, class F>
│ │ │ │ +
│ │ │ │ +
279constexpr T accumulate(Range&& range, T value, F&& f)
│ │ │ │ +
280{
│ │ │ │ +
281 forEach(std::forward<Range>(range), [&](auto&& entry) {
│ │ │ │ +
282 value = f(value, entry);
│ │ │ │ +
283 });
│ │ │ │ +
284 return value;
│ │ │ │ +
285}
│ │ │ │ +
│ │ │ │ +
286
│ │ │ │ +
287
│ │ │ │ +
288
│ │ │ │ +
289namespace Impl {
│ │ │ │ +
290
│ │ │ │ +
291 struct Id {
│ │ │ │ +
292 template<class T>
│ │ │ │ +
293 constexpr T operator()(T&& x) const {
│ │ │ │ +
294 return std::forward<T>(x);
│ │ │ │ +
295 }
│ │ │ │ +
296 };
│ │ │ │ +
297
│ │ │ │ +
298 template<class IfFunc, class ElseFunc>
│ │ │ │ +
299 constexpr decltype(auto) ifElse(std::true_type, IfFunc&& ifFunc, ElseFunc&& /*elseFunc*/)
│ │ │ │ +
300 {
│ │ │ │ +
301 return ifFunc(Id{});
│ │ │ │ +
302 }
│ │ │ │ +
303
│ │ │ │ +
304 template<class IfFunc, class ElseFunc>
│ │ │ │ +
305 constexpr decltype(auto) ifElse(std::false_type, IfFunc&& /*ifFunc*/, ElseFunc&& elseFunc)
│ │ │ │ +
306 {
│ │ │ │ +
307 return elseFunc(Id{});
│ │ │ │ +
308 }
│ │ │ │ +
309
│ │ │ │ +
310 template<class IfFunc, class ElseFunc>
│ │ │ │ +
311 decltype(auto) ifElse(const bool& condition, IfFunc&& ifFunc, ElseFunc&& elseFunc)
│ │ │ │ +
312 {
│ │ │ │ +
313 if (condition)
│ │ │ │ +
314 return ifFunc(Id{});
│ │ │ │ +
315 else
│ │ │ │ +
316 return elseFunc(Id{});
│ │ │ │ +
317 }
│ │ │ │ +
318
│ │ │ │ +
319} // namespace Impl
│ │ │ │ +
320
│ │ │ │ +
321
│ │ │ │ +
322
│ │ │ │ +
343template<class Condition, class IfFunc, class ElseFunc>
│ │ │ │ +
│ │ │ │ +
344decltype(auto) ifElse(const Condition& condition, IfFunc&& ifFunc, ElseFunc&& elseFunc)
│ │ │ │ +
345{
│ │ │ │ +
346 return Impl::ifElse(condition, std::forward<IfFunc>(ifFunc), std::forward<ElseFunc>(elseFunc));
│ │ │ │ +
347}
│ │ │ │ +
│ │ │ │ +
348
│ │ │ │ +
356template<class Condition, class IfFunc>
│ │ │ │ +
│ │ │ │ +
357void ifElse(const Condition& condition, IfFunc&& ifFunc)
│ │ │ │ +
358{
│ │ │ │ +
359 ifElse(condition, std::forward<IfFunc>(ifFunc), [](auto&&) {});
│ │ │ │ +
360}
│ │ │ │ +
│ │ │ │ +
361
│ │ │ │ +
362
│ │ │ │ +
363
│ │ │ │ +
364namespace Impl {
│ │ │ │ +
365
│ │ │ │ +
366 struct Max {
│ │ │ │ +
367 template<class... Args>
│ │ │ │ +
368 constexpr decltype(auto) operator()(Args&&... args) const
│ │ │ │ +
369 {
│ │ │ │ +
370 using T = std::common_type_t<Args...>;
│ │ │ │ +
371 return std::max({T(args)...});
│ │ │ │ +
372 }
│ │ │ │ +
373 };
│ │ │ │ +
374
│ │ │ │ +
375 struct Min {
│ │ │ │ +
376 template<class... Args>
│ │ │ │ +
377 constexpr decltype(auto) operator()(Args&&... args) const
│ │ │ │ +
378 {
│ │ │ │ +
379 using T = std::common_type_t<Args...>;
│ │ │ │ +
380 return std::min({T(args)...});
│ │ │ │ +
381 }
│ │ │ │ +
382 };
│ │ │ │ +
383
│ │ │ │ +
384} // namespace Impl
│ │ │ │ +
385
│ │ │ │ +
386
│ │ │ │ +
417template<class Functor>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
419
│ │ │ │ +
420 static_assert(std::is_default_constructible_v<Functor>,
│ │ │ │ +
421 "Operator in integral expressions shall be constexpr default constructible");
│ │ │ │ +
422
│ │ │ │ +
423 inline static constexpr Functor _functor = Functor{};
│ │ │ │ +
424
│ │ │ │ +
425public:
│ │ │ │ +
426
│ │ │ │ +
436 template<class... Args>
│ │ │ │ +
│ │ │ │ +
437 constexpr decltype(auto) operator()(const Args&... args) const
│ │ │ │ +
438 {
│ │ │ │ +
439 if constexpr (std::conjunction_v<IsCompileTimeConstant<Args>...>)
│ │ │ │ +
440 {
│ │ │ │ +
441 constexpr auto result = _functor(Args::value...);
│ │ │ │ +
442 // apply functor on integral constant arguments and return an integral constant of the result
│ │ │ │ +
443 // this is guaranteed to be evaluated at compile-time
│ │ │ │ +
444 return std::integral_constant<std::remove_cv_t<decltype(result)>,result>{};
│ │ │ │ +
445 } else {
│ │ │ │ +
446 // apply functor directly on arguments and return the result of the functor
│ │ │ │ +
447 // (integral constants are likely to be casted to underlying type)
│ │ │ │ +
448 // this not is guaranteed to be evaluated at compile-time although is possible if expression is constexpr
│ │ │ │ +
449 return _functor(args...);
│ │ │ │ +
450 }
│ │ │ │ +
451 }
│ │ │ │ +
│ │ │ │ +
452};
│ │ │ │ +
│ │ │ │ +
453
│ │ │ │ +
458template<class Functor>
│ │ │ │ +
│ │ │ │ +
459constexpr HybridFunctor<Functor> hybridFunctor(const Functor&)
│ │ │ │ +
460{
│ │ │ │ +
461 return {};
│ │ │ │ +
462}
│ │ │ │ +
│ │ │ │ +
463
│ │ │ │ +
484inline constexpr auto max = hybridFunctor(Impl::Max{});
│ │ │ │ +
485
│ │ │ │ +
506inline constexpr auto min = hybridFunctor(Impl::Min{});
│ │ │ │ +
507
│ │ │ │ +
528inline constexpr auto plus = hybridFunctor(std::plus<>{});
│ │ │ │ +
529
│ │ │ │ +
550inline constexpr auto minus = hybridFunctor(std::minus<>{});
│ │ │ │ +
551
│ │ │ │ +
572inline constexpr auto equal_to = hybridFunctor(std::equal_to<>{});
│ │ │ │ +
573
│ │ │ │ +
574
│ │ │ │ +
586template<class T1, class T2>
│ │ │ │ +
│ │ │ │ +
587[[deprecated("Use Hybrid::equal_to instead!")]] constexpr auto equals(T1&& t1, T2&& t2){
│ │ │ │ +
588 return equal_to(std::forward<T1>(t1), std::forward<T2>(t2));
│ │ │ │ +
589}
│ │ │ │ +
│ │ │ │ +
590
│ │ │ │ +
591
│ │ │ │ +
592namespace Impl {
│ │ │ │ +
593
│ │ │ │ +
594 // This overload is selected if the passed value is already a compile time constant.
│ │ │ │ +
595 template<class Result, class T, T t0, T... tt, class ValueType, ValueType value, class Branches, class ElseBranch>
│ │ │ │ +
596 constexpr Result switchCases(std::integer_sequence<T, t0, tt...>, const std::integral_constant<ValueType, value>& /*value*/, Branches&& branches, ElseBranch&& elseBranch)
│ │ │ │ +
597 {
│ │ │ │ +
598 // In case we pass a value known at compile time, we no longer have to do
│ │ │ │ +
599 // a dynamic to static dispatch via recursion. The only thing that's left
│ │ │ │ +
600 // is to check if the value is contained in the passed range.
│ │ │ │ +
601 // If this is true, we have to pass it to the branches callback
│ │ │ │ +
602 // as an appropriate integral_constant type. Otherwise we have to
│ │ │ │ +
603 // execute the else callback.
│ │ │ │ +
604 if constexpr (((t0 == value) || ... || (tt == value)))
│ │ │ │ +
605 return branches(std::integral_constant<T, value>{});
│ │ │ │ +
606 else
│ │ │ │ +
607 return elseBranch();
│ │ │ │ +
608 }
│ │ │ │ +
609
│ │ │ │ +
610 // This overload is selected if the passed value is dynamic.
│ │ │ │ +
611 template<class Result, class T, class Value, class Branches, class ElseBranch>
│ │ │ │ +
612 constexpr Result switchCases(std::integer_sequence<T>, const Value& /*value*/, Branches&& /*branches*/, ElseBranch&& elseBranch)
│ │ │ │ +
613 {
│ │ │ │ +
614 return elseBranch();
│ │ │ │ +
615 }
│ │ │ │ +
616
│ │ │ │ +
617 template<class Result, class T, T t0, T... tt, class Value, class Branches, class ElseBranch>
│ │ │ │ +
618 constexpr Result switchCases(std::integer_sequence<T, t0, tt...>, const Value& value, Branches&& branches, ElseBranch&& elseBranch)
│ │ │ │ +
619 {
│ │ │ │ +
620 if (t0 == value)
│ │ │ │ +
621 return branches(std::integral_constant<T, t0>());
│ │ │ │ +
622 else
│ │ │ │ +
623 return Impl::switchCases<Result>(std::integer_sequence<T, tt...>(), value, branches, elseBranch);
│ │ │ │ +
624 }
│ │ │ │ +
625
│ │ │ │ +
626 // This overload is selected if the range of cases is an IntegralRange
│ │ │ │ +
627 template <class Result, class T, class Value, class Branches, class ElseBranch>
│ │ │ │ +
628 constexpr Result switchCases(IntegralRange<T> range, const Value& value, Branches&& branches, ElseBranch&& elseBranch)
│ │ │ │ +
629 {
│ │ │ │ +
630 return range.contains(value) ? branches(T(value)) : elseBranch();
│ │ │ │ +
631 }
│ │ │ │ +
632
│ │ │ │ +
633 // This overload is selected if the range of cases is a StaticIntegralRange
│ │ │ │ +
634 template <class Result, class T, T to, T from, class Value, class Branches, class ElseBranch>
│ │ │ │ +
635 constexpr Result switchCases(StaticIntegralRange<T, to, from> range, const Value& value, Branches&& branches, ElseBranch&& elseBranch)
│ │ │ │ +
636 {
│ │ │ │ +
637 using seq = typename decltype(range)::integer_sequence;
│ │ │ │ +
638 return Impl::switchCases<Result>(seq{}, value, branches, elseBranch);
│ │ │ │ +
639 }
│ │ │ │ +
640
│ │ │ │ +
641} // namespace Impl
│ │ │ │ +
642
│ │ │ │ +
643
│ │ │ │ +
644
│ │ │ │ +
672template<class Cases, class Value, class Branches, class ElseBranch>
│ │ │ │ +
│ │ │ │ +
673constexpr decltype(auto) switchCases(const Cases& cases, const Value& value, Branches&& branches, ElseBranch&& elseBranch)
│ │ │ │ +
674{
│ │ │ │ +
675 return Impl::switchCases<decltype(elseBranch())>(cases, value, std::forward<Branches>(branches), std::forward<ElseBranch>(elseBranch));
│ │ │ │ +
676}
│ │ │ │ +
│ │ │ │ +
677
│ │ │ │ +
697template<class Cases, class Value, class Branches>
│ │ │ │ +
│ │ │ │ +
698constexpr void switchCases(const Cases& cases, const Value& value, Branches&& branches)
│ │ │ │ +
699{
│ │ │ │ +
700 Impl::switchCases<void>(cases, value, std::forward<Branches>(branches),
│ │ │ │ +
701 []{ assert(false && "value not found in range"); });
│ │ │ │ +
702}
│ │ │ │ +
│ │ │ │ +
703
│ │ │ │ +
722template <class T, class Value, class Branches>
│ │ │ │ +
│ │ │ │ +
723constexpr void switchCases(IntegralRange<T> range, const Value& value, Branches&& branches)
│ │ │ │ +
724{
│ │ │ │ +
725 assert(range.contains(value) && "value not found in range");
│ │ │ │ +
726 branches(T(value));
│ │ │ │ +
727}
│ │ │ │ +
│ │ │ │ +
728
│ │ │ │ +
729} // namespace Hybrid
│ │ │ │ +
│ │ │ │ +
730} // namespace Dune
│ │ │ │ +
731
│ │ │ │ +
732
│ │ │ │ +
733#endif // #ifndef DUNE_COMMON_HYBRIDUTILITIES_HH
│ │ │ │ +
Utilities for reduction like operations on ranges.
│ │ │ │ +
Utilities for type computations, constraining overloads, ...
│ │ │ │ +
Implements a vector constructed from a given type representing a field and a compile-time given size.
│ │ │ │ + │ │ │ │ +
Traits for type conversions and type information.
│ │ │ │ +
constexpr index_constant< 0 > _0
Compile time index with value 0.
Definition indices.hh:52
│ │ │ │ +
static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
Definition rangeutilities.hh:312
│ │ │ │ +
constexpr auto size(const T &t)
Size query.
Definition hybridutilities.hh:73
│ │ │ │ +
constexpr auto minus
Function object for performing subtraction.
Definition hybridutilities.hh:550
│ │ │ │ +
constexpr auto equals(T1 &&t1, T2 &&t2)
Equality comparison.
Definition hybridutilities.hh:587
│ │ │ │ +
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition hybridutilities.hh:256
│ │ │ │ +
constexpr auto equal_to
Function object for performing equality comparison.
Definition hybridutilities.hh:572
│ │ │ │ +
constexpr decltype(auto) switchCases(const Cases &cases, const Value &value, Branches &&branches, ElseBranch &&elseBranch)
Switch statement.
Definition hybridutilities.hh:673
│ │ │ │ +
constexpr auto max
Function object that returns the greater of the given values.
Definition hybridutilities.hh:484
│ │ │ │ +
constexpr auto plus
Function object for performing addition.
Definition hybridutilities.hh:528
│ │ │ │ +
constexpr auto min
Function object that returns the smaller of the given values.
Definition hybridutilities.hh:506
│ │ │ │ +
decltype(auto) ifElse(const Condition &condition, IfFunc &&ifFunc, ElseFunc &&elseFunc)
A conditional expression.
Definition hybridutilities.hh:344
│ │ │ │ +
constexpr auto integralRange(const Begin &begin, const End &end)
Create an integral range.
Definition hybridutilities.hh:172
│ │ │ │ +
constexpr decltype(auto) elementAt(Container &&c, Index &&i)
Get element at given position from container.
Definition hybridutilities.hh:126
│ │ │ │ +
constexpr T accumulate(Range &&range, T value, F &&f)
Accumulate values.
Definition hybridutilities.hh:279
│ │ │ │ +
constexpr auto integerSequenceEntry(std::integer_sequence< T, t... >, std::integral_constant< std::size_t, index > i)
Get entry of std::integer_sequence.
Definition typetraits.hh:492
│ │ │ │ +
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ +
constexpr HybridFunctor< Functor > hybridFunctor(const Functor &)
Returns an HybridFunctor adaptor.
Definition hybridutilities.hh:459
│ │ │ │ +
Definition binaryfunctions.hh:34
│ │ │ │ +
Adapter of a hybrid functor that maintains results hybrid.
Definition hybridutilities.hh:418
│ │ │ │ +
dynamic integer range for use in range-based for loops
Definition rangeutilities.hh:177
│ │ │ │ +
static integer range for use in range-based for loops
Definition rangeutilities.hh:230
│ │ │ │ +
Check if T is an std::integral_constant<I, i>
Definition typetraits.hh:384
│ │ │ │ +
Helper class for tagging priorities.
Definition typeutilities.hh:73
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,59 +1,535 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -parmetis.hh │ │ │ │ │ +hybridutilities.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_PARMETIS_HH │ │ │ │ │ -6#define DUNE_PARMETIS_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_HYBRIDUTILITIES_HH │ │ │ │ │ +6#define DUNE_COMMON_HYBRIDUTILITIES_HH │ │ │ │ │ 7 │ │ │ │ │ -15#if HAVE_PARMETIS │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10 │ │ │ │ │ +11#include │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14#include │ │ │ │ │ +15#include │ │ │ │ │ 16 │ │ │ │ │ -17#if HAVE_MPI │ │ │ │ │ -18#include │ │ │ │ │ -19#endif │ │ │ │ │ -20 │ │ │ │ │ -21#if HAVE_PTSCOTCH_PARMETIS │ │ │ │ │ -22extern "C" { │ │ │ │ │ -23 #include │ │ │ │ │ -24} │ │ │ │ │ -25#endif │ │ │ │ │ -26 │ │ │ │ │ -27extern "C" { │ │ │ │ │ -28 #include │ │ │ │ │ -29} │ │ │ │ │ -30 │ │ │ │ │ -31namespace Dune::ParMetis { │ │ │ │ │ -32 │ │ │ │ │ -33#if defined(REALTYPEWIDTH) │ │ │ │ │ -34 using real_t = ::real_t; │ │ │ │ │ -35#else │ │ │ │ │ -36 using real_t = float; │ │ │ │ │ -37#endif │ │ │ │ │ -38 │ │ │ │ │ -39#if defined(IDXTYPEWIDTH) │ │ │ │ │ -40 using idx_t = ::idx_t; │ │ │ │ │ -41#elif HAVE_PTSCOTCH_PARMETIS │ │ │ │ │ -42 using idx_t = SCOTCH_Num; │ │ │ │ │ -43#else │ │ │ │ │ -44 using idx_t = int; │ │ │ │ │ -45#endif │ │ │ │ │ +17 │ │ │ │ │ +18 │ │ │ │ │ +19namespace Dune { │ │ │ │ │ +20namespace Hybrid { │ │ │ │ │ +21 │ │ │ │ │ +22namespace Impl { │ │ │ │ │ +23 │ │ │ │ │ +24 // Try if std::tuple_size is implemented for class │ │ │ │ │ +25 template │ │ │ │ │ +26 constexpr auto size(const T&, const PriorityTag<2>&) │ │ │ │ │ +27 -> decltype(std::integral_constant::value>()) │ │ │ │ │ +28 { │ │ │ │ │ +29 return {}; │ │ │ │ │ +30 } │ │ │ │ │ +31 │ │ │ │ │ +32 // Try if there's a static constexpr size() method │ │ │ │ │ +33 template │ │ │ │ │ +34 constexpr auto size(const T&, const PriorityTag<1>&) │ │ │ │ │ +35 -> decltype(std::integral_constant()) │ │ │ │ │ +36 { │ │ │ │ │ +37 return {}; │ │ │ │ │ +38 } │ │ │ │ │ +39 │ │ │ │ │ +40 // As a last resort try if there's a non-static size() │ │ │ │ │ +41 template │ │ │ │ │ +42 constexpr auto size(const T& t, const PriorityTag<0>&) │ │ │ │ │ +43 { │ │ │ │ │ +44 return t.size(); │ │ │ │ │ +45 } │ │ │ │ │ 46 │ │ │ │ │ -47} // end namespace Dune::ParMetis │ │ │ │ │ +47} // namespace Impl │ │ │ │ │ 48 │ │ │ │ │ -49#endif // HAVE_PARMETIS │ │ │ │ │ -50#endif // DUNE_PARMETIS_HH │ │ │ │ │ -Dune::real_t │ │ │ │ │ -typename FieldTraits< Type >::real_type real_t │ │ │ │ │ -Convenient access to FieldTraits::real_type. │ │ │ │ │ -Definition typetraits.hh:301 │ │ │ │ │ +49 │ │ │ │ │ +50 │ │ │ │ │ +72template │ │ │ │ │ +73constexpr auto size(const T& t) │ │ │ │ │ +74{ │ │ │ │ │ +75 return Impl::size(t, PriorityTag<42>()); │ │ │ │ │ +76} │ │ │ │ │ +77 │ │ │ │ │ +78 │ │ │ │ │ +79 │ │ │ │ │ +80namespace Impl { │ │ │ │ │ +81 │ │ │ │ │ +82 template>::value, int> = 0> │ │ │ │ │ +84 constexpr decltype(auto) elementAt(Container&& c, Index&&, PriorityTag<2>) │ │ │ │ │ +85 { │ │ │ │ │ +86 return std::get::value>(c); │ │ │ │ │ +87 } │ │ │ │ │ +88 │ │ │ │ │ +89 template │ │ │ │ │ +90 constexpr decltype(auto) elementAt(std::integer_sequence c, Index, │ │ │ │ │ +PriorityTag<1>) │ │ │ │ │ +91 { │ │ │ │ │ +92 return Dune::integerSequenceEntry(c, std::integral_constant()); │ │ │ │ │ +93 } │ │ │ │ │ +94 │ │ │ │ │ +95 template │ │ │ │ │ +96 constexpr decltype(auto) elementAt(Container&& c, Index&& i, PriorityTag<0>) │ │ │ │ │ +97 { │ │ │ │ │ +98 return c[i]; │ │ │ │ │ +99 } │ │ │ │ │ +100 │ │ │ │ │ +101} // namespace Impl │ │ │ │ │ +102 │ │ │ │ │ +103 │ │ │ │ │ +104 │ │ │ │ │ +125template │ │ │ │ │ +126constexpr decltype(auto) elementAt(Container&& c, Index&& i) │ │ │ │ │ +127{ │ │ │ │ │ +128 return Impl::elementAt(std::forward(c), std::forward(i), │ │ │ │ │ +PriorityTag<42>()); │ │ │ │ │ +129} │ │ │ │ │ +130 │ │ │ │ │ +131 │ │ │ │ │ +132 │ │ │ │ │ +133namespace Impl { │ │ │ │ │ +134 │ │ │ │ │ +135 template::value and │ │ │ │ │ +IsIntegralConstant::value, int> = 0> │ │ │ │ │ +137 constexpr auto integralRange(const Begin& /*begin*/, const End& /*end*/, │ │ │ │ │ +const PriorityTag<1>&) │ │ │ │ │ +138 { │ │ │ │ │ +139 static_assert(Begin::value <= End::value, "You cannot create an │ │ │ │ │ +integralRange where end(); │ │ │ │ │ +141 } │ │ │ │ │ +142 │ │ │ │ │ +143 template │ │ │ │ │ +144 constexpr auto integralRange(const Begin& begin, const End& end, const │ │ │ │ │ +PriorityTag<0>&) │ │ │ │ │ +145 { │ │ │ │ │ +146 assert(begin<=end && "You cannot create an integralRange where end(begin, end); │ │ │ │ │ +148 } │ │ │ │ │ +149 │ │ │ │ │ +150} // namespace Impl │ │ │ │ │ +151 │ │ │ │ │ +152 │ │ │ │ │ +153 │ │ │ │ │ +171template │ │ │ │ │ +172constexpr auto integralRange(const Begin& begin, const End& end) │ │ │ │ │ +173{ │ │ │ │ │ +174 return Impl::integralRange(begin, end, PriorityTag<42>()); │ │ │ │ │ +175} │ │ │ │ │ +176 │ │ │ │ │ +190template │ │ │ │ │ +191constexpr auto integralRange(const End& end) │ │ │ │ │ +192{ │ │ │ │ │ +193 return Impl::integralRange(Dune::Indices::_0, end, PriorityTag<42>()); │ │ │ │ │ +194} │ │ │ │ │ +195 │ │ │ │ │ +196 │ │ │ │ │ +197 │ │ │ │ │ +198namespace Impl { │ │ │ │ │ +199 │ │ │ │ │ +200 template │ │ │ │ │ +201 constexpr void evaluateFoldExpression(std::initializer_list&&) │ │ │ │ │ +202 {} │ │ │ │ │ +203 │ │ │ │ │ +204 template │ │ │ │ │ +205 constexpr void forEachIndex(Range&& range, F&& f, std::integer_ │ │ │ │ │ +sequence) │ │ │ │ │ +206 { │ │ │ │ │ +207 evaluateFoldExpression({(f(Hybrid::elementAt(range, std::integral_ │ │ │ │ │ +constant())), 0)...}); │ │ │ │ │ +208 } │ │ │ │ │ +209 │ │ │ │ │ +210 template │ │ │ │ │ +211 constexpr void forEach(std::integer_sequence /*range*/, F&& f, │ │ │ │ │ +PriorityTag<2>) │ │ │ │ │ +212 { │ │ │ │ │ +213 evaluateFoldExpression({(f(std::integral_constant()), │ │ │ │ │ +0)...}); │ │ │ │ │ +214 } │ │ │ │ │ +215 │ │ │ │ │ +216 │ │ │ │ │ +217 template()))>::value, int> = 0> │ │ │ │ │ +219 constexpr void forEach(Range&& range, F&& f, PriorityTag<1>) │ │ │ │ │ +220 { │ │ │ │ │ +221 auto size = Hybrid::size(range); │ │ │ │ │ +222 auto indices = std::make_index_sequence(); │ │ │ │ │ +223 (forEachIndex)(std::forward(range), std::forward(f), indices); │ │ │ │ │ +224 } │ │ │ │ │ +225 │ │ │ │ │ +226 template │ │ │ │ │ +227 constexpr void forEach(Range&& range, F&& f, PriorityTag<0>) │ │ │ │ │ +228 { │ │ │ │ │ +229 for(auto&& e : range) │ │ │ │ │ +230 f(e); │ │ │ │ │ +231 } │ │ │ │ │ +232 │ │ │ │ │ +233} // namespace Impl │ │ │ │ │ +234 │ │ │ │ │ +235 │ │ │ │ │ +236 │ │ │ │ │ +255template │ │ │ │ │ +256constexpr void forEach(Range&& range, F&& f) │ │ │ │ │ +257{ │ │ │ │ │ +258 Impl::forEach(std::forward(range), std::forward(f), │ │ │ │ │ +PriorityTag<42>()); │ │ │ │ │ +259} │ │ │ │ │ +260 │ │ │ │ │ +261 │ │ │ │ │ +262 │ │ │ │ │ +278template │ │ │ │ │ +279constexpr T accumulate(Range&& range, T value, F&& f) │ │ │ │ │ +280{ │ │ │ │ │ +281 forEach(std::forward(range), [&](auto&& entry) { │ │ │ │ │ +282 value = f(value, entry); │ │ │ │ │ +283 }); │ │ │ │ │ +284 return value; │ │ │ │ │ +285} │ │ │ │ │ +286 │ │ │ │ │ +287 │ │ │ │ │ +288 │ │ │ │ │ +289namespace Impl { │ │ │ │ │ +290 │ │ │ │ │ +291 struct Id { │ │ │ │ │ +292 template │ │ │ │ │ +293 constexpr T operator()(T&& x) const { │ │ │ │ │ +294 return std::forward(x); │ │ │ │ │ +295 } │ │ │ │ │ +296 }; │ │ │ │ │ +297 │ │ │ │ │ +298 template │ │ │ │ │ +299 constexpr decltype(auto) ifElse(std::true_type, IfFunc&& ifFunc, ElseFunc&& │ │ │ │ │ +/*elseFunc*/) │ │ │ │ │ +300 { │ │ │ │ │ +301 return ifFunc(Id{}); │ │ │ │ │ +302 } │ │ │ │ │ +303 │ │ │ │ │ +304 template │ │ │ │ │ +305 constexpr decltype(auto) ifElse(std::false_type, IfFunc&& /*ifFunc*/, │ │ │ │ │ +ElseFunc&& elseFunc) │ │ │ │ │ +306 { │ │ │ │ │ +307 return elseFunc(Id{}); │ │ │ │ │ +308 } │ │ │ │ │ +309 │ │ │ │ │ +310 template │ │ │ │ │ +311 decltype(auto) ifElse(const bool& condition, IfFunc&& ifFunc, ElseFunc&& │ │ │ │ │ +elseFunc) │ │ │ │ │ +312 { │ │ │ │ │ +313 if (condition) │ │ │ │ │ +314 return ifFunc(Id{}); │ │ │ │ │ +315 else │ │ │ │ │ +316 return elseFunc(Id{}); │ │ │ │ │ +317 } │ │ │ │ │ +318 │ │ │ │ │ +319} // namespace Impl │ │ │ │ │ +320 │ │ │ │ │ +321 │ │ │ │ │ +322 │ │ │ │ │ +343template │ │ │ │ │ +344decltype(auto) ifElse(const Condition& condition, IfFunc&& ifFunc, │ │ │ │ │ +ElseFunc&& elseFunc) │ │ │ │ │ +345{ │ │ │ │ │ +346 return Impl::ifElse(condition, std::forward(ifFunc), std:: │ │ │ │ │ +forward(elseFunc)); │ │ │ │ │ +347} │ │ │ │ │ +348 │ │ │ │ │ +356template │ │ │ │ │ +357void ifElse(const Condition& condition, IfFunc&& ifFunc) │ │ │ │ │ +358{ │ │ │ │ │ +359 ifElse(condition, std::forward(ifFunc), [](auto&&) {}); │ │ │ │ │ +360} │ │ │ │ │ +361 │ │ │ │ │ +362 │ │ │ │ │ +363 │ │ │ │ │ +364namespace Impl { │ │ │ │ │ +365 │ │ │ │ │ +366 struct Max { │ │ │ │ │ +367 template │ │ │ │ │ +368 constexpr decltype(auto) operator()(Args&&... args) const │ │ │ │ │ +369 { │ │ │ │ │ +370 using T = std::common_type_t; │ │ │ │ │ +371 return std::max({T(args)...}); │ │ │ │ │ +372 } │ │ │ │ │ +373 }; │ │ │ │ │ +374 │ │ │ │ │ +375 struct Min { │ │ │ │ │ +376 template │ │ │ │ │ +377 constexpr decltype(auto) operator()(Args&&... args) const │ │ │ │ │ +378 { │ │ │ │ │ +379 using T = std::common_type_t; │ │ │ │ │ +380 return std::min({T(args)...}); │ │ │ │ │ +381 } │ │ │ │ │ +382 }; │ │ │ │ │ +383 │ │ │ │ │ +384} // namespace Impl │ │ │ │ │ +385 │ │ │ │ │ +386 │ │ │ │ │ +417template │ │ │ │ │ +418class HybridFunctor { │ │ │ │ │ +419 │ │ │ │ │ +420 static_assert(std::is_default_constructible_v, │ │ │ │ │ +421 "Operator in integral expressions shall be constexpr default │ │ │ │ │ +constructible"); │ │ │ │ │ +422 │ │ │ │ │ +423 inline static constexpr Functor _functor = Functor{}; │ │ │ │ │ +424 │ │ │ │ │ +425public: │ │ │ │ │ +426 │ │ │ │ │ +436 template │ │ │ │ │ +437 constexpr decltype(auto) operator()(const Args&... args) const │ │ │ │ │ +438 { │ │ │ │ │ +439 if constexpr (std::conjunction_v...>) │ │ │ │ │ +440 { │ │ │ │ │ +441 constexpr auto result = _functor(Args::value...); │ │ │ │ │ +442 // apply functor on integral constant arguments and return an integral │ │ │ │ │ +constant of the result │ │ │ │ │ +443 // this is guaranteed to be evaluated at compile-time │ │ │ │ │ +444 return std::integral_constant,result>{}; │ │ │ │ │ +445 } else { │ │ │ │ │ +446 // apply functor directly on arguments and return the result of the functor │ │ │ │ │ +447 // (integral constants are likely to be casted to underlying type) │ │ │ │ │ +448 // this not is guaranteed to be evaluated at compile-time although is │ │ │ │ │ +possible if expression is constexpr │ │ │ │ │ +449 return _functor(args...); │ │ │ │ │ +450 } │ │ │ │ │ +451 } │ │ │ │ │ +452}; │ │ │ │ │ +453 │ │ │ │ │ +458template │ │ │ │ │ +459constexpr HybridFunctor hybridFunctor(const Functor&) │ │ │ │ │ +460{ │ │ │ │ │ +461 return {}; │ │ │ │ │ +462} │ │ │ │ │ +463 │ │ │ │ │ +484inline constexpr auto max = hybridFunctor(Impl::Max{}); │ │ │ │ │ +485 │ │ │ │ │ +506inline constexpr auto min = hybridFunctor(Impl::Min{}); │ │ │ │ │ +507 │ │ │ │ │ +528inline constexpr auto plus = hybridFunctor(std::plus<>{}); │ │ │ │ │ +529 │ │ │ │ │ +550inline constexpr auto minus = hybridFunctor(std::minus<>{}); │ │ │ │ │ +551 │ │ │ │ │ +572inline constexpr auto equal_to = hybridFunctor(std::equal_to<>{}); │ │ │ │ │ +573 │ │ │ │ │ +574 │ │ │ │ │ +586template │ │ │ │ │ +587[[deprecated("Use Hybrid::equal_to instead!")]] constexpr auto equals(T1&& │ │ │ │ │ +t1, T2&& t2){ │ │ │ │ │ +588 return equal_to(std::forward(t1), std::forward(t2)); │ │ │ │ │ +589} │ │ │ │ │ +590 │ │ │ │ │ +591 │ │ │ │ │ +592namespace Impl { │ │ │ │ │ +593 │ │ │ │ │ +594 // This overload is selected if the passed value is already a compile time │ │ │ │ │ +constant. │ │ │ │ │ +595 template │ │ │ │ │ +596 constexpr Result switchCases(std::integer_sequence, const │ │ │ │ │ +std::integral_constant& /*value*/, Branches&& branches, │ │ │ │ │ +ElseBranch&& elseBranch) │ │ │ │ │ +597 { │ │ │ │ │ +598 // In case we pass a value known at compile time, we no longer have to do │ │ │ │ │ +599 // a dynamic to static dispatch via recursion. The only thing that's left │ │ │ │ │ +600 // is to check if the value is contained in the passed range. │ │ │ │ │ +601 // If this is true, we have to pass it to the branches callback │ │ │ │ │ +602 // as an appropriate integral_constant type. Otherwise we have to │ │ │ │ │ +603 // execute the else callback. │ │ │ │ │ +604 if constexpr (((t0 == value) || ... || (tt == value))) │ │ │ │ │ +605 return branches(std::integral_constant{}); │ │ │ │ │ +606 else │ │ │ │ │ +607 return elseBranch(); │ │ │ │ │ +608 } │ │ │ │ │ +609 │ │ │ │ │ +610 // This overload is selected if the passed value is dynamic. │ │ │ │ │ +611 template │ │ │ │ │ +612 constexpr Result switchCases(std::integer_sequence, const Value& / │ │ │ │ │ +*value*/, Branches&& /*branches*/, ElseBranch&& elseBranch) │ │ │ │ │ +613 { │ │ │ │ │ +614 return elseBranch(); │ │ │ │ │ +615 } │ │ │ │ │ +616 │ │ │ │ │ +617 template │ │ │ │ │ +618 constexpr Result switchCases(std::integer_sequence, const │ │ │ │ │ +Value& value, Branches&& branches, ElseBranch&& elseBranch) │ │ │ │ │ +619 { │ │ │ │ │ +620 if (t0 == value) │ │ │ │ │ +621 return branches(std::integral_constant()); │ │ │ │ │ +622 else │ │ │ │ │ +623 return Impl::switchCases(std::integer_sequence(), value, │ │ │ │ │ +branches, elseBranch); │ │ │ │ │ +624 } │ │ │ │ │ +625 │ │ │ │ │ +626 // This overload is selected if the range of cases is an IntegralRange │ │ │ │ │ +627 template │ │ │ │ │ +628 constexpr Result switchCases(IntegralRange range, const Value& value, │ │ │ │ │ +Branches&& branches, ElseBranch&& elseBranch) │ │ │ │ │ +629 { │ │ │ │ │ +630 return range.contains(value) ? branches(T(value)) : elseBranch(); │ │ │ │ │ +631 } │ │ │ │ │ +632 │ │ │ │ │ +633 // This overload is selected if the range of cases is a StaticIntegralRange │ │ │ │ │ +634 template │ │ │ │ │ +635 constexpr Result switchCases(StaticIntegralRange range, const │ │ │ │ │ +Value& value, Branches&& branches, ElseBranch&& elseBranch) │ │ │ │ │ +636 { │ │ │ │ │ +637 using seq = typename decltype(range)::integer_sequence; │ │ │ │ │ +638 return Impl::switchCases(seq{}, value, branches, elseBranch); │ │ │ │ │ +639 } │ │ │ │ │ +640 │ │ │ │ │ +641} // namespace Impl │ │ │ │ │ +642 │ │ │ │ │ +643 │ │ │ │ │ +644 │ │ │ │ │ +672template │ │ │ │ │ +673constexpr decltype(auto) switchCases(const Cases& cases, const Value& value, │ │ │ │ │ +Branches&& branches, ElseBranch&& elseBranch) │ │ │ │ │ +674{ │ │ │ │ │ +675 return Impl::switchCases(cases, value, std:: │ │ │ │ │ +forward(branches), std::forward(elseBranch)); │ │ │ │ │ +676} │ │ │ │ │ +677 │ │ │ │ │ +697template │ │ │ │ │ +698constexpr void switchCases(const Cases& cases, const Value& value, │ │ │ │ │ +Branches&& branches) │ │ │ │ │ +699{ │ │ │ │ │ +700 Impl::switchCases(cases, value, std::forward(branches), │ │ │ │ │ +701 []{ assert(false && "value not found in range"); }); │ │ │ │ │ +702} │ │ │ │ │ +703 │ │ │ │ │ +722template │ │ │ │ │ +723constexpr void switchCases(IntegralRange range, const Value& value, │ │ │ │ │ +Branches&& branches) │ │ │ │ │ +724{ │ │ │ │ │ +725 assert(range.contains(value) && "value not found in range"); │ │ │ │ │ +726 branches(T(value)); │ │ │ │ │ +727} │ │ │ │ │ +728 │ │ │ │ │ +729} // namespace Hybrid │ │ │ │ │ +730} // namespace Dune │ │ │ │ │ +731 │ │ │ │ │ +732 │ │ │ │ │ +733#endif // #ifndef DUNE_COMMON_HYBRIDUTILITIES_HH │ │ │ │ │ +rangeutilities.hh │ │ │ │ │ +Utilities for reduction like operations on ranges. │ │ │ │ │ +typeutilities.hh │ │ │ │ │ +Utilities for type computations, constraining overloads, ... │ │ │ │ │ +fvector.hh │ │ │ │ │ +Implements a vector constructed from a given type representing a field and a │ │ │ │ │ +compile-time given size. │ │ │ │ │ +indices.hh │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +Dune::Indices::_0 │ │ │ │ │ +constexpr index_constant< 0 > _0 │ │ │ │ │ +Compile time index with value 0. │ │ │ │ │ +Definition indices.hh:52 │ │ │ │ │ +Dune::range │ │ │ │ │ +static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ +>, std::integral_constant< T, to >) noexcept │ │ │ │ │ +Definition rangeutilities.hh:312 │ │ │ │ │ +Dune::Hybrid::size │ │ │ │ │ +constexpr auto size(const T &t) │ │ │ │ │ +Size query. │ │ │ │ │ +Definition hybridutilities.hh:73 │ │ │ │ │ +Dune::Hybrid::minus │ │ │ │ │ +constexpr auto minus │ │ │ │ │ +Function object for performing subtraction. │ │ │ │ │ +Definition hybridutilities.hh:550 │ │ │ │ │ +Dune::Hybrid::equals │ │ │ │ │ +constexpr auto equals(T1 &&t1, T2 &&t2) │ │ │ │ │ +Equality comparison. │ │ │ │ │ +Definition hybridutilities.hh:587 │ │ │ │ │ +Dune::Hybrid::forEach │ │ │ │ │ +constexpr void forEach(Range &&range, F &&f) │ │ │ │ │ +Range based for loop. │ │ │ │ │ +Definition hybridutilities.hh:256 │ │ │ │ │ +Dune::Hybrid::equal_to │ │ │ │ │ +constexpr auto equal_to │ │ │ │ │ +Function object for performing equality comparison. │ │ │ │ │ +Definition hybridutilities.hh:572 │ │ │ │ │ +Dune::Hybrid::switchCases │ │ │ │ │ +constexpr decltype(auto) switchCases(const Cases &cases, const Value &value, │ │ │ │ │ +Branches &&branches, ElseBranch &&elseBranch) │ │ │ │ │ +Switch statement. │ │ │ │ │ +Definition hybridutilities.hh:673 │ │ │ │ │ +Dune::Hybrid::max │ │ │ │ │ +constexpr auto max │ │ │ │ │ +Function object that returns the greater of the given values. │ │ │ │ │ +Definition hybridutilities.hh:484 │ │ │ │ │ +Dune::Hybrid::plus │ │ │ │ │ +constexpr auto plus │ │ │ │ │ +Function object for performing addition. │ │ │ │ │ +Definition hybridutilities.hh:528 │ │ │ │ │ +Dune::Hybrid::min │ │ │ │ │ +constexpr auto min │ │ │ │ │ +Function object that returns the smaller of the given values. │ │ │ │ │ +Definition hybridutilities.hh:506 │ │ │ │ │ +Dune::Hybrid::ifElse │ │ │ │ │ +decltype(auto) ifElse(const Condition &condition, IfFunc &&ifFunc, ElseFunc │ │ │ │ │ +&&elseFunc) │ │ │ │ │ +A conditional expression. │ │ │ │ │ +Definition hybridutilities.hh:344 │ │ │ │ │ +Dune::Hybrid::integralRange │ │ │ │ │ +constexpr auto integralRange(const Begin &begin, const End &end) │ │ │ │ │ +Create an integral range. │ │ │ │ │ +Definition hybridutilities.hh:172 │ │ │ │ │ +Dune::Hybrid::elementAt │ │ │ │ │ +constexpr decltype(auto) elementAt(Container &&c, Index &&i) │ │ │ │ │ +Get element at given position from container. │ │ │ │ │ +Definition hybridutilities.hh:126 │ │ │ │ │ +Dune::Hybrid::accumulate │ │ │ │ │ +constexpr T accumulate(Range &&range, T value, F &&f) │ │ │ │ │ +Accumulate values. │ │ │ │ │ +Definition hybridutilities.hh:279 │ │ │ │ │ +Dune::integerSequenceEntry │ │ │ │ │ +constexpr auto integerSequenceEntry(std::integer_sequence< T, t... >, std:: │ │ │ │ │ +integral_constant< std::size_t, index > i) │ │ │ │ │ +Get entry of std::integer_sequence. │ │ │ │ │ +Definition typetraits.hh:492 │ │ │ │ │ +Dune │ │ │ │ │ +Dune namespace. │ │ │ │ │ +Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::Hybrid::hybridFunctor │ │ │ │ │ +constexpr HybridFunctor< Functor > hybridFunctor(const Functor &) │ │ │ │ │ +Returns an HybridFunctor adaptor. │ │ │ │ │ +Definition hybridutilities.hh:459 │ │ │ │ │ +Dune::Max │ │ │ │ │ +Definition binaryfunctions.hh:34 │ │ │ │ │ +Dune::Hybrid::HybridFunctor │ │ │ │ │ +Adapter of a hybrid functor that maintains results hybrid. │ │ │ │ │ +Definition hybridutilities.hh:418 │ │ │ │ │ +Dune::IntegralRange │ │ │ │ │ +dynamic integer range for use in range-based for loops │ │ │ │ │ +Definition rangeutilities.hh:177 │ │ │ │ │ +Dune::StaticIntegralRange │ │ │ │ │ +static integer range for use in range-based for loops │ │ │ │ │ +Definition rangeutilities.hh:230 │ │ │ │ │ +Dune::IsIntegralConstant │ │ │ │ │ +Check if T is an std::integral_constant │ │ │ │ │ +Definition typetraits.hh:384 │ │ │ │ │ +Dune::PriorityTag │ │ │ │ │ +Helper class for tagging priorities. │ │ │ │ │ +Definition typeutilities.hh:73 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00077.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpicommunication.hh File Reference │ │ │ │ +dune-common: scalarmatrixview.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,114 +65,46 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ -Namespaces | │ │ │ │ -Macros | │ │ │ │ -Functions
│ │ │ │ -
mpicommunication.hh File Reference
│ │ │ │ +Namespaces
│ │ │ │ +
scalarmatrixview.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Implements an utility class that provides MPI's collective communication methods. │ │ │ │ +

Implements a scalar matrix view wrapper around an existing scalar. │ │ │ │ More...

│ │ │ │ -
#include <algorithm>
│ │ │ │ -#include <functional>
│ │ │ │ -#include <memory>
│ │ │ │ -#include <mpi.h>
│ │ │ │ -#include <dune/common/binaryfunctions.hh>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/parallel/communication.hh>
│ │ │ │ -#include <dune/common/parallel/mpitraits.hh>
│ │ │ │ -#include <dune/common/parallel/mpifuture.hh>
│ │ │ │ -#include <dune/common/parallel/mpidata.hh>
│ │ │ │ +
#include <cstddef>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <ostream>
│ │ │ │ +#include <dune/common/boundschecking.hh>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │ +#include <dune/common/matvectraits.hh>
│ │ │ │ +#include <dune/common/densematrix.hh>
│ │ │ │ +#include <dune/common/fmatrix.hh>
│ │ │ │ +#include <dune/common/scalarvectorview.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

class  Dune::Generic_MPI_Op< Type, BinaryFunction, Enable >
 
class  Dune::Communication< MPI_Comm >
 Specialization of Communication for MPI. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Macros

#define ComposeMPIOp(func, op)
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │

│ │ │ │ -Functions

 Dune::ComposeMPIOp (std::plus, MPI_SUM)
 
 Dune::ComposeMPIOp (std::multiplies, MPI_PROD)
 
 Dune::ComposeMPIOp (Min, MPI_MIN)
 
 Dune::ComposeMPIOp (Max, MPI_MAX)
 
│ │ │ │

Detailed Description

│ │ │ │ -

Implements an utility class that provides MPI's collective communication methods.

│ │ │ │ -

Macro Definition Documentation

│ │ │ │ - │ │ │ │ -

◆ ComposeMPIOp

│ │ │ │ - │ │ │ │ -
│ │ │ │ -
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
#define ComposeMPIOp( func,
 op 
)
│ │ │ │ -
│ │ │ │ -Value:
template<class T, class S> \
│ │ │ │ -
class Generic_MPI_Op<T, func<S>, std::enable_if_t<MPITraits<S>::is_intrinsic> >{ \
│ │ │ │ -
public: \
│ │ │ │ -
static MPI_Op get(){ \
│ │ │ │ -
return op; \
│ │ │ │ -
} \
│ │ │ │ -
private: \
│ │ │ │ -
Generic_MPI_Op () {} \
│ │ │ │ -
Generic_MPI_Op (const Generic_MPI_Op & ) {} \
│ │ │ │ -
}
│ │ │ │ -
STL namespace.
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
│ │ │ │ +

Implements a scalar matrix view wrapper around an existing scalar.

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,69 +1,28 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces | Macros | Functions │ │ │ │ │ -mpicommunication.hh File Reference │ │ │ │ │ -Common » Parallel_Communication │ │ │ │ │ -Implements an utility class that provides MPI's collective communication │ │ │ │ │ -methods. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Namespaces │ │ │ │ │ +scalarmatrixview.hh File Reference │ │ │ │ │ +Common » Dense_Matrix_and_Vector_Template_Library │ │ │ │ │ +Implements a scalar matrix view wrapper around an existing scalar. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ -Classes │ │ │ │ │ -class   Dune::Generic_MPI_Op<_Type,_BinaryFunction,_Enable_> │ │ │ │ │ -  │ │ │ │ │ -class   Dune::Communication<_MPI_Comm_> │ │ │ │ │ -  Specialization of Communication for MPI. More... │ │ │ │ │ -  │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Macros │ │ │ │ │ -#define  ComposeMPIOp(func, op) │ │ │ │ │ -  │ │ │ │ │ -Functions │ │ │ │ │ -  Dune::ComposeMPIOp (std::plus, MPI_SUM) │ │ │ │ │ -  │ │ │ │ │ -  Dune::ComposeMPIOp (std::multiplies, MPI_PROD) │ │ │ │ │ -  │ │ │ │ │ -  Dune::ComposeMPIOp (Min, MPI_MIN) │ │ │ │ │ -  │ │ │ │ │ -  Dune::ComposeMPIOp (Max, MPI_MAX) │ │ │ │ │ -  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Implements an utility class that provides MPI's collective communication │ │ │ │ │ -methods. │ │ │ │ │ -***** Macro Definition Documentation ***** │ │ │ │ │ -***** ◆ ComposeMPIOp ***** │ │ │ │ │ -#define ComposeMPIOp (   func, │ │ │ │ │ -   op  │ │ │ │ │ - ) │ │ │ │ │ -Value: │ │ │ │ │ -template \ │ │ │ │ │ -class Generic_MPI_Op, std::enable_if_t::is_intrinsic> > │ │ │ │ │ -{ \ │ │ │ │ │ -public: \ │ │ │ │ │ -static MPI_Op get(){ \ │ │ │ │ │ -return op; \ │ │ │ │ │ -} \ │ │ │ │ │ -private: \ │ │ │ │ │ -Generic_MPI_Op () {} \ │ │ │ │ │ -Generic_MPI_Op (const Generic_MPI_Op & ) {} \ │ │ │ │ │ -} │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ +Implements a scalar matrix view wrapper around an existing scalar. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00077_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpicommunication.hh Source File │ │ │ │ +dune-common: scalarmatrixview.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,588 +70,202 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
mpicommunication.hh
│ │ │ │ +
scalarmatrixview.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PARALLEL_MPICOMMUNICATION_HH
│ │ │ │ -
6#define DUNE_COMMON_PARALLEL_MPICOMMUNICATION_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_SCALARMATRIXVIEW_HH
│ │ │ │ +
6#define DUNE_COMMON_SCALARMATRIXVIEW_HH
│ │ │ │
7
│ │ │ │ -
16#if HAVE_MPI
│ │ │ │ -
17
│ │ │ │ -
18#include <algorithm>
│ │ │ │ -
19#include <functional>
│ │ │ │ -
20#include <memory>
│ │ │ │ +
8#include <cstddef>
│ │ │ │ +
9#include <type_traits>
│ │ │ │ +
10#include <ostream>
│ │ │ │ +
11
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
18
│ │ │ │ +
19
│ │ │ │ +
20namespace Dune {
│ │ │ │
21
│ │ │ │ -
22#include <mpi.h>
│ │ │ │ +
22namespace Impl {
│ │ │ │
23
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
30
│ │ │ │ -
31namespace Dune
│ │ │ │ -
32{
│ │ │ │ -
33
│ │ │ │ -
34 //=======================================================
│ │ │ │ -
35 // use singleton pattern and template specialization to
│ │ │ │ -
36 // generate MPI operations
│ │ │ │ -
37 //=======================================================
│ │ │ │ -
38
│ │ │ │ -
39 template<typename Type, typename BinaryFunction, typename Enable=void>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
41 {
│ │ │ │ -
42
│ │ │ │ -
43 public:
│ │ │ │ -
│ │ │ │ -
44 static MPI_Op get ()
│ │ │ │ -
45 {
│ │ │ │ -
46 if (!op)
│ │ │ │ -
47 {
│ │ │ │ -
48 op = std::make_unique<MPI_Op>();
│ │ │ │ -
49 // The following line leaks an MPI operation object, because the corresponding
│ │ │ │ -
50 //`MPI_Op_free` is never called. It is never called because there is no easy
│ │ │ │ -
51 // way to call it at the right moment: right before the call to MPI_Finalize.
│ │ │ │ -
52 // See https://gitlab.dune-project.org/core/dune-istl/issues/80
│ │ │ │ -
53 MPI_Op_create((void (*)(void*, void*, int*, MPI_Datatype*))&operation,true,op.get());
│ │ │ │ -
54 }
│ │ │ │ -
55 return *op;
│ │ │ │ -
56 }
│ │ │ │ -
│ │ │ │ -
57 private:
│ │ │ │ -
58 static void operation (Type *in, Type *inout, int *len, MPI_Datatype*)
│ │ │ │ -
59 {
│ │ │ │ -
60 BinaryFunction func;
│ │ │ │ -
61
│ │ │ │ -
62 for (int i=0; i< *len; ++i, ++in, ++inout) {
│ │ │ │ -
63 Type temp;
│ │ │ │ -
64 temp = func(*in, *inout);
│ │ │ │ -
65 *inout = temp;
│ │ │ │ -
66 }
│ │ │ │ -
67 }
│ │ │ │ -
68 Generic_MPI_Op () {}
│ │ │ │ -
69 Generic_MPI_Op (const Generic_MPI_Op& ) {}
│ │ │ │ -
70 static std::unique_ptr<MPI_Op> op;
│ │ │ │ -
71 };
│ │ │ │ -
│ │ │ │ -
72
│ │ │ │ -
73
│ │ │ │ -
74 template<typename Type, typename BinaryFunction, typename Enable>
│ │ │ │ -
75 std::unique_ptr<MPI_Op> Generic_MPI_Op<Type,BinaryFunction, Enable>::op;
│ │ │ │ -
76
│ │ │ │ -
│ │ │ │ -
77#define ComposeMPIOp(func,op) \
│ │ │ │ -
78 template<class T, class S> \
│ │ │ │ -
79 class Generic_MPI_Op<T, func<S>, std::enable_if_t<MPITraits<S>::is_intrinsic> >{ \
│ │ │ │ -
80 public: \
│ │ │ │ -
81 static MPI_Op get(){ \
│ │ │ │ -
82 return op; \
│ │ │ │ -
83 } \
│ │ │ │ -
84 private: \
│ │ │ │ -
85 Generic_MPI_Op () {} \
│ │ │ │ -
86 Generic_MPI_Op (const Generic_MPI_Op & ) {} \
│ │ │ │ -
87 }
│ │ │ │ -
│ │ │ │ -
88
│ │ │ │ -
89
│ │ │ │ -
90 ComposeMPIOp(std::plus, MPI_SUM);
│ │ │ │ -
91 ComposeMPIOp(std::multiplies, MPI_PROD);
│ │ │ │ -
92 ComposeMPIOp(Min, MPI_MIN);
│ │ │ │ -
93 ComposeMPIOp(Max, MPI_MAX);
│ │ │ │ -
94
│ │ │ │ -
95#undef ComposeMPIOp
│ │ │ │ -
96
│ │ │ │ -
97
│ │ │ │ -
98 //=======================================================
│ │ │ │ -
99 // use singleton pattern and template specialization to
│ │ │ │ -
100 // generate MPI operations
│ │ │ │ -
101 //=======================================================
│ │ │ │ -
102
│ │ │ │ -
106 template<>
│ │ │ │ -
│ │ │ │ -
107 class Communication<MPI_Comm>
│ │ │ │ -
108 {
│ │ │ │ -
109 public:
│ │ │ │ -
│ │ │ │ -
111 Communication (const MPI_Comm& c = MPI_COMM_WORLD)
│ │ │ │ -
112 : communicator(c)
│ │ │ │ -
113 {
│ │ │ │ -
114 if(communicator!=MPI_COMM_NULL) {
│ │ │ │ -
115 int initialized = 0;
│ │ │ │ -
116 MPI_Initialized(&initialized);
│ │ │ │ -
117 if (!initialized)
│ │ │ │ -
118 DUNE_THROW(ParallelError,"You must call MPIHelper::instance(argc,argv) in your main() function before using the MPI Communication!");
│ │ │ │ -
119 MPI_Comm_rank(communicator,&me);
│ │ │ │ -
120 MPI_Comm_size(communicator,&procs);
│ │ │ │ -
121 }else{
│ │ │ │ -
122 procs=0;
│ │ │ │ -
123 me=-1;
│ │ │ │ -
124 }
│ │ │ │ -
125 }
│ │ │ │ -
│ │ │ │ -
126
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
129 : Communication(MPI_COMM_SELF)
│ │ │ │ -
130 {}
│ │ │ │ -
│ │ │ │ +
39 template<class K>
│ │ │ │ +
40 class ScalarMatrixView :
│ │ │ │ +
41 public DenseMatrix<ScalarMatrixView<K>>
│ │ │ │ +
42 {
│ │ │ │ +
43 ScalarVectorView<K> data_;
│ │ │ │ +
44 using Base = DenseMatrix<ScalarMatrixView<K>>;
│ │ │ │ +
45
│ │ │ │ +
46 template <class>
│ │ │ │ +
47 friend class ScalarMatrixView;
│ │ │ │ +
48 public:
│ │ │ │ +
49
│ │ │ │ +
50 //===== type definitions and constants
│ │ │ │ +
51
│ │ │ │ +
54 constexpr static int blocklevel = 1;
│ │ │ │ +
55
│ │ │ │ +
56 using size_type = typename Base::size_type;
│ │ │ │ +
57 using row_type = typename Base::row_type;
│ │ │ │ +
58 using row_reference = typename Base::row_reference;
│ │ │ │ + │ │ │ │ +
60
│ │ │ │ +
63 constexpr static int rows = 1;
│ │ │ │ +
66 constexpr static int cols = 1;
│ │ │ │ +
67
│ │ │ │ +
68 //===== constructors
│ │ │ │ +
71 constexpr ScalarMatrixView ()
│ │ │ │ +
72 : data_()
│ │ │ │ +
73 {}
│ │ │ │ +
74
│ │ │ │ +
76 ScalarMatrixView (K* p) :
│ │ │ │ +
77 data_(p)
│ │ │ │ +
78 {}
│ │ │ │ +
79
│ │ │ │ +
81 ScalarMatrixView (const ScalarMatrixView &other) :
│ │ │ │ +
82 Base(),
│ │ │ │ +
83 data_(other.data_)
│ │ │ │ +
84 {}
│ │ │ │ +
85
│ │ │ │ +
87 ScalarMatrixView (ScalarMatrixView &&other) :
│ │ │ │ +
88 Base(),
│ │ │ │ +
89 data_( other.data_ )
│ │ │ │ +
90 {}
│ │ │ │ +
91
│ │ │ │ +
93 ScalarMatrixView& operator= (const ScalarMatrixView& other)
│ │ │ │ +
94 {
│ │ │ │ +
95 data_ = other.data_;
│ │ │ │ +
96 return *this;
│ │ │ │ +
97 }
│ │ │ │ +
98
│ │ │ │ +
99 template<class KK>
│ │ │ │ +
100 ScalarMatrixView& operator= (const ScalarMatrixView<KK>& other)
│ │ │ │ +
101 {
│ │ │ │ +
102 data_ = other.data_;
│ │ │ │ +
103 return *this;
│ │ │ │ +
104 }
│ │ │ │ +
105
│ │ │ │ +
107 template<typename T,
│ │ │ │ +
108 std::enable_if_t<std::is_convertible<T, K>::value, int> = 0>
│ │ │ │ +
109 inline ScalarMatrixView& operator= (const T& k)
│ │ │ │ +
110 {
│ │ │ │ +
111 data_ = k;
│ │ │ │ +
112 return *this;
│ │ │ │ +
113 }
│ │ │ │ +
114
│ │ │ │ +
115 // make this thing a matrix
│ │ │ │ +
116 static constexpr size_type mat_rows() { return 1; }
│ │ │ │ +
117 static constexpr size_type mat_cols() { return 1; }
│ │ │ │ +
118
│ │ │ │ +
119 row_reference mat_access ([[maybe_unused]] size_type i)
│ │ │ │ +
120 {
│ │ │ │ +
121 DUNE_ASSERT_BOUNDS(i == 0);
│ │ │ │ +
122 return data_;
│ │ │ │ +
123 }
│ │ │ │ +
124
│ │ │ │ +
125 const_row_reference mat_access ([[maybe_unused]] size_type i) const
│ │ │ │ +
126 {
│ │ │ │ +
127 DUNE_ASSERT_BOUNDS(i == 0);
│ │ │ │ +
128 return data_;
│ │ │ │ +
129 }
│ │ │ │ +
130 }; // class ScalarMatrixView
│ │ │ │
131
│ │ │ │ -
│ │ │ │ -
133 int rank () const
│ │ │ │ -
134 {
│ │ │ │ -
135 return me;
│ │ │ │ -
136 }
│ │ │ │ -
│ │ │ │ -
137
│ │ │ │ -
│ │ │ │ -
139 int size () const
│ │ │ │ -
140 {
│ │ │ │ -
141 return procs;
│ │ │ │ -
142 }
│ │ │ │ -
│ │ │ │ -
143
│ │ │ │ -
145 template<class T>
│ │ │ │ -
│ │ │ │ -
146 int send(const T& data, int dest_rank, int tag) const
│ │ │ │ -
147 {
│ │ │ │ -
148 auto mpi_data = getMPIData(data);
│ │ │ │ -
149 return MPI_Send(mpi_data.ptr(), mpi_data.size(), mpi_data.type(),
│ │ │ │ -
150 dest_rank, tag, communicator);
│ │ │ │ -
151 }
│ │ │ │ -
│ │ │ │ -
152
│ │ │ │ -
154 template<class T>
│ │ │ │ -
│ │ │ │ -
155 MPIFuture<T> isend(T&& data, int dest_rank, int tag) const
│ │ │ │ -
156 {
│ │ │ │ -
157 MPIFuture<T> future(std::forward<T>(data));
│ │ │ │ -
158 auto mpidata = future.get_mpidata();
│ │ │ │ -
159 MPI_Isend(mpidata.ptr(), mpidata.size(), mpidata.type(),
│ │ │ │ -
160 dest_rank, tag, communicator, &future.req_);
│ │ │ │ -
161 return future;
│ │ │ │ -
162 }
│ │ │ │ -
│ │ │ │ +
133 template<typename K>
│ │ │ │ +
134 std::ostream& operator<< (std::ostream& s, const ScalarMatrixView<K>& a)
│ │ │ │ +
135 {
│ │ │ │ +
136 s << a[0][0];
│ │ │ │ +
137 return s;
│ │ │ │ +
138 }
│ │ │ │ +
139
│ │ │ │ +
141 template<class T,
│ │ │ │ +
142 std::enable_if_t<IsNumber<T>::value, int> = 0>
│ │ │ │ +
143 auto asMatrix(T& t)
│ │ │ │ +
144 {
│ │ │ │ +
145 return ScalarMatrixView<T>{&t};
│ │ │ │ +
146 }
│ │ │ │ +
147
│ │ │ │ +
149 template<class T,
│ │ │ │ +
150 std::enable_if_t<IsNumber<T>::value, int> = 0>
│ │ │ │ +
151 auto asMatrix(const T& t)
│ │ │ │ +
152 {
│ │ │ │ +
153 return ScalarMatrixView<const T>{&t};
│ │ │ │ +
154 }
│ │ │ │ +
155
│ │ │ │ +
157 template<class T,
│ │ │ │ +
158 std::enable_if_t<not IsNumber<T>::value, int> = 0>
│ │ │ │ +
159 T& asMatrix(T& t)
│ │ │ │ +
160 {
│ │ │ │ +
161 return t;
│ │ │ │ +
162 }
│ │ │ │
163
│ │ │ │ -
165 template<class T>
│ │ │ │ -
│ │ │ │ -
166 T recv(T&& data, int source_rank, int tag, MPI_Status* status = MPI_STATUS_IGNORE) const
│ │ │ │ -
167 {
│ │ │ │ -
168 T lvalue_data(std::forward<T>(data));
│ │ │ │ -
169 auto mpi_data = getMPIData(lvalue_data);
│ │ │ │ -
170 MPI_Recv(mpi_data.ptr(), mpi_data.size(), mpi_data.type(),
│ │ │ │ -
171 source_rank, tag, communicator, status);
│ │ │ │ -
172 return lvalue_data;
│ │ │ │ -
173 }
│ │ │ │ -
│ │ │ │ -
174
│ │ │ │ -
176 template<class T>
│ │ │ │ -
│ │ │ │ -
177 MPIFuture<T> irecv(T&& data, int source_rank, int tag) const
│ │ │ │ -
178 {
│ │ │ │ -
179 MPIFuture<T> future(std::forward<T>(data));
│ │ │ │ -
180 auto mpidata = future.get_mpidata();
│ │ │ │ -
181 if (mpidata.size() == 0)
│ │ │ │ -
182 DUNE_THROW(ParallelError, "Size if irecv data object is zero. Reserve sufficient size for the whole message");
│ │ │ │ -
183 MPI_Irecv(mpidata.ptr(), mpidata.size(), mpidata.type(),
│ │ │ │ -
184 source_rank, tag, communicator, &future.req_);
│ │ │ │ -
185 return future;
│ │ │ │ -
186 }
│ │ │ │ -
│ │ │ │ -
187
│ │ │ │ -
188 template<class T>
│ │ │ │ -
│ │ │ │ -
189 T rrecv(T&& data, int source_rank, int tag, MPI_Status* status = MPI_STATUS_IGNORE) const
│ │ │ │ -
190 {
│ │ │ │ -
191 MPI_Status _status;
│ │ │ │ -
192 MPI_Message _message;
│ │ │ │ -
193 T lvalue_data(std::forward<T>(data));
│ │ │ │ -
194 auto mpi_data = getMPIData(lvalue_data);
│ │ │ │ -
195 static_assert(!mpi_data.static_size, "rrecv work only for non-static-sized types.");
│ │ │ │ -
196 if(status == MPI_STATUS_IGNORE)
│ │ │ │ -
197 status = &_status;
│ │ │ │ -
198 MPI_Mprobe(source_rank, tag, communicator, &_message, status);
│ │ │ │ -
199 int size;
│ │ │ │ -
200 MPI_Get_count(status, mpi_data.type(), &size);
│ │ │ │ -
201 mpi_data.resize(size);
│ │ │ │ -
202 MPI_Mrecv(mpi_data.ptr(), mpi_data.size(), mpi_data.type(), &_message, status);
│ │ │ │ -
203 return lvalue_data;
│ │ │ │ -
204 }
│ │ │ │ -
│ │ │ │ -
205
│ │ │ │ -
207 template<typename T>
│ │ │ │ -
│ │ │ │ -
208 T sum (const T& in) const
│ │ │ │ -
209 {
│ │ │ │ -
210 T out;
│ │ │ │ -
211 allreduce<std::plus<T> >(&in,&out,1);
│ │ │ │ -
212 return out;
│ │ │ │ -
213 }
│ │ │ │ -
│ │ │ │ -
214
│ │ │ │ -
216 template<typename T>
│ │ │ │ -
│ │ │ │ -
217 int sum (T* inout, int len) const
│ │ │ │ -
218 {
│ │ │ │ -
219 return allreduce<std::plus<T> >(inout,len);
│ │ │ │ -
220 }
│ │ │ │ -
│ │ │ │ -
221
│ │ │ │ -
223 template<typename T>
│ │ │ │ -
│ │ │ │ -
224 T prod (const T& in) const
│ │ │ │ -
225 {
│ │ │ │ -
226 T out;
│ │ │ │ -
227 allreduce<std::multiplies<T> >(&in,&out,1);
│ │ │ │ -
228 return out;
│ │ │ │ -
229 }
│ │ │ │ -
│ │ │ │ -
230
│ │ │ │ -
232 template<typename T>
│ │ │ │ -
│ │ │ │ -
233 int prod (T* inout, int len) const
│ │ │ │ -
234 {
│ │ │ │ -
235 return allreduce<std::multiplies<T> >(inout,len);
│ │ │ │ -
236 }
│ │ │ │ -
│ │ │ │ -
237
│ │ │ │ -
239 template<typename T>
│ │ │ │ -
│ │ │ │ -
240 T min (const T& in) const
│ │ │ │ -
241 {
│ │ │ │ -
242 T out;
│ │ │ │ -
243 allreduce<Min<T> >(&in,&out,1);
│ │ │ │ -
244 return out;
│ │ │ │ -
245 }
│ │ │ │ -
│ │ │ │ -
246
│ │ │ │ -
248 template<typename T>
│ │ │ │ -
│ │ │ │ -
249 int min (T* inout, int len) const
│ │ │ │ -
250 {
│ │ │ │ -
251 return allreduce<Min<T> >(inout,len);
│ │ │ │ -
252 }
│ │ │ │ -
│ │ │ │ -
253
│ │ │ │ -
254
│ │ │ │ -
256 template<typename T>
│ │ │ │ -
│ │ │ │ -
257 T max (const T& in) const
│ │ │ │ -
258 {
│ │ │ │ -
259 T out;
│ │ │ │ -
260 allreduce<Max<T> >(&in,&out,1);
│ │ │ │ -
261 return out;
│ │ │ │ -
262 }
│ │ │ │ -
│ │ │ │ -
263
│ │ │ │ -
265 template<typename T>
│ │ │ │ -
│ │ │ │ -
266 int max (T* inout, int len) const
│ │ │ │ -
267 {
│ │ │ │ -
268 return allreduce<Max<T> >(inout,len);
│ │ │ │ -
269 }
│ │ │ │ -
│ │ │ │ -
270
│ │ │ │ -
│ │ │ │ -
272 int barrier () const
│ │ │ │ -
273 {
│ │ │ │ -
274 return MPI_Barrier(communicator);
│ │ │ │ -
275 }
│ │ │ │ -
│ │ │ │ -
276
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
279 {
│ │ │ │ -
280 MPIFuture<void> future(true); // make a valid MPIFuture<void>
│ │ │ │ -
281 MPI_Ibarrier(communicator, &future.req_);
│ │ │ │ -
282 return future;
│ │ │ │ -
283 }
│ │ │ │ -
│ │ │ │ -
284
│ │ │ │ -
285
│ │ │ │ -
287 template<typename T>
│ │ │ │ -
│ │ │ │ -
288 int broadcast (T* inout, int len, int root) const
│ │ │ │ -
289 {
│ │ │ │ -
290 return MPI_Bcast(inout,len,MPITraits<T>::getType(),root,communicator);
│ │ │ │ -
291 }
│ │ │ │ -
│ │ │ │ -
292
│ │ │ │ -
294 template<class T>
│ │ │ │ -
│ │ │ │ -
295 MPIFuture<T> ibroadcast(T&& data, int root) const{
│ │ │ │ -
296 MPIFuture<T> future(std::forward<T>(data));
│ │ │ │ -
297 auto mpidata = future.get_mpidata();
│ │ │ │ -
298 MPI_Ibcast(mpidata.ptr(),
│ │ │ │ -
299 mpidata.size(),
│ │ │ │ -
300 mpidata.type(),
│ │ │ │ -
301 root,
│ │ │ │ -
302 communicator,
│ │ │ │ -
303 &future.req_);
│ │ │ │ -
304 return future;
│ │ │ │ -
305 }
│ │ │ │ -
│ │ │ │ -
306
│ │ │ │ -
309 template<typename T>
│ │ │ │ -
│ │ │ │ -
310 int gather (const T* in, T* out, int len, int root) const
│ │ │ │ -
311 {
│ │ │ │ -
312 return MPI_Gather(const_cast<T*>(in),len,MPITraits<T>::getType(),
│ │ │ │ -
313 out,len,MPITraits<T>::getType(),
│ │ │ │ -
314 root,communicator);
│ │ │ │ -
315 }
│ │ │ │ -
│ │ │ │ -
316
│ │ │ │ -
318 template<class TIN, class TOUT = std::vector<TIN>>
│ │ │ │ -
│ │ │ │ -
319 MPIFuture<TOUT, TIN> igather(TIN&& data_in, TOUT&& data_out, int root) const{
│ │ │ │ -
320 MPIFuture<TOUT, TIN> future(std::forward<TOUT>(data_out), std::forward<TIN>(data_in));
│ │ │ │ -
321 auto mpidata_in = future.get_send_mpidata();
│ │ │ │ -
322 auto mpidata_out = future.get_mpidata();
│ │ │ │ -
323 assert(root != me || mpidata_in.size()*procs <= mpidata_out.size());
│ │ │ │ -
324 int outlen = (me==root) * mpidata_in.size();
│ │ │ │ -
325 MPI_Igather(mpidata_in.ptr(), mpidata_in.size(), mpidata_in.type(),
│ │ │ │ -
326 mpidata_out.ptr(), outlen, mpidata_out.type(),
│ │ │ │ -
327 root, communicator, &future.req_);
│ │ │ │ -
328 return future;
│ │ │ │ -
329 }
│ │ │ │ -
│ │ │ │ -
330
│ │ │ │ -
332 template<typename T>
│ │ │ │ -
│ │ │ │ -
333 int gatherv (const T* in, int sendDataLen, T* out, int* recvDataLen, int* displ, int root) const
│ │ │ │ -
334 {
│ │ │ │ -
335 return MPI_Gatherv(const_cast<T*>(in),sendDataLen,MPITraits<T>::getType(),
│ │ │ │ -
336 out,recvDataLen,displ,MPITraits<T>::getType(),
│ │ │ │ -
337 root,communicator);
│ │ │ │ -
338 }
│ │ │ │ -
│ │ │ │ -
339
│ │ │ │ -
342 template<typename T>
│ │ │ │ -
│ │ │ │ -
343 int scatter (const T* sendData, T* recvData, int len, int root) const
│ │ │ │ -
344 {
│ │ │ │ -
345 return MPI_Scatter(const_cast<T*>(sendData),len,MPITraits<T>::getType(),
│ │ │ │ -
346 recvData,len,MPITraits<T>::getType(),
│ │ │ │ -
347 root,communicator);
│ │ │ │ -
348 }
│ │ │ │ -
│ │ │ │ -
349
│ │ │ │ -
351 template<class TIN, class TOUT = TIN>
│ │ │ │ -
│ │ │ │ -
352 MPIFuture<TOUT, TIN> iscatter(TIN&& data_in, TOUT&& data_out, int root) const
│ │ │ │ -
353 {
│ │ │ │ -
354 MPIFuture<TOUT, TIN> future(std::forward<TOUT>(data_out), std::forward<TIN>(data_in));
│ │ │ │ -
355 auto mpidata_in = future.get_send_mpidata();
│ │ │ │ -
356 auto mpidata_out = future.get_mpidata();
│ │ │ │ -
357 int inlen = (me==root) * mpidata_in.size()/procs;
│ │ │ │ -
358 MPI_Iscatter(mpidata_in.ptr(), inlen, mpidata_in.type(),
│ │ │ │ -
359 mpidata_out.ptr(), mpidata_out.size(), mpidata_out.type(),
│ │ │ │ -
360 root, communicator, &future.req_);
│ │ │ │ -
361 return future;
│ │ │ │ -
362 }
│ │ │ │ -
│ │ │ │ -
363
│ │ │ │ -
365 template<typename T>
│ │ │ │ -
│ │ │ │ -
366 int scatterv (const T* sendData, int* sendDataLen, int* displ, T* recvData, int recvDataLen, int root) const
│ │ │ │ -
367 {
│ │ │ │ -
368 return MPI_Scatterv(const_cast<T*>(sendData),sendDataLen,displ,MPITraits<T>::getType(),
│ │ │ │ -
369 recvData,recvDataLen,MPITraits<T>::getType(),
│ │ │ │ -
370 root,communicator);
│ │ │ │ -
371 }
│ │ │ │ -
│ │ │ │ -
372
│ │ │ │ -
373
│ │ │ │ -
│ │ │ │ -
374 operator MPI_Comm () const
│ │ │ │ -
375 {
│ │ │ │ -
376 return communicator;
│ │ │ │ -
377 }
│ │ │ │ -
│ │ │ │ -
378
│ │ │ │ -
380 template<typename T, typename T1>
│ │ │ │ -
│ │ │ │ -
381 int allgather(const T* sbuf, int count, T1* rbuf) const
│ │ │ │ -
382 {
│ │ │ │ -
383 return MPI_Allgather(const_cast<T*>(sbuf), count, MPITraits<T>::getType(),
│ │ │ │ -
384 rbuf, count, MPITraits<T1>::getType(),
│ │ │ │ -
385 communicator);
│ │ │ │ -
386 }
│ │ │ │ -
│ │ │ │ -
387
│ │ │ │ -
389 template<class TIN, class TOUT = TIN>
│ │ │ │ -
│ │ │ │ -
390 MPIFuture<TOUT, TIN> iallgather(TIN&& data_in, TOUT&& data_out) const
│ │ │ │ -
391 {
│ │ │ │ -
392 MPIFuture<TOUT, TIN> future(std::forward<TOUT>(data_out), std::forward<TIN>(data_in));
│ │ │ │ -
393 auto mpidata_in = future.get_send_mpidata();
│ │ │ │ -
394 auto mpidata_out = future.get_mpidata();
│ │ │ │ -
395 assert(mpidata_in.size()*procs <= mpidata_out.size());
│ │ │ │ -
396 int outlen = mpidata_in.size();
│ │ │ │ -
397 MPI_Iallgather(mpidata_in.ptr(), mpidata_in.size(), mpidata_in.type(),
│ │ │ │ -
398 mpidata_out.ptr(), outlen, mpidata_out.type(),
│ │ │ │ -
399 communicator, &future.req_);
│ │ │ │ -
400 return future;
│ │ │ │ -
401 }
│ │ │ │ -
│ │ │ │ -
402
│ │ │ │ -
404 template<typename T>
│ │ │ │ -
│ │ │ │ -
405 int allgatherv (const T* in, int sendDataLen, T* out, int* recvDataLen, int* displ) const
│ │ │ │ -
406 {
│ │ │ │ -
407 return MPI_Allgatherv(const_cast<T*>(in),sendDataLen,MPITraits<T>::getType(),
│ │ │ │ -
408 out,recvDataLen,displ,MPITraits<T>::getType(),
│ │ │ │ -
409 communicator);
│ │ │ │ -
410 }
│ │ │ │ -
│ │ │ │ -
411
│ │ │ │ -
413 template<typename BinaryFunction, typename Type>
│ │ │ │ -
│ │ │ │ -
414 int allreduce(Type* inout, int len) const
│ │ │ │ -
415 {
│ │ │ │ -
416 Type* out = new Type[len];
│ │ │ │ -
417 int ret = allreduce<BinaryFunction>(inout,out,len);
│ │ │ │ -
418 std::copy(out, out+len, inout);
│ │ │ │ -
419 delete[] out;
│ │ │ │ -
420 return ret;
│ │ │ │ -
421 }
│ │ │ │ -
│ │ │ │ -
422
│ │ │ │ -
423 template<typename BinaryFunction, typename Type>
│ │ │ │ -
│ │ │ │ -
424 Type allreduce(Type&& in) const{
│ │ │ │ -
425 Type lvalue_data = std::forward<Type>(in);
│ │ │ │ -
426 auto data = getMPIData(lvalue_data);
│ │ │ │ -
427 MPI_Allreduce(MPI_IN_PLACE, data.ptr(), data.size(), data.type(),
│ │ │ │ - │ │ │ │ -
429 communicator);
│ │ │ │ -
430 return lvalue_data;
│ │ │ │ -
431 }
│ │ │ │ -
│ │ │ │ -
432
│ │ │ │ -
434 template<class BinaryFunction, class TIN, class TOUT = TIN>
│ │ │ │ -
│ │ │ │ -
435 MPIFuture<TOUT, TIN> iallreduce(TIN&& data_in, TOUT&& data_out) const {
│ │ │ │ -
436 MPIFuture<TOUT, TIN> future(std::forward<TOUT>(data_out), std::forward<TIN>(data_in));
│ │ │ │ -
437 auto mpidata_in = future.get_send_mpidata();
│ │ │ │ -
438 auto mpidata_out = future.get_mpidata();
│ │ │ │ -
439 assert(mpidata_out.size() == mpidata_in.size());
│ │ │ │ -
440 assert(mpidata_out.type() == mpidata_in.type());
│ │ │ │ -
441 MPI_Iallreduce(mpidata_in.ptr(), mpidata_out.ptr(),
│ │ │ │ -
442 mpidata_out.size(), mpidata_out.type(),
│ │ │ │ - │ │ │ │ -
444 communicator, &future.req_);
│ │ │ │ -
445 return future;
│ │ │ │ -
446 }
│ │ │ │ -
│ │ │ │ -
447
│ │ │ │ -
449 template<class BinaryFunction, class T>
│ │ │ │ -
│ │ │ │ -
450 MPIFuture<T> iallreduce(T&& data) const{
│ │ │ │ -
451 MPIFuture<T> future(std::forward<T>(data));
│ │ │ │ -
452 auto mpidata = future.get_mpidata();
│ │ │ │ -
453 MPI_Iallreduce(MPI_IN_PLACE, mpidata.ptr(),
│ │ │ │ -
454 mpidata.size(), mpidata.type(),
│ │ │ │ - │ │ │ │ -
456 communicator, &future.req_);
│ │ │ │ -
457 return future;
│ │ │ │ -
458 }
│ │ │ │ -
│ │ │ │ -
459
│ │ │ │ -
461 template<typename BinaryFunction, typename Type>
│ │ │ │ -
│ │ │ │ -
462 int allreduce(const Type* in, Type* out, int len) const
│ │ │ │ -
463 {
│ │ │ │ -
464 return MPI_Allreduce(const_cast<Type*>(in), out, len, MPITraits<Type>::getType(),
│ │ │ │ - │ │ │ │ -
466 }
│ │ │ │ -
│ │ │ │ -
467
│ │ │ │ -
468 private:
│ │ │ │ -
469 MPI_Comm communicator;
│ │ │ │ -
470 int me;
│ │ │ │ -
471 int procs;
│ │ │ │ -
472 };
│ │ │ │ -
│ │ │ │ -
473} // namespace dune
│ │ │ │ -
474
│ │ │ │ -
475#endif // HAVE_MPI
│ │ │ │ -
476
│ │ │ │ -
477#endif
│ │ │ │ - │ │ │ │ -
Implements an utility class that provides collective communication methods for sequential programs.
│ │ │ │ -
Interface class to translate objects to a MPI_Datatype, void* and size used for MPI calls.
│ │ │ │ -
#define ComposeMPIOp(func, op)
Definition mpicommunication.hh:77
│ │ │ │ -
Traits classes for mapping types onto MPI_Datatype.
│ │ │ │ -
helper classes to provide unique types for standard functions
│ │ │ │ -
A few common exception classes.
│ │ │ │ -
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ +
165 template<class T,
│ │ │ │ +
166 std::enable_if_t<not IsNumber<T>::value, int> = 0>
│ │ │ │ +
167 const T& asMatrix(const T& t)
│ │ │ │ +
168 {
│ │ │ │ +
169 return t;
│ │ │ │ +
170 }
│ │ │ │ +
171
│ │ │ │ +
174} // end namespace Impl
│ │ │ │ +
175
│ │ │ │ +
176 template<class K>
│ │ │ │ +
177 struct FieldTraits<Impl::ScalarMatrixView<K>> : public FieldTraits<std::remove_const_t<K>> {};
│ │ │ │ +
178
│ │ │ │ +
179 template<class K>
│ │ │ │ +
180 struct DenseMatVecTraits<Impl::ScalarMatrixView<K>>
│ │ │ │ +
181 {
│ │ │ │ +
182 using derived_type = Impl::ScalarMatrixView<K>;
│ │ │ │ +
183 using row_type = Impl::ScalarVectorView<K>;
│ │ │ │ +
184 using row_reference = row_type&;
│ │ │ │ +
185 using const_row_reference = const row_type&;
│ │ │ │ +
186 using value_type = std::remove_const_t<K>;
│ │ │ │ +
187 using size_type = std::size_t;
│ │ │ │ +
188 };
│ │ │ │ +
189
│ │ │ │ +
190
│ │ │ │ +
191 template<class K>
│ │ │ │ +
192 struct AutonomousValueType<Impl::ScalarMatrixView<K>>
│ │ │ │ +
193 {
│ │ │ │ +
194 using type = FieldMatrix<std::remove_const_t<K>,1,1>;
│ │ │ │ +
195 };
│ │ │ │ +
196
│ │ │ │ +
197
│ │ │ │ +
198} // end namespace Dune
│ │ │ │ +
199
│ │ │ │ +
200#endif // DUNE_COMMON_SCALARMATRIXVIEW_HH
│ │ │ │ +
Documentation of the traits classes you need to write for each implementation of DenseVector or Dense...
│ │ │ │ +
Implements a matrix constructed from a given type representing a field and compile-time given number ...
│ │ │ │ +
Implements a matrix constructed from a given type representing a field and a compile-time given numbe...
│ │ │ │ +
Macro for wrapping boundary checks.
│ │ │ │ +
Traits for type conversions and type information.
│ │ │ │ +
Implements a scalar vector view wrapper around an existing scalar.
│ │ │ │ +
#define DUNE_ASSERT_BOUNDS(cond)
If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
Definition boundschecking.hh:30
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
auto getMPIData(T &t)
Definition mpidata.hh:44
│ │ │ │ -
A traits class describing the mapping of types onto MPI_Datatypes.
Definition mpitraits.hh:41
│ │ │ │ -
Definition binaryfunctions.hh:18
│ │ │ │ -
Definition binaryfunctions.hh:34
│ │ │ │ -
Default exception if an error in the parallel communication of the program occurred.
Definition exceptions.hh:287
│ │ │ │ -
Collective communication interface and sequential default implementation.
Definition communication.hh:100
│ │ │ │ -
int size() const
Number of processes in set, is greater than 0.
Definition communication.hh:126
│ │ │ │ -
Definition mpicommunication.hh:41
│ │ │ │ -
static MPI_Op get()
Definition mpicommunication.hh:44
│ │ │ │ -
int max(T *inout, int len) const
Compute the maximum of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:266
│ │ │ │ -
int allgatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int *displ) const
Gathers data of variable length from all tasks and distribute it to all.
Definition mpicommunication.hh:405
│ │ │ │ -
T max(const T &in) const
Compute the maximum of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:257
│ │ │ │ -
MPIFuture< T > ibroadcast(T &&data, int root) const
Distribute an array from the process with rank root to all other processes nonblocking.
Definition mpicommunication.hh:295
│ │ │ │ -
MPIFuture< void > ibarrier() const
Nonblocking barrier.
Definition mpicommunication.hh:278
│ │ │ │ -
T recv(T &&data, int source_rank, int tag, MPI_Status *status=MPI_STATUS_IGNORE) const
Receives the data from the source_rank.
Definition mpicommunication.hh:166
│ │ │ │ -
int barrier() const
Wait until all processes have arrived at this point in the program.
Definition mpicommunication.hh:272
│ │ │ │ -
int rank() const
Return rank, is between 0 and size()-1.
Definition mpicommunication.hh:133
│ │ │ │ -
int scatterv(const T *sendData, int *sendDataLen, int *displ, T *recvData, int recvDataLen, int root) const
Scatter arrays of variable length from a root to all other tasks.
Definition mpicommunication.hh:366
│ │ │ │ -
MPIFuture< T > isend(T &&data, int dest_rank, int tag) const
Sends the data to the dest_rank nonblocking.
Definition mpicommunication.hh:155
│ │ │ │ -
MPIFuture< TOUT, TIN > iallgather(TIN &&data_in, TOUT &&data_out) const
Gathers data from all tasks and distribute it to all nonblocking.
Definition mpicommunication.hh:390
│ │ │ │ -
Type allreduce(Type &&in) const
Definition mpicommunication.hh:424
│ │ │ │ -
int sum(T *inout, int len) const
Compute the sum of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:217
│ │ │ │ -
int broadcast(T *inout, int len, int root) const
Distribute an array from the process with rank root to all other processes.
Definition mpicommunication.hh:288
│ │ │ │ -
MPIFuture< T > iallreduce(T &&data) const
Compute something over all processes nonblocking.
Definition mpicommunication.hh:450
│ │ │ │ -
T sum(const T &in) const
Compute the sum of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:208
│ │ │ │ -
int allreduce(const Type *in, Type *out, int len) const
Definition mpicommunication.hh:462
│ │ │ │ -
MPIFuture< TOUT, TIN > iallreduce(TIN &&data_in, TOUT &&data_out) const
Compute something over all processes nonblocking.
Definition mpicommunication.hh:435
│ │ │ │ -
int size() const
Number of processes in set, is greater than 0.
Definition mpicommunication.hh:139
│ │ │ │ -
int gather(const T *in, T *out, int len, int root) const
Gather arrays on root task.
Definition mpicommunication.hh:310
│ │ │ │ -
int allreduce(Type *inout, int len) const
Compute something over all processes for each component of an array and return the result in every pr...
Definition mpicommunication.hh:414
│ │ │ │ -
T rrecv(T &&data, int source_rank, int tag, MPI_Status *status=MPI_STATUS_IGNORE) const
Definition mpicommunication.hh:189
│ │ │ │ -
int scatter(const T *sendData, T *recvData, int len, int root) const
Scatter array from a root to all other task.
Definition mpicommunication.hh:343
│ │ │ │ -
MPIFuture< T > irecv(T &&data, int source_rank, int tag) const
Receives the data from the source_rank nonblocking.
Definition mpicommunication.hh:177
│ │ │ │ -
int prod(T *inout, int len) const
Compute the product of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:233
│ │ │ │ -
MPIFuture< TOUT, TIN > igather(TIN &&data_in, TOUT &&data_out, int root) const
Gather arrays on root task nonblocking.
Definition mpicommunication.hh:319
│ │ │ │ -
T min(const T &in) const
Compute the minimum of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:240
│ │ │ │ -
Communication(const MPI_Comm &c=MPI_COMM_WORLD)
Instantiation using a MPI communicator.
Definition mpicommunication.hh:111
│ │ │ │ -
MPIFuture< TOUT, TIN > iscatter(TIN &&data_in, TOUT &&data_out, int root) const
Scatter array from a root to all other task nonblocking.
Definition mpicommunication.hh:352
│ │ │ │ -
int gatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int *displ, int root) const
Gather arrays of variable size on root task.
Definition mpicommunication.hh:333
│ │ │ │ -
int min(T *inout, int len) const
Compute the minimum of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:249
│ │ │ │ -
int allgather(const T *sbuf, int count, T1 *rbuf) const
Gathers data from all tasks and distribute it to all.
Definition mpicommunication.hh:381
│ │ │ │ -
int send(const T &data, int dest_rank, int tag) const
Sends the data to the dest_rank.
Definition mpicommunication.hh:146
│ │ │ │ -
Communication(const Communication< No_Comm > &)
Converting constructor for no-communication that is interpreted as MPI_COMM_SELF.
Definition mpicommunication.hh:128
│ │ │ │ -
T prod(const T &in) const
Compute the product of the argument over all processes and return the result in every process....
Definition mpicommunication.hh:224
│ │ │ │ -
Provides a future-like object for MPI communication. It contains the object that will be received and...
Definition mpifuture.hh:93
│ │ │ │ -
auto get_send_mpidata()
Definition mpifuture.hh:177
│ │ │ │ -
auto get_mpidata()
Definition mpifuture.hh:173
│ │ │ │ +
constexpr size_type cols() const
number of columns
Definition densematrix.hh:715
│ │ │ │ +
constexpr size_type rows() const
number of rows
Definition densematrix.hh:709
│ │ │ │ +
static constexpr int blocklevel
The number of block levels we contain. This is the leaf, that is, 1.
Definition densematrix.hh:178
│ │ │ │ +
Traits::row_type row_type
The type used to represent a row (must fulfill the Dune::DenseVector interface)
Definition densematrix.hh:169
│ │ │ │ +
Traits::size_type size_type
The type used for the index access and size operation.
Definition densematrix.hh:166
│ │ │ │ +
Traits::const_row_reference const_row_reference
The type used to represent a reference to a constant row (usually const row_type &)
Definition densematrix.hh:175
│ │ │ │ +
Traits::row_reference row_reference
The type used to represent a reference to a row (usually row_type &)
Definition densematrix.hh:172
│ │ │ │ +
T type
Definition typetraits.hh:531
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,676 +1,232 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -mpicommunication.hh │ │ │ │ │ +scalarmatrixview.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PARALLEL_MPICOMMUNICATION_HH │ │ │ │ │ -6#define DUNE_COMMON_PARALLEL_MPICOMMUNICATION_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_SCALARMATRIXVIEW_HH │ │ │ │ │ +6#define DUNE_COMMON_SCALARMATRIXVIEW_HH │ │ │ │ │ 7 │ │ │ │ │ -16#if HAVE_MPI │ │ │ │ │ -17 │ │ │ │ │ -18#include │ │ │ │ │ -19#include │ │ │ │ │ -20#include │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11 │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14#include │ │ │ │ │ +15#include │ │ │ │ │ +16#include │ │ │ │ │ +17#include │ │ │ │ │ +18 │ │ │ │ │ +19 │ │ │ │ │ +20namespace Dune { │ │ │ │ │ 21 │ │ │ │ │ -22#include │ │ │ │ │ +22namespace Impl { │ │ │ │ │ 23 │ │ │ │ │ -24#include │ │ │ │ │ -25#include │ │ │ │ │ -26#include │ │ │ │ │ -27#include │ │ │ │ │ -28#include │ │ │ │ │ -29#include │ │ │ │ │ -30 │ │ │ │ │ -31namespace Dune │ │ │ │ │ -32{ │ │ │ │ │ -33 │ │ │ │ │ -34 //======================================================= │ │ │ │ │ -35 // use singleton pattern and template specialization to │ │ │ │ │ -36 // generate MPI operations │ │ │ │ │ -37 //======================================================= │ │ │ │ │ -38 │ │ │ │ │ -39 template │ │ │ │ │ -40 class Generic_MPI_Op │ │ │ │ │ -41 { │ │ │ │ │ -42 │ │ │ │ │ -43 public: │ │ │ │ │ -44 static MPI_Op get () │ │ │ │ │ -45 { │ │ │ │ │ -46 if (!op) │ │ │ │ │ -47 { │ │ │ │ │ -48 op = std::make_unique(); │ │ │ │ │ -49 // The following line leaks an MPI operation object, because the │ │ │ │ │ -corresponding │ │ │ │ │ -50 //`MPI_Op_free` is never called. It is never called because there is no easy │ │ │ │ │ -51 // way to call it at the right moment: right before the call to MPI_ │ │ │ │ │ -Finalize. │ │ │ │ │ -52 // See https://gitlab.dune-project.org/core/dune-istl/issues/80 │ │ │ │ │ -53 MPI_Op_create((void (*)(void*, void*, int*, MPI_ │ │ │ │ │ -Datatype*))&operation,true,op.get()); │ │ │ │ │ -54 } │ │ │ │ │ -55 return *op; │ │ │ │ │ -56 } │ │ │ │ │ -57 private: │ │ │ │ │ -58 static void operation (Type *in, Type *inout, int *len, MPI_Datatype*) │ │ │ │ │ -59 { │ │ │ │ │ -60 BinaryFunction func; │ │ │ │ │ -61 │ │ │ │ │ -62 for (int i=0; i< *len; ++i, ++in, ++inout) { │ │ │ │ │ -63 Type temp; │ │ │ │ │ -64 temp = func(*in, *inout); │ │ │ │ │ -65 *inout = temp; │ │ │ │ │ -66 } │ │ │ │ │ -67 } │ │ │ │ │ -68 Generic_MPI_Op () {} │ │ │ │ │ -69 Generic_MPI_Op (const Generic_MPI_Op& ) {} │ │ │ │ │ -70 static std::unique_ptr op; │ │ │ │ │ -71 }; │ │ │ │ │ -72 │ │ │ │ │ -73 │ │ │ │ │ -74 template │ │ │ │ │ -75 std::unique_ptr Generic_MPI_Op::op; │ │ │ │ │ -76 │ │ │ │ │ -77#define ComposeMPIOp(func,op) \ │ │ │ │ │ -78 template \ │ │ │ │ │ -79 class Generic_MPI_Op, std::enable_if_t::is_ │ │ │ │ │ -intrinsic> >{ \ │ │ │ │ │ -80 public: \ │ │ │ │ │ -81 static MPI_Op get(){ \ │ │ │ │ │ -82 return op; \ │ │ │ │ │ -83 } \ │ │ │ │ │ -84 private: \ │ │ │ │ │ -85 Generic_MPI_Op () {} \ │ │ │ │ │ -86 Generic_MPI_Op (const Generic_MPI_Op & ) {} \ │ │ │ │ │ -87 } │ │ │ │ │ -88 │ │ │ │ │ -89 │ │ │ │ │ -90 ComposeMPIOp(std::plus, MPI_SUM); │ │ │ │ │ -91 ComposeMPIOp(std::multiplies, MPI_PROD); │ │ │ │ │ -92 ComposeMPIOp(Min, MPI_MIN); │ │ │ │ │ -93 ComposeMPIOp(Max, MPI_MAX); │ │ │ │ │ -94 │ │ │ │ │ -95#undef ComposeMPIOp │ │ │ │ │ -96 │ │ │ │ │ -97 │ │ │ │ │ -98 //======================================================= │ │ │ │ │ -99 // use singleton pattern and template specialization to │ │ │ │ │ -100 // generate MPI operations │ │ │ │ │ -101 //======================================================= │ │ │ │ │ -102 │ │ │ │ │ -106 template<> │ │ │ │ │ -107 class Communication │ │ │ │ │ -108 { │ │ │ │ │ -109 public: │ │ │ │ │ -111 Communication (const MPI_Comm& c = MPI_COMM_WORLD) │ │ │ │ │ -112 : communicator(c) │ │ │ │ │ -113 { │ │ │ │ │ -114 if(communicator!=MPI_COMM_NULL) { │ │ │ │ │ -115 int initialized = 0; │ │ │ │ │ -116 MPI_Initialized(&initialized); │ │ │ │ │ -117 if (!initialized) │ │ │ │ │ -118 DUNE_THROW(ParallelError,"You must call MPIHelper::instance(argc,argv) in │ │ │ │ │ -your main() function before using the MPI Communication!"); │ │ │ │ │ -119 MPI_Comm_rank(communicator,&me); │ │ │ │ │ -120 MPI_Comm_size(communicator,&procs); │ │ │ │ │ -121 }else{ │ │ │ │ │ -122 procs=0; │ │ │ │ │ -123 me=-1; │ │ │ │ │ -124 } │ │ │ │ │ -125 } │ │ │ │ │ -126 │ │ │ │ │ -128 Communication (const Communication&) │ │ │ │ │ -129 : Communication(MPI_COMM_SELF) │ │ │ │ │ -130 {} │ │ │ │ │ +39 template │ │ │ │ │ +40 class ScalarMatrixView : │ │ │ │ │ +41 public DenseMatrix> │ │ │ │ │ +42 { │ │ │ │ │ +43 ScalarVectorView data_; │ │ │ │ │ +44 using Base = DenseMatrix>; │ │ │ │ │ +45 │ │ │ │ │ +46 template │ │ │ │ │ +47 friend class ScalarMatrixView; │ │ │ │ │ +48 public: │ │ │ │ │ +49 │ │ │ │ │ +50 //===== type definitions and constants │ │ │ │ │ +51 │ │ │ │ │ +54 constexpr static int blocklevel = 1; │ │ │ │ │ +55 │ │ │ │ │ +56 using size_type = typename Base::size_type; │ │ │ │ │ +57 using row_type = typename Base::row_type; │ │ │ │ │ +58 using row_reference = typename Base::row_reference; │ │ │ │ │ +59 using const_row_reference = typename Base::const_row_reference; │ │ │ │ │ +60 │ │ │ │ │ +63 constexpr static int rows = 1; │ │ │ │ │ +66 constexpr static int cols = 1; │ │ │ │ │ +67 │ │ │ │ │ +68 //===== constructors │ │ │ │ │ +71 constexpr ScalarMatrixView () │ │ │ │ │ +72 : data_() │ │ │ │ │ +73 {} │ │ │ │ │ +74 │ │ │ │ │ +76 ScalarMatrixView (K* p) : │ │ │ │ │ +77 data_(p) │ │ │ │ │ +78 {} │ │ │ │ │ +79 │ │ │ │ │ +81 ScalarMatrixView (const ScalarMatrixView &other) : │ │ │ │ │ +82 Base(), │ │ │ │ │ +83 data_(other.data_) │ │ │ │ │ +84 {} │ │ │ │ │ +85 │ │ │ │ │ +87 ScalarMatrixView (ScalarMatrixView &&other) : │ │ │ │ │ +88 Base(), │ │ │ │ │ +89 data_( other.data_ ) │ │ │ │ │ +90 {} │ │ │ │ │ +91 │ │ │ │ │ +93 ScalarMatrixView& operator= (const ScalarMatrixView& other) │ │ │ │ │ +94 { │ │ │ │ │ +95 data_ = other.data_; │ │ │ │ │ +96 return *this; │ │ │ │ │ +97 } │ │ │ │ │ +98 │ │ │ │ │ +99 template │ │ │ │ │ +100 ScalarMatrixView& operator= (const ScalarMatrixView& other) │ │ │ │ │ +101 { │ │ │ │ │ +102 data_ = other.data_; │ │ │ │ │ +103 return *this; │ │ │ │ │ +104 } │ │ │ │ │ +105 │ │ │ │ │ +107 template::value, int> = 0> │ │ │ │ │ +109 inline ScalarMatrixView& operator= (const T& k) │ │ │ │ │ +110 { │ │ │ │ │ +111 data_ = k; │ │ │ │ │ +112 return *this; │ │ │ │ │ +113 } │ │ │ │ │ +114 │ │ │ │ │ +115 // make this thing a matrix │ │ │ │ │ +116 static constexpr size_type mat_rows() { return 1; } │ │ │ │ │ +117 static constexpr size_type mat_cols() { return 1; } │ │ │ │ │ +118 │ │ │ │ │ +119 row_reference mat_access ([[maybe_unused]] size_type i) │ │ │ │ │ +120 { │ │ │ │ │ +121 DUNE_ASSERT_BOUNDS(i == 0); │ │ │ │ │ +122 return data_; │ │ │ │ │ +123 } │ │ │ │ │ +124 │ │ │ │ │ +125 const_row_reference mat_access ([[maybe_unused]] size_type i) const │ │ │ │ │ +126 { │ │ │ │ │ +127 DUNE_ASSERT_BOUNDS(i == 0); │ │ │ │ │ +128 return data_; │ │ │ │ │ +129 } │ │ │ │ │ +130 }; // class ScalarMatrixView │ │ │ │ │ 131 │ │ │ │ │ -133 int rank () const │ │ │ │ │ -134 { │ │ │ │ │ -135 return me; │ │ │ │ │ -136 } │ │ │ │ │ -137 │ │ │ │ │ -139 int size () const │ │ │ │ │ -140 { │ │ │ │ │ -141 return procs; │ │ │ │ │ -142 } │ │ │ │ │ -143 │ │ │ │ │ -145 template │ │ │ │ │ -146 int send(const T& data, int dest_rank, int tag) const │ │ │ │ │ -147 { │ │ │ │ │ -148 auto mpi_data = getMPIData(data); │ │ │ │ │ -149 return MPI_Send(mpi_data.ptr(), mpi_data.size(), mpi_data.type(), │ │ │ │ │ -150 dest_rank, tag, communicator); │ │ │ │ │ -151 } │ │ │ │ │ -152 │ │ │ │ │ -154 template │ │ │ │ │ -155 MPIFuture isend(T&& data, int dest_rank, int tag) const │ │ │ │ │ -156 { │ │ │ │ │ -157 MPIFuture future(std::forward(data)); │ │ │ │ │ -158 auto mpidata = future.get_mpidata(); │ │ │ │ │ -159 MPI_Isend(mpidata.ptr(), mpidata.size(), mpidata.type(), │ │ │ │ │ -160 dest_rank, tag, communicator, &future.req_); │ │ │ │ │ -161 return future; │ │ │ │ │ +133 template │ │ │ │ │ +134 std::ostream& operator<< (std::ostream& s, const ScalarMatrixView& a) │ │ │ │ │ +135 { │ │ │ │ │ +136 s << a[0][0]; │ │ │ │ │ +137 return s; │ │ │ │ │ +138 } │ │ │ │ │ +139 │ │ │ │ │ +141 template::value, int> = 0> │ │ │ │ │ +143 auto asMatrix(T& t) │ │ │ │ │ +144 { │ │ │ │ │ +145 return ScalarMatrixView{&t}; │ │ │ │ │ +146 } │ │ │ │ │ +147 │ │ │ │ │ +149 template::value, int> = 0> │ │ │ │ │ +151 auto asMatrix(const T& t) │ │ │ │ │ +152 { │ │ │ │ │ +153 return ScalarMatrixView{&t}; │ │ │ │ │ +154 } │ │ │ │ │ +155 │ │ │ │ │ +157 template::value, int> = 0> │ │ │ │ │ +159 T& asMatrix(T& t) │ │ │ │ │ +160 { │ │ │ │ │ +161 return t; │ │ │ │ │ 162 } │ │ │ │ │ 163 │ │ │ │ │ -165 template │ │ │ │ │ -166 T recv(T&& data, int source_rank, int tag, MPI_Status* status = MPI_STATUS_ │ │ │ │ │ -IGNORE) const │ │ │ │ │ -167 { │ │ │ │ │ -168 T lvalue_data(std::forward(data)); │ │ │ │ │ -169 auto mpi_data = getMPIData(lvalue_data); │ │ │ │ │ -170 MPI_Recv(mpi_data.ptr(), mpi_data.size(), mpi_data.type(), │ │ │ │ │ -171 source_rank, tag, communicator, status); │ │ │ │ │ -172 return lvalue_data; │ │ │ │ │ -173 } │ │ │ │ │ -174 │ │ │ │ │ -176 template │ │ │ │ │ -177 MPIFuture irecv(T&& data, int source_rank, int tag) const │ │ │ │ │ -178 { │ │ │ │ │ -179 MPIFuture future(std::forward(data)); │ │ │ │ │ -180 auto mpidata = future.get_mpidata(); │ │ │ │ │ -181 if (mpidata.size() == 0) │ │ │ │ │ -182 DUNE_THROW(ParallelError, "Size if irecv data object is zero. Reserve │ │ │ │ │ -sufficient size for the whole message"); │ │ │ │ │ -183 MPI_Irecv(mpidata.ptr(), mpidata.size(), mpidata.type(), │ │ │ │ │ -184 source_rank, tag, communicator, &future.req_); │ │ │ │ │ -185 return future; │ │ │ │ │ -186 } │ │ │ │ │ -187 │ │ │ │ │ -188 template │ │ │ │ │ -189 T rrecv(T&& data, int source_rank, int tag, MPI_Status* status = MPI_ │ │ │ │ │ -STATUS_IGNORE) const │ │ │ │ │ -190 { │ │ │ │ │ -191 MPI_Status _status; │ │ │ │ │ -192 MPI_Message _message; │ │ │ │ │ -193 T lvalue_data(std::forward(data)); │ │ │ │ │ -194 auto mpi_data = getMPIData(lvalue_data); │ │ │ │ │ -195 static_assert(!mpi_data.static_size, "rrecv work only for non-static-sized │ │ │ │ │ -types."); │ │ │ │ │ -196 if(status == MPI_STATUS_IGNORE) │ │ │ │ │ -197 status = &_status; │ │ │ │ │ -198 MPI_Mprobe(source_rank, tag, communicator, &_message, status); │ │ │ │ │ -199 int size; │ │ │ │ │ -200 MPI_Get_count(status, mpi_data.type(), &size); │ │ │ │ │ -201 mpi_data.resize(size); │ │ │ │ │ -202 MPI_Mrecv(mpi_data.ptr(), mpi_data.size(), mpi_data.type(), &_message, │ │ │ │ │ -status); │ │ │ │ │ -203 return lvalue_data; │ │ │ │ │ -204 } │ │ │ │ │ -205 │ │ │ │ │ -207 template │ │ │ │ │ -208 T sum (const T& in) const │ │ │ │ │ -209 { │ │ │ │ │ -210 T out; │ │ │ │ │ -211 allreduce >(&in,&out,1); │ │ │ │ │ -212 return out; │ │ │ │ │ -213 } │ │ │ │ │ -214 │ │ │ │ │ -216 template │ │ │ │ │ -217 int sum (T* inout, int len) const │ │ │ │ │ -218 { │ │ │ │ │ -219 return allreduce >(inout,len); │ │ │ │ │ -220 } │ │ │ │ │ -221 │ │ │ │ │ -223 template │ │ │ │ │ -224 T prod (const T& in) const │ │ │ │ │ -225 { │ │ │ │ │ -226 T out; │ │ │ │ │ -227 allreduce >(&in,&out,1); │ │ │ │ │ -228 return out; │ │ │ │ │ -229 } │ │ │ │ │ -230 │ │ │ │ │ -232 template │ │ │ │ │ -233 int prod (T* inout, int len) const │ │ │ │ │ -234 { │ │ │ │ │ -235 return allreduce >(inout,len); │ │ │ │ │ -236 } │ │ │ │ │ -237 │ │ │ │ │ -239 template │ │ │ │ │ -240 T min (const T& in) const │ │ │ │ │ -241 { │ │ │ │ │ -242 T out; │ │ │ │ │ -243 allreduce >(&in,&out,1); │ │ │ │ │ -244 return out; │ │ │ │ │ -245 } │ │ │ │ │ -246 │ │ │ │ │ -248 template │ │ │ │ │ -249 int min (T* inout, int len) const │ │ │ │ │ -250 { │ │ │ │ │ -251 return allreduce >(inout,len); │ │ │ │ │ -252 } │ │ │ │ │ -253 │ │ │ │ │ -254 │ │ │ │ │ -256 template │ │ │ │ │ -257 T max (const T& in) const │ │ │ │ │ -258 { │ │ │ │ │ -259 T out; │ │ │ │ │ -260 allreduce >(&in,&out,1); │ │ │ │ │ -261 return out; │ │ │ │ │ -262 } │ │ │ │ │ -263 │ │ │ │ │ -265 template │ │ │ │ │ -266 int max (T* inout, int len) const │ │ │ │ │ -267 { │ │ │ │ │ -268 return allreduce >(inout,len); │ │ │ │ │ -269 } │ │ │ │ │ -270 │ │ │ │ │ -272 int barrier () const │ │ │ │ │ -273 { │ │ │ │ │ -274 return MPI_Barrier(communicator); │ │ │ │ │ -275 } │ │ │ │ │ -276 │ │ │ │ │ -278 MPIFuture ibarrier () const │ │ │ │ │ -279 { │ │ │ │ │ -280 MPIFuture future(true); // make a valid MPIFuture │ │ │ │ │ -281 MPI_Ibarrier(communicator, &future.req_); │ │ │ │ │ -282 return future; │ │ │ │ │ -283 } │ │ │ │ │ -284 │ │ │ │ │ -285 │ │ │ │ │ -287 template │ │ │ │ │ -288 int broadcast (T* inout, int len, int root) const │ │ │ │ │ -289 { │ │ │ │ │ -290 return MPI_Bcast(inout,len,MPITraits::getType(),root,communicator); │ │ │ │ │ -291 } │ │ │ │ │ -292 │ │ │ │ │ -294 template │ │ │ │ │ -295 MPIFuture ibroadcast(T&& data, int root) const{ │ │ │ │ │ -296 MPIFuture future(std::forward(data)); │ │ │ │ │ -297 auto mpidata = future.get_mpidata(); │ │ │ │ │ -298 MPI_Ibcast(mpidata.ptr(), │ │ │ │ │ -299 mpidata.size(), │ │ │ │ │ -300 mpidata.type(), │ │ │ │ │ -301 root, │ │ │ │ │ -302 communicator, │ │ │ │ │ -303 &future.req_); │ │ │ │ │ -304 return future; │ │ │ │ │ -305 } │ │ │ │ │ -306 │ │ │ │ │ -309 template │ │ │ │ │ -310 int gather (const T* in, T* out, int len, int root) const │ │ │ │ │ -311 { │ │ │ │ │ -312 return MPI_Gather(const_cast(in),len,MPITraits::getType(), │ │ │ │ │ -313 out,len,MPITraits::getType(), │ │ │ │ │ -314 root,communicator); │ │ │ │ │ -315 } │ │ │ │ │ -316 │ │ │ │ │ -318 template> │ │ │ │ │ -319 MPIFuture igather(TIN&& data_in, TOUT&& data_out, int root) │ │ │ │ │ -const{ │ │ │ │ │ -320 MPIFuture future(std::forward(data_out), std::forward │ │ │ │ │ -(data_in)); │ │ │ │ │ -321 auto mpidata_in = future.get_send_mpidata(); │ │ │ │ │ -322 auto mpidata_out = future.get_mpidata(); │ │ │ │ │ -323 assert(root != me || mpidata_in.size()*procs <= mpidata_out.size()); │ │ │ │ │ -324 int outlen = (me==root) * mpidata_in.size(); │ │ │ │ │ -325 MPI_Igather(mpidata_in.ptr(), mpidata_in.size(), mpidata_in.type(), │ │ │ │ │ -326 mpidata_out.ptr(), outlen, mpidata_out.type(), │ │ │ │ │ -327 root, communicator, &future.req_); │ │ │ │ │ -328 return future; │ │ │ │ │ -329 } │ │ │ │ │ -330 │ │ │ │ │ -332 template │ │ │ │ │ -333 int gatherv (const T* in, int sendDataLen, T* out, int* recvDataLen, int* │ │ │ │ │ -displ, int root) const │ │ │ │ │ -334 { │ │ │ │ │ -335 return MPI_Gatherv(const_cast(in),sendDataLen,MPITraits::getType(), │ │ │ │ │ -336 out,recvDataLen,displ,MPITraits::getType(), │ │ │ │ │ -337 root,communicator); │ │ │ │ │ -338 } │ │ │ │ │ -339 │ │ │ │ │ -342 template │ │ │ │ │ -343 int scatter (const T* sendData, T* recvData, int len, int root) const │ │ │ │ │ -344 { │ │ │ │ │ -345 return MPI_Scatter(const_cast(sendData),len,MPITraits::getType(), │ │ │ │ │ -346 recvData,len,MPITraits::getType(), │ │ │ │ │ -347 root,communicator); │ │ │ │ │ -348 } │ │ │ │ │ -349 │ │ │ │ │ -351 template │ │ │ │ │ -352 MPIFuture iscatter(TIN&& data_in, TOUT&& data_out, int root) │ │ │ │ │ -const │ │ │ │ │ -353 { │ │ │ │ │ -354 MPIFuture future(std::forward(data_out), std::forward │ │ │ │ │ -(data_in)); │ │ │ │ │ -355 auto mpidata_in = future.get_send_mpidata(); │ │ │ │ │ -356 auto mpidata_out = future.get_mpidata(); │ │ │ │ │ -357 int inlen = (me==root) * mpidata_in.size()/procs; │ │ │ │ │ -358 MPI_Iscatter(mpidata_in.ptr(), inlen, mpidata_in.type(), │ │ │ │ │ -359 mpidata_out.ptr(), mpidata_out.size(), mpidata_out.type(), │ │ │ │ │ -360 root, communicator, &future.req_); │ │ │ │ │ -361 return future; │ │ │ │ │ -362 } │ │ │ │ │ -363 │ │ │ │ │ -365 template │ │ │ │ │ -366 int scatterv (const T* sendData, int* sendDataLen, int* displ, T* recvData, │ │ │ │ │ -int recvDataLen, int root) const │ │ │ │ │ -367 { │ │ │ │ │ -368 return MPI_Scatterv(const_cast │ │ │ │ │ -(sendData),sendDataLen,displ,MPITraits::getType(), │ │ │ │ │ -369 recvData,recvDataLen,MPITraits::getType(), │ │ │ │ │ -370 root,communicator); │ │ │ │ │ -371 } │ │ │ │ │ -372 │ │ │ │ │ -373 │ │ │ │ │ -374 operator MPI_Comm () const │ │ │ │ │ -375 { │ │ │ │ │ -376 return communicator; │ │ │ │ │ -377 } │ │ │ │ │ -378 │ │ │ │ │ -380 template │ │ │ │ │ -381 int allgather(const T* sbuf, int count, T1* rbuf) const │ │ │ │ │ -382 { │ │ │ │ │ -383 return MPI_Allgather(const_cast(sbuf), count, MPITraits::getType(), │ │ │ │ │ -384 rbuf, count, MPITraits::getType(), │ │ │ │ │ -385 communicator); │ │ │ │ │ -386 } │ │ │ │ │ -387 │ │ │ │ │ -389 template │ │ │ │ │ -390 MPIFuture iallgather(TIN&& data_in, TOUT&& data_out) const │ │ │ │ │ -391 { │ │ │ │ │ -392 MPIFuture future(std::forward(data_out), std::forward │ │ │ │ │ -(data_in)); │ │ │ │ │ -393 auto mpidata_in = future.get_send_mpidata(); │ │ │ │ │ -394 auto mpidata_out = future.get_mpidata(); │ │ │ │ │ -395 assert(mpidata_in.size()*procs <= mpidata_out.size()); │ │ │ │ │ -396 int outlen = mpidata_in.size(); │ │ │ │ │ -397 MPI_Iallgather(mpidata_in.ptr(), mpidata_in.size(), mpidata_in.type(), │ │ │ │ │ -398 mpidata_out.ptr(), outlen, mpidata_out.type(), │ │ │ │ │ -399 communicator, &future.req_); │ │ │ │ │ -400 return future; │ │ │ │ │ -401 } │ │ │ │ │ -402 │ │ │ │ │ -404 template │ │ │ │ │ -405 int allgatherv (const T* in, int sendDataLen, T* out, int* recvDataLen, │ │ │ │ │ -int* displ) const │ │ │ │ │ -406 { │ │ │ │ │ -407 return MPI_Allgatherv(const_cast(in),sendDataLen,MPITraits::getType │ │ │ │ │ -(), │ │ │ │ │ -408 out,recvDataLen,displ,MPITraits::getType(), │ │ │ │ │ -409 communicator); │ │ │ │ │ -410 } │ │ │ │ │ -411 │ │ │ │ │ -413 template │ │ │ │ │ -414 int allreduce(Type* inout, int len) const │ │ │ │ │ -415 { │ │ │ │ │ -416 Type* out = new Type[len]; │ │ │ │ │ -417 int ret = allreduce(inout,out,len); │ │ │ │ │ -418 std::copy(out, out+len, inout); │ │ │ │ │ -419 delete[] out; │ │ │ │ │ -420 return ret; │ │ │ │ │ -421 } │ │ │ │ │ -422 │ │ │ │ │ -423 template │ │ │ │ │ -424 Type allreduce(Type&& in) const{ │ │ │ │ │ -425 Type lvalue_data = std::forward(in); │ │ │ │ │ -426 auto data = getMPIData(lvalue_data); │ │ │ │ │ -427 MPI_Allreduce(MPI_IN_PLACE, data.ptr(), data.size(), data.type(), │ │ │ │ │ -428 (Generic_MPI_Op::get()), │ │ │ │ │ -429 communicator); │ │ │ │ │ -430 return lvalue_data; │ │ │ │ │ -431 } │ │ │ │ │ -432 │ │ │ │ │ -434 template │ │ │ │ │ -435 MPIFuture iallreduce(TIN&& data_in, TOUT&& data_out) const { │ │ │ │ │ -436 MPIFuture future(std::forward(data_out), std::forward │ │ │ │ │ -(data_in)); │ │ │ │ │ -437 auto mpidata_in = future.get_send_mpidata(); │ │ │ │ │ -438 auto mpidata_out = future.get_mpidata(); │ │ │ │ │ -439 assert(mpidata_out.size() == mpidata_in.size()); │ │ │ │ │ -440 assert(mpidata_out.type() == mpidata_in.type()); │ │ │ │ │ -441 MPI_Iallreduce(mpidata_in.ptr(), mpidata_out.ptr(), │ │ │ │ │ -442 mpidata_out.size(), mpidata_out.type(), │ │ │ │ │ -443 (Generic_MPI_Op::get()), │ │ │ │ │ -444 communicator, &future.req_); │ │ │ │ │ -445 return future; │ │ │ │ │ -446 } │ │ │ │ │ -447 │ │ │ │ │ -449 template │ │ │ │ │ -450 MPIFuture iallreduce(T&& data) const{ │ │ │ │ │ -451 MPIFuture future(std::forward(data)); │ │ │ │ │ -452 auto mpidata = future.get_mpidata(); │ │ │ │ │ -453 MPI_Iallreduce(MPI_IN_PLACE, mpidata.ptr(), │ │ │ │ │ -454 mpidata.size(), mpidata.type(), │ │ │ │ │ -455 (Generic_MPI_Op::get()), │ │ │ │ │ -456 communicator, &future.req_); │ │ │ │ │ -457 return future; │ │ │ │ │ -458 } │ │ │ │ │ -459 │ │ │ │ │ -461 template │ │ │ │ │ -462 int allreduce(const Type* in, Type* out, int len) const │ │ │ │ │ -463 { │ │ │ │ │ -464 return MPI_Allreduce(const_cast(in), out, len, MPITraits:: │ │ │ │ │ -getType(), │ │ │ │ │ -465 (Generic_MPI_Op::get()),communicator); │ │ │ │ │ -466 } │ │ │ │ │ -467 │ │ │ │ │ -468 private: │ │ │ │ │ -469 MPI_Comm communicator; │ │ │ │ │ -470 int me; │ │ │ │ │ -471 int procs; │ │ │ │ │ -472 }; │ │ │ │ │ -473} // namespace dune │ │ │ │ │ -474 │ │ │ │ │ -475#endif // HAVE_MPI │ │ │ │ │ -476 │ │ │ │ │ -477#endif │ │ │ │ │ -mpifuture.hh │ │ │ │ │ -communication.hh │ │ │ │ │ -Implements an utility class that provides collective communication methods for │ │ │ │ │ -sequential programs. │ │ │ │ │ -mpidata.hh │ │ │ │ │ -Interface class to translate objects to a MPI_Datatype, void* and size used for │ │ │ │ │ -MPI calls. │ │ │ │ │ -ComposeMPIOp │ │ │ │ │ -#define ComposeMPIOp(func, op) │ │ │ │ │ -Definition mpicommunication.hh:77 │ │ │ │ │ -mpitraits.hh │ │ │ │ │ -Traits classes for mapping types onto MPI_Datatype. │ │ │ │ │ -binaryfunctions.hh │ │ │ │ │ -helper classes to provide unique types for standard functions │ │ │ │ │ -exceptions.hh │ │ │ │ │ -A few common exception classes. │ │ │ │ │ -DUNE_THROW │ │ │ │ │ -#define DUNE_THROW(E, m) │ │ │ │ │ -Definition exceptions.hh:218 │ │ │ │ │ +165 template::value, int> = 0> │ │ │ │ │ +167 const T& asMatrix(const T& t) │ │ │ │ │ +168 { │ │ │ │ │ +169 return t; │ │ │ │ │ +170 } │ │ │ │ │ +171 │ │ │ │ │ +174} // end namespace Impl │ │ │ │ │ +175 │ │ │ │ │ +176 template │ │ │ │ │ +177 struct FieldTraits> : public FieldTraits> {}; │ │ │ │ │ +178 │ │ │ │ │ +179 template │ │ │ │ │ +180 struct DenseMatVecTraits> │ │ │ │ │ +181 { │ │ │ │ │ +182 using derived_type = Impl::ScalarMatrixView; │ │ │ │ │ +183 using row_type = Impl::ScalarVectorView; │ │ │ │ │ +184 using row_reference = row_type&; │ │ │ │ │ +185 using const_row_reference = const row_type&; │ │ │ │ │ +186 using value_type = std::remove_const_t; │ │ │ │ │ +187 using size_type = std::size_t; │ │ │ │ │ +188 }; │ │ │ │ │ +189 │ │ │ │ │ +190 │ │ │ │ │ +191 template │ │ │ │ │ +192 struct AutonomousValueType> │ │ │ │ │ +193 { │ │ │ │ │ +194 using type = FieldMatrix,1,1>; │ │ │ │ │ +195 }; │ │ │ │ │ +196 │ │ │ │ │ +197 │ │ │ │ │ +198} // end namespace Dune │ │ │ │ │ +199 │ │ │ │ │ +200#endif // DUNE_COMMON_SCALARMATRIXVIEW_HH │ │ │ │ │ +matvectraits.hh │ │ │ │ │ +Documentation of the traits classes you need to write for each implementation │ │ │ │ │ +of DenseVector or Dense... │ │ │ │ │ +fmatrix.hh │ │ │ │ │ +Implements a matrix constructed from a given type representing a field and │ │ │ │ │ +compile-time given number ... │ │ │ │ │ +densematrix.hh │ │ │ │ │ +Implements a matrix constructed from a given type representing a field and a │ │ │ │ │ +compile-time given numbe... │ │ │ │ │ +boundschecking.hh │ │ │ │ │ +Macro for wrapping boundary checks. │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +scalarvectorview.hh │ │ │ │ │ +Implements a scalar vector view wrapper around an existing scalar. │ │ │ │ │ +DUNE_ASSERT_BOUNDS │ │ │ │ │ +#define DUNE_ASSERT_BOUNDS(cond) │ │ │ │ │ +If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do │ │ │ │ │ +nothing. │ │ │ │ │ +Definition boundschecking.hh:30 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::getMPIData │ │ │ │ │ -auto getMPIData(T &t) │ │ │ │ │ -Definition mpidata.hh:44 │ │ │ │ │ -Dune::MPITraits │ │ │ │ │ -A traits class describing the mapping of types onto MPI_Datatypes. │ │ │ │ │ -Definition mpitraits.hh:41 │ │ │ │ │ -Dune::Min │ │ │ │ │ -Definition binaryfunctions.hh:18 │ │ │ │ │ -Dune::Max │ │ │ │ │ -Definition binaryfunctions.hh:34 │ │ │ │ │ -Dune::ParallelError │ │ │ │ │ -Default exception if an error in the parallel communication of the program │ │ │ │ │ -occurred. │ │ │ │ │ -Definition exceptions.hh:287 │ │ │ │ │ -Dune::Communication │ │ │ │ │ -Collective communication interface and sequential default implementation. │ │ │ │ │ -Definition communication.hh:100 │ │ │ │ │ -Dune::Communication::size │ │ │ │ │ -int size() const │ │ │ │ │ -Number of processes in set, is greater than 0. │ │ │ │ │ -Definition communication.hh:126 │ │ │ │ │ -Dune::Generic_MPI_Op │ │ │ │ │ -Definition mpicommunication.hh:41 │ │ │ │ │ -Dune::Generic_MPI_Op::get │ │ │ │ │ -static MPI_Op get() │ │ │ │ │ -Definition mpicommunication.hh:44 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::max │ │ │ │ │ -int max(T *inout, int len) const │ │ │ │ │ -Compute the maximum of the argument over all processes and return the result in │ │ │ │ │ -every process.... │ │ │ │ │ -Definition mpicommunication.hh:266 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::allgatherv │ │ │ │ │ -int allgatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int │ │ │ │ │ -*displ) const │ │ │ │ │ -Gathers data of variable length from all tasks and distribute it to all. │ │ │ │ │ -Definition mpicommunication.hh:405 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::max │ │ │ │ │ -T max(const T &in) const │ │ │ │ │ -Compute the maximum of the argument over all processes and return the result in │ │ │ │ │ -every process.... │ │ │ │ │ -Definition mpicommunication.hh:257 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::ibroadcast │ │ │ │ │ -MPIFuture< T > ibroadcast(T &&data, int root) const │ │ │ │ │ -Distribute an array from the process with rank root to all other processes │ │ │ │ │ -nonblocking. │ │ │ │ │ -Definition mpicommunication.hh:295 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::ibarrier │ │ │ │ │ -MPIFuture< void > ibarrier() const │ │ │ │ │ -Nonblocking barrier. │ │ │ │ │ -Definition mpicommunication.hh:278 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::recv │ │ │ │ │ -T recv(T &&data, int source_rank, int tag, MPI_Status *status=MPI_STATUS_ │ │ │ │ │ -IGNORE) const │ │ │ │ │ -Receives the data from the source_rank. │ │ │ │ │ -Definition mpicommunication.hh:166 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::barrier │ │ │ │ │ -int barrier() const │ │ │ │ │ -Wait until all processes have arrived at this point in the program. │ │ │ │ │ -Definition mpicommunication.hh:272 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::rank │ │ │ │ │ -int rank() const │ │ │ │ │ -Return rank, is between 0 and size()-1. │ │ │ │ │ -Definition mpicommunication.hh:133 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::scatterv │ │ │ │ │ -int scatterv(const T *sendData, int *sendDataLen, int *displ, T *recvData, int │ │ │ │ │ -recvDataLen, int root) const │ │ │ │ │ -Scatter arrays of variable length from a root to all other tasks. │ │ │ │ │ -Definition mpicommunication.hh:366 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::isend │ │ │ │ │ -MPIFuture< T > isend(T &&data, int dest_rank, int tag) const │ │ │ │ │ -Sends the data to the dest_rank nonblocking. │ │ │ │ │ -Definition mpicommunication.hh:155 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::iallgather │ │ │ │ │ -MPIFuture< TOUT, TIN > iallgather(TIN &&data_in, TOUT &&data_out) const │ │ │ │ │ -Gathers data from all tasks and distribute it to all nonblocking. │ │ │ │ │ -Definition mpicommunication.hh:390 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::allreduce │ │ │ │ │ -Type allreduce(Type &&in) const │ │ │ │ │ -Definition mpicommunication.hh:424 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::sum │ │ │ │ │ -int sum(T *inout, int len) const │ │ │ │ │ -Compute the sum of the argument over all processes and return the result in │ │ │ │ │ -every process.... │ │ │ │ │ -Definition mpicommunication.hh:217 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::broadcast │ │ │ │ │ -int broadcast(T *inout, int len, int root) const │ │ │ │ │ -Distribute an array from the process with rank root to all other processes. │ │ │ │ │ -Definition mpicommunication.hh:288 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::iallreduce │ │ │ │ │ -MPIFuture< T > iallreduce(T &&data) const │ │ │ │ │ -Compute something over all processes nonblocking. │ │ │ │ │ -Definition mpicommunication.hh:450 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::sum │ │ │ │ │ -T sum(const T &in) const │ │ │ │ │ -Compute the sum of the argument over all processes and return the result in │ │ │ │ │ -every process.... │ │ │ │ │ -Definition mpicommunication.hh:208 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::allreduce │ │ │ │ │ -int allreduce(const Type *in, Type *out, int len) const │ │ │ │ │ -Definition mpicommunication.hh:462 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::iallreduce │ │ │ │ │ -MPIFuture< TOUT, TIN > iallreduce(TIN &&data_in, TOUT &&data_out) const │ │ │ │ │ -Compute something over all processes nonblocking. │ │ │ │ │ -Definition mpicommunication.hh:435 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::size │ │ │ │ │ -int size() const │ │ │ │ │ -Number of processes in set, is greater than 0. │ │ │ │ │ -Definition mpicommunication.hh:139 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::gather │ │ │ │ │ -int gather(const T *in, T *out, int len, int root) const │ │ │ │ │ -Gather arrays on root task. │ │ │ │ │ -Definition mpicommunication.hh:310 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::allreduce │ │ │ │ │ -int allreduce(Type *inout, int len) const │ │ │ │ │ -Compute something over all processes for each component of an array and return │ │ │ │ │ -the result in every pr... │ │ │ │ │ -Definition mpicommunication.hh:414 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::rrecv │ │ │ │ │ -T rrecv(T &&data, int source_rank, int tag, MPI_Status *status=MPI_STATUS_ │ │ │ │ │ -IGNORE) const │ │ │ │ │ -Definition mpicommunication.hh:189 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::scatter │ │ │ │ │ -int scatter(const T *sendData, T *recvData, int len, int root) const │ │ │ │ │ -Scatter array from a root to all other task. │ │ │ │ │ -Definition mpicommunication.hh:343 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::irecv │ │ │ │ │ -MPIFuture< T > irecv(T &&data, int source_rank, int tag) const │ │ │ │ │ -Receives the data from the source_rank nonblocking. │ │ │ │ │ -Definition mpicommunication.hh:177 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::prod │ │ │ │ │ -int prod(T *inout, int len) const │ │ │ │ │ -Compute the product of the argument over all processes and return the result in │ │ │ │ │ -every process.... │ │ │ │ │ -Definition mpicommunication.hh:233 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::igather │ │ │ │ │ -MPIFuture< TOUT, TIN > igather(TIN &&data_in, TOUT &&data_out, int root) const │ │ │ │ │ -Gather arrays on root task nonblocking. │ │ │ │ │ -Definition mpicommunication.hh:319 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::min │ │ │ │ │ -T min(const T &in) const │ │ │ │ │ -Compute the minimum of the argument over all processes and return the result in │ │ │ │ │ -every process.... │ │ │ │ │ -Definition mpicommunication.hh:240 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::Communication │ │ │ │ │ -Communication(const MPI_Comm &c=MPI_COMM_WORLD) │ │ │ │ │ -Instantiation using a MPI communicator. │ │ │ │ │ -Definition mpicommunication.hh:111 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::iscatter │ │ │ │ │ -MPIFuture< TOUT, TIN > iscatter(TIN &&data_in, TOUT &&data_out, int root) const │ │ │ │ │ -Scatter array from a root to all other task nonblocking. │ │ │ │ │ -Definition mpicommunication.hh:352 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::gatherv │ │ │ │ │ -int gatherv(const T *in, int sendDataLen, T *out, int *recvDataLen, int *displ, │ │ │ │ │ -int root) const │ │ │ │ │ -Gather arrays of variable size on root task. │ │ │ │ │ -Definition mpicommunication.hh:333 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::min │ │ │ │ │ -int min(T *inout, int len) const │ │ │ │ │ -Compute the minimum of the argument over all processes and return the result in │ │ │ │ │ -every process.... │ │ │ │ │ -Definition mpicommunication.hh:249 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::allgather │ │ │ │ │ -int allgather(const T *sbuf, int count, T1 *rbuf) const │ │ │ │ │ -Gathers data from all tasks and distribute it to all. │ │ │ │ │ -Definition mpicommunication.hh:381 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::send │ │ │ │ │ -int send(const T &data, int dest_rank, int tag) const │ │ │ │ │ -Sends the data to the dest_rank. │ │ │ │ │ -Definition mpicommunication.hh:146 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::Communication │ │ │ │ │ -Communication(const Communication< No_Comm > &) │ │ │ │ │ -Converting constructor for no-communication that is interpreted as MPI_COMM_ │ │ │ │ │ -SELF. │ │ │ │ │ -Definition mpicommunication.hh:128 │ │ │ │ │ -Dune::Communication<_MPI_Comm_>::prod │ │ │ │ │ -T prod(const T &in) const │ │ │ │ │ -Compute the product of the argument over all processes and return the result in │ │ │ │ │ -every process.... │ │ │ │ │ -Definition mpicommunication.hh:224 │ │ │ │ │ -Dune::MPIFuture │ │ │ │ │ -Provides a future-like object for MPI communication. It contains the object │ │ │ │ │ -that will be received and... │ │ │ │ │ -Definition mpifuture.hh:93 │ │ │ │ │ -Dune::MPIFuture::get_send_mpidata │ │ │ │ │ -auto get_send_mpidata() │ │ │ │ │ -Definition mpifuture.hh:177 │ │ │ │ │ -Dune::MPIFuture::get_mpidata │ │ │ │ │ -auto get_mpidata() │ │ │ │ │ -Definition mpifuture.hh:173 │ │ │ │ │ +Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::cols │ │ │ │ │ +constexpr size_type cols() const │ │ │ │ │ +number of columns │ │ │ │ │ +Definition densematrix.hh:715 │ │ │ │ │ +Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::rows │ │ │ │ │ +constexpr size_type rows() const │ │ │ │ │ +number of rows │ │ │ │ │ +Definition densematrix.hh:709 │ │ │ │ │ +Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::blocklevel │ │ │ │ │ +static constexpr int blocklevel │ │ │ │ │ +The number of block levels we contain. This is the leaf, that is, 1. │ │ │ │ │ +Definition densematrix.hh:178 │ │ │ │ │ +Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::row_type │ │ │ │ │ +Traits::row_type row_type │ │ │ │ │ +The type used to represent a row (must fulfill the Dune::DenseVector interface) │ │ │ │ │ +Definition densematrix.hh:169 │ │ │ │ │ +Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::size_type │ │ │ │ │ +Traits::size_type size_type │ │ │ │ │ +The type used for the index access and size operation. │ │ │ │ │ +Definition densematrix.hh:166 │ │ │ │ │ +Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::const_row_reference │ │ │ │ │ +Traits::const_row_reference const_row_reference │ │ │ │ │ +The type used to represent a reference to a constant row (usually const row_ │ │ │ │ │ +type &) │ │ │ │ │ +Definition densematrix.hh:175 │ │ │ │ │ +Dune::DenseMatrix<_ScalarMatrixView<_K_>_>::row_reference │ │ │ │ │ +Traits::row_reference row_reference │ │ │ │ │ +The type used to represent a reference to a row (usually row_type &) │ │ │ │ │ +Definition densematrix.hh:172 │ │ │ │ │ +Dune::AutonomousValueType::type │ │ │ │ │ +T type │ │ │ │ │ +Definition typetraits.hh:531 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00080.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: selection.hh File Reference │ │ │ │ +dune-common: rangeutilities.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,54 +65,127 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ - │ │ │ │ +Namespaces | │ │ │ │ +Functions | │ │ │ │ +Variables
│ │ │ │ +
rangeutilities.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Provides classes for selecting indices based on attribute flags. │ │ │ │ +

Utilities for reduction like operations on ranges. │ │ │ │ More...

│ │ │ │ -
#include <cstdint>
│ │ │ │ -#include <dune/common/iteratorfacades.hh>
│ │ │ │ -#include <dune/common/parallel/indexset.hh>
│ │ │ │ +
#include <algorithm>
│ │ │ │ +#include <utility>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <bitset>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │ +#include <dune/common/iteratorfacades.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::SelectionIterator< TS, TG, TL, N >
 A const iterator over an uncached selection. More...
class  Dune::IntegralRange< T >
 dynamic integer range for use in range-based for loops More...
 
class  Dune::UncachedSelection< TS, TG, TL, N >
 An uncached selection of indices. More...
class  Dune::StaticIntegralRange< T, to, from >
 static integer range for use in range-based for loops More...
 
class  Dune::Selection< TS, TG, TL, N >
 A cached selection of indices. More...
struct  Dune::ValueTransformationTag
 Tag to enable value based transformations in TransformedRangeView. More...
 
struct  Dune::IteratorTransformationTag
 Tag to enable iterator based transformations in TransformedRangeView. More...
 
class  Dune::TransformedRangeView< R, F, T >
 A range transforming the values of another range on-the-fly. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Functions

template<typename T , typename std::enable_if< IsIterable< T >::value, int >::type = 0>
T::value_type Dune::max_value (const T &v)
 compute the maximum value over a range
 
template<typename T , typename std::enable_if<!IsIterable< T >::value, int >::type = 0>
const T & Dune::max_value (const T &v)
 
template<typename T , typename std::enable_if< IsIterable< T >::value, int >::type = 0>
T::value_type Dune::min_value (const T &v)
 compute the minimum value over a range
 
template<typename T , typename std::enable_if<!IsIterable< T >::value, int >::type = 0>
const T & Dune::min_value (const T &v)
 
template<typename T , typename std::enable_if< IsIterable< T >::value, int >::type = 0>
bool Dune::any_true (const T &v)
 similar to std::bitset<N>::any() return true, if any entries is true
 
template<std::size_t N>
bool Dune::any_true (const std::bitset< N > &b)
 
template<typename T , typename std::enable_if< IsIterable< T >::value, int >::type = 0>
bool Dune::all_true (const T &v)
 similar to std::bitset<N>::all() return true, if any entries is true
 
template<std::size_t N>
bool Dune::all_true (const std::bitset< N > &b)
 
template<class T , class U , std::enable_if_t< std::is_same< std::decay_t< T >, std::decay_t< U > >::value, int > = 0, std::enable_if_t< std::is_integral< std::decay_t< T > >::value, int > = 0>
static IntegralRange< std::decay_t< T > > Dune::range (T &&from, U &&to) noexcept
 free standing function for setting up a range based for loop over an integer range for (auto i: range(0,10)) // 0,1,2,3,4,5,6,7,8,9 or for (auto i: range(-10,10)) // -10,-9,..,8,9 or for (auto i: range(10)) // 0,1,2,3,4,5,6,7,8,9
 
template<class T , std::enable_if_t< std::is_integral< std::decay_t< T > >::value, int > = 0>
static IntegralRange< std::decay_t< T > > Dune::range (T &&to) noexcept
 
template<class T , std::enable_if_t< std::is_enum< std::decay_t< T > >::value, int > = 0>
static IntegralRange< std::underlying_type_t< std::decay_t< T > > > Dune::range (T &&to) noexcept
 
template<class T , T to>
static StaticIntegralRange< T, to > Dune::range (std::integral_constant< T, to >) noexcept
 
template<class R , class F >
auto Dune::transformedRangeView (R &&range, F &&f)
 Create a TransformedRangeView.
 
template<class R , class F >
auto Dune::iteratorTransformedRangeView (R &&range, F &&f)
 Create a TransformedRangeView using an iterator transformation.
 
template<class Range >
auto Dune::sparseRange (Range &&range)
 Allow structured-binding for-loops for sparse iterators.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Variables

template<class T , T from, T to>
static StaticIntegralRange< T, to, from > Dune::range (std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
 
│ │ │ │

Detailed Description

│ │ │ │ -

Provides classes for selecting indices based on attribute flags.

│ │ │ │ -
Author
Markus Blatt
│ │ │ │ +

Utilities for reduction like operations on ranges.

│ │ │ │ +
Author
Christian Engwer
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,35 +1,130 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -selection.hh File Reference │ │ │ │ │ -Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ -Provides classes for selecting indices based on attribute flags. More... │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Functions | Variables │ │ │ │ │ +rangeutilities.hh File Reference │ │ │ │ │ +Utilities for reduction like operations on ranges. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::SelectionIterator<_TS,_TG,_TL,_N_> │ │ │ │ │ -  A const iterator over an uncached selection. More... │ │ │ │ │ + class   Dune::IntegralRange<_T_> │ │ │ │ │ +  dynamic integer range for use in range-based for loops More... │ │ │ │ │   │ │ │ │ │ -class   Dune::UncachedSelection<_TS,_TG,_TL,_N_> │ │ │ │ │ -  An uncached selection of indices. More... │ │ │ │ │ + class   Dune::StaticIntegralRange<_T,_to,_from_> │ │ │ │ │ +  static integer range for use in range-based for loops More... │ │ │ │ │   │ │ │ │ │ -class   Dune::Selection<_TS,_TG,_TL,_N_> │ │ │ │ │ -  A cached selection of indices. More... │ │ │ │ │ +struct   Dune::ValueTransformationTag │ │ │ │ │ +  Tag to enable value based transformations in TransformedRangeView. │ │ │ │ │ + More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::IteratorTransformationTag │ │ │ │ │ +  Tag to enable iterator based transformations in TransformedRangeView. │ │ │ │ │ + More... │ │ │ │ │ +  │ │ │ │ │ + class   Dune::TransformedRangeView<_R,_F,_T_> │ │ │ │ │ +  A range transforming the values of another range on-the-fly. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ +Functions │ │ │ │ │ +template::value, int >:: │ │ │ │ │ +type = 0> │ │ │ │ │ + T::value_type  Dune::max_value (const T &v) │ │ │ │ │ +  compute the maximum value over a range │ │ │ │ │ +  │ │ │ │ │ +template::value, int >:: │ │ │ │ │ +type = 0> │ │ │ │ │ + const T &  Dune::max_value (const T &v) │ │ │ │ │ +  │ │ │ │ │ +template::value, int >:: │ │ │ │ │ +type = 0> │ │ │ │ │ + T::value_type  Dune::min_value (const T &v) │ │ │ │ │ +  compute the minimum value over a range │ │ │ │ │ +  │ │ │ │ │ +template::value, int >:: │ │ │ │ │ +type = 0> │ │ │ │ │ + const T &  Dune::min_value (const T &v) │ │ │ │ │ +  │ │ │ │ │ +template::value, int >:: │ │ │ │ │ +type = 0> │ │ │ │ │ + bool  Dune::any_true (const T &v) │ │ │ │ │ +  similar to std::bitset::any() return │ │ │ │ │ + true, if any entries is true │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool  Dune::any_true (const std::bitset< N > &b) │ │ │ │ │ +  │ │ │ │ │ +template::value, int >:: │ │ │ │ │ +type = 0> │ │ │ │ │ + bool  Dune::all_true (const T &v) │ │ │ │ │ +  similar to std::bitset::all() return │ │ │ │ │ + true, if any entries is true │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool  Dune::all_true (const std::bitset< N > &b) │ │ │ │ │ +  │ │ │ │ │ +template, │ │ │ │ │ +std::decay_t< U > >::value, int > = 0, std::enable_if_t< std::is_integral< │ │ │ │ │ +std::decay_t< T > >::value, int > = 0> │ │ │ │ │ +static IntegralRange< std::decay_t< │ │ │ │ │ + T > >  Dune::range (T &&from, U &&to) noexcept │ │ │ │ │ + free standing function for setting up a │ │ │ │ │ + range based for loop over an integer range │ │ │ │ │ +  for (auto i: range(0,10)) / │ │ │ │ │ + / 0,1,2,3,4,5,6,7,8,9 or for (auto i: range │ │ │ │ │ + (-10,10)) // -10,-9,..,8,9 or for (auto i: │ │ │ │ │ + range(10)) // 0,1,2,3,4,5,6,7,8,9 │ │ │ │ │ +  │ │ │ │ │ +template >:: │ │ │ │ │ +value, int > = 0> │ │ │ │ │ +static IntegralRange< std::decay_t< │ │ │ │ │ + T > >  Dune::range (T &&to) noexcept │ │ │ │ │ +  │ │ │ │ │ +template >::value, │ │ │ │ │ +int > = 0> │ │ │ │ │ + static IntegralRange< std:: │ │ │ │ │ + underlying_type_t< std::decay_t< T │ │ │ │ │ + > > >  Dune::range (T &&to) noexcept │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + static StaticIntegralRange< T, to Dune::range (std::integral_constant< T, to │ │ │ │ │ + >  >) noexcept │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::transformedRangeView (R &&range, F │ │ │ │ │ + &&f) │ │ │ │ │ +  Create a TransformedRangeView. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::iteratorTransformedRangeView (R │ │ │ │ │ + &&range, F &&f) │ │ │ │ │ +  Create a TransformedRangeView using an │ │ │ │ │ + iterator transformation. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::sparseRange (Range &&range) │ │ │ │ │ +  Allow structured-binding for-loops for │ │ │ │ │ + sparse iterators. │ │ │ │ │ +  │ │ │ │ │ +Variables │ │ │ │ │ +template │ │ │ │ │ +static StaticIntegralRange< T, to, from >  Dune::range (std::integral_constant< │ │ │ │ │ + T, from >, std::integral_constant< │ │ │ │ │ + T, to >) noexcept │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Provides classes for selecting indices based on attribute flags. │ │ │ │ │ +Utilities for reduction like operations on ranges. │ │ │ │ │ Author │ │ │ │ │ - Markus Blatt │ │ │ │ │ + Christian Engwer │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00080_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: selection.hh Source File │ │ │ │ +dune-common: rangeutilities.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,324 +70,615 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
selection.hh
│ │ │ │ +
rangeutilities.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PARALLEL_SELECTION_HH
│ │ │ │ -
6#define DUNE_COMMON_PARALLEL_SELECTION_HH
│ │ │ │ +
5#ifndef DUNE_COMMON_RANGE_UTILITIES_HH
│ │ │ │ +
6#define DUNE_COMMON_RANGE_UTILITIES_HH
│ │ │ │
7
│ │ │ │ -
8#include <cstdint>
│ │ │ │ -
9
│ │ │ │ - │ │ │ │ - │ │ │ │ +
8#include <algorithm>
│ │ │ │ +
9#include <utility>
│ │ │ │ +
10#include <type_traits>
│ │ │ │ +
11#include <bitset>
│ │ │ │
12
│ │ │ │ -
13namespace Dune
│ │ │ │ -
14{
│ │ │ │ -
29 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
31 {
│ │ │ │ -
32 public:
│ │ │ │ -
41 typedef TS AttributeSet;
│ │ │ │ -
42
│ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ +
15
│ │ │ │ +
23namespace Dune
│ │ │ │ +
24{
│ │ │ │ +
25
│ │ │ │ +
36 template <typename T,
│ │ │ │ +
37 typename std::enable_if<IsIterable<T>::value, int>::type = 0>
│ │ │ │ +
38 typename T::value_type
│ │ │ │ +
│ │ │ │ +
39 max_value(const T & v) {
│ │ │ │ +
40 using std::max_element;
│ │ │ │ +
41 return *max_element(v.begin(), v.end());
│ │ │ │ +
42 }
│ │ │ │ +
│ │ │ │ +
43
│ │ │ │ +
44 template <typename T,
│ │ │ │ +
45 typename std::enable_if<!IsIterable<T>::value, int>::type = 0>
│ │ │ │ +
46 const T & max_value(const T & v) { return v; }
│ │ │ │
47
│ │ │ │ -
48 //typedef typename ParallelIndexSet::const_iterator ParallelIndexSetIterator;
│ │ │ │ -
49
│ │ │ │ -
50 typedef ConstArrayListIterator<IndexPair<TG,TL>, N, std::allocator<Dune::IndexPair<TG,TL> > > ParallelIndexSetIterator;
│ │ │ │ +
53 template <typename T,
│ │ │ │ +
54 typename std::enable_if<IsIterable<T>::value, int>::type = 0>
│ │ │ │ +
55 typename T::value_type
│ │ │ │
│ │ │ │ - │ │ │ │ -
57 : iter_(iter), end_(end)
│ │ │ │ -
58 {
│ │ │ │ -
59 // Step to the first valid entry
│ │ │ │ -
60 while(iter_!=end_ && !AttributeSet::contains(iter_->local().attribute()))
│ │ │ │ -
61 ++iter_;
│ │ │ │ -
62 }
│ │ │ │ -
│ │ │ │ -
63
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
65 {
│ │ │ │ -
66 assert(iter_!=end_);
│ │ │ │ -
67 for(++iter_; iter_!=end_; ++iter_)
│ │ │ │ -
68 if(AttributeSet::contains(iter_->local().attribute()))
│ │ │ │ -
69 break;
│ │ │ │ -
70 }
│ │ │ │ -
│ │ │ │ -
71
│ │ │ │ -
72
│ │ │ │ -
│ │ │ │ -
73 uint32_t operator*() const
│ │ │ │ -
74 {
│ │ │ │ -
75 return iter_->local().local();
│ │ │ │ -
76 }
│ │ │ │ -
│ │ │ │ -
77
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
79 {
│ │ │ │ -
80 return iter_ == other.iter_;
│ │ │ │ -
81 }
│ │ │ │ -
│ │ │ │ +
56 min_value(const T & v) {
│ │ │ │ +
57 using std::min_element;
│ │ │ │ +
58 return *min_element(v.begin(), v.end());
│ │ │ │ +
59 }
│ │ │ │ +
│ │ │ │ +
60
│ │ │ │ +
61 template <typename T,
│ │ │ │ +
62 typename std::enable_if<!IsIterable<T>::value, int>::type = 0>
│ │ │ │ +
63 const T & min_value(const T & v) { return v; }
│ │ │ │ +
64
│ │ │ │ +
70 template <typename T,
│ │ │ │ +
71 typename std::enable_if<IsIterable<T>::value, int>::type = 0>
│ │ │ │ +
│ │ │ │ +
72 bool any_true(const T & v) {
│ │ │ │ +
73 bool b = false;
│ │ │ │ +
74 for (const auto & e : v)
│ │ │ │ +
75 b = b or bool(e);
│ │ │ │ +
76 return b;
│ │ │ │ +
77 }
│ │ │ │ +
│ │ │ │ +
78
│ │ │ │ +
79 template <typename T,
│ │ │ │ +
80 typename std::enable_if<!IsIterable<T>::value, int>::type = 0>
│ │ │ │ +
81 bool any_true(const T & v) { return v; }
│ │ │ │
82
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
84 {
│ │ │ │ -
85 return iter_ != other.iter_;
│ │ │ │ -
86 }
│ │ │ │ -
│ │ │ │ -
87
│ │ │ │ -
88 private:
│ │ │ │ - │ │ │ │ -
90 const ParallelIndexSetIterator end_;
│ │ │ │ -
91 };
│ │ │ │ -
│ │ │ │ -
92
│ │ │ │ -
93
│ │ │ │ -
97 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
99 {
│ │ │ │ -
100 public:
│ │ │ │ -
109 typedef TS AttributeSet;
│ │ │ │ -
110
│ │ │ │ -
114 typedef TG GlobalIndex;
│ │ │ │ -
115
│ │ │ │ -
122 typedef TL LocalIndex;
│ │ │ │ -
123
│ │ │ │ - │ │ │ │ -
128
│ │ │ │ - │ │ │ │ +
83 template<std::size_t N>
│ │ │ │ +
│ │ │ │ +
84 bool any_true(const std::bitset<N> & b)
│ │ │ │ +
85 {
│ │ │ │ +
86 return b.any();
│ │ │ │ +
87 }
│ │ │ │ +
│ │ │ │ +
88
│ │ │ │ +
94 template <typename T,
│ │ │ │ +
95 typename std::enable_if<IsIterable<T>::value, int>::type = 0>
│ │ │ │ +
│ │ │ │ +
96 bool all_true(const T & v) {
│ │ │ │ +
97 bool b = true;
│ │ │ │ +
98 for (const auto & e : v)
│ │ │ │ +
99 b = b and bool(e);
│ │ │ │ +
100 return b;
│ │ │ │ +
101 }
│ │ │ │ +
│ │ │ │ +
102
│ │ │ │ +
103 template <typename T,
│ │ │ │ +
104 typename std::enable_if<!IsIterable<T>::value, int>::type = 0>
│ │ │ │ +
105 bool all_true(const T & v) { return v; }
│ │ │ │ +
106
│ │ │ │ +
107 template<std::size_t N>
│ │ │ │ +
│ │ │ │ +
108 bool all_true(const std::bitset<N> & b)
│ │ │ │ +
109 {
│ │ │ │ +
110 return b.all();
│ │ │ │ +
111 }
│ │ │ │ +
│ │ │ │ +
112
│ │ │ │ +
113
│ │ │ │ +
114
│ │ │ │ +
115 namespace Impl
│ │ │ │ +
116 {
│ │ │ │ +
117
│ │ │ │ +
118 template <class T>
│ │ │ │ +
119 class IntegralRangeIterator
│ │ │ │ +
120 {
│ │ │ │ +
121 public:
│ │ │ │ +
122 typedef std::random_access_iterator_tag iterator_category;
│ │ │ │ +
123 typedef T value_type;
│ │ │ │ +
124 typedef std::make_signed_t<T> difference_type;
│ │ │ │ +
125 typedef const T *pointer;
│ │ │ │ +
126 typedef T reference;
│ │ │ │ +
127
│ │ │ │ +
128 constexpr IntegralRangeIterator() noexcept : value_(0) {}
│ │ │ │ +
129 constexpr explicit IntegralRangeIterator(value_type value) noexcept : value_(value) {}
│ │ │ │ +
130
│ │ │ │ +
131 pointer operator->() const noexcept { return &value_; }
│ │ │ │ +
132 constexpr reference operator*() const noexcept { return value_; }
│ │ │ │
133
│ │ │ │ - │ │ │ │ +
134 constexpr reference operator[]( difference_type n ) const noexcept { return (value_ + n); }
│ │ │ │ +
135
│ │ │ │ +
136 constexpr bool operator==(const IntegralRangeIterator & other) const noexcept { return (value_ == other.value_); }
│ │ │ │ +
137 constexpr bool operator!=(const IntegralRangeIterator & other) const noexcept { return (value_ != other.value_); }
│ │ │ │
138
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
140 : indexSet_()
│ │ │ │ -
141 {}
│ │ │ │ -
│ │ │ │ -
142
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
144 : indexSet_(&indexset)
│ │ │ │ -
145 {}
│ │ │ │ -
│ │ │ │ -
150 void setIndexSet(const ParallelIndexSet& indexset);
│ │ │ │ -
151
│ │ │ │ -
155 //const ParallelIndexSet& indexSet() const;
│ │ │ │ +
139 constexpr bool operator<(const IntegralRangeIterator & other) const noexcept { return (value_ <= other.value_); }
│ │ │ │ +
140 constexpr bool operator<=(const IntegralRangeIterator & other) const noexcept { return (value_ <= other.value_); }
│ │ │ │ +
141 constexpr bool operator>(const IntegralRangeIterator & other) const noexcept { return (value_ >= other.value_); }
│ │ │ │ +
142 constexpr bool operator>=(const IntegralRangeIterator & other) const noexcept { return (value_ >= other.value_); }
│ │ │ │ +
143
│ │ │ │ +
144 IntegralRangeIterator& operator++() noexcept { ++value_; return *this; }
│ │ │ │ +
145 IntegralRangeIterator operator++(int) noexcept { IntegralRangeIterator copy( *this ); ++(*this); return copy; }
│ │ │ │ +
146
│ │ │ │ +
147 IntegralRangeIterator& operator--() noexcept { --value_; return *this; }
│ │ │ │ +
148 IntegralRangeIterator operator--(int) noexcept { IntegralRangeIterator copy( *this ); --(*this); return copy; }
│ │ │ │ +
149
│ │ │ │ +
150 IntegralRangeIterator& operator+=(difference_type n) noexcept { value_ += n; return *this; }
│ │ │ │ +
151 IntegralRangeIterator& operator-=(difference_type n) noexcept { value_ -= n; return *this; }
│ │ │ │ +
152
│ │ │ │ +
153 friend constexpr IntegralRangeIterator operator+(const IntegralRangeIterator &a, difference_type n) noexcept { return IntegralRangeIterator(a.value_ + n); }
│ │ │ │ +
154 friend constexpr IntegralRangeIterator operator+(difference_type n, const IntegralRangeIterator &a) noexcept { return IntegralRangeIterator(a.value_ + n); }
│ │ │ │ +
155 friend constexpr IntegralRangeIterator operator-(const IntegralRangeIterator &a, difference_type n) noexcept { return IntegralRangeIterator(a.value_ - n); }
│ │ │ │
156
│ │ │ │ -
161 const_iterator begin() const;
│ │ │ │ +
157 constexpr difference_type operator-(const IntegralRangeIterator &other) const noexcept { return (static_cast<difference_type>(value_) - static_cast<difference_type>(other.value_)); }
│ │ │ │ +
158
│ │ │ │ +
159 private:
│ │ │ │ +
160 value_type value_;
│ │ │ │ +
161 };
│ │ │ │
162
│ │ │ │ -
167 const_iterator end() const;
│ │ │ │ -
168
│ │ │ │ -
169
│ │ │ │ -
170 private:
│ │ │ │ -
171 const ParallelIndexSet* indexSet_;
│ │ │ │ -
172
│ │ │ │ -
173 };
│ │ │ │ -
│ │ │ │ -
174
│ │ │ │ -
178 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
180 {
│ │ │ │ -
181 public:
│ │ │ │ -
190 typedef TS AttributeSet;
│ │ │ │ -
191
│ │ │ │ -
195 typedef TG GlobalIndex;
│ │ │ │ -
196
│ │ │ │ -
203 typedef TL LocalIndex;
│ │ │ │ -
204
│ │ │ │ - │ │ │ │ -
209
│ │ │ │ -
213 typedef uint32_t* iterator;
│ │ │ │ -
214
│ │ │ │ -
218 typedef uint32_t* const_iterator;
│ │ │ │ -
219
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
221 : selected_()
│ │ │ │ -
222 {}
│ │ │ │ -
│ │ │ │ -
223
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
225 : selected_(), size_(0), built_(false)
│ │ │ │ -
226 {
│ │ │ │ -
227 setIndexSet(indexset);
│ │ │ │ -
228 }
│ │ │ │ -
│ │ │ │ -
229
│ │ │ │ -
230 ~Selection();
│ │ │ │ -
231
│ │ │ │ -
236 void setIndexSet(const ParallelIndexSet& indexset);
│ │ │ │ -
237
│ │ │ │ -
241 void free();
│ │ │ │ -
242
│ │ │ │ -
246 //IndexSet indexSet() const;
│ │ │ │ +
163 } // namespace Impl
│ │ │ │ +
164
│ │ │ │ +
165
│ │ │ │ +
166
│ │ │ │ +
175 template <class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
177 {
│ │ │ │ +
178 public:
│ │ │ │ +
180 typedef T value_type;
│ │ │ │ +
182 typedef Impl::IntegralRangeIterator<T> iterator;
│ │ │ │ +
184 typedef std::make_unsigned_t<T> size_type;
│ │ │ │ +
185
│ │ │ │ +
187 constexpr IntegralRange(value_type from, value_type to) noexcept : from_(from), to_(to) {}
│ │ │ │ +
189 constexpr explicit IntegralRange(value_type to) noexcept : from_(0), to_(to) {}
│ │ │ │ +
191 constexpr IntegralRange(std::pair<value_type, value_type> range) noexcept : from_(range.first), to_(range.second) {}
│ │ │ │ +
192
│ │ │ │ +
194 constexpr iterator begin() const noexcept { return iterator(from_); }
│ │ │ │ +
196 constexpr iterator end() const noexcept { return iterator(to_); }
│ │ │ │ +
197
│ │ │ │ +
199 constexpr value_type operator[](const value_type &i) const noexcept { return (from_ + i); }
│ │ │ │ +
200
│ │ │ │ +
202 constexpr bool empty() const noexcept { return (from_ == to_); }
│ │ │ │ +
204 constexpr size_type size() const noexcept { return (static_cast<size_type>(to_) - static_cast<size_type>(from_)); }
│ │ │ │ +
205
│ │ │ │ +
207 constexpr bool contains(value_type index) const noexcept { return from_ <= index && index < to_; }
│ │ │ │ +
208
│ │ │ │ +
209 private:
│ │ │ │ +
210 value_type from_, to_;
│ │ │ │ +
211 };
│ │ │ │ +
│ │ │ │ +
212
│ │ │ │ +
213
│ │ │ │ +
228 template <class T, T to, T from = 0>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
230 {
│ │ │ │ +
231 template <T ofs, T... i>
│ │ │ │ +
232 static std::integer_sequence<T, (i+ofs)...> shift_integer_sequence(std::integer_sequence<T, i...>);
│ │ │ │ +
233
│ │ │ │ +
234 public:
│ │ │ │ +
236 typedef T value_type;
│ │ │ │ +
238 typedef Impl::IntegralRangeIterator<T> iterator;
│ │ │ │ +
240 typedef std::make_unsigned_t<T> size_type;
│ │ │ │ +
241
│ │ │ │ +
243 typedef decltype(shift_integer_sequence<from>(std::make_integer_sequence<T, to-from>())) integer_sequence;
│ │ │ │ +
244
│ │ │ │ +
246 constexpr StaticIntegralRange() noexcept = default;
│ │ │ │
247
│ │ │ │ -
252 const_iterator begin() const;
│ │ │ │ -
253
│ │ │ │ -
258 const_iterator end() const;
│ │ │ │ -
259
│ │ │ │ +
249 constexpr operator IntegralRange<T>() const noexcept { return {from, to}; }
│ │ │ │ +
251 constexpr operator integer_sequence() const noexcept { return {}; }
│ │ │ │ +
252
│ │ │ │ +
254 static constexpr integer_sequence to_integer_sequence() noexcept { return {}; }
│ │ │ │ +
255
│ │ │ │ +
257 static constexpr iterator begin() noexcept { return iterator(from); }
│ │ │ │ +
259 static constexpr iterator end() noexcept { return iterator(to); }
│ │ │ │
260
│ │ │ │ -
261 private:
│ │ │ │ -
262 uint32_t* selected_;
│ │ │ │ -
263 size_t size_;
│ │ │ │ -
264 bool built_;
│ │ │ │ -
265
│ │ │ │ -
266 };
│ │ │ │ -
│ │ │ │ -
267
│ │ │ │ -
268 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
270 {
│ │ │ │ -
271 if(built_)
│ │ │ │ -
272 free();
│ │ │ │ -
273
│ │ │ │ -
274 // Count the number of entries the selection has to hold
│ │ │ │ - │ │ │ │ -
276 const const_iterator end = indexset.end();
│ │ │ │ -
277 int entries = 0;
│ │ │ │ -
278
│ │ │ │ -
279 for(const_iterator index = indexset.begin(); index != end; ++index)
│ │ │ │ -
280 if(AttributeSet::contains(index->local().attribute()))
│ │ │ │ -
281 ++entries;
│ │ │ │ -
282
│ │ │ │ -
283 selected_ = new uint32_t[entries];
│ │ │ │ -
284 built_ = true;
│ │ │ │ -
285
│ │ │ │ -
286 entries = 0;
│ │ │ │ -
287 for(const_iterator index = indexset.begin(); index != end; ++index)
│ │ │ │ -
288 if(AttributeSet::contains(index->local().attribute()))
│ │ │ │ -
289 selected_[entries++]= index->local().local();
│ │ │ │ -
290
│ │ │ │ -
291 size_=entries;
│ │ │ │ -
292 built_=true;
│ │ │ │ -
293 }
│ │ │ │ -
│ │ │ │ -
294
│ │ │ │ -
295 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
297 {
│ │ │ │ -
298 return selected_;
│ │ │ │ -
299 }
│ │ │ │ -
│ │ │ │ -
300
│ │ │ │ -
301 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
303 {
│ │ │ │ -
304 return selected_+size_;
│ │ │ │ -
305 }
│ │ │ │ -
│ │ │ │ -
306
│ │ │ │ -
307 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
309 {
│ │ │ │ -
310 delete[] selected_;
│ │ │ │ -
311 size_=0;
│ │ │ │ -
312 built_=false;
│ │ │ │ -
313 }
│ │ │ │ -
│ │ │ │ -
314
│ │ │ │ -
315 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
317 {
│ │ │ │ -
318 if(built_)
│ │ │ │ -
319 free();
│ │ │ │ -
320 }
│ │ │ │ -
│ │ │ │ -
321
│ │ │ │ -
322 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
324 {
│ │ │ │ -
325 return SelectionIterator<TS,TG,TL,N>(indexSet_->begin(),
│ │ │ │ -
326 indexSet_->end());
│ │ │ │ -
327 }
│ │ │ │ -
│ │ │ │ -
328
│ │ │ │ -
329 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
331 {
│ │ │ │ -
332 return SelectionIterator<TS,TG,TL,N>(indexSet_->end(),
│ │ │ │ -
333 indexSet_->end());
│ │ │ │ -
334 }
│ │ │ │ -
│ │ │ │ -
335 template<typename TS, typename TG, typename TL, int N>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
337 {
│ │ │ │ -
338 indexSet_ = &indexset;
│ │ │ │ -
339 }
│ │ │ │ -
│ │ │ │ -
340
│ │ │ │ -
344}
│ │ │ │ -
345#endif // DUNE_COMMON_PARALLEL_SELECTION_HH
│ │ │ │ -
Provides a map between global and local indices.
│ │ │ │ -
This file implements iterator facade classes for writing stl conformant iterators.
│ │ │ │ -
const_iterator end() const
Get an iterator over the selected indices.
Definition selection.hh:330
│ │ │ │ -
void setIndexSet(const ParallelIndexSet &indexset)
Set the index set of the selection.
Definition selection.hh:269
│ │ │ │ -
void setIndexSet(const ParallelIndexSet &indexset)
Set the index set of the selection.
Definition selection.hh:336
│ │ │ │ -
iterator begin()
Get an iterator over the indices positioned at the first index.
│ │ │ │ -
iterator end()
Get an iterator over the indices positioned after the last index.
│ │ │ │ -
const_iterator end() const
Get an iterator over the selected indices.
Definition selection.hh:302
│ │ │ │ -
const_iterator begin() const
Get the index set we are a selection for.
Definition selection.hh:296
│ │ │ │ -
void free()
Free allocated memory.
Definition selection.hh:308
│ │ │ │ -
const_iterator begin() const
Get the index set we are a selection for.
Definition selection.hh:323
│ │ │ │ -
~Selection()
Definition selection.hh:316
│ │ │ │ +
262 template <class U, U i>
│ │ │ │ +
│ │ │ │ +
263 constexpr auto operator[](const std::integral_constant<U, i> &) const noexcept
│ │ │ │ +
264 -> std::integral_constant<value_type, from + static_cast<value_type>(i)>
│ │ │ │ +
265 {
│ │ │ │ +
266 return {};
│ │ │ │ +
267 }
│ │ │ │ +
│ │ │ │ +
268
│ │ │ │ +
270 constexpr value_type operator[](const size_type &i) const noexcept { return (from + static_cast<value_type>(i)); }
│ │ │ │ +
271
│ │ │ │ +
273 static constexpr std::integral_constant<bool, from == to> empty() noexcept { return {}; }
│ │ │ │ +
275 static constexpr std::integral_constant<size_type, static_cast<size_type>(to) - static_cast<size_type>(from) > size() noexcept { return {}; }
│ │ │ │ +
276
│ │ │ │ +
278 static constexpr bool contains(value_type index) noexcept { return from <= index && index < to; }
│ │ │ │ +
279
│ │ │ │ +
280 };
│ │ │ │ +
│ │ │ │ +
281
│ │ │ │ +
291 template<class T, class U,
│ │ │ │ +
292 std::enable_if_t<std::is_same<std::decay_t<T>, std::decay_t<U>>::value, int> = 0,
│ │ │ │ +
293 std::enable_if_t<std::is_integral<std::decay_t<T>>::value, int> = 0>
│ │ │ │ +
│ │ │ │ +
294 inline static IntegralRange<std::decay_t<T>> range(T &&from, U &&to) noexcept
│ │ │ │ +
295 {
│ │ │ │ +
296 return IntegralRange<std::decay_t<T>>(std::forward<T>(from), std::forward<U>(to));
│ │ │ │ +
297 }
│ │ │ │ +
│ │ │ │ +
298
│ │ │ │ +
299 template<class T, std::enable_if_t<std::is_integral<std::decay_t<T>>::value, int> = 0>
│ │ │ │ +
│ │ │ │ +
300 inline static IntegralRange<std::decay_t<T>> range(T &&to) noexcept
│ │ │ │ +
301 {
│ │ │ │ +
302 return IntegralRange<std::decay_t<T>>(std::forward<T>(to));
│ │ │ │ +
303 }
│ │ │ │ +
│ │ │ │ +
304
│ │ │ │ +
305 template<class T, std::enable_if_t<std::is_enum<std::decay_t<T>>::value, int> = 0>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
307 {
│ │ │ │ +
308 return IntegralRange<std::underlying_type_t<std::decay_t<T>>>(std::forward<T>(to));
│ │ │ │ +
309 }
│ │ │ │ +
│ │ │ │ +
310
│ │ │ │ +
311 template<class T, T from, T to>
│ │ │ │ +
│ │ │ │ +
312 inline static StaticIntegralRange<T, to, from> range(std::integral_constant<T, from>, std::integral_constant<T, to>) noexcept
│ │ │ │ +
313 {
│ │ │ │ +
314 return {};
│ │ │ │ +
315 }
│ │ │ │ +
│ │ │ │ +
316
│ │ │ │ +
317 template<class T, T to>
│ │ │ │ +
│ │ │ │ +
318 inline static StaticIntegralRange<T, to> range(std::integral_constant<T, to>) noexcept
│ │ │ │ +
319 {
│ │ │ │ +
320 return {};
│ │ │ │ +
321 }
│ │ │ │ +
│ │ │ │ +
322
│ │ │ │ +
323
│ │ │ │ +
324
│ │ │ │ + │ │ │ │ +
329
│ │ │ │ + │ │ │ │ +
334
│ │ │ │ +
335 namespace Impl
│ │ │ │ +
336 {
│ │ │ │ +
337
│ │ │ │ +
338
│ │ │ │ +
339
│ │ │ │ +
340 // An iterator transforming a wrapped iterator using
│ │ │ │ +
341 // an unary function. It inherits the iterator-category
│ │ │ │ +
342 // of the underlying iterator.
│ │ │ │ +
343 //
│ │ │ │ +
344 // \tparam I Type of the underlying iterator
│ │ │ │ +
345 // \tparam F Type of transformation function that can either be applied directly or after dereferencing
│ │ │ │ +
346 // \tparam TT Type of transformation (ValueTransformationTag or IteratorTransformationTag)
│ │ │ │ +
347 // \tparam C An iterator category tag, defaults to the one of I
│ │ │ │ +
348 template <class I, class F, class TT, class C = typename std::iterator_traits<I>::iterator_category>
│ │ │ │ +
349 class TransformedRangeIterator;
│ │ │ │ +
350
│ │ │ │ +
351 template<class I, class F, class TT, class C>
│ │ │ │ +
352 struct TransformationRangeIteratorTraits
│ │ │ │ +
353 {
│ │ │ │ +
354 template<class FF>
│ │ │ │ +
355 static decltype(auto) transform(FF&& f, const I& it) {
│ │ │ │ +
356 if constexpr (std::is_same_v<TT,IteratorTransformationTag>)
│ │ │ │ +
357 {
│ │ │ │ +
358 if constexpr (Dune::IsCallable<FF(const I&)>::value)
│ │ │ │ +
359 return f(it);
│ │ │ │ +
360 else
│ │ │ │ +
361 return (*f)(it);
│ │ │ │ +
362 }
│ │ │ │ +
363 else
│ │ │ │ +
364 {
│ │ │ │ +
365 if constexpr (Dune::IsCallable<FF(decltype(*it))>::value)
│ │ │ │ +
366 return f(*it);
│ │ │ │ +
367 else
│ │ │ │ +
368 return (*f)(*it);
│ │ │ │ +
369 }
│ │ │ │ +
370 }
│ │ │ │ +
371
│ │ │ │ +
372 using reference = decltype(transform(std::declval<F>(), std::declval<I>()));
│ │ │ │ +
373 using value_type = Dune::AutonomousValue<reference>;
│ │ │ │ +
374 using pointer = std::conditional_t<std::is_lvalue_reference_v<reference>, value_type*, ProxyArrowResult<reference>>;
│ │ │ │ +
375 using difference_type = typename std::iterator_traits<I>::difference_type;
│ │ │ │ +
376 using Facade = Dune::IteratorFacade<TransformedRangeIterator<I,F,TT,C>, C, value_type, reference, pointer, difference_type>;
│ │ │ │ +
377 };
│ │ │ │ +
378
│ │ │ │ +
379
│ │ │ │ +
380 template <class I, class F, class TT, class C>
│ │ │ │ +
381 class TransformedRangeIterator :
│ │ │ │ +
382 public TransformationRangeIteratorTraits<I,F, TT, C>::Facade
│ │ │ │ +
383 {
│ │ │ │ +
384 using Traits = TransformationRangeIteratorTraits<I,F, TT, C>;
│ │ │ │ +
385 using Facade = typename Traits::Facade;
│ │ │ │ +
386
│ │ │ │ +
387 static constexpr bool isBidirectional = std::is_convertible_v<C, std::bidirectional_iterator_tag>;
│ │ │ │ +
388 static constexpr bool isRandomAccess = std::is_convertible_v<C, std::random_access_iterator_tag>;
│ │ │ │ +
389
│ │ │ │ +
390 public:
│ │ │ │ +
391
│ │ │ │ +
392 using Function = F;
│ │ │ │ +
393 using reference = typename Facade::reference;
│ │ │ │ +
394 using difference_type = typename Facade::difference_type;
│ │ │ │ +
395
│ │ │ │ +
396 template<class II, class FF>
│ │ │ │ +
397 constexpr TransformedRangeIterator(II&& it, FF&& f) noexcept :
│ │ │ │ +
398 it_(std::forward<II>(it)),
│ │ │ │ +
399 f_(std::forward<FF>(f))
│ │ │ │ +
400 {}
│ │ │ │ +
401
│ │ │ │ +
402 template<class II,
│ │ │ │ +
403 disableCopyMove<TransformedRangeIterator,II> =0,
│ │ │ │ +
404 std::enable_if_t<std::is_convertible_v<II, I> and std::is_default_constructible_v<F>, int> =0>
│ │ │ │ +
405 constexpr TransformedRangeIterator(II&& it) noexcept :
│ │ │ │ +
406 it_(std::forward<II>(it)),
│ │ │ │ +
407 f_()
│ │ │ │ +
408 {}
│ │ │ │ +
409
│ │ │ │ +
410 template<class FF,
│ │ │ │ +
411 disableCopyMove<TransformedRangeIterator,FF> =0,
│ │ │ │ +
412 std::enable_if_t<std::is_convertible_v<FF, F> and std::is_default_constructible_v<I>, int> =0>
│ │ │ │ +
413 constexpr TransformedRangeIterator(FF&& f) noexcept :
│ │ │ │ +
414 it_(),
│ │ │ │ +
415 f_(std::forward<FF>(f))
│ │ │ │ +
416 {}
│ │ │ │ +
417
│ │ │ │ +
418 // Explicitly initialize members. Using a plain
│ │ │ │ +
419 //
│ │ │ │ +
420 // constexpr TransformedRangeIterator() noexcept {}
│ │ │ │ +
421 //
│ │ │ │ +
422 // would default-initialize the members while
│ │ │ │ +
423 //
│ │ │ │ +
424 // constexpr TransformedRangeIterator() noexcept : it_(), f_() {}
│ │ │ │ +
425 //
│ │ │ │ +
426 // leads to value-initialization. This is a case where
│ │ │ │ +
427 // both are really different. If it_ is a raw pointer (i.e. POD)
│ │ │ │ +
428 // then default-initialization leaves it uninitialized while
│ │ │ │ +
429 // value-initialization zero-initializes it.
│ │ │ │ +
430 constexpr TransformedRangeIterator() noexcept :
│ │ │ │ +
431 it_(),
│ │ │ │ +
432 f_()
│ │ │ │ +
433 {}
│ │ │ │ +
434
│ │ │ │ +
435 // Dereferencing returns a value created by the function
│ │ │ │ +
436 constexpr reference operator*() const noexcept {
│ │ │ │ +
437 return Traits::transform(f_, it_);
│ │ │ │ +
438 }
│ │ │ │ +
439
│ │ │ │ +
440 protected:
│ │ │ │ +
441
│ │ │ │ + │ │ │ │ +
443
│ │ │ │ +
444 // Export base iterator, such that equalilty comparison,
│ │ │ │ +
445 // differences, and inequality comparisons are automatically
│ │ │ │ +
446 // forwarded to the base iterator by the facade.
│ │ │ │ +
447 const I& baseIterator() const noexcept {
│ │ │ │ +
448 return it_;
│ │ │ │ +
449 }
│ │ │ │ +
450
│ │ │ │ +
451 I& baseIterator() noexcept {
│ │ │ │ +
452 return it_;
│ │ │ │ +
453 }
│ │ │ │ +
454
│ │ │ │ +
455 I it_;
│ │ │ │ +
456 Function f_;
│ │ │ │ +
457 };
│ │ │ │ +
458
│ │ │ │ +
459 } // namespace Impl
│ │ │ │ +
460
│ │ │ │ +
461
│ │ │ │ +
462
│ │ │ │ +
499 template <class R, class F, class T=ValueTransformationTag>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
501 {
│ │ │ │ +
502 using RawConstIterator = std::decay_t<decltype(std::declval<const R>().begin())>;
│ │ │ │ +
503 using RawIterator = std::decay_t<decltype(std::declval<R>().begin())>;
│ │ │ │ +
504
│ │ │ │ +
505 public:
│ │ │ │ +
506
│ │ │ │ +
513 using const_iterator = Impl::TransformedRangeIterator<RawConstIterator, const F*, T>;
│ │ │ │ +
514
│ │ │ │ +
521 using iterator = Impl::TransformedRangeIterator<RawIterator, F*, T>;
│ │ │ │ +
522
│ │ │ │ +
529 using RawRange = std::remove_reference_t<R>;
│ │ │ │ +
530
│ │ │ │ +
534 template<class RR, class FF>
│ │ │ │ +
│ │ │ │ +
535 constexpr TransformedRangeView(RR&& rawRange, FF&& f) noexcept :
│ │ │ │ +
536 rawRange_(std::forward<RR>(rawRange)),
│ │ │ │ +
537 f_(std::forward<FF>(f))
│ │ │ │ +
538 {
│ │ │ │ +
539 static_assert(std::is_same_v<T, ValueTransformationTag> or std::is_same_v<T, IteratorTransformationTag>,
│ │ │ │ +
540 "The TransformationType passed to TransformedRangeView has to be either ValueTransformationTag or IteratorTransformationTag.");
│ │ │ │ +
541 }
│ │ │ │ +
│ │ │ │ +
542
│ │ │ │ +
│ │ │ │ +
551 constexpr const_iterator begin() const noexcept {
│ │ │ │ +
552 return const_iterator(rawRange_.begin(), &f_);
│ │ │ │ +
553 }
│ │ │ │ +
│ │ │ │ +
554
│ │ │ │ +
│ │ │ │ +
555 constexpr iterator begin() noexcept {
│ │ │ │ +
556 return iterator(rawRange_.begin(), &f_);
│ │ │ │ +
557 }
│ │ │ │ +
│ │ │ │ +
558
│ │ │ │ +
│ │ │ │ +
567 constexpr const_iterator end() const noexcept {
│ │ │ │ +
568 return const_iterator(rawRange_.end(), &f_);
│ │ │ │ +
569 }
│ │ │ │ +
│ │ │ │ +
570
│ │ │ │ +
│ │ │ │ +
571 constexpr iterator end() noexcept {
│ │ │ │ +
572 return iterator(rawRange_.end(), &f_);
│ │ │ │ +
573 }
│ │ │ │ +
│ │ │ │ +
574
│ │ │ │ +
578 template<class It=const_iterator,
│ │ │ │ +
579 std::enable_if_t<std::is_same_v<typename It::iterator_category,std::random_access_iterator_tag>, int> = 0>
│ │ │ │ +
│ │ │ │ +
580 constexpr decltype(auto) operator[](std::size_t i) const noexcept
│ │ │ │ +
581 {
│ │ │ │ +
582 return this->begin()[i];
│ │ │ │ +
583 }
│ │ │ │ +
│ │ │ │ +
584
│ │ │ │ +
588 template<class It=iterator,
│ │ │ │ +
589 std::enable_if_t<std::is_same_v<typename It::iterator_category,std::random_access_iterator_tag>, int> = 0>
│ │ │ │ +
│ │ │ │ +
590 constexpr decltype(auto) operator[](std::size_t i) noexcept
│ │ │ │ +
591 {
│ │ │ │ +
592 return this->begin()[i];
│ │ │ │ +
593 }
│ │ │ │ +
│ │ │ │ +
594
│ │ │ │ +
605 template<class Range=R,
│ │ │ │ +
606 class = std::void_t<decltype(std::declval<const Range>().size())>>
│ │ │ │ +
│ │ │ │ +
607 auto size() const noexcept
│ │ │ │ +
608 {
│ │ │ │ +
609 return rawRange_.size();
│ │ │ │ +
610 }
│ │ │ │ +
│ │ │ │ +
611
│ │ │ │ +
│ │ │ │ +
615 constexpr bool empty() const noexcept
│ │ │ │ +
616 {
│ │ │ │ +
617 return rawRange_.begin() == rawRange_.end();
│ │ │ │ +
618 }
│ │ │ │ +
│ │ │ │ +
619
│ │ │ │ +
│ │ │ │ +
623 const RawRange& rawRange() const noexcept
│ │ │ │ +
624 {
│ │ │ │ +
625 return rawRange_;
│ │ │ │ +
626 }
│ │ │ │ +
│ │ │ │ +
627
│ │ │ │ +
│ │ │ │ +
631 RawRange& rawRange() noexcept
│ │ │ │ +
632 {
│ │ │ │ +
633 return rawRange_;
│ │ │ │ +
634 }
│ │ │ │ +
│ │ │ │ +
635
│ │ │ │ +
636 private:
│ │ │ │ +
637 R rawRange_;
│ │ │ │ +
638 F f_;
│ │ │ │ +
639 };
│ │ │ │ +
│ │ │ │ +
640
│ │ │ │ +
669 template <class R, class F>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
671 {
│ │ │ │ +
672 return TransformedRangeView<R, std::decay_t<F>, ValueTransformationTag>(std::forward<R>(range), std::forward<F>(f));
│ │ │ │ +
673 }
│ │ │ │ +
│ │ │ │ +
674
│ │ │ │ +
702 template <class R, class F>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
704 {
│ │ │ │ +
705 return TransformedRangeView<R, std::decay_t<F>, IteratorTransformationTag>(std::forward<R>(range), std::forward<F>(f));
│ │ │ │ +
706 }
│ │ │ │ +
│ │ │ │ +
707
│ │ │ │ +
708
│ │ │ │ +
721 template<class Range>
│ │ │ │ +
│ │ │ │ +
722 auto sparseRange(Range&& range) {
│ │ │ │ +
723 return Dune::iteratorTransformedRangeView(std::forward<Range>(range), [](auto&& it) {
│ │ │ │ +
724 return std::tuple<decltype(*it), decltype(it.index())>(*it, it.index());
│ │ │ │ +
725 });
│ │ │ │ +
726 }
│ │ │ │ +
│ │ │ │ +
727
│ │ │ │ +
732}
│ │ │ │ +
733
│ │ │ │ +
734#endif // DUNE_COMMON_RANGE_UTILITIES_HH
│ │ │ │ +
This file implements iterator facade classes for writing stl conformant iterators.
│ │ │ │ +
Traits for type conversions and type information.
│ │ │ │ +
auto iteratorTransformedRangeView(R &&range, F &&f)
Create a TransformedRangeView using an iterator transformation.
Definition rangeutilities.hh:703
│ │ │ │ +
auto transformedRangeView(R &&range, F &&f)
Create a TransformedRangeView.
Definition rangeutilities.hh:670
│ │ │ │ +
auto sparseRange(Range &&range)
Allow structured-binding for-loops for sparse iterators.
Definition rangeutilities.hh:722
│ │ │ │ +
static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
Definition rangeutilities.hh:312
│ │ │ │ +
typename AutonomousValueType< T >::type AutonomousValue
Type free of internal references that T can be converted to.
Definition typetraits.hh:588
│ │ │ │ +
bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y)
Definition bigunsignedint.hh:549
│ │ │ │ +
bigunsignedint< k > operator-(const bigunsignedint< k > &x, std::uintmax_t y)
Definition bigunsignedint.hh:542
│ │ │ │ +
bigunsignedint< k > operator+(const bigunsignedint< k > &x, std::uintmax_t y)
Definition bigunsignedint.hh:535
│ │ │ │ +
EnableIfInterOperable< T1, T2, bool >::type operator<(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition iteratorfacades.hh:638
│ │ │ │ +
EnableIfInterOperable< T1, T2, bool >::type operator>(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition iteratorfacades.hh:684
│ │ │ │ +
EnableIfInterOperable< T1, T2, bool >::type operator<=(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition iteratorfacades.hh:661
│ │ │ │ +
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition iteratorfacades.hh:238
│ │ │ │ +
EnableIfInterOperable< T1, T2, bool >::type operator>=(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition iteratorfacades.hh:706
│ │ │ │ +
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition iteratorfacades.hh:260
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
A constant random access iterator for the Dune::ArrayList class.
Definition arraylist.hh:368
│ │ │ │ -
Manager class for the mapping between local indices and globally unique indices.
Definition indexset.hh:218
│ │ │ │ -
A const iterator over an uncached selection.
Definition selection.hh:31
│ │ │ │ -
ConstArrayListIterator< IndexPair< TG, TL >, N, std::allocator< Dune::IndexPair< TG, TL > > > ParallelIndexSetIterator
Definition selection.hh:50
│ │ │ │ -
void operator++()
Definition selection.hh:64
│ │ │ │ -
uint32_t operator*() const
Definition selection.hh:73
│ │ │ │ -
TS AttributeSet
The type of the Set of attributes.
Definition selection.hh:41
│ │ │ │ -
Dune::ParallelIndexSet< TG, TL, N > ParallelIndexSet
The type of the underlying index set.
Definition selection.hh:46
│ │ │ │ -
SelectionIterator(const ParallelIndexSetIterator &iter, const ParallelIndexSetIterator &end)
Constructor.
Definition selection.hh:56
│ │ │ │ -
bool operator!=(const SelectionIterator< TS, TG, TL, N > &other) const
Definition selection.hh:83
│ │ │ │ -
bool operator==(const SelectionIterator< TS, TG, TL, N > &other) const
Definition selection.hh:78
│ │ │ │ -
An uncached selection of indices.
Definition selection.hh:99
│ │ │ │ -
UncachedSelection()
Definition selection.hh:139
│ │ │ │ -
SelectionIterator< TS, TG, TL, N > iterator
The type of the iterator of the selected indices.
Definition selection.hh:132
│ │ │ │ -
TS AttributeSet
The type of the Set of attributes.
Definition selection.hh:109
│ │ │ │ -
iterator const_iterator
The type of the iterator of the selected indices.
Definition selection.hh:137
│ │ │ │ -
TG GlobalIndex
The type of the global index of the underlying index set.
Definition selection.hh:114
│ │ │ │ -
UncachedSelection(const ParallelIndexSet &indexset)
Definition selection.hh:143
│ │ │ │ -
Dune::ParallelIndexSet< GlobalIndex, LocalIndex, N > ParallelIndexSet
The type of the underlying index set.
Definition selection.hh:127
│ │ │ │ -
TL LocalIndex
The type of the local index of the underlying index set.
Definition selection.hh:122
│ │ │ │ -
A cached selection of indices.
Definition selection.hh:180
│ │ │ │ -
TG GlobalIndex
The type of the global index of the underlying index set.
Definition selection.hh:195
│ │ │ │ -
Selection(const ParallelIndexSet &indexset)
Definition selection.hh:224
│ │ │ │ -
Selection()
Definition selection.hh:220
│ │ │ │ -
TL LocalIndex
The type of the local index of the underlying index set.
Definition selection.hh:203
│ │ │ │ -
TS AttributeSet
The type of the set of attributes.
Definition selection.hh:190
│ │ │ │ -
uint32_t * iterator
The type of the iterator of the selected indices.
Definition selection.hh:213
│ │ │ │ -
uint32_t * const_iterator
The type of the iterator of the selected indices.
Definition selection.hh:218
│ │ │ │ -
Dune::ParallelIndexSet< GlobalIndex, LocalIndex, N > ParallelIndexSet
The type of the underlying index set.
Definition selection.hh:208
│ │ │ │ +
bool any_true(const AlignedNumber< bool, align > &val)
Definition debugalign.hh:506
│ │ │ │ +
bool all_true(const AlignedNumber< bool, align > &val)
Definition debugalign.hh:512
│ │ │ │ +
T max_value(const AlignedNumber< T, align > &val)
Definition debugalign.hh:494
│ │ │ │ +
T min_value(const AlignedNumber< T, align > &val)
Definition debugalign.hh:500
│ │ │ │ +
This class encapsulates access of IteratorFacade.
Definition iteratorfacades.hh:786
│ │ │ │ +
CRTP-Mixing class for stl conformant iterators of given iterator category.
Definition iteratorfacades.hh:1053
│ │ │ │ +
constexpr decltype(auto) operator*() const
Dereferencing operator.
Definition iteratorfacades.hh:1119
│ │ │ │ +
dynamic integer range for use in range-based for loops
Definition rangeutilities.hh:177
│ │ │ │ +
constexpr iterator begin() const noexcept
obtain a random-access iterator to the first element
Definition rangeutilities.hh:194
│ │ │ │ +
constexpr iterator end() const noexcept
obtain a random-access iterator past the last element
Definition rangeutilities.hh:196
│ │ │ │ +
std::make_unsigned_t< T > size_type
unsigned integer type corresponding to value_type
Definition rangeutilities.hh:184
│ │ │ │ +
Impl::IntegralRangeIterator< T > iterator
type of iterator
Definition rangeutilities.hh:182
│ │ │ │ +
constexpr value_type operator[](const value_type &i) const noexcept
access specified element
Definition rangeutilities.hh:199
│ │ │ │ +
constexpr bool contains(value_type index) const noexcept
check whether given index is within range [from, to)
Definition rangeutilities.hh:207
│ │ │ │ +
constexpr bool empty() const noexcept
check whether the range is empty
Definition rangeutilities.hh:202
│ │ │ │ +
constexpr IntegralRange(std::pair< value_type, value_type > range) noexcept
construct integer range std::pair
Definition rangeutilities.hh:191
│ │ │ │ +
constexpr IntegralRange(value_type from, value_type to) noexcept
construct integer range [from, to)
Definition rangeutilities.hh:187
│ │ │ │ +
constexpr size_type size() const noexcept
obtain number of elements in the range
Definition rangeutilities.hh:204
│ │ │ │ +
constexpr IntegralRange(value_type to) noexcept
construct integer range [0, to)
Definition rangeutilities.hh:189
│ │ │ │ +
T value_type
type of integers contained in the range
Definition rangeutilities.hh:180
│ │ │ │ +
static integer range for use in range-based for loops
Definition rangeutilities.hh:230
│ │ │ │ +
static constexpr iterator end() noexcept
obtain a random-access iterator past the last element
Definition rangeutilities.hh:259
│ │ │ │ +
decltype(shift_integer_sequence< from >(std::make_integer_sequence< T, to-from >())) integer_sequence
type of corresponding std::integer_sequence
Definition rangeutilities.hh:243
│ │ │ │ +
static constexpr bool contains(value_type index) noexcept
check whether given index is within range [from, to)
Definition rangeutilities.hh:278
│ │ │ │ +
constexpr StaticIntegralRange() noexcept=default
default constructor
│ │ │ │ +
std::make_unsigned_t< T > size_type
unsigned integer type corresponding to value_type
Definition rangeutilities.hh:240
│ │ │ │ +
T value_type
type of integers contained in the range
Definition rangeutilities.hh:236
│ │ │ │ +
constexpr auto operator[](const std::integral_constant< U, i > &) const noexcept -> std::integral_constant< value_type, from+static_cast< value_type >(i)>
access specified element (static version)
Definition rangeutilities.hh:263
│ │ │ │ +
static constexpr std::integral_constant< bool, from==to > empty() noexcept
check whether the range is empty
Definition rangeutilities.hh:273
│ │ │ │ +
static constexpr iterator begin() noexcept
obtain a random-access iterator to the first element
Definition rangeutilities.hh:257
│ │ │ │ +
static constexpr integer_sequence to_integer_sequence() noexcept
return corresponding std::integer_sequence
Definition rangeutilities.hh:254
│ │ │ │ +
constexpr value_type operator[](const size_type &i) const noexcept
access specified element (dynamic version)
Definition rangeutilities.hh:270
│ │ │ │ +
Impl::IntegralRangeIterator< T > iterator
type of iterator
Definition rangeutilities.hh:238
│ │ │ │ +
static constexpr std::integral_constant< size_type, static_cast< size_type >(to) - static_cast< size_type >(from) > size() noexcept
obtain number of elements in the range
Definition rangeutilities.hh:275
│ │ │ │ +
Tag to enable value based transformations in TransformedRangeView.
Definition rangeutilities.hh:328
│ │ │ │ +
Tag to enable iterator based transformations in TransformedRangeView.
Definition rangeutilities.hh:333
│ │ │ │ +
A range transforming the values of another range on-the-fly.
Definition rangeutilities.hh:501
│ │ │ │ +
Impl::TransformedRangeIterator< RawIterator, F *, T > iterator
Iterator type.
Definition rangeutilities.hh:521
│ │ │ │ +
constexpr TransformedRangeView(RR &&rawRange, FF &&f) noexcept
Construct from range and function.
Definition rangeutilities.hh:535
│ │ │ │ +
constexpr iterator end() noexcept
Definition rangeutilities.hh:571
│ │ │ │ +
Impl::TransformedRangeIterator< RawConstIterator, const F *, T > const_iterator
Const iterator type.
Definition rangeutilities.hh:513
│ │ │ │ +
std::remove_reference_t< R > RawRange
Export type of the wrapped untransformed range.
Definition rangeutilities.hh:529
│ │ │ │ +
constexpr iterator begin() noexcept
Definition rangeutilities.hh:555
│ │ │ │ +
RawRange & rawRange() noexcept
Export the wrapped untransformed range.
Definition rangeutilities.hh:631
│ │ │ │ +
const RawRange & rawRange() const noexcept
Export the wrapped untransformed range.
Definition rangeutilities.hh:623
│ │ │ │ +
constexpr const_iterator begin() const noexcept
Obtain a iterator to the first element.
Definition rangeutilities.hh:551
│ │ │ │ +
auto size() const noexcept
Obtain the size of the range.
Definition rangeutilities.hh:607
│ │ │ │ +
constexpr const_iterator end() const noexcept
Obtain a iterator past the last element.
Definition rangeutilities.hh:567
│ │ │ │ +
constexpr bool empty() const noexcept
Checks whether the range is empty.
Definition rangeutilities.hh:615
│ │ │ │ +
Check if a type is callable with ()-operator and given arguments.
Definition typetraits.hh:162
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,388 +1,804 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -selection.hh │ │ │ │ │ +rangeutilities.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PARALLEL_SELECTION_HH │ │ │ │ │ -6#define DUNE_COMMON_PARALLEL_SELECTION_HH │ │ │ │ │ +5#ifndef DUNE_COMMON_RANGE_UTILITIES_HH │ │ │ │ │ +6#define DUNE_COMMON_RANGE_UTILITIES_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ -9 │ │ │ │ │ -10#include │ │ │ │ │ -11#include │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11#include │ │ │ │ │ 12 │ │ │ │ │ -13namespace Dune │ │ │ │ │ -14{ │ │ │ │ │ -29 template │ │ │ │ │ -30 class SelectionIterator │ │ │ │ │ -31 { │ │ │ │ │ -32 public: │ │ │ │ │ -41 typedef TS AttributeSet; │ │ │ │ │ -42 │ │ │ │ │ -46 typedef Dune::ParallelIndexSet ParallelIndexSet; │ │ │ │ │ +13#include │ │ │ │ │ +14#include │ │ │ │ │ +15 │ │ │ │ │ +23namespace Dune │ │ │ │ │ +24{ │ │ │ │ │ +25 │ │ │ │ │ +36 template ::value, int>::type = 0> │ │ │ │ │ +38 typename T::value_type │ │ │ │ │ +39 max_value(const T & v) { │ │ │ │ │ +40 using std::max_element; │ │ │ │ │ +41 return *max_element(v.begin(), v.end()); │ │ │ │ │ +42 } │ │ │ │ │ +43 │ │ │ │ │ +44 template ::value, int>::type = 0> │ │ │ │ │ +46 const T & max_value(const T & v) { return v; } │ │ │ │ │ 47 │ │ │ │ │ -48 //typedef typename ParallelIndexSet::const_iterator │ │ │ │ │ -ParallelIndexSetIterator; │ │ │ │ │ -49 │ │ │ │ │ -50 typedef ConstArrayListIterator, N, std::allocator > > ParallelIndexSetIterator; │ │ │ │ │ -56 SelectionIterator(const ParallelIndexSetIterator& iter, const │ │ │ │ │ -ParallelIndexSetIterator& end) │ │ │ │ │ -57 : iter_(iter), end_(end) │ │ │ │ │ -58 { │ │ │ │ │ -59 // Step to the first valid entry │ │ │ │ │ -60 while(iter_!=end_ && !AttributeSet::contains(iter_->local().attribute())) │ │ │ │ │ -61 ++iter_; │ │ │ │ │ -62 } │ │ │ │ │ -63 │ │ │ │ │ -64 void operator++() │ │ │ │ │ -65 { │ │ │ │ │ -66 assert(iter_!=end_); │ │ │ │ │ -67 for(++iter_; iter_!=end_; ++iter_) │ │ │ │ │ -68 if(AttributeSet::contains(iter_->local().attribute())) │ │ │ │ │ -69 break; │ │ │ │ │ -70 } │ │ │ │ │ -71 │ │ │ │ │ -72 │ │ │ │ │ -73 uint32_t operator*() const │ │ │ │ │ -74 { │ │ │ │ │ -75 return iter_->local().local(); │ │ │ │ │ -76 } │ │ │ │ │ -77 │ │ │ │ │ -78 bool operator==(const SelectionIterator& other) const │ │ │ │ │ -79 { │ │ │ │ │ -80 return iter_ == other.iter_; │ │ │ │ │ -81 } │ │ │ │ │ +53 template ::value, int>::type = 0> │ │ │ │ │ +55 typename T::value_type │ │ │ │ │ +56 min_value(const T & v) { │ │ │ │ │ +57 using std::min_element; │ │ │ │ │ +58 return *min_element(v.begin(), v.end()); │ │ │ │ │ +59 } │ │ │ │ │ +60 │ │ │ │ │ +61 template ::value, int>::type = 0> │ │ │ │ │ +63 const T & min_value(const T & v) { return v; } │ │ │ │ │ +64 │ │ │ │ │ +70 template ::value, int>::type = 0> │ │ │ │ │ +72 bool any_true(const T & v) { │ │ │ │ │ +73 bool b = false; │ │ │ │ │ +74 for (const auto & e : v) │ │ │ │ │ +75 b = b or bool(e); │ │ │ │ │ +76 return b; │ │ │ │ │ +77 } │ │ │ │ │ +78 │ │ │ │ │ +79 template ::value, int>::type = 0> │ │ │ │ │ +81 bool any_true(const T & v) { return v; } │ │ │ │ │ 82 │ │ │ │ │ -83 bool operator!=(const SelectionIterator& other) const │ │ │ │ │ -84 { │ │ │ │ │ -85 return iter_ != other.iter_; │ │ │ │ │ -86 } │ │ │ │ │ -87 │ │ │ │ │ -88 private: │ │ │ │ │ -89 ParallelIndexSetIterator iter_; │ │ │ │ │ -90 const ParallelIndexSetIterator end_; │ │ │ │ │ -91 }; │ │ │ │ │ -92 │ │ │ │ │ -93 │ │ │ │ │ -97 template │ │ │ │ │ -98 class UncachedSelection │ │ │ │ │ -99 { │ │ │ │ │ -100 public: │ │ │ │ │ -109 typedef TS AttributeSet; │ │ │ │ │ -110 │ │ │ │ │ -114 typedef TG GlobalIndex; │ │ │ │ │ -115 │ │ │ │ │ -122 typedef TL LocalIndex; │ │ │ │ │ -123 │ │ │ │ │ -127 typedef Dune::ParallelIndexSet ParallelIndexSet; │ │ │ │ │ -128 │ │ │ │ │ -132 typedef SelectionIterator iterator; │ │ │ │ │ +83 template │ │ │ │ │ +84 bool any_true(const std::bitset & b) │ │ │ │ │ +85 { │ │ │ │ │ +86 return b.any(); │ │ │ │ │ +87 } │ │ │ │ │ +88 │ │ │ │ │ +94 template ::value, int>::type = 0> │ │ │ │ │ +96 bool all_true(const T & v) { │ │ │ │ │ +97 bool b = true; │ │ │ │ │ +98 for (const auto & e : v) │ │ │ │ │ +99 b = b and bool(e); │ │ │ │ │ +100 return b; │ │ │ │ │ +101 } │ │ │ │ │ +102 │ │ │ │ │ +103 template ::value, int>::type = 0> │ │ │ │ │ +105 bool all_true(const T & v) { return v; } │ │ │ │ │ +106 │ │ │ │ │ +107 template │ │ │ │ │ +108 bool all_true(const std::bitset & b) │ │ │ │ │ +109 { │ │ │ │ │ +110 return b.all(); │ │ │ │ │ +111 } │ │ │ │ │ +112 │ │ │ │ │ +113 │ │ │ │ │ +114 │ │ │ │ │ +115 namespace Impl │ │ │ │ │ +116 { │ │ │ │ │ +117 │ │ │ │ │ +118 template │ │ │ │ │ +119 class IntegralRangeIterator │ │ │ │ │ +120 { │ │ │ │ │ +121 public: │ │ │ │ │ +122 typedef std::random_access_iterator_tag iterator_category; │ │ │ │ │ +123 typedef T value_type; │ │ │ │ │ +124 typedef std::make_signed_t difference_type; │ │ │ │ │ +125 typedef const T *pointer; │ │ │ │ │ +126 typedef T reference; │ │ │ │ │ +127 │ │ │ │ │ +128 constexpr IntegralRangeIterator() noexcept : value_(0) {} │ │ │ │ │ +129 constexpr explicit IntegralRangeIterator(value_type value) noexcept : │ │ │ │ │ +value_(value) {} │ │ │ │ │ +130 │ │ │ │ │ +131 pointer operator->() const noexcept { return &value_; } │ │ │ │ │ +132 constexpr reference operator*() const noexcept { return value_; } │ │ │ │ │ 133 │ │ │ │ │ -137 typedef iterator const_iterator; │ │ │ │ │ +134 constexpr reference operator[]( difference_type n ) const noexcept { return │ │ │ │ │ +(value_ + n); } │ │ │ │ │ +135 │ │ │ │ │ +136 constexpr bool operator==(const IntegralRangeIterator & other) const │ │ │ │ │ +noexcept { return (value_ == other.value_); } │ │ │ │ │ +137 constexpr bool operator!=(const IntegralRangeIterator & other) const │ │ │ │ │ +noexcept { return (value_ != other.value_); } │ │ │ │ │ 138 │ │ │ │ │ -139 UncachedSelection() │ │ │ │ │ -140 : indexSet_() │ │ │ │ │ -141 {} │ │ │ │ │ -142 │ │ │ │ │ -143 UncachedSelection(const ParallelIndexSet& indexset) │ │ │ │ │ -144 : indexSet_(&indexset) │ │ │ │ │ -145 {} │ │ │ │ │ -150 void setIndexSet(const ParallelIndexSet& indexset); │ │ │ │ │ -151 │ │ │ │ │ -155 //const ParallelIndexSet& indexSet() const; │ │ │ │ │ +139 constexpr bool operator<(const IntegralRangeIterator & other) const │ │ │ │ │ +noexcept { return (value_ <= other.value_); } │ │ │ │ │ +140 constexpr bool operator<=(const IntegralRangeIterator & other) const │ │ │ │ │ +noexcept { return (value_ <= other.value_); } │ │ │ │ │ +141 constexpr bool operator>(const IntegralRangeIterator & other) const │ │ │ │ │ +noexcept { return (value_ >= other.value_); } │ │ │ │ │ +142 constexpr bool operator>=(const IntegralRangeIterator & other) const │ │ │ │ │ +noexcept { return (value_ >= other.value_); } │ │ │ │ │ +143 │ │ │ │ │ +144 IntegralRangeIterator& operator++() noexcept { ++value_; return *this; } │ │ │ │ │ +145 IntegralRangeIterator operator++(int) noexcept { IntegralRangeIterator copy │ │ │ │ │ +( *this ); ++(*this); return copy; } │ │ │ │ │ +146 │ │ │ │ │ +147 IntegralRangeIterator& operator--() noexcept { --value_; return *this; } │ │ │ │ │ +148 IntegralRangeIterator operator--(int) noexcept { IntegralRangeIterator copy │ │ │ │ │ +( *this ); --(*this); return copy; } │ │ │ │ │ +149 │ │ │ │ │ +150 IntegralRangeIterator& operator+=(difference_type n) noexcept { value_ += │ │ │ │ │ +n; return *this; } │ │ │ │ │ +151 IntegralRangeIterator& operator-=(difference_type n) noexcept { value_ - │ │ │ │ │ += n; return *this; } │ │ │ │ │ +152 │ │ │ │ │ +153 friend constexpr IntegralRangeIterator operator+(const │ │ │ │ │ +IntegralRangeIterator &a, difference_type n) noexcept { return │ │ │ │ │ +IntegralRangeIterator(a.value_ + n); } │ │ │ │ │ +154 friend constexpr IntegralRangeIterator operator+(difference_type n, const │ │ │ │ │ +IntegralRangeIterator &a) noexcept { return IntegralRangeIterator(a.value_ + │ │ │ │ │ +n); } │ │ │ │ │ +155 friend constexpr IntegralRangeIterator operator-(const │ │ │ │ │ +IntegralRangeIterator &a, difference_type n) noexcept { return │ │ │ │ │ +IntegralRangeIterator(a.value_ - n); } │ │ │ │ │ 156 │ │ │ │ │ -161 const_iterator begin() const; │ │ │ │ │ +157 constexpr difference_type operator-(const IntegralRangeIterator &other) │ │ │ │ │ +const noexcept { return (static_cast(value_) - static_ │ │ │ │ │ +cast(other.value_)); } │ │ │ │ │ +158 │ │ │ │ │ +159 private: │ │ │ │ │ +160 value_type value_; │ │ │ │ │ +161 }; │ │ │ │ │ 162 │ │ │ │ │ -167 const_iterator end() const; │ │ │ │ │ -168 │ │ │ │ │ -169 │ │ │ │ │ -170 private: │ │ │ │ │ -171 const ParallelIndexSet* indexSet_; │ │ │ │ │ -172 │ │ │ │ │ -173 }; │ │ │ │ │ -174 │ │ │ │ │ -178 template │ │ │ │ │ -179 class Selection │ │ │ │ │ -180 { │ │ │ │ │ -181 public: │ │ │ │ │ -190 typedef TS AttributeSet; │ │ │ │ │ -191 │ │ │ │ │ -195 typedef TG GlobalIndex; │ │ │ │ │ -196 │ │ │ │ │ -203 typedef TL LocalIndex; │ │ │ │ │ -204 │ │ │ │ │ -208 typedef Dune::ParallelIndexSet ParallelIndexSet; │ │ │ │ │ -209 │ │ │ │ │ -213 typedef uint32_t* iterator; │ │ │ │ │ -214 │ │ │ │ │ -218 typedef uint32_t* const_iterator; │ │ │ │ │ -219 │ │ │ │ │ -220 Selection() │ │ │ │ │ -221 : selected_() │ │ │ │ │ -222 {} │ │ │ │ │ -223 │ │ │ │ │ -224 Selection(const ParallelIndexSet& indexset) │ │ │ │ │ -225 : selected_(), size_(0), built_(false) │ │ │ │ │ -226 { │ │ │ │ │ -227 setIndexSet(indexset); │ │ │ │ │ -228 } │ │ │ │ │ -229 │ │ │ │ │ -230 ~Selection(); │ │ │ │ │ -231 │ │ │ │ │ -236 void setIndexSet(const ParallelIndexSet& indexset); │ │ │ │ │ -237 │ │ │ │ │ -241 void free(); │ │ │ │ │ -242 │ │ │ │ │ -246 //IndexSet indexSet() const; │ │ │ │ │ +163 } // namespace Impl │ │ │ │ │ +164 │ │ │ │ │ +165 │ │ │ │ │ +166 │ │ │ │ │ +175 template │ │ │ │ │ +176 class IntegralRange │ │ │ │ │ +177 { │ │ │ │ │ +178 public: │ │ │ │ │ +180 typedef T value_type; │ │ │ │ │ +182 typedef Impl::IntegralRangeIterator iterator; │ │ │ │ │ +184 typedef std::make_unsigned_t size_type; │ │ │ │ │ +185 │ │ │ │ │ +187 constexpr IntegralRange(value_type from, value_type to) noexcept : from_ │ │ │ │ │ +(from), to_(to) {} │ │ │ │ │ +189 constexpr explicit IntegralRange(value_type to) noexcept : from_(0), to_ │ │ │ │ │ +(to) {} │ │ │ │ │ +191 constexpr IntegralRange(std::pair range) noexcept : │ │ │ │ │ +from_(range.first), to_(range.second) {} │ │ │ │ │ +192 │ │ │ │ │ +194 constexpr iterator begin() const noexcept { return iterator(from_); } │ │ │ │ │ +196 constexpr iterator end() const noexcept { return iterator(to_); } │ │ │ │ │ +197 │ │ │ │ │ +199 constexpr value_type operator[](const value_type &i) const noexcept │ │ │ │ │ +{ return (from_ + i); } │ │ │ │ │ +200 │ │ │ │ │ +202 constexpr bool empty() const noexcept { return (from_ == to_); } │ │ │ │ │ +204 constexpr size_type size() const noexcept { return (static_cast │ │ │ │ │ +(to_) - static_cast(from_)); } │ │ │ │ │ +205 │ │ │ │ │ +207 constexpr bool contains(value_type index) const noexcept { return from_ <= │ │ │ │ │ +index && index < to_; } │ │ │ │ │ +208 │ │ │ │ │ +209 private: │ │ │ │ │ +210 value_type from_, to_; │ │ │ │ │ +211 }; │ │ │ │ │ +212 │ │ │ │ │ +213 │ │ │ │ │ +228 template │ │ │ │ │ +229 class StaticIntegralRange │ │ │ │ │ +230 { │ │ │ │ │ +231 template │ │ │ │ │ +232 static std::integer_sequence shift_integer_sequence(std:: │ │ │ │ │ +integer_sequence); │ │ │ │ │ +233 │ │ │ │ │ +234 public: │ │ │ │ │ +236 typedef T value_type; │ │ │ │ │ +238 typedef Impl::IntegralRangeIterator iterator; │ │ │ │ │ +240 typedef std::make_unsigned_t size_type; │ │ │ │ │ +241 │ │ │ │ │ +243 typedef decltype(shift_integer_sequence(std::make_integer_sequence())) integer_sequence; │ │ │ │ │ +244 │ │ │ │ │ +246 constexpr StaticIntegralRange() noexcept = default; │ │ │ │ │ 247 │ │ │ │ │ -252 const_iterator begin() const; │ │ │ │ │ -253 │ │ │ │ │ -258 const_iterator end() const; │ │ │ │ │ -259 │ │ │ │ │ +249 constexpr operator IntegralRange() const noexcept { return {from, to}; } │ │ │ │ │ +251 constexpr operator integer_sequence() const noexcept { return {}; } │ │ │ │ │ +252 │ │ │ │ │ +254 static constexpr integer_sequence to_integer_sequence() noexcept { return │ │ │ │ │ +{}; } │ │ │ │ │ +255 │ │ │ │ │ +257 static constexpr iterator begin() noexcept { return iterator(from); } │ │ │ │ │ +259 static constexpr iterator end() noexcept { return iterator(to); } │ │ │ │ │ 260 │ │ │ │ │ -261 private: │ │ │ │ │ -262 uint32_t* selected_; │ │ │ │ │ -263 size_t size_; │ │ │ │ │ -264 bool built_; │ │ │ │ │ -265 │ │ │ │ │ -266 }; │ │ │ │ │ -267 │ │ │ │ │ -268 template │ │ │ │ │ -269 inline void Selection::setIndexSet(const ParallelIndexSet& │ │ │ │ │ -indexset) │ │ │ │ │ -270 { │ │ │ │ │ -271 if(built_) │ │ │ │ │ -272 free(); │ │ │ │ │ -273 │ │ │ │ │ -274 // Count the number of entries the selection has to hold │ │ │ │ │ -275 typedef typename ParallelIndexSet::const_iterator const_iterator; │ │ │ │ │ -276 const const_iterator end = indexset.end(); │ │ │ │ │ -277 int entries = 0; │ │ │ │ │ -278 │ │ │ │ │ -279 for(const_iterator index = indexset.begin(); index != end; ++index) │ │ │ │ │ -280 if(AttributeSet::contains(index->local().attribute())) │ │ │ │ │ -281 ++entries; │ │ │ │ │ -282 │ │ │ │ │ -283 selected_ = new uint32_t[entries]; │ │ │ │ │ -284 built_ = true; │ │ │ │ │ -285 │ │ │ │ │ -286 entries = 0; │ │ │ │ │ -287 for(const_iterator index = indexset.begin(); index != end; ++index) │ │ │ │ │ -288 if(AttributeSet::contains(index->local().attribute())) │ │ │ │ │ -289 selected_[entries++]= index->local().local(); │ │ │ │ │ -290 │ │ │ │ │ -291 size_=entries; │ │ │ │ │ -292 built_=true; │ │ │ │ │ -293 } │ │ │ │ │ -294 │ │ │ │ │ -295 template │ │ │ │ │ -296 uint32_t* Selection::begin() const │ │ │ │ │ -297 { │ │ │ │ │ -298 return selected_; │ │ │ │ │ -299 } │ │ │ │ │ -300 │ │ │ │ │ -301 template │ │ │ │ │ -302 uint32_t* Selection::end() const │ │ │ │ │ -303 { │ │ │ │ │ -304 return selected_+size_; │ │ │ │ │ -305 } │ │ │ │ │ -306 │ │ │ │ │ -307 template │ │ │ │ │ -308 inline void Selection::free() │ │ │ │ │ -309 { │ │ │ │ │ -310 delete[] selected_; │ │ │ │ │ -311 size_=0; │ │ │ │ │ -312 built_=false; │ │ │ │ │ -313 } │ │ │ │ │ -314 │ │ │ │ │ -315 template │ │ │ │ │ -316 inline Selection::~Selection() │ │ │ │ │ -317 { │ │ │ │ │ -318 if(built_) │ │ │ │ │ -319 free(); │ │ │ │ │ -320 } │ │ │ │ │ -321 │ │ │ │ │ -322 template │ │ │ │ │ -323 SelectionIterator UncachedSelection::begin() const │ │ │ │ │ -324 { │ │ │ │ │ -325 return SelectionIterator(indexSet_->begin(), │ │ │ │ │ -326 indexSet_->end()); │ │ │ │ │ -327 } │ │ │ │ │ -328 │ │ │ │ │ -329 template │ │ │ │ │ -330 SelectionIterator UncachedSelection::end() const │ │ │ │ │ -331 { │ │ │ │ │ -332 return SelectionIterator(indexSet_->end(), │ │ │ │ │ -333 indexSet_->end()); │ │ │ │ │ -334 } │ │ │ │ │ -335 template │ │ │ │ │ -336 void UncachedSelection::setIndexSet(const ParallelIndexSet& │ │ │ │ │ -indexset) │ │ │ │ │ -337 { │ │ │ │ │ -338 indexSet_ = &indexset; │ │ │ │ │ -339 } │ │ │ │ │ -340 │ │ │ │ │ -344} │ │ │ │ │ -345#endif // DUNE_COMMON_PARALLEL_SELECTION_HH │ │ │ │ │ -indexset.hh │ │ │ │ │ -Provides a map between global and local indices. │ │ │ │ │ +262 template │ │ │ │ │ +263 constexpr auto operator[](const std::integral_constant &) const │ │ │ │ │ +noexcept │ │ │ │ │ +264 -> std::integral_constant(i)> │ │ │ │ │ +265 { │ │ │ │ │ +266 return {}; │ │ │ │ │ +267 } │ │ │ │ │ +268 │ │ │ │ │ +270 constexpr value_type operator[](const size_type &i) const noexcept { return │ │ │ │ │ +(from + static_cast(i)); } │ │ │ │ │ +271 │ │ │ │ │ +273 static constexpr std::integral_constant empty() noexcept │ │ │ │ │ +{ return {}; } │ │ │ │ │ +275 static constexpr std::integral_constant │ │ │ │ │ +(to) - static_cast(from) > size() noexcept { return {}; } │ │ │ │ │ +276 │ │ │ │ │ +278 static constexpr bool contains(value_type index) noexcept { return from <= │ │ │ │ │ +index && index < to; } │ │ │ │ │ +279 │ │ │ │ │ +280 }; │ │ │ │ │ +281 │ │ │ │ │ +291 template, std::decay_t>::value, │ │ │ │ │ +int> = 0, │ │ │ │ │ +293 std::enable_if_t>::value, int> = 0> │ │ │ │ │ +294 inline static IntegralRange> range(T &&from, U &&to) │ │ │ │ │ +noexcept │ │ │ │ │ +295 { │ │ │ │ │ +296 return IntegralRange>(std::forward(from), std:: │ │ │ │ │ +forward(to)); │ │ │ │ │ +297 } │ │ │ │ │ +298 │ │ │ │ │ +299 template>:: │ │ │ │ │ +value, int> = 0> │ │ │ │ │ +300 inline static IntegralRange> range(T &&to) noexcept │ │ │ │ │ +301 { │ │ │ │ │ +302 return IntegralRange>(std::forward(to)); │ │ │ │ │ +303 } │ │ │ │ │ +304 │ │ │ │ │ +305 template>::value, │ │ │ │ │ +int> = 0> │ │ │ │ │ +306 inline static IntegralRange>> range │ │ │ │ │ +(T &&to) noexcept │ │ │ │ │ +307 { │ │ │ │ │ +308 return IntegralRange>>(std:: │ │ │ │ │ +forward(to)); │ │ │ │ │ +309 } │ │ │ │ │ +310 │ │ │ │ │ +311 template │ │ │ │ │ +312 inline static StaticIntegralRange range(std::integral_ │ │ │ │ │ +constant, std::integral_constant) noexcept │ │ │ │ │ +313 { │ │ │ │ │ +314 return {}; │ │ │ │ │ +315 } │ │ │ │ │ +316 │ │ │ │ │ +317 template │ │ │ │ │ +318 inline static StaticIntegralRange range(std::integral_constant) noexcept │ │ │ │ │ +319 { │ │ │ │ │ +320 return {}; │ │ │ │ │ +321 } │ │ │ │ │ +322 │ │ │ │ │ +323 │ │ │ │ │ +324 │ │ │ │ │ +328 struct ValueTransformationTag {}; │ │ │ │ │ +329 │ │ │ │ │ +333 struct IteratorTransformationTag {}; │ │ │ │ │ +334 │ │ │ │ │ +335 namespace Impl │ │ │ │ │ +336 { │ │ │ │ │ +337 │ │ │ │ │ +338 │ │ │ │ │ +339 │ │ │ │ │ +340 // An iterator transforming a wrapped iterator using │ │ │ │ │ +341 // an unary function. It inherits the iterator-category │ │ │ │ │ +342 // of the underlying iterator. │ │ │ │ │ +343 // │ │ │ │ │ +344 // \tparam I Type of the underlying iterator │ │ │ │ │ +345 // \tparam F Type of transformation function that can either be applied │ │ │ │ │ +directly or after dereferencing │ │ │ │ │ +346 // \tparam TT Type of transformation (ValueTransformationTag or │ │ │ │ │ +IteratorTransformationTag) │ │ │ │ │ +347 // \tparam C An iterator category tag, defaults to the one of I │ │ │ │ │ +348 template ::iterator_category> │ │ │ │ │ +349 class TransformedRangeIterator; │ │ │ │ │ +350 │ │ │ │ │ +351 template │ │ │ │ │ +352 struct TransformationRangeIteratorTraits │ │ │ │ │ +353 { │ │ │ │ │ +354 template │ │ │ │ │ +355 static decltype(auto) transform(FF&& f, const I& it) { │ │ │ │ │ +356 if constexpr (std::is_same_v) │ │ │ │ │ +357 { │ │ │ │ │ +358 if constexpr (Dune::IsCallable::value) │ │ │ │ │ +359 return f(it); │ │ │ │ │ +360 else │ │ │ │ │ +361 return (*f)(it); │ │ │ │ │ +362 } │ │ │ │ │ +363 else │ │ │ │ │ +364 { │ │ │ │ │ +365 if constexpr (Dune::IsCallable::value) │ │ │ │ │ +366 return f(*it); │ │ │ │ │ +367 else │ │ │ │ │ +368 return (*f)(*it); │ │ │ │ │ +369 } │ │ │ │ │ +370 } │ │ │ │ │ +371 │ │ │ │ │ +372 using reference = decltype(transform(std::declval(), std::declval │ │ │ │ │ +())); │ │ │ │ │ +373 using value_type = Dune::AutonomousValue; │ │ │ │ │ +374 using pointer = std::conditional_t, │ │ │ │ │ +value_type*, ProxyArrowResult>; │ │ │ │ │ +375 using difference_type = typename std::iterator_traits::difference_type; │ │ │ │ │ +376 using Facade = Dune::IteratorFacade, C, │ │ │ │ │ +value_type, reference, pointer, difference_type>; │ │ │ │ │ +377 }; │ │ │ │ │ +378 │ │ │ │ │ +379 │ │ │ │ │ +380 template │ │ │ │ │ +381 class TransformedRangeIterator : │ │ │ │ │ +382 public TransformationRangeIteratorTraits::Facade │ │ │ │ │ +383 { │ │ │ │ │ +384 using Traits = TransformationRangeIteratorTraits; │ │ │ │ │ +385 using Facade = typename Traits::Facade; │ │ │ │ │ +386 │ │ │ │ │ +387 static constexpr bool isBidirectional = std::is_convertible_v; │ │ │ │ │ +388 static constexpr bool isRandomAccess = std::is_convertible_v; │ │ │ │ │ +389 │ │ │ │ │ +390 public: │ │ │ │ │ +391 │ │ │ │ │ +392 using Function = F; │ │ │ │ │ +393 using reference = typename Facade::reference; │ │ │ │ │ +394 using difference_type = typename Facade::difference_type; │ │ │ │ │ +395 │ │ │ │ │ +396 template │ │ │ │ │ +397 constexpr TransformedRangeIterator(II&& it, FF&& f) noexcept : │ │ │ │ │ +398 it_(std::forward(it)), │ │ │ │ │ +399 f_(std::forward(f)) │ │ │ │ │ +400 {} │ │ │ │ │ +401 │ │ │ │ │ +402 template =0, │ │ │ │ │ +404 std::enable_if_t and std::is_default_ │ │ │ │ │ +constructible_v, int> =0> │ │ │ │ │ +405 constexpr TransformedRangeIterator(II&& it) noexcept : │ │ │ │ │ +406 it_(std::forward(it)), │ │ │ │ │ +407 f_() │ │ │ │ │ +408 {} │ │ │ │ │ +409 │ │ │ │ │ +410 template =0, │ │ │ │ │ +412 std::enable_if_t and std::is_default_ │ │ │ │ │ +constructible_v, int> =0> │ │ │ │ │ +413 constexpr TransformedRangeIterator(FF&& f) noexcept : │ │ │ │ │ +414 it_(), │ │ │ │ │ +415 f_(std::forward(f)) │ │ │ │ │ +416 {} │ │ │ │ │ +417 │ │ │ │ │ +418 // Explicitly initialize members. Using a plain │ │ │ │ │ +419 // │ │ │ │ │ +420 // constexpr TransformedRangeIterator() noexcept {} │ │ │ │ │ +421 // │ │ │ │ │ +422 // would default-initialize the members while │ │ │ │ │ +423 // │ │ │ │ │ +424 // constexpr TransformedRangeIterator() noexcept : it_(), f_() {} │ │ │ │ │ +425 // │ │ │ │ │ +426 // leads to value-initialization. This is a case where │ │ │ │ │ +427 // both are really different. If it_ is a raw pointer (i.e. POD) │ │ │ │ │ +428 // then default-initialization leaves it uninitialized while │ │ │ │ │ +429 // value-initialization zero-initializes it. │ │ │ │ │ +430 constexpr TransformedRangeIterator() noexcept : │ │ │ │ │ +431 it_(), │ │ │ │ │ +432 f_() │ │ │ │ │ +433 {} │ │ │ │ │ +434 │ │ │ │ │ +435 // Dereferencing returns a value created by the function │ │ │ │ │ +436 constexpr reference operator*() const noexcept { │ │ │ │ │ +437 return Traits::transform(f_, it_); │ │ │ │ │ +438 } │ │ │ │ │ +439 │ │ │ │ │ +440 protected: │ │ │ │ │ +441 │ │ │ │ │ +442 friend Dune::IteratorFacadeAccess; │ │ │ │ │ +443 │ │ │ │ │ +444 // Export base iterator, such that equalilty comparison, │ │ │ │ │ +445 // differences, and inequality comparisons are automatically │ │ │ │ │ +446 // forwarded to the base iterator by the facade. │ │ │ │ │ +447 const I& baseIterator() const noexcept { │ │ │ │ │ +448 return it_; │ │ │ │ │ +449 } │ │ │ │ │ +450 │ │ │ │ │ +451 I& baseIterator() noexcept { │ │ │ │ │ +452 return it_; │ │ │ │ │ +453 } │ │ │ │ │ +454 │ │ │ │ │ +455 I it_; │ │ │ │ │ +456 Function f_; │ │ │ │ │ +457 }; │ │ │ │ │ +458 │ │ │ │ │ +459 } // namespace Impl │ │ │ │ │ +460 │ │ │ │ │ +461 │ │ │ │ │ +462 │ │ │ │ │ +499 template │ │ │ │ │ +500 class TransformedRangeView │ │ │ │ │ +501 { │ │ │ │ │ +502 using RawConstIterator = std::decay_t │ │ │ │ │ +().begin())>; │ │ │ │ │ +503 using RawIterator = std::decay_t().begin())>; │ │ │ │ │ +504 │ │ │ │ │ +505 public: │ │ │ │ │ +506 │ │ │ │ │ +513 using const_iterator = Impl::TransformedRangeIterator; │ │ │ │ │ +514 │ │ │ │ │ +521 using iterator = Impl::TransformedRangeIterator; │ │ │ │ │ +522 │ │ │ │ │ +529 using RawRange = std::remove_reference_t; │ │ │ │ │ +530 │ │ │ │ │ +534 template │ │ │ │ │ +535 constexpr TransformedRangeView(RR&& rawRange, FF&& f) noexcept : │ │ │ │ │ +536 rawRange_(std::forward(rawRange)), │ │ │ │ │ +537 f_(std::forward(f)) │ │ │ │ │ +538 { │ │ │ │ │ +539 static_assert(std::is_same_v or std::is_same_ │ │ │ │ │ +v, │ │ │ │ │ +540 "The TransformationType passed to TransformedRangeView has to be either │ │ │ │ │ +ValueTransformationTag or IteratorTransformationTag."); │ │ │ │ │ +541 } │ │ │ │ │ +542 │ │ │ │ │ +551 constexpr const_iterator begin() const noexcept { │ │ │ │ │ +552 return const_iterator(rawRange_.begin(), &f_); │ │ │ │ │ +553 } │ │ │ │ │ +554 │ │ │ │ │ +555 constexpr iterator begin() noexcept { │ │ │ │ │ +556 return iterator(rawRange_.begin(), &f_); │ │ │ │ │ +557 } │ │ │ │ │ +558 │ │ │ │ │ +567 constexpr const_iterator end() const noexcept { │ │ │ │ │ +568 return const_iterator(rawRange_.end(), &f_); │ │ │ │ │ +569 } │ │ │ │ │ +570 │ │ │ │ │ +571 constexpr iterator end() noexcept { │ │ │ │ │ +572 return iterator(rawRange_.end(), &f_); │ │ │ │ │ +573 } │ │ │ │ │ +574 │ │ │ │ │ +578 template, int> = 0> │ │ │ │ │ +580 constexpr decltype(auto) operator[](std::size_t i) const noexcept │ │ │ │ │ +581 { │ │ │ │ │ +582 return this->begin()[i]; │ │ │ │ │ +583 } │ │ │ │ │ +584 │ │ │ │ │ +588 template, int> = 0> │ │ │ │ │ +590 constexpr decltype(auto) operator[](std::size_t i) noexcept │ │ │ │ │ +591 { │ │ │ │ │ +592 return this->begin()[i]; │ │ │ │ │ +593 } │ │ │ │ │ +594 │ │ │ │ │ +605 template().size())>> │ │ │ │ │ +607 auto size() const noexcept │ │ │ │ │ +608 { │ │ │ │ │ +609 return rawRange_.size(); │ │ │ │ │ +610 } │ │ │ │ │ +611 │ │ │ │ │ +615 constexpr bool empty() const noexcept │ │ │ │ │ +616 { │ │ │ │ │ +617 return rawRange_.begin() == rawRange_.end(); │ │ │ │ │ +618 } │ │ │ │ │ +619 │ │ │ │ │ +623 const RawRange& rawRange() const noexcept │ │ │ │ │ +624 { │ │ │ │ │ +625 return rawRange_; │ │ │ │ │ +626 } │ │ │ │ │ +627 │ │ │ │ │ +631 RawRange& rawRange() noexcept │ │ │ │ │ +632 { │ │ │ │ │ +633 return rawRange_; │ │ │ │ │ +634 } │ │ │ │ │ +635 │ │ │ │ │ +636 private: │ │ │ │ │ +637 R rawRange_; │ │ │ │ │ +638 F f_; │ │ │ │ │ +639 }; │ │ │ │ │ +640 │ │ │ │ │ +669 template │ │ │ │ │ +670 auto transformedRangeView(R&& range, F&& f) │ │ │ │ │ +671 { │ │ │ │ │ +672 return TransformedRangeView, ValueTransformationTag> │ │ │ │ │ +(std::forward(range), std::forward(f)); │ │ │ │ │ +673 } │ │ │ │ │ +674 │ │ │ │ │ +702 template │ │ │ │ │ +703 auto iteratorTransformedRangeView(R&& range, F&& f) │ │ │ │ │ +704 { │ │ │ │ │ +705 return TransformedRangeView, IteratorTransformationTag> │ │ │ │ │ +(std::forward(range), std::forward(f)); │ │ │ │ │ +706 } │ │ │ │ │ +707 │ │ │ │ │ +708 │ │ │ │ │ +721 template │ │ │ │ │ +722 auto sparseRange(Range&& range) { │ │ │ │ │ +723 return Dune::iteratorTransformedRangeView(std::forward(range), [] │ │ │ │ │ +(auto&& it) { │ │ │ │ │ +724 return std::tuple(*it, it.index()); │ │ │ │ │ +725 }); │ │ │ │ │ +726 } │ │ │ │ │ +727 │ │ │ │ │ +732} │ │ │ │ │ +733 │ │ │ │ │ +734#endif // DUNE_COMMON_RANGE_UTILITIES_HH │ │ │ │ │ iteratorfacades.hh │ │ │ │ │ This file implements iterator facade classes for writing stl conformant │ │ │ │ │ iterators. │ │ │ │ │ -Dune::UncachedSelection::end │ │ │ │ │ -const_iterator end() const │ │ │ │ │ -Get an iterator over the selected indices. │ │ │ │ │ -Definition selection.hh:330 │ │ │ │ │ -Dune::Selection::setIndexSet │ │ │ │ │ -void setIndexSet(const ParallelIndexSet &indexset) │ │ │ │ │ -Set the index set of the selection. │ │ │ │ │ -Definition selection.hh:269 │ │ │ │ │ -Dune::UncachedSelection::setIndexSet │ │ │ │ │ -void setIndexSet(const ParallelIndexSet &indexset) │ │ │ │ │ -Set the index set of the selection. │ │ │ │ │ -Definition selection.hh:336 │ │ │ │ │ -Dune::ParallelIndexSet::begin │ │ │ │ │ -iterator begin() │ │ │ │ │ -Get an iterator over the indices positioned at the first index. │ │ │ │ │ -Dune::ParallelIndexSet::end │ │ │ │ │ -iterator end() │ │ │ │ │ -Get an iterator over the indices positioned after the last index. │ │ │ │ │ -Dune::Selection::end │ │ │ │ │ -const_iterator end() const │ │ │ │ │ -Get an iterator over the selected indices. │ │ │ │ │ -Definition selection.hh:302 │ │ │ │ │ -Dune::Selection::begin │ │ │ │ │ -const_iterator begin() const │ │ │ │ │ -Get the index set we are a selection for. │ │ │ │ │ -Definition selection.hh:296 │ │ │ │ │ -Dune::Selection::free │ │ │ │ │ -void free() │ │ │ │ │ -Free allocated memory. │ │ │ │ │ -Definition selection.hh:308 │ │ │ │ │ -Dune::UncachedSelection::begin │ │ │ │ │ -const_iterator begin() const │ │ │ │ │ -Get the index set we are a selection for. │ │ │ │ │ -Definition selection.hh:323 │ │ │ │ │ -Dune::Selection::~Selection │ │ │ │ │ -~Selection() │ │ │ │ │ -Definition selection.hh:316 │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +Dune::iteratorTransformedRangeView │ │ │ │ │ +auto iteratorTransformedRangeView(R &&range, F &&f) │ │ │ │ │ +Create a TransformedRangeView using an iterator transformation. │ │ │ │ │ +Definition rangeutilities.hh:703 │ │ │ │ │ +Dune::transformedRangeView │ │ │ │ │ +auto transformedRangeView(R &&range, F &&f) │ │ │ │ │ +Create a TransformedRangeView. │ │ │ │ │ +Definition rangeutilities.hh:670 │ │ │ │ │ +Dune::sparseRange │ │ │ │ │ +auto sparseRange(Range &&range) │ │ │ │ │ +Allow structured-binding for-loops for sparse iterators. │ │ │ │ │ +Definition rangeutilities.hh:722 │ │ │ │ │ +Dune::range │ │ │ │ │ +static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from │ │ │ │ │ +>, std::integral_constant< T, to >) noexcept │ │ │ │ │ +Definition rangeutilities.hh:312 │ │ │ │ │ +Dune::AutonomousValue │ │ │ │ │ +typename AutonomousValueType< T >::type AutonomousValue │ │ │ │ │ +Type free of internal references that T can be converted to. │ │ │ │ │ +Definition typetraits.hh:588 │ │ │ │ │ +Dune::operator* │ │ │ │ │ +bigunsignedint< k > operator*(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ +Definition bigunsignedint.hh:549 │ │ │ │ │ +Dune::operator- │ │ │ │ │ +bigunsignedint< k > operator-(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ +Definition bigunsignedint.hh:542 │ │ │ │ │ +Dune::operator+ │ │ │ │ │ +bigunsignedint< k > operator+(const bigunsignedint< k > &x, std::uintmax_t y) │ │ │ │ │ +Definition bigunsignedint.hh:535 │ │ │ │ │ +Dune::operator< │ │ │ │ │ +EnableIfInterOperable< T1, T2, bool >::type operator<(const │ │ │ │ │ +RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const │ │ │ │ │ +RandomAccessIteratorFacade< T2, V2, R2, D > &rhs) │ │ │ │ │ +Comparison operator. │ │ │ │ │ +Definition iteratorfacades.hh:638 │ │ │ │ │ +Dune::operator> │ │ │ │ │ +EnableIfInterOperable< T1, T2, bool >::type operator>(const │ │ │ │ │ +RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const │ │ │ │ │ +RandomAccessIteratorFacade< T2, V2, R2, D > &rhs) │ │ │ │ │ +Comparison operator. │ │ │ │ │ +Definition iteratorfacades.hh:684 │ │ │ │ │ +Dune::operator<= │ │ │ │ │ +EnableIfInterOperable< T1, T2, bool >::type operator<=(const │ │ │ │ │ +RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const │ │ │ │ │ +RandomAccessIteratorFacade< T2, V2, R2, D > &rhs) │ │ │ │ │ +Comparison operator. │ │ │ │ │ +Definition iteratorfacades.hh:661 │ │ │ │ │ +Dune::operator== │ │ │ │ │ +EnableIfInterOperable< T1, T2, bool >::type operator==(const │ │ │ │ │ +ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, │ │ │ │ │ +V2, R2, D > &rhs) │ │ │ │ │ +Checks for equality. │ │ │ │ │ +Definition iteratorfacades.hh:238 │ │ │ │ │ +Dune::operator>= │ │ │ │ │ +EnableIfInterOperable< T1, T2, bool >::type operator>=(const │ │ │ │ │ +RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const │ │ │ │ │ +RandomAccessIteratorFacade< T2, V2, R2, D > &rhs) │ │ │ │ │ +Comparison operator. │ │ │ │ │ +Definition iteratorfacades.hh:706 │ │ │ │ │ +Dune::operator!= │ │ │ │ │ +EnableIfInterOperable< T1, T2, bool >::type operator!=(const │ │ │ │ │ +ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, │ │ │ │ │ +V2, R2, D > &rhs) │ │ │ │ │ +Checks for inequality. │ │ │ │ │ +Definition iteratorfacades.hh:260 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::ConstArrayListIterator │ │ │ │ │ -A constant random access iterator for the Dune::ArrayList class. │ │ │ │ │ -Definition arraylist.hh:368 │ │ │ │ │ -Dune::ParallelIndexSet │ │ │ │ │ -Manager class for the mapping between local indices and globally unique │ │ │ │ │ -indices. │ │ │ │ │ -Definition indexset.hh:218 │ │ │ │ │ -Dune::SelectionIterator │ │ │ │ │ -A const iterator over an uncached selection. │ │ │ │ │ -Definition selection.hh:31 │ │ │ │ │ -Dune::SelectionIterator::ParallelIndexSetIterator │ │ │ │ │ -ConstArrayListIterator< IndexPair< TG, TL >, N, std::allocator< Dune:: │ │ │ │ │ -IndexPair< TG, TL > > > ParallelIndexSetIterator │ │ │ │ │ -Definition selection.hh:50 │ │ │ │ │ -Dune::SelectionIterator::operator++ │ │ │ │ │ -void operator++() │ │ │ │ │ -Definition selection.hh:64 │ │ │ │ │ -Dune::SelectionIterator::operator* │ │ │ │ │ -uint32_t operator*() const │ │ │ │ │ -Definition selection.hh:73 │ │ │ │ │ -Dune::SelectionIterator::AttributeSet │ │ │ │ │ -TS AttributeSet │ │ │ │ │ -The type of the Set of attributes. │ │ │ │ │ -Definition selection.hh:41 │ │ │ │ │ -Dune::SelectionIterator::ParallelIndexSet │ │ │ │ │ -Dune::ParallelIndexSet< TG, TL, N > ParallelIndexSet │ │ │ │ │ -The type of the underlying index set. │ │ │ │ │ -Definition selection.hh:46 │ │ │ │ │ -Dune::SelectionIterator::SelectionIterator │ │ │ │ │ -SelectionIterator(const ParallelIndexSetIterator &iter, const │ │ │ │ │ -ParallelIndexSetIterator &end) │ │ │ │ │ -Constructor. │ │ │ │ │ -Definition selection.hh:56 │ │ │ │ │ -Dune::SelectionIterator::operator!= │ │ │ │ │ -bool operator!=(const SelectionIterator< TS, TG, TL, N > &other) const │ │ │ │ │ -Definition selection.hh:83 │ │ │ │ │ -Dune::SelectionIterator::operator== │ │ │ │ │ -bool operator==(const SelectionIterator< TS, TG, TL, N > &other) const │ │ │ │ │ -Definition selection.hh:78 │ │ │ │ │ -Dune::UncachedSelection │ │ │ │ │ -An uncached selection of indices. │ │ │ │ │ -Definition selection.hh:99 │ │ │ │ │ -Dune::UncachedSelection::UncachedSelection │ │ │ │ │ -UncachedSelection() │ │ │ │ │ -Definition selection.hh:139 │ │ │ │ │ -Dune::UncachedSelection::iterator │ │ │ │ │ -SelectionIterator< TS, TG, TL, N > iterator │ │ │ │ │ -The type of the iterator of the selected indices. │ │ │ │ │ -Definition selection.hh:132 │ │ │ │ │ -Dune::UncachedSelection::AttributeSet │ │ │ │ │ -TS AttributeSet │ │ │ │ │ -The type of the Set of attributes. │ │ │ │ │ -Definition selection.hh:109 │ │ │ │ │ -Dune::UncachedSelection::const_iterator │ │ │ │ │ -iterator const_iterator │ │ │ │ │ -The type of the iterator of the selected indices. │ │ │ │ │ -Definition selection.hh:137 │ │ │ │ │ -Dune::UncachedSelection::GlobalIndex │ │ │ │ │ -TG GlobalIndex │ │ │ │ │ -The type of the global index of the underlying index set. │ │ │ │ │ -Definition selection.hh:114 │ │ │ │ │ -Dune::UncachedSelection::UncachedSelection │ │ │ │ │ -UncachedSelection(const ParallelIndexSet &indexset) │ │ │ │ │ -Definition selection.hh:143 │ │ │ │ │ -Dune::UncachedSelection::ParallelIndexSet │ │ │ │ │ -Dune::ParallelIndexSet< GlobalIndex, LocalIndex, N > ParallelIndexSet │ │ │ │ │ -The type of the underlying index set. │ │ │ │ │ -Definition selection.hh:127 │ │ │ │ │ -Dune::UncachedSelection::LocalIndex │ │ │ │ │ -TL LocalIndex │ │ │ │ │ -The type of the local index of the underlying index set. │ │ │ │ │ -Definition selection.hh:122 │ │ │ │ │ -Dune::Selection │ │ │ │ │ -A cached selection of indices. │ │ │ │ │ -Definition selection.hh:180 │ │ │ │ │ -Dune::Selection::GlobalIndex │ │ │ │ │ -TG GlobalIndex │ │ │ │ │ -The type of the global index of the underlying index set. │ │ │ │ │ -Definition selection.hh:195 │ │ │ │ │ -Dune::Selection::Selection │ │ │ │ │ -Selection(const ParallelIndexSet &indexset) │ │ │ │ │ -Definition selection.hh:224 │ │ │ │ │ -Dune::Selection::Selection │ │ │ │ │ -Selection() │ │ │ │ │ -Definition selection.hh:220 │ │ │ │ │ -Dune::Selection::LocalIndex │ │ │ │ │ -TL LocalIndex │ │ │ │ │ -The type of the local index of the underlying index set. │ │ │ │ │ -Definition selection.hh:203 │ │ │ │ │ -Dune::Selection::AttributeSet │ │ │ │ │ -TS AttributeSet │ │ │ │ │ -The type of the set of attributes. │ │ │ │ │ -Definition selection.hh:190 │ │ │ │ │ -Dune::Selection::iterator │ │ │ │ │ -uint32_t * iterator │ │ │ │ │ -The type of the iterator of the selected indices. │ │ │ │ │ -Definition selection.hh:213 │ │ │ │ │ -Dune::Selection::const_iterator │ │ │ │ │ -uint32_t * const_iterator │ │ │ │ │ -The type of the iterator of the selected indices. │ │ │ │ │ -Definition selection.hh:218 │ │ │ │ │ -Dune::Selection::ParallelIndexSet │ │ │ │ │ -Dune::ParallelIndexSet< GlobalIndex, LocalIndex, N > ParallelIndexSet │ │ │ │ │ -The type of the underlying index set. │ │ │ │ │ -Definition selection.hh:208 │ │ │ │ │ +Dune::any_true │ │ │ │ │ +bool any_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ +Definition debugalign.hh:506 │ │ │ │ │ +Dune::all_true │ │ │ │ │ +bool all_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ +Definition debugalign.hh:512 │ │ │ │ │ +Dune::max_value │ │ │ │ │ +T max_value(const AlignedNumber< T, align > &val) │ │ │ │ │ +Definition debugalign.hh:494 │ │ │ │ │ +Dune::min_value │ │ │ │ │ +T min_value(const AlignedNumber< T, align > &val) │ │ │ │ │ +Definition debugalign.hh:500 │ │ │ │ │ +Dune::IteratorFacadeAccess │ │ │ │ │ +This class encapsulates access of IteratorFacade. │ │ │ │ │ +Definition iteratorfacades.hh:786 │ │ │ │ │ +Dune::IteratorFacade │ │ │ │ │ +CRTP-Mixing class for stl conformant iterators of given iterator category. │ │ │ │ │ +Definition iteratorfacades.hh:1053 │ │ │ │ │ +Dune::IteratorFacade::operator* │ │ │ │ │ +constexpr decltype(auto) operator*() const │ │ │ │ │ +Dereferencing operator. │ │ │ │ │ +Definition iteratorfacades.hh:1119 │ │ │ │ │ +Dune::IntegralRange │ │ │ │ │ +dynamic integer range for use in range-based for loops │ │ │ │ │ +Definition rangeutilities.hh:177 │ │ │ │ │ +Dune::IntegralRange::begin │ │ │ │ │ +constexpr iterator begin() const noexcept │ │ │ │ │ +obtain a random-access iterator to the first element │ │ │ │ │ +Definition rangeutilities.hh:194 │ │ │ │ │ +Dune::IntegralRange::end │ │ │ │ │ +constexpr iterator end() const noexcept │ │ │ │ │ +obtain a random-access iterator past the last element │ │ │ │ │ +Definition rangeutilities.hh:196 │ │ │ │ │ +Dune::IntegralRange::size_type │ │ │ │ │ +std::make_unsigned_t< T > size_type │ │ │ │ │ +unsigned integer type corresponding to value_type │ │ │ │ │ +Definition rangeutilities.hh:184 │ │ │ │ │ +Dune::IntegralRange::iterator │ │ │ │ │ +Impl::IntegralRangeIterator< T > iterator │ │ │ │ │ +type of iterator │ │ │ │ │ +Definition rangeutilities.hh:182 │ │ │ │ │ +Dune::IntegralRange::operator[] │ │ │ │ │ +constexpr value_type operator[](const value_type &i) const noexcept │ │ │ │ │ +access specified element │ │ │ │ │ +Definition rangeutilities.hh:199 │ │ │ │ │ +Dune::IntegralRange::contains │ │ │ │ │ +constexpr bool contains(value_type index) const noexcept │ │ │ │ │ +check whether given index is within range [from, to) │ │ │ │ │ +Definition rangeutilities.hh:207 │ │ │ │ │ +Dune::IntegralRange::empty │ │ │ │ │ +constexpr bool empty() const noexcept │ │ │ │ │ +check whether the range is empty │ │ │ │ │ +Definition rangeutilities.hh:202 │ │ │ │ │ +Dune::IntegralRange::IntegralRange │ │ │ │ │ +constexpr IntegralRange(std::pair< value_type, value_type > range) noexcept │ │ │ │ │ +construct integer range std::pair │ │ │ │ │ +Definition rangeutilities.hh:191 │ │ │ │ │ +Dune::IntegralRange::IntegralRange │ │ │ │ │ +constexpr IntegralRange(value_type from, value_type to) noexcept │ │ │ │ │ +construct integer range [from, to) │ │ │ │ │ +Definition rangeutilities.hh:187 │ │ │ │ │ +Dune::IntegralRange::size │ │ │ │ │ +constexpr size_type size() const noexcept │ │ │ │ │ +obtain number of elements in the range │ │ │ │ │ +Definition rangeutilities.hh:204 │ │ │ │ │ +Dune::IntegralRange::IntegralRange │ │ │ │ │ +constexpr IntegralRange(value_type to) noexcept │ │ │ │ │ +construct integer range [0, to) │ │ │ │ │ +Definition rangeutilities.hh:189 │ │ │ │ │ +Dune::IntegralRange::value_type │ │ │ │ │ +T value_type │ │ │ │ │ +type of integers contained in the range │ │ │ │ │ +Definition rangeutilities.hh:180 │ │ │ │ │ +Dune::StaticIntegralRange │ │ │ │ │ +static integer range for use in range-based for loops │ │ │ │ │ +Definition rangeutilities.hh:230 │ │ │ │ │ +Dune::StaticIntegralRange::end │ │ │ │ │ +static constexpr iterator end() noexcept │ │ │ │ │ +obtain a random-access iterator past the last element │ │ │ │ │ +Definition rangeutilities.hh:259 │ │ │ │ │ +Dune::StaticIntegralRange::integer_sequence │ │ │ │ │ +decltype(shift_integer_sequence< from >(std::make_integer_sequence< T, to-from │ │ │ │ │ +>())) integer_sequence │ │ │ │ │ +type of corresponding std::integer_sequence │ │ │ │ │ +Definition rangeutilities.hh:243 │ │ │ │ │ +Dune::StaticIntegralRange::contains │ │ │ │ │ +static constexpr bool contains(value_type index) noexcept │ │ │ │ │ +check whether given index is within range [from, to) │ │ │ │ │ +Definition rangeutilities.hh:278 │ │ │ │ │ +Dune::StaticIntegralRange::StaticIntegralRange │ │ │ │ │ +constexpr StaticIntegralRange() noexcept=default │ │ │ │ │ +default constructor │ │ │ │ │ +Dune::StaticIntegralRange::size_type │ │ │ │ │ +std::make_unsigned_t< T > size_type │ │ │ │ │ +unsigned integer type corresponding to value_type │ │ │ │ │ +Definition rangeutilities.hh:240 │ │ │ │ │ +Dune::StaticIntegralRange::value_type │ │ │ │ │ +T value_type │ │ │ │ │ +type of integers contained in the range │ │ │ │ │ +Definition rangeutilities.hh:236 │ │ │ │ │ +Dune::StaticIntegralRange::operator[] │ │ │ │ │ +constexpr auto operator[](const std::integral_constant< U, i > &) const │ │ │ │ │ +noexcept -> std::integral_constant< value_type, from+static_cast< value_type > │ │ │ │ │ +(i)> │ │ │ │ │ +access specified element (static version) │ │ │ │ │ +Definition rangeutilities.hh:263 │ │ │ │ │ +Dune::StaticIntegralRange::empty │ │ │ │ │ +static constexpr std::integral_constant< bool, from==to > empty() noexcept │ │ │ │ │ +check whether the range is empty │ │ │ │ │ +Definition rangeutilities.hh:273 │ │ │ │ │ +Dune::StaticIntegralRange::begin │ │ │ │ │ +static constexpr iterator begin() noexcept │ │ │ │ │ +obtain a random-access iterator to the first element │ │ │ │ │ +Definition rangeutilities.hh:257 │ │ │ │ │ +Dune::StaticIntegralRange::to_integer_sequence │ │ │ │ │ +static constexpr integer_sequence to_integer_sequence() noexcept │ │ │ │ │ +return corresponding std::integer_sequence │ │ │ │ │ +Definition rangeutilities.hh:254 │ │ │ │ │ +Dune::StaticIntegralRange::operator[] │ │ │ │ │ +constexpr value_type operator[](const size_type &i) const noexcept │ │ │ │ │ +access specified element (dynamic version) │ │ │ │ │ +Definition rangeutilities.hh:270 │ │ │ │ │ +Dune::StaticIntegralRange::iterator │ │ │ │ │ +Impl::IntegralRangeIterator< T > iterator │ │ │ │ │ +type of iterator │ │ │ │ │ +Definition rangeutilities.hh:238 │ │ │ │ │ +Dune::StaticIntegralRange::size │ │ │ │ │ +static constexpr std::integral_constant< size_type, static_cast< size_type > │ │ │ │ │ +(to) - static_cast< size_type >(from) > size() noexcept │ │ │ │ │ +obtain number of elements in the range │ │ │ │ │ +Definition rangeutilities.hh:275 │ │ │ │ │ +Dune::ValueTransformationTag │ │ │ │ │ +Tag to enable value based transformations in TransformedRangeView. │ │ │ │ │ +Definition rangeutilities.hh:328 │ │ │ │ │ +Dune::IteratorTransformationTag │ │ │ │ │ +Tag to enable iterator based transformations in TransformedRangeView. │ │ │ │ │ +Definition rangeutilities.hh:333 │ │ │ │ │ +Dune::TransformedRangeView │ │ │ │ │ +A range transforming the values of another range on-the-fly. │ │ │ │ │ +Definition rangeutilities.hh:501 │ │ │ │ │ +Dune::TransformedRangeView::iterator │ │ │ │ │ +Impl::TransformedRangeIterator< RawIterator, F *, T > iterator │ │ │ │ │ +Iterator type. │ │ │ │ │ +Definition rangeutilities.hh:521 │ │ │ │ │ +Dune::TransformedRangeView::TransformedRangeView │ │ │ │ │ +constexpr TransformedRangeView(RR &&rawRange, FF &&f) noexcept │ │ │ │ │ +Construct from range and function. │ │ │ │ │ +Definition rangeutilities.hh:535 │ │ │ │ │ +Dune::TransformedRangeView::end │ │ │ │ │ +constexpr iterator end() noexcept │ │ │ │ │ +Definition rangeutilities.hh:571 │ │ │ │ │ +Dune::TransformedRangeView::const_iterator │ │ │ │ │ +Impl::TransformedRangeIterator< RawConstIterator, const F *, T > const_iterator │ │ │ │ │ +Const iterator type. │ │ │ │ │ +Definition rangeutilities.hh:513 │ │ │ │ │ +Dune::TransformedRangeView::RawRange │ │ │ │ │ +std::remove_reference_t< R > RawRange │ │ │ │ │ +Export type of the wrapped untransformed range. │ │ │ │ │ +Definition rangeutilities.hh:529 │ │ │ │ │ +Dune::TransformedRangeView::begin │ │ │ │ │ +constexpr iterator begin() noexcept │ │ │ │ │ +Definition rangeutilities.hh:555 │ │ │ │ │ +Dune::TransformedRangeView::rawRange │ │ │ │ │ +RawRange & rawRange() noexcept │ │ │ │ │ +Export the wrapped untransformed range. │ │ │ │ │ +Definition rangeutilities.hh:631 │ │ │ │ │ +Dune::TransformedRangeView::rawRange │ │ │ │ │ +const RawRange & rawRange() const noexcept │ │ │ │ │ +Export the wrapped untransformed range. │ │ │ │ │ +Definition rangeutilities.hh:623 │ │ │ │ │ +Dune::TransformedRangeView::begin │ │ │ │ │ +constexpr const_iterator begin() const noexcept │ │ │ │ │ +Obtain a iterator to the first element. │ │ │ │ │ +Definition rangeutilities.hh:551 │ │ │ │ │ +Dune::TransformedRangeView::size │ │ │ │ │ +auto size() const noexcept │ │ │ │ │ +Obtain the size of the range. │ │ │ │ │ +Definition rangeutilities.hh:607 │ │ │ │ │ +Dune::TransformedRangeView::end │ │ │ │ │ +constexpr const_iterator end() const noexcept │ │ │ │ │ +Obtain a iterator past the last element. │ │ │ │ │ +Definition rangeutilities.hh:567 │ │ │ │ │ +Dune::TransformedRangeView::empty │ │ │ │ │ +constexpr bool empty() const noexcept │ │ │ │ │ +Checks whether the range is empty. │ │ │ │ │ +Definition rangeutilities.hh:615 │ │ │ │ │ +Dune::IsCallable │ │ │ │ │ +Check if a type is callable with ()-operator and given arguments. │ │ │ │ │ +Definition typetraits.hh:162 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00083.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: collectivecommunication.hh File Reference │ │ │ │ +dune-common: genericiterator.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,24 +65,65 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
collectivecommunication.hh File Reference
│ │ │ │ +
│ │ │ │ +Classes | │ │ │ │ +Namespaces
│ │ │ │ +
genericiterator.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <dune/common/parallel/communication.hh>
│ │ │ │ + │ │ │ │ +

Implements a generic iterator class for writing stl conformant iterators. │ │ │ │ +More...

│ │ │ │ +
#include <dune/common/iteratorfacades.hh>
│ │ │ │ +#include <cassert>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ -
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

struct  Dune::const_reference< R >
 Get the 'const' version of a reference to a mutable object. More...
 
struct  Dune::const_reference< const R >
 
struct  Dune::const_reference< R & >
 
struct  Dune::const_reference< const R & >
 
struct  Dune::mutable_reference< R >
 get the 'mutable' version of a reference to a const object More...
 
struct  Dune::mutable_reference< const R >
 
struct  Dune::mutable_reference< R & >
 
struct  Dune::mutable_reference< const R & >
 
class  Dune::GenericIterator< C, T, R, D, IteratorFacade >
 Generic class for stl-conforming iterators for container classes with operator[]. More...
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ +

Detailed Description

│ │ │ │ +

Implements a generic iterator class for writing stl conformant iterators.

│ │ │ │ +

Using this generic iterator writing iterators for containers that implement operator[] is only a matter of seconds.

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,12 +1,46 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -collectivecommunication.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +genericiterator.hh File Reference │ │ │ │ │ +Implements a generic iterator class for writing stl conformant iterators. │ │ │ │ │ +More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ +Classes │ │ │ │ │ +struct   Dune::const_reference<_R_> │ │ │ │ │ +  Get the 'const' version of a reference to a mutable object. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::const_reference<_const_R_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::const_reference<_R_&_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::const_reference<_const_R_&_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::mutable_reference<_R_> │ │ │ │ │ +  get the 'mutable' version of a reference to a const object More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::mutable_reference<_const_R_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::mutable_reference<_R_&_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::mutable_reference<_const_R_&_> │ │ │ │ │ +  │ │ │ │ │ + class   Dune::GenericIterator<_C,_T,_R,_D,_IteratorFacade_> │ │ │ │ │ +  Generic class for stl-conforming iterators for container classes with │ │ │ │ │ + operator[]. More... │ │ │ │ │ +  │ │ │ │ │ +Namespaces │ │ │ │ │ +namespace   Dune │ │ │ │ │ +  Dune namespace. │ │ │ │ │ +  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +Implements a generic iterator class for writing stl conformant iterators. │ │ │ │ │ +Using this generic iterator writing iterators for containers that implement │ │ │ │ │ +operator[] is only a matter of seconds. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00083_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: collectivecommunication.hh Source File │ │ │ │ +dune-common: genericiterator.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,27 +70,244 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
collectivecommunication.hh
│ │ │ │ +
genericiterator.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
3// Will be removed after the 2.7 release
│ │ │ │ -
4#warning "Deprecated header, use #include <dune/common/parallel/communication.hh> instead!"
│ │ │ │ - │ │ │ │ -
Implements an utility class that provides collective communication methods for sequential programs.
│ │ │ │ +Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ +
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ +
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
5#ifndef DUNE_GENERICITERATOR_HH
│ │ │ │ +
6#define DUNE_GENERICITERATOR_HH
│ │ │ │ +
7
│ │ │ │ + │ │ │ │ +
9#include <cassert>
│ │ │ │ +
10
│ │ │ │ +
11namespace Dune {
│ │ │ │ +
12
│ │ │ │ +
85 template<class R>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
87 {
│ │ │ │ +
88 typedef const R type;
│ │ │ │ +
89 };
│ │ │ │ +
│ │ │ │ +
90
│ │ │ │ +
91 template<class R>
│ │ │ │ +
│ │ │ │ +
92 struct const_reference<const R>
│ │ │ │ +
93 {
│ │ │ │ +
94 typedef const R type;
│ │ │ │ +
95 };
│ │ │ │ +
│ │ │ │ +
96
│ │ │ │ +
97 template<class R>
│ │ │ │ +
│ │ │ │ +
98 struct const_reference<R&>
│ │ │ │ +
99 {
│ │ │ │ +
100 typedef const R& type;
│ │ │ │ +
101 };
│ │ │ │ +
│ │ │ │ +
102
│ │ │ │ +
103 template<class R>
│ │ │ │ +
│ │ │ │ +
104 struct const_reference<const R&>
│ │ │ │ +
105 {
│ │ │ │ +
106 typedef const R& type;
│ │ │ │ +
107 };
│ │ │ │ +
│ │ │ │ +
108
│ │ │ │ +
114 template<class R>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
116 {
│ │ │ │ +
117 typedef R type;
│ │ │ │ +
118 };
│ │ │ │ +
│ │ │ │ +
119
│ │ │ │ +
120 template<class R>
│ │ │ │ +
│ │ │ │ +
121 struct mutable_reference<const R>
│ │ │ │ +
122 {
│ │ │ │ +
123 typedef R type;
│ │ │ │ +
124 };
│ │ │ │ +
│ │ │ │ +
125
│ │ │ │ +
126 template<class R>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
128 {
│ │ │ │ +
129 typedef R& type;
│ │ │ │ +
130 };
│ │ │ │ +
│ │ │ │ +
131
│ │ │ │ +
132 template<class R>
│ │ │ │ +
│ │ │ │ +
133 struct mutable_reference<const R&>
│ │ │ │ +
134 {
│ │ │ │ +
135 typedef R& type;
│ │ │ │ +
136 };
│ │ │ │ +
│ │ │ │ +
137
│ │ │ │ +
149 template<class C, class T, class R=T&, class D = std::ptrdiff_t,
│ │ │ │ +
150 template<class,class,class,class> class IteratorFacade=RandomAccessIteratorFacade>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
152 public IteratorFacade<GenericIterator<C,T,R,D,IteratorFacade>,T,R,D>
│ │ │ │ +
153 {
│ │ │ │ +
154 friend class GenericIterator<typename std::remove_const<C>::type, typename std::remove_const<T>::type, typename mutable_reference<R>::type, D, IteratorFacade>;
│ │ │ │ +
155 friend class GenericIterator<const typename std::remove_const<C>::type, const typename std::remove_const<T>::type, typename const_reference<R>::type, D, IteratorFacade>;
│ │ │ │ +
156
│ │ │ │ +
157 typedef GenericIterator<typename std::remove_const<C>::type, typename std::remove_const<T>::type, typename mutable_reference<R>::type, D, IteratorFacade> MutableIterator;
│ │ │ │ +
158 typedef GenericIterator<const typename std::remove_const<C>::type, const typename std::remove_const<T>::type, typename const_reference<R>::type, D, IteratorFacade> ConstIterator;
│ │ │ │ +
159
│ │ │ │ +
160 public:
│ │ │ │ +
161
│ │ │ │ +
170 typedef C Container;
│ │ │ │ +
171
│ │ │ │ +
177 typedef T Value;
│ │ │ │ +
178
│ │ │ │ +
182 typedef D DifferenceType;
│ │ │ │ +
183
│ │ │ │ +
187 typedef R Reference;
│ │ │ │ +
188
│ │ │ │ +
189 // Constructors needed by the base iterators
│ │ │ │ +
│ │ │ │ +
190 GenericIterator() : container_(0), position_(0)
│ │ │ │ +
191 {}
│ │ │ │ +
│ │ │ │ +
192
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
201 : container_(&cont), position_(pos)
│ │ │ │ +
202 {}
│ │ │ │ +
│ │ │ │ +
203
│ │ │ │ +
│ │ │ │ +
211 GenericIterator(const MutableIterator& other) : container_(other.container_), position_(other.position_)
│ │ │ │ +
212 {}
│ │ │ │ +
│ │ │ │ +
213
│ │ │ │ +
│ │ │ │ +
223 GenericIterator(const ConstIterator& other) : container_(other.container_), position_(other.position_)
│ │ │ │ +
224 {}
│ │ │ │ +
│ │ │ │ +
225
│ │ │ │ +
226 // Methods needed by the forward iterator
│ │ │ │ +
│ │ │ │ +
227 bool equals(const MutableIterator & other) const
│ │ │ │ +
228 {
│ │ │ │ +
229 return position_ == other.position_ && container_ == other.container_;
│ │ │ │ +
230 }
│ │ │ │ +
│ │ │ │ +
231
│ │ │ │ +
│ │ │ │ +
232 bool equals(const ConstIterator & other) const
│ │ │ │ +
233 {
│ │ │ │ +
234 return position_ == other.position_ && container_ == other.container_;
│ │ │ │ +
235 }
│ │ │ │ +
│ │ │ │ +
236
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
238 return container_->operator[](position_);
│ │ │ │ +
239 }
│ │ │ │ +
│ │ │ │ +
240
│ │ │ │ +
│ │ │ │ +
241 void increment(){
│ │ │ │ +
242 ++position_;
│ │ │ │ +
243 }
│ │ │ │ +
│ │ │ │ +
244
│ │ │ │ +
245 // Additional function needed by BidirectionalIterator
│ │ │ │ +
│ │ │ │ +
246 void decrement(){
│ │ │ │ +
247 --position_;
│ │ │ │ +
248 }
│ │ │ │ +
│ │ │ │ +
249
│ │ │ │ +
250 // Additional function needed by RandomAccessIterator
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
252 return container_->operator[](position_+i);
│ │ │ │ +
253 }
│ │ │ │ +
│ │ │ │ +
254
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
256 position_=position_+n;
│ │ │ │ +
257 }
│ │ │ │ +
│ │ │ │ +
258
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
260 {
│ │ │ │ +
261 assert(other.container_==container_);
│ │ │ │ +
262 return other.position_ - position_;
│ │ │ │ +
263 }
│ │ │ │ +
│ │ │ │ +
264
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
266 {
│ │ │ │ +
267 assert(other.container_==container_);
│ │ │ │ +
268 return other.position_ - position_;
│ │ │ │ +
269 }
│ │ │ │ +
│ │ │ │ +
270
│ │ │ │ +
271 private:
│ │ │ │ +
272 Container *container_;
│ │ │ │ +
273 DifferenceType position_;
│ │ │ │ +
274 };
│ │ │ │ +
│ │ │ │ +
275
│ │ │ │ +
278} // end namespace Dune
│ │ │ │ +
279
│ │ │ │ +
280#endif
│ │ │ │ +
This file implements iterator facade classes for writing stl conformant iterators.
│ │ │ │ +
STL namespace.
│ │ │ │ +
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ +
Get the 'const' version of a reference to a mutable object.
Definition genericiterator.hh:87
│ │ │ │ +
const R type
Definition genericiterator.hh:88
│ │ │ │ +
const R type
Definition genericiterator.hh:94
│ │ │ │ +
const R & type
Definition genericiterator.hh:100
│ │ │ │ +
const R & type
Definition genericiterator.hh:106
│ │ │ │ +
get the 'mutable' version of a reference to a const object
Definition genericiterator.hh:116
│ │ │ │ +
R type
Definition genericiterator.hh:117
│ │ │ │ +
R type
Definition genericiterator.hh:123
│ │ │ │ +
R & type
Definition genericiterator.hh:129
│ │ │ │ +
Generic class for stl-conforming iterators for container classes with operator[].
Definition genericiterator.hh:153
│ │ │ │ +
GenericIterator(const MutableIterator &other)
Copy constructor.
Definition genericiterator.hh:211
│ │ │ │ +
bool equals(const MutableIterator &other) const
Definition genericiterator.hh:227
│ │ │ │ +
Reference elementAt(DifferenceType i) const
Definition genericiterator.hh:251
│ │ │ │ +
void increment()
Definition genericiterator.hh:241
│ │ │ │ +
GenericIterator(const ConstIterator &other)
Copy constructor.
Definition genericiterator.hh:223
│ │ │ │ +
void advance(DifferenceType n)
Definition genericiterator.hh:255
│ │ │ │ +
GenericIterator(Container &cont, DifferenceType pos)
Constructor.
Definition genericiterator.hh:200
│ │ │ │ +
D DifferenceType
The type of the difference between two positions.
Definition genericiterator.hh:182
│ │ │ │ +
R Reference
The type of the reference to the values accessed.
Definition genericiterator.hh:187
│ │ │ │ +
DifferenceType distanceTo(const MutableIterator &other) const
Definition genericiterator.hh:259
│ │ │ │ +
C Container
The type of container we are an iterator for.
Definition genericiterator.hh:170
│ │ │ │ +
T Value
The value type of the iterator.
Definition genericiterator.hh:177
│ │ │ │ +
DifferenceType distanceTo(const ConstIterator &other) const
Definition genericiterator.hh:265
│ │ │ │ +
void decrement()
Definition genericiterator.hh:246
│ │ │ │ +
Reference dereference() const
Definition genericiterator.hh:237
│ │ │ │ +
bool equals(const ConstIterator &other) const
Definition genericiterator.hh:232
│ │ │ │ +
Base class for stl conformant forward iterators.
Definition iteratorfacades.hh:435
│ │ │ │ +
CRTP-Mixing class for stl conformant iterators of given iterator category.
Definition iteratorfacades.hh:1053
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,21 +1,270 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -collectivecommunication.hh │ │ │ │ │ +genericiterator.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ +2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ +3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -3// Will be removed after the 2.7 release │ │ │ │ │ -4#warning "Deprecated header, use #include instead!" │ │ │ │ │ -5#include │ │ │ │ │ -communication.hh │ │ │ │ │ -Implements an utility class that provides collective communication methods for │ │ │ │ │ -sequential programs. │ │ │ │ │ +4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +5#ifndef DUNE_GENERICITERATOR_HH │ │ │ │ │ +6#define DUNE_GENERICITERATOR_HH │ │ │ │ │ +7 │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10 │ │ │ │ │ +11namespace Dune { │ │ │ │ │ +12 │ │ │ │ │ +85 template │ │ │ │ │ +86 struct const_reference │ │ │ │ │ +87 { │ │ │ │ │ +88 typedef const R type; │ │ │ │ │ +89 }; │ │ │ │ │ +90 │ │ │ │ │ +91 template │ │ │ │ │ +92 struct const_reference │ │ │ │ │ +93 { │ │ │ │ │ +94 typedef const R type; │ │ │ │ │ +95 }; │ │ │ │ │ +96 │ │ │ │ │ +97 template │ │ │ │ │ +98 struct const_reference │ │ │ │ │ +99 { │ │ │ │ │ +100 typedef const R& type; │ │ │ │ │ +101 }; │ │ │ │ │ +102 │ │ │ │ │ +103 template │ │ │ │ │ +104 struct const_reference │ │ │ │ │ +105 { │ │ │ │ │ +106 typedef const R& type; │ │ │ │ │ +107 }; │ │ │ │ │ +108 │ │ │ │ │ +114 template │ │ │ │ │ +115 struct mutable_reference │ │ │ │ │ +116 { │ │ │ │ │ +117 typedef R type; │ │ │ │ │ +118 }; │ │ │ │ │ +119 │ │ │ │ │ +120 template │ │ │ │ │ +121 struct mutable_reference │ │ │ │ │ +122 { │ │ │ │ │ +123 typedef R type; │ │ │ │ │ +124 }; │ │ │ │ │ +125 │ │ │ │ │ +126 template │ │ │ │ │ +127 struct mutable_reference │ │ │ │ │ +128 { │ │ │ │ │ +129 typedef R& type; │ │ │ │ │ +130 }; │ │ │ │ │ +131 │ │ │ │ │ +132 template │ │ │ │ │ +133 struct mutable_reference │ │ │ │ │ +134 { │ │ │ │ │ +135 typedef R& type; │ │ │ │ │ +136 }; │ │ │ │ │ +137 │ │ │ │ │ +149 template class │ │ │ │ │ +IteratorFacade=RandomAccessIteratorFacade> │ │ │ │ │ +151 class GenericIterator : │ │ │ │ │ +152 public IteratorFacade,T,R,D> │ │ │ │ │ +153 { │ │ │ │ │ +154 friend class GenericIterator::type, typename │ │ │ │ │ +std::remove_const::type, typename mutable_reference::type, D, │ │ │ │ │ +IteratorFacade>; │ │ │ │ │ +155 friend class GenericIterator::type, │ │ │ │ │ +const typename std::remove_const::type, typename const_reference::type, │ │ │ │ │ +D, IteratorFacade>; │ │ │ │ │ +156 │ │ │ │ │ +157 typedef GenericIterator::type, typename std:: │ │ │ │ │ +remove_const::type, typename mutable_reference::type, D, IteratorFacade> │ │ │ │ │ +MutableIterator; │ │ │ │ │ +158 typedef GenericIterator::type, const │ │ │ │ │ +typename std::remove_const::type, typename const_reference::type, D, │ │ │ │ │ +IteratorFacade> ConstIterator; │ │ │ │ │ +159 │ │ │ │ │ +160 public: │ │ │ │ │ +161 │ │ │ │ │ +170 typedef C Container; │ │ │ │ │ +171 │ │ │ │ │ +177 typedef T Value; │ │ │ │ │ +178 │ │ │ │ │ +182 typedef D DifferenceType; │ │ │ │ │ +183 │ │ │ │ │ +187 typedef R Reference; │ │ │ │ │ +188 │ │ │ │ │ +189 // Constructors needed by the base iterators │ │ │ │ │ +190 GenericIterator() : container_(0), position_(0) │ │ │ │ │ +191 {} │ │ │ │ │ +192 │ │ │ │ │ +200 GenericIterator(Container& cont, DifferenceType pos) │ │ │ │ │ +201 : container_(&cont), position_(pos) │ │ │ │ │ +202 {} │ │ │ │ │ +203 │ │ │ │ │ +211 GenericIterator(const MutableIterator& other) : container_(other.container_ │ │ │ │ │ +), position_(other.position_) │ │ │ │ │ +212 {} │ │ │ │ │ +213 │ │ │ │ │ +223 GenericIterator(const ConstIterator& other) : container_(other.container_), │ │ │ │ │ +position_(other.position_) │ │ │ │ │ +224 {} │ │ │ │ │ +225 │ │ │ │ │ +226 // Methods needed by the forward iterator │ │ │ │ │ +227 bool equals(const MutableIterator & other) const │ │ │ │ │ +228 { │ │ │ │ │ +229 return position_ == other.position_ && container_ == other.container_; │ │ │ │ │ +230 } │ │ │ │ │ +231 │ │ │ │ │ +232 bool equals(const ConstIterator & other) const │ │ │ │ │ +233 { │ │ │ │ │ +234 return position_ == other.position_ && container_ == other.container_; │ │ │ │ │ +235 } │ │ │ │ │ +236 │ │ │ │ │ +237 Reference dereference() const { │ │ │ │ │ +238 return container_->operator[](position_); │ │ │ │ │ +239 } │ │ │ │ │ +240 │ │ │ │ │ +241 void increment(){ │ │ │ │ │ +242 ++position_; │ │ │ │ │ +243 } │ │ │ │ │ +244 │ │ │ │ │ +245 // Additional function needed by BidirectionalIterator │ │ │ │ │ +246 void decrement(){ │ │ │ │ │ +247 --position_; │ │ │ │ │ +248 } │ │ │ │ │ +249 │ │ │ │ │ +250 // Additional function needed by RandomAccessIterator │ │ │ │ │ +251 Reference elementAt(DifferenceType i) const { │ │ │ │ │ +252 return container_->operator[](position_+i); │ │ │ │ │ +253 } │ │ │ │ │ +254 │ │ │ │ │ +255 void advance(DifferenceType n){ │ │ │ │ │ +256 position_=position_+n; │ │ │ │ │ +257 } │ │ │ │ │ +258 │ │ │ │ │ +259 DifferenceType distanceTo(const MutableIterator& other) const │ │ │ │ │ +260 { │ │ │ │ │ +261 assert(other.container_==container_); │ │ │ │ │ +262 return other.position_ - position_; │ │ │ │ │ +263 } │ │ │ │ │ +264 │ │ │ │ │ +265 DifferenceType distanceTo(const ConstIterator& other) const │ │ │ │ │ +266 { │ │ │ │ │ +267 assert(other.container_==container_); │ │ │ │ │ +268 return other.position_ - position_; │ │ │ │ │ +269 } │ │ │ │ │ +270 │ │ │ │ │ +271 private: │ │ │ │ │ +272 Container *container_; │ │ │ │ │ +273 DifferenceType position_; │ │ │ │ │ +274 }; │ │ │ │ │ +275 │ │ │ │ │ +278} // end namespace Dune │ │ │ │ │ +279 │ │ │ │ │ +280#endif │ │ │ │ │ +iteratorfacades.hh │ │ │ │ │ +This file implements iterator facade classes for writing stl conformant │ │ │ │ │ +iterators. │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ +Dune │ │ │ │ │ +Dune namespace. │ │ │ │ │ +Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::const_reference │ │ │ │ │ +Get the 'const' version of a reference to a mutable object. │ │ │ │ │ +Definition genericiterator.hh:87 │ │ │ │ │ +Dune::const_reference::type │ │ │ │ │ +const R type │ │ │ │ │ +Definition genericiterator.hh:88 │ │ │ │ │ +Dune::const_reference<_const_R_>::type │ │ │ │ │ +const R type │ │ │ │ │ +Definition genericiterator.hh:94 │ │ │ │ │ +Dune::const_reference<_R_&_>::type │ │ │ │ │ +const R & type │ │ │ │ │ +Definition genericiterator.hh:100 │ │ │ │ │ +Dune::const_reference<_const_R_&_>::type │ │ │ │ │ +const R & type │ │ │ │ │ +Definition genericiterator.hh:106 │ │ │ │ │ +Dune::mutable_reference │ │ │ │ │ +get the 'mutable' version of a reference to a const object │ │ │ │ │ +Definition genericiterator.hh:116 │ │ │ │ │ +Dune::mutable_reference::type │ │ │ │ │ +R type │ │ │ │ │ +Definition genericiterator.hh:117 │ │ │ │ │ +Dune::mutable_reference<_const_R_>::type │ │ │ │ │ +R type │ │ │ │ │ +Definition genericiterator.hh:123 │ │ │ │ │ +Dune::mutable_reference<_R_&_>::type │ │ │ │ │ +R & type │ │ │ │ │ +Definition genericiterator.hh:129 │ │ │ │ │ +Dune::GenericIterator │ │ │ │ │ +Generic class for stl-conforming iterators for container classes with operator │ │ │ │ │ +[]. │ │ │ │ │ +Definition genericiterator.hh:153 │ │ │ │ │ +Dune::GenericIterator::GenericIterator │ │ │ │ │ +GenericIterator(const MutableIterator &other) │ │ │ │ │ +Copy constructor. │ │ │ │ │ +Definition genericiterator.hh:211 │ │ │ │ │ +Dune::GenericIterator::equals │ │ │ │ │ +bool equals(const MutableIterator &other) const │ │ │ │ │ +Definition genericiterator.hh:227 │ │ │ │ │ +Dune::GenericIterator::elementAt │ │ │ │ │ +Reference elementAt(DifferenceType i) const │ │ │ │ │ +Definition genericiterator.hh:251 │ │ │ │ │ +Dune::GenericIterator::increment │ │ │ │ │ +void increment() │ │ │ │ │ +Definition genericiterator.hh:241 │ │ │ │ │ +Dune::GenericIterator::GenericIterator │ │ │ │ │ +GenericIterator(const ConstIterator &other) │ │ │ │ │ +Copy constructor. │ │ │ │ │ +Definition genericiterator.hh:223 │ │ │ │ │ +Dune::GenericIterator::advance │ │ │ │ │ +void advance(DifferenceType n) │ │ │ │ │ +Definition genericiterator.hh:255 │ │ │ │ │ +Dune::GenericIterator::GenericIterator │ │ │ │ │ +GenericIterator(Container &cont, DifferenceType pos) │ │ │ │ │ +Constructor. │ │ │ │ │ +Definition genericiterator.hh:200 │ │ │ │ │ +Dune::GenericIterator::DifferenceType │ │ │ │ │ +D DifferenceType │ │ │ │ │ +The type of the difference between two positions. │ │ │ │ │ +Definition genericiterator.hh:182 │ │ │ │ │ +Dune::GenericIterator::Reference │ │ │ │ │ +R Reference │ │ │ │ │ +The type of the reference to the values accessed. │ │ │ │ │ +Definition genericiterator.hh:187 │ │ │ │ │ +Dune::GenericIterator::distanceTo │ │ │ │ │ +DifferenceType distanceTo(const MutableIterator &other) const │ │ │ │ │ +Definition genericiterator.hh:259 │ │ │ │ │ +Dune::GenericIterator::Container │ │ │ │ │ +C Container │ │ │ │ │ +The type of container we are an iterator for. │ │ │ │ │ +Definition genericiterator.hh:170 │ │ │ │ │ +Dune::GenericIterator::Value │ │ │ │ │ +T Value │ │ │ │ │ +The value type of the iterator. │ │ │ │ │ +Definition genericiterator.hh:177 │ │ │ │ │ +Dune::GenericIterator::distanceTo │ │ │ │ │ +DifferenceType distanceTo(const ConstIterator &other) const │ │ │ │ │ +Definition genericiterator.hh:265 │ │ │ │ │ +Dune::GenericIterator::decrement │ │ │ │ │ +void decrement() │ │ │ │ │ +Definition genericiterator.hh:246 │ │ │ │ │ +Dune::GenericIterator::dereference │ │ │ │ │ +Reference dereference() const │ │ │ │ │ +Definition genericiterator.hh:237 │ │ │ │ │ +Dune::GenericIterator::equals │ │ │ │ │ +bool equals(const ConstIterator &other) const │ │ │ │ │ +Definition genericiterator.hh:232 │ │ │ │ │ +Dune::RandomAccessIteratorFacade │ │ │ │ │ +Base class for stl conformant forward iterators. │ │ │ │ │ +Definition iteratorfacades.hh:435 │ │ │ │ │ +Dune::IteratorFacade │ │ │ │ │ +CRTP-Mixing class for stl conformant iterators of given iterator category. │ │ │ │ │ +Definition iteratorfacades.hh:1053 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00086.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: future.hh File Reference │ │ │ │ +dune-common: propertymap.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,49 +65,83 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
future.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
propertymap.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ -
#include <memory>
│ │ │ │ +
#include <cstddef>
│ │ │ │ +#include <iterator>
│ │ │ │ #include <type_traits>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

class  Dune::InvalidFutureException
 This exception is thrown when ready(), wait() or get() is called on an invalid future. A future is valid until get() is called and if it is not default-constructed and it was not moved from. More...
struct  Dune::PropertyMapTraits< PM >
 
class  Dune::Future< T >
 Type-erasure for future-like objects. A future-like object is a object satisfying the interface of FutureBase. More...
struct  Dune::ReadablePropertyMapTag
 Tag for the category of readable property maps. More...
 
class  Dune::PseudoFuture< T >
 A wrapper-class for a object which is ready immediately. More...
struct  Dune::WritablePropertyMapTag
 Tag for the category of writable property maps. More...
 
class  Dune::PseudoFuture< void >
struct  Dune::ReadWritePropertyMapTag
 Tag for the category of readable and writable property maps. More...
 
struct  Dune::LvaluePropertyMapTag
 Tag for the category of lvalue property maps. More...
 
struct  Dune::PropertyMapTraits< T * >
 
struct  Dune::PropertyMapTraits< const T * >
 
struct  Dune::RAPropertyMapHelper< Reference, PropertyMap >
 
class  Dune::IteratorPropertyMap< RAI, IM, T, R >
 Adapter to turn a random access iterator into a property map. More...
 
class  Dune::AssociativePropertyMap< T >
 An adapter to turn an unique associative container into a property map. More...
 
class  Dune::ConstAssociativePropertyMap< T >
 An adaptor to turn an unique associative container into a property map. More...
 
struct  Dune::IdentityMap
 A property map that applies the identity function to integers. More...
 
struct  Dune::PropertyMapTypeSelector< T, C >
 Selector for the property map type. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

template<class Reference , class PropertyMap , class Key >
Reference Dune::get (const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key &key)
 
template<class Reference , class PropertyMap , class Key , class Value >
void Dune::put (const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key &key, const Value &value)
 
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,34 +1,65 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -future.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +propertymap.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -class   Dune::InvalidFutureException │ │ │ │ │ - This exception is thrown when ready(), wait() or get() is called on an │ │ │ │ │ -  invalid future. A future is valid until get() is called and if it is │ │ │ │ │ - not default-constructed and it was not moved from. More... │ │ │ │ │ -  │ │ │ │ │ -class   Dune::Future<_T_> │ │ │ │ │ -  Type-erasure for future-like objects. A future-like object is a object │ │ │ │ │ - satisfying the interface of FutureBase. More... │ │ │ │ │ +struct   Dune::PropertyMapTraits<_PM_> │ │ │ │ │   │ │ │ │ │ -class   Dune::PseudoFuture<_T_> │ │ │ │ │ -  A wrapper-class for a object which is ready immediately. More... │ │ │ │ │ +struct   Dune::ReadablePropertyMapTag │ │ │ │ │ +  Tag for the category of readable property maps. More... │ │ │ │ │   │ │ │ │ │ -class   Dune::PseudoFuture<_void_> │ │ │ │ │ +struct   Dune::WritablePropertyMapTag │ │ │ │ │ +  Tag for the category of writable property maps. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::ReadWritePropertyMapTag │ │ │ │ │ +  Tag for the category of readable and writable property maps. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::LvaluePropertyMapTag │ │ │ │ │ +  Tag for the category of lvalue property maps. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::PropertyMapTraits<_T_*_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::PropertyMapTraits<_const_T_*_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::RAPropertyMapHelper<_Reference,_PropertyMap_> │ │ │ │ │ +  │ │ │ │ │ + class   Dune::IteratorPropertyMap<_RAI,_IM,_T,_R_> │ │ │ │ │ +  Adapter to turn a random access iterator into a property map. More... │ │ │ │ │ +  │ │ │ │ │ + class   Dune::AssociativePropertyMap<_T_> │ │ │ │ │ +  An adapter to turn an unique associative container into a property │ │ │ │ │ + map. More... │ │ │ │ │ +  │ │ │ │ │ + class   Dune::ConstAssociativePropertyMap<_T_> │ │ │ │ │ +  An adaptor to turn an unique associative container into a property │ │ │ │ │ + map. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::IdentityMap │ │ │ │ │ +  A property map that applies the identity function to integers. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::PropertyMapTypeSelector<_T,_C_> │ │ │ │ │ +  Selector for the property map type. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ +Reference  Dune::get (const RAPropertyMapHelper< Reference, PropertyMap > │ │ │ │ │ + &pmap, const Key &key) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + void  Dune::put (const RAPropertyMapHelper< Reference, PropertyMap > │ │ │ │ │ + &pmap, const Key &key, const Value &value) │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00086_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: future.hh Source File │ │ │ │ +dune-common: propertymap.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,256 +70,311 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
future.hh
│ │ │ │ +
propertymap.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PARALLEL_FUTURE_HH
│ │ │ │ -
6#define DUNE_COMMON_PARALLEL_FUTURE_HH
│ │ │ │ +
5#ifndef DUNE_PROPERTYMAP_HH
│ │ │ │ +
6#define DUNE_PROPERTYMAP_HH
│ │ │ │
7
│ │ │ │ -
8#include <memory>
│ │ │ │ -
9#include <type_traits>
│ │ │ │ -
10
│ │ │ │ - │ │ │ │ -
12
│ │ │ │ -
13namespace Dune{
│ │ │ │ +
8#include <cstddef>
│ │ │ │ +
9#include <iterator>
│ │ │ │ +
10#include <type_traits>
│ │ │ │ +
11
│ │ │ │ +
12namespace Dune
│ │ │ │ +
13{
│ │ │ │
14
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
20 {};
│ │ │ │ -
│ │ │ │ -
21
│ │ │ │ -
22 // forward declaration
│ │ │ │ -
23 template<class T>
│ │ │ │ -
24 class PseudoFuture;
│ │ │ │ -
25
│ │ │ │ -
29 template<class T>
│ │ │ │ -
│ │ │ │ -
30 class Future{
│ │ │ │ -
31 // Future interface:
│ │ │ │ -
32 class FutureBase{
│ │ │ │ -
33 public:
│ │ │ │ -
34 virtual ~FutureBase() = default;
│ │ │ │ -
35 virtual void wait() = 0;
│ │ │ │ -
36 virtual bool ready() const = 0;
│ │ │ │ -
37 virtual bool valid() const = 0;
│ │ │ │ -
38 virtual T get() = 0;
│ │ │ │ -
39 };
│ │ │ │ -
40
│ │ │ │ -
41 // model class
│ │ │ │ -
42 template<class F>
│ │ │ │ -
43 class FutureModel
│ │ │ │ -
44 : public FutureBase
│ │ │ │ -
45 {
│ │ │ │ -
46 F _future;
│ │ │ │ -
47 public:
│ │ │ │ -
48 FutureModel(F&& f)
│ │ │ │ -
49 : _future(std::forward<F>(f))
│ │ │ │ -
50 {}
│ │ │ │ -
51
│ │ │ │ -
52 virtual void wait() override
│ │ │ │ -
53 {
│ │ │ │ -
54 _future.wait();
│ │ │ │ -
55 }
│ │ │ │ -
56
│ │ │ │ -
57 virtual bool ready() const override
│ │ │ │ -
58 {
│ │ │ │ -
59 return _future.ready();
│ │ │ │ -
60 }
│ │ │ │ -
61
│ │ │ │ -
62 virtual bool valid() const override
│ │ │ │ -
63 {
│ │ │ │ -
64 return _future.valid();
│ │ │ │ -
65 }
│ │ │ │ -
66
│ │ │ │ -
67 virtual T get() override{
│ │ │ │ -
68 return (T)_future.get();
│ │ │ │ -
69 }
│ │ │ │ -
70 };
│ │ │ │ -
71
│ │ │ │ -
72 std::unique_ptr<FutureBase> _future;
│ │ │ │ -
73 public:
│ │ │ │ -
74 template<class F>
│ │ │ │ -
│ │ │ │ -
75 Future(F&& f)
│ │ │ │ -
76 : _future(std::make_unique<FutureModel<F>>(std::forward<F>(f)))
│ │ │ │ -
77 {}
│ │ │ │ -
│ │ │ │ -
78
│ │ │ │ -
79 template<class U, std::enable_if_t<std::is_same<U,T>::value && !std::is_same<T,void>::value>>
│ │ │ │ -
│ │ │ │ -
80 Future(U&& data)
│ │ │ │ -
81 : _future(std::make_unique<FutureModel<PseudoFuture<T>>>(PseudoFuture<T>(std::forward<U>(data))))
│ │ │ │ -
82 {}
│ │ │ │ -
│ │ │ │ -
83
│ │ │ │ -
84 Future() = default;
│ │ │ │ -
85
│ │ │ │ -
│ │ │ │ -
89 void wait(){
│ │ │ │ -
90 _future->wait();
│ │ │ │ -
91 }
│ │ │ │ -
│ │ │ │ -
92
│ │ │ │ -
│ │ │ │ -
97 T get() {
│ │ │ │ -
98 return _future->get();
│ │ │ │ -
99 }
│ │ │ │ -
│ │ │ │ -
100
│ │ │ │ -
│ │ │ │ -
105 bool ready() const {
│ │ │ │ -
106 return _future->ready();
│ │ │ │ -
107 }
│ │ │ │ -
│ │ │ │ -
108
│ │ │ │ -
│ │ │ │ -
114 bool valid() const {
│ │ │ │ -
115 if(_future)
│ │ │ │ -
116 return _future->valid();
│ │ │ │ -
117 return false;
│ │ │ │ -
118 }
│ │ │ │ -
│ │ │ │ -
119 };
│ │ │ │ -
│ │ │ │ -
120
│ │ │ │ -
123 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
125 bool valid_;
│ │ │ │ -
126 T data_;
│ │ │ │ -
127 public:
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
129 valid_(false)
│ │ │ │ -
130 {}
│ │ │ │ +
15 template<class PM>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
17 {
│ │ │ │ +
21 typedef typename PM::KeyType KeyType;
│ │ │ │ +
25 typedef typename PM::ValueType ValueType;
│ │ │ │ +
29 typedef typename PM::Reference Reference;
│ │ │ │ +
33 typedef typename PM::Category Category;
│ │ │ │ +
34 };
│ │ │ │ +
│ │ │ │ +
35
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
38 {};
│ │ │ │ +
│ │ │ │ +
39
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
42 {};
│ │ │ │ +
│ │ │ │ +
43
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ +
50 {};
│ │ │ │
│ │ │ │ +
51
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ +
57 {};
│ │ │ │ +
│ │ │ │ +
58
│ │ │ │ +
59 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
61 {
│ │ │ │ +
62 typedef T ValueType;
│ │ │ │ + │ │ │ │ +
64 typedef std::ptrdiff_t KeyType;
│ │ │ │ + │ │ │ │ +
66 };
│ │ │ │ +
│ │ │ │ +
67
│ │ │ │ +
68
│ │ │ │ +
69 template<class T>
│ │ │ │ +
│ │ │ │ +
70 struct PropertyMapTraits<const T*>
│ │ │ │ +
71 {
│ │ │ │ +
72 typedef T ValueType;
│ │ │ │ +
73 typedef const ValueType& Reference;
│ │ │ │ +
74 typedef std::ptrdiff_t KeyType;
│ │ │ │ + │ │ │ │ +
76 };
│ │ │ │ +
│ │ │ │ +
77
│ │ │ │ +
78 template<class Reference, class PropertyMap>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
80 {};
│ │ │ │ +
│ │ │ │ +
81
│ │ │ │ +
82 template<class Reference, class PropertyMap, class Key>
│ │ │ │ +
83 inline Reference
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
85 const Key& key)
│ │ │ │ +
86 {
│ │ │ │ +
87 return static_cast<const PropertyMap&>(pmap)[key];
│ │ │ │ +
88 }
│ │ │ │ +
│ │ │ │ +
89
│ │ │ │ +
90 template<class Reference, class PropertyMap, class Key, class Value>
│ │ │ │ +
91 inline void
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
93 const Key& key, const Value& value)
│ │ │ │ +
94 {
│ │ │ │ +
95 static_assert(std::is_convertible<typename PropertyMap::Category,WritablePropertyMapTag>::value,
│ │ │ │ +
96 "WritablePropertyMapTag required!");
│ │ │ │ +
97 static_cast<const PropertyMap&>(pmap)[key] = value;
│ │ │ │ +
98 }
│ │ │ │ +
│ │ │ │ +
99
│ │ │ │ +
103 template<class RAI, class IM,
│ │ │ │ +
104 class T = typename std::iterator_traits<RAI>::value_type,
│ │ │ │ +
105 class R = typename std::iterator_traits<RAI>::reference>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
107 : public RAPropertyMapHelper<R,IteratorPropertyMap<RAI,IM,T,R> >
│ │ │ │ +
108 {
│ │ │ │ +
109 public:
│ │ │ │ + │ │ │ │ +
114
│ │ │ │ +
120 typedef IM IndexMap;
│ │ │ │ +
121
│ │ │ │ +
125 typedef typename IndexMap::KeyType KeyType;
│ │ │ │ +
126
│ │ │ │ +
130 typedef T ValueType;
│ │ │ │
131
│ │ │ │ -
132 template<class U>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
134 valid_(true),
│ │ │ │ -
135 data_(std::forward<U>(u))
│ │ │ │ -
136 {}
│ │ │ │ -
│ │ │ │ -
137
│ │ │ │ -
│ │ │ │ -
138 void wait() {
│ │ │ │ -
139 if(!valid_)
│ │ │ │ -
140 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid");
│ │ │ │ -
141 }
│ │ │ │ -
│ │ │ │ -
142
│ │ │ │ -
│ │ │ │ -
143 bool ready() const {
│ │ │ │ -
144 if(!valid_)
│ │ │ │ -
145 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid");
│ │ │ │ -
146 return true;
│ │ │ │ -
147 }
│ │ │ │ -
│ │ │ │ -
148
│ │ │ │ +
135 typedef R Reference;
│ │ │ │ +
136
│ │ │ │ + │ │ │ │ +
141
│ │ │ │
│ │ │ │ -
149 T get() {
│ │ │ │ -
150 if(!valid_)
│ │ │ │ -
151 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid");
│ │ │ │ -
152 valid_ = false;
│ │ │ │ -
153 return std::forward<T>(data_);
│ │ │ │ -
154 }
│ │ │ │ -
│ │ │ │ -
155
│ │ │ │ -
│ │ │ │ -
156 bool valid() const {
│ │ │ │ -
157 return valid_;
│ │ │ │ -
158 }
│ │ │ │ -
│ │ │ │ -
159 };
│ │ │ │ -
│ │ │ │ -
160
│ │ │ │ -
161 template<>
│ │ │ │ -
│ │ │ │ -
162 class PseudoFuture<void>{
│ │ │ │ -
163 bool valid_;
│ │ │ │ -
164 public:
│ │ │ │ -
│ │ │ │ -
165 PseudoFuture(bool valid = false) :
│ │ │ │ -
166 valid_(valid)
│ │ │ │ -
167 {}
│ │ │ │ -
│ │ │ │ -
168
│ │ │ │ -
│ │ │ │ -
169 void wait(){
│ │ │ │ -
170 if(!valid_)
│ │ │ │ -
171 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid");
│ │ │ │ -
172 }
│ │ │ │ -
│ │ │ │ -
│ │ │ │ -
173 bool ready() const{
│ │ │ │ -
174 if(!valid_)
│ │ │ │ -
175 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid");
│ │ │ │ -
176 return true;
│ │ │ │ -
177 }
│ │ │ │ -
│ │ │ │ -
178
│ │ │ │ -
│ │ │ │ -
179 void get(){
│ │ │ │ -
180 if(!valid_)
│ │ │ │ -
181 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid");
│ │ │ │ -
182 valid_ = false;
│ │ │ │ -
183 }
│ │ │ │ -
│ │ │ │ -
184
│ │ │ │ -
│ │ │ │ -
185 bool valid() const{
│ │ │ │ -
186 return valid_;
│ │ │ │ -
187 }
│ │ │ │ -
│ │ │ │ -
188 };
│ │ │ │ -
│ │ │ │ -
189}
│ │ │ │ -
190
│ │ │ │ -
191#endif // DUNE_COMMON_PARALLEL_FUTURE_HH
│ │ │ │ -
A few common exception classes.
│ │ │ │ -
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ -
STL namespace.
│ │ │ │ + │ │ │ │ +
150 const IndexMap& im=IndexMap())
│ │ │ │ +
151 : iter_(iter), indexMap_(im)
│ │ │ │ +
152 {}
│ │ │ │ +
│ │ │ │ +
153
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
156 : iter_(), indexMap_()
│ │ │ │ +
157 {}
│ │ │ │ +
│ │ │ │ +
158
│ │ │ │ +
│ │ │ │ +
160 inline Reference operator[](KeyType key) const
│ │ │ │ +
161 {
│ │ │ │ +
162 return *(iter_ + get(indexMap_, key));
│ │ │ │ +
163 }
│ │ │ │ +
│ │ │ │ +
164
│ │ │ │ +
165 private:
│ │ │ │ + │ │ │ │ +
169 IndexMap indexMap_;
│ │ │ │ +
170 };
│ │ │ │ +
│ │ │ │ +
171
│ │ │ │ +
176 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
178 : RAPropertyMapHelper<typename T::value_type::second_type&,
│ │ │ │ +
179 AssociativePropertyMap<T> >
│ │ │ │ +
180 {
│ │ │ │ +
184 typedef T UniqueAssociativeContainer;
│ │ │ │ +
185
│ │ │ │ +
189 typedef typename UniqueAssociativeContainer::value_type::first_type
│ │ │ │ +
190 KeyType;
│ │ │ │ +
191
│ │ │ │ +
195 typedef typename UniqueAssociativeContainer::value_type::second_type
│ │ │ │ +
196 ValueType;
│ │ │ │ +
197
│ │ │ │ +
201 typedef ValueType& Reference;
│ │ │ │ +
202
│ │ │ │ + │ │ │ │ +
207
│ │ │ │ + │ │ │ │ +
210 : map_(0)
│ │ │ │ +
211 {}
│ │ │ │ +
212
│ │ │ │ +
214 inline AssociativePropertyMap(UniqueAssociativeContainer& map)
│ │ │ │ +
215 : map_(&map)
│ │ │ │ +
216 {}
│ │ │ │ +
217
│ │ │ │ +
222 inline Reference operator[](KeyType key) const
│ │ │ │ +
223 {
│ │ │ │ +
224 return map_->find(key)->second;
│ │ │ │ +
225 }
│ │ │ │ +
226 private:
│ │ │ │ +
227 UniqueAssociativeContainer* map_;
│ │ │ │ +
228 };
│ │ │ │ +
│ │ │ │ +
229
│ │ │ │ +
234 template<typename T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
236 : RAPropertyMapHelper<const typename T::value_type::second_type&,
│ │ │ │ +
237 ConstAssociativePropertyMap<T> >
│ │ │ │ +
238 {
│ │ │ │ +
242 typedef T UniqueAssociativeContainer;
│ │ │ │ +
243
│ │ │ │ +
247 typedef typename UniqueAssociativeContainer::value_type::first_type
│ │ │ │ +
248 KeyType;
│ │ │ │ +
249
│ │ │ │ +
253 typedef typename UniqueAssociativeContainer::value_type::second_type
│ │ │ │ +
254 ValueType;
│ │ │ │ +
255
│ │ │ │ +
259 typedef const ValueType& Reference;
│ │ │ │ +
260
│ │ │ │ + │ │ │ │ +
265
│ │ │ │ + │ │ │ │ +
268 : map_(0)
│ │ │ │ +
269 {}
│ │ │ │ +
270
│ │ │ │ +
272 inline ConstAssociativePropertyMap(const UniqueAssociativeContainer& map)
│ │ │ │ +
273 : map_(&map)
│ │ │ │ +
274 {}
│ │ │ │ +
275
│ │ │ │ +
280 inline Reference operator[](KeyType key) const
│ │ │ │ +
281 {
│ │ │ │ +
282 return map_->find(key)->second;
│ │ │ │ +
283 }
│ │ │ │ +
284 private:
│ │ │ │ +
285 const UniqueAssociativeContainer* map_;
│ │ │ │ +
286 };
│ │ │ │ +
│ │ │ │ +
287
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
292 : public RAPropertyMapHelper<std::size_t, IdentityMap>
│ │ │ │ +
293 {
│ │ │ │ +
295 typedef std::size_t KeyType;
│ │ │ │ +
296
│ │ │ │ +
298 typedef std::size_t ValueType;
│ │ │ │ +
299
│ │ │ │ +
301 typedef std::size_t Reference;
│ │ │ │ +
302
│ │ │ │ + │ │ │ │ +
305
│ │ │ │ +
│ │ │ │ +
306 inline ValueType operator[](const KeyType& key) const
│ │ │ │ +
307 {
│ │ │ │ +
308 return key;
│ │ │ │ +
309 }
│ │ │ │ +
│ │ │ │ +
310 };
│ │ │ │ +
│ │ │ │ +
311
│ │ │ │ +
312
│ │ │ │ +
318 template<typename T, typename C>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
320 {
│ │ │ │ +
324 typedef T Tag;
│ │ │ │ +
329 typedef C Container;
│ │ │ │ +
330 };
│ │ │ │ +
│ │ │ │ +
331
│ │ │ │ +
332}
│ │ │ │ +
333
│ │ │ │ +
334#endif
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ +
void put(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key &key, const Value &value)
Definition propertymap.hh:92
│ │ │ │
constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< std::size_t, pos >={})
Return the entry at position pos of the given sequence.
Definition integersequence.hh:22
│ │ │ │ -
Default exception if a function was called while the object is not in a valid state for that function...
Definition exceptions.hh:281
│ │ │ │ -
This exception is thrown when ready(), wait() or get() is called on an invalid future....
Definition future.hh:20
│ │ │ │ -
A wrapper-class for a object which is ready immediately.
Definition future.hh:124
│ │ │ │ -
bool ready() const
Definition future.hh:143
│ │ │ │ -
T get()
Definition future.hh:149
│ │ │ │ -
PseudoFuture(U &&u)
Definition future.hh:133
│ │ │ │ -
PseudoFuture()
Definition future.hh:128
│ │ │ │ -
void wait()
Definition future.hh:138
│ │ │ │ -
bool valid() const
Definition future.hh:156
│ │ │ │ -
Type-erasure for future-like objects. A future-like object is a object satisfying the interface of Fu...
Definition future.hh:30
│ │ │ │ -
bool ready() const
Definition future.hh:105
│ │ │ │ -
void wait()
wait until the future is ready
Definition future.hh:89
│ │ │ │ -
Future(U &&data)
Definition future.hh:80
│ │ │ │ -
T get()
Waits until the future is ready and returns the resulting value.
Definition future.hh:97
│ │ │ │ -
Future()=default
│ │ │ │ -
bool valid() const
Checks whether the future is valid. I.e. ‘get()’ was not called on that future and when it was not de...
Definition future.hh:114
│ │ │ │ -
Future(F &&f)
Definition future.hh:75
│ │ │ │ -
bool ready() const
Definition future.hh:173
│ │ │ │ -
bool valid() const
Definition future.hh:185
│ │ │ │ -
void get()
Definition future.hh:179
│ │ │ │ -
PseudoFuture(bool valid=false)
Definition future.hh:165
│ │ │ │ -
void wait()
Definition future.hh:169
│ │ │ │ +
Definition propertymap.hh:17
│ │ │ │ +
PM::ValueType ValueType
The type of the values of the property map.
Definition propertymap.hh:25
│ │ │ │ +
PM::Category Category
The category the property map belongs to.
Definition propertymap.hh:33
│ │ │ │ +
PM::Reference Reference
The type of the reference to the values.
Definition propertymap.hh:29
│ │ │ │ +
PM::KeyType KeyType
The type of the key of the property map.
Definition propertymap.hh:21
│ │ │ │ +
Tag for the category of readable property maps.
Definition propertymap.hh:38
│ │ │ │ +
Tag for the category of writable property maps.
Definition propertymap.hh:42
│ │ │ │ +
Tag for the category of readable and writable property maps.
Definition propertymap.hh:50
│ │ │ │ +
Tag for the category of lvalue property maps.
Definition propertymap.hh:57
│ │ │ │ +
ValueType & Reference
Definition propertymap.hh:63
│ │ │ │ +
std::ptrdiff_t KeyType
Definition propertymap.hh:64
│ │ │ │ +
T ValueType
Definition propertymap.hh:62
│ │ │ │ +
LvaluePropertyMapTag Category
Definition propertymap.hh:65
│ │ │ │ +
std::ptrdiff_t KeyType
Definition propertymap.hh:74
│ │ │ │ +
const ValueType & Reference
Definition propertymap.hh:73
│ │ │ │ +
T ValueType
Definition propertymap.hh:72
│ │ │ │ +
LvaluePropertyMapTag Category
Definition propertymap.hh:75
│ │ │ │ +
Definition propertymap.hh:80
│ │ │ │ +
Adapter to turn a random access iterator into a property map.
Definition propertymap.hh:108
│ │ │ │ +
IndexMap::KeyType KeyType
The key type of the property map.
Definition propertymap.hh:125
│ │ │ │ +
R Reference
The reference type of the property map.
Definition propertymap.hh:135
│ │ │ │ +
T ValueType
The value type of the property map.
Definition propertymap.hh:130
│ │ │ │ +
Reference operator[](KeyType key) const
Access the a value by reference.
Definition propertymap.hh:160
│ │ │ │ +
IteratorPropertyMap(RandomAccessIterator iter, const IndexMap &im=IndexMap())
Constructor.
Definition propertymap.hh:149
│ │ │ │ +
IteratorPropertyMap()
Constructor.
Definition propertymap.hh:155
│ │ │ │ +
IM IndexMap
The type of the index map.
Definition propertymap.hh:120
│ │ │ │ +
RAI RandomAccessIterator
The type of the random access iterator.
Definition propertymap.hh:113
│ │ │ │ +
LvaluePropertyMapTag Category
The category of this property map.
Definition propertymap.hh:140
│ │ │ │ +
An adapter to turn an unique associative container into a property map.
Definition propertymap.hh:180
│ │ │ │ +
An adaptor to turn an unique associative container into a property map.
Definition propertymap.hh:238
│ │ │ │ +
A property map that applies the identity function to integers.
Definition propertymap.hh:293
│ │ │ │ +
std::size_t ValueType
The value type of the map.
Definition propertymap.hh:298
│ │ │ │ +
std::size_t KeyType
The key type of the map.
Definition propertymap.hh:295
│ │ │ │ +
ValueType operator[](const KeyType &key) const
Definition propertymap.hh:306
│ │ │ │ +
std::size_t Reference
The reference type of the map.
Definition propertymap.hh:301
│ │ │ │ +
ReadablePropertyMapTag Category
The category of the map.
Definition propertymap.hh:304
│ │ │ │ +
Selector for the property map type.
Definition propertymap.hh:320
│ │ │ │ +
T Tag
the tag identifying the property.
Definition propertymap.hh:324
│ │ │ │ +
C Container
The container type to whose entries the properties are attached.
Definition propertymap.hh:329
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,267 +1,368 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -future.hh │ │ │ │ │ +propertymap.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PARALLEL_FUTURE_HH │ │ │ │ │ -6#define DUNE_COMMON_PARALLEL_FUTURE_HH │ │ │ │ │ +5#ifndef DUNE_PROPERTYMAP_HH │ │ │ │ │ +6#define DUNE_PROPERTYMAP_HH │ │ │ │ │ 7 │ │ │ │ │ -8#include │ │ │ │ │ -9#include │ │ │ │ │ -10 │ │ │ │ │ -11#include │ │ │ │ │ -12 │ │ │ │ │ -13namespace Dune{ │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11 │ │ │ │ │ +12namespace Dune │ │ │ │ │ +13{ │ │ │ │ │ 14 │ │ │ │ │ -19 class InvalidFutureException : public InvalidStateException │ │ │ │ │ -20 {}; │ │ │ │ │ -21 │ │ │ │ │ -22 // forward declaration │ │ │ │ │ -23 template │ │ │ │ │ -24 class PseudoFuture; │ │ │ │ │ -25 │ │ │ │ │ -29 template │ │ │ │ │ -30 class Future{ │ │ │ │ │ -31 // Future interface: │ │ │ │ │ -32 class FutureBase{ │ │ │ │ │ -33 public: │ │ │ │ │ -34 virtual ~FutureBase() = default; │ │ │ │ │ -35 virtual void wait() = 0; │ │ │ │ │ -36 virtual bool ready() const = 0; │ │ │ │ │ -37 virtual bool valid() const = 0; │ │ │ │ │ -38 virtual T get() = 0; │ │ │ │ │ -39 }; │ │ │ │ │ -40 │ │ │ │ │ -41 // model class │ │ │ │ │ -42 template │ │ │ │ │ -43 class FutureModel │ │ │ │ │ -44 : public FutureBase │ │ │ │ │ -45 { │ │ │ │ │ -46 F _future; │ │ │ │ │ -47 public: │ │ │ │ │ -48 FutureModel(F&& f) │ │ │ │ │ -49 : _future(std::forward(f)) │ │ │ │ │ -50 {} │ │ │ │ │ +15 template │ │ │ │ │ +16 struct PropertyMapTraits │ │ │ │ │ +17 { │ │ │ │ │ +21 typedef typename PM::KeyType KeyType; │ │ │ │ │ +25 typedef typename PM::ValueType ValueType; │ │ │ │ │ +29 typedef typename PM::Reference Reference; │ │ │ │ │ +33 typedef typename PM::Category Category; │ │ │ │ │ +34 }; │ │ │ │ │ +35 │ │ │ │ │ +37 struct ReadablePropertyMapTag │ │ │ │ │ +38 {}; │ │ │ │ │ +39 │ │ │ │ │ +41 struct WritablePropertyMapTag │ │ │ │ │ +42 {}; │ │ │ │ │ +43 │ │ │ │ │ +48 struct ReadWritePropertyMapTag │ │ │ │ │ +49 : public ReadablePropertyMapTag, public WritablePropertyMapTag │ │ │ │ │ +50 {}; │ │ │ │ │ 51 │ │ │ │ │ -52 virtual void wait() override │ │ │ │ │ -53 { │ │ │ │ │ -54 _future.wait(); │ │ │ │ │ -55 } │ │ │ │ │ -56 │ │ │ │ │ -57 virtual bool ready() const override │ │ │ │ │ -58 { │ │ │ │ │ -59 return _future.ready(); │ │ │ │ │ -60 } │ │ │ │ │ -61 │ │ │ │ │ -62 virtual bool valid() const override │ │ │ │ │ -63 { │ │ │ │ │ -64 return _future.valid(); │ │ │ │ │ -65 } │ │ │ │ │ -66 │ │ │ │ │ -67 virtual T get() override{ │ │ │ │ │ -68 return (T)_future.get(); │ │ │ │ │ -69 } │ │ │ │ │ -70 }; │ │ │ │ │ -71 │ │ │ │ │ -72 std::unique_ptr _future; │ │ │ │ │ -73 public: │ │ │ │ │ -74 template │ │ │ │ │ -75 Future(F&& f) │ │ │ │ │ -76 : _future(std::make_unique>(std::forward(f))) │ │ │ │ │ -77 {} │ │ │ │ │ -78 │ │ │ │ │ -79 template::value && !std::is_ │ │ │ │ │ -same::value>> │ │ │ │ │ -80 Future(U&& data) │ │ │ │ │ -81 : _future(std::make_unique>>(PseudoFuture │ │ │ │ │ -(std::forward(data)))) │ │ │ │ │ -82 {} │ │ │ │ │ -83 │ │ │ │ │ -84 Future() = default; │ │ │ │ │ -85 │ │ │ │ │ -89 void wait(){ │ │ │ │ │ -90 _future->wait(); │ │ │ │ │ -91 } │ │ │ │ │ -92 │ │ │ │ │ -97 T get() { │ │ │ │ │ -98 return _future->get(); │ │ │ │ │ -99 } │ │ │ │ │ -100 │ │ │ │ │ -105 bool ready() const { │ │ │ │ │ -106 return _future->ready(); │ │ │ │ │ -107 } │ │ │ │ │ -108 │ │ │ │ │ -114 bool valid() const { │ │ │ │ │ -115 if(_future) │ │ │ │ │ -116 return _future->valid(); │ │ │ │ │ -117 return false; │ │ │ │ │ -118 } │ │ │ │ │ -119 }; │ │ │ │ │ -120 │ │ │ │ │ -123 template │ │ │ │ │ -124 class PseudoFuture{ │ │ │ │ │ -125 bool valid_; │ │ │ │ │ -126 T data_; │ │ │ │ │ -127 public: │ │ │ │ │ -128 PseudoFuture() : │ │ │ │ │ -129 valid_(false) │ │ │ │ │ -130 {} │ │ │ │ │ +55 struct LvaluePropertyMapTag │ │ │ │ │ +56 : public ReadWritePropertyMapTag │ │ │ │ │ +57 {}; │ │ │ │ │ +58 │ │ │ │ │ +59 template │ │ │ │ │ +60 struct PropertyMapTraits │ │ │ │ │ +61 { │ │ │ │ │ +62 typedef T ValueType; │ │ │ │ │ +63 typedef ValueType& Reference; │ │ │ │ │ +64 typedef std::ptrdiff_t KeyType; │ │ │ │ │ +65 typedef LvaluePropertyMapTag Category; │ │ │ │ │ +66 }; │ │ │ │ │ +67 │ │ │ │ │ +68 │ │ │ │ │ +69 template │ │ │ │ │ +70 struct PropertyMapTraits │ │ │ │ │ +71 { │ │ │ │ │ +72 typedef T ValueType; │ │ │ │ │ +73 typedef const ValueType& Reference; │ │ │ │ │ +74 typedef std::ptrdiff_t KeyType; │ │ │ │ │ +75 typedef LvaluePropertyMapTag Category; │ │ │ │ │ +76 }; │ │ │ │ │ +77 │ │ │ │ │ +78 template │ │ │ │ │ +79 struct RAPropertyMapHelper │ │ │ │ │ +80 {}; │ │ │ │ │ +81 │ │ │ │ │ +82 template │ │ │ │ │ +83 inline Reference │ │ │ │ │ +84 get(const RAPropertyMapHelper& pmap, │ │ │ │ │ +85 const Key& key) │ │ │ │ │ +86 { │ │ │ │ │ +87 return static_cast(pmap)[key]; │ │ │ │ │ +88 } │ │ │ │ │ +89 │ │ │ │ │ +90 template │ │ │ │ │ +91 inline void │ │ │ │ │ +92 put(const RAPropertyMapHelper& pmap, │ │ │ │ │ +93 const Key& key, const Value& value) │ │ │ │ │ +94 { │ │ │ │ │ +95 static_assert(std::is_convertible::value, │ │ │ │ │ +96 "WritablePropertyMapTag required!"); │ │ │ │ │ +97 static_cast(pmap)[key] = value; │ │ │ │ │ +98 } │ │ │ │ │ +99 │ │ │ │ │ +103 template::value_type, │ │ │ │ │ +105 class R = typename std::iterator_traits::reference> │ │ │ │ │ +106 class IteratorPropertyMap │ │ │ │ │ +107 : public RAPropertyMapHelper > │ │ │ │ │ +108 { │ │ │ │ │ +109 public: │ │ │ │ │ +113 typedef RAI RandomAccessIterator; │ │ │ │ │ +114 │ │ │ │ │ +120 typedef IM IndexMap; │ │ │ │ │ +121 │ │ │ │ │ +125 typedef typename IndexMap::KeyType KeyType; │ │ │ │ │ +126 │ │ │ │ │ +130 typedef T ValueType; │ │ │ │ │ 131 │ │ │ │ │ -132 template │ │ │ │ │ -133 PseudoFuture(U&& u) : │ │ │ │ │ -134 valid_(true), │ │ │ │ │ -135 data_(std::forward(u)) │ │ │ │ │ -136 {} │ │ │ │ │ -137 │ │ │ │ │ -138 void wait() { │ │ │ │ │ -139 if(!valid_) │ │ │ │ │ -140 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid"); │ │ │ │ │ -141 } │ │ │ │ │ -142 │ │ │ │ │ -143 bool ready() const { │ │ │ │ │ -144 if(!valid_) │ │ │ │ │ -145 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid"); │ │ │ │ │ -146 return true; │ │ │ │ │ -147 } │ │ │ │ │ -148 │ │ │ │ │ -149 T get() { │ │ │ │ │ -150 if(!valid_) │ │ │ │ │ -151 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid"); │ │ │ │ │ -152 valid_ = false; │ │ │ │ │ -153 return std::forward(data_); │ │ │ │ │ -154 } │ │ │ │ │ -155 │ │ │ │ │ -156 bool valid() const { │ │ │ │ │ -157 return valid_; │ │ │ │ │ -158 } │ │ │ │ │ -159 }; │ │ │ │ │ -160 │ │ │ │ │ -161 template<> │ │ │ │ │ -162 class PseudoFuture{ │ │ │ │ │ -163 bool valid_; │ │ │ │ │ -164 public: │ │ │ │ │ -165 PseudoFuture(bool valid = false) : │ │ │ │ │ -166 valid_(valid) │ │ │ │ │ -167 {} │ │ │ │ │ -168 │ │ │ │ │ -169 void wait(){ │ │ │ │ │ -170 if(!valid_) │ │ │ │ │ -171 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid"); │ │ │ │ │ -172 } │ │ │ │ │ -173 bool ready() const{ │ │ │ │ │ -174 if(!valid_) │ │ │ │ │ -175 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid"); │ │ │ │ │ -176 return true; │ │ │ │ │ -177 } │ │ │ │ │ -178 │ │ │ │ │ -179 void get(){ │ │ │ │ │ -180 if(!valid_) │ │ │ │ │ -181 DUNE_THROW(InvalidFutureException, "The PseudoFuture is not valid"); │ │ │ │ │ -182 valid_ = false; │ │ │ │ │ -183 } │ │ │ │ │ -184 │ │ │ │ │ -185 bool valid() const{ │ │ │ │ │ -186 return valid_; │ │ │ │ │ -187 } │ │ │ │ │ -188 }; │ │ │ │ │ -189} │ │ │ │ │ -190 │ │ │ │ │ -191#endif // DUNE_COMMON_PARALLEL_FUTURE_HH │ │ │ │ │ -exceptions.hh │ │ │ │ │ -A few common exception classes. │ │ │ │ │ -DUNE_THROW │ │ │ │ │ -#define DUNE_THROW(E, m) │ │ │ │ │ -Definition exceptions.hh:218 │ │ │ │ │ -std │ │ │ │ │ -STL namespace. │ │ │ │ │ +135 typedef R Reference; │ │ │ │ │ +136 │ │ │ │ │ +140 typedef LvaluePropertyMapTag Category; │ │ │ │ │ +141 │ │ │ │ │ +149 inline IteratorPropertyMap(RandomAccessIterator iter, │ │ │ │ │ +150 const IndexMap& im=IndexMap()) │ │ │ │ │ +151 : iter_(iter), indexMap_(im) │ │ │ │ │ +152 {} │ │ │ │ │ +153 │ │ │ │ │ +155 inline IteratorPropertyMap() │ │ │ │ │ +156 : iter_(), indexMap_() │ │ │ │ │ +157 {} │ │ │ │ │ +158 │ │ │ │ │ +160 inline Reference operator[](KeyType key) const │ │ │ │ │ +161 { │ │ │ │ │ +162 return *(iter_ + get(indexMap_, key)); │ │ │ │ │ +163 } │ │ │ │ │ +164 │ │ │ │ │ +165 private: │ │ │ │ │ +167 RandomAccessIterator iter_; │ │ │ │ │ +169 IndexMap indexMap_; │ │ │ │ │ +170 }; │ │ │ │ │ +171 │ │ │ │ │ +176 template │ │ │ │ │ +177 class AssociativePropertyMap │ │ │ │ │ +178 : RAPropertyMapHelper > │ │ │ │ │ +180 { │ │ │ │ │ +184 typedef T UniqueAssociativeContainer; │ │ │ │ │ +185 │ │ │ │ │ +189 typedef typename UniqueAssociativeContainer::value_type::first_type │ │ │ │ │ +190 KeyType; │ │ │ │ │ +191 │ │ │ │ │ +195 typedef typename UniqueAssociativeContainer::value_type::second_type │ │ │ │ │ +196 ValueType; │ │ │ │ │ +197 │ │ │ │ │ +201 typedef ValueType& Reference; │ │ │ │ │ +202 │ │ │ │ │ +206 typedef LvaluePropertyMapTag Category; │ │ │ │ │ +207 │ │ │ │ │ +209 inline AssociativePropertyMap() │ │ │ │ │ +210 : map_(0) │ │ │ │ │ +211 {} │ │ │ │ │ +212 │ │ │ │ │ +214 inline AssociativePropertyMap(UniqueAssociativeContainer& map) │ │ │ │ │ +215 : map_(&map) │ │ │ │ │ +216 {} │ │ │ │ │ +217 │ │ │ │ │ +222 inline Reference operator[](KeyType key) const │ │ │ │ │ +223 { │ │ │ │ │ +224 return map_->find(key)->second; │ │ │ │ │ +225 } │ │ │ │ │ +226 private: │ │ │ │ │ +227 UniqueAssociativeContainer* map_; │ │ │ │ │ +228 }; │ │ │ │ │ +229 │ │ │ │ │ +234 template │ │ │ │ │ +235 class ConstAssociativePropertyMap │ │ │ │ │ +236 : RAPropertyMapHelper > │ │ │ │ │ +238 { │ │ │ │ │ +242 typedef T UniqueAssociativeContainer; │ │ │ │ │ +243 │ │ │ │ │ +247 typedef typename UniqueAssociativeContainer::value_type::first_type │ │ │ │ │ +248 KeyType; │ │ │ │ │ +249 │ │ │ │ │ +253 typedef typename UniqueAssociativeContainer::value_type::second_type │ │ │ │ │ +254 ValueType; │ │ │ │ │ +255 │ │ │ │ │ +259 typedef const ValueType& Reference; │ │ │ │ │ +260 │ │ │ │ │ +264 typedef LvaluePropertyMapTag Category; │ │ │ │ │ +265 │ │ │ │ │ +267 inline ConstAssociativePropertyMap() │ │ │ │ │ +268 : map_(0) │ │ │ │ │ +269 {} │ │ │ │ │ +270 │ │ │ │ │ +272 inline ConstAssociativePropertyMap(const UniqueAssociativeContainer& map) │ │ │ │ │ +273 : map_(&map) │ │ │ │ │ +274 {} │ │ │ │ │ +275 │ │ │ │ │ +280 inline Reference operator[](KeyType key) const │ │ │ │ │ +281 { │ │ │ │ │ +282 return map_->find(key)->second; │ │ │ │ │ +283 } │ │ │ │ │ +284 private: │ │ │ │ │ +285 const UniqueAssociativeContainer* map_; │ │ │ │ │ +286 }; │ │ │ │ │ +287 │ │ │ │ │ +291 struct IdentityMap │ │ │ │ │ +292 : public RAPropertyMapHelper │ │ │ │ │ +293 { │ │ │ │ │ +295 typedef std::size_t KeyType; │ │ │ │ │ +296 │ │ │ │ │ +298 typedef std::size_t ValueType; │ │ │ │ │ +299 │ │ │ │ │ +301 typedef std::size_t Reference; │ │ │ │ │ +302 │ │ │ │ │ +304 typedef ReadablePropertyMapTag Category; │ │ │ │ │ +305 │ │ │ │ │ +306 inline ValueType operator[](const KeyType& key) const │ │ │ │ │ +307 { │ │ │ │ │ +308 return key; │ │ │ │ │ +309 } │ │ │ │ │ +310 }; │ │ │ │ │ +311 │ │ │ │ │ +312 │ │ │ │ │ +318 template │ │ │ │ │ +319 struct PropertyMapTypeSelector │ │ │ │ │ +320 { │ │ │ │ │ +324 typedef T Tag; │ │ │ │ │ +329 typedef C Container; │ │ │ │ │ +330 }; │ │ │ │ │ +331 │ │ │ │ │ +332} │ │ │ │ │ +333 │ │ │ │ │ +334#endif │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::put │ │ │ │ │ +void put(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key │ │ │ │ │ +&key, const Value &value) │ │ │ │ │ +Definition propertymap.hh:92 │ │ │ │ │ Dune::get │ │ │ │ │ constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< │ │ │ │ │ std::size_t, pos >={}) │ │ │ │ │ Return the entry at position pos of the given sequence. │ │ │ │ │ Definition integersequence.hh:22 │ │ │ │ │ -Dune::InvalidStateException │ │ │ │ │ -Default exception if a function was called while the object is not in a valid │ │ │ │ │ -state for that function... │ │ │ │ │ -Definition exceptions.hh:281 │ │ │ │ │ -Dune::InvalidFutureException │ │ │ │ │ -This exception is thrown when ready(), wait() or get() is called on an invalid │ │ │ │ │ -future.... │ │ │ │ │ -Definition future.hh:20 │ │ │ │ │ -Dune::PseudoFuture │ │ │ │ │ -A wrapper-class for a object which is ready immediately. │ │ │ │ │ -Definition future.hh:124 │ │ │ │ │ -Dune::PseudoFuture::ready │ │ │ │ │ -bool ready() const │ │ │ │ │ -Definition future.hh:143 │ │ │ │ │ -Dune::PseudoFuture::get │ │ │ │ │ -T get() │ │ │ │ │ -Definition future.hh:149 │ │ │ │ │ -Dune::PseudoFuture::PseudoFuture │ │ │ │ │ -PseudoFuture(U &&u) │ │ │ │ │ -Definition future.hh:133 │ │ │ │ │ -Dune::PseudoFuture::PseudoFuture │ │ │ │ │ -PseudoFuture() │ │ │ │ │ -Definition future.hh:128 │ │ │ │ │ -Dune::PseudoFuture::wait │ │ │ │ │ -void wait() │ │ │ │ │ -Definition future.hh:138 │ │ │ │ │ -Dune::PseudoFuture::valid │ │ │ │ │ -bool valid() const │ │ │ │ │ -Definition future.hh:156 │ │ │ │ │ -Dune::Future │ │ │ │ │ -Type-erasure for future-like objects. A future-like object is a object │ │ │ │ │ -satisfying the interface of Fu... │ │ │ │ │ -Definition future.hh:30 │ │ │ │ │ -Dune::Future::ready │ │ │ │ │ -bool ready() const │ │ │ │ │ -Definition future.hh:105 │ │ │ │ │ -Dune::Future::wait │ │ │ │ │ -void wait() │ │ │ │ │ -wait until the future is ready │ │ │ │ │ -Definition future.hh:89 │ │ │ │ │ -Dune::Future::Future │ │ │ │ │ -Future(U &&data) │ │ │ │ │ -Definition future.hh:80 │ │ │ │ │ -Dune::Future::get │ │ │ │ │ -T get() │ │ │ │ │ -Waits until the future is ready and returns the resulting value. │ │ │ │ │ -Definition future.hh:97 │ │ │ │ │ -Dune::Future::Future │ │ │ │ │ -Future()=default │ │ │ │ │ -Dune::Future::valid │ │ │ │ │ -bool valid() const │ │ │ │ │ -Checks whether the future is valid. I.e. ‘get()’ was not called on that │ │ │ │ │ -future and when it was not de... │ │ │ │ │ -Definition future.hh:114 │ │ │ │ │ -Dune::Future::Future │ │ │ │ │ -Future(F &&f) │ │ │ │ │ -Definition future.hh:75 │ │ │ │ │ -Dune::PseudoFuture<_void_>::ready │ │ │ │ │ -bool ready() const │ │ │ │ │ -Definition future.hh:173 │ │ │ │ │ -Dune::PseudoFuture<_void_>::valid │ │ │ │ │ -bool valid() const │ │ │ │ │ -Definition future.hh:185 │ │ │ │ │ -Dune::PseudoFuture<_void_>::get │ │ │ │ │ -void get() │ │ │ │ │ -Definition future.hh:179 │ │ │ │ │ -Dune::PseudoFuture<_void_>::PseudoFuture │ │ │ │ │ -PseudoFuture(bool valid=false) │ │ │ │ │ -Definition future.hh:165 │ │ │ │ │ -Dune::PseudoFuture<_void_>::wait │ │ │ │ │ -void wait() │ │ │ │ │ -Definition future.hh:169 │ │ │ │ │ +Dune::PropertyMapTraits │ │ │ │ │ +Definition propertymap.hh:17 │ │ │ │ │ +Dune::PropertyMapTraits::ValueType │ │ │ │ │ +PM::ValueType ValueType │ │ │ │ │ +The type of the values of the property map. │ │ │ │ │ +Definition propertymap.hh:25 │ │ │ │ │ +Dune::PropertyMapTraits::Category │ │ │ │ │ +PM::Category Category │ │ │ │ │ +The category the property map belongs to. │ │ │ │ │ +Definition propertymap.hh:33 │ │ │ │ │ +Dune::PropertyMapTraits::Reference │ │ │ │ │ +PM::Reference Reference │ │ │ │ │ +The type of the reference to the values. │ │ │ │ │ +Definition propertymap.hh:29 │ │ │ │ │ +Dune::PropertyMapTraits::KeyType │ │ │ │ │ +PM::KeyType KeyType │ │ │ │ │ +The type of the key of the property map. │ │ │ │ │ +Definition propertymap.hh:21 │ │ │ │ │ +Dune::ReadablePropertyMapTag │ │ │ │ │ +Tag for the category of readable property maps. │ │ │ │ │ +Definition propertymap.hh:38 │ │ │ │ │ +Dune::WritablePropertyMapTag │ │ │ │ │ +Tag for the category of writable property maps. │ │ │ │ │ +Definition propertymap.hh:42 │ │ │ │ │ +Dune::ReadWritePropertyMapTag │ │ │ │ │ +Tag for the category of readable and writable property maps. │ │ │ │ │ +Definition propertymap.hh:50 │ │ │ │ │ +Dune::LvaluePropertyMapTag │ │ │ │ │ +Tag for the category of lvalue property maps. │ │ │ │ │ +Definition propertymap.hh:57 │ │ │ │ │ +Dune::PropertyMapTraits<_T_*_>::Reference │ │ │ │ │ +ValueType & Reference │ │ │ │ │ +Definition propertymap.hh:63 │ │ │ │ │ +Dune::PropertyMapTraits<_T_*_>::KeyType │ │ │ │ │ +std::ptrdiff_t KeyType │ │ │ │ │ +Definition propertymap.hh:64 │ │ │ │ │ +Dune::PropertyMapTraits<_T_*_>::ValueType │ │ │ │ │ +T ValueType │ │ │ │ │ +Definition propertymap.hh:62 │ │ │ │ │ +Dune::PropertyMapTraits<_T_*_>::Category │ │ │ │ │ +LvaluePropertyMapTag Category │ │ │ │ │ +Definition propertymap.hh:65 │ │ │ │ │ +Dune::PropertyMapTraits<_const_T_*_>::KeyType │ │ │ │ │ +std::ptrdiff_t KeyType │ │ │ │ │ +Definition propertymap.hh:74 │ │ │ │ │ +Dune::PropertyMapTraits<_const_T_*_>::Reference │ │ │ │ │ +const ValueType & Reference │ │ │ │ │ +Definition propertymap.hh:73 │ │ │ │ │ +Dune::PropertyMapTraits<_const_T_*_>::ValueType │ │ │ │ │ +T ValueType │ │ │ │ │ +Definition propertymap.hh:72 │ │ │ │ │ +Dune::PropertyMapTraits<_const_T_*_>::Category │ │ │ │ │ +LvaluePropertyMapTag Category │ │ │ │ │ +Definition propertymap.hh:75 │ │ │ │ │ +Dune::RAPropertyMapHelper │ │ │ │ │ +Definition propertymap.hh:80 │ │ │ │ │ +Dune::IteratorPropertyMap │ │ │ │ │ +Adapter to turn a random access iterator into a property map. │ │ │ │ │ +Definition propertymap.hh:108 │ │ │ │ │ +Dune::IteratorPropertyMap::KeyType │ │ │ │ │ +IndexMap::KeyType KeyType │ │ │ │ │ +The key type of the property map. │ │ │ │ │ +Definition propertymap.hh:125 │ │ │ │ │ +Dune::IteratorPropertyMap::Reference │ │ │ │ │ +R Reference │ │ │ │ │ +The reference type of the property map. │ │ │ │ │ +Definition propertymap.hh:135 │ │ │ │ │ +Dune::IteratorPropertyMap::ValueType │ │ │ │ │ +T ValueType │ │ │ │ │ +The value type of the property map. │ │ │ │ │ +Definition propertymap.hh:130 │ │ │ │ │ +Dune::IteratorPropertyMap::operator[] │ │ │ │ │ +Reference operator[](KeyType key) const │ │ │ │ │ +Access the a value by reference. │ │ │ │ │ +Definition propertymap.hh:160 │ │ │ │ │ +Dune::IteratorPropertyMap::IteratorPropertyMap │ │ │ │ │ +IteratorPropertyMap(RandomAccessIterator iter, const IndexMap &im=IndexMap()) │ │ │ │ │ +Constructor. │ │ │ │ │ +Definition propertymap.hh:149 │ │ │ │ │ +Dune::IteratorPropertyMap::IteratorPropertyMap │ │ │ │ │ +IteratorPropertyMap() │ │ │ │ │ +Constructor. │ │ │ │ │ +Definition propertymap.hh:155 │ │ │ │ │ +Dune::IteratorPropertyMap::IndexMap │ │ │ │ │ +IM IndexMap │ │ │ │ │ +The type of the index map. │ │ │ │ │ +Definition propertymap.hh:120 │ │ │ │ │ +Dune::IteratorPropertyMap::RandomAccessIterator │ │ │ │ │ +RAI RandomAccessIterator │ │ │ │ │ +The type of the random access iterator. │ │ │ │ │ +Definition propertymap.hh:113 │ │ │ │ │ +Dune::IteratorPropertyMap::Category │ │ │ │ │ +LvaluePropertyMapTag Category │ │ │ │ │ +The category of this property map. │ │ │ │ │ +Definition propertymap.hh:140 │ │ │ │ │ +Dune::AssociativePropertyMap │ │ │ │ │ +An adapter to turn an unique associative container into a property map. │ │ │ │ │ +Definition propertymap.hh:180 │ │ │ │ │ +Dune::ConstAssociativePropertyMap │ │ │ │ │ +An adaptor to turn an unique associative container into a property map. │ │ │ │ │ +Definition propertymap.hh:238 │ │ │ │ │ +Dune::IdentityMap │ │ │ │ │ +A property map that applies the identity function to integers. │ │ │ │ │ +Definition propertymap.hh:293 │ │ │ │ │ +Dune::IdentityMap::ValueType │ │ │ │ │ +std::size_t ValueType │ │ │ │ │ +The value type of the map. │ │ │ │ │ +Definition propertymap.hh:298 │ │ │ │ │ +Dune::IdentityMap::KeyType │ │ │ │ │ +std::size_t KeyType │ │ │ │ │ +The key type of the map. │ │ │ │ │ +Definition propertymap.hh:295 │ │ │ │ │ +Dune::IdentityMap::operator[] │ │ │ │ │ +ValueType operator[](const KeyType &key) const │ │ │ │ │ +Definition propertymap.hh:306 │ │ │ │ │ +Dune::IdentityMap::Reference │ │ │ │ │ +std::size_t Reference │ │ │ │ │ +The reference type of the map. │ │ │ │ │ +Definition propertymap.hh:301 │ │ │ │ │ +Dune::IdentityMap::Category │ │ │ │ │ +ReadablePropertyMapTag Category │ │ │ │ │ +The category of the map. │ │ │ │ │ +Definition propertymap.hh:304 │ │ │ │ │ +Dune::PropertyMapTypeSelector │ │ │ │ │ +Selector for the property map type. │ │ │ │ │ +Definition propertymap.hh:320 │ │ │ │ │ +Dune::PropertyMapTypeSelector::Tag │ │ │ │ │ +T Tag │ │ │ │ │ +the tag identifying the property. │ │ │ │ │ +Definition propertymap.hh:324 │ │ │ │ │ +Dune::PropertyMapTypeSelector::Container │ │ │ │ │ +C Container │ │ │ │ │ +The container type to whose entries the properties are attached. │ │ │ │ │ +Definition propertymap.hh:329 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00089.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: localindex.hh File Reference │ │ │ │ +dune-common: stdstreams.cc File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,55 +65,54 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -Classes | │ │ │ │ Namespaces | │ │ │ │ -Enumerations
│ │ │ │ - │ │ │ │ +Variables
│ │ │ │ +
stdstreams.cc File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

Provides classes for use as the local index in ParallelIndexSet. │ │ │ │ -More...

│ │ │ │ -
#include <cstddef>
│ │ │ │ -
│ │ │ │ -

Go to the source code of this file.

│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -

│ │ │ │ -Classes

class  Dune::LocalIndex
 An index present on the local process. More...
 
│ │ │ │ +
#include <iostream>
│ │ │ │ +#include "stdstreams.hh"
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ -Enumerations

enum  Dune::LocalIndexState { Dune::VALID │ │ │ │ -, Dune::DELETED │ │ │ │ - }
 The states available for the local indices. More...
 

│ │ │ │ +Variables

DVVerbType Dune::dvverb (std::cout)
 stream for very verbose output.
 
DVerbType Dune::dverb (std::cout)
 Singleton of verbose debug stream.
 
DInfoType Dune::dinfo (std::cout)
 Stream for informative output.
 
DWarnType Dune::dwarn (std::cerr)
 Stream for warnings indicating problems.
 
DGraveType Dune::dgrave (std::cerr)
 Stream for warnings indicating fatal errors.
 
DErrType Dune::derr (std::cerr)
 Stream for error messages.
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Provides classes for use as the local index in ParallelIndexSet.

│ │ │ │ -
Author
Markus Blatt
│ │ │ │ -
│ │ │ │ + │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,31 +1,35 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces | Enumerations │ │ │ │ │ -localindex.hh File Reference │ │ │ │ │ -Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ -Provides classes for use as the local index in ParallelIndexSet. More... │ │ │ │ │ -#include │ │ │ │ │ -Go_to_the_source_code_of_this_file. │ │ │ │ │ -Classes │ │ │ │ │ -class   Dune::LocalIndex │ │ │ │ │ -  An index present on the local process. More... │ │ │ │ │ -  │ │ │ │ │ +Namespaces | Variables │ │ │ │ │ +stdstreams.cc File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include "stdstreams.hh" │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Enumerations │ │ │ │ │ -enum   Dune::LocalIndexState { Dune::VALID , Dune::DELETED } │ │ │ │ │ -  The states available for the local indices. More... │ │ │ │ │ -  │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Provides classes for use as the local index in ParallelIndexSet. │ │ │ │ │ - Author │ │ │ │ │ - Markus Blatt │ │ │ │ │ +Variables │ │ │ │ │ +DVVerbType  Dune::dvverb (std::cout) │ │ │ │ │ +  stream for very verbose output. │ │ │ │ │ +  │ │ │ │ │ + DVerbType  Dune::dverb (std::cout) │ │ │ │ │ +  Singleton of verbose debug stream. │ │ │ │ │ +  │ │ │ │ │ + DInfoType  Dune::dinfo (std::cout) │ │ │ │ │ +  Stream for informative output. │ │ │ │ │ +  │ │ │ │ │ + DWarnType  Dune::dwarn (std::cerr) │ │ │ │ │ +  Stream for warnings indicating problems. │ │ │ │ │ +  │ │ │ │ │ +DGraveType  Dune::dgrave (std::cerr) │ │ │ │ │ +  Stream for warnings indicating fatal errors. │ │ │ │ │ +  │ │ │ │ │ + DErrType  Dune::derr (std::cerr) │ │ │ │ │ +  Stream for error messages. │ │ │ │ │ +  │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00092.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpitraits.hh File Reference │ │ │ │ +dune-common: debugalign.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,51 +65,385 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ -
mpitraits.hh File Reference
│ │ │ │ +Namespaces | │ │ │ │ +Macros | │ │ │ │ +Typedefs | │ │ │ │ +Functions | │ │ │ │ +Variables
│ │ │ │ +
debugalign.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ - │ │ │ │ -

Traits classes for mapping types onto MPI_Datatype. │ │ │ │ -More...

│ │ │ │ -
#include <complex>
│ │ │ │ +
#include <algorithm>
│ │ │ │ +#include <cassert>
│ │ │ │ +#include <cmath>
│ │ │ │ +#include <complex>
│ │ │ │ #include <cstddef>
│ │ │ │ #include <cstdint>
│ │ │ │ +#include <cstdlib>
│ │ │ │ +#include <functional>
│ │ │ │ +#include <istream>
│ │ │ │ +#include <ostream>
│ │ │ │ #include <type_traits>
│ │ │ │ #include <utility>
│ │ │ │ -#include <mpi.h>
│ │ │ │ +#include <dune/common/classname.hh>
│ │ │ │ +#include <dune/common/indices.hh>
│ │ │ │ +#include <dune/common/simd/base.hh>
│ │ │ │ +#include <dune/common/simd/defaults.hh>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

struct  Dune::MPITraits< T >
 A traits class describing the mapping of types onto MPI_Datatypes. More...
struct  Dune::AlignedBase< align, Impl >
 CRTP base mixin class to check alignment. More...
 
struct  Dune::IsNumber< AlignedNumberImpl::AlignedNumber< T, align > >
 
class  Dune::AlignedNumberImpl::AlignedNumber< T, align >
 aligned wrappers for arithmetic types More...
 
struct  Dune::Simd::Overloads::ScalarType< AlignedNumber< T, align > >
 
struct  Dune::Simd::Overloads::RebindType< U, AlignedNumber< T, align > >
 
struct  Dune::Simd::Overloads::LaneCount< AlignedNumber< T, align > >
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
namespace  Dune::AlignedNumberImpl
 
namespace  Dune::Simd
 Namespace for vectorization interface functions used by library developers.
 
namespace  Dune::Simd::Overloads
 Namespace for the overloads and specializations that make up a SIMD implementation.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Macros

#define DUNE_ASSIGN_OP(OP)
 
#define DUNE_BINARY_OP(OP)
 
#define DUNE_UNARY_FUNC(name)
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Typedefs

using Dune::ViolatedAlignmentHandler = std::function< void(const char *, std::size_t, const void *)>
 type of the handler called by violatedAlignment()
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Functions

ViolatedAlignmentHandlerDune::violatedAlignmentHandler ()
 access the handler called by violatedAlignment()
 
void Dune::violatedAlignment (const char *className, std::size_t expectedAlignment, const void *address)
 called when an alignment violation is detected
 
bool Dune::isAligned (const void *p, std::size_t align)
 check whether an address conforms to the given alignment
 
template<std::size_t align = debugAlignment, class T >
AlignedNumber< T, align > Dune::aligned (T value)
 align a value to a certain alignment
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (+)
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (-)
 
DUNE_BINARY_OP * Dune::AlignedNumberImpl::DUNE_BINARY_OP (/);DUNE_BINARY_OP(%
 
DUNE_BINARY_OP^ Dune::AlignedNumberImpl::DUNE_BINARY_OP (&);DUNE_BINARY_OP(|
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (<<)
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (> >)
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (==)
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (!=)
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (<=)
 
 Dune::AlignedNumberImpl::DUNE_BINARY_OP (>=)
 
DUNE_BINARY_OP && Dune::AlignedNumberImpl::DUNE_BINARY_OP (||);#define DUNE_UNARY_FUNC(name) DUNE_UNARY_FUNC(abs
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (acos)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (acosh)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (asin)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (asinh)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (atan)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (atanh)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (cbrt)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (ceil)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (cos)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (cosh)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (erf)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (erfc)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (exp)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (exp2)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (expm1)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (fabs)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (floor)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (ilogb)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (lgamma)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (llrint)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (llround)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (log)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (log10)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (log1p)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (log2)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (logb)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (lrint)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (lround)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (nearbyint)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (rint)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (round)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (sin)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (sinh)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (sqrt)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (tan)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (tanh)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (tgamma)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (trunc)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (isfinite)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (isinf)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (isnan)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (isnormal)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (signbit)
 
 Dune::AlignedNumberImpl::DUNE_UNARY_FUNC (real)
 
template<class T , std::size_t align>
auto Dune::AlignedNumberImpl::max (const AlignedNumber< T, align > &a, const AlignedNumber< T, align > &b)
 
template<class T , std::size_t align>
auto Dune::AlignedNumberImpl::max (const T &a, const AlignedNumber< T, align > &b)
 
template<class T , std::size_t align>
auto Dune::AlignedNumberImpl::max (const AlignedNumber< T, align > &a, const T &b)
 
template<class T , std::size_t align>
auto Dune::AlignedNumberImpl::min (const AlignedNumber< T, align > &a, const AlignedNumber< T, align > &b)
 
template<class T , std::size_t align>
auto Dune::AlignedNumberImpl::min (const T &a, const AlignedNumber< T, align > &b)
 
template<class T , std::size_t align>
auto Dune::AlignedNumberImpl::min (const AlignedNumber< T, align > &a, const T &b)
 
template<class T , std::size_t align>
AlignedNumber< T, align > Dune::cond (const AlignedNumber< bool, align > &b, const AlignedNumber< T, align > &v1, const AlignedNumber< T, align > &v2)
 
template<class T , std::size_t align>
Dune::max_value (const AlignedNumber< T, align > &val)
 
template<class T , std::size_t align>
Dune::min_value (const AlignedNumber< T, align > &val)
 
template<std::size_t align>
bool Dune::any_true (const AlignedNumber< bool, align > &val)
 
template<std::size_t align>
bool Dune::all_true (const AlignedNumber< bool, align > &val)
 
template<class T , std::size_t align>
T & Dune::Simd::Overloads::lane (ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
 
template<class T , std::size_t align>
Dune::Simd::Overloads::lane (ADLTag< 5 >, std::size_t l, const AlignedNumber< T, align > &v)
 
template<class T , std::size_t align>
const AlignedNumber< T, align > & Dune::Simd::Overloads::cond (ADLTag< 5 >, AlignedNumber< bool, align > mask, const AlignedNumber< T, align > &ifTrue, const AlignedNumber< T, align > &ifFalse)
 
template<std::size_t align>
bool Dune::Simd::Overloads::anyTrue (ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Variables

static constexpr auto Dune::debugAlignment = 2*alignof(std::max_align_t)
 an alignment large enough to trigger alignment errors
 
│ │ │ │ -

Detailed Description

│ │ │ │ -

Traits classes for mapping types onto MPI_Datatype.

│ │ │ │ -
Author
Markus Blatt
│ │ │ │ -
│ │ │ │ +

Macro Definition Documentation

│ │ │ │ + │ │ │ │ +

◆ DUNE_ASSIGN_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_ASSIGN_OP( OP)
│ │ │ │ +
│ │ │ │ +Value:
template<class U, std::size_t uAlign, \
│ │ │ │ +
class = std::enable_if_t< \
│ │ │ │ +
( uAlign <= align && \
│ │ │ │ +
sizeof(std::declval<T&>() OP std::declval<U>()) ) \
│ │ │ │ +
> > \
│ │ │ │ +
AlignedNumber &operator OP(const AlignedNumber<U, uAlign> &u) \
│ │ │ │ +
{ \
│ │ │ │ +
value_ OP U(u); \
│ │ │ │ +
return *this; \
│ │ │ │ +
} \
│ │ │ │ +
\
│ │ │ │ +
template<class U, \
│ │ │ │ +
class = std::void_t<decltype(std::declval<T&>() OP \
│ │ │ │ +
std::declval<U>())> > \
│ │ │ │ +
AlignedNumber &operator OP(const U &u) \
│ │ │ │ +
{ \
│ │ │ │ +
value_ OP u; \
│ │ │ │ +
return *this; \
│ │ │ │ +
} \
│ │ │ │ +
\
│ │ │ │ +
static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ +
STL namespace.
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_BINARY_OP

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_BINARY_OP( OP)
│ │ │ │ +
│ │ │ │ +Value:
template<class T, std::size_t tAlign, class U, std::size_t uAlign, \
│ │ │ │ +
class = std::void_t<decltype(std::declval<T>() \
│ │ │ │ +
OP std::declval<U>())> > \
│ │ │ │ +
decltype(auto) \
│ │ │ │ +
operator OP(const AlignedNumber<T, tAlign> &t, \
│ │ │ │ +
const AlignedNumber<U, uAlign> &u) \
│ │ │ │ +
{ \
│ │ │ │ +
/* can't use std::max(); not constexpr */ \
│ │ │ │ +
return aligned<(tAlign > uAlign ? tAlign : uAlign)>(T(t) OP U(u)); \
│ │ │ │ +
} \
│ │ │ │ +
\
│ │ │ │ +
template<class T, class U, std::size_t uAlign, \
│ │ │ │ +
class = std::void_t<decltype(std::declval<T>() \
│ │ │ │ +
OP std::declval<U>())> > \
│ │ │ │ +
decltype(auto) \
│ │ │ │ +
operator OP(const T &t, const AlignedNumber<U, uAlign> &u) \
│ │ │ │ +
{ \
│ │ │ │ +
return aligned<uAlign>(t OP U(u)); \
│ │ │ │ +
} \
│ │ │ │ +
\
│ │ │ │ +
template<class T, std::size_t tAlign, class U, \
│ │ │ │ +
class = std::void_t<decltype(std::declval<T>() \
│ │ │ │ +
OP std::declval<U>())> > \
│ │ │ │ +
decltype(auto) \
│ │ │ │ +
operator OP(const AlignedNumber<T, tAlign> &t, const U &u) \
│ │ │ │ +
{ \
│ │ │ │ +
return aligned<tAlign>(T(t) OP u); \
│ │ │ │ +
} \
│ │ │ │ +
\
│ │ │ │ +
static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ +

◆ DUNE_UNARY_FUNC

│ │ │ │ + │ │ │ │ +
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
#define DUNE_UNARY_FUNC( name)
│ │ │ │ +
│ │ │ │ +Value:
template<class T, std::size_t align> \
│ │ │ │ +
decltype(auto) name(const AlignedNumber<T, align> &u) \
│ │ │ │ +
{ \
│ │ │ │ +
using std::name; \
│ │ │ │ +
return aligned<align>(name(T(u))); \
│ │ │ │ +
} \
│ │ │ │ +
static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,33 +1,388 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -mpitraits.hh File Reference │ │ │ │ │ -Common » Parallel_Communication │ │ │ │ │ -Traits classes for mapping types onto MPI_Datatype. More... │ │ │ │ │ +Classes | Namespaces | Macros | Typedefs | Functions | Variables │ │ │ │ │ +debugalign.hh File Reference │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ #include │ │ │ │ │ #include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct   Dune::MPITraits<_T_> │ │ │ │ │ -  A traits class describing the mapping of types onto MPI_Datatypes. │ │ │ │ │ - More... │ │ │ │ │ +struct   Dune::AlignedBase<_align,_Impl_> │ │ │ │ │ +  CRTP base mixin class to check alignment. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::IsNumber<_AlignedNumberImpl::AlignedNumber<_T,_align_>_> │ │ │ │ │ +  │ │ │ │ │ + class   Dune::AlignedNumberImpl::AlignedNumber<_T,_align_> │ │ │ │ │ +  aligned wrappers for arithmetic types More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::Simd::Overloads::ScalarType<_AlignedNumber<_T,_align_>_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::Simd::Overloads::RebindType<_U,_AlignedNumber<_T,_align_>_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::Simd::Overloads::LaneCount<_AlignedNumber<_T,_align_>_> │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -***** Detailed Description ***** │ │ │ │ │ -Traits classes for mapping types onto MPI_Datatype. │ │ │ │ │ - Author │ │ │ │ │ - Markus Blatt │ │ │ │ │ +namespace   Dune::AlignedNumberImpl │ │ │ │ │ +  │ │ │ │ │ +namespace   Dune::Simd │ │ │ │ │ +  Namespace for vectorization interface functions used by library │ │ │ │ │ + developers. │ │ │ │ │ +  │ │ │ │ │ +namespace   Dune::Simd::Overloads │ │ │ │ │ +  Namespace for the overloads and specializations that make up a SIMD │ │ │ │ │ + implementation. │ │ │ │ │ +  │ │ │ │ │ +Macros │ │ │ │ │ +#define  DUNE_ASSIGN_OP(OP) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_BINARY_OP(OP) │ │ │ │ │ +  │ │ │ │ │ +#define  DUNE_UNARY_FUNC(name) │ │ │ │ │ +  │ │ │ │ │ +Typedefs │ │ │ │ │ +using  Dune::ViolatedAlignmentHandler = std::function< void(const char *, std:: │ │ │ │ │ + size_t, const void *)> │ │ │ │ │ +  type of the handler called by violatedAlignment() │ │ │ │ │ +  │ │ │ │ │ +Functions │ │ │ │ │ + ViolatedAlignmentHandler &  Dune::violatedAlignmentHandler () │ │ │ │ │ +  access the handler called by │ │ │ │ │ + violatedAlignment() │ │ │ │ │ +  │ │ │ │ │ + void  Dune::violatedAlignment (const char │ │ │ │ │ + *className, std::size_t expectedAlignment, │ │ │ │ │ + const void *address) │ │ │ │ │ +  called when an alignment violation is │ │ │ │ │ + detected │ │ │ │ │ +  │ │ │ │ │ + bool  Dune::isAligned (const void *p, std::size_ │ │ │ │ │ + t align) │ │ │ │ │ +  check whether an address conforms to the │ │ │ │ │ + given alignment │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + AlignedNumber< T, align >  Dune::aligned (T value) │ │ │ │ │ +  align a value to a certain alignment │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_BINARY_OP (+) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_BINARY_OP (-) │ │ │ │ │ +  │ │ │ │ │ + DUNE_BINARY_OP *  Dune::AlignedNumberImpl::DUNE_BINARY_OP (/ │ │ │ │ │ + );DUNE_BINARY_OP(% │ │ │ │ │ +  │ │ │ │ │ + DUNE_BINARY_OP^  Dune::AlignedNumberImpl::DUNE_BINARY_OP │ │ │ │ │ + (&);DUNE_BINARY_OP(| │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_BINARY_OP (<<) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_BINARY_OP (> │ │ │ │ │ + >) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_BINARY_OP (==) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_BINARY_OP (!=) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_BINARY_OP (<=) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_BINARY_OP (>=) │ │ │ │ │ +  │ │ │ │ │ + DUNE_BINARY_OP &&  Dune::AlignedNumberImpl::DUNE_BINARY_OP │ │ │ │ │ + (||);#define DUNE_UNARY_FUNC(name) DUNE_ │ │ │ │ │ + UNARY_FUNC(abs │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (acos) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (acosh) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (asin) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (asinh) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (atan) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (atanh) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (cbrt) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (ceil) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (cos) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (cosh) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (erf) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (erfc) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (exp) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (exp2) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (expm1) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (fabs) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (floor) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (ilogb) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (lgamma) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (llrint) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (llround) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (log) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (log10) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (log1p) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (log2) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (logb) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (lrint) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (lround) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (nearbyint) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (rint) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (round) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (sin) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (sinh) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (sqrt) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (tan) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (tanh) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (tgamma) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (trunc) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (isfinite) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (isinf) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (isnan) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (isnormal) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (signbit) │ │ │ │ │ +  │ │ │ │ │ +   Dune::AlignedNumberImpl::DUNE_UNARY_FUNC │ │ │ │ │ + (real) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::AlignedNumberImpl::max (const │ │ │ │ │ + AlignedNumber< T, align > &a, const │ │ │ │ │ + AlignedNumber< T, align > &b) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::AlignedNumberImpl::max (const T &a, │ │ │ │ │ + const AlignedNumber< T, align > &b) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::AlignedNumberImpl::max (const │ │ │ │ │ + AlignedNumber< T, align > &a, const T &b) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::AlignedNumberImpl::min (const │ │ │ │ │ + AlignedNumber< T, align > &a, const │ │ │ │ │ + AlignedNumber< T, align > &b) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::AlignedNumberImpl::min (const T &a, │ │ │ │ │ + const AlignedNumber< T, align > &b) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::AlignedNumberImpl::min (const │ │ │ │ │ + AlignedNumber< T, align > &a, const T &b) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + AlignedNumber< T, align >  Dune::cond (const AlignedNumber< bool, align │ │ │ │ │ + > &b, const AlignedNumber< T, align > &v1, │ │ │ │ │ + const AlignedNumber< T, align > &v2) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + T  Dune::max_value (const AlignedNumber< T, │ │ │ │ │ + align > &val) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + T  Dune::min_value (const AlignedNumber< T, │ │ │ │ │ + align > &val) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool  Dune::any_true (const AlignedNumber< bool, │ │ │ │ │ + align > &val) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool  Dune::all_true (const AlignedNumber< bool, │ │ │ │ │ + align > &val) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + T &  Dune::Simd::Overloads::lane (ADLTag< 5 >, │ │ │ │ │ + std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + T  Dune::Simd::Overloads::lane (ADLTag< 5 >, │ │ │ │ │ + std::size_t l, const AlignedNumber< T, align │ │ │ │ │ + > &v) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ +const AlignedNumber< T, align > &  Dune::Simd::Overloads::cond (ADLTag< 5 >, │ │ │ │ │ + AlignedNumber< bool, align > mask, const │ │ │ │ │ + AlignedNumber< T, align > &ifTrue, const │ │ │ │ │ + AlignedNumber< T, align > &ifFalse) │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + bool  Dune::Simd::Overloads::anyTrue (ADLTag< 5 >, │ │ │ │ │ + const AlignedNumber< bool, align > &mask) │ │ │ │ │ +  │ │ │ │ │ +Variables │ │ │ │ │ +static constexpr auto  Dune::debugAlignment = 2*alignof(std::max_align_t) │ │ │ │ │ +  an alignment large enough to trigger alignment errors │ │ │ │ │ +  │ │ │ │ │ +***** Macro Definition Documentation ***** │ │ │ │ │ +***** ◆ DUNE_ASSIGN_OP ***** │ │ │ │ │ +#define DUNE_ASSIGN_OP (   OP ) │ │ │ │ │ +Value: │ │ │ │ │ +template() OP std::declval()) ) \ │ │ │ │ │ +> > \ │ │ │ │ │ +AlignedNumber &operator OP(const AlignedNumber &u) \ │ │ │ │ │ +{ \ │ │ │ │ │ +value_ OP U(u); \ │ │ │ │ │ +return *this; \ │ │ │ │ │ +} \ │ │ │ │ │ +\ │ │ │ │ │ +template() OP \ │ │ │ │ │ +std::declval())> > \ │ │ │ │ │ +AlignedNumber &operator OP(const U &u) \ │ │ │ │ │ +{ \ │ │ │ │ │ +value_ OP u; \ │ │ │ │ │ +return *this; \ │ │ │ │ │ +} \ │ │ │ │ │ +\ │ │ │ │ │ +static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ +std │ │ │ │ │ +STL namespace. │ │ │ │ │ +***** ◆ DUNE_BINARY_OP ***** │ │ │ │ │ +#define DUNE_BINARY_OP (   OP ) │ │ │ │ │ +Value: │ │ │ │ │ +template() \ │ │ │ │ │ +OP std::declval())> > \ │ │ │ │ │ +decltype(auto) \ │ │ │ │ │ +operator OP(const AlignedNumber &t, \ │ │ │ │ │ +const AlignedNumber &u) \ │ │ │ │ │ +{ \ │ │ │ │ │ +/* can't use std::max(); not constexpr */ \ │ │ │ │ │ +return aligned<(tAlign > uAlign ? tAlign : uAlign)>(T(t) OP U(u)); \ │ │ │ │ │ +} \ │ │ │ │ │ +\ │ │ │ │ │ +template() \ │ │ │ │ │ +OP std::declval())> > \ │ │ │ │ │ +decltype(auto) \ │ │ │ │ │ +operator OP(const T &t, const AlignedNumber &u) \ │ │ │ │ │ +{ \ │ │ │ │ │ +return aligned(t OP U(u)); \ │ │ │ │ │ +} \ │ │ │ │ │ +\ │ │ │ │ │ +template() \ │ │ │ │ │ +OP std::declval())> > \ │ │ │ │ │ +decltype(auto) \ │ │ │ │ │ +operator OP(const AlignedNumber &t, const U &u) \ │ │ │ │ │ +{ \ │ │ │ │ │ +return aligned(T(t) OP u); \ │ │ │ │ │ +} \ │ │ │ │ │ +\ │ │ │ │ │ +static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ +***** ◆ DUNE_UNARY_FUNC ***** │ │ │ │ │ +#define DUNE_UNARY_FUNC (   name ) │ │ │ │ │ +Value: │ │ │ │ │ +template \ │ │ │ │ │ +decltype(auto) name(const AlignedNumber &u) \ │ │ │ │ │ +{ \ │ │ │ │ │ +using std::name; \ │ │ │ │ │ +return aligned(name(T(u))); \ │ │ │ │ │ +} \ │ │ │ │ │ +static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00092_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpitraits.hh Source File │ │ │ │ +dune-common: debugalign.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,218 +70,661 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
mpitraits.hh
│ │ │ │ +
debugalign.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PARALLEL_MPITRAITS_HH
│ │ │ │ -
6#define DUNE_COMMON_PARALLEL_MPITRAITS_HH
│ │ │ │ +
5#ifndef DUNE_DEBUGALIGN_HH
│ │ │ │ +
6#define DUNE_DEBUGALIGN_HH
│ │ │ │
7
│ │ │ │ -
18#if HAVE_MPI
│ │ │ │ -
19
│ │ │ │ -
20#include <complex>
│ │ │ │ -
21#include <cstddef>
│ │ │ │ -
22#include <cstdint>
│ │ │ │ -
23#include <type_traits>
│ │ │ │ -
24#include <utility>
│ │ │ │ -
25
│ │ │ │ -
26#include <mpi.h>
│ │ │ │ -
27
│ │ │ │ -
28namespace Dune
│ │ │ │ -
29{
│ │ │ │ -
39 template<typename T>
│ │ │ │ -
│ │ │ │ -
40 struct MPITraits
│ │ │ │ -
41 {
│ │ │ │ -
42 private:
│ │ │ │ -
43 MPITraits(){}
│ │ │ │ -
44 MPITraits(const MPITraits&){}
│ │ │ │ -
45 static MPI_Datatype datatype;
│ │ │ │ -
46 static MPI_Datatype vectortype;
│ │ │ │ -
47 public:
│ │ │ │ -
│ │ │ │ -
48 static inline MPI_Datatype getType()
│ │ │ │ -
49 {
│ │ │ │ -
50 if(datatype==MPI_DATATYPE_NULL) {
│ │ │ │ -
51 MPI_Type_contiguous(sizeof(T),MPI_BYTE,&datatype);
│ │ │ │ -
52 MPI_Type_commit(&datatype);
│ │ │ │ -
53 }
│ │ │ │ -
54 return datatype;
│ │ │ │ -
55 }
│ │ │ │ -
│ │ │ │ -
56 static constexpr bool is_intrinsic = false;
│ │ │ │ -
57 };
│ │ │ │ -
│ │ │ │ -
58 template<class T>
│ │ │ │ -
59 MPI_Datatype MPITraits<T>::datatype = MPI_DATATYPE_NULL;
│ │ │ │ -
60
│ │ │ │ -
61#ifndef DOXYGEN
│ │ │ │ +
8#include <algorithm>
│ │ │ │ +
9#include <cassert>
│ │ │ │ +
10#include <cmath>
│ │ │ │ +
11#include <complex>
│ │ │ │ +
12#include <cstddef>
│ │ │ │ +
13#include <cstdint>
│ │ │ │ +
14#include <cstdlib> // abs
│ │ │ │ +
15#include <functional>
│ │ │ │ +
16#include <istream>
│ │ │ │ +
17#include <ostream>
│ │ │ │ +
18#include <type_traits>
│ │ │ │ +
19#include <utility>
│ │ │ │ +
20
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
26
│ │ │ │ +
27namespace Dune {
│ │ │ │ +
28
│ │ │ │ + │ │ │ │ +
31 std::function<void(const char*, std::size_t, const void*)>;
│ │ │ │ +
32
│ │ │ │ +
34
│ │ │ │ + │ │ │ │ +
41
│ │ │ │ +
43
│ │ │ │ +
52 void violatedAlignment(const char *className, std::size_t expectedAlignment,
│ │ │ │ +
53 const void *address);
│ │ │ │ +
54
│ │ │ │ +
│ │ │ │ +
56 inline bool isAligned(const void *p, std::size_t align)
│ │ │ │ +
57 {
│ │ │ │ +
58 void* aligned_p = (void*)p;
│ │ │ │ +
59 std::size_t space = align*2;
│ │ │ │ +
60 return p == std::align(align, align, aligned_p, space);
│ │ │ │ +
61 }
│ │ │ │ +
│ │ │ │
62
│ │ │ │ -
63 // A Macro for defining traits for the primitive data types
│ │ │ │ -
64#define ComposeMPITraits(p,m) \
│ │ │ │ -
65 template<> \
│ │ │ │ -
66 struct MPITraits<p>{ \
│ │ │ │ -
67 static inline MPI_Datatype getType(){ \
│ │ │ │ -
68 return m; \
│ │ │ │ -
69 } \
│ │ │ │ -
70 static constexpr bool is_intrinsic = true; \
│ │ │ │ -
71 }
│ │ │ │ -
72
│ │ │ │ -
73 ComposeMPITraits(char, MPI_CHAR);
│ │ │ │ -
74 ComposeMPITraits(unsigned char,MPI_UNSIGNED_CHAR);
│ │ │ │ -
75 ComposeMPITraits(short,MPI_SHORT);
│ │ │ │ -
76 ComposeMPITraits(unsigned short,MPI_UNSIGNED_SHORT);
│ │ │ │ -
77 ComposeMPITraits(int,MPI_INT);
│ │ │ │ -
78 ComposeMPITraits(unsigned int,MPI_UNSIGNED);
│ │ │ │ -
79 ComposeMPITraits(long,MPI_LONG);
│ │ │ │ -
80 ComposeMPITraits(unsigned long,MPI_UNSIGNED_LONG);
│ │ │ │ -
81 ComposeMPITraits(float,MPI_FLOAT);
│ │ │ │ -
82 ComposeMPITraits(double,MPI_DOUBLE);
│ │ │ │ -
83 ComposeMPITraits(long double,MPI_LONG_DOUBLE);
│ │ │ │ -
84 ComposeMPITraits(std::complex<double>, MPI_CXX_DOUBLE_COMPLEX);
│ │ │ │ -
85 ComposeMPITraits(std::complex<long double>, MPI_CXX_LONG_DOUBLE_COMPLEX);
│ │ │ │ -
86 ComposeMPITraits(std::complex<float>, MPI_CXX_FLOAT_COMPLEX);
│ │ │ │ -
87
│ │ │ │ -
88
│ │ │ │ -
89#undef ComposeMPITraits
│ │ │ │ -
90
│ │ │ │ -
91 template<class K, int n> class FieldVector;
│ │ │ │ -
92
│ │ │ │ -
93 template<class K, int n>
│ │ │ │ -
94 struct MPITraits<FieldVector<K,n> >
│ │ │ │ -
95 {
│ │ │ │ -
96 static MPI_Datatype datatype;
│ │ │ │ -
97 static MPI_Datatype vectortype;
│ │ │ │ +
64 template<std::size_t align, class Impl>
│ │ │ │ +
│ │ │ │ +
65 struct alignas(align) AlignedBase
│ │ │ │ +
66 {
│ │ │ │ +
│ │ │ │ +
75 static void* operator new(std::size_t count, void* ptr) {
│ │ │ │ +
76 if(!isAligned(ptr, align))
│ │ │ │ +
77 violatedAlignment(className<Impl>().c_str(), align, ptr);
│ │ │ │ +
78 return ::operator new(count*sizeof(Impl), ptr);
│ │ │ │ +
79 }
│ │ │ │ +
│ │ │ │ +
80
│ │ │ │ +
│ │ │ │ +
89 static void* operator new[](std::size_t count, void* ptr) {
│ │ │ │ +
90 if(!isAligned(ptr, align))
│ │ │ │ +
91 violatedAlignment(className<Impl>().c_str(), align, ptr);
│ │ │ │ +
92 return ::operator new[](count*sizeof(Impl), ptr);
│ │ │ │ +
93 }
│ │ │ │ +
│ │ │ │ +
94 };
│ │ │ │ +
│ │ │ │ +
95
│ │ │ │ +
97 static constexpr auto debugAlignment = 2*alignof(std::max_align_t);
│ │ │ │
98
│ │ │ │ -
99 static inline MPI_Datatype getType()
│ │ │ │ -
100 {
│ │ │ │ -
101 if(datatype==MPI_DATATYPE_NULL) {
│ │ │ │ -
102 MPI_Type_contiguous(n, MPITraits<K>::getType(), &vectortype);
│ │ │ │ -
103 MPI_Type_commit(&vectortype);
│ │ │ │ -
104 FieldVector<K,n> fvector;
│ │ │ │ -
105 MPI_Aint base;
│ │ │ │ -
106 MPI_Aint displ;
│ │ │ │ -
107 MPI_Get_address(&fvector, &base);
│ │ │ │ -
108 MPI_Get_address(&(fvector[0]), &displ);
│ │ │ │ -
109 displ -= base;
│ │ │ │ -
110 int length[1]={1};
│ │ │ │ +
│ │ │ │ +
99 namespace AlignedNumberImpl {
│ │ │ │ +
100
│ │ │ │ +
101 template<class T, std::size_t align = debugAlignment>
│ │ │ │ +
102 class AlignedNumber;
│ │ │ │ +
103
│ │ │ │ +
104 } // namespace AlignedNumberImpl
│ │ │ │ +
│ │ │ │ +
105
│ │ │ │ + │ │ │ │ +
107
│ │ │ │ +
108 template<class T, std::size_t align>
│ │ │ │ +
│ │ │ │ +
109 struct IsNumber<AlignedNumberImpl::AlignedNumber<T,align>>
│ │ │ │ +
110 : public std::true_type {};
│ │ │ │ +
│ │ │ │
111
│ │ │ │ -
112 MPI_Type_create_struct(1, length, &displ, &vectortype, &datatype);
│ │ │ │ -
113 MPI_Type_commit(&datatype);
│ │ │ │ -
114 }
│ │ │ │ -
115 return datatype;
│ │ │ │ -
116 }
│ │ │ │ -
117
│ │ │ │ -
118 };
│ │ │ │ -
119
│ │ │ │ -
120 template<class K, int n>
│ │ │ │ -
121 MPI_Datatype MPITraits<FieldVector<K,n> >::datatype = MPI_DATATYPE_NULL;
│ │ │ │ -
122 template<class K, int n>
│ │ │ │ -
123 MPI_Datatype MPITraits<FieldVector<K,n> >::vectortype = {MPI_DATATYPE_NULL};
│ │ │ │ -
124
│ │ │ │ -
125
│ │ │ │ -
126 template<int k>
│ │ │ │ -
127 class bigunsignedint;
│ │ │ │ -
128
│ │ │ │ -
129 template<int k>
│ │ │ │ -
130 struct MPITraits<bigunsignedint<k> >
│ │ │ │ -
131 {
│ │ │ │ -
132 static MPI_Datatype datatype;
│ │ │ │ -
133 static MPI_Datatype vectortype;
│ │ │ │ -
134
│ │ │ │ -
135 static inline MPI_Datatype getType()
│ │ │ │ -
136 {
│ │ │ │ -
137 if(datatype==MPI_DATATYPE_NULL) {
│ │ │ │ - │ │ │ │ -
139 &vectortype);
│ │ │ │ -
140 //MPI_Type_commit(&vectortype);
│ │ │ │ -
141 bigunsignedint<k> data;
│ │ │ │ -
142 MPI_Aint base;
│ │ │ │ -
143 MPI_Aint displ;
│ │ │ │ -
144 MPI_Get_address(&data, &base);
│ │ │ │ -
145 MPI_Get_address(&(data.digit), &displ);
│ │ │ │ -
146 displ -= base;
│ │ │ │ -
147 int length[1]={1};
│ │ │ │ -
148 MPI_Type_create_struct(1, length, &displ, &vectortype, &datatype);
│ │ │ │ -
149 MPI_Type_commit(&datatype);
│ │ │ │ -
150 }
│ │ │ │ -
151 return datatype;
│ │ │ │ -
152 }
│ │ │ │ -
153 };
│ │ │ │ -
154}
│ │ │ │ -
155
│ │ │ │ -
156namespace Dune
│ │ │ │ -
157{
│ │ │ │ -
158 template<int k>
│ │ │ │ -
159 MPI_Datatype MPITraits<bigunsignedint<k> >::datatype = MPI_DATATYPE_NULL;
│ │ │ │ -
160 template<int k>
│ │ │ │ -
161 MPI_Datatype MPITraits<bigunsignedint<k> >::vectortype = MPI_DATATYPE_NULL;
│ │ │ │ +
113 template<std::size_t align = debugAlignment, class T>
│ │ │ │ +
114 AlignedNumber<T, align> aligned(T value) { return { std::move(value) }; }
│ │ │ │ +
115
│ │ │ │ +
116 // The purpose of this namespace is to move the `<cmath>` function overloads
│ │ │ │ +
117 // out of namespace `Dune`. This avoids problems where people called
│ │ │ │ +
118 // e.g. `sqrt(1.0)` inside the `Dune` namespace, without first doing `using
│ │ │ │ +
119 // std::sqrt;`. Without any `Dune::sqrt()`, such a use will find
│ │ │ │ +
120 // `::sqrt()`, but with `Dune::sqrt()` it will find only `Dune::sqrt()`,
│ │ │ │ +
121 // which does not have an overload for `double`.
│ │ │ │ +
122 namespace AlignedNumberImpl {
│ │ │ │ +
123
│ │ │ │ +
125 template<class T, std::size_t align>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
127 : public AlignedBase<align, AlignedNumber<T, align> >
│ │ │ │ +
128 {
│ │ │ │ +
129 T value_;
│ │ │ │ +
130
│ │ │ │ +
131 public:
│ │ │ │ +
132 AlignedNumber() = default;
│ │ │ │ +
133 AlignedNumber(T value) : value_(std::move(value)) {}
│ │ │ │ +
134 template<class U, std::size_t uAlign,
│ │ │ │ +
135 class = std::enable_if_t<(align >= uAlign) &&
│ │ │ │ +
136 std::is_convertible<U, T>::value> >
│ │ │ │ +
137 AlignedNumber(const AlignedNumber<U, uAlign> &o) : value_(U(o)) {}
│ │ │ │ +
138
│ │ │ │ +
139 // accessors
│ │ │ │ +
140 template<class U,
│ │ │ │ +
141 class = std::enable_if_t<std::is_convertible<T, U>::value> >
│ │ │ │ +
142 explicit operator U() const { return value_; }
│ │ │ │ +
143
│ │ │ │ +
144 const T &value() const { return value_; }
│ │ │ │ +
145 T &value() { return value_; }
│ │ │ │ +
146
│ │ │ │ +
147 // I/O
│ │ │ │ +
148 template<class charT, class Traits>
│ │ │ │ +
149 friend std::basic_istream<charT, Traits>&
│ │ │ │ +
│ │ │ │ +
150 operator>>(std::basic_istream<charT, Traits>& str, AlignedNumber &u)
│ │ │ │ +
151 {
│ │ │ │ +
152 return str >> u.value_;
│ │ │ │ +
153 }
│ │ │ │ +
│ │ │ │ +
154
│ │ │ │ +
155 template<class charT, class Traits>
│ │ │ │ +
│ │ │ │ +
156 friend std::basic_ostream<charT, Traits>&
│ │ │ │ +
157 operator<<(std::basic_ostream<charT, Traits>& str,
│ │ │ │ +
158 const AlignedNumber &u)
│ │ │ │ +
159 {
│ │ │ │ +
160 return str << u.value_;
│ │ │ │ +
161 }
│ │ │ │ +
│ │ │ │
162
│ │ │ │ -
163 template<typename T1, typename T2>
│ │ │ │ -
164 struct MPITraits<std::pair<T1,T2 > >
│ │ │ │ -
165 {
│ │ │ │ -
166 public:
│ │ │ │ -
167 inline static MPI_Datatype getType();
│ │ │ │ -
168 private:
│ │ │ │ -
169 static MPI_Datatype type;
│ │ │ │ -
170 };
│ │ │ │ -
171 template<typename T1, typename T2>
│ │ │ │ -
172 MPI_Datatype MPITraits<std::pair<T1,T2> >::getType()
│ │ │ │ -
173 {
│ │ │ │ -
174 if(type==MPI_DATATYPE_NULL) {
│ │ │ │ -
175 int length[2] = {1, 1};
│ │ │ │ -
176 MPI_Aint disp[2];
│ │ │ │ -
177 MPI_Datatype types[2] = {MPITraits<T1>::getType(),
│ │ │ │ - │ │ │ │ -
179
│ │ │ │ -
180 using Pair = std::pair<T1, T2>;
│ │ │ │ -
181 static_assert(std::is_standard_layout<Pair>::value, "offsetof() is only defined for standard layout types");
│ │ │ │ -
182 disp[0] = offsetof(Pair, first);
│ │ │ │ -
183 disp[1] = offsetof(Pair, second);
│ │ │ │ -
184
│ │ │ │ -
185 MPI_Datatype tmp;
│ │ │ │ -
186 MPI_Type_create_struct(2, length, disp, types, &tmp);
│ │ │ │ -
187
│ │ │ │ -
188 MPI_Type_create_resized(tmp, 0, sizeof(Pair), &type);
│ │ │ │ -
189 MPI_Type_commit(&type);
│ │ │ │ -
190
│ │ │ │ -
191 MPI_Type_free(&tmp);
│ │ │ │ -
192 }
│ │ │ │ -
193 return type;
│ │ │ │ -
194 }
│ │ │ │ -
195
│ │ │ │ -
196 template<typename T1, typename T2>
│ │ │ │ -
197 MPI_Datatype MPITraits<std::pair<T1,T2> >::type=MPI_DATATYPE_NULL;
│ │ │ │ -
198
│ │ │ │ -
199#endif // !DOXYGEN
│ │ │ │ -
200
│ │ │ │ -
201} // namespace Dune
│ │ │ │ -
202
│ │ │ │ -
203#endif // HAVE_MPI
│ │ │ │ -
204
│ │ │ │ -
207#endif // DUNE_COMMON_PARALLEL_MPITRAITS_HH
│ │ │ │ +
163 // The trick with `template<class U = T, class = std::void_t<expr(U)> >` is
│ │ │ │ +
164 // needed because at least g++-4.9 seems to evaluates a default argument
│ │ │ │ +
165 // in `template<class = std::void_t<expr(T))> >` as soon as possible and will
│ │ │ │ +
166 // error out if `expr(T)` is invalid. E.g. for `expr(T)` =
│ │ │ │ +
167 // `decltype(--std::declval<T&>())`, instantiating `AlignedNumber<bool>`
│ │ │ │ +
168 // will result in an unrecoverable error (`--` cannot be applied to a
│ │ │ │ +
169 // `bool`).
│ │ │ │ +
170
│ │ │ │ +
171 // Increment, decrement
│ │ │ │ +
172 template<class U = T, class = std::void_t<decltype(++std::declval<U&>())> >
│ │ │ │ +
173 AlignedNumber &operator++() { ++value_; return *this; }
│ │ │ │ +
174
│ │ │ │ +
175 template<class U = T, class = std::void_t<decltype(--std::declval<U&>())> >
│ │ │ │ +
176 AlignedNumber &operator--() { --value_; return *this; }
│ │ │ │ +
177
│ │ │ │ +
178 template<class U = T, class = std::void_t<decltype(std::declval<U&>()++)> >
│ │ │ │ +
179 decltype(auto) operator++(int) { return aligned<align>(value_++); }
│ │ │ │ +
180
│ │ │ │ +
181 template<class U = T, class = std::void_t<decltype(std::declval<U&>()--)> >
│ │ │ │ +
182 decltype(auto) operator--(int) { return aligned<align>(value_--); }
│ │ │ │ +
183
│ │ │ │ +
184 // unary operators
│ │ │ │ +
185 template<class U = T,
│ │ │ │ +
186 class = std::void_t<decltype(+std::declval<const U&>())> >
│ │ │ │ +
187 decltype(auto) operator+() const { return aligned<align>(+value_); }
│ │ │ │ +
188
│ │ │ │ +
189 template<class U = T,
│ │ │ │ +
190 class = std::void_t<decltype(-std::declval<const U&>())> >
│ │ │ │ +
191 decltype(auto) operator-() const { return aligned<align>(-value_); }
│ │ │ │ +
192
│ │ │ │ +
193 /*
│ │ │ │ +
194 * silence warnings from GCC about using `~` on a bool
│ │ │ │ +
195 * (when instantiated for T=bool)
│ │ │ │ +
196 */
│ │ │ │ +
197#if __GNUC__ >= 7
│ │ │ │ +
198# pragma GCC diagnostic push
│ │ │ │ +
199# pragma GCC diagnostic ignored "-Wbool-operation"
│ │ │ │ +
200#endif
│ │ │ │ +
201#ifdef __clang__
│ │ │ │ +
202# pragma clang diagnostic push
│ │ │ │ +
203# pragma clang diagnostic ignored "-Wbool-operation"
│ │ │ │ +
204#endif
│ │ │ │ +
205 template<class U = T,
│ │ │ │ +
206 class = std::void_t<decltype(~std::declval<const U&>())> >
│ │ │ │ +
207 decltype(auto) operator~() const { return aligned<align>(~value_); }
│ │ │ │ +
208#if __GNUC__ >= 7
│ │ │ │ +
209# pragma GCC diagnostic pop
│ │ │ │ +
210#endif
│ │ │ │ +
211#ifdef __clang__
│ │ │ │ +
212# pragma clang diagnostic pop
│ │ │ │ +
213#endif
│ │ │ │ +
214
│ │ │ │ +
215 template<class U = T,
│ │ │ │ +
216 class = std::void_t<decltype(!std::declval<const U&>())> >
│ │ │ │ +
217 decltype(auto) operator!() const { return aligned<align>(!value_); }
│ │ │ │ +
218
│ │ │ │ +
219 // assignment operators
│ │ │ │ +
│ │ │ │ +
220#define DUNE_ASSIGN_OP(OP) \
│ │ │ │ +
221 template<class U, std::size_t uAlign, \
│ │ │ │ +
222 class = std::enable_if_t< \
│ │ │ │ +
223 ( uAlign <= align && \
│ │ │ │ +
224 sizeof(std::declval<T&>() OP std::declval<U>()) ) \
│ │ │ │ +
225 > > \
│ │ │ │ +
226 AlignedNumber &operator OP(const AlignedNumber<U, uAlign> &u) \
│ │ │ │ +
227 { \
│ │ │ │ +
228 value_ OP U(u); \
│ │ │ │ +
229 return *this; \
│ │ │ │ +
230 } \
│ │ │ │ +
231 \
│ │ │ │ +
232 template<class U, \
│ │ │ │ +
233 class = std::void_t<decltype(std::declval<T&>() OP \
│ │ │ │ +
234 std::declval<U>())> > \
│ │ │ │ +
235 AlignedNumber &operator OP(const U &u) \
│ │ │ │ +
236 { \
│ │ │ │ +
237 value_ OP u; \
│ │ │ │ +
238 return *this; \
│ │ │ │ +
239 } \
│ │ │ │ +
240 \
│ │ │ │ +
241 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ +
│ │ │ │ +
242
│ │ │ │ + │ │ │ │ + │ │ │ │ +
245
│ │ │ │ + │ │ │ │ +
247 DUNE_ASSIGN_OP(/=);
│ │ │ │ +
248 DUNE_ASSIGN_OP(%=);
│ │ │ │ +
249
│ │ │ │ + │ │ │ │ +
251 DUNE_ASSIGN_OP(&=);
│ │ │ │ +
252 DUNE_ASSIGN_OP(|=);
│ │ │ │ +
253
│ │ │ │ + │ │ │ │ + │ │ │ │ +
256
│ │ │ │ +
257#undef DUNE_ASSIGN_OP
│ │ │ │ +
258 };
│ │ │ │ +
│ │ │ │ +
259
│ │ │ │ +
260 // binary operators
│ │ │ │ +
│ │ │ │ +
261#define DUNE_BINARY_OP(OP) \
│ │ │ │ +
262 template<class T, std::size_t tAlign, class U, std::size_t uAlign, \
│ │ │ │ +
263 class = std::void_t<decltype(std::declval<T>() \
│ │ │ │ +
264 OP std::declval<U>())> > \
│ │ │ │ +
265 decltype(auto) \
│ │ │ │ +
266 operator OP(const AlignedNumber<T, tAlign> &t, \
│ │ │ │ +
267 const AlignedNumber<U, uAlign> &u) \
│ │ │ │ +
268 { \
│ │ │ │ +
269 /* can't use std::max(); not constexpr */ \
│ │ │ │ +
270 return aligned<(tAlign > uAlign ? tAlign : uAlign)>(T(t) OP U(u)); \
│ │ │ │ +
271 } \
│ │ │ │ +
272 \
│ │ │ │ +
273 template<class T, class U, std::size_t uAlign, \
│ │ │ │ +
274 class = std::void_t<decltype(std::declval<T>() \
│ │ │ │ +
275 OP std::declval<U>())> > \
│ │ │ │ +
276 decltype(auto) \
│ │ │ │ +
277 operator OP(const T &t, const AlignedNumber<U, uAlign> &u) \
│ │ │ │ +
278 { \
│ │ │ │ +
279 return aligned<uAlign>(t OP U(u)); \
│ │ │ │ +
280 } \
│ │ │ │ +
281 \
│ │ │ │ +
282 template<class T, std::size_t tAlign, class U, \
│ │ │ │ +
283 class = std::void_t<decltype(std::declval<T>() \
│ │ │ │ +
284 OP std::declval<U>())> > \
│ │ │ │ +
285 decltype(auto) \
│ │ │ │ +
286 operator OP(const AlignedNumber<T, tAlign> &t, const U &u) \
│ │ │ │ +
287 { \
│ │ │ │ +
288 return aligned<tAlign>(T(t) OP u); \
│ │ │ │ +
289 } \
│ │ │ │ +
290 \
│ │ │ │ +
291 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ +
│ │ │ │ +
292
│ │ │ │ + │ │ │ │ + │ │ │ │ +
295
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
299
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
303
│ │ │ │ + │ │ │ │ + │ │ │ │ +
306
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
313
│ │ │ │ + │ │ │ │ +
315 DUNE_BINARY_OP(||);
│ │ │ │ +
316
│ │ │ │ +
317#undef DUNE_BINARY_OP
│ │ │ │ +
318
│ │ │ │ +
320 //
│ │ │ │ +
321 // Overloads for the functions provided by the standard library
│ │ │ │ +
322 //
│ │ │ │ +
323#define DUNE_UNARY_FUNC(name) \
│ │ │ │ +
324 template<class T, std::size_t align> \
│ │ │ │ +
325 decltype(auto) name(const AlignedNumber<T, align> &u) \
│ │ │ │ +
326 { \
│ │ │ │ +
327 using std::name; \
│ │ │ │ +
328 return aligned<align>(name(T(u))); \
│ │ │ │ +
329 } \
│ │ │ │ +
330 static_assert(true, "Require semicolon to unconfuse editors")
│ │ │ │ +
331
│ │ │ │ +
332 //
│ │ │ │ +
333 // <cmath> functions
│ │ │ │ +
334 //
│ │ │ │ +
335
│ │ │ │ +
336 // note: only unary functions are provided at the moment. Getting all the
│ │ │ │ +
337 // overloads right for functions with more than one argument is tricky.
│ │ │ │ +
338 // All <cmath> functions appear in the list below in the order they are
│ │ │ │ +
339 // listed in in the standard, but the unimplemented ones are commented
│ │ │ │ +
340 // out.
│ │ │ │ +
341
│ │ │ │ +
342 // note: abs is provided by both <cstdlib> (for integer) and <cmath> (for
│ │ │ │ +
343 // floating point). This overload works for both.
│ │ │ │ +
344 DUNE_UNARY_FUNC(abs);
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
350 // atan2
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
354 // copysign
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
363 // fdim
│ │ │ │ + │ │ │ │ +
365 // fma
│ │ │ │ +
366 // fmax
│ │ │ │ +
367 // fmin
│ │ │ │ +
368 // fmod
│ │ │ │ +
369 // frexp
│ │ │ │ +
370 // hypos
│ │ │ │ + │ │ │ │ +
372 // ldexp
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
383 // modf
│ │ │ │ +
384 DUNE_UNARY_FUNC(nearbyint);
│ │ │ │ +
385 // nextafter
│ │ │ │ +
386 // nexttoward
│ │ │ │ +
387 // pow
│ │ │ │ +
388 // remainder
│ │ │ │ +
389 // remquo
│ │ │ │ + │ │ │ │ + │ │ │ │ +
392 // scalbln
│ │ │ │ +
393 // scalbn
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
401
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +
407
│ │ │ │ +
408 // isgreater
│ │ │ │ +
409 // isgreaterequal
│ │ │ │ +
410 // isless
│ │ │ │ +
411 // islessequal
│ │ │ │ +
412 // islessgreater
│ │ │ │ +
413 // isunordered
│ │ │ │ +
414
│ │ │ │ +
415 //
│ │ │ │ +
416 // <complex> functions
│ │ │ │ +
417 //
│ │ │ │ +
418
│ │ │ │ +
419 // not all functions are implemented, and unlike for <cmath>, no
│ │ │ │ +
420 // comprehensive list is provided
│ │ │ │ + │ │ │ │ +
422
│ │ │ │ +
423#undef DUNE_UNARY_FUNC
│ │ │ │ +
424
│ │ │ │ +
425 // We need to overload min() and max() since they require types to be
│ │ │ │ +
426 // LessThanComparable, which requires `a<b` to be "convertible to bool".
│ │ │ │ +
427 // That wording seems to be a leftover from C++03, and today is probably
│ │ │ │ +
428 // equivalent to "implicitly convertible". There is also issue 2114
│ │ │ │ +
429 // <https://cplusplus.github.io/LWG/issue2114> in the standard (still open
│ │ │ │ +
430 // as of 2018-07-06), which strives to require both "implicitly" and
│ │ │ │ +
431 // "contextually" convertible -- plus a few other things.
│ │ │ │ +
432 //
│ │ │ │ +
433 // We do not want our debug type to automatically decay to the underlying
│ │ │ │ +
434 // type, so we do not want to make the conversion non-explicit. So the
│ │ │ │ +
435 // only option left is to overload min() and max().
│ │ │ │ +
436
│ │ │ │ +
437 template<class T, std::size_t align>
│ │ │ │ +
│ │ │ │ +
438 auto max(const AlignedNumber<T, align> &a,
│ │ │ │ + │ │ │ │ +
440 {
│ │ │ │ +
441 using std::max;
│ │ │ │ +
442 return aligned<align>(max(T(a), T(b)));
│ │ │ │ +
443 }
│ │ │ │ +
│ │ │ │ +
444
│ │ │ │ +
445 template<class T, std::size_t align>
│ │ │ │ +
│ │ │ │ +
446 auto max(const T &a, const AlignedNumber<T, align> &b)
│ │ │ │ +
447 {
│ │ │ │ +
448 using std::max;
│ │ │ │ +
449 return aligned<align>(max(a, T(b)));
│ │ │ │ +
450 }
│ │ │ │ +
│ │ │ │ +
451
│ │ │ │ +
452 template<class T, std::size_t align>
│ │ │ │ +
│ │ │ │ +
453 auto max(const AlignedNumber<T, align> &a, const T &b)
│ │ │ │ +
454 {
│ │ │ │ +
455 using std::max;
│ │ │ │ +
456 return aligned<align>(max(T(a), b));
│ │ │ │ +
457 }
│ │ │ │ +
│ │ │ │ +
458
│ │ │ │ +
459 template<class T, std::size_t align>
│ │ │ │ +
│ │ │ │ +
460 auto min(const AlignedNumber<T, align> &a,
│ │ │ │ + │ │ │ │ +
462 {
│ │ │ │ +
463 using std::min;
│ │ │ │ +
464 return aligned<align>(min(T(a), T(b)));
│ │ │ │ +
465 }
│ │ │ │ +
│ │ │ │ +
466
│ │ │ │ +
467 template<class T, std::size_t align>
│ │ │ │ +
│ │ │ │ +
468 auto min(const T &a, const AlignedNumber<T, align> &b)
│ │ │ │ +
469 {
│ │ │ │ +
470 using std::min;
│ │ │ │ +
471 return aligned<align>(min(a, T(b)));
│ │ │ │ +
472 }
│ │ │ │ +
│ │ │ │ +
473
│ │ │ │ +
474 template<class T, std::size_t align>
│ │ │ │ +
│ │ │ │ +
475 auto min(const AlignedNumber<T, align> &a, const T &b)
│ │ │ │ +
476 {
│ │ │ │ +
477 using std::min;
│ │ │ │ +
478 return aligned<align>(min(T(a), b));
│ │ │ │ +
479 }
│ │ │ │ +
│ │ │ │ +
480
│ │ │ │ +
481 } // namespace AlignedNumberImpl
│ │ │ │ +
482
│ │ │ │ +
483 // SIMD-like functions from "conditional.hh"
│ │ │ │ +
484 template<class T, std::size_t align>
│ │ │ │ +
485 AlignedNumber<T, align>
│ │ │ │ +
│ │ │ │ + │ │ │ │ + │ │ │ │ +
488 {
│ │ │ │ +
489 return b ? v1 : v2;
│ │ │ │ +
490 }
│ │ │ │ +
│ │ │ │ +
491
│ │ │ │ +
492 // SIMD-like functions from "rangeutilities.hh"
│ │ │ │ +
493 template<class T, std::size_t align>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
495 {
│ │ │ │ +
496 return T(val);
│ │ │ │ +
497 }
│ │ │ │ +
│ │ │ │ +
498
│ │ │ │ +
499 template<class T, std::size_t align>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
501 {
│ │ │ │ +
502 return T(val);
│ │ │ │ +
503 }
│ │ │ │ +
│ │ │ │ +
504
│ │ │ │ +
505 template<std::size_t align>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
507 {
│ │ │ │ +
508 return bool(val);
│ │ │ │ +
509 }
│ │ │ │ +
│ │ │ │ +
510
│ │ │ │ +
511 template<std::size_t align>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
513 {
│ │ │ │ +
514 return bool(val);
│ │ │ │ +
515 }
│ │ │ │ +
│ │ │ │ +
516
│ │ │ │ +
517 // SIMD-like functionality from "simd/interface.hh"
│ │ │ │ +
│ │ │ │ +
518 namespace Simd {
│ │ │ │ +
│ │ │ │ +
519 namespace Overloads {
│ │ │ │ +
520
│ │ │ │ +
521 template<class T, std::size_t align>
│ │ │ │ + │ │ │ │ +
523
│ │ │ │ +
524 template<class U, class T, std::size_t align>
│ │ │ │ +
│ │ │ │ +
525 struct RebindType<U, AlignedNumber<T, align> > {
│ │ │ │ + │ │ │ │ +
527 };
│ │ │ │ +
│ │ │ │ +
528
│ │ │ │ +
529 template<class T, std::size_t align>
│ │ │ │ +
530 struct LaneCount<AlignedNumber<T, align> > : index_constant<1> {};
│ │ │ │ +
531
│ │ │ │ +
532 template<class T, std::size_t align>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
534 {
│ │ │ │ +
535 assert(l == 0);
│ │ │ │ +
536 return v.value();
│ │ │ │ +
537 }
│ │ │ │ +
│ │ │ │ +
538
│ │ │ │ +
539 template<class T, std::size_t align>
│ │ │ │ +
│ │ │ │ +
540 T lane(ADLTag<5>, std::size_t l, const AlignedNumber<T, align> &v)
│ │ │ │ +
541 {
│ │ │ │ +
542 assert(l == 0);
│ │ │ │ +
543 return v.value();
│ │ │ │ +
544 }
│ │ │ │ +
│ │ │ │ +
545
│ │ │ │ +
546 template<class T, std::size_t align>
│ │ │ │ + │ │ │ │ +
│ │ │ │ + │ │ │ │ +
549 const AlignedNumber<T, align> &ifTrue,
│ │ │ │ +
550 const AlignedNumber<T, align> &ifFalse)
│ │ │ │ +
551 {
│ │ │ │ +
552 return mask ? ifTrue : ifFalse;
│ │ │ │ +
553 }
│ │ │ │ +
│ │ │ │ +
554
│ │ │ │ +
555 template<std::size_t align>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
557 {
│ │ │ │ +
558 return bool(mask);
│ │ │ │ +
559 }
│ │ │ │ +
│ │ │ │ +
560
│ │ │ │ +
561 } // namespace Overloads
│ │ │ │ +
│ │ │ │ +
562
│ │ │ │ +
563 } // namespace Simd
│ │ │ │ +
│ │ │ │ +
564
│ │ │ │ +
565} // namespace Dune
│ │ │ │ +
566
│ │ │ │ +
567#endif // DUNE_DEBUGALIGN_HH
│ │ │ │ +
Default implementations for SIMD Implementations.
│ │ │ │ +
Basic definitions for SIMD Implementations.
│ │ │ │ +
A free function to provide the demangled class name of a given object or type as a string.
│ │ │ │ +
#define DUNE_BINARY_OP(OP)
Definition debugalign.hh:261
│ │ │ │ +
#define DUNE_UNARY_FUNC(name)
│ │ │ │ +
#define DUNE_ASSIGN_OP(OP)
Definition debugalign.hh:220
│ │ │ │ + │ │ │ │ +
Traits for type conversions and type information.
│ │ │ │ +
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition indices.hh:29
│ │ │ │ +
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition bigunsignedint.hh:278
│ │ │ │ +
Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v)
implements Simd::mask()
Definition defaults.hh:153
│ │ │ │
STL namespace.
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
A traits class describing the mapping of types onto MPI_Datatypes.
Definition mpitraits.hh:41
│ │ │ │ -
static MPI_Datatype getType()
Definition mpitraits.hh:48
│ │ │ │ -
static constexpr bool is_intrinsic
Definition mpitraits.hh:56
│ │ │ │ -
static constexpr int n
Definition bigunsignedint.hh:78
│ │ │ │ -
vector space out of a tensor product of fields.
Definition fvector.hh:91
│ │ │ │ +
void violatedAlignment(const char *className, std::size_t expectedAlignment, const void *address)
called when an alignment violation is detected
Definition debugalign.cc:36
│ │ │ │ +
bool any_true(const AlignedNumber< bool, align > &val)
Definition debugalign.hh:506
│ │ │ │ +
bool all_true(const AlignedNumber< bool, align > &val)
Definition debugalign.hh:512
│ │ │ │ +
std::string className()
Provide the demangled class name of a type T as a string.
Definition classname.hh:47
│ │ │ │ +
static constexpr auto debugAlignment
an alignment large enough to trigger alignment errors
Definition debugalign.hh:97
│ │ │ │ +
const T1 cond(bool b, const T1 &v1, const T2 &v2)
conditional evaluate
Definition conditional.hh:28
│ │ │ │ +
AlignedNumber< T, align > aligned(T value)
align a value to a certain alignment
Definition debugalign.hh:114
│ │ │ │ +
ViolatedAlignmentHandler & violatedAlignmentHandler()
access the handler called by violatedAlignment()
Definition debugalign.cc:30
│ │ │ │ +
bool isAligned(const void *p, std::size_t align)
check whether an address conforms to the given alignment
Definition debugalign.hh:56
│ │ │ │ +
T max_value(const AlignedNumber< T, align > &val)
Definition debugalign.hh:494
│ │ │ │ +
std::function< void(const char *, std::size_t, const void *)> ViolatedAlignmentHandler
type of the handler called by violatedAlignment()
Definition debugalign.hh:31
│ │ │ │ +
T min_value(const AlignedNumber< T, align > &val)
Definition debugalign.hh:500
│ │ │ │ +
bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask)
Definition debugalign.hh:556
│ │ │ │ +
T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v)
Definition debugalign.hh:533
│ │ │ │ +
Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
Definition typetraits.hh:194
│ │ │ │ +
CRTP base mixin class to check alignment.
Definition debugalign.hh:66
│ │ │ │ +
aligned wrappers for arithmetic types
Definition debugalign.hh:128
│ │ │ │ + │ │ │ │ + │ │ │ │ +
decltype(auto) operator+() const
Definition debugalign.hh:187
│ │ │ │ + │ │ │ │ +
decltype(auto) operator--(int)
Definition debugalign.hh:182
│ │ │ │ +
DUNE_ASSIGN_OP * DUNE_ASSIGN_OP(/=);DUNE_ASSIGN_OP(%=
│ │ │ │ +
decltype(auto) operator++(int)
Definition debugalign.hh:179
│ │ │ │ +
decltype(auto) operator!() const
Definition debugalign.hh:217
│ │ │ │ +
T & value()
Definition debugalign.hh:145
│ │ │ │ +
const T & value() const
Definition debugalign.hh:144
│ │ │ │ +
DUNE_ASSIGN_OP^ DUNE_ASSIGN_OP(&=);DUNE_ASSIGN_OP(|=
│ │ │ │ +
friend std::basic_istream< charT, Traits > & operator>>(std::basic_istream< charT, Traits > &str, AlignedNumber &u)
Definition debugalign.hh:150
│ │ │ │ + │ │ │ │ + │ │ │ │ +
decltype(auto) operator~() const
Definition debugalign.hh:207
│ │ │ │ +
AlignedNumber(T value)
Definition debugalign.hh:133
│ │ │ │ +
AlignedNumber(const AlignedNumber< U, uAlign > &o)
Definition debugalign.hh:137
│ │ │ │ +
decltype(auto) operator-() const
Definition debugalign.hh:191
│ │ │ │ + │ │ │ │ +
Tag used to force late-binding lookup in Dune::Simd::Overloads.
Definition base.hh:182
│ │ │ │ +
should have a member type type
Definition standard.hh:60
│ │ │ │ +
should have a member type type
Definition standard.hh:67
│ │ │ │ +
should be derived from a Dune::index_constant
Definition standard.hh:74
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,221 +1,701 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -mpitraits.hh │ │ │ │ │ +debugalign.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PARALLEL_MPITRAITS_HH │ │ │ │ │ -6#define DUNE_COMMON_PARALLEL_MPITRAITS_HH │ │ │ │ │ +5#ifndef DUNE_DEBUGALIGN_HH │ │ │ │ │ +6#define DUNE_DEBUGALIGN_HH │ │ │ │ │ 7 │ │ │ │ │ -18#if HAVE_MPI │ │ │ │ │ -19 │ │ │ │ │ -20#include │ │ │ │ │ -21#include │ │ │ │ │ -22#include │ │ │ │ │ -23#include │ │ │ │ │ -24#include │ │ │ │ │ -25 │ │ │ │ │ -26#include │ │ │ │ │ -27 │ │ │ │ │ -28namespace Dune │ │ │ │ │ -29{ │ │ │ │ │ -39 template │ │ │ │ │ -40 struct MPITraits │ │ │ │ │ -41 { │ │ │ │ │ -42 private: │ │ │ │ │ -43 MPITraits(){} │ │ │ │ │ -44 MPITraits(const MPITraits&){} │ │ │ │ │ -45 static MPI_Datatype datatype; │ │ │ │ │ -46 static MPI_Datatype vectortype; │ │ │ │ │ -47 public: │ │ │ │ │ -48 static inline MPI_Datatype getType() │ │ │ │ │ -49 { │ │ │ │ │ -50 if(datatype==MPI_DATATYPE_NULL) { │ │ │ │ │ -51 MPI_Type_contiguous(sizeof(T),MPI_BYTE,&datatype); │ │ │ │ │ -52 MPI_Type_commit(&datatype); │ │ │ │ │ -53 } │ │ │ │ │ -54 return datatype; │ │ │ │ │ -55 } │ │ │ │ │ -56 static constexpr bool is_intrinsic = false; │ │ │ │ │ -57 }; │ │ │ │ │ -58 template │ │ │ │ │ -59 MPI_Datatype MPITraits::datatype = MPI_DATATYPE_NULL; │ │ │ │ │ -60 │ │ │ │ │ -61#ifndef DOXYGEN │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11#include │ │ │ │ │ +12#include │ │ │ │ │ +13#include │ │ │ │ │ +14#include // abs │ │ │ │ │ +15#include │ │ │ │ │ +16#include │ │ │ │ │ +17#include │ │ │ │ │ +18#include │ │ │ │ │ +19#include │ │ │ │ │ +20 │ │ │ │ │ +21#include │ │ │ │ │ +22#include │ │ │ │ │ +23#include │ │ │ │ │ +24#include │ │ │ │ │ +25#include │ │ │ │ │ +26 │ │ │ │ │ +27namespace Dune { │ │ │ │ │ +28 │ │ │ │ │ +30 using ViolatedAlignmentHandler = │ │ │ │ │ +31 std::function; │ │ │ │ │ +32 │ │ │ │ │ +34 │ │ │ │ │ +40 ViolatedAlignmentHandler &violatedAlignmentHandler(); │ │ │ │ │ +41 │ │ │ │ │ +43 │ │ │ │ │ +52 void violatedAlignment(const char *className, std::size_t expectedAlignment, │ │ │ │ │ +53 const void *address); │ │ │ │ │ +54 │ │ │ │ │ +56 inline bool isAligned(const void *p, std::size_t align) │ │ │ │ │ +57 { │ │ │ │ │ +58 void* aligned_p = (void*)p; │ │ │ │ │ +59 std::size_t space = align*2; │ │ │ │ │ +60 return p == std::align(align, align, aligned_p, space); │ │ │ │ │ +61 } │ │ │ │ │ 62 │ │ │ │ │ -63 // A Macro for defining traits for the primitive data types │ │ │ │ │ -64#define ComposeMPITraits(p,m) \ │ │ │ │ │ -65 template<> \ │ │ │ │ │ -66 struct MPITraits

{ \ │ │ │ │ │ -67 static inline MPI_Datatype getType(){ \ │ │ │ │ │ -68 return m; \ │ │ │ │ │ -69 } \ │ │ │ │ │ -70 static constexpr bool is_intrinsic = true; \ │ │ │ │ │ -71 } │ │ │ │ │ -72 │ │ │ │ │ -73 ComposeMPITraits(char, MPI_CHAR); │ │ │ │ │ -74 ComposeMPITraits(unsigned char,MPI_UNSIGNED_CHAR); │ │ │ │ │ -75 ComposeMPITraits(short,MPI_SHORT); │ │ │ │ │ -76 ComposeMPITraits(unsigned short,MPI_UNSIGNED_SHORT); │ │ │ │ │ -77 ComposeMPITraits(int,MPI_INT); │ │ │ │ │ -78 ComposeMPITraits(unsigned int,MPI_UNSIGNED); │ │ │ │ │ -79 ComposeMPITraits(long,MPI_LONG); │ │ │ │ │ -80 ComposeMPITraits(unsigned long,MPI_UNSIGNED_LONG); │ │ │ │ │ -81 ComposeMPITraits(float,MPI_FLOAT); │ │ │ │ │ -82 ComposeMPITraits(double,MPI_DOUBLE); │ │ │ │ │ -83 ComposeMPITraits(long double,MPI_LONG_DOUBLE); │ │ │ │ │ -84 ComposeMPITraits(std::complex, MPI_CXX_DOUBLE_COMPLEX); │ │ │ │ │ -85 ComposeMPITraits(std::complex, MPI_CXX_LONG_DOUBLE_COMPLEX); │ │ │ │ │ -86 ComposeMPITraits(std::complex, MPI_CXX_FLOAT_COMPLEX); │ │ │ │ │ -87 │ │ │ │ │ -88 │ │ │ │ │ -89#undef ComposeMPITraits │ │ │ │ │ -90 │ │ │ │ │ -91 template class FieldVector; │ │ │ │ │ -92 │ │ │ │ │ -93 template │ │ │ │ │ -94 struct MPITraits > │ │ │ │ │ -95 { │ │ │ │ │ -96 static MPI_Datatype datatype; │ │ │ │ │ -97 static MPI_Datatype vectortype; │ │ │ │ │ +64 template │ │ │ │ │ +65 struct alignas(align) AlignedBase │ │ │ │ │ +66 { │ │ │ │ │ +75 static void* operator new(std::size_t count, void* ptr) { │ │ │ │ │ +76 if(!isAligned(ptr, align)) │ │ │ │ │ +77 violatedAlignment(className().c_str(), align, ptr); │ │ │ │ │ +78 return ::operator new(count*sizeof(Impl), ptr); │ │ │ │ │ +79 } │ │ │ │ │ +80 │ │ │ │ │ +89 static void* operator new[](std::size_t count, void* ptr) { │ │ │ │ │ +90 if(!isAligned(ptr, align)) │ │ │ │ │ +91 violatedAlignment(className().c_str(), align, ptr); │ │ │ │ │ +92 return ::operator new[](count*sizeof(Impl), ptr); │ │ │ │ │ +93 } │ │ │ │ │ +94 }; │ │ │ │ │ +95 │ │ │ │ │ +97 static constexpr auto debugAlignment = 2*alignof(std::max_align_t); │ │ │ │ │ 98 │ │ │ │ │ -99 static inline MPI_Datatype getType() │ │ │ │ │ -100 { │ │ │ │ │ -101 if(datatype==MPI_DATATYPE_NULL) { │ │ │ │ │ -102 MPI_Type_contiguous(n, MPITraits::getType(), &vectortype); │ │ │ │ │ -103 MPI_Type_commit(&vectortype); │ │ │ │ │ -104 FieldVector fvector; │ │ │ │ │ -105 MPI_Aint base; │ │ │ │ │ -106 MPI_Aint displ; │ │ │ │ │ -107 MPI_Get_address(&fvector, &base); │ │ │ │ │ -108 MPI_Get_address(&(fvector[0]), &displ); │ │ │ │ │ -109 displ -= base; │ │ │ │ │ -110 int length[1]={1}; │ │ │ │ │ +99 namespace AlignedNumberImpl { │ │ │ │ │ +100 │ │ │ │ │ +101 template │ │ │ │ │ +102 class AlignedNumber; │ │ │ │ │ +103 │ │ │ │ │ +104 } // namespace AlignedNumberImpl │ │ │ │ │ +105 │ │ │ │ │ +106 using AlignedNumberImpl::AlignedNumber; │ │ │ │ │ +107 │ │ │ │ │ +108 template │ │ │ │ │ +109 struct IsNumber> │ │ │ │ │ +110 : public std::true_type {}; │ │ │ │ │ 111 │ │ │ │ │ -112 MPI_Type_create_struct(1, length, &displ, &vectortype, &datatype); │ │ │ │ │ -113 MPI_Type_commit(&datatype); │ │ │ │ │ -114 } │ │ │ │ │ -115 return datatype; │ │ │ │ │ -116 } │ │ │ │ │ -117 │ │ │ │ │ -118 }; │ │ │ │ │ -119 │ │ │ │ │ -120 template │ │ │ │ │ -121 MPI_Datatype MPITraits >::datatype = MPI_DATATYPE_NULL; │ │ │ │ │ -122 template │ │ │ │ │ -123 MPI_Datatype MPITraits >::vectortype = {MPI_DATATYPE_ │ │ │ │ │ -NULL}; │ │ │ │ │ -124 │ │ │ │ │ -125 │ │ │ │ │ -126 template │ │ │ │ │ -127 class bigunsignedint; │ │ │ │ │ -128 │ │ │ │ │ -129 template │ │ │ │ │ -130 struct MPITraits > │ │ │ │ │ -131 { │ │ │ │ │ -132 static MPI_Datatype datatype; │ │ │ │ │ -133 static MPI_Datatype vectortype; │ │ │ │ │ -134 │ │ │ │ │ -135 static inline MPI_Datatype getType() │ │ │ │ │ -136 { │ │ │ │ │ -137 if(datatype==MPI_DATATYPE_NULL) { │ │ │ │ │ -138 MPI_Type_contiguous(bigunsignedint::n, MPITraits::getType │ │ │ │ │ -(), │ │ │ │ │ -139 &vectortype); │ │ │ │ │ -140 //MPI_Type_commit(&vectortype); │ │ │ │ │ -141 bigunsignedint data; │ │ │ │ │ -142 MPI_Aint base; │ │ │ │ │ -143 MPI_Aint displ; │ │ │ │ │ -144 MPI_Get_address(&data, &base); │ │ │ │ │ -145 MPI_Get_address(&(data.digit), &displ); │ │ │ │ │ -146 displ -= base; │ │ │ │ │ -147 int length[1]={1}; │ │ │ │ │ -148 MPI_Type_create_struct(1, length, &displ, &vectortype, &datatype); │ │ │ │ │ -149 MPI_Type_commit(&datatype); │ │ │ │ │ -150 } │ │ │ │ │ -151 return datatype; │ │ │ │ │ -152 } │ │ │ │ │ -153 }; │ │ │ │ │ -154} │ │ │ │ │ -155 │ │ │ │ │ -156namespace Dune │ │ │ │ │ -157{ │ │ │ │ │ -158 template │ │ │ │ │ -159 MPI_Datatype MPITraits >::datatype = MPI_DATATYPE_NULL; │ │ │ │ │ -160 template │ │ │ │ │ -161 MPI_Datatype MPITraits >::vectortype = MPI_DATATYPE_NULL; │ │ │ │ │ +113 template │ │ │ │ │ +114 AlignedNumber aligned(T value) { return { std::move(value) }; } │ │ │ │ │ +115 │ │ │ │ │ +116 // The purpose of this namespace is to move the `` function │ │ │ │ │ +overloads │ │ │ │ │ +117 // out of namespace `Dune`. This avoids problems where people called │ │ │ │ │ +118 // e.g. `sqrt(1.0)` inside the `Dune` namespace, without first doing `using │ │ │ │ │ +119 // std::sqrt;`. Without any `Dune::sqrt()`, such a use will find │ │ │ │ │ +120 // `::sqrt()`, but with `Dune::sqrt()` it will find only `Dune::sqrt()`, │ │ │ │ │ +121 // which does not have an overload for `double`. │ │ │ │ │ +122 namespace AlignedNumberImpl { │ │ │ │ │ +123 │ │ │ │ │ +125 template │ │ │ │ │ +126 class AlignedNumber │ │ │ │ │ +127 : public AlignedBase > │ │ │ │ │ +128 { │ │ │ │ │ +129 T value_; │ │ │ │ │ +130 │ │ │ │ │ +131 public: │ │ │ │ │ +132 AlignedNumber() = default; │ │ │ │ │ +133 AlignedNumber(T value) : value_(std::move(value)) {} │ │ │ │ │ +134 template= uAlign) && │ │ │ │ │ +136 std::is_convertible::value> > │ │ │ │ │ +137 AlignedNumber(const AlignedNumber &o) : value_(U(o)) {} │ │ │ │ │ +138 │ │ │ │ │ +139 // accessors │ │ │ │ │ +140 template::value> > │ │ │ │ │ +142 explicit operator U() const { return value_; } │ │ │ │ │ +143 │ │ │ │ │ +144 const T &value() const { return value_; } │ │ │ │ │ +145 T &value() { return value_; } │ │ │ │ │ +146 │ │ │ │ │ +147 // I/O │ │ │ │ │ +148 template │ │ │ │ │ +149 friend std::basic_istream& │ │ │ │ │ +150 operator>>(std::basic_istream& str, AlignedNumber &u) │ │ │ │ │ +151 { │ │ │ │ │ +152 return str >> u.value_; │ │ │ │ │ +153 } │ │ │ │ │ +154 │ │ │ │ │ +155 template │ │ │ │ │ +156 friend std::basic_ostream& │ │ │ │ │ +157 operator<<(std::basic_ostream& str, │ │ │ │ │ +158 const AlignedNumber &u) │ │ │ │ │ +159 { │ │ │ │ │ +160 return str << u.value_; │ │ │ │ │ +161 } │ │ │ │ │ 162 │ │ │ │ │ -163 template │ │ │ │ │ -164 struct MPITraits > │ │ │ │ │ -165 { │ │ │ │ │ -166 public: │ │ │ │ │ -167 inline static MPI_Datatype getType(); │ │ │ │ │ -168 private: │ │ │ │ │ -169 static MPI_Datatype type; │ │ │ │ │ -170 }; │ │ │ │ │ -171 template │ │ │ │ │ -172 MPI_Datatype MPITraits >::getType() │ │ │ │ │ -173 { │ │ │ │ │ -174 if(type==MPI_DATATYPE_NULL) { │ │ │ │ │ -175 int length[2] = {1, 1}; │ │ │ │ │ -176 MPI_Aint disp[2]; │ │ │ │ │ -177 MPI_Datatype types[2] = {MPITraits::getType(), │ │ │ │ │ -178 MPITraits::getType()}; │ │ │ │ │ -179 │ │ │ │ │ -180 using Pair = std::pair; │ │ │ │ │ -181 static_assert(std::is_standard_layout::value, "offsetof() is only │ │ │ │ │ -defined for standard layout types"); │ │ │ │ │ -182 disp[0] = offsetof(Pair, first); │ │ │ │ │ -183 disp[1] = offsetof(Pair, second); │ │ │ │ │ -184 │ │ │ │ │ -185 MPI_Datatype tmp; │ │ │ │ │ -186 MPI_Type_create_struct(2, length, disp, types, &tmp); │ │ │ │ │ -187 │ │ │ │ │ -188 MPI_Type_create_resized(tmp, 0, sizeof(Pair), &type); │ │ │ │ │ -189 MPI_Type_commit(&type); │ │ │ │ │ -190 │ │ │ │ │ -191 MPI_Type_free(&tmp); │ │ │ │ │ -192 } │ │ │ │ │ -193 return type; │ │ │ │ │ -194 } │ │ │ │ │ -195 │ │ │ │ │ -196 template │ │ │ │ │ -197 MPI_Datatype MPITraits >::type=MPI_DATATYPE_NULL; │ │ │ │ │ -198 │ │ │ │ │ -199#endif // !DOXYGEN │ │ │ │ │ -200 │ │ │ │ │ -201} // namespace Dune │ │ │ │ │ -202 │ │ │ │ │ -203#endif // HAVE_MPI │ │ │ │ │ -204 │ │ │ │ │ -207#endif // DUNE_COMMON_PARALLEL_MPITRAITS_HH │ │ │ │ │ +163 // The trick with `template >` is │ │ │ │ │ +164 // needed because at least g++-4.9 seems to evaluates a default argument │ │ │ │ │ +165 // in `template >` as soon as possible and │ │ │ │ │ +will │ │ │ │ │ +166 // error out if `expr(T)` is invalid. E.g. for `expr(T)` = │ │ │ │ │ +167 // `decltype(--std::declval())`, instantiating `AlignedNumber` │ │ │ │ │ +168 // will result in an unrecoverable error (`--` cannot be applied to a │ │ │ │ │ +169 // `bool`). │ │ │ │ │ +170 │ │ │ │ │ +171 // Increment, decrement │ │ │ │ │ +172 template())> > │ │ │ │ │ +173 AlignedNumber &operator++() { ++value_; return *this; } │ │ │ │ │ +174 │ │ │ │ │ +175 template())> > │ │ │ │ │ +176 AlignedNumber &operator--() { --value_; return *this; } │ │ │ │ │ +177 │ │ │ │ │ +178 template()++)> > │ │ │ │ │ +179 decltype(auto) operator++(int) { return aligned(value_++); } │ │ │ │ │ +180 │ │ │ │ │ +181 template()--)> > │ │ │ │ │ +182 decltype(auto) operator--(int) { return aligned(value_--); } │ │ │ │ │ +183 │ │ │ │ │ +184 // unary operators │ │ │ │ │ +185 template())> > │ │ │ │ │ +187 decltype(auto) operator+() const { return aligned(+value_); } │ │ │ │ │ +188 │ │ │ │ │ +189 template())> > │ │ │ │ │ +191 decltype(auto) operator-() const { return aligned(-value_); } │ │ │ │ │ +192 │ │ │ │ │ +193 /* │ │ │ │ │ +194 * silence warnings from GCC about using `~` on a bool │ │ │ │ │ +195 * (when instantiated for T=bool) │ │ │ │ │ +196 */ │ │ │ │ │ +197#if __GNUC__ >= 7 │ │ │ │ │ +198# pragma GCC diagnostic push │ │ │ │ │ +199# pragma GCC diagnostic ignored "-Wbool-operation" │ │ │ │ │ +200#endif │ │ │ │ │ +201#ifdef __clang__ │ │ │ │ │ +202# pragma clang diagnostic push │ │ │ │ │ +203# pragma clang diagnostic ignored "-Wbool-operation" │ │ │ │ │ +204#endif │ │ │ │ │ +205 template())> > │ │ │ │ │ +207 decltype(auto) operator~() const { return aligned(~value_); } │ │ │ │ │ +208#if __GNUC__ >= 7 │ │ │ │ │ +209# pragma GCC diagnostic pop │ │ │ │ │ +210#endif │ │ │ │ │ +211#ifdef __clang__ │ │ │ │ │ +212# pragma clang diagnostic pop │ │ │ │ │ +213#endif │ │ │ │ │ +214 │ │ │ │ │ +215 template())> > │ │ │ │ │ +217 decltype(auto) operator!() const { return aligned(!value_); } │ │ │ │ │ +218 │ │ │ │ │ +219 // assignment operators │ │ │ │ │ +220#define DUNE_ASSIGN_OP(OP) \ │ │ │ │ │ +221 template() OP std::declval()) ) \ │ │ │ │ │ +225 > > \ │ │ │ │ │ +226 AlignedNumber &operator OP(const AlignedNumber &u) \ │ │ │ │ │ +227 { \ │ │ │ │ │ +228 value_ OP U(u); \ │ │ │ │ │ +229 return *this; \ │ │ │ │ │ +230 } \ │ │ │ │ │ +231 \ │ │ │ │ │ +232 template() OP \ │ │ │ │ │ +234 std::declval())> > \ │ │ │ │ │ +235 AlignedNumber &operator OP(const U &u) \ │ │ │ │ │ +236 { \ │ │ │ │ │ +237 value_ OP u; \ │ │ │ │ │ +238 return *this; \ │ │ │ │ │ +239 } \ │ │ │ │ │ +240 \ │ │ │ │ │ +241 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ +242 │ │ │ │ │ +243 DUNE_ASSIGN_OP(+=); │ │ │ │ │ +244 DUNE_ASSIGN_OP(-=); │ │ │ │ │ +245 │ │ │ │ │ +246 DUNE_ASSIGN_OP(*=); │ │ │ │ │ +247 DUNE_ASSIGN_OP(/=); │ │ │ │ │ +248 DUNE_ASSIGN_OP(%=); │ │ │ │ │ +249 │ │ │ │ │ +250 DUNE_ASSIGN_OP(^=); │ │ │ │ │ +251 DUNE_ASSIGN_OP(&=); │ │ │ │ │ +252 DUNE_ASSIGN_OP(|=); │ │ │ │ │ +253 │ │ │ │ │ +254 DUNE_ASSIGN_OP(<<=); │ │ │ │ │ +255 DUNE_ASSIGN_OP(>>=); │ │ │ │ │ +256 │ │ │ │ │ +257#undef DUNE_ASSIGN_OP │ │ │ │ │ +258 }; │ │ │ │ │ +259 │ │ │ │ │ +260 // binary operators │ │ │ │ │ +261#define DUNE_BINARY_OP(OP) \ │ │ │ │ │ +262 template() \ │ │ │ │ │ +264 OP std::declval())> > \ │ │ │ │ │ +265 decltype(auto) \ │ │ │ │ │ +266 operator OP(const AlignedNumber &t, \ │ │ │ │ │ +267 const AlignedNumber &u) \ │ │ │ │ │ +268 { \ │ │ │ │ │ +269 /* can't use std::max(); not constexpr */ \ │ │ │ │ │ +270 return aligned<(tAlign > uAlign ? tAlign : uAlign)>(T(t) OP U(u)); \ │ │ │ │ │ +271 } \ │ │ │ │ │ +272 \ │ │ │ │ │ +273 template() \ │ │ │ │ │ +275 OP std::declval())> > \ │ │ │ │ │ +276 decltype(auto) \ │ │ │ │ │ +277 operator OP(const T &t, const AlignedNumber &u) \ │ │ │ │ │ +278 { \ │ │ │ │ │ +279 return aligned(t OP U(u)); \ │ │ │ │ │ +280 } \ │ │ │ │ │ +281 \ │ │ │ │ │ +282 template() \ │ │ │ │ │ +284 OP std::declval())> > \ │ │ │ │ │ +285 decltype(auto) \ │ │ │ │ │ +286 operator OP(const AlignedNumber &t, const U &u) \ │ │ │ │ │ +287 { \ │ │ │ │ │ +288 return aligned(T(t) OP u); \ │ │ │ │ │ +289 } \ │ │ │ │ │ +290 \ │ │ │ │ │ +291 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ +292 │ │ │ │ │ +293 DUNE_BINARY_OP(+); │ │ │ │ │ +294 DUNE_BINARY_OP(-); │ │ │ │ │ +295 │ │ │ │ │ +296 DUNE_BINARY_OP(*); │ │ │ │ │ +297 DUNE_BINARY_OP(/); │ │ │ │ │ +298 DUNE_BINARY_OP(%); │ │ │ │ │ +299 │ │ │ │ │ +300 DUNE_BINARY_OP(^); │ │ │ │ │ +301 DUNE_BINARY_OP(&); │ │ │ │ │ +302 DUNE_BINARY_OP(|); │ │ │ │ │ +303 │ │ │ │ │ +304 DUNE_BINARY_OP(<<); │ │ │ │ │ +305 DUNE_BINARY_OP(>>); │ │ │ │ │ +306 │ │ │ │ │ +307 DUNE_BINARY_OP(==); │ │ │ │ │ +308 DUNE_BINARY_OP(!=); │ │ │ │ │ +309 DUNE_BINARY_OP(<); │ │ │ │ │ +310 DUNE_BINARY_OP(>); │ │ │ │ │ +311 DUNE_BINARY_OP(<=); │ │ │ │ │ +312 DUNE_BINARY_OP(>=); │ │ │ │ │ +313 │ │ │ │ │ +314 DUNE_BINARY_OP(&&); │ │ │ │ │ +315 DUNE_BINARY_OP(||); │ │ │ │ │ +316 │ │ │ │ │ +317#undef DUNE_BINARY_OP │ │ │ │ │ +318 │ │ │ │ │ +320 // │ │ │ │ │ +321 // Overloads for the functions provided by the standard library │ │ │ │ │ +322 // │ │ │ │ │ +323#define DUNE_UNARY_FUNC(name) \ │ │ │ │ │ +324 template \ │ │ │ │ │ +325 decltype(auto) name(const AlignedNumber &u) \ │ │ │ │ │ +326 { \ │ │ │ │ │ +327 using std::name; \ │ │ │ │ │ +328 return aligned(name(T(u))); \ │ │ │ │ │ +329 } \ │ │ │ │ │ +330 static_assert(true, "Require semicolon to unconfuse editors") │ │ │ │ │ +331 │ │ │ │ │ +332 // │ │ │ │ │ +333 // functions │ │ │ │ │ +334 // │ │ │ │ │ +335 │ │ │ │ │ +336 // note: only unary functions are provided at the moment. Getting all the │ │ │ │ │ +337 // overloads right for functions with more than one argument is tricky. │ │ │ │ │ +338 // All functions appear in the list below in the order they are │ │ │ │ │ +339 // listed in in the standard, but the unimplemented ones are commented │ │ │ │ │ +340 // out. │ │ │ │ │ +341 │ │ │ │ │ +342 // note: abs is provided by both (for integer) and (for │ │ │ │ │ +343 // floating point). This overload works for both. │ │ │ │ │ +344 DUNE_UNARY_FUNC(abs); │ │ │ │ │ +345 DUNE_UNARY_FUNC(acos); │ │ │ │ │ +346 DUNE_UNARY_FUNC(acosh); │ │ │ │ │ +347 DUNE_UNARY_FUNC(asin); │ │ │ │ │ +348 DUNE_UNARY_FUNC(asinh); │ │ │ │ │ +349 DUNE_UNARY_FUNC(atan); │ │ │ │ │ +350 // atan2 │ │ │ │ │ +351 DUNE_UNARY_FUNC(atanh); │ │ │ │ │ +352 DUNE_UNARY_FUNC(cbrt); │ │ │ │ │ +353 DUNE_UNARY_FUNC(ceil); │ │ │ │ │ +354 // copysign │ │ │ │ │ +355 DUNE_UNARY_FUNC(cos); │ │ │ │ │ +356 DUNE_UNARY_FUNC(cosh); │ │ │ │ │ +357 DUNE_UNARY_FUNC(erf); │ │ │ │ │ +358 DUNE_UNARY_FUNC(erfc); │ │ │ │ │ +359 DUNE_UNARY_FUNC(exp); │ │ │ │ │ +360 DUNE_UNARY_FUNC(exp2); │ │ │ │ │ +361 DUNE_UNARY_FUNC(expm1); │ │ │ │ │ +362 DUNE_UNARY_FUNC(fabs); │ │ │ │ │ +363 // fdim │ │ │ │ │ +364 DUNE_UNARY_FUNC(floor); │ │ │ │ │ +365 // fma │ │ │ │ │ +366 // fmax │ │ │ │ │ +367 // fmin │ │ │ │ │ +368 // fmod │ │ │ │ │ +369 // frexp │ │ │ │ │ +370 // hypos │ │ │ │ │ +371 DUNE_UNARY_FUNC(ilogb); │ │ │ │ │ +372 // ldexp │ │ │ │ │ +373 DUNE_UNARY_FUNC(lgamma); │ │ │ │ │ +374 DUNE_UNARY_FUNC(llrint); │ │ │ │ │ +375 DUNE_UNARY_FUNC(llround); │ │ │ │ │ +376 DUNE_UNARY_FUNC(log); │ │ │ │ │ +377 DUNE_UNARY_FUNC(log10); │ │ │ │ │ +378 DUNE_UNARY_FUNC(log1p); │ │ │ │ │ +379 DUNE_UNARY_FUNC(log2); │ │ │ │ │ +380 DUNE_UNARY_FUNC(logb); │ │ │ │ │ +381 DUNE_UNARY_FUNC(lrint); │ │ │ │ │ +382 DUNE_UNARY_FUNC(lround); │ │ │ │ │ +383 // modf │ │ │ │ │ +384 DUNE_UNARY_FUNC(nearbyint); │ │ │ │ │ +385 // nextafter │ │ │ │ │ +386 // nexttoward │ │ │ │ │ +387 // pow │ │ │ │ │ +388 // remainder │ │ │ │ │ +389 // remquo │ │ │ │ │ +390 DUNE_UNARY_FUNC(rint); │ │ │ │ │ +391 DUNE_UNARY_FUNC(round); │ │ │ │ │ +392 // scalbln │ │ │ │ │ +393 // scalbn │ │ │ │ │ +394 DUNE_UNARY_FUNC(sin); │ │ │ │ │ +395 DUNE_UNARY_FUNC(sinh); │ │ │ │ │ +396 DUNE_UNARY_FUNC(sqrt); │ │ │ │ │ +397 DUNE_UNARY_FUNC(tan); │ │ │ │ │ +398 DUNE_UNARY_FUNC(tanh); │ │ │ │ │ +399 DUNE_UNARY_FUNC(tgamma); │ │ │ │ │ +400 DUNE_UNARY_FUNC(trunc); │ │ │ │ │ +401 │ │ │ │ │ +402 DUNE_UNARY_FUNC(isfinite); │ │ │ │ │ +403 DUNE_UNARY_FUNC(isinf); │ │ │ │ │ +404 DUNE_UNARY_FUNC(isnan); │ │ │ │ │ +405 DUNE_UNARY_FUNC(isnormal); │ │ │ │ │ +406 DUNE_UNARY_FUNC(signbit); │ │ │ │ │ +407 │ │ │ │ │ +408 // isgreater │ │ │ │ │ +409 // isgreaterequal │ │ │ │ │ +410 // isless │ │ │ │ │ +411 // islessequal │ │ │ │ │ +412 // islessgreater │ │ │ │ │ +413 // isunordered │ │ │ │ │ +414 │ │ │ │ │ +415 // │ │ │ │ │ +416 // functions │ │ │ │ │ +417 // │ │ │ │ │ +418 │ │ │ │ │ +419 // not all functions are implemented, and unlike for , no │ │ │ │ │ +420 // comprehensive list is provided │ │ │ │ │ +421 DUNE_UNARY_FUNC(real); │ │ │ │ │ +422 │ │ │ │ │ +423#undef DUNE_UNARY_FUNC │ │ │ │ │ +424 │ │ │ │ │ +425 // We need to overload min() and max() since they require types to be │ │ │ │ │ +426 // LessThanComparable, which requires `a in the standard (still open │ │ │ │ │ +430 // as of 2018-07-06), which strives to require both "implicitly" and │ │ │ │ │ +431 // "contextually" convertible -- plus a few other things. │ │ │ │ │ +432 // │ │ │ │ │ +433 // We do not want our debug type to automatically decay to the underlying │ │ │ │ │ +434 // type, so we do not want to make the conversion non-explicit. So the │ │ │ │ │ +435 // only option left is to overload min() and max(). │ │ │ │ │ +436 │ │ │ │ │ +437 template │ │ │ │ │ +438 auto max(const AlignedNumber &a, │ │ │ │ │ +439 const AlignedNumber &b) │ │ │ │ │ +440 { │ │ │ │ │ +441 using std::max; │ │ │ │ │ +442 return aligned(max(T(a), T(b))); │ │ │ │ │ +443 } │ │ │ │ │ +444 │ │ │ │ │ +445 template │ │ │ │ │ +446 auto max(const T &a, const AlignedNumber &b) │ │ │ │ │ +447 { │ │ │ │ │ +448 using std::max; │ │ │ │ │ +449 return aligned(max(a, T(b))); │ │ │ │ │ +450 } │ │ │ │ │ +451 │ │ │ │ │ +452 template │ │ │ │ │ +453 auto max(const AlignedNumber &a, const T &b) │ │ │ │ │ +454 { │ │ │ │ │ +455 using std::max; │ │ │ │ │ +456 return aligned(max(T(a), b)); │ │ │ │ │ +457 } │ │ │ │ │ +458 │ │ │ │ │ +459 template │ │ │ │ │ +460 auto min(const AlignedNumber &a, │ │ │ │ │ +461 const AlignedNumber &b) │ │ │ │ │ +462 { │ │ │ │ │ +463 using std::min; │ │ │ │ │ +464 return aligned(min(T(a), T(b))); │ │ │ │ │ +465 } │ │ │ │ │ +466 │ │ │ │ │ +467 template │ │ │ │ │ +468 auto min(const T &a, const AlignedNumber &b) │ │ │ │ │ +469 { │ │ │ │ │ +470 using std::min; │ │ │ │ │ +471 return aligned(min(a, T(b))); │ │ │ │ │ +472 } │ │ │ │ │ +473 │ │ │ │ │ +474 template │ │ │ │ │ +475 auto min(const AlignedNumber &a, const T &b) │ │ │ │ │ +476 { │ │ │ │ │ +477 using std::min; │ │ │ │ │ +478 return aligned(min(T(a), b)); │ │ │ │ │ +479 } │ │ │ │ │ +480 │ │ │ │ │ +481 } // namespace AlignedNumberImpl │ │ │ │ │ +482 │ │ │ │ │ +483 // SIMD-like functions from "conditional.hh" │ │ │ │ │ +484 template │ │ │ │ │ +485 AlignedNumber │ │ │ │ │ +486 cond(const AlignedNumber &b, │ │ │ │ │ +487 const AlignedNumber &v1, const AlignedNumber &v2) │ │ │ │ │ +488 { │ │ │ │ │ +489 return b ? v1 : v2; │ │ │ │ │ +490 } │ │ │ │ │ +491 │ │ │ │ │ +492 // SIMD-like functions from "rangeutilities.hh" │ │ │ │ │ +493 template │ │ │ │ │ +494 T max_value(const AlignedNumber& val) │ │ │ │ │ +495 { │ │ │ │ │ +496 return T(val); │ │ │ │ │ +497 } │ │ │ │ │ +498 │ │ │ │ │ +499 template │ │ │ │ │ +500 T min_value(const AlignedNumber& val) │ │ │ │ │ +501 { │ │ │ │ │ +502 return T(val); │ │ │ │ │ +503 } │ │ │ │ │ +504 │ │ │ │ │ +505 template │ │ │ │ │ +506 bool any_true(const AlignedNumber& val) │ │ │ │ │ +507 { │ │ │ │ │ +508 return bool(val); │ │ │ │ │ +509 } │ │ │ │ │ +510 │ │ │ │ │ +511 template │ │ │ │ │ +512 bool all_true(const AlignedNumber& val) │ │ │ │ │ +513 { │ │ │ │ │ +514 return bool(val); │ │ │ │ │ +515 } │ │ │ │ │ +516 │ │ │ │ │ +517 // SIMD-like functionality from "simd/interface.hh" │ │ │ │ │ +518 namespace Simd { │ │ │ │ │ +519 namespace Overloads { │ │ │ │ │ +520 │ │ │ │ │ +521 template │ │ │ │ │ +522 struct ScalarType > { using type = T; }; │ │ │ │ │ +523 │ │ │ │ │ +524 template │ │ │ │ │ +525 struct RebindType > { │ │ │ │ │ +526 using type = AlignedNumber; │ │ │ │ │ +527 }; │ │ │ │ │ +528 │ │ │ │ │ +529 template │ │ │ │ │ +530 struct LaneCount > : index_constant<1> {}; │ │ │ │ │ +531 │ │ │ │ │ +532 template │ │ │ │ │ +533 T& lane(ADLTag<5>, std::size_t l, AlignedNumber &v) │ │ │ │ │ +534 { │ │ │ │ │ +535 assert(l == 0); │ │ │ │ │ +536 return v.value(); │ │ │ │ │ +537 } │ │ │ │ │ +538 │ │ │ │ │ +539 template │ │ │ │ │ +540 T lane(ADLTag<5>, std::size_t l, const AlignedNumber &v) │ │ │ │ │ +541 { │ │ │ │ │ +542 assert(l == 0); │ │ │ │ │ +543 return v.value(); │ │ │ │ │ +544 } │ │ │ │ │ +545 │ │ │ │ │ +546 template │ │ │ │ │ +547 const AlignedNumber & │ │ │ │ │ +548 cond(ADLTag<5>, AlignedNumber mask, │ │ │ │ │ +549 const AlignedNumber &ifTrue, │ │ │ │ │ +550 const AlignedNumber &ifFalse) │ │ │ │ │ +551 { │ │ │ │ │ +552 return mask ? ifTrue : ifFalse; │ │ │ │ │ +553 } │ │ │ │ │ +554 │ │ │ │ │ +555 template │ │ │ │ │ +556 bool anyTrue(ADLTag<5>, const AlignedNumber &mask) │ │ │ │ │ +557 { │ │ │ │ │ +558 return bool(mask); │ │ │ │ │ +559 } │ │ │ │ │ +560 │ │ │ │ │ +561 } // namespace Overloads │ │ │ │ │ +562 │ │ │ │ │ +563 } // namespace Simd │ │ │ │ │ +564 │ │ │ │ │ +565} // namespace Dune │ │ │ │ │ +566 │ │ │ │ │ +567#endif // DUNE_DEBUGALIGN_HH │ │ │ │ │ +defaults.hh │ │ │ │ │ +Default implementations for SIMD Implementations. │ │ │ │ │ +base.hh │ │ │ │ │ +Basic definitions for SIMD Implementations. │ │ │ │ │ +classname.hh │ │ │ │ │ +A free function to provide the demangled class name of a given object or type │ │ │ │ │ +as a string. │ │ │ │ │ +DUNE_BINARY_OP │ │ │ │ │ +#define DUNE_BINARY_OP(OP) │ │ │ │ │ +Definition debugalign.hh:261 │ │ │ │ │ +DUNE_UNARY_FUNC │ │ │ │ │ +#define DUNE_UNARY_FUNC(name) │ │ │ │ │ +DUNE_ASSIGN_OP │ │ │ │ │ +#define DUNE_ASSIGN_OP(OP) │ │ │ │ │ +Definition debugalign.hh:220 │ │ │ │ │ +indices.hh │ │ │ │ │ +typetraits.hh │ │ │ │ │ +Traits for type conversions and type information. │ │ │ │ │ +Dune::index_constant │ │ │ │ │ +std::integral_constant< std::size_t, i > index_constant │ │ │ │ │ +An index constant with value i. │ │ │ │ │ +Definition indices.hh:29 │ │ │ │ │ +Dune::operator<< │ │ │ │ │ +std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ +Definition bigunsignedint.hh:278 │ │ │ │ │ +Dune::Simd::Overloads::mask │ │ │ │ │ +Mask< V > mask(ADLTag< 0, std::is_same< V, Mask< V > >::value >, const V &v) │ │ │ │ │ +implements Simd::mask() │ │ │ │ │ +Definition defaults.hh:153 │ │ │ │ │ std │ │ │ │ │ STL namespace. │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ -Dune::MPITraits │ │ │ │ │ -A traits class describing the mapping of types onto MPI_Datatypes. │ │ │ │ │ -Definition mpitraits.hh:41 │ │ │ │ │ -Dune::MPITraits::getType │ │ │ │ │ -static MPI_Datatype getType() │ │ │ │ │ -Definition mpitraits.hh:48 │ │ │ │ │ -Dune::MPITraits::is_intrinsic │ │ │ │ │ -static constexpr bool is_intrinsic │ │ │ │ │ -Definition mpitraits.hh:56 │ │ │ │ │ -Dune::bigunsignedint::n │ │ │ │ │ -static constexpr int n │ │ │ │ │ -Definition bigunsignedint.hh:78 │ │ │ │ │ -Dune::FieldVector │ │ │ │ │ -vector space out of a tensor product of fields. │ │ │ │ │ -Definition fvector.hh:91 │ │ │ │ │ +Dune::violatedAlignment │ │ │ │ │ +void violatedAlignment(const char *className, std::size_t expectedAlignment, │ │ │ │ │ +const void *address) │ │ │ │ │ +called when an alignment violation is detected │ │ │ │ │ +Definition debugalign.cc:36 │ │ │ │ │ +Dune::any_true │ │ │ │ │ +bool any_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ +Definition debugalign.hh:506 │ │ │ │ │ +Dune::all_true │ │ │ │ │ +bool all_true(const AlignedNumber< bool, align > &val) │ │ │ │ │ +Definition debugalign.hh:512 │ │ │ │ │ +Dune::className │ │ │ │ │ +std::string className() │ │ │ │ │ +Provide the demangled class name of a type T as a string. │ │ │ │ │ +Definition classname.hh:47 │ │ │ │ │ +Dune::debugAlignment │ │ │ │ │ +static constexpr auto debugAlignment │ │ │ │ │ +an alignment large enough to trigger alignment errors │ │ │ │ │ +Definition debugalign.hh:97 │ │ │ │ │ +Dune::cond │ │ │ │ │ +const T1 cond(bool b, const T1 &v1, const T2 &v2) │ │ │ │ │ +conditional evaluate │ │ │ │ │ +Definition conditional.hh:28 │ │ │ │ │ +Dune::aligned │ │ │ │ │ +AlignedNumber< T, align > aligned(T value) │ │ │ │ │ +align a value to a certain alignment │ │ │ │ │ +Definition debugalign.hh:114 │ │ │ │ │ +Dune::violatedAlignmentHandler │ │ │ │ │ +ViolatedAlignmentHandler & violatedAlignmentHandler() │ │ │ │ │ +access the handler called by violatedAlignment() │ │ │ │ │ +Definition debugalign.cc:30 │ │ │ │ │ +Dune::isAligned │ │ │ │ │ +bool isAligned(const void *p, std::size_t align) │ │ │ │ │ +check whether an address conforms to the given alignment │ │ │ │ │ +Definition debugalign.hh:56 │ │ │ │ │ +Dune::max_value │ │ │ │ │ +T max_value(const AlignedNumber< T, align > &val) │ │ │ │ │ +Definition debugalign.hh:494 │ │ │ │ │ +Dune::ViolatedAlignmentHandler │ │ │ │ │ +std::function< void(const char *, std::size_t, const void *)> │ │ │ │ │ +ViolatedAlignmentHandler │ │ │ │ │ +type of the handler called by violatedAlignment() │ │ │ │ │ +Definition debugalign.hh:31 │ │ │ │ │ +Dune::min_value │ │ │ │ │ +T min_value(const AlignedNumber< T, align > &val) │ │ │ │ │ +Definition debugalign.hh:500 │ │ │ │ │ +Dune::Simd::Overloads::anyTrue │ │ │ │ │ +bool anyTrue(ADLTag< 5 >, const AlignedNumber< bool, align > &mask) │ │ │ │ │ +Definition debugalign.hh:556 │ │ │ │ │ +Dune::Simd::Overloads::lane │ │ │ │ │ +T & lane(ADLTag< 5 >, std::size_t l, AlignedNumber< T, align > &v) │ │ │ │ │ +Definition debugalign.hh:533 │ │ │ │ │ +Dune::IsNumber │ │ │ │ │ +Whether this type acts as a scalar in the context of (hierarchically blocked) │ │ │ │ │ +containers. │ │ │ │ │ +Definition typetraits.hh:194 │ │ │ │ │ +Dune::AlignedBase │ │ │ │ │ +CRTP base mixin class to check alignment. │ │ │ │ │ +Definition debugalign.hh:66 │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber │ │ │ │ │ +aligned wrappers for arithmetic types │ │ │ │ │ +Definition debugalign.hh:128 │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::DUNE_ASSIGN_OP │ │ │ │ │ +DUNE_ASSIGN_OP(<<=) │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::DUNE_ASSIGN_OP │ │ │ │ │ +DUNE_ASSIGN_OP(-=) │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::operator+ │ │ │ │ │ +decltype(auto) operator+() const │ │ │ │ │ +Definition debugalign.hh:187 │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::DUNE_ASSIGN_OP │ │ │ │ │ +DUNE_ASSIGN_OP(+=) │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::operator-- │ │ │ │ │ +decltype(auto) operator--(int) │ │ │ │ │ +Definition debugalign.hh:182 │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::DUNE_ASSIGN_OP │ │ │ │ │ +DUNE_ASSIGN_OP * DUNE_ASSIGN_OP(/=);DUNE_ASSIGN_OP(%= │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::operator++ │ │ │ │ │ +decltype(auto) operator++(int) │ │ │ │ │ +Definition debugalign.hh:179 │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::operator! │ │ │ │ │ +decltype(auto) operator!() const │ │ │ │ │ +Definition debugalign.hh:217 │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::value │ │ │ │ │ +T & value() │ │ │ │ │ +Definition debugalign.hh:145 │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::value │ │ │ │ │ +const T & value() const │ │ │ │ │ +Definition debugalign.hh:144 │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::DUNE_ASSIGN_OP │ │ │ │ │ +DUNE_ASSIGN_OP^ DUNE_ASSIGN_OP(&=);DUNE_ASSIGN_OP(|= │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::operator>> │ │ │ │ │ +friend std::basic_istream< charT, Traits > & operator>>(std::basic_istream< │ │ │ │ │ +charT, Traits > &str, AlignedNumber &u) │ │ │ │ │ +Definition debugalign.hh:150 │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::DUNE_ASSIGN_OP │ │ │ │ │ +DUNE_ASSIGN_OP(> >=) │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::AlignedNumber │ │ │ │ │ +AlignedNumber()=default │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::operator~ │ │ │ │ │ +decltype(auto) operator~() const │ │ │ │ │ +Definition debugalign.hh:207 │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::AlignedNumber │ │ │ │ │ +AlignedNumber(T value) │ │ │ │ │ +Definition debugalign.hh:133 │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::AlignedNumber │ │ │ │ │ +AlignedNumber(const AlignedNumber< U, uAlign > &o) │ │ │ │ │ +Definition debugalign.hh:137 │ │ │ │ │ +Dune::AlignedNumberImpl::AlignedNumber::operator- │ │ │ │ │ +decltype(auto) operator-() const │ │ │ │ │ +Definition debugalign.hh:191 │ │ │ │ │ +Dune::Simd::Overloads::ScalarType<_AlignedNumber<_T,_align_>_>::type │ │ │ │ │ +T type │ │ │ │ │ +Definition debugalign.hh:522 │ │ │ │ │ +Dune::Simd::Overloads::ADLTag │ │ │ │ │ +Tag used to force late-binding lookup in Dune::Simd::Overloads. │ │ │ │ │ +Definition base.hh:182 │ │ │ │ │ +Dune::Simd::Overloads::ScalarType │ │ │ │ │ +should have a member type type │ │ │ │ │ +Definition standard.hh:60 │ │ │ │ │ +Dune::Simd::Overloads::RebindType │ │ │ │ │ +should have a member type type │ │ │ │ │ +Definition standard.hh:67 │ │ │ │ │ +Dune::Simd::Overloads::LaneCount │ │ │ │ │ +should be derived from a Dune::index_constant │ │ │ │ │ +Definition standard.hh:74 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00095.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpicollectivecommunication.hh File Reference │ │ │ │ +dune-common: binaryfunctions.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,24 +65,46 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ │ │ │ │
│ │ │ │ -
mpicollectivecommunication.hh File Reference
│ │ │ │ +
│ │ │ │ +Classes | │ │ │ │ +Namespaces
│ │ │ │ +
binaryfunctions.hh File Reference
│ │ │ │
│ │ │ │
│ │ │ │ -
#include <dune/common/parallel/mpicommunication.hh>
│ │ │ │ + │ │ │ │ +

helper classes to provide unique types for standard functions │ │ │ │ +More...

│ │ │ │ +
#include <algorithm>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ -
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Classes

struct  Dune::Min< Type >
 
struct  Dune::Max< Type >
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ +

│ │ │ │ +Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ +

Detailed Description

│ │ │ │ +

helper classes to provide unique types for standard functions

│ │ │ │ +
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,12 +1,24 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -mpicollectivecommunication.hh File Reference │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces │ │ │ │ │ +binaryfunctions.hh File Reference │ │ │ │ │ +helper classes to provide unique types for standard functions More... │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ +Classes │ │ │ │ │ +struct   Dune::Min<_Type_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::Max<_Type_> │ │ │ │ │ +  │ │ │ │ │ +Namespaces │ │ │ │ │ +namespace   Dune │ │ │ │ │ +  Dune namespace. │ │ │ │ │ +  │ │ │ │ │ +***** Detailed Description ***** │ │ │ │ │ +helper classes to provide unique types for standard functions │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00095_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: mpicollectivecommunication.hh Source File │ │ │ │ +dune-common: binaryfunctions.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,27 +70,85 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
mpicollectivecommunication.hh
│ │ │ │ +
binaryfunctions.hh
│ │ │ │
│ │ │ │
│ │ │ │ -Go to the documentation of this file.
1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ -
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
3// Will be removed after the 2.7 release
│ │ │ │ -
4#warning "Deprecated header, use #include <dune/common/parallel/mpicommunication.hh> instead!"
│ │ │ │ - │ │ │ │ -
Implements an utility class that provides MPI's collective communication methods.
│ │ │ │ +Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │ +
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │ +
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │ +
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ +
5#ifndef DUNE_BINARYFUNCTIONS_HH
│ │ │ │ +
6#define DUNE_BINARYFUNCTIONS_HH
│ │ │ │ +
7
│ │ │ │ +
12#include <algorithm>
│ │ │ │ +
13
│ │ │ │ +
14namespace Dune
│ │ │ │ +
15{
│ │ │ │ +
16 template<typename Type>
│ │ │ │ +
│ │ │ │ +
17 struct Min
│ │ │ │ +
18 {
│ │ │ │ +
19 using first_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
│ │ │ │ +
20
│ │ │ │ +
21 using second_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
│ │ │ │ +
22
│ │ │ │ +
23 using result_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
│ │ │ │ +
24
│ │ │ │ +
│ │ │ │ +
25 Type operator()(const Type& t1, const Type& t2) const
│ │ │ │ +
26 {
│ │ │ │ +
27 using std::min;
│ │ │ │ +
28 return min(t1,t2);
│ │ │ │ +
29 }
│ │ │ │ +
│ │ │ │ +
30 };
│ │ │ │ +
│ │ │ │ +
31
│ │ │ │ +
32 template<typename Type>
│ │ │ │ +
│ │ │ │ +
33 struct Max
│ │ │ │ +
34 {
│ │ │ │ +
35 using first_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
│ │ │ │ +
36
│ │ │ │ +
37 using second_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
│ │ │ │ +
38
│ │ │ │ +
39 using result_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
│ │ │ │ +
40
│ │ │ │ +
│ │ │ │ +
41 Type operator()(const Type& t1, const Type& t2) const
│ │ │ │ +
42 {
│ │ │ │ +
43 using std::max;
│ │ │ │ +
44 return max(t1,t2);
│ │ │ │ +
45 }
│ │ │ │ +
│ │ │ │ +
46 };
│ │ │ │ +
│ │ │ │ +
47}
│ │ │ │ +
48
│ │ │ │ +
49#endif
│ │ │ │ +
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ +
Definition binaryfunctions.hh:18
│ │ │ │ +
Type result_type
Definition binaryfunctions.hh:23
│ │ │ │ +
Type operator()(const Type &t1, const Type &t2) const
Definition binaryfunctions.hh:25
│ │ │ │ +
Type first_argument_type
Definition binaryfunctions.hh:19
│ │ │ │ +
Type second_argument_type
Definition binaryfunctions.hh:21
│ │ │ │ +
Definition binaryfunctions.hh:34
│ │ │ │ +
Type operator()(const Type &t1, const Type &t2) const
Definition binaryfunctions.hh:41
│ │ │ │ +
Type result_type
Definition binaryfunctions.hh:39
│ │ │ │ +
Type first_argument_type
Definition binaryfunctions.hh:35
│ │ │ │ +
Type second_argument_type
Definition binaryfunctions.hh:37
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,21 +1,93 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -mpicollectivecommunication.hh │ │ │ │ │ +binaryfunctions.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ -1// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ +1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ +2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ +3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ -2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -3// Will be removed after the 2.7 release │ │ │ │ │ -4#warning "Deprecated header, use #include instead!" │ │ │ │ │ -5#include │ │ │ │ │ -mpicommunication.hh │ │ │ │ │ -Implements an utility class that provides MPI's collective communication │ │ │ │ │ -methods. │ │ │ │ │ +4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ +5#ifndef DUNE_BINARYFUNCTIONS_HH │ │ │ │ │ +6#define DUNE_BINARYFUNCTIONS_HH │ │ │ │ │ +7 │ │ │ │ │ +12#include │ │ │ │ │ +13 │ │ │ │ │ +14namespace Dune │ │ │ │ │ +15{ │ │ │ │ │ +16 template │ │ │ │ │ +17 struct Min │ │ │ │ │ +18 { │ │ │ │ │ +19 using first_argument_type [[deprecated("This type alias is deprecated │ │ │ │ │ +following similar deprecations in C++17")]] = Type; │ │ │ │ │ +20 │ │ │ │ │ +21 using second_argument_type [[deprecated("This type alias is deprecated │ │ │ │ │ +following similar deprecations in C++17")]] = Type; │ │ │ │ │ +22 │ │ │ │ │ +23 using result_type [[deprecated("This type alias is deprecated following │ │ │ │ │ +similar deprecations in C++17")]] = Type; │ │ │ │ │ +24 │ │ │ │ │ +25 Type operator()(const Type& t1, const Type& t2) const │ │ │ │ │ +26 { │ │ │ │ │ +27 using std::min; │ │ │ │ │ +28 return min(t1,t2); │ │ │ │ │ +29 } │ │ │ │ │ +30 }; │ │ │ │ │ +31 │ │ │ │ │ +32 template │ │ │ │ │ +33 struct Max │ │ │ │ │ +34 { │ │ │ │ │ +35 using first_argument_type [[deprecated("This type alias is deprecated │ │ │ │ │ +following similar deprecations in C++17")]] = Type; │ │ │ │ │ +36 │ │ │ │ │ +37 using second_argument_type [[deprecated("This type alias is deprecated │ │ │ │ │ +following similar deprecations in C++17")]] = Type; │ │ │ │ │ +38 │ │ │ │ │ +39 using result_type [[deprecated("This type alias is deprecated following │ │ │ │ │ +similar deprecations in C++17")]] = Type; │ │ │ │ │ +40 │ │ │ │ │ +41 Type operator()(const Type& t1, const Type& t2) const │ │ │ │ │ +42 { │ │ │ │ │ +43 using std::max; │ │ │ │ │ +44 return max(t1,t2); │ │ │ │ │ +45 } │ │ │ │ │ +46 }; │ │ │ │ │ +47} │ │ │ │ │ +48 │ │ │ │ │ +49#endif │ │ │ │ │ +Dune │ │ │ │ │ +Dune namespace. │ │ │ │ │ +Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::Min │ │ │ │ │ +Definition binaryfunctions.hh:18 │ │ │ │ │ +Dune::Min::result_type │ │ │ │ │ +Type result_type │ │ │ │ │ +Definition binaryfunctions.hh:23 │ │ │ │ │ +Dune::Min::operator() │ │ │ │ │ +Type operator()(const Type &t1, const Type &t2) const │ │ │ │ │ +Definition binaryfunctions.hh:25 │ │ │ │ │ +Dune::Min::first_argument_type │ │ │ │ │ +Type first_argument_type │ │ │ │ │ +Definition binaryfunctions.hh:19 │ │ │ │ │ +Dune::Min::second_argument_type │ │ │ │ │ +Type second_argument_type │ │ │ │ │ +Definition binaryfunctions.hh:21 │ │ │ │ │ +Dune::Max │ │ │ │ │ +Definition binaryfunctions.hh:34 │ │ │ │ │ +Dune::Max::operator() │ │ │ │ │ +Type operator()(const Type &t1, const Type &t2) const │ │ │ │ │ +Definition binaryfunctions.hh:41 │ │ │ │ │ +Dune::Max::result_type │ │ │ │ │ +Type result_type │ │ │ │ │ +Definition binaryfunctions.hh:39 │ │ │ │ │ +Dune::Max::first_argument_type │ │ │ │ │ +Type first_argument_type │ │ │ │ │ +Definition binaryfunctions.hh:35 │ │ │ │ │ +Dune::Max::second_argument_type │ │ │ │ │ +Type second_argument_type │ │ │ │ │ +Definition binaryfunctions.hh:37 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00098.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: communicator.hh File Reference │ │ │ │ +dune-common: sllist.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -65,72 +65,64 @@ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ -Namespaces
│ │ │ │ - │ │ │ │ +Namespaces | │ │ │ │ +Functions
│ │ │ │ +
sllist.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Provides utility classes for syncing distributed data via MPI communication. │ │ │ │ +

Implements a singly linked list together with the necessary iterators. │ │ │ │ More...

│ │ │ │ -
#include <cassert>
│ │ │ │ -#include <cstddef>
│ │ │ │ -#include <iostream>
│ │ │ │ -#include <map>
│ │ │ │ -#include <type_traits>
│ │ │ │ -#include <utility>
│ │ │ │ -#include <mpi.h>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ -#include <dune/common/parallel/interface.hh>
│ │ │ │ -#include <dune/common/parallel/remoteindices.hh>
│ │ │ │ -#include <dune/common/stdstreams.hh>
│ │ │ │ +
#include <memory>
│ │ │ │ +#include <cassert>
│ │ │ │ +#include "iteratorfacades.hh"
│ │ │ │ +#include <ostream>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

struct  Dune::SizeOne
 Flag for marking indexed data structures where data at each index is of the same size. More...
class  Dune::SLList< T, A >
 A single linked list. More...
 
struct  Dune::VariableSize
 Flag for marking indexed data structures where the data at each index may be a variable multiple of another type. More...
class  Dune::SLListIterator< T, A >
 A mutable iterator for the SLList. More...
 
struct  Dune::CommPolicy< V >
 Default policy used for communicating an indexed type. More...
class  Dune::SLListConstIterator< T, A >
 A constant iterator for the SLList. More...
 
struct  Dune::CommPolicy< V >::CommPolicy< VariableBlockVector< FieldVector< K, n >, A > >
 
class  Dune::CommPolicy< V >::CommunicationError
 Error thrown if there was a problem with the communication. More...
 
struct  Dune::CommPolicy< V >::CopyGatherScatter< T >
 GatherScatter default implementation that just copies data. More...
 
class  Dune::BufferedCommunicator
 A communicator that uses buffers to gather and scatter the data to be send or received. More...
class  Dune::SLListModifyIterator< T, A >
 A mutable iterator for the SLList. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ +

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ +Functions

template<typename T , typename A >
std::ostream & Dune::operator<< (std::ostream &os, const SLList< T, A > &sllist)
 
│ │ │ │

Detailed Description

│ │ │ │ -

Provides utility classes for syncing distributed data via MPI communication.

│ │ │ │ +

Implements a singly linked list together with the necessary iterators.

│ │ │ │
Author
Markus Blatt
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,59 +1,43 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -Classes | Namespaces │ │ │ │ │ -communicator.hh File Reference │ │ │ │ │ -Common » Parallel_Communication » Parallel_Computing_based_on_Indexsets │ │ │ │ │ -Provides utility classes for syncing distributed data via MPI communication. │ │ │ │ │ -More... │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +sllist.hh File Reference │ │ │ │ │ +Common │ │ │ │ │ +Implements a singly linked list together with the necessary iterators. More... │ │ │ │ │ +#include │ │ │ │ │ #include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +#include "iteratorfacades.hh" │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct   Dune::SizeOne │ │ │ │ │ -  Flag for marking indexed data structures where data at each index is │ │ │ │ │ - of the same size. More... │ │ │ │ │ +class   Dune::SLList<_T,_A_> │ │ │ │ │ +  A single linked list. More... │ │ │ │ │   │ │ │ │ │ -struct   Dune::VariableSize │ │ │ │ │ -  Flag for marking indexed data structures where the data at each index │ │ │ │ │ - may be a variable multiple of another type. More... │ │ │ │ │ +class   Dune::SLListIterator<_T,_A_> │ │ │ │ │ +  A mutable iterator for the SLList. More... │ │ │ │ │   │ │ │ │ │ -struct   Dune::CommPolicy<_V_> │ │ │ │ │ -  Default policy used for communicating an indexed type. More... │ │ │ │ │ +class   Dune::SLListConstIterator<_T,_A_> │ │ │ │ │ +  A constant iterator for the SLList. More... │ │ │ │ │   │ │ │ │ │ -struct   Dune::CommPolicy<_V_>::CommPolicy<_VariableBlockVector<_FieldVector< │ │ │ │ │ - K,_n_>,_A_>_> │ │ │ │ │ -  │ │ │ │ │ - class   Dune::CommPolicy<_V_>::CommunicationError │ │ │ │ │ -  Error thrown if there was a problem with the communication. More... │ │ │ │ │ -  │ │ │ │ │ -struct   Dune::CommPolicy<_V_>::CopyGatherScatter<_T_> │ │ │ │ │ -  GatherScatter default implementation that just copies data. More... │ │ │ │ │ -  │ │ │ │ │ - class   Dune::BufferedCommunicator │ │ │ │ │ -  A communicator that uses buffers to gather and scatter the data to be │ │ │ │ │ - send or received. More... │ │ │ │ │ +class   Dune::SLListModifyIterator<_T,_A_> │ │ │ │ │ +  A mutable iterator for the SLList. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ +std::ostream &  Dune::operator<< (std::ostream &os, const SLList< T, A > │ │ │ │ │ + &sllist) │ │ │ │ │ +  │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Provides utility classes for syncing distributed data via MPI communication. │ │ │ │ │ +Implements a singly linked list together with the necessary iterators. │ │ │ │ │ Author │ │ │ │ │ Markus Blatt │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00098_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: communicator.hh Source File │ │ │ │ +dune-common: sllist.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -70,1040 +70,784 @@ │ │ │ │
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ -
communicator.hh
│ │ │ │ +
sllist.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │ -
5#ifndef DUNE_COMMON_PARALLEL_COMMUNICATOR_HH
│ │ │ │ -
6#define DUNE_COMMON_PARALLEL_COMMUNICATOR_HH
│ │ │ │ +
5#ifndef DUNE_SLLIST_HH
│ │ │ │ +
6#define DUNE_SLLIST_HH
│ │ │ │
7
│ │ │ │ -
8#if HAVE_MPI
│ │ │ │ -
9
│ │ │ │ -
10#include <cassert>
│ │ │ │ -
11#include <cstddef>
│ │ │ │ -
12#include <iostream>
│ │ │ │ -
13#include <map>
│ │ │ │ -
14#include <type_traits>
│ │ │ │ -
15#include <utility>
│ │ │ │ -
16
│ │ │ │ -
17#include <mpi.h>
│ │ │ │ -
18
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ -
23
│ │ │ │ -
24namespace Dune
│ │ │ │ -
25{
│ │ │ │ -
│ │ │ │ -
109 struct SizeOne
│ │ │ │ -
110 {};
│ │ │ │ -
│ │ │ │ -
111
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
118 {};
│ │ │ │ -
│ │ │ │ -
119
│ │ │ │ -
120
│ │ │ │ -
126 template<class V>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
128 {
│ │ │ │ -
140 typedef V Type;
│ │ │ │ -
141
│ │ │ │ -
147 typedef typename V::value_type IndexedType;
│ │ │ │ +
8#include <memory>
│ │ │ │ +
9#include <cassert>
│ │ │ │ +
10#include "iteratorfacades.hh"
│ │ │ │ +
11#include <ostream>
│ │ │ │ +
12
│ │ │ │ +
13namespace Dune
│ │ │ │ +
14{
│ │ │ │ +
26 template<typename T, class A>
│ │ │ │ +
27 class SLListIterator;
│ │ │ │ +
28
│ │ │ │ +
29 template<typename T, class A>
│ │ │ │ +
30 class SLListConstIterator;
│ │ │ │ +
31
│ │ │ │ +
32 template<typename T, class A>
│ │ │ │ +
33 class SLListModifyIterator;
│ │ │ │ +
34
│ │ │ │ +
42 template<typename T, class A=std::allocator<T> >
│ │ │ │ +
│ │ │ │ +
43 class SLList
│ │ │ │ +
44 {
│ │ │ │ +
45 struct Element;
│ │ │ │ +
46 friend class SLListIterator<T,A>;
│ │ │ │ +
47 friend class SLListConstIterator<T,A>;
│ │ │ │ +
48
│ │ │ │ +
49 public:
│ │ │ │ +
50
│ │ │ │ +
54 typedef typename A::size_type size_type;
│ │ │ │ +
55
│ │ │ │ +
59 typedef T MemberType;
│ │ │ │ +
60
│ │ │ │ +
64 using Allocator = typename std::allocator_traits<A>::template rebind_alloc<Element>;
│ │ │ │ +
65
│ │ │ │ + │ │ │ │ +
70
│ │ │ │ + │ │ │ │ +
75
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
80
│ │ │ │ +
84 template<typename T1, typename A1>
│ │ │ │ +
│ │ │ │ +
85 SLList(const SLList<T1,A1>& other);
│ │ │ │ +
86
│ │ │ │ +
│ │ │ │ +
90 SLList(const SLList<T,A>& other);
│ │ │ │ +
91
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
98
│ │ │ │ + │ │ │ │ +
104
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
109
│ │ │ │ +
110
│ │ │ │ +
│ │ │ │ +
115 inline void push_back(const MemberType& item);
│ │ │ │ +
116
│ │ │ │ +
│ │ │ │ +
121 inline void push_front(const MemberType& item);
│ │ │ │ +
122
│ │ │ │ +
│ │ │ │ +
126 inline void pop_front();
│ │ │ │ +
127
│ │ │ │ +
│ │ │ │ +
129 inline void clear();
│ │ │ │ +
130
│ │ │ │ +
│ │ │ │ +
138 inline iterator begin();
│ │ │ │ +
139
│ │ │ │ +
│ │ │ │ +
147 inline const_iterator begin() const;
│ │ │ │
148
│ │ │ │ - │ │ │ │ -
154
│ │ │ │ -
163 static const void* getAddress(const V& v, int index);
│ │ │ │ -
164
│ │ │ │ -
170 static int getSize(const V&, int index);
│ │ │ │ -
171 };
│ │ │ │ -
172
│ │ │ │ -
173 template<class K, int n> class FieldVector;
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
157
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
166
│ │ │ │ +
│ │ │ │ +
173 inline iterator end();
│ │ │ │
174
│ │ │ │ -
175 template<class B, class A> class VariableBlockVector;
│ │ │ │ -
176
│ │ │ │ -
177 template<class K, class A, int n>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
179 {
│ │ │ │ - │ │ │ │ -
181
│ │ │ │ -
182 typedef typename Type::B IndexedType;
│ │ │ │ -
183
│ │ │ │ - │ │ │ │ -
185
│ │ │ │ -
186 static const void* getAddress(const Type& v, int i);
│ │ │ │ -
187
│ │ │ │ -
188 static int getSize(const Type& v, int i);
│ │ │ │ -
189 };
│ │ │ │ -
│ │ │ │ -
190
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
195 {};
│ │ │ │ -
│ │ │ │ -
196
│ │ │ │ -
200 template<class T>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
202 {
│ │ │ │ - │ │ │ │ -
204
│ │ │ │ -
205 static const IndexedType& gather(const T& vec, std::size_t i);
│ │ │ │ -
206
│ │ │ │ -
207 static void scatter(T& vec, const IndexedType& v, std::size_t i);
│ │ │ │ -
208
│ │ │ │ -
209 };
│ │ │ │ -
│ │ │ │ -
210
│ │ │ │ -
222 template<typename T>
│ │ │ │ -
223 class DatatypeCommunicator : public InterfaceBuilder
│ │ │ │ -
224 {
│ │ │ │ -
225 public:
│ │ │ │ +
│ │ │ │ +
181 inline const_iterator end() const;
│ │ │ │ +
182
│ │ │ │ +
│ │ │ │ +
188 inline bool empty() const;
│ │ │ │ +
189
│ │ │ │ +
│ │ │ │ +
194 inline int size() const;
│ │ │ │ +
195
│ │ │ │ +
│ │ │ │ +
196 bool operator==(const SLList& sl) const;
│ │ │ │ +
197
│ │ │ │ +
198
│ │ │ │ +
│ │ │ │ +
199 bool operator!=(const SLList& sl) const;
│ │ │ │ +
200
│ │ │ │ +
201 private:
│ │ │ │ +
203 struct Element
│ │ │ │ +
204 {
│ │ │ │ + │ │ │ │ + │ │ │ │ +
213
│ │ │ │ +
│ │ │ │ +
214 Element(const MemberType& item, Element* next_=0);
│ │ │ │ +
215
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
217
│ │ │ │ + │ │ │ │ +
219 };
│ │ │ │ +
220
│ │ │ │ +
225 void deleteNext(Element* current);
│ │ │ │
226
│ │ │ │ -
230 typedef T ParallelIndexSet;
│ │ │ │ -
231
│ │ │ │ - │ │ │ │ -
236
│ │ │ │ -
240 typedef typename RemoteIndices::GlobalIndex GlobalIndex;
│ │ │ │ -
241
│ │ │ │ -
245 typedef typename RemoteIndices::Attribute Attribute;
│ │ │ │ -
246
│ │ │ │ -
250 typedef typename RemoteIndices::LocalIndex LocalIndex;
│ │ │ │ +
231 void copyElements(const SLList<T,A>& other);
│ │ │ │ +
232
│ │ │ │ +
240 template<bool watchForTail>
│ │ │ │ +
241 void deleteNext(Element* current);
│ │ │ │ +
247 void insertAfter(Element* current, const T& item);
│ │ │ │ +
248
│ │ │ │ +
250 Element beforeHead_;
│ │ │ │
251
│ │ │ │ -
255 DatatypeCommunicator();
│ │ │ │ -
256
│ │ │ │ -
260 ~DatatypeCommunicator();
│ │ │ │ +
257 Element* tail_;
│ │ │ │ +
258
│ │ │ │ +
260 Allocator allocator_;
│ │ │ │
261
│ │ │ │ -
288 template<class T1, class T2, class V>
│ │ │ │ -
289 void build(const RemoteIndices& remoteIndices, const T1& sourceFlags, V& sendData, const T2& destFlags, V& receiveData);
│ │ │ │ -
290
│ │ │ │ -
294 void forward();
│ │ │ │ -
295
│ │ │ │ -
299 void backward();
│ │ │ │ -
300
│ │ │ │ -
304 void free();
│ │ │ │ -
305 private:
│ │ │ │ -
309 constexpr static int commTag_ = 234;
│ │ │ │ -
310
│ │ │ │ -
314 const RemoteIndices* remoteIndices_;
│ │ │ │ -
315
│ │ │ │ -
316 typedef std::map<int,std::pair<MPI_Datatype,MPI_Datatype> >
│ │ │ │ -
317 MessageTypeMap;
│ │ │ │ +
263 int size_;
│ │ │ │ +
264 };
│ │ │ │ +
265
│ │ │ │ +
269 template<typename T, class A>
│ │ │ │ +
│ │ │ │ +
270 class SLListIterator : public Dune::ForwardIteratorFacade<SLListIterator<T,A>, T, T&, std::size_t>
│ │ │ │ +
271 {
│ │ │ │ +
272 friend class SLListConstIterator<T,A>;
│ │ │ │ +
273 friend class SLListModifyIterator<T,A>;
│ │ │ │ +
274 friend class SLList<T,A>;
│ │ │ │ +
275
│ │ │ │ +
276 public:
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
278 SLList<T,A>* sllist)
│ │ │ │ +
279 : current_(item), list_(sllist)
│ │ │ │ +
280 {}
│ │ │ │ +
│ │ │ │ +
281
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
283 : current_(0), list_(0)
│ │ │ │ +
284 {}
│ │ │ │ +
│ │ │ │ +
285
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
287 : current_(other.iterator_.current_), list_(other.iterator_.list_)
│ │ │ │ +
288 {}
│ │ │ │ +
│ │ │ │ +
289
│ │ │ │ +
│ │ │ │ +
294 inline T& dereference() const
│ │ │ │ +
295 {
│ │ │ │ +
296 return current_->item_;
│ │ │ │ +
297 }
│ │ │ │ +
│ │ │ │ +
298
│ │ │ │ +
│ │ │ │ +
304 inline bool equals(const SLListConstIterator<T,A>& other) const
│ │ │ │ +
305 {
│ │ │ │ +
306 return current_==other.current_;
│ │ │ │ +
307 }
│ │ │ │ +
│ │ │ │ +
308
│ │ │ │ +
│ │ │ │ +
314 inline bool equals(const SLListIterator<T,A>& other) const
│ │ │ │ +
315 {
│ │ │ │ +
316 return current_==other.current_;
│ │ │ │ +
317 }
│ │ │ │ +
│ │ │ │
318
│ │ │ │ -
322 MessageTypeMap messageTypes;
│ │ │ │ -
323
│ │ │ │ -
327 void* data_;
│ │ │ │ +
│ │ │ │ +
324 inline bool equals(const SLListModifyIterator<T,A>& other) const
│ │ │ │ +
325 {
│ │ │ │ +
326 return current_==other.iterator_.current_;
│ │ │ │ +
327 }
│ │ │ │ +
│ │ │ │
328
│ │ │ │ -
329 MPI_Request* requests_[2];
│ │ │ │ -
330
│ │ │ │ -
334 bool created_;
│ │ │ │ -
335
│ │ │ │ -
339 template<class V, bool FORWARD>
│ │ │ │ -
340 void createRequests(V& sendData, V& receiveData);
│ │ │ │ -
341
│ │ │ │ -
345 template<class T1, class T2, class V, bool send>
│ │ │ │ -
346 void createDataTypes(const T1& source, const T2& destination, V& data);
│ │ │ │ +
│ │ │ │ +
332 inline void increment()
│ │ │ │ +
333 {
│ │ │ │ +
334 current_ = current_->next_;
│ │ │ │ +
335 }
│ │ │ │ +
│ │ │ │ +
336
│ │ │ │ +
│ │ │ │ +
342 inline void insertAfter(const T& v) const
│ │ │ │ +
343 {
│ │ │ │ +
344 assert(list_ );
│ │ │ │ +
345 list_->insertAfter(current_, v);
│ │ │ │ +
346 }
│ │ │ │ +
│ │ │ │
347
│ │ │ │ -
351 void sendRecv(MPI_Request* req);
│ │ │ │ -
352
│ │ │ │ -
356 struct IndexedTypeInformation
│ │ │ │ -
357 {
│ │ │ │ -
363 void build(int i)
│ │ │ │ -
364 {
│ │ │ │ -
365 length = new int[i];
│ │ │ │ -
366 displ = new MPI_Aint[i];
│ │ │ │ -
367 size = i;
│ │ │ │ -
368 }
│ │ │ │ -
369
│ │ │ │ -
373 void free()
│ │ │ │ -
374 {
│ │ │ │ -
375 delete[] length;
│ │ │ │ -
376 delete[] displ;
│ │ │ │ -
377 }
│ │ │ │ -
379 int* length;
│ │ │ │ -
381 MPI_Aint* displ;
│ │ │ │ -
387 int elements;
│ │ │ │ -
391 int size;
│ │ │ │ -
392 };
│ │ │ │ -
393
│ │ │ │ -
399 template<class V>
│ │ │ │ -
400 struct MPIDatatypeInformation
│ │ │ │ -
401 {
│ │ │ │ -
406 MPIDatatypeInformation(const V& data) : data_(data)
│ │ │ │ -
407 {}
│ │ │ │ -
408
│ │ │ │ -
414 void reserve(int proc, int size)
│ │ │ │ -
415 {
│ │ │ │ -
416 information_[proc].build(size);
│ │ │ │ -
417 }
│ │ │ │ -
424 void add(int proc, int local)
│ │ │ │ -
425 {
│ │ │ │ -
426 IndexedTypeInformation& info=information_[proc];
│ │ │ │ -
427 assert((info.elements)<info.size);
│ │ │ │ -
428 MPI_Get_address( const_cast<void*>(CommPolicy<V>::getAddress(data_, local)),
│ │ │ │ -
429 info.displ+info.elements);
│ │ │ │ -
430 info.length[info.elements]=CommPolicy<V>::getSize(data_, local);
│ │ │ │ -
431 info.elements++;
│ │ │ │ -
432 }
│ │ │ │ -
433
│ │ │ │ -
438 std::map<int,IndexedTypeInformation> information_;
│ │ │ │ -
442 const V& data_;
│ │ │ │ -
443
│ │ │ │ -
444 };
│ │ │ │ -
445
│ │ │ │ -
446 };
│ │ │ │ -
│ │ │ │ -
447
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
458 {
│ │ │ │ -
459
│ │ │ │ -
460 public:
│ │ │ │ - │ │ │ │ -
465
│ │ │ │ -
472 template<class Data, class Interface>
│ │ │ │ -
473 typename std::enable_if<std::is_same<SizeOne,typename CommPolicy<Data>::IndexedTypeFlag>::value, void>::type
│ │ │ │ -
474 build(const Interface& interface);
│ │ │ │ -
475
│ │ │ │ -
483 template<class Data, class Interface>
│ │ │ │ -
484 void build(const Data& source, const Data& target, const Interface& interface);
│ │ │ │ -
485
│ │ │ │ -
514 template<class GatherScatter, class Data>
│ │ │ │ -
515 void forward(const Data& source, Data& dest);
│ │ │ │ -
516
│ │ │ │ -
545 template<class GatherScatter, class Data>
│ │ │ │ -
546 void backward(Data& source, const Data& dest);
│ │ │ │ -
547
│ │ │ │ -
573 template<class GatherScatter, class Data>
│ │ │ │ -
574 void forward(Data& data);
│ │ │ │ +
│ │ │ │ +
353 inline void deleteNext() const
│ │ │ │ +
354 {
│ │ │ │ +
355 assert(list_);
│ │ │ │ +
356 list_->deleteNext(current_);
│ │ │ │ +
357 }
│ │ │ │ +
│ │ │ │ +
358
│ │ │ │ +
359 private:
│ │ │ │ +
361 typename SLList<T,A>::Element* current_;
│ │ │ │ + │ │ │ │ +
364 };
│ │ │ │ +
│ │ │ │ +
365
│ │ │ │ +
369 template<class T, class A>
│ │ │ │ +
│ │ │ │ +
370 class SLListConstIterator : public Dune::ForwardIteratorFacade<SLListConstIterator<T,A>, const T, const T&, std::size_t>
│ │ │ │ +
371 {
│ │ │ │ +
372 friend class SLListIterator<T,A>;
│ │ │ │ +
373 friend class SLList<T,A>;
│ │ │ │ +
374
│ │ │ │ +
375 public:
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
377 : current_(0)
│ │ │ │ +
378 {}
│ │ │ │ +
│ │ │ │ +
379
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
381 : current_(item)
│ │ │ │ +
382 {}
│ │ │ │ +
│ │ │ │ +
383
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
385 : current_(other.current_)
│ │ │ │ +
386 {}
│ │ │ │ +
│ │ │ │ +
387
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
389 : current_(other.iterator_.current_)
│ │ │ │ +
390 {}
│ │ │ │ +
│ │ │ │ +
391
│ │ │ │ +
│ │ │ │ +
396 inline const T& dereference() const
│ │ │ │ +
397 {
│ │ │ │ +
398 return current_->item_;
│ │ │ │ +
399 }
│ │ │ │ +
│ │ │ │ +
400
│ │ │ │ +
│ │ │ │ +
406 inline bool equals(const SLListConstIterator<T,A>& other) const
│ │ │ │ +
407 {
│ │ │ │ +
408 return current_==other.current_;
│ │ │ │ +
409 }
│ │ │ │ +
│ │ │ │ +
410
│ │ │ │ +
│ │ │ │ +
414 inline void increment()
│ │ │ │ +
415 {
│ │ │ │ +
416 current_ = current_->next_;
│ │ │ │ +
417 }
│ │ │ │ +
│ │ │ │ +
418
│ │ │ │ +
419 private:
│ │ │ │ +
421 typename SLList<T,A>::Element* current_;
│ │ │ │ +
422 };
│ │ │ │ +
│ │ │ │ +
423
│ │ │ │ +
427 template<typename T, class A>
│ │ │ │ +
│ │ │ │ +
428 class SLListModifyIterator : public Dune::ForwardIteratorFacade<SLListModifyIterator<T,A>, T, T&, std::size_t>
│ │ │ │ +
429 {
│ │ │ │ +
430 friend class SLListConstIterator<T,A>;
│ │ │ │ +
431 friend class SLListIterator<T,A>;
│ │ │ │ +
432 public:
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
434 SLListIterator<T,A> _iterator)
│ │ │ │ +
435 : beforeIterator_(beforeIterator), iterator_(_iterator)
│ │ │ │ +
436 {}
│ │ │ │ +
│ │ │ │ +
437
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
439 : beforeIterator_(), iterator_()
│ │ │ │ +
440 {}
│ │ │ │ +
│ │ │ │ +
441
│ │ │ │ +
│ │ │ │ +
446 inline T& dereference() const
│ │ │ │ +
447 {
│ │ │ │ +
448 return *iterator_;
│ │ │ │ +
449 }
│ │ │ │ +
│ │ │ │ +
450
│ │ │ │ +
│ │ │ │ +
456 inline bool equals(const SLListConstIterator<T,A>& other) const
│ │ │ │ +
457 {
│ │ │ │ +
458 return iterator_== other;
│ │ │ │ +
459 }
│ │ │ │ +
│ │ │ │ +
460
│ │ │ │ +
461
│ │ │ │ +
│ │ │ │ +
467 inline bool equals(const SLListIterator<T,A>& other) const
│ │ │ │ +
468 {
│ │ │ │ +
469 return iterator_== other;
│ │ │ │ +
470 }
│ │ │ │ +
│ │ │ │ +
471
│ │ │ │ +
472
│ │ │ │ +
│ │ │ │ +
478 inline bool equals(const SLListModifyIterator<T,A>& other) const
│ │ │ │ +
479 {
│ │ │ │ +
480 return iterator_== other.iterator_;
│ │ │ │ +
481 }
│ │ │ │ +
│ │ │ │ +
482
│ │ │ │ +
│ │ │ │ +
486 inline void increment()
│ │ │ │ +
487 {
│ │ │ │ +
488 ++iterator_;
│ │ │ │ +
489 ++beforeIterator_;
│ │ │ │ +
490 }
│ │ │ │ +
│ │ │ │ +
491
│ │ │ │ +
│ │ │ │ +
505 inline void insert(const T& v)
│ │ │ │ +
506 {
│ │ │ │ +
507 beforeIterator_.insertAfter(v);
│ │ │ │ +
508 ++beforeIterator_;
│ │ │ │ +
509 }
│ │ │ │ +
│ │ │ │ +
510
│ │ │ │ +
│ │ │ │ +
518 inline void remove()
│ │ │ │ +
519 {
│ │ │ │ +
520 ++iterator_;
│ │ │ │ +
521 beforeIterator_.deleteNext();
│ │ │ │ +
522 }
│ │ │ │ +
│ │ │ │ +
523
│ │ │ │ +
524 private:
│ │ │ │ +
526 SLListIterator<T,A> beforeIterator_;
│ │ │ │ +
528 SLListIterator<T,A> iterator_;
│ │ │ │ +
529 };
│ │ │ │ +
│ │ │ │ +
530
│ │ │ │ +
531 template<typename T, typename A>
│ │ │ │ +
│ │ │ │ +
532 std::ostream& operator<<(std::ostream& os, const SLList<T,A>& sllist)
│ │ │ │ +
533 {
│ │ │ │ +
534 typedef typename SLList<T,A>::const_iterator Iterator;
│ │ │ │ +
535 Iterator end = sllist.end();
│ │ │ │ +
536 Iterator current= sllist.begin();
│ │ │ │ +
537
│ │ │ │ +
538 os << "{ ";
│ │ │ │ +
539
│ │ │ │ +
540 if(current!=end) {
│ │ │ │ +
541 os<<*current<<" ("<<static_cast<const void*>(&(*current))<<")";
│ │ │ │ +
542 ++current;
│ │ │ │ +
543
│ │ │ │ +
544 for(; current != end; ++current)
│ │ │ │ +
545 os<<", "<<*current<<" ("<<static_cast<const void*>(&(*current))<<")";
│ │ │ │ +
546 }
│ │ │ │ +
547 os<<"} ";
│ │ │ │ +
548 return os;
│ │ │ │ +
549 }
│ │ │ │ +
│ │ │ │ +
550
│ │ │ │ +
551 template<typename T, class A>
│ │ │ │ +
│ │ │ │ +
552 SLList<T,A>::Element::Element(const MemberType& item, Element* next)
│ │ │ │ +
553 : next_(next), item_(item)
│ │ │ │ +
554 {}
│ │ │ │ +
│ │ │ │ +
555
│ │ │ │ +
556 template<typename T, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
558 : next_(0), item_()
│ │ │ │ +
559 {}
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
560
│ │ │ │ +
561 template<typename T, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
563 {
│ │ │ │ +
564 next_=0;
│ │ │ │ +
565 }
│ │ │ │ +
│ │ │ │ +
566
│ │ │ │ +
567 template<typename T, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
569 : beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0)
│ │ │ │ +
570 {
│ │ │ │ +
571 beforeHead_.next_=0;
│ │ │ │ +
572 assert(&beforeHead_==tail_);
│ │ │ │ +
573 assert(tail_->next_==0);
│ │ │ │ +
574 }
│ │ │ │ +
│ │ │ │
575
│ │ │ │ -
601 template<class GatherScatter, class Data>
│ │ │ │ -
602 void backward(Data& data);
│ │ │ │ +
576 template<typename T, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
578 : beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0)
│ │ │ │ +
579 {
│ │ │ │ +
580 copyElements(other);
│ │ │ │ +
581 }
│ │ │ │ +
│ │ │ │ +
582
│ │ │ │ +
583 template<typename T, class A>
│ │ │ │ +
584 template<typename T1, class A1>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
586 : beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0)
│ │ │ │ +
587 {
│ │ │ │ +
588 copyElements(other);
│ │ │ │ +
589 }
│ │ │ │ +
│ │ │ │ +
590
│ │ │ │ +
591 template<typename T, typename A>
│ │ │ │ +
592 void SLList<T,A>::copyElements(const SLList<T,A>& other)
│ │ │ │ +
593 {
│ │ │ │ +
594 assert(tail_==&beforeHead_);
│ │ │ │ +
595 assert(size_==0);
│ │ │ │ +
596 typedef typename SLList<T,A>::const_iterator Iterator;
│ │ │ │ +
597 Iterator iend = other.end();
│ │ │ │ +
598 for(Iterator element=other.begin(); element != iend; ++element)
│ │ │ │ +
599 push_back(*element);
│ │ │ │ +
600
│ │ │ │ +
601 assert(other.size()==size());
│ │ │ │ +
602 }
│ │ │ │
603
│ │ │ │ -
607 void free();
│ │ │ │ -
608
│ │ │ │ - │ │ │ │ -
613
│ │ │ │ -
614 private:
│ │ │ │ -
615
│ │ │ │ -
619 typedef std::map<int,std::pair<InterfaceInformation,InterfaceInformation> >
│ │ │ │ -
620 InterfaceMap;
│ │ │ │ +
604 template<typename T, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
606 {
│ │ │ │ +
607 clear();
│ │ │ │ +
608 }
│ │ │ │ +
│ │ │ │ +
609
│ │ │ │ +
610 template<typename T, class A>
│ │ │ │ +
│ │ │ │ +
611 bool SLList<T,A>::operator==(const SLList& other) const
│ │ │ │ +
612 {
│ │ │ │ +
613 if(size()!=other.size())
│ │ │ │ +
614 return false;
│ │ │ │ +
615 for(const_iterator iter=begin(), oiter=other.begin();
│ │ │ │ +
616 iter != end(); ++iter, ++oiter)
│ │ │ │ +
617 if(*iter!=*oiter)
│ │ │ │ +
618 return false;
│ │ │ │ +
619 return true;
│ │ │ │ +
620 }
│ │ │ │ +
│ │ │ │
621
│ │ │ │ -
622
│ │ │ │ -
626 template<class Data, typename IndexedTypeFlag>
│ │ │ │ -
627 struct MessageSizeCalculator
│ │ │ │ -
628 {};
│ │ │ │ -
629
│ │ │ │ -
634 template<class Data>
│ │ │ │ -
635 struct MessageSizeCalculator<Data,SizeOne>
│ │ │ │ -
636 {
│ │ │ │ -
643 inline int operator()(const InterfaceInformation& info) const;
│ │ │ │ -
652 inline int operator()(const Data& data, const InterfaceInformation& info) const;
│ │ │ │ -
653 };
│ │ │ │ +
622 template<typename T, class A>
│ │ │ │ +
│ │ │ │ +
623 bool SLList<T,A>::operator!=(const SLList& other) const
│ │ │ │ +
624 {
│ │ │ │ +
625 if(size()==other.size()) {
│ │ │ │ +
626 for(const_iterator iter=begin(), oiter=other.begin();
│ │ │ │ +
627 iter != end(); ++iter, ++oiter)
│ │ │ │ +
628 if(*iter!=*oiter)
│ │ │ │ +
629 return true;
│ │ │ │ +
630 return false;
│ │ │ │ +
631 }else
│ │ │ │ +
632 return true;
│ │ │ │ +
633 }
│ │ │ │ +
│ │ │ │ +
634 template<typename T, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
636 {
│ │ │ │ +
637 clear();
│ │ │ │ +
638 copyElements(other);
│ │ │ │ +
639 return *this;
│ │ │ │ +
640 }
│ │ │ │ +
│ │ │ │ +
641
│ │ │ │ +
642 template<typename T, class A>
│ │ │ │ +
│ │ │ │ +
643 inline void SLList<T,A>::push_back(const MemberType& item)
│ │ │ │ +
644 {
│ │ │ │ +
645 assert(size_>0 || tail_==&beforeHead_);
│ │ │ │ +
646 tail_->next_ = allocator_.allocate(1);
│ │ │ │ +
647 assert(size_>0 || tail_==&beforeHead_);
│ │ │ │ +
648 tail_ = tail_->next_;
│ │ │ │ +
649 ::new (static_cast<void*>(&(tail_->item_)))T(item);
│ │ │ │ +
650 tail_->next_=0;
│ │ │ │ +
651 assert(tail_->next_==0);
│ │ │ │ +
652 ++size_;
│ │ │ │ +
653 }
│ │ │ │ +
│ │ │ │
654
│ │ │ │ -
659 template<class Data>
│ │ │ │ -
660 struct MessageSizeCalculator<Data,VariableSize>
│ │ │ │ -
661 {
│ │ │ │ -
670 inline int operator()(const Data& data, const InterfaceInformation& info) const;
│ │ │ │ -
671 };
│ │ │ │ -
672
│ │ │ │ -
676 template<class Data, class GatherScatter, bool send, typename IndexedTypeFlag>
│ │ │ │ -
677 struct MessageGatherer
│ │ │ │ -
678 {};
│ │ │ │ -
679
│ │ │ │ -
684 template<class Data, class GatherScatter, bool send>
│ │ │ │ -
685 struct MessageGatherer<Data,GatherScatter,send,SizeOne>
│ │ │ │ -
686 {
│ │ │ │ -
688 typedef typename CommPolicy<Data>::IndexedType Type;
│ │ │ │ -
689
│ │ │ │ -
694 typedef GatherScatter Gatherer;
│ │ │ │ -
695
│ │ │ │ -
701 constexpr static bool forward = send;
│ │ │ │ -
702
│ │ │ │ -
710 inline void operator()(const InterfaceMap& interface, const Data& data, Type* buffer, size_t bufferSize) const;
│ │ │ │ -
711 };
│ │ │ │ -
712
│ │ │ │ -
717 template<class Data, class GatherScatter, bool send>
│ │ │ │ -
718 struct MessageGatherer<Data,GatherScatter,send,VariableSize>
│ │ │ │ -
719 {
│ │ │ │ -
721 typedef typename CommPolicy<Data>::IndexedType Type;
│ │ │ │ -
722
│ │ │ │ -
727 typedef GatherScatter Gatherer;
│ │ │ │ -
728
│ │ │ │ -
734 constexpr static bool forward = send;
│ │ │ │ -
735
│ │ │ │ -
743 inline void operator()(const InterfaceMap& interface, const Data& data, Type* buffer, size_t bufferSize) const;
│ │ │ │ -
744 };
│ │ │ │ -
745
│ │ │ │ -
749 template<class Data, class GatherScatter, bool send, typename IndexedTypeFlag>
│ │ │ │ -
750 struct MessageScatterer
│ │ │ │ -
751 {};
│ │ │ │ -
752
│ │ │ │ -
757 template<class Data, class GatherScatter, bool send>
│ │ │ │ -
758 struct MessageScatterer<Data,GatherScatter,send,SizeOne>
│ │ │ │ -
759 {
│ │ │ │ -
761 typedef typename CommPolicy<Data>::IndexedType Type;
│ │ │ │ -
762
│ │ │ │ -
767 typedef GatherScatter Scatterer;
│ │ │ │ -
768
│ │ │ │ -
774 constexpr static bool forward = send;
│ │ │ │ -
775
│ │ │ │ -
783 inline void operator()(const InterfaceMap& interface, Data& data, Type* buffer, const int& proc) const;
│ │ │ │ -
784 };
│ │ │ │ -
789 template<class Data, class GatherScatter, bool send>
│ │ │ │ -
790 struct MessageScatterer<Data,GatherScatter,send,VariableSize>
│ │ │ │ -
791 {
│ │ │ │ -
793 typedef typename CommPolicy<Data>::IndexedType Type;
│ │ │ │ -
794
│ │ │ │ -
799 typedef GatherScatter Scatterer;
│ │ │ │ -
800
│ │ │ │ -
806 constexpr static bool forward = send;
│ │ │ │ -
807
│ │ │ │ -
815 inline void operator()(const InterfaceMap& interface, Data& data, Type* buffer, const int& proc) const;
│ │ │ │ -
816 };
│ │ │ │ -
817
│ │ │ │ -
821 struct MessageInformation
│ │ │ │ -
822 {
│ │ │ │ -
824 MessageInformation()
│ │ │ │ -
825 : start_(0), size_(0)
│ │ │ │ -
826 {}
│ │ │ │ -
827
│ │ │ │ -
835 MessageInformation(size_t start, size_t size)
│ │ │ │ -
836 : start_(start), size_(size)
│ │ │ │ -
837 {}
│ │ │ │ -
841 size_t start_;
│ │ │ │ -
845 size_t size_;
│ │ │ │ -
846 };
│ │ │ │ -
847
│ │ │ │ -
854 typedef std::map<int,std::pair<MessageInformation,MessageInformation> >
│ │ │ │ -
855 InformationMap;
│ │ │ │ -
859 InformationMap messageInformation_;
│ │ │ │ -
863 char* buffers_[2];
│ │ │ │ -
867 size_t bufferSize_[2];
│ │ │ │ -
868
│ │ │ │ -
872 constexpr static int commTag_ = 0;
│ │ │ │ -
873
│ │ │ │ -
877 std::map<int,std::pair<InterfaceInformation,InterfaceInformation> > interfaces_;
│ │ │ │ -
878
│ │ │ │ -
879 MPI_Comm communicator_;
│ │ │ │ -
880
│ │ │ │ -
884 template<class GatherScatter, bool FORWARD, class Data>
│ │ │ │ -
885 void sendRecv(const Data& source, Data& target);
│ │ │ │ -
886
│ │ │ │ -
887 };
│ │ │ │ -
│ │ │ │ -
888
│ │ │ │ -
889#ifndef DOXYGEN
│ │ │ │ -
890
│ │ │ │ -
891 template<class V>
│ │ │ │ -
892 inline const void* CommPolicy<V>::getAddress(const V& v, int index)
│ │ │ │ -
893 {
│ │ │ │ -
894 return &(v[index]);
│ │ │ │ -
895 }
│ │ │ │ -
896
│ │ │ │ -
897 template<class V>
│ │ │ │ -
898 inline int CommPolicy<V>::getSize([[maybe_unused]] const V& v, [[maybe_unused]] int index)
│ │ │ │ -
899 {
│ │ │ │ -
900 return 1;
│ │ │ │ -
901 }
│ │ │ │ -
902
│ │ │ │ -
903 template<class K, class A, int n>
│ │ │ │ -
904 inline const void* CommPolicy<VariableBlockVector<FieldVector<K, n>, A> >::getAddress(const Type& v, int index)
│ │ │ │ -
905 {
│ │ │ │ -
906 return &(v[index][0]);
│ │ │ │ -
907 }
│ │ │ │ -
908
│ │ │ │ -
909 template<class K, class A, int n>
│ │ │ │ -
910 inline int CommPolicy<VariableBlockVector<FieldVector<K, n>, A> >::getSize(const Type& v, int index)
│ │ │ │ -
911 {
│ │ │ │ -
912 return v[index].getsize();
│ │ │ │ -
913 }
│ │ │ │ -
914
│ │ │ │ -
915 template<class T>
│ │ │ │ -
916 inline const typename CopyGatherScatter<T>::IndexedType& CopyGatherScatter<T>::gather(const T & vec, std::size_t i)
│ │ │ │ -
917 {
│ │ │ │ -
918 return vec[i];
│ │ │ │ -
919 }
│ │ │ │ -
920
│ │ │ │ -
921 template<class T>
│ │ │ │ -
922 inline void CopyGatherScatter<T>::scatter(T& vec, const IndexedType& v, std::size_t i)
│ │ │ │ -
923 {
│ │ │ │ -
924 vec[i]=v;
│ │ │ │ -
925 }
│ │ │ │ -
926
│ │ │ │ -
927 template<typename T>
│ │ │ │ -
928 DatatypeCommunicator<T>::DatatypeCommunicator()
│ │ │ │ -
929 : remoteIndices_(0), created_(false)
│ │ │ │ -
930 {
│ │ │ │ -
931 requests_[0]=0;
│ │ │ │ -
932 requests_[1]=0;
│ │ │ │ -
933 }
│ │ │ │ -
934
│ │ │ │ -
935
│ │ │ │ -
936
│ │ │ │ -
937 template<typename T>
│ │ │ │ -
938 DatatypeCommunicator<T>::~DatatypeCommunicator()
│ │ │ │ -
939 {
│ │ │ │ -
940 free();
│ │ │ │ -
941 }
│ │ │ │ -
942
│ │ │ │ -
943 template<typename T>
│ │ │ │ -
944 template<class T1, class T2, class V>
│ │ │ │ -
945 inline void DatatypeCommunicator<T>::build(const RemoteIndices& remoteIndices,
│ │ │ │ -
946 const T1& source, V& sendData,
│ │ │ │ -
947 const T2& destination, V& receiveData)
│ │ │ │ -
948 {
│ │ │ │ -
949 remoteIndices_ = &remoteIndices;
│ │ │ │ -
950 free();
│ │ │ │ -
951 createDataTypes<T1,T2,V,false>(source,destination, receiveData);
│ │ │ │ -
952 createDataTypes<T1,T2,V,true>(source,destination, sendData);
│ │ │ │ -
953 createRequests<V,true>(sendData, receiveData);
│ │ │ │ -
954 createRequests<V,false>(receiveData, sendData);
│ │ │ │ -
955 created_=true;
│ │ │ │ -
956 }
│ │ │ │ -
957
│ │ │ │ -
958 template<typename T>
│ │ │ │ -
959 void DatatypeCommunicator<T>::free()
│ │ │ │ -
960 {
│ │ │ │ -
961 if(created_) {
│ │ │ │ -
962 delete[] requests_[0];
│ │ │ │ -
963 delete[] requests_[1];
│ │ │ │ -
964 typedef MessageTypeMap::iterator iterator;
│ │ │ │ -
965 typedef MessageTypeMap::const_iterator const_iterator;
│ │ │ │ -
966
│ │ │ │ -
967 const const_iterator end=messageTypes.end();
│ │ │ │ -
968
│ │ │ │ -
969 for(iterator process = messageTypes.begin(); process != end; ++process) {
│ │ │ │ -
970 MPI_Datatype *type = &(process->second.first);
│ │ │ │ -
971 int finalized=0;
│ │ │ │ -
972 MPI_Finalized(&finalized);
│ │ │ │ -
973 if(*type!=MPI_DATATYPE_NULL && !finalized)
│ │ │ │ -
974 MPI_Type_free(type);
│ │ │ │ -
975 type = &(process->second.second);
│ │ │ │ -
976 if(*type!=MPI_DATATYPE_NULL && !finalized)
│ │ │ │ -
977 MPI_Type_free(type);
│ │ │ │ -
978 }
│ │ │ │ -
979 messageTypes.clear();
│ │ │ │ -
980 created_=false;
│ │ │ │ -
981 }
│ │ │ │ -
982
│ │ │ │ -
983 }
│ │ │ │ -
984
│ │ │ │ -
985 template<typename T>
│ │ │ │ -
986 template<class T1, class T2, class V, bool send>
│ │ │ │ -
987 void DatatypeCommunicator<T>::createDataTypes(const T1& sourceFlags, const T2& destFlags, V& data)
│ │ │ │ -
988 {
│ │ │ │ -
989
│ │ │ │ -
990 MPIDatatypeInformation<V> dataInfo(data);
│ │ │ │ -
991 this->template buildInterface<RemoteIndices,T1,T2,MPIDatatypeInformation<V>,send>(*remoteIndices_,sourceFlags, destFlags, dataInfo);
│ │ │ │ -
992
│ │ │ │ -
993 typedef typename RemoteIndices::RemoteIndexMap::const_iterator const_iterator;
│ │ │ │ -
994 const const_iterator end=this->remoteIndices_->end();
│ │ │ │ -
995
│ │ │ │ -
996 // Allocate MPI_Datatypes and deallocate memory for the type construction.
│ │ │ │ -
997 for(const_iterator process=this->remoteIndices_->begin(); process != end; ++process) {
│ │ │ │ -
998 IndexedTypeInformation& info=dataInfo.information_[process->first];
│ │ │ │ -
999 // Shift the displacement
│ │ │ │ -
1000 MPI_Aint base;
│ │ │ │ -
1001 MPI_Get_address(const_cast<void *>(CommPolicy<V>::getAddress(data, 0)), &base);
│ │ │ │ -
1002
│ │ │ │ -
1003 for(int i=0; i< info.elements; i++) {
│ │ │ │ -
1004 info.displ[i]-=base;
│ │ │ │ -
1005 }
│ │ │ │ -
1006
│ │ │ │ -
1007 // Create data type
│ │ │ │ -
1008 MPI_Datatype* type = &( send ? messageTypes[process->first].first : messageTypes[process->first].second);
│ │ │ │ -
1009 MPI_Type_create_hindexed(info.elements, info.length, info.displ,
│ │ │ │ -
1010 MPITraits<typename CommPolicy<V>::IndexedType>::getType(), type);
│ │ │ │ -
1011 MPI_Type_commit(type);
│ │ │ │ -
1012 // Deallocate memory
│ │ │ │ -
1013 info.free();
│ │ │ │ -
1014 }
│ │ │ │ -
1015 }
│ │ │ │ -
1016
│ │ │ │ -
1017 template<typename T>
│ │ │ │ -
1018 template<class V, bool createForward>
│ │ │ │ -
1019 void DatatypeCommunicator<T>::createRequests(V& sendData, V& receiveData)
│ │ │ │ -
1020 {
│ │ │ │ -
1021 typedef std::map<int,std::pair<MPI_Datatype,MPI_Datatype> >::const_iterator MapIterator;
│ │ │ │ -
1022 int rank;
│ │ │ │ -
1023 static int index = createForward ? 1 : 0;
│ │ │ │ -
1024 int noMessages = messageTypes.size();
│ │ │ │ -
1025 // allocate request handles
│ │ │ │ -
1026 requests_[index] = new MPI_Request[2*noMessages];
│ │ │ │ -
1027 const MapIterator end = messageTypes.end();
│ │ │ │ -
1028 int request=0;
│ │ │ │ -
1029 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
│ │ │ │ -
1030
│ │ │ │ -
1031 // Set up the requests for receiving first
│ │ │ │ -
1032 for(MapIterator process = messageTypes.begin(); process != end;
│ │ │ │ -
1033 ++process, ++request) {
│ │ │ │ -
1034 MPI_Datatype type = createForward ? process->second.second : process->second.first;
│ │ │ │ -
1035 void* address = const_cast<void*>(CommPolicy<V>::getAddress(receiveData,0));
│ │ │ │ -
1036 MPI_Recv_init(address, 1, type, process->first, commTag_, this->remoteIndices_->communicator(), requests_[index]+request);
│ │ │ │ -
1037 }
│ │ │ │ -
1038
│ │ │ │ -
1039 // And now the send requests
│ │ │ │ -
1040
│ │ │ │ -
1041 for(MapIterator process = messageTypes.begin(); process != end;
│ │ │ │ -
1042 ++process, ++request) {
│ │ │ │ -
1043 MPI_Datatype type = createForward ? process->second.first : process->second.second;
│ │ │ │ -
1044 void* address = const_cast<void*>(CommPolicy<V>::getAddress(sendData, 0));
│ │ │ │ -
1045 MPI_Ssend_init(address, 1, type, process->first, commTag_, this->remoteIndices_->communicator(), requests_[index]+request);
│ │ │ │ -
1046 }
│ │ │ │ -
1047 }
│ │ │ │ -
1048
│ │ │ │ -
1049 template<typename T>
│ │ │ │ -
1050 void DatatypeCommunicator<T>::forward()
│ │ │ │ -
1051 {
│ │ │ │ -
1052 sendRecv(requests_[1]);
│ │ │ │ -
1053 }
│ │ │ │ -
1054
│ │ │ │ -
1055 template<typename T>
│ │ │ │ -
1056 void DatatypeCommunicator<T>::backward()
│ │ │ │ -
1057 {
│ │ │ │ -
1058 sendRecv(requests_[0]);
│ │ │ │ -
1059 }
│ │ │ │ -
1060
│ │ │ │ -
1061 template<typename T>
│ │ │ │ -
1062 void DatatypeCommunicator<T>::sendRecv(MPI_Request* requests)
│ │ │ │ -
1063 {
│ │ │ │ -
1064 int noMessages = messageTypes.size();
│ │ │ │ -
1065 // Start the receive calls first
│ │ │ │ -
1066 MPI_Startall(noMessages, requests);
│ │ │ │ -
1067 // Now the send calls
│ │ │ │ -
1068 MPI_Startall(noMessages, requests+noMessages);
│ │ │ │ -
1069
│ │ │ │ -
1070 // Wait for completion of the communication send first then receive
│ │ │ │ -
1071 MPI_Status* status=new MPI_Status[2*noMessages];
│ │ │ │ -
1072 for(int i=0; i<2*noMessages; i++)
│ │ │ │ -
1073 status[i].MPI_ERROR=MPI_SUCCESS;
│ │ │ │ -
1074
│ │ │ │ -
1075 int send = MPI_Waitall(noMessages, requests+noMessages, status+noMessages);
│ │ │ │ -
1076 int receive = MPI_Waitall(noMessages, requests, status);
│ │ │ │ -
1077
│ │ │ │ -
1078 // Error checks
│ │ │ │ -
1079 int success=1, globalSuccess=0;
│ │ │ │ -
1080 if(send==MPI_ERR_IN_STATUS) {
│ │ │ │ -
1081 int rank;
│ │ │ │ -
1082 MPI_Comm_rank(this->remoteIndices_->communicator(), &rank);
│ │ │ │ -
1083 std::cerr<<rank<<": Error in sending :"<<std::endl;
│ │ │ │ -
1084 // Search for the error
│ │ │ │ -
1085 for(int i=noMessages; i< 2*noMessages; i++)
│ │ │ │ -
1086 if(status[i].MPI_ERROR!=MPI_SUCCESS) {
│ │ │ │ -
1087 char message[300];
│ │ │ │ -
1088 int messageLength;
│ │ │ │ -
1089 MPI_Error_string(status[i].MPI_ERROR, message, &messageLength);
│ │ │ │ -
1090 std::cerr<<" source="<<status[i].MPI_SOURCE<<" message: ";
│ │ │ │ -
1091 for(int j = 0; j < messageLength; j++)
│ │ │ │ -
1092 std::cout << message[j];
│ │ │ │ -
1093 }
│ │ │ │ -
1094 std::cerr<<std::endl;
│ │ │ │ -
1095 success=0;
│ │ │ │ -
1096 }
│ │ │ │ -
1097
│ │ │ │ -
1098 if(receive==MPI_ERR_IN_STATUS) {
│ │ │ │ -
1099 int rank;
│ │ │ │ -
1100 MPI_Comm_rank(this->remoteIndices_->communicator(), &rank);
│ │ │ │ -
1101 std::cerr<<rank<<": Error in receiving!"<<std::endl;
│ │ │ │ -
1102 // Search for the error
│ │ │ │ -
1103 for(int i=0; i< noMessages; i++)
│ │ │ │ -
1104 if(status[i].MPI_ERROR!=MPI_SUCCESS) {
│ │ │ │ -
1105 char message[300];
│ │ │ │ -
1106 int messageLength;
│ │ │ │ -
1107 MPI_Error_string(status[i].MPI_ERROR, message, &messageLength);
│ │ │ │ -
1108 std::cerr<<" source="<<status[i].MPI_SOURCE<<" message: ";
│ │ │ │ -
1109 for(int j = 0; j < messageLength; j++)
│ │ │ │ -
1110 std::cerr << message[j];
│ │ │ │ -
1111 }
│ │ │ │ -
1112 std::cerr<<std::endl;
│ │ │ │ -
1113 success=0;
│ │ │ │ -
1114 }
│ │ │ │ -
1115
│ │ │ │ -
1116 MPI_Allreduce(&success, &globalSuccess, 1, MPI_INT, MPI_MIN, this->remoteIndices_->communicator());
│ │ │ │ -
1117
│ │ │ │ -
1118 delete[] status;
│ │ │ │ -
1119
│ │ │ │ -
1120 if(!globalSuccess)
│ │ │ │ -
1121 DUNE_THROW(CommunicationError, "A communication error occurred!");
│ │ │ │ -
1122
│ │ │ │ -
1123 }
│ │ │ │ -
1124
│ │ │ │ - │ │ │ │ -
1126 {
│ │ │ │ -
1127 buffers_[0]=0;
│ │ │ │ -
1128 buffers_[1]=0;
│ │ │ │ -
1129 bufferSize_[0]=0;
│ │ │ │ -
1130 bufferSize_[1]=0;
│ │ │ │ -
1131 }
│ │ │ │ -
1132
│ │ │ │ -
1133 template<class Data, class Interface>
│ │ │ │ -
1134 typename std::enable_if<std::is_same<SizeOne, typename CommPolicy<Data>::IndexedTypeFlag>::value, void>::type
│ │ │ │ -
1135 BufferedCommunicator::build(const Interface& interface)
│ │ │ │ -
1136 {
│ │ │ │ -
1137 interfaces_=interface.interfaces();
│ │ │ │ -
1138 communicator_=interface.communicator();
│ │ │ │ -
1139 typedef typename std::map<int,std::pair<InterfaceInformation,InterfaceInformation> >
│ │ │ │ -
1140 ::const_iterator const_iterator;
│ │ │ │ -
1141 typedef typename CommPolicy<Data>::IndexedTypeFlag Flag;
│ │ │ │ -
1142 const const_iterator end = interfaces_.end();
│ │ │ │ -
1143 int lrank;
│ │ │ │ -
1144 MPI_Comm_rank(communicator_, &lrank);
│ │ │ │ -
1145
│ │ │ │ -
1146 bufferSize_[0]=0;
│ │ │ │ -
1147 bufferSize_[1]=0;
│ │ │ │ -
1148
│ │ │ │ -
1149 for(const_iterator interfacePair = interfaces_.begin();
│ │ │ │ -
1150 interfacePair != end; ++interfacePair) {
│ │ │ │ -
1151 int noSend = MessageSizeCalculator<Data,Flag>() (interfacePair->second.first);
│ │ │ │ -
1152 int noRecv = MessageSizeCalculator<Data,Flag>() (interfacePair->second.second);
│ │ │ │ -
1153 if (noSend + noRecv > 0)
│ │ │ │ -
1154 messageInformation_.insert(std::make_pair(interfacePair->first,
│ │ │ │ -
1155 std::make_pair(MessageInformation(bufferSize_[0],
│ │ │ │ -
1156 noSend*sizeof(typename CommPolicy<Data>::IndexedType)),
│ │ │ │ -
1157 MessageInformation(bufferSize_[1],
│ │ │ │ -
1158 noRecv*sizeof(typename CommPolicy<Data>::IndexedType)))));
│ │ │ │ -
1159 bufferSize_[0] += noSend;
│ │ │ │ -
1160 bufferSize_[1] += noRecv;
│ │ │ │ -
1161 }
│ │ │ │ -
1162
│ │ │ │ -
1163 // allocate the buffers
│ │ │ │ -
1164 bufferSize_[0] *= sizeof(typename CommPolicy<Data>::IndexedType);
│ │ │ │ -
1165 bufferSize_[1] *= sizeof(typename CommPolicy<Data>::IndexedType);
│ │ │ │ -
1166
│ │ │ │ -
1167 buffers_[0] = new char[bufferSize_[0]];
│ │ │ │ -
1168 buffers_[1] = new char[bufferSize_[1]];
│ │ │ │ -
1169 }
│ │ │ │ -
1170
│ │ │ │ -
1171 template<class Data, class Interface>
│ │ │ │ -
1172 void BufferedCommunicator::build(const Data& source, const Data& dest, const Interface& interface)
│ │ │ │ -
1173 {
│ │ │ │ -
1174
│ │ │ │ -
1175 interfaces_=interface.interfaces();
│ │ │ │ -
1176 communicator_=interface.communicator();
│ │ │ │ -
1177 typedef typename std::map<int,std::pair<InterfaceInformation,InterfaceInformation> >
│ │ │ │ -
1178 ::const_iterator const_iterator;
│ │ │ │ -
1179 typedef typename CommPolicy<Data>::IndexedTypeFlag Flag;
│ │ │ │ -
1180 const const_iterator end = interfaces_.end();
│ │ │ │ -
1181
│ │ │ │ -
1182 bufferSize_[0]=0;
│ │ │ │ -
1183 bufferSize_[1]=0;
│ │ │ │ -
1184
│ │ │ │ -
1185 for(const_iterator interfacePair = interfaces_.begin();
│ │ │ │ -
1186 interfacePair != end; ++interfacePair) {
│ │ │ │ -
1187 int noSend = MessageSizeCalculator<Data,Flag>() (source, interfacePair->second.first);
│ │ │ │ -
1188 int noRecv = MessageSizeCalculator<Data,Flag>() (dest, interfacePair->second.second);
│ │ │ │ -
1189 if (noSend + noRecv > 0)
│ │ │ │ -
1190 messageInformation_.insert(std::make_pair(interfacePair->first,
│ │ │ │ -
1191 std::make_pair(MessageInformation(bufferSize_[0],
│ │ │ │ -
1192 noSend*sizeof(typename CommPolicy<Data>::IndexedType)),
│ │ │ │ -
1193 MessageInformation(bufferSize_[1],
│ │ │ │ -
1194 noRecv*sizeof(typename CommPolicy<Data>::IndexedType)))));
│ │ │ │ -
1195 bufferSize_[0] += noSend;
│ │ │ │ -
1196 bufferSize_[1] += noRecv;
│ │ │ │ -
1197 }
│ │ │ │ -
1198
│ │ │ │ -
1199 bufferSize_[0] *= sizeof(typename CommPolicy<Data>::IndexedType);
│ │ │ │ -
1200 bufferSize_[1] *= sizeof(typename CommPolicy<Data>::IndexedType);
│ │ │ │ -
1201 // allocate the buffers
│ │ │ │ -
1202 buffers_[0] = new char[bufferSize_[0]];
│ │ │ │ -
1203 buffers_[1] = new char[bufferSize_[1]];
│ │ │ │ -
1204 }
│ │ │ │ -
1205
│ │ │ │ -
1206 inline void BufferedCommunicator::free()
│ │ │ │ -
1207 {
│ │ │ │ -
1208 messageInformation_.clear();
│ │ │ │ -
1209 if(buffers_[0])
│ │ │ │ -
1210 delete[] buffers_[0];
│ │ │ │ -
1211
│ │ │ │ -
1212 if(buffers_[1])
│ │ │ │ -
1213 delete[] buffers_[1];
│ │ │ │ -
1214 buffers_[0]=buffers_[1]=0;
│ │ │ │ -
1215 }
│ │ │ │ -
1216
│ │ │ │ - │ │ │ │ -
1218 {
│ │ │ │ -
1219 free();
│ │ │ │ -
1220 }
│ │ │ │ -
1221
│ │ │ │ -
1222 template<class Data>
│ │ │ │ -
1223 inline int BufferedCommunicator::MessageSizeCalculator<Data,SizeOne>::operator()
│ │ │ │ -
1224 (const InterfaceInformation& info) const
│ │ │ │ -
1225 {
│ │ │ │ -
1226 return info.size();
│ │ │ │ -
1227 }
│ │ │ │ -
1228
│ │ │ │ -
1229
│ │ │ │ -
1230 template<class Data>
│ │ │ │ -
1231 inline int BufferedCommunicator::MessageSizeCalculator<Data,SizeOne>::operator()
│ │ │ │ -
1232 (const Data&, const InterfaceInformation& info) const
│ │ │ │ -
1233 {
│ │ │ │ -
1234 return operator()(info);
│ │ │ │ -
1235 }
│ │ │ │ -
1236
│ │ │ │ -
1237
│ │ │ │ -
1238 template<class Data>
│ │ │ │ -
1239 inline int BufferedCommunicator::MessageSizeCalculator<Data, VariableSize>::operator()
│ │ │ │ -
1240 (const Data& data, const InterfaceInformation& info) const
│ │ │ │ -
1241 {
│ │ │ │ -
1242 int entries=0;
│ │ │ │ -
1243
│ │ │ │ -
1244 for(size_t i=0; i < info.size(); i++)
│ │ │ │ -
1245 entries += CommPolicy<Data>::getSize(data,info[i]);
│ │ │ │ -
1246
│ │ │ │ -
1247 return entries;
│ │ │ │ -
1248 }
│ │ │ │ -
1249
│ │ │ │ -
1250
│ │ │ │ -
1251 template<class Data, class GatherScatter, bool FORWARD>
│ │ │ │ -
1252 inline void BufferedCommunicator::MessageGatherer<Data,GatherScatter,FORWARD,VariableSize>::operator()(const InterfaceMap& interfaces,const Data& data, Type* buffer, [[maybe_unused]] size_t bufferSize) const
│ │ │ │ -
1253 {
│ │ │ │ -
1254 typedef typename InterfaceMap::const_iterator
│ │ │ │ -
1255 const_iterator;
│ │ │ │ -
1256
│ │ │ │ -
1257 int rank;
│ │ │ │ -
1258 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
│ │ │ │ -
1259 const const_iterator end = interfaces.end();
│ │ │ │ -
1260 size_t index=0;
│ │ │ │ -
1261
│ │ │ │ -
1262 for(const_iterator interfacePair = interfaces.begin();
│ │ │ │ -
1263 interfacePair != end; ++interfacePair) {
│ │ │ │ -
1264 int size = forward ? interfacePair->second.first.size() :
│ │ │ │ -
1265 interfacePair->second.second.size();
│ │ │ │ -
1266
│ │ │ │ -
1267 for(int i=0; i < size; i++) {
│ │ │ │ -
1268 int local = forward ? interfacePair->second.first[i] :
│ │ │ │ -
1269 interfacePair->second.second[i];
│ │ │ │ -
1270 for(std::size_t j=0; j < CommPolicy<Data>::getSize(data, local); j++, index++) {
│ │ │ │ -
1271
│ │ │ │ -
1272#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ -
1273 assert(bufferSize>=(index+1)*sizeof(typename CommPolicy<Data>::IndexedType));
│ │ │ │ -
1274#endif
│ │ │ │ -
1275 buffer[index]=GatherScatter::gather(data, local, j);
│ │ │ │ -
1276 }
│ │ │ │ -
1277
│ │ │ │ -
1278 }
│ │ │ │ -
1279 }
│ │ │ │ -
1280
│ │ │ │ -
1281 }
│ │ │ │ -
1282
│ │ │ │ -
1283
│ │ │ │ -
1284 template<class Data, class GatherScatter, bool FORWARD>
│ │ │ │ -
1285 inline void BufferedCommunicator::MessageGatherer<Data,GatherScatter,FORWARD,SizeOne>::operator()(
│ │ │ │ -
1286 const InterfaceMap& interfaces, const Data& data, Type* buffer, [[maybe_unused]] size_t bufferSize) const
│ │ │ │ -
1287 {
│ │ │ │ -
1288 typedef typename InterfaceMap::const_iterator
│ │ │ │ -
1289 const_iterator;
│ │ │ │ -
1290 const const_iterator end = interfaces.end();
│ │ │ │ -
1291 size_t index = 0;
│ │ │ │ -
1292
│ │ │ │ -
1293 int rank;
│ │ │ │ -
1294 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
│ │ │ │ -
1295
│ │ │ │ -
1296 for(const_iterator interfacePair = interfaces.begin();
│ │ │ │ -
1297 interfacePair != end; ++interfacePair) {
│ │ │ │ -
1298 size_t size = FORWARD ? interfacePair->second.first.size() :
│ │ │ │ -
1299 interfacePair->second.second.size();
│ │ │ │ -
1300
│ │ │ │ -
1301 for(size_t i=0; i < size; i++) {
│ │ │ │ -
1302
│ │ │ │ -
1303#ifdef DUNE_ISTL_WITH_CHECKING
│ │ │ │ -
1304 assert(bufferSize>=(index+1)*sizeof(typename CommPolicy<Data>::IndexedType));
│ │ │ │ -
1305#endif
│ │ │ │ -
1306
│ │ │ │ -
1307 buffer[index++] = GatherScatter::gather(data, FORWARD ? interfacePair->second.first[i] :
│ │ │ │ -
1308 interfacePair->second.second[i]);
│ │ │ │ -
1309 }
│ │ │ │ -
1310 }
│ │ │ │ -
1311
│ │ │ │ -
1312 }
│ │ │ │ -
1313
│ │ │ │ -
1314
│ │ │ │ -
1315 template<class Data, class GatherScatter, bool FORWARD>
│ │ │ │ -
1316 inline void BufferedCommunicator::MessageScatterer<Data,GatherScatter,FORWARD,VariableSize>::operator()(const InterfaceMap& interfaces, Data& data, Type* buffer, const int& proc) const
│ │ │ │ -
1317 {
│ │ │ │ -
1318 typedef typename InterfaceMap::value_type::second_type::first_type Information;
│ │ │ │ -
1319 const typename InterfaceMap::const_iterator infoPair = interfaces.find(proc);
│ │ │ │ -
1320
│ │ │ │ -
1321 assert(infoPair!=interfaces.end());
│ │ │ │ -
1322
│ │ │ │ -
1323 const Information& info = FORWARD ? infoPair->second.second :
│ │ │ │ -
1324 infoPair->second.first;
│ │ │ │ -
1325
│ │ │ │ -
1326 for(size_t i=0, index=0; i < info.size(); i++) {
│ │ │ │ -
1327 for(size_t j=0; j < CommPolicy<Data>::getSize(data, info[i]); j++)
│ │ │ │ -
1328 GatherScatter::scatter(data, buffer[index++], info[i], j);
│ │ │ │ -
1329 }
│ │ │ │ -
1330 }
│ │ │ │ -
1331
│ │ │ │ -
1332
│ │ │ │ -
1333 template<class Data, class GatherScatter, bool FORWARD>
│ │ │ │ -
1334 inline void BufferedCommunicator::MessageScatterer<Data,GatherScatter,FORWARD,SizeOne>::operator()(const InterfaceMap& interfaces, Data& data, Type* buffer, const int& proc) const
│ │ │ │ -
1335 {
│ │ │ │ -
1336 typedef typename InterfaceMap::value_type::second_type::first_type Information;
│ │ │ │ -
1337 const typename InterfaceMap::const_iterator infoPair = interfaces.find(proc);
│ │ │ │ -
1338
│ │ │ │ -
1339 assert(infoPair!=interfaces.end());
│ │ │ │ -
1340
│ │ │ │ -
1341 const Information& info = FORWARD ? infoPair->second.second :
│ │ │ │ -
1342 infoPair->second.first;
│ │ │ │ -
1343
│ │ │ │ -
1344 for(size_t i=0; i < info.size(); i++) {
│ │ │ │ -
1345 GatherScatter::scatter(data, buffer[i], info[i]);
│ │ │ │ -
1346 }
│ │ │ │ -
1347 }
│ │ │ │ -
1348
│ │ │ │ -
1349
│ │ │ │ -
1350 template<class GatherScatter,class Data>
│ │ │ │ -
1351 void BufferedCommunicator::forward(Data& data)
│ │ │ │ -
1352 {
│ │ │ │ -
1353 this->template sendRecv<GatherScatter,true>(data, data);
│ │ │ │ -
1354 }
│ │ │ │ -
1355
│ │ │ │ -
1356
│ │ │ │ -
1357 template<class GatherScatter, class Data>
│ │ │ │ -
1358 void BufferedCommunicator::backward(Data& data)
│ │ │ │ -
1359 {
│ │ │ │ -
1360 this->template sendRecv<GatherScatter,false>(data, data);
│ │ │ │ -
1361 }
│ │ │ │ -
1362
│ │ │ │ -
1363
│ │ │ │ -
1364 template<class GatherScatter, class Data>
│ │ │ │ -
1365 void BufferedCommunicator::forward(const Data& source, Data& dest)
│ │ │ │ -
1366 {
│ │ │ │ -
1367 this->template sendRecv<GatherScatter,true>(source, dest);
│ │ │ │ -
1368 }
│ │ │ │ -
1369
│ │ │ │ -
1370
│ │ │ │ -
1371 template<class GatherScatter, class Data>
│ │ │ │ -
1372 void BufferedCommunicator::backward(Data& source, const Data& dest)
│ │ │ │ -
1373 {
│ │ │ │ -
1374 this->template sendRecv<GatherScatter,false>(dest, source);
│ │ │ │ -
1375 }
│ │ │ │ -
1376
│ │ │ │ -
1377
│ │ │ │ -
1378 template<class GatherScatter, bool FORWARD, class Data>
│ │ │ │ -
1379 void BufferedCommunicator::sendRecv(const Data& source, Data& dest)
│ │ │ │ -
1380 {
│ │ │ │ -
1381 int rank, lrank;
│ │ │ │ -
1382
│ │ │ │ -
1383 MPI_Comm_rank(MPI_COMM_WORLD,&rank);
│ │ │ │ -
1384 MPI_Comm_rank(MPI_COMM_WORLD,&lrank);
│ │ │ │ -
1385
│ │ │ │ -
1386 typedef typename CommPolicy<Data>::IndexedType Type;
│ │ │ │ -
1387 Type *sendBuffer, *recvBuffer;
│ │ │ │ -
1388 size_t sendBufferSize;
│ │ │ │ -
1389#ifndef NDEBUG
│ │ │ │ -
1390 size_t recvBufferSize;
│ │ │ │ -
1391#endif
│ │ │ │ -
1392
│ │ │ │ -
1393 if(FORWARD) {
│ │ │ │ -
1394 sendBuffer = reinterpret_cast<Type*>(buffers_[0]);
│ │ │ │ -
1395 sendBufferSize = bufferSize_[0];
│ │ │ │ -
1396 recvBuffer = reinterpret_cast<Type*>(buffers_[1]);
│ │ │ │ -
1397#ifndef NDEBUG
│ │ │ │ -
1398 recvBufferSize = bufferSize_[1];
│ │ │ │ -
1399#endif
│ │ │ │ -
1400 }else{
│ │ │ │ -
1401 sendBuffer = reinterpret_cast<Type*>(buffers_[1]);
│ │ │ │ -
1402 sendBufferSize = bufferSize_[1];
│ │ │ │ -
1403 recvBuffer = reinterpret_cast<Type*>(buffers_[0]);
│ │ │ │ -
1404#ifndef NDEBUG
│ │ │ │ -
1405 recvBufferSize = bufferSize_[0];
│ │ │ │ -
1406#endif
│ │ │ │ -
1407 }
│ │ │ │ -
1408 typedef typename CommPolicy<Data>::IndexedTypeFlag Flag;
│ │ │ │ -
1409
│ │ │ │ -
1410 MessageGatherer<Data,GatherScatter,FORWARD,Flag>() (interfaces_, source, sendBuffer, sendBufferSize);
│ │ │ │ -
1411
│ │ │ │ -
1412 MPI_Request* sendRequests = new MPI_Request[messageInformation_.size()];
│ │ │ │ -
1413 MPI_Request* recvRequests = new MPI_Request[messageInformation_.size()];
│ │ │ │ -
1414 /* Number of recvRequests that are not MPI_REQUEST_NULL */
│ │ │ │ -
1415 size_t numberOfRealRecvRequests = 0;
│ │ │ │ -
1416
│ │ │ │ -
1417 // Setup receive first
│ │ │ │ -
1418 typedef typename InformationMap::const_iterator const_iterator;
│ │ │ │ -
1419
│ │ │ │ -
1420 const const_iterator end = messageInformation_.end();
│ │ │ │ -
1421 size_t i=0;
│ │ │ │ -
1422 int* processMap = new int[messageInformation_.size()];
│ │ │ │ -
1423
│ │ │ │ -
1424 for(const_iterator info = messageInformation_.begin(); info != end; ++info, ++i) {
│ │ │ │ -
1425 processMap[i]=info->first;
│ │ │ │ -
1426 if(FORWARD) {
│ │ │ │ -
1427 assert(info->second.second.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.second.size_ <= recvBufferSize );
│ │ │ │ -
1428 Dune::dvverb<<rank<<": receiving "<<info->second.second.size_<<" from "<<info->first<<std::endl;
│ │ │ │ -
1429 if(info->second.second.size_) {
│ │ │ │ -
1430 MPI_Irecv(recvBuffer+info->second.second.start_, info->second.second.size_,
│ │ │ │ -
1431 MPI_BYTE, info->first, commTag_, communicator_,
│ │ │ │ -
1432 recvRequests+i);
│ │ │ │ -
1433 numberOfRealRecvRequests += 1;
│ │ │ │ -
1434 } else {
│ │ │ │ -
1435 // Nothing to receive -> set request to inactive
│ │ │ │ -
1436 recvRequests[i]=MPI_REQUEST_NULL;
│ │ │ │ -
1437 }
│ │ │ │ -
1438 }else{
│ │ │ │ -
1439 assert(info->second.first.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.first.size_ <= recvBufferSize );
│ │ │ │ -
1440 Dune::dvverb<<rank<<": receiving "<<info->second.first.size_<<" to "<<info->first<<std::endl;
│ │ │ │ -
1441 if(info->second.first.size_) {
│ │ │ │ -
1442 MPI_Irecv(recvBuffer+info->second.first.start_, info->second.first.size_,
│ │ │ │ -
1443 MPI_BYTE, info->first, commTag_, communicator_,
│ │ │ │ -
1444 recvRequests+i);
│ │ │ │ -
1445 numberOfRealRecvRequests += 1;
│ │ │ │ -
1446 } else {
│ │ │ │ -
1447 // Nothing to receive -> set request to inactive
│ │ │ │ -
1448 recvRequests[i]=MPI_REQUEST_NULL;
│ │ │ │ -
1449 }
│ │ │ │ -
1450 }
│ │ │ │ -
1451 }
│ │ │ │ -
1452
│ │ │ │ -
1453 // now the send requests
│ │ │ │ -
1454 i=0;
│ │ │ │ -
1455 for(const_iterator info = messageInformation_.begin(); info != end; ++info, ++i)
│ │ │ │ -
1456 if(FORWARD) {
│ │ │ │ -
1457 assert(info->second.second.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.second.size_ <= recvBufferSize );
│ │ │ │ -
1458 Dune::dvverb<<rank<<": sending "<<info->second.first.size_<<" to "<<info->first<<std::endl;
│ │ │ │ -
1459 assert(info->second.first.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.first.size_ <= sendBufferSize );
│ │ │ │ -
1460 if(info->second.first.size_)
│ │ │ │ -
1461 MPI_Issend(sendBuffer+info->second.first.start_, info->second.first.size_,
│ │ │ │ -
1462 MPI_BYTE, info->first, commTag_, communicator_,
│ │ │ │ -
1463 sendRequests+i);
│ │ │ │ -
1464 else
│ │ │ │ -
1465 // Nothing to send -> set request to inactive
│ │ │ │ -
1466 sendRequests[i]=MPI_REQUEST_NULL;
│ │ │ │ -
1467 }else{
│ │ │ │ -
1468 assert(info->second.second.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.second.size_ <= sendBufferSize );
│ │ │ │ -
1469 Dune::dvverb<<rank<<": sending "<<info->second.second.size_<<" to "<<info->first<<std::endl;
│ │ │ │ -
1470 if(info->second.second.size_)
│ │ │ │ -
1471 MPI_Issend(sendBuffer+info->second.second.start_, info->second.second.size_,
│ │ │ │ -
1472 MPI_BYTE, info->first, commTag_, communicator_,
│ │ │ │ -
1473 sendRequests+i);
│ │ │ │ -
1474 else
│ │ │ │ -
1475 // Nothing to send -> set request to inactive
│ │ │ │ -
1476 sendRequests[i]=MPI_REQUEST_NULL;
│ │ │ │ -
1477 }
│ │ │ │ -
1478
│ │ │ │ -
1479 // Wait for completion of receive and immediately start scatter
│ │ │ │ -
1480 i=0;
│ │ │ │ -
1481 //int success = 1;
│ │ │ │ -
1482 int finished = MPI_UNDEFINED;
│ │ │ │ -
1483 MPI_Status status; //[messageInformation_.size()];
│ │ │ │ -
1484 //MPI_Waitall(messageInformation_.size(), recvRequests, status);
│ │ │ │ -
1485
│ │ │ │ -
1486 for(i=0; i< numberOfRealRecvRequests; i++) {
│ │ │ │ -
1487 status.MPI_ERROR=MPI_SUCCESS;
│ │ │ │ -
1488 MPI_Waitany(messageInformation_.size(), recvRequests, &finished, &status);
│ │ │ │ -
1489 assert(finished != MPI_UNDEFINED);
│ │ │ │ -
1490
│ │ │ │ -
1491 if(status.MPI_ERROR==MPI_SUCCESS) {
│ │ │ │ -
1492 int& proc = processMap[finished];
│ │ │ │ -
1493 typename InformationMap::const_iterator infoIter = messageInformation_.find(proc);
│ │ │ │ -
1494 assert(infoIter != messageInformation_.end());
│ │ │ │ -
1495
│ │ │ │ -
1496 MessageInformation info = (FORWARD) ? infoIter->second.second : infoIter->second.first;
│ │ │ │ -
1497 assert(info.start_+info.size_ <= recvBufferSize);
│ │ │ │ -
1498
│ │ │ │ -
1499 MessageScatterer<Data,GatherScatter,FORWARD,Flag>() (interfaces_, dest, recvBuffer+info.start_, proc);
│ │ │ │ -
1500 }else{
│ │ │ │ -
1501 std::cerr<<rank<<": MPI_Error occurred while receiving message from "<<processMap[finished]<<std::endl;
│ │ │ │ -
1502 //success=0;
│ │ │ │ -
1503 }
│ │ │ │ -
1504 }
│ │ │ │ -
1505
│ │ │ │ -
1506 MPI_Status recvStatus;
│ │ │ │ -
1507
│ │ │ │ -
1508 // Wait for completion of sends
│ │ │ │ -
1509 for(i=0; i< messageInformation_.size(); i++)
│ │ │ │ -
1510 if(MPI_SUCCESS!=MPI_Wait(sendRequests+i, &recvStatus)) {
│ │ │ │ -
1511 std::cerr<<rank<<": MPI_Error occurred while sending message to "<<processMap[finished]<<std::endl;
│ │ │ │ -
1512 //success=0;
│ │ │ │ -
1513 }
│ │ │ │ -
1514 /*
│ │ │ │ -
1515 int globalSuccess;
│ │ │ │ -
1516 MPI_Allreduce(&success, &globalSuccess, 1, MPI_INT, MPI_MIN, interface_->communicator());
│ │ │ │ -
1517
│ │ │ │ -
1518 if(!globalSuccess)
│ │ │ │ -
1519 DUNE_THROW(CommunicationError, "A communication error occurred!");
│ │ │ │ -
1520 */
│ │ │ │ -
1521 delete[] processMap;
│ │ │ │ -
1522 delete[] sendRequests;
│ │ │ │ -
1523 delete[] recvRequests;
│ │ │ │ -
1524
│ │ │ │ -
1525 }
│ │ │ │ -
1526
│ │ │ │ -
1527#endif // DOXYGEN
│ │ │ │ -
1528
│ │ │ │ -
1530}
│ │ │ │ -
1531
│ │ │ │ -
1532#endif // HAVE_MPI
│ │ │ │ -
1533#endif // DUNE_COMMON_PARALLEL_COMMUNICATOR_HH
│ │ │ │ -
Classes describing a distributed indexset.
│ │ │ │ -
Standard Dune debug streams.
│ │ │ │ -
A few common exception classes.
│ │ │ │ -
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ -
DVVerbType dvverb(std::cout)
stream for very verbose output.
Definition stdstreams.hh:96
│ │ │ │ +
655 template<typename T, class A>
│ │ │ │ +
656 inline void SLList<T,A>::insertAfter(Element* current, const T& item)
│ │ │ │ +
657 {
│ │ │ │ +
658 assert(current);
│ │ │ │ +
659
│ │ │ │ +
660#ifndef NDEBUG
│ │ │ │ +
661 bool changeTail = (current == tail_);
│ │ │ │ +
662#endif
│ │ │ │ +
663
│ │ │ │ +
664 // Save old next element
│ │ │ │ +
665 Element* tmp = current->next_;
│ │ │ │ +
666
│ │ │ │ +
667 assert(!changeTail || !tmp);
│ │ │ │ +
668
│ │ │ │ +
669 // Allocate space
│ │ │ │ +
670 current->next_ = allocator_.allocate(1);
│ │ │ │ +
671
│ │ │ │ +
672 // Use copy constructor to initialize memory
│ │ │ │ +
673 std::allocator_traits<Allocator>::construct(allocator_, current->next_, Element(item,tmp));
│ │ │ │ +
674
│ │ │ │ +
675 //::new(static_cast<void*>(&(current->next_->item_))) T(item);
│ │ │ │ +
676
│ │ │ │ +
677 if(!current->next_->next_) {
│ │ │ │ +
678 // Update tail
│ │ │ │ +
679 assert(changeTail);
│ │ │ │ +
680 tail_ = current->next_;
│ │ │ │ +
681 }
│ │ │ │ +
682 ++size_;
│ │ │ │ +
683 assert(!tail_->next_);
│ │ │ │ +
684 }
│ │ │ │ +
685
│ │ │ │ +
686 template<typename T, class A>
│ │ │ │ +
│ │ │ │ +
687 inline void SLList<T,A>::push_front(const MemberType& item)
│ │ │ │ +
688 {
│ │ │ │ +
689 if(tail_ == &beforeHead_) {
│ │ │ │ +
690 // list was empty
│ │ │ │ +
691 beforeHead_.next_ = tail_ = allocator_.allocate(1, 0);
│ │ │ │ +
692 ::new(static_cast<void*>(&beforeHead_.next_->item_))T(item);
│ │ │ │ +
693 beforeHead_.next_->next_=0;
│ │ │ │ +
694 }else{
│ │ │ │ +
695 Element* added = allocator_.allocate(1, 0);
│ │ │ │ +
696 ::new(static_cast<void*>(&added->item_))T(item);
│ │ │ │ +
697 added->next_=beforeHead_.next_;
│ │ │ │ +
698 beforeHead_.next_=added;
│ │ │ │ +
699 }
│ │ │ │ +
700 assert(tail_->next_==0);
│ │ │ │ +
701 ++size_;
│ │ │ │ +
702 }
│ │ │ │ +
│ │ │ │ +
703
│ │ │ │ +
704
│ │ │ │ +
705 template<typename T, class A>
│ │ │ │ +
706 inline void SLList<T,A>::deleteNext(Element* current)
│ │ │ │ +
707 {
│ │ │ │ +
708 this->template deleteNext<true>(current);
│ │ │ │ +
709 }
│ │ │ │ +
710
│ │ │ │ +
711 template<typename T, class A>
│ │ │ │ +
712 template<bool watchForTail>
│ │ │ │ +
713 inline void SLList<T,A>::deleteNext(Element* current)
│ │ │ │ +
714 {
│ │ │ │ +
715 assert(current->next_);
│ │ │ │ +
716 Element* next = current->next_;
│ │ │ │ +
717
│ │ │ │ +
718 if(watchForTail)
│ │ │ │ +
719 if(next == tail_) {
│ │ │ │ +
720 // deleting last element changes tail!
│ │ │ │ +
721 tail_ = current;
│ │ │ │ +
722 }
│ │ │ │ +
723
│ │ │ │ +
724 current->next_ = next->next_;
│ │ │ │ +
725 std::allocator_traits<Allocator>::destroy(allocator_, next);
│ │ │ │ +
726 allocator_.deallocate(next, 1);
│ │ │ │ +
727 --size_;
│ │ │ │ +
728 assert(!watchForTail || &beforeHead_ != tail_ || size_==0);
│ │ │ │ +
729 }
│ │ │ │ +
730
│ │ │ │ +
731 template<typename T, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
733 {
│ │ │ │ +
734 deleteNext(&beforeHead_);
│ │ │ │ +
735 }
│ │ │ │ +
│ │ │ │ +
736
│ │ │ │ +
737 template<typename T, class A>
│ │ │ │ +
│ │ │ │ +
738 inline void SLList<T,A>::clear()
│ │ │ │ +
739 {
│ │ │ │ +
740 while(beforeHead_.next_ ) {
│ │ │ │ +
741 this->template deleteNext<false>(&beforeHead_);
│ │ │ │ +
742 }
│ │ │ │ +
743
│ │ │ │ +
744 assert(size_==0);
│ │ │ │ +
745 // update the tail!
│ │ │ │ +
746 tail_ = &beforeHead_;
│ │ │ │ +
747 }
│ │ │ │ +
│ │ │ │ +
748
│ │ │ │ +
749 template<typename T, class A>
│ │ │ │ +
│ │ │ │ +
750 inline bool SLList<T,A>::empty() const
│ │ │ │ +
751 {
│ │ │ │ +
752 return (&beforeHead_ == tail_);
│ │ │ │ +
753 }
│ │ │ │ +
│ │ │ │ +
754
│ │ │ │ +
755 template<typename T, class A>
│ │ │ │ +
│ │ │ │ +
756 inline int SLList<T,A>::size() const
│ │ │ │ +
757 {
│ │ │ │ +
758 return size_;
│ │ │ │ +
759 }
│ │ │ │ +
│ │ │ │ +
760
│ │ │ │ +
761 template<typename T, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
763 {
│ │ │ │ +
764 return iterator(beforeHead_.next_, this);
│ │ │ │ +
765 }
│ │ │ │ +
│ │ │ │ +
766
│ │ │ │ +
767 template<typename T, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
769 {
│ │ │ │ +
770 return const_iterator(beforeHead_.next_);
│ │ │ │ +
771 }
│ │ │ │ +
│ │ │ │ +
772
│ │ │ │ +
773 template<typename T, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
775 {
│ │ │ │ +
776 return iterator();
│ │ │ │ +
777 }
│ │ │ │ +
│ │ │ │ +
778
│ │ │ │ +
779 template<typename T, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
781 {
│ │ │ │ +
782 return SLListModifyIterator<T,A>(iterator(tail_, this),iterator());
│ │ │ │ +
783 }
│ │ │ │ +
│ │ │ │ +
784
│ │ │ │ +
785
│ │ │ │ +
786 template<typename T, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
788 {
│ │ │ │ +
789 return SLListModifyIterator<T,A>(iterator(&beforeHead_, this),
│ │ │ │ +
790 iterator(beforeHead_.next_, this));
│ │ │ │ +
791 }
│ │ │ │ +
│ │ │ │ +
792
│ │ │ │ +
793 template<typename T, class A>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
795 {
│ │ │ │ +
796 return const_iterator();
│ │ │ │ +
797 }
│ │ │ │ +
│ │ │ │ +
798
│ │ │ │ +
800}
│ │ │ │ +
801#endif
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
│ │ │ │ +
This file implements iterator facade classes for writing stl conformant iterators.
│ │ │ │ +
void push_front(const MemberType &item)
Add a new entry to the beginning of the list.
Definition sllist.hh:687
│ │ │ │ +
bool equals(const SLListConstIterator< T, A > &other) const
Equality test for the iterator facade.
Definition sllist.hh:406
│ │ │ │ +
void push_back(const MemberType &item)
Add a new entry to the end of the list.
Definition sllist.hh:643
│ │ │ │ +
ModifyIterator endModify()
Get an iterator capable of deleting and inserting elements.
Definition sllist.hh:780
│ │ │ │ +
SLListModifyIterator()
Definition sllist.hh:438
│ │ │ │ +
Element()
Definition sllist.hh:557
│ │ │ │ +
T & dereference() const
Dereferencing function for the iterator facade.
Definition sllist.hh:294
│ │ │ │ +
bool operator!=(const SLList &sl) const
Definition sllist.hh:623
│ │ │ │ +
MemberType item_
The element we hold.
Definition sllist.hh:212
│ │ │ │ +
SLListConstIterator(typename SLList< T, A >::Element *item)
Definition sllist.hh:380
│ │ │ │ +
typename std::allocator_traits< A >::template rebind_alloc< Element > Allocator
The allocator to use.
Definition sllist.hh:64
│ │ │ │ +
void insertAfter(const T &v) const
Insert an element in the underlying list after the current position.
Definition sllist.hh:342
│ │ │ │ +
SLListIterator< T, A > iterator
The mutable iterator of the list.
Definition sllist.hh:69
│ │ │ │ +
SLListConstIterator(const SLListModifyIterator< T, A > &other)
Definition sllist.hh:388
│ │ │ │ +
SLListIterator()
Definition sllist.hh:282
│ │ │ │ +
~Element()
Definition sllist.hh:562
│ │ │ │ +
bool operator==(const SLList &sl) const
Definition sllist.hh:611
│ │ │ │ +
void deleteNext() const
Delete the entry after the current position.
Definition sllist.hh:353
│ │ │ │ +
SLList(const SLList< T, A > &other)
Copy constructor.
Definition sllist.hh:577
│ │ │ │ +
bool equals(const SLListModifyIterator< T, A > &other) const
Equality test for the iterator facade.
Definition sllist.hh:324
│ │ │ │ +
T & dereference() const
Dereferencing function for the iterator facade.
Definition sllist.hh:446
│ │ │ │ +
int size() const
Get the number of elements the list contains.
Definition sllist.hh:756
│ │ │ │ +
const_iterator begin() const
Get an iterator pointing to the first element in the list.
Definition sllist.hh:768
│ │ │ │ +
iterator end()
Get an iterator pointing to the end of the list.
Definition sllist.hh:774
│ │ │ │ +
void clear()
Remove all elements from the list.
Definition sllist.hh:738
│ │ │ │ +
SLList(const SLList< T1, A1 > &other)
Copy constructor with type conversion.
Definition sllist.hh:585
│ │ │ │ +
T MemberType
The type we store.
Definition sllist.hh:59
│ │ │ │ +
bool equals(const SLListModifyIterator< T, A > &other) const
Test whether another iterator is equal.
Definition sllist.hh:478
│ │ │ │ +
ModifyIterator beginModify()
Get an iterator capable of deleting and inserting elements.
Definition sllist.hh:787
│ │ │ │ +
SLList< T, A > & operator=(const SLList< T, A > &other)
Assignment operator.
Definition sllist.hh:635
│ │ │ │ +
SLListConstIterator(const SLListIterator< T, A > &other)
Definition sllist.hh:384
│ │ │ │ +
SLListConstIterator< T, A > const_iterator
The constant iterator of the list.
Definition sllist.hh:74
│ │ │ │ +
bool empty() const
Check whether the list is empty.
Definition sllist.hh:750
│ │ │ │ +
SLListConstIterator()
Definition sllist.hh:376
│ │ │ │ +
bool equals(const SLListConstIterator< T, A > &other) const
Equality test for the iterator facade.
Definition sllist.hh:304
│ │ │ │ +
bool equals(const SLListConstIterator< T, A > &other) const
Test whether another iterator is equal.
Definition sllist.hh:456
│ │ │ │ +
SLListModifyIterator< T, A > ModifyIterator
The type of the iterator capable of deletion and insertion.
Definition sllist.hh:103
│ │ │ │ +
const_iterator end() const
Get an iterator pointing to the end of the list.
Definition sllist.hh:794
│ │ │ │ +
SLList()
Constructor.
Definition sllist.hh:568
│ │ │ │ +
void insert(const T &v)
Insert an element at the current position.
Definition sllist.hh:505
│ │ │ │ +
SLListIterator(typename SLList< T, A >::Element *item, SLList< T, A > *sllist)
Definition sllist.hh:277
│ │ │ │ +
SLListModifyIterator(SLListIterator< T, A > beforeIterator, SLListIterator< T, A > _iterator)
Definition sllist.hh:433
│ │ │ │ +
void pop_front()
Remove the first item in the list.
Definition sllist.hh:732
│ │ │ │ +
void increment()
Increment function for the iterator facade.
Definition sllist.hh:332
│ │ │ │ +
SLListIterator(const SLListModifyIterator< T, A > &other)
Definition sllist.hh:286
│ │ │ │ +
A::size_type size_type
The size type.
Definition sllist.hh:54
│ │ │ │ +
void remove()
Delete the entry at the current position.
Definition sllist.hh:518
│ │ │ │ +
const T & dereference() const
Dereferencing function for the facade.
Definition sllist.hh:396
│ │ │ │ +
Element * next_
The next element in the list.
Definition sllist.hh:208
│ │ │ │ +
void increment()
Increment function for the iterator facade.
Definition sllist.hh:486
│ │ │ │ +
void increment()
Increment function for the iterator facade.
Definition sllist.hh:414
│ │ │ │ +
~SLList()
Destructor.
Definition sllist.hh:605
│ │ │ │ +
bool equals(const SLListIterator< T, A > &other) const
Test whether another iterator is equal.
Definition sllist.hh:467
│ │ │ │ +
iterator begin()
Get an iterator pointing to the first element in the list.
Definition sllist.hh:762
│ │ │ │ +
bool equals(const SLListIterator< T, A > &other) const
Equality test for the iterator facade.
Definition sllist.hh:314
│ │ │ │ +
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition bigunsignedint.hh:278
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ +
constexpr std::integer_sequence< T, II..., T(IN)> push_back(std::integer_sequence< T, II... >, std::integral_constant< T, IN >={})
Append an index IN to the back of the sequence.
Definition integersequence.hh:69
│ │ │ │
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition integersequence.hh:75
│ │ │ │ -
Default exception class for I/O errors.
Definition exceptions.hh:231
│ │ │ │ -
Flag for marking indexed data structures where data at each index is of the same size.
Definition communicator.hh:110
│ │ │ │ -
Flag for marking indexed data structures where the data at each index may be a variable multiple of a...
Definition communicator.hh:118
│ │ │ │ -
Default policy used for communicating an indexed type.
Definition communicator.hh:128
│ │ │ │ -
V::value_type IndexedType
The type we get at each index with operator[].
Definition communicator.hh:147
│ │ │ │ -
static int getSize(const V &, int index)
Get the number of primitive elements at that index.
│ │ │ │ -
SizeOne IndexedTypeFlag
Whether the indexed type has variable size or there is always one value at each index.
Definition communicator.hh:153
│ │ │ │ -
static const void * getAddress(const V &v, int index)
Get the address of entry at an index.
│ │ │ │ -
V Type
The type the policy is for.
Definition communicator.hh:140
│ │ │ │ -
Definition communicator.hh:173
│ │ │ │ -
Definition communicator.hh:175
│ │ │ │ - │ │ │ │ - │ │ │ │ -
VariableBlockVector< FieldVector< K, n >, A > Type
Definition communicator.hh:180
│ │ │ │ - │ │ │ │ - │ │ │ │ -
Error thrown if there was a problem with the communication.
Definition communicator.hh:195
│ │ │ │ -
GatherScatter default implementation that just copies data.
Definition communicator.hh:202
│ │ │ │ -
static void scatter(T &vec, const IndexedType &v, std::size_t i)
│ │ │ │ -
CommPolicy< T >::IndexedType IndexedType
Definition communicator.hh:203
│ │ │ │ -
static const IndexedType & gather(const T &vec, std::size_t i)
│ │ │ │ -
A communicator that uses buffers to gather and scatter the data to be send or received.
Definition communicator.hh:458
│ │ │ │ -
void backward(Data &data)
Backward send where target and source are the same.
│ │ │ │ -
BufferedCommunicator()
Constructor.
│ │ │ │ -
~BufferedCommunicator()
Destructor.
│ │ │ │ -
void forward(const Data &source, Data &dest)
Send from source to target.
│ │ │ │ -
void free()
Free the allocated memory (i.e. buffers and message information.
│ │ │ │ -
std::enable_if< std::is_same< SizeOne, typenameCommPolicy< Data >::IndexedTypeFlag >::value, void >::type build(const Interface &interface)
Build the buffers and information for the communication process.
│ │ │ │ -
void backward(Data &source, const Data &dest)
Communicate in the reverse direction, i.e. send from target to source.
│ │ │ │ -
void build(const Data &source, const Data &target, const Interface &interface)
Build the buffers and information for the communication process.
│ │ │ │ -
void forward(Data &data)
Forward send where target and source are the same.
│ │ │ │ -
Manager class for the mapping between local indices and globally unique indices.
Definition indexset.hh:218
│ │ │ │ -
Base class of all classes representing a communication interface.
Definition parallel/interface.hh:44
│ │ │ │ -
Information describing an interface.
Definition parallel/interface.hh:110
│ │ │ │ -
Communication interface between remote and local indices.
Definition parallel/interface.hh:218
│ │ │ │ -
An index present on the local process.
Definition localindex.hh:35
│ │ │ │ -
The indices present on remote processes.
Definition remoteindices.hh:190
│ │ │ │ -
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition remoteindices.hh:216
│ │ │ │ -
LocalIndex::Attribute Attribute
The type of the attribute.
Definition remoteindices.hh:227
│ │ │ │ -
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition remoteindices.hh:222
│ │ │ │ -
Provides classes for building the communication interface between remote indices.
│ │ │ │ +
Base class for stl conformant forward iterators.
Definition iteratorfacades.hh:142
│ │ │ │ +
A mutable iterator for the SLList.
Definition sllist.hh:271
│ │ │ │ +
A constant iterator for the SLList.
Definition sllist.hh:371
│ │ │ │ +
A mutable iterator for the SLList.
Definition sllist.hh:429
│ │ │ │ +
A single linked list.
Definition sllist.hh:44
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,1206 +1,808 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ - * parallel │ │ │ │ │ -communicator.hh │ │ │ │ │ +sllist.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ -5#ifndef DUNE_COMMON_PARALLEL_COMMUNICATOR_HH │ │ │ │ │ -6#define DUNE_COMMON_PARALLEL_COMMUNICATOR_HH │ │ │ │ │ +5#ifndef DUNE_SLLIST_HH │ │ │ │ │ +6#define DUNE_SLLIST_HH │ │ │ │ │ 7 │ │ │ │ │ -8#if HAVE_MPI │ │ │ │ │ -9 │ │ │ │ │ -10#include │ │ │ │ │ -11#include │ │ │ │ │ -12#include │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15#include │ │ │ │ │ -16 │ │ │ │ │ -17#include │ │ │ │ │ -18 │ │ │ │ │ -19#include │ │ │ │ │ -20#include │ │ │ │ │ -21#include │ │ │ │ │ -22#include │ │ │ │ │ -23 │ │ │ │ │ -24namespace Dune │ │ │ │ │ -25{ │ │ │ │ │ -109 struct SizeOne │ │ │ │ │ -110 {}; │ │ │ │ │ -111 │ │ │ │ │ -117 struct VariableSize │ │ │ │ │ -118 {}; │ │ │ │ │ -119 │ │ │ │ │ -120 │ │ │ │ │ -126 template │ │ │ │ │ -127 struct CommPolicy │ │ │ │ │ -128 { │ │ │ │ │ -140 typedef V Type; │ │ │ │ │ -141 │ │ │ │ │ -147 typedef typename V::value_type IndexedType; │ │ │ │ │ +8#include │ │ │ │ │ +9#include │ │ │ │ │ +10#include "iteratorfacades.hh" │ │ │ │ │ +11#include │ │ │ │ │ +12 │ │ │ │ │ +13namespace Dune │ │ │ │ │ +14{ │ │ │ │ │ +26 template │ │ │ │ │ +27 class SLListIterator; │ │ │ │ │ +28 │ │ │ │ │ +29 template │ │ │ │ │ +30 class SLListConstIterator; │ │ │ │ │ +31 │ │ │ │ │ +32 template │ │ │ │ │ +33 class SLListModifyIterator; │ │ │ │ │ +34 │ │ │ │ │ +42 template > │ │ │ │ │ +43 class SLList │ │ │ │ │ +44 { │ │ │ │ │ +45 struct Element; │ │ │ │ │ +46 friend class SLListIterator; │ │ │ │ │ +47 friend class SLListConstIterator; │ │ │ │ │ +48 │ │ │ │ │ +49 public: │ │ │ │ │ +50 │ │ │ │ │ +54 typedef typename A::size_type size_type; │ │ │ │ │ +55 │ │ │ │ │ +59 typedef T MemberType; │ │ │ │ │ +60 │ │ │ │ │ +64 using Allocator = typename std::allocator_traits::template rebind_ │ │ │ │ │ +alloc; │ │ │ │ │ +65 │ │ │ │ │ +69 typedef SLListIterator iterator; │ │ │ │ │ +70 │ │ │ │ │ +74 typedef SLListConstIterator const_iterator; │ │ │ │ │ +75 │ │ │ │ │ +79 SLList(); │ │ │ │ │ +80 │ │ │ │ │ +84 template │ │ │ │ │ +85 SLList(const SLList& other); │ │ │ │ │ +86 │ │ │ │ │ +90 SLList(const SLList& other); │ │ │ │ │ +91 │ │ │ │ │ +97 ~SLList(); │ │ │ │ │ +98 │ │ │ │ │ +103 typedef SLListModifyIterator ModifyIterator; │ │ │ │ │ +104 │ │ │ │ │ +108 SLList& operator=(const SLList& other); │ │ │ │ │ +109 │ │ │ │ │ +110 │ │ │ │ │ +115 inline void push_back(const MemberType& item); │ │ │ │ │ +116 │ │ │ │ │ +121 inline void push_front(const MemberType& item); │ │ │ │ │ +122 │ │ │ │ │ +126 inline void pop_front(); │ │ │ │ │ +127 │ │ │ │ │ +129 inline void clear(); │ │ │ │ │ +130 │ │ │ │ │ +138 inline iterator begin(); │ │ │ │ │ +139 │ │ │ │ │ +147 inline const_iterator begin() const; │ │ │ │ │ 148 │ │ │ │ │ -153 typedef SizeOne IndexedTypeFlag; │ │ │ │ │ -154 │ │ │ │ │ -163 static const void* getAddress(const V& v, int index); │ │ │ │ │ -164 │ │ │ │ │ -170 static int getSize(const V&, int index); │ │ │ │ │ -171 }; │ │ │ │ │ -172 │ │ │ │ │ -173 template class FieldVector; │ │ │ │ │ +156 inline ModifyIterator beginModify(); │ │ │ │ │ +157 │ │ │ │ │ +165 inline ModifyIterator endModify(); │ │ │ │ │ +166 │ │ │ │ │ +173 inline iterator end(); │ │ │ │ │ 174 │ │ │ │ │ -175 template class VariableBlockVector; │ │ │ │ │ -176 │ │ │ │ │ -177 template │ │ │ │ │ -178 struct CommPolicy, A> > │ │ │ │ │ -179 { │ │ │ │ │ -180 typedef VariableBlockVector, A> Type; │ │ │ │ │ -181 │ │ │ │ │ -182 typedef typename Type::B IndexedType; │ │ │ │ │ -183 │ │ │ │ │ -184 typedef VariableSize IndexedTypeFlag; │ │ │ │ │ -185 │ │ │ │ │ -186 static const void* getAddress(const Type& v, int i); │ │ │ │ │ -187 │ │ │ │ │ -188 static int getSize(const Type& v, int i); │ │ │ │ │ -189 }; │ │ │ │ │ -190 │ │ │ │ │ -194 class CommunicationError : public IOError │ │ │ │ │ -195 {}; │ │ │ │ │ -196 │ │ │ │ │ -200 template │ │ │ │ │ -201 struct CopyGatherScatter │ │ │ │ │ -202 { │ │ │ │ │ -203 typedef typename CommPolicy::IndexedType IndexedType; │ │ │ │ │ -204 │ │ │ │ │ -205 static const IndexedType& gather(const T& vec, std::size_t i); │ │ │ │ │ -206 │ │ │ │ │ -207 static void scatter(T& vec, const IndexedType& v, std::size_t i); │ │ │ │ │ -208 │ │ │ │ │ -209 }; │ │ │ │ │ -210 │ │ │ │ │ -222 template │ │ │ │ │ -223 class DatatypeCommunicator : public InterfaceBuilder │ │ │ │ │ -224 { │ │ │ │ │ -225 public: │ │ │ │ │ +181 inline const_iterator end() const; │ │ │ │ │ +182 │ │ │ │ │ +188 inline bool empty() const; │ │ │ │ │ +189 │ │ │ │ │ +194 inline int size() const; │ │ │ │ │ +195 │ │ │ │ │ +196 bool operator==(const SLList& sl) const; │ │ │ │ │ +197 │ │ │ │ │ +198 │ │ │ │ │ +199 bool operator!=(const SLList& sl) const; │ │ │ │ │ +200 │ │ │ │ │ +201 private: │ │ │ │ │ +203 struct Element │ │ │ │ │ +204 { │ │ │ │ │ +208 Element* next_; │ │ │ │ │ +212 MemberType item_; │ │ │ │ │ +213 │ │ │ │ │ +214 Element(const MemberType& item, Element* next_=0); │ │ │ │ │ +215 │ │ │ │ │ +216 Element(); │ │ │ │ │ +217 │ │ │ │ │ +218 ~Element(); │ │ │ │ │ +219 }; │ │ │ │ │ +220 │ │ │ │ │ +225 void deleteNext(Element* current); │ │ │ │ │ 226 │ │ │ │ │ -230 typedef T ParallelIndexSet; │ │ │ │ │ -231 │ │ │ │ │ -235 typedef Dune::RemoteIndices RemoteIndices; │ │ │ │ │ -236 │ │ │ │ │ -240 typedef typename RemoteIndices::GlobalIndex GlobalIndex; │ │ │ │ │ -241 │ │ │ │ │ -245 typedef typename RemoteIndices::Attribute Attribute; │ │ │ │ │ -246 │ │ │ │ │ -250 typedef typename RemoteIndices::LocalIndex LocalIndex; │ │ │ │ │ +231 void copyElements(const SLList& other); │ │ │ │ │ +232 │ │ │ │ │ +240 template │ │ │ │ │ +241 void deleteNext(Element* current); │ │ │ │ │ +247 void insertAfter(Element* current, const T& item); │ │ │ │ │ +248 │ │ │ │ │ +250 Element beforeHead_; │ │ │ │ │ 251 │ │ │ │ │ -255 DatatypeCommunicator(); │ │ │ │ │ -256 │ │ │ │ │ -260 ~DatatypeCommunicator(); │ │ │ │ │ +257 Element* tail_; │ │ │ │ │ +258 │ │ │ │ │ +260 Allocator allocator_; │ │ │ │ │ 261 │ │ │ │ │ -288 template │ │ │ │ │ -289 void build(const RemoteIndices& remoteIndices, const T1& sourceFlags, V& │ │ │ │ │ -sendData, const T2& destFlags, V& receiveData); │ │ │ │ │ -290 │ │ │ │ │ -294 void forward(); │ │ │ │ │ -295 │ │ │ │ │ -299 void backward(); │ │ │ │ │ -300 │ │ │ │ │ -304 void free(); │ │ │ │ │ -305 private: │ │ │ │ │ -309 constexpr static int commTag_ = 234; │ │ │ │ │ -310 │ │ │ │ │ -314 const RemoteIndices* remoteIndices_; │ │ │ │ │ -315 │ │ │ │ │ -316 typedef std::map > │ │ │ │ │ -317 MessageTypeMap; │ │ │ │ │ +263 int size_; │ │ │ │ │ +264 }; │ │ │ │ │ +265 │ │ │ │ │ +269 template │ │ │ │ │ +270 class SLListIterator : public Dune:: │ │ │ │ │ +ForwardIteratorFacade, T, T&, std::size_t> │ │ │ │ │ +271 { │ │ │ │ │ +272 friend class SLListConstIterator; │ │ │ │ │ +273 friend class SLListModifyIterator; │ │ │ │ │ +274 friend class SLList; │ │ │ │ │ +275 │ │ │ │ │ +276 public: │ │ │ │ │ +277 inline SLListIterator(typename SLList::Element* item, │ │ │ │ │ +278 SLList* sllist) │ │ │ │ │ +279 : current_(item), list_(sllist) │ │ │ │ │ +280 {} │ │ │ │ │ +281 │ │ │ │ │ +282 inline SLListIterator() │ │ │ │ │ +283 : current_(0), list_(0) │ │ │ │ │ +284 {} │ │ │ │ │ +285 │ │ │ │ │ +286 inline SLListIterator(const SLListModifyIterator& other) │ │ │ │ │ +287 : current_(other.iterator_.current_), list_(other.iterator_.list_) │ │ │ │ │ +288 {} │ │ │ │ │ +289 │ │ │ │ │ +294 inline T& dereference() const │ │ │ │ │ +295 { │ │ │ │ │ +296 return current_->item_; │ │ │ │ │ +297 } │ │ │ │ │ +298 │ │ │ │ │ +304 inline bool equals(const SLListConstIterator& other) const │ │ │ │ │ +305 { │ │ │ │ │ +306 return current_==other.current_; │ │ │ │ │ +307 } │ │ │ │ │ +308 │ │ │ │ │ +314 inline bool equals(const SLListIterator& other) const │ │ │ │ │ +315 { │ │ │ │ │ +316 return current_==other.current_; │ │ │ │ │ +317 } │ │ │ │ │ 318 │ │ │ │ │ -322 MessageTypeMap messageTypes; │ │ │ │ │ -323 │ │ │ │ │ -327 void* data_; │ │ │ │ │ +324 inline bool equals(const SLListModifyIterator& other) const │ │ │ │ │ +325 { │ │ │ │ │ +326 return current_==other.iterator_.current_; │ │ │ │ │ +327 } │ │ │ │ │ 328 │ │ │ │ │ -329 MPI_Request* requests_[2]; │ │ │ │ │ -330 │ │ │ │ │ -334 bool created_; │ │ │ │ │ -335 │ │ │ │ │ -339 template │ │ │ │ │ -340 void createRequests(V& sendData, V& receiveData); │ │ │ │ │ -341 │ │ │ │ │ -345 template │ │ │ │ │ -346 void createDataTypes(const T1& source, const T2& destination, V& data); │ │ │ │ │ +332 inline void increment() │ │ │ │ │ +333 { │ │ │ │ │ +334 current_ = current_->next_; │ │ │ │ │ +335 } │ │ │ │ │ +336 │ │ │ │ │ +342 inline void insertAfter(const T& v) const │ │ │ │ │ +343 { │ │ │ │ │ +344 assert(list_ ); │ │ │ │ │ +345 list_->insertAfter(current_, v); │ │ │ │ │ +346 } │ │ │ │ │ 347 │ │ │ │ │ -351 void sendRecv(MPI_Request* req); │ │ │ │ │ -352 │ │ │ │ │ -356 struct IndexedTypeInformation │ │ │ │ │ -357 { │ │ │ │ │ -363 void build(int i) │ │ │ │ │ -364 { │ │ │ │ │ -365 length = new int[i]; │ │ │ │ │ -366 displ = new MPI_Aint[i]; │ │ │ │ │ -367 size = i; │ │ │ │ │ -368 } │ │ │ │ │ -369 │ │ │ │ │ -373 void free() │ │ │ │ │ -374 { │ │ │ │ │ -375 delete[] length; │ │ │ │ │ -376 delete[] displ; │ │ │ │ │ -377 } │ │ │ │ │ -379 int* length; │ │ │ │ │ -381 MPI_Aint* displ; │ │ │ │ │ -387 int elements; │ │ │ │ │ -391 int size; │ │ │ │ │ -392 }; │ │ │ │ │ -393 │ │ │ │ │ -399 template │ │ │ │ │ -400 struct MPIDatatypeInformation │ │ │ │ │ -401 { │ │ │ │ │ -406 MPIDatatypeInformation(const V& data) : data_(data) │ │ │ │ │ -407 {} │ │ │ │ │ -408 │ │ │ │ │ -414 void reserve(int proc, int size) │ │ │ │ │ +353 inline void deleteNext() const │ │ │ │ │ +354 { │ │ │ │ │ +355 assert(list_); │ │ │ │ │ +356 list_->deleteNext(current_); │ │ │ │ │ +357 } │ │ │ │ │ +358 │ │ │ │ │ +359 private: │ │ │ │ │ +361 typename SLList::Element* current_; │ │ │ │ │ +363 SLList* list_; │ │ │ │ │ +364 }; │ │ │ │ │ +365 │ │ │ │ │ +369 template │ │ │ │ │ +370 class SLListConstIterator : public Dune:: │ │ │ │ │ +ForwardIteratorFacade, const T, const T&, std::size_t> │ │ │ │ │ +371 { │ │ │ │ │ +372 friend class SLListIterator; │ │ │ │ │ +373 friend class SLList; │ │ │ │ │ +374 │ │ │ │ │ +375 public: │ │ │ │ │ +376 inline SLListConstIterator() │ │ │ │ │ +377 : current_(0) │ │ │ │ │ +378 {} │ │ │ │ │ +379 │ │ │ │ │ +380 inline SLListConstIterator(typename SLList::Element* item) │ │ │ │ │ +381 : current_(item) │ │ │ │ │ +382 {} │ │ │ │ │ +383 │ │ │ │ │ +384 inline SLListConstIterator(const SLListIterator& other) │ │ │ │ │ +385 : current_(other.current_) │ │ │ │ │ +386 {} │ │ │ │ │ +387 │ │ │ │ │ +388 inline SLListConstIterator(const SLListModifyIterator& other) │ │ │ │ │ +389 : current_(other.iterator_.current_) │ │ │ │ │ +390 {} │ │ │ │ │ +391 │ │ │ │ │ +396 inline const T& dereference() const │ │ │ │ │ +397 { │ │ │ │ │ +398 return current_->item_; │ │ │ │ │ +399 } │ │ │ │ │ +400 │ │ │ │ │ +406 inline bool equals(const SLListConstIterator& other) const │ │ │ │ │ +407 { │ │ │ │ │ +408 return current_==other.current_; │ │ │ │ │ +409 } │ │ │ │ │ +410 │ │ │ │ │ +414 inline void increment() │ │ │ │ │ 415 { │ │ │ │ │ -416 information_[proc].build(size); │ │ │ │ │ +416 current_ = current_->next_; │ │ │ │ │ 417 } │ │ │ │ │ -424 void add(int proc, int local) │ │ │ │ │ -425 { │ │ │ │ │ -426 IndexedTypeInformation& info=information_[proc]; │ │ │ │ │ -427 assert((info.elements)(CommPolicy::getAddress(data_, │ │ │ │ │ -local)), │ │ │ │ │ -429 info.displ+info.elements); │ │ │ │ │ -430 info.length[info.elements]=CommPolicy::getSize(data_, local); │ │ │ │ │ -431 info.elements++; │ │ │ │ │ -432 } │ │ │ │ │ -433 │ │ │ │ │ -438 std::map information_; │ │ │ │ │ -442 const V& data_; │ │ │ │ │ -443 │ │ │ │ │ -444 }; │ │ │ │ │ -445 │ │ │ │ │ -446 }; │ │ │ │ │ -447 │ │ │ │ │ -457 class BufferedCommunicator │ │ │ │ │ -458 { │ │ │ │ │ -459 │ │ │ │ │ -460 public: │ │ │ │ │ -464 BufferedCommunicator(); │ │ │ │ │ -465 │ │ │ │ │ -472 template │ │ │ │ │ -473 typename std::enable_if:: │ │ │ │ │ -IndexedTypeFlag>::value, void>::type │ │ │ │ │ -474 build(const Interface& interface); │ │ │ │ │ -475 │ │ │ │ │ -483 template │ │ │ │ │ -484 void build(const Data& source, const Data& target, const Interface& │ │ │ │ │ -interface); │ │ │ │ │ -485 │ │ │ │ │ -514 template │ │ │ │ │ -515 void forward(const Data& source, Data& dest); │ │ │ │ │ -516 │ │ │ │ │ -545 template │ │ │ │ │ -546 void backward(Data& source, const Data& dest); │ │ │ │ │ -547 │ │ │ │ │ -573 template │ │ │ │ │ -574 void forward(Data& data); │ │ │ │ │ +418 │ │ │ │ │ +419 private: │ │ │ │ │ +421 typename SLList::Element* current_; │ │ │ │ │ +422 }; │ │ │ │ │ +423 │ │ │ │ │ +427 template │ │ │ │ │ +428 class SLListModifyIterator : public Dune:: │ │ │ │ │ +ForwardIteratorFacade, T, T&, std::size_t> │ │ │ │ │ +429 { │ │ │ │ │ +430 friend class SLListConstIterator; │ │ │ │ │ +431 friend class SLListIterator; │ │ │ │ │ +432 public: │ │ │ │ │ +433 inline SLListModifyIterator(SLListIterator beforeIterator, │ │ │ │ │ +434 SLListIterator _iterator) │ │ │ │ │ +435 : beforeIterator_(beforeIterator), iterator_(_iterator) │ │ │ │ │ +436 {} │ │ │ │ │ +437 │ │ │ │ │ +438 inline SLListModifyIterator() │ │ │ │ │ +439 : beforeIterator_(), iterator_() │ │ │ │ │ +440 {} │ │ │ │ │ +441 │ │ │ │ │ +446 inline T& dereference() const │ │ │ │ │ +447 { │ │ │ │ │ +448 return *iterator_; │ │ │ │ │ +449 } │ │ │ │ │ +450 │ │ │ │ │ +456 inline bool equals(const SLListConstIterator& other) const │ │ │ │ │ +457 { │ │ │ │ │ +458 return iterator_== other; │ │ │ │ │ +459 } │ │ │ │ │ +460 │ │ │ │ │ +461 │ │ │ │ │ +467 inline bool equals(const SLListIterator& other) const │ │ │ │ │ +468 { │ │ │ │ │ +469 return iterator_== other; │ │ │ │ │ +470 } │ │ │ │ │ +471 │ │ │ │ │ +472 │ │ │ │ │ +478 inline bool equals(const SLListModifyIterator& other) const │ │ │ │ │ +479 { │ │ │ │ │ +480 return iterator_== other.iterator_; │ │ │ │ │ +481 } │ │ │ │ │ +482 │ │ │ │ │ +486 inline void increment() │ │ │ │ │ +487 { │ │ │ │ │ +488 ++iterator_; │ │ │ │ │ +489 ++beforeIterator_; │ │ │ │ │ +490 } │ │ │ │ │ +491 │ │ │ │ │ +505 inline void insert(const T& v) │ │ │ │ │ +506 { │ │ │ │ │ +507 beforeIterator_.insertAfter(v); │ │ │ │ │ +508 ++beforeIterator_; │ │ │ │ │ +509 } │ │ │ │ │ +510 │ │ │ │ │ +518 inline void remove() │ │ │ │ │ +519 { │ │ │ │ │ +520 ++iterator_; │ │ │ │ │ +521 beforeIterator_.deleteNext(); │ │ │ │ │ +522 } │ │ │ │ │ +523 │ │ │ │ │ +524 private: │ │ │ │ │ +526 SLListIterator beforeIterator_; │ │ │ │ │ +528 SLListIterator iterator_; │ │ │ │ │ +529 }; │ │ │ │ │ +530 │ │ │ │ │ +531 template │ │ │ │ │ +532 std::ostream& operator<<(std::ostream& os, const SLList& sllist) │ │ │ │ │ +533 { │ │ │ │ │ +534 typedef typename SLList::const_iterator Iterator; │ │ │ │ │ +535 Iterator end = sllist.end(); │ │ │ │ │ +536 Iterator current= sllist.begin(); │ │ │ │ │ +537 │ │ │ │ │ +538 os << "{ "; │ │ │ │ │ +539 │ │ │ │ │ +540 if(current!=end) { │ │ │ │ │ +541 os<<*current<<" ("<(&(*current))<<")"; │ │ │ │ │ +542 ++current; │ │ │ │ │ +543 │ │ │ │ │ +544 for(; current != end; ++current) │ │ │ │ │ +545 os<<", "<<*current<<" ("<(&(*current))<<")"; │ │ │ │ │ +546 } │ │ │ │ │ +547 os<<"} "; │ │ │ │ │ +548 return os; │ │ │ │ │ +549 } │ │ │ │ │ +550 │ │ │ │ │ +551 template │ │ │ │ │ +552 SLList::Element::Element(const MemberType& item, Element* next) │ │ │ │ │ +553 : next_(next), item_(item) │ │ │ │ │ +554 {} │ │ │ │ │ +555 │ │ │ │ │ +556 template │ │ │ │ │ +557 SLList::Element::Element() │ │ │ │ │ +558 : next_(0), item_() │ │ │ │ │ +559 {} │ │ │ │ │ +560 │ │ │ │ │ +561 template │ │ │ │ │ +562 SLList::Element::~Element() │ │ │ │ │ +563 { │ │ │ │ │ +564 next_=0; │ │ │ │ │ +565 } │ │ │ │ │ +566 │ │ │ │ │ +567 template │ │ │ │ │ +568 SLList::SLList() │ │ │ │ │ +569 : beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0) │ │ │ │ │ +570 { │ │ │ │ │ +571 beforeHead_.next_=0; │ │ │ │ │ +572 assert(&beforeHead_==tail_); │ │ │ │ │ +573 assert(tail_->next_==0); │ │ │ │ │ +574 } │ │ │ │ │ 575 │ │ │ │ │ -601 template │ │ │ │ │ -602 void backward(Data& data); │ │ │ │ │ +576 template │ │ │ │ │ +577 SLList::SLList(const SLList& other) │ │ │ │ │ +578 : beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0) │ │ │ │ │ +579 { │ │ │ │ │ +580 copyElements(other); │ │ │ │ │ +581 } │ │ │ │ │ +582 │ │ │ │ │ +583 template │ │ │ │ │ +584 template │ │ │ │ │ +585 SLList::SLList(const SLList& other) │ │ │ │ │ +586 : beforeHead_(), tail_(&beforeHead_), allocator_(), size_(0) │ │ │ │ │ +587 { │ │ │ │ │ +588 copyElements(other); │ │ │ │ │ +589 } │ │ │ │ │ +590 │ │ │ │ │ +591 template │ │ │ │ │ +592 void SLList::copyElements(const SLList& other) │ │ │ │ │ +593 { │ │ │ │ │ +594 assert(tail_==&beforeHead_); │ │ │ │ │ +595 assert(size_==0); │ │ │ │ │ +596 typedef typename SLList::const_iterator Iterator; │ │ │ │ │ +597 Iterator iend = other.end(); │ │ │ │ │ +598 for(Iterator element=other.begin(); element != iend; ++element) │ │ │ │ │ +599 push_back(*element); │ │ │ │ │ +600 │ │ │ │ │ +601 assert(other.size()==size()); │ │ │ │ │ +602 } │ │ │ │ │ 603 │ │ │ │ │ -607 void free(); │ │ │ │ │ -608 │ │ │ │ │ -612 ~BufferedCommunicator(); │ │ │ │ │ -613 │ │ │ │ │ -614 private: │ │ │ │ │ -615 │ │ │ │ │ -619 typedef std::map > │ │ │ │ │ -620 InterfaceMap; │ │ │ │ │ +604 template │ │ │ │ │ +605 SLList::~SLList() │ │ │ │ │ +606 { │ │ │ │ │ +607 clear(); │ │ │ │ │ +608 } │ │ │ │ │ +609 │ │ │ │ │ +610 template │ │ │ │ │ +611 bool SLList::operator==(const SLList& other) const │ │ │ │ │ +612 { │ │ │ │ │ +613 if(size()!=other.size()) │ │ │ │ │ +614 return false; │ │ │ │ │ +615 for(const_iterator iter=begin(), oiter=other.begin(); │ │ │ │ │ +616 iter != end(); ++iter, ++oiter) │ │ │ │ │ +617 if(*iter!=*oiter) │ │ │ │ │ +618 return false; │ │ │ │ │ +619 return true; │ │ │ │ │ +620 } │ │ │ │ │ 621 │ │ │ │ │ -622 │ │ │ │ │ -626 template │ │ │ │ │ -627 struct MessageSizeCalculator │ │ │ │ │ -628 {}; │ │ │ │ │ -629 │ │ │ │ │ -634 template │ │ │ │ │ -635 struct MessageSizeCalculator │ │ │ │ │ +622 template │ │ │ │ │ +623 bool SLList::operator!=(const SLList& other) const │ │ │ │ │ +624 { │ │ │ │ │ +625 if(size()==other.size()) { │ │ │ │ │ +626 for(const_iterator iter=begin(), oiter=other.begin(); │ │ │ │ │ +627 iter != end(); ++iter, ++oiter) │ │ │ │ │ +628 if(*iter!=*oiter) │ │ │ │ │ +629 return true; │ │ │ │ │ +630 return false; │ │ │ │ │ +631 }else │ │ │ │ │ +632 return true; │ │ │ │ │ +633 } │ │ │ │ │ +634 template │ │ │ │ │ +635 SLList& SLList::operator=(const SLList& other) │ │ │ │ │ 636 { │ │ │ │ │ -643 inline int operator()(const InterfaceInformation& info) const; │ │ │ │ │ -652 inline int operator()(const Data& data, const InterfaceInformation& info) │ │ │ │ │ -const; │ │ │ │ │ -653 }; │ │ │ │ │ +637 clear(); │ │ │ │ │ +638 copyElements(other); │ │ │ │ │ +639 return *this; │ │ │ │ │ +640 } │ │ │ │ │ +641 │ │ │ │ │ +642 template │ │ │ │ │ +643 inline void SLList::push_back(const MemberType& item) │ │ │ │ │ +644 { │ │ │ │ │ +645 assert(size_>0 || tail_==&beforeHead_); │ │ │ │ │ +646 tail_->next_ = allocator_.allocate(1); │ │ │ │ │ +647 assert(size_>0 || tail_==&beforeHead_); │ │ │ │ │ +648 tail_ = tail_->next_; │ │ │ │ │ +649 ::new (static_cast(&(tail_->item_)))T(item); │ │ │ │ │ +650 tail_->next_=0; │ │ │ │ │ +651 assert(tail_->next_==0); │ │ │ │ │ +652 ++size_; │ │ │ │ │ +653 } │ │ │ │ │ 654 │ │ │ │ │ -659 template │ │ │ │ │ -660 struct MessageSizeCalculator │ │ │ │ │ -661 { │ │ │ │ │ -670 inline int operator()(const Data& data, const InterfaceInformation& info) │ │ │ │ │ -const; │ │ │ │ │ -671 }; │ │ │ │ │ -672 │ │ │ │ │ -676 template │ │ │ │ │ -677 struct MessageGatherer │ │ │ │ │ -678 {}; │ │ │ │ │ -679 │ │ │ │ │ -684 template │ │ │ │ │ -685 struct MessageGatherer │ │ │ │ │ -686 { │ │ │ │ │ -688 typedef typename CommPolicy::IndexedType Type; │ │ │ │ │ -689 │ │ │ │ │ -694 typedef GatherScatter Gatherer; │ │ │ │ │ -695 │ │ │ │ │ -701 constexpr static bool forward = send; │ │ │ │ │ -702 │ │ │ │ │ -710 inline void operator()(const InterfaceMap& interface, const Data& data, │ │ │ │ │ -Type* buffer, size_t bufferSize) const; │ │ │ │ │ -711 }; │ │ │ │ │ -712 │ │ │ │ │ -717 template │ │ │ │ │ -718 struct MessageGatherer │ │ │ │ │ -719 { │ │ │ │ │ -721 typedef typename CommPolicy::IndexedType Type; │ │ │ │ │ -722 │ │ │ │ │ -727 typedef GatherScatter Gatherer; │ │ │ │ │ -728 │ │ │ │ │ -734 constexpr static bool forward = send; │ │ │ │ │ -735 │ │ │ │ │ -743 inline void operator()(const InterfaceMap& interface, const Data& data, │ │ │ │ │ -Type* buffer, size_t bufferSize) const; │ │ │ │ │ -744 }; │ │ │ │ │ -745 │ │ │ │ │ -749 template │ │ │ │ │ -750 struct MessageScatterer │ │ │ │ │ -751 {}; │ │ │ │ │ -752 │ │ │ │ │ -757 template │ │ │ │ │ -758 struct MessageScatterer │ │ │ │ │ -759 { │ │ │ │ │ -761 typedef typename CommPolicy::IndexedType Type; │ │ │ │ │ -762 │ │ │ │ │ -767 typedef GatherScatter Scatterer; │ │ │ │ │ -768 │ │ │ │ │ -774 constexpr static bool forward = send; │ │ │ │ │ -775 │ │ │ │ │ -783 inline void operator()(const InterfaceMap& interface, Data& data, Type* │ │ │ │ │ -buffer, const int& proc) const; │ │ │ │ │ -784 }; │ │ │ │ │ -789 template │ │ │ │ │ -790 struct MessageScatterer │ │ │ │ │ -791 { │ │ │ │ │ -793 typedef typename CommPolicy::IndexedType Type; │ │ │ │ │ -794 │ │ │ │ │ -799 typedef GatherScatter Scatterer; │ │ │ │ │ -800 │ │ │ │ │ -806 constexpr static bool forward = send; │ │ │ │ │ -807 │ │ │ │ │ -815 inline void operator()(const InterfaceMap& interface, Data& data, Type* │ │ │ │ │ -buffer, const int& proc) const; │ │ │ │ │ -816 }; │ │ │ │ │ -817 │ │ │ │ │ -821 struct MessageInformation │ │ │ │ │ -822 { │ │ │ │ │ -824 MessageInformation() │ │ │ │ │ -825 : start_(0), size_(0) │ │ │ │ │ -826 {} │ │ │ │ │ -827 │ │ │ │ │ -835 MessageInformation(size_t start, size_t size) │ │ │ │ │ -836 : start_(start), size_(size) │ │ │ │ │ -837 {} │ │ │ │ │ -841 size_t start_; │ │ │ │ │ -845 size_t size_; │ │ │ │ │ -846 }; │ │ │ │ │ -847 │ │ │ │ │ -854 typedef std::map > │ │ │ │ │ -855 InformationMap; │ │ │ │ │ -859 InformationMap messageInformation_; │ │ │ │ │ -863 char* buffers_[2]; │ │ │ │ │ -867 size_t bufferSize_[2]; │ │ │ │ │ -868 │ │ │ │ │ -872 constexpr static int commTag_ = 0; │ │ │ │ │ -873 │ │ │ │ │ -877 std::map > │ │ │ │ │ -interfaces_; │ │ │ │ │ -878 │ │ │ │ │ -879 MPI_Comm communicator_; │ │ │ │ │ -880 │ │ │ │ │ -884 template │ │ │ │ │ -885 void sendRecv(const Data& source, Data& target); │ │ │ │ │ -886 │ │ │ │ │ -887 }; │ │ │ │ │ -888 │ │ │ │ │ -889#ifndef DOXYGEN │ │ │ │ │ -890 │ │ │ │ │ -891 template │ │ │ │ │ -892 inline const void* CommPolicy::getAddress(const V& v, int index) │ │ │ │ │ -893 { │ │ │ │ │ -894 return &(v[index]); │ │ │ │ │ -895 } │ │ │ │ │ -896 │ │ │ │ │ -897 template │ │ │ │ │ -898 inline int CommPolicy::getSize([[maybe_unused]] const V& v, [[maybe_ │ │ │ │ │ -unused]] int index) │ │ │ │ │ -899 { │ │ │ │ │ -900 return 1; │ │ │ │ │ -901 } │ │ │ │ │ -902 │ │ │ │ │ -903 template │ │ │ │ │ -904 inline const void* CommPolicy, A> >:: │ │ │ │ │ -getAddress(const Type& v, int index) │ │ │ │ │ -905 { │ │ │ │ │ -906 return &(v[index][0]); │ │ │ │ │ -907 } │ │ │ │ │ -908 │ │ │ │ │ -909 template │ │ │ │ │ -910 inline int CommPolicy, A> >::getSize │ │ │ │ │ -(const Type& v, int index) │ │ │ │ │ -911 { │ │ │ │ │ -912 return v[index].getsize(); │ │ │ │ │ -913 } │ │ │ │ │ -914 │ │ │ │ │ -915 template │ │ │ │ │ -916 inline const typename CopyGatherScatter::IndexedType& │ │ │ │ │ -CopyGatherScatter::gather(const T & vec, std::size_t i) │ │ │ │ │ -917 { │ │ │ │ │ -918 return vec[i]; │ │ │ │ │ -919 } │ │ │ │ │ -920 │ │ │ │ │ -921 template │ │ │ │ │ -922 inline void CopyGatherScatter::scatter(T& vec, const IndexedType& v, │ │ │ │ │ -std::size_t i) │ │ │ │ │ -923 { │ │ │ │ │ -924 vec[i]=v; │ │ │ │ │ -925 } │ │ │ │ │ -926 │ │ │ │ │ -927 template │ │ │ │ │ -928 DatatypeCommunicator::DatatypeCommunicator() │ │ │ │ │ -929 : remoteIndices_(0), created_(false) │ │ │ │ │ -930 { │ │ │ │ │ -931 requests_[0]=0; │ │ │ │ │ -932 requests_[1]=0; │ │ │ │ │ -933 } │ │ │ │ │ -934 │ │ │ │ │ -935 │ │ │ │ │ -936 │ │ │ │ │ -937 template │ │ │ │ │ -938 DatatypeCommunicator::~DatatypeCommunicator() │ │ │ │ │ -939 { │ │ │ │ │ -940 free(); │ │ │ │ │ -941 } │ │ │ │ │ -942 │ │ │ │ │ -943 template │ │ │ │ │ -944 template │ │ │ │ │ -945 inline void DatatypeCommunicator::build(const RemoteIndices& │ │ │ │ │ -remoteIndices, │ │ │ │ │ -946 const T1& source, V& sendData, │ │ │ │ │ -947 const T2& destination, V& receiveData) │ │ │ │ │ -948 { │ │ │ │ │ -949 remoteIndices_ = &remoteIndices; │ │ │ │ │ -950 free(); │ │ │ │ │ -951 createDataTypes(source,destination, receiveData); │ │ │ │ │ -952 createDataTypes(source,destination, sendData); │ │ │ │ │ -953 createRequests(sendData, receiveData); │ │ │ │ │ -954 createRequests(receiveData, sendData); │ │ │ │ │ -955 created_=true; │ │ │ │ │ -956 } │ │ │ │ │ -957 │ │ │ │ │ -958 template │ │ │ │ │ -959 void DatatypeCommunicator::free() │ │ │ │ │ -960 { │ │ │ │ │ -961 if(created_) { │ │ │ │ │ -962 delete[] requests_[0]; │ │ │ │ │ -963 delete[] requests_[1]; │ │ │ │ │ -964 typedef MessageTypeMap::iterator iterator; │ │ │ │ │ -965 typedef MessageTypeMap::const_iterator const_iterator; │ │ │ │ │ -966 │ │ │ │ │ -967 const const_iterator end=messageTypes.end(); │ │ │ │ │ -968 │ │ │ │ │ -969 for(iterator process = messageTypes.begin(); process != end; ++process) { │ │ │ │ │ -970 MPI_Datatype *type = &(process->second.first); │ │ │ │ │ -971 int finalized=0; │ │ │ │ │ -972 MPI_Finalized(&finalized); │ │ │ │ │ -973 if(*type!=MPI_DATATYPE_NULL && !finalized) │ │ │ │ │ -974 MPI_Type_free(type); │ │ │ │ │ -975 type = &(process->second.second); │ │ │ │ │ -976 if(*type!=MPI_DATATYPE_NULL && !finalized) │ │ │ │ │ -977 MPI_Type_free(type); │ │ │ │ │ -978 } │ │ │ │ │ -979 messageTypes.clear(); │ │ │ │ │ -980 created_=false; │ │ │ │ │ -981 } │ │ │ │ │ -982 │ │ │ │ │ -983 } │ │ │ │ │ -984 │ │ │ │ │ -985 template │ │ │ │ │ -986 template │ │ │ │ │ -987 void DatatypeCommunicator::createDataTypes(const T1& sourceFlags, const │ │ │ │ │ -T2& destFlags, V& data) │ │ │ │ │ -988 { │ │ │ │ │ -989 │ │ │ │ │ -990 MPIDatatypeInformation dataInfo(data); │ │ │ │ │ -991 this->template │ │ │ │ │ -buildInterface,send> │ │ │ │ │ -(*remoteIndices_,sourceFlags, destFlags, dataInfo); │ │ │ │ │ -992 │ │ │ │ │ -993 typedef typename RemoteIndices::RemoteIndexMap::const_iterator const_ │ │ │ │ │ -iterator; │ │ │ │ │ -994 const const_iterator end=this->remoteIndices_->end(); │ │ │ │ │ -995 │ │ │ │ │ -996 // Allocate MPI_Datatypes and deallocate memory for the type construction. │ │ │ │ │ -997 for(const_iterator process=this->remoteIndices_->begin(); process != end; │ │ │ │ │ -++process) { │ │ │ │ │ -998 IndexedTypeInformation& info=dataInfo.information_[process->first]; │ │ │ │ │ -999 // Shift the displacement │ │ │ │ │ -1000 MPI_Aint base; │ │ │ │ │ -1001 MPI_Get_address(const_cast(CommPolicy::getAddress(data, 0)), │ │ │ │ │ -&base); │ │ │ │ │ -1002 │ │ │ │ │ -1003 for(int i=0; i< info.elements; i++) { │ │ │ │ │ -1004 info.displ[i]-=base; │ │ │ │ │ -1005 } │ │ │ │ │ -1006 │ │ │ │ │ -1007 // Create data type │ │ │ │ │ -1008 MPI_Datatype* type = &( send ? messageTypes[process->first].first : │ │ │ │ │ -messageTypes[process->first].second); │ │ │ │ │ -1009 MPI_Type_create_hindexed(info.elements, info.length, info.displ, │ │ │ │ │ -1010 MPITraits::IndexedType>::getType(), type); │ │ │ │ │ -1011 MPI_Type_commit(type); │ │ │ │ │ -1012 // Deallocate memory │ │ │ │ │ -1013 info.free(); │ │ │ │ │ -1014 } │ │ │ │ │ -1015 } │ │ │ │ │ -1016 │ │ │ │ │ -1017 template │ │ │ │ │ -1018 template │ │ │ │ │ -1019 void DatatypeCommunicator::createRequests(V& sendData, V& receiveData) │ │ │ │ │ -1020 { │ │ │ │ │ -1021 typedef std::map >::const_ │ │ │ │ │ -iterator MapIterator; │ │ │ │ │ -1022 int rank; │ │ │ │ │ -1023 static int index = createForward ? 1 : 0; │ │ │ │ │ -1024 int noMessages = messageTypes.size(); │ │ │ │ │ -1025 // allocate request handles │ │ │ │ │ -1026 requests_[index] = new MPI_Request[2*noMessages]; │ │ │ │ │ -1027 const MapIterator end = messageTypes.end(); │ │ │ │ │ -1028 int request=0; │ │ │ │ │ -1029 MPI_Comm_rank(MPI_COMM_WORLD, &rank); │ │ │ │ │ -1030 │ │ │ │ │ -1031 // Set up the requests for receiving first │ │ │ │ │ -1032 for(MapIterator process = messageTypes.begin(); process != end; │ │ │ │ │ -1033 ++process, ++request) { │ │ │ │ │ -1034 MPI_Datatype type = createForward ? process->second.second : process- │ │ │ │ │ ->second.first; │ │ │ │ │ -1035 void* address = const_cast(CommPolicy::getAddress │ │ │ │ │ -(receiveData,0)); │ │ │ │ │ -1036 MPI_Recv_init(address, 1, type, process->first, commTag_, this- │ │ │ │ │ ->remoteIndices_->communicator(), requests_[index]+request); │ │ │ │ │ -1037 } │ │ │ │ │ -1038 │ │ │ │ │ -1039 // And now the send requests │ │ │ │ │ -1040 │ │ │ │ │ -1041 for(MapIterator process = messageTypes.begin(); process != end; │ │ │ │ │ -1042 ++process, ++request) { │ │ │ │ │ -1043 MPI_Datatype type = createForward ? process->second.first : process- │ │ │ │ │ ->second.second; │ │ │ │ │ -1044 void* address = const_cast(CommPolicy::getAddress(sendData, 0)); │ │ │ │ │ -1045 MPI_Ssend_init(address, 1, type, process->first, commTag_, this- │ │ │ │ │ ->remoteIndices_->communicator(), requests_[index]+request); │ │ │ │ │ -1046 } │ │ │ │ │ -1047 } │ │ │ │ │ -1048 │ │ │ │ │ -1049 template │ │ │ │ │ -1050 void DatatypeCommunicator::forward() │ │ │ │ │ -1051 { │ │ │ │ │ -1052 sendRecv(requests_[1]); │ │ │ │ │ -1053 } │ │ │ │ │ -1054 │ │ │ │ │ -1055 template │ │ │ │ │ -1056 void DatatypeCommunicator::backward() │ │ │ │ │ -1057 { │ │ │ │ │ -1058 sendRecv(requests_[0]); │ │ │ │ │ -1059 } │ │ │ │ │ -1060 │ │ │ │ │ -1061 template │ │ │ │ │ -1062 void DatatypeCommunicator::sendRecv(MPI_Request* requests) │ │ │ │ │ -1063 { │ │ │ │ │ -1064 int noMessages = messageTypes.size(); │ │ │ │ │ -1065 // Start the receive calls first │ │ │ │ │ -1066 MPI_Startall(noMessages, requests); │ │ │ │ │ -1067 // Now the send calls │ │ │ │ │ -1068 MPI_Startall(noMessages, requests+noMessages); │ │ │ │ │ -1069 │ │ │ │ │ -1070 // Wait for completion of the communication send first then receive │ │ │ │ │ -1071 MPI_Status* status=new MPI_Status[2*noMessages]; │ │ │ │ │ -1072 for(int i=0; i<2*noMessages; i++) │ │ │ │ │ -1073 status[i].MPI_ERROR=MPI_SUCCESS; │ │ │ │ │ -1074 │ │ │ │ │ -1075 int send = MPI_Waitall(noMessages, requests+noMessages, │ │ │ │ │ -status+noMessages); │ │ │ │ │ -1076 int receive = MPI_Waitall(noMessages, requests, status); │ │ │ │ │ -1077 │ │ │ │ │ -1078 // Error checks │ │ │ │ │ -1079 int success=1, globalSuccess=0; │ │ │ │ │ -1080 if(send==MPI_ERR_IN_STATUS) { │ │ │ │ │ -1081 int rank; │ │ │ │ │ -1082 MPI_Comm_rank(this->remoteIndices_->communicator(), &rank); │ │ │ │ │ -1083 std::cerr<remoteIndices_->communicator(), &rank); │ │ │ │ │ -1101 std::cerr<remoteIndices_->communicator()); │ │ │ │ │ -1117 │ │ │ │ │ -1118 delete[] status; │ │ │ │ │ -1119 │ │ │ │ │ -1120 if(!globalSuccess) │ │ │ │ │ -1121 DUNE_THROW(CommunicationError, "A communication error occurred!"); │ │ │ │ │ -1122 │ │ │ │ │ -1123 } │ │ │ │ │ -1124 │ │ │ │ │ -1125 inline BufferedCommunicator::BufferedCommunicator() │ │ │ │ │ -1126 { │ │ │ │ │ -1127 buffers_[0]=0; │ │ │ │ │ -1128 buffers_[1]=0; │ │ │ │ │ -1129 bufferSize_[0]=0; │ │ │ │ │ -1130 bufferSize_[1]=0; │ │ │ │ │ -1131 } │ │ │ │ │ -1132 │ │ │ │ │ -1133 template │ │ │ │ │ -1134 typename std::enable_if:: │ │ │ │ │ -IndexedTypeFlag>::value, void>::type │ │ │ │ │ -1135 BufferedCommunicator::build(const Interface& interface) │ │ │ │ │ -1136 { │ │ │ │ │ -1137 interfaces_=interface.interfaces(); │ │ │ │ │ -1138 communicator_=interface.communicator(); │ │ │ │ │ -1139 typedef typename std::map > │ │ │ │ │ -1140 ::const_iterator const_iterator; │ │ │ │ │ -1141 typedef typename CommPolicy::IndexedTypeFlag Flag; │ │ │ │ │ -1142 const const_iterator end = interfaces_.end(); │ │ │ │ │ -1143 int lrank; │ │ │ │ │ -1144 MPI_Comm_rank(communicator_, &lrank); │ │ │ │ │ -1145 │ │ │ │ │ -1146 bufferSize_[0]=0; │ │ │ │ │ -1147 bufferSize_[1]=0; │ │ │ │ │ -1148 │ │ │ │ │ -1149 for(const_iterator interfacePair = interfaces_.begin(); │ │ │ │ │ -1150 interfacePair != end; ++interfacePair) { │ │ │ │ │ -1151 int noSend = MessageSizeCalculator() (interfacePair- │ │ │ │ │ ->second.first); │ │ │ │ │ -1152 int noRecv = MessageSizeCalculator() (interfacePair- │ │ │ │ │ ->second.second); │ │ │ │ │ -1153 if (noSend + noRecv > 0) │ │ │ │ │ -1154 messageInformation_.insert(std::make_pair(interfacePair->first, │ │ │ │ │ -1155 std::make_pair(MessageInformation(bufferSize_[0], │ │ │ │ │ -1156 noSend*sizeof(typename CommPolicy::IndexedType)), │ │ │ │ │ -1157 MessageInformation(bufferSize_[1], │ │ │ │ │ -1158 noRecv*sizeof(typename CommPolicy::IndexedType))))); │ │ │ │ │ -1159 bufferSize_[0] += noSend; │ │ │ │ │ -1160 bufferSize_[1] += noRecv; │ │ │ │ │ -1161 } │ │ │ │ │ -1162 │ │ │ │ │ -1163 // allocate the buffers │ │ │ │ │ -1164 bufferSize_[0] *= sizeof(typename CommPolicy::IndexedType); │ │ │ │ │ -1165 bufferSize_[1] *= sizeof(typename CommPolicy::IndexedType); │ │ │ │ │ -1166 │ │ │ │ │ -1167 buffers_[0] = new char[bufferSize_[0]]; │ │ │ │ │ -1168 buffers_[1] = new char[bufferSize_[1]]; │ │ │ │ │ -1169 } │ │ │ │ │ -1170 │ │ │ │ │ -1171 template │ │ │ │ │ -1172 void BufferedCommunicator::build(const Data& source, const Data& dest, │ │ │ │ │ -const Interface& interface) │ │ │ │ │ -1173 { │ │ │ │ │ -1174 │ │ │ │ │ -1175 interfaces_=interface.interfaces(); │ │ │ │ │ -1176 communicator_=interface.communicator(); │ │ │ │ │ -1177 typedef typename std::map > │ │ │ │ │ -1178 ::const_iterator const_iterator; │ │ │ │ │ -1179 typedef typename CommPolicy::IndexedTypeFlag Flag; │ │ │ │ │ -1180 const const_iterator end = interfaces_.end(); │ │ │ │ │ -1181 │ │ │ │ │ -1182 bufferSize_[0]=0; │ │ │ │ │ -1183 bufferSize_[1]=0; │ │ │ │ │ -1184 │ │ │ │ │ -1185 for(const_iterator interfacePair = interfaces_.begin(); │ │ │ │ │ -1186 interfacePair != end; ++interfacePair) { │ │ │ │ │ -1187 int noSend = MessageSizeCalculator() (source, interfacePair- │ │ │ │ │ ->second.first); │ │ │ │ │ -1188 int noRecv = MessageSizeCalculator() (dest, interfacePair- │ │ │ │ │ ->second.second); │ │ │ │ │ -1189 if (noSend + noRecv > 0) │ │ │ │ │ -1190 messageInformation_.insert(std::make_pair(interfacePair->first, │ │ │ │ │ -1191 std::make_pair(MessageInformation(bufferSize_[0], │ │ │ │ │ -1192 noSend*sizeof(typename CommPolicy::IndexedType)), │ │ │ │ │ -1193 MessageInformation(bufferSize_[1], │ │ │ │ │ -1194 noRecv*sizeof(typename CommPolicy::IndexedType))))); │ │ │ │ │ -1195 bufferSize_[0] += noSend; │ │ │ │ │ -1196 bufferSize_[1] += noRecv; │ │ │ │ │ -1197 } │ │ │ │ │ -1198 │ │ │ │ │ -1199 bufferSize_[0] *= sizeof(typename CommPolicy::IndexedType); │ │ │ │ │ -1200 bufferSize_[1] *= sizeof(typename CommPolicy::IndexedType); │ │ │ │ │ -1201 // allocate the buffers │ │ │ │ │ -1202 buffers_[0] = new char[bufferSize_[0]]; │ │ │ │ │ -1203 buffers_[1] = new char[bufferSize_[1]]; │ │ │ │ │ -1204 } │ │ │ │ │ -1205 │ │ │ │ │ -1206 inline void BufferedCommunicator::free() │ │ │ │ │ -1207 { │ │ │ │ │ -1208 messageInformation_.clear(); │ │ │ │ │ -1209 if(buffers_[0]) │ │ │ │ │ -1210 delete[] buffers_[0]; │ │ │ │ │ -1211 │ │ │ │ │ -1212 if(buffers_[1]) │ │ │ │ │ -1213 delete[] buffers_[1]; │ │ │ │ │ -1214 buffers_[0]=buffers_[1]=0; │ │ │ │ │ -1215 } │ │ │ │ │ -1216 │ │ │ │ │ -1217 inline BufferedCommunicator::~BufferedCommunicator() │ │ │ │ │ -1218 { │ │ │ │ │ -1219 free(); │ │ │ │ │ -1220 } │ │ │ │ │ -1221 │ │ │ │ │ -1222 template │ │ │ │ │ -1223 inline int BufferedCommunicator::MessageSizeCalculator:: │ │ │ │ │ -operator() │ │ │ │ │ -1224 (const InterfaceInformation& info) const │ │ │ │ │ -1225 { │ │ │ │ │ -1226 return info.size(); │ │ │ │ │ -1227 } │ │ │ │ │ -1228 │ │ │ │ │ -1229 │ │ │ │ │ -1230 template │ │ │ │ │ -1231 inline int BufferedCommunicator::MessageSizeCalculator:: │ │ │ │ │ -operator() │ │ │ │ │ -1232 (const Data&, const InterfaceInformation& info) const │ │ │ │ │ -1233 { │ │ │ │ │ -1234 return operator()(info); │ │ │ │ │ -1235 } │ │ │ │ │ -1236 │ │ │ │ │ -1237 │ │ │ │ │ -1238 template │ │ │ │ │ -1239 inline int BufferedCommunicator::MessageSizeCalculator::operator() │ │ │ │ │ -1240 (const Data& data, const InterfaceInformation& info) const │ │ │ │ │ -1241 { │ │ │ │ │ -1242 int entries=0; │ │ │ │ │ -1243 │ │ │ │ │ -1244 for(size_t i=0; i < info.size(); i++) │ │ │ │ │ -1245 entries += CommPolicy::getSize(data,info[i]); │ │ │ │ │ -1246 │ │ │ │ │ -1247 return entries; │ │ │ │ │ -1248 } │ │ │ │ │ -1249 │ │ │ │ │ -1250 │ │ │ │ │ -1251 template │ │ │ │ │ -1252 inline void BufferedCommunicator:: │ │ │ │ │ -MessageGatherer::operator()(const │ │ │ │ │ -InterfaceMap& interfaces,const Data& data, Type* buffer, [[maybe_unused]] size_ │ │ │ │ │ -t bufferSize) const │ │ │ │ │ -1253 { │ │ │ │ │ -1254 typedef typename InterfaceMap::const_iterator │ │ │ │ │ -1255 const_iterator; │ │ │ │ │ -1256 │ │ │ │ │ -1257 int rank; │ │ │ │ │ -1258 MPI_Comm_rank(MPI_COMM_WORLD, &rank); │ │ │ │ │ -1259 const const_iterator end = interfaces.end(); │ │ │ │ │ -1260 size_t index=0; │ │ │ │ │ -1261 │ │ │ │ │ -1262 for(const_iterator interfacePair = interfaces.begin(); │ │ │ │ │ -1263 interfacePair != end; ++interfacePair) { │ │ │ │ │ -1264 int size = forward ? interfacePair->second.first.size() : │ │ │ │ │ -1265 interfacePair->second.second.size(); │ │ │ │ │ -1266 │ │ │ │ │ -1267 for(int i=0; i < size; i++) { │ │ │ │ │ -1268 int local = forward ? interfacePair->second.first[i] : │ │ │ │ │ -1269 interfacePair->second.second[i]; │ │ │ │ │ -1270 for(std::size_t j=0; j < CommPolicy::getSize(data, local); j++, │ │ │ │ │ -index++) { │ │ │ │ │ -1271 │ │ │ │ │ -1272#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ -1273 assert(bufferSize>=(index+1)*sizeof(typename CommPolicy:: │ │ │ │ │ -IndexedType)); │ │ │ │ │ -1274#endif │ │ │ │ │ -1275 buffer[index]=GatherScatter::gather(data, local, j); │ │ │ │ │ -1276 } │ │ │ │ │ -1277 │ │ │ │ │ -1278 } │ │ │ │ │ -1279 } │ │ │ │ │ -1280 │ │ │ │ │ -1281 } │ │ │ │ │ -1282 │ │ │ │ │ -1283 │ │ │ │ │ -1284 template │ │ │ │ │ -1285 inline void BufferedCommunicator:: │ │ │ │ │ -MessageGatherer::operator()( │ │ │ │ │ -1286 const InterfaceMap& interfaces, const Data& data, Type* buffer, [[maybe_ │ │ │ │ │ -unused]] size_t bufferSize) const │ │ │ │ │ -1287 { │ │ │ │ │ -1288 typedef typename InterfaceMap::const_iterator │ │ │ │ │ -1289 const_iterator; │ │ │ │ │ -1290 const const_iterator end = interfaces.end(); │ │ │ │ │ -1291 size_t index = 0; │ │ │ │ │ -1292 │ │ │ │ │ -1293 int rank; │ │ │ │ │ -1294 MPI_Comm_rank(MPI_COMM_WORLD, &rank); │ │ │ │ │ -1295 │ │ │ │ │ -1296 for(const_iterator interfacePair = interfaces.begin(); │ │ │ │ │ -1297 interfacePair != end; ++interfacePair) { │ │ │ │ │ -1298 size_t size = FORWARD ? interfacePair->second.first.size() : │ │ │ │ │ -1299 interfacePair->second.second.size(); │ │ │ │ │ -1300 │ │ │ │ │ -1301 for(size_t i=0; i < size; i++) { │ │ │ │ │ -1302 │ │ │ │ │ -1303#ifdef DUNE_ISTL_WITH_CHECKING │ │ │ │ │ -1304 assert(bufferSize>=(index+1)*sizeof(typename CommPolicy:: │ │ │ │ │ -IndexedType)); │ │ │ │ │ -1305#endif │ │ │ │ │ -1306 │ │ │ │ │ -1307 buffer[index++] = GatherScatter::gather(data, FORWARD ? interfacePair- │ │ │ │ │ ->second.first[i] : │ │ │ │ │ -1308 interfacePair->second.second[i]); │ │ │ │ │ -1309 } │ │ │ │ │ -1310 } │ │ │ │ │ -1311 │ │ │ │ │ -1312 } │ │ │ │ │ -1313 │ │ │ │ │ -1314 │ │ │ │ │ -1315 template │ │ │ │ │ -1316 inline void BufferedCommunicator:: │ │ │ │ │ -MessageScatterer::operator()(const │ │ │ │ │ -InterfaceMap& interfaces, Data& data, Type* buffer, const int& proc) const │ │ │ │ │ -1317 { │ │ │ │ │ -1318 typedef typename InterfaceMap::value_type::second_type::first_type │ │ │ │ │ -Information; │ │ │ │ │ -1319 const typename InterfaceMap::const_iterator infoPair = interfaces.find │ │ │ │ │ -(proc); │ │ │ │ │ -1320 │ │ │ │ │ -1321 assert(infoPair!=interfaces.end()); │ │ │ │ │ -1322 │ │ │ │ │ -1323 const Information& info = FORWARD ? infoPair->second.second : │ │ │ │ │ -1324 infoPair->second.first; │ │ │ │ │ -1325 │ │ │ │ │ -1326 for(size_t i=0, index=0; i < info.size(); i++) { │ │ │ │ │ -1327 for(size_t j=0; j < CommPolicy::getSize(data, info[i]); j++) │ │ │ │ │ -1328 GatherScatter::scatter(data, buffer[index++], info[i], j); │ │ │ │ │ -1329 } │ │ │ │ │ -1330 } │ │ │ │ │ -1331 │ │ │ │ │ -1332 │ │ │ │ │ -1333 template │ │ │ │ │ -1334 inline void BufferedCommunicator:: │ │ │ │ │ -MessageScatterer::operator()(const │ │ │ │ │ -InterfaceMap& interfaces, Data& data, Type* buffer, const int& proc) const │ │ │ │ │ -1335 { │ │ │ │ │ -1336 typedef typename InterfaceMap::value_type::second_type::first_type │ │ │ │ │ -Information; │ │ │ │ │ -1337 const typename InterfaceMap::const_iterator infoPair = interfaces.find │ │ │ │ │ -(proc); │ │ │ │ │ -1338 │ │ │ │ │ -1339 assert(infoPair!=interfaces.end()); │ │ │ │ │ -1340 │ │ │ │ │ -1341 const Information& info = FORWARD ? infoPair->second.second : │ │ │ │ │ -1342 infoPair->second.first; │ │ │ │ │ -1343 │ │ │ │ │ -1344 for(size_t i=0; i < info.size(); i++) { │ │ │ │ │ -1345 GatherScatter::scatter(data, buffer[i], info[i]); │ │ │ │ │ -1346 } │ │ │ │ │ -1347 } │ │ │ │ │ -1348 │ │ │ │ │ -1349 │ │ │ │ │ -1350 template │ │ │ │ │ -1351 void BufferedCommunicator::forward(Data& data) │ │ │ │ │ -1352 { │ │ │ │ │ -1353 this->template sendRecv(data, data); │ │ │ │ │ -1354 } │ │ │ │ │ -1355 │ │ │ │ │ -1356 │ │ │ │ │ -1357 template │ │ │ │ │ -1358 void BufferedCommunicator::backward(Data& data) │ │ │ │ │ -1359 { │ │ │ │ │ -1360 this->template sendRecv(data, data); │ │ │ │ │ -1361 } │ │ │ │ │ -1362 │ │ │ │ │ -1363 │ │ │ │ │ -1364 template │ │ │ │ │ -1365 void BufferedCommunicator::forward(const Data& source, Data& dest) │ │ │ │ │ -1366 { │ │ │ │ │ -1367 this->template sendRecv(source, dest); │ │ │ │ │ -1368 } │ │ │ │ │ -1369 │ │ │ │ │ -1370 │ │ │ │ │ -1371 template │ │ │ │ │ -1372 void BufferedCommunicator::backward(Data& source, const Data& dest) │ │ │ │ │ -1373 { │ │ │ │ │ -1374 this->template sendRecv(dest, source); │ │ │ │ │ -1375 } │ │ │ │ │ -1376 │ │ │ │ │ -1377 │ │ │ │ │ -1378 template │ │ │ │ │ -1379 void BufferedCommunicator::sendRecv(const Data& source, Data& dest) │ │ │ │ │ -1380 { │ │ │ │ │ -1381 int rank, lrank; │ │ │ │ │ -1382 │ │ │ │ │ -1383 MPI_Comm_rank(MPI_COMM_WORLD,&rank); │ │ │ │ │ -1384 MPI_Comm_rank(MPI_COMM_WORLD,&lrank); │ │ │ │ │ -1385 │ │ │ │ │ -1386 typedef typename CommPolicy::IndexedType Type; │ │ │ │ │ -1387 Type *sendBuffer, *recvBuffer; │ │ │ │ │ -1388 size_t sendBufferSize; │ │ │ │ │ -1389#ifndef NDEBUG │ │ │ │ │ -1390 size_t recvBufferSize; │ │ │ │ │ -1391#endif │ │ │ │ │ -1392 │ │ │ │ │ -1393 if(FORWARD) { │ │ │ │ │ -1394 sendBuffer = reinterpret_cast(buffers_[0]); │ │ │ │ │ -1395 sendBufferSize = bufferSize_[0]; │ │ │ │ │ -1396 recvBuffer = reinterpret_cast(buffers_[1]); │ │ │ │ │ -1397#ifndef NDEBUG │ │ │ │ │ -1398 recvBufferSize = bufferSize_[1]; │ │ │ │ │ -1399#endif │ │ │ │ │ -1400 }else{ │ │ │ │ │ -1401 sendBuffer = reinterpret_cast(buffers_[1]); │ │ │ │ │ -1402 sendBufferSize = bufferSize_[1]; │ │ │ │ │ -1403 recvBuffer = reinterpret_cast(buffers_[0]); │ │ │ │ │ -1404#ifndef NDEBUG │ │ │ │ │ -1405 recvBufferSize = bufferSize_[0]; │ │ │ │ │ -1406#endif │ │ │ │ │ -1407 } │ │ │ │ │ -1408 typedef typename CommPolicy::IndexedTypeFlag Flag; │ │ │ │ │ -1409 │ │ │ │ │ -1410 MessageGatherer() (interfaces_, source, │ │ │ │ │ -sendBuffer, sendBufferSize); │ │ │ │ │ -1411 │ │ │ │ │ -1412 MPI_Request* sendRequests = new MPI_Request[messageInformation_.size()]; │ │ │ │ │ -1413 MPI_Request* recvRequests = new MPI_Request[messageInformation_.size()]; │ │ │ │ │ -1414 /* Number of recvRequests that are not MPI_REQUEST_NULL */ │ │ │ │ │ -1415 size_t numberOfRealRecvRequests = 0; │ │ │ │ │ -1416 │ │ │ │ │ -1417 // Setup receive first │ │ │ │ │ -1418 typedef typename InformationMap::const_iterator const_iterator; │ │ │ │ │ -1419 │ │ │ │ │ -1420 const const_iterator end = messageInformation_.end(); │ │ │ │ │ -1421 size_t i=0; │ │ │ │ │ -1422 int* processMap = new int[messageInformation_.size()]; │ │ │ │ │ -1423 │ │ │ │ │ -1424 for(const_iterator info = messageInformation_.begin(); info != end; │ │ │ │ │ -++info, ++i) { │ │ │ │ │ -1425 processMap[i]=info->first; │ │ │ │ │ -1426 if(FORWARD) { │ │ │ │ │ -1427 assert(info->second.second.start_*sizeof(typename CommPolicy:: │ │ │ │ │ -IndexedType)+info->second.second.size_ <= recvBufferSize ); │ │ │ │ │ -1428 Dune::dvverb<second.second.size_<<" from │ │ │ │ │ -"<first<second.second.size_) { │ │ │ │ │ -1430 MPI_Irecv(recvBuffer+info->second.second.start_, info- │ │ │ │ │ ->second.second.size_, │ │ │ │ │ -1431 MPI_BYTE, info->first, commTag_, communicator_, │ │ │ │ │ -1432 recvRequests+i); │ │ │ │ │ -1433 numberOfRealRecvRequests += 1; │ │ │ │ │ -1434 } else { │ │ │ │ │ -1435 // Nothing to receive -> set request to inactive │ │ │ │ │ -1436 recvRequests[i]=MPI_REQUEST_NULL; │ │ │ │ │ -1437 } │ │ │ │ │ -1438 }else{ │ │ │ │ │ -1439 assert(info->second.first.start_*sizeof(typename CommPolicy:: │ │ │ │ │ -IndexedType)+info->second.first.size_ <= recvBufferSize ); │ │ │ │ │ -1440 Dune::dvverb<second.first.size_<<" to │ │ │ │ │ -"<first<second.first.size_) { │ │ │ │ │ -1442 MPI_Irecv(recvBuffer+info->second.first.start_, info->second.first.size_, │ │ │ │ │ -1443 MPI_BYTE, info->first, commTag_, communicator_, │ │ │ │ │ -1444 recvRequests+i); │ │ │ │ │ -1445 numberOfRealRecvRequests += 1; │ │ │ │ │ -1446 } else { │ │ │ │ │ -1447 // Nothing to receive -> set request to inactive │ │ │ │ │ -1448 recvRequests[i]=MPI_REQUEST_NULL; │ │ │ │ │ -1449 } │ │ │ │ │ -1450 } │ │ │ │ │ -1451 } │ │ │ │ │ -1452 │ │ │ │ │ -1453 // now the send requests │ │ │ │ │ -1454 i=0; │ │ │ │ │ -1455 for(const_iterator info = messageInformation_.begin(); info != end; │ │ │ │ │ -++info, ++i) │ │ │ │ │ -1456 if(FORWARD) { │ │ │ │ │ -1457 assert(info->second.second.start_*sizeof(typename CommPolicy:: │ │ │ │ │ -IndexedType)+info->second.second.size_ <= recvBufferSize ); │ │ │ │ │ -1458 Dune::dvverb<second.first.size_<<" to "<first<second.first.start_*sizeof(typename CommPolicy:: │ │ │ │ │ -IndexedType)+info->second.first.size_ <= sendBufferSize ); │ │ │ │ │ -1460 if(info->second.first.size_) │ │ │ │ │ -1461 MPI_Issend(sendBuffer+info->second.first.start_, info->second.first.size_, │ │ │ │ │ -1462 MPI_BYTE, info->first, commTag_, communicator_, │ │ │ │ │ -1463 sendRequests+i); │ │ │ │ │ -1464 else │ │ │ │ │ -1465 // Nothing to send -> set request to inactive │ │ │ │ │ -1466 sendRequests[i]=MPI_REQUEST_NULL; │ │ │ │ │ -1467 }else{ │ │ │ │ │ -1468 assert(info->second.second.start_*sizeof(typename CommPolicy:: │ │ │ │ │ -IndexedType)+info->second.second.size_ <= sendBufferSize ); │ │ │ │ │ -1469 Dune::dvverb<second.second.size_<<" to "<first<second.second.size_) │ │ │ │ │ -1471 MPI_Issend(sendBuffer+info->second.second.start_, info- │ │ │ │ │ ->second.second.size_, │ │ │ │ │ -1472 MPI_BYTE, info->first, commTag_, communicator_, │ │ │ │ │ -1473 sendRequests+i); │ │ │ │ │ -1474 else │ │ │ │ │ -1475 // Nothing to send -> set request to inactive │ │ │ │ │ -1476 sendRequests[i]=MPI_REQUEST_NULL; │ │ │ │ │ -1477 } │ │ │ │ │ -1478 │ │ │ │ │ -1479 // Wait for completion of receive and immediately start scatter │ │ │ │ │ -1480 i=0; │ │ │ │ │ -1481 //int success = 1; │ │ │ │ │ -1482 int finished = MPI_UNDEFINED; │ │ │ │ │ -1483 MPI_Status status; //[messageInformation_.size()]; │ │ │ │ │ -1484 //MPI_Waitall(messageInformation_.size(), recvRequests, status); │ │ │ │ │ -1485 │ │ │ │ │ -1486 for(i=0; i< numberOfRealRecvRequests; i++) { │ │ │ │ │ -1487 status.MPI_ERROR=MPI_SUCCESS; │ │ │ │ │ -1488 MPI_Waitany(messageInformation_.size(), recvRequests, &finished, &status); │ │ │ │ │ -1489 assert(finished != MPI_UNDEFINED); │ │ │ │ │ -1490 │ │ │ │ │ -1491 if(status.MPI_ERROR==MPI_SUCCESS) { │ │ │ │ │ -1492 int& proc = processMap[finished]; │ │ │ │ │ -1493 typename InformationMap::const_iterator infoIter = │ │ │ │ │ -messageInformation_.find(proc); │ │ │ │ │ -1494 assert(infoIter != messageInformation_.end()); │ │ │ │ │ -1495 │ │ │ │ │ -1496 MessageInformation info = (FORWARD) ? infoIter->second.second : infoIter- │ │ │ │ │ ->second.first; │ │ │ │ │ -1497 assert(info.start_+info.size_ <= recvBufferSize); │ │ │ │ │ -1498 │ │ │ │ │ -1499 MessageScatterer() (interfaces_, dest, │ │ │ │ │ -recvBuffer+info.start_, proc); │ │ │ │ │ -1500 }else{ │ │ │ │ │ -1501 std::cerr<communicator()); │ │ │ │ │ -1517 │ │ │ │ │ -1518 if(!globalSuccess) │ │ │ │ │ -1519 DUNE_THROW(CommunicationError, "A communication error occurred!"); │ │ │ │ │ -1520 */ │ │ │ │ │ -1521 delete[] processMap; │ │ │ │ │ -1522 delete[] sendRequests; │ │ │ │ │ -1523 delete[] recvRequests; │ │ │ │ │ -1524 │ │ │ │ │ -1525 } │ │ │ │ │ -1526 │ │ │ │ │ -1527#endif // DOXYGEN │ │ │ │ │ -1528 │ │ │ │ │ -1530} │ │ │ │ │ -1531 │ │ │ │ │ -1532#endif // HAVE_MPI │ │ │ │ │ -1533#endif // DUNE_COMMON_PARALLEL_COMMUNICATOR_HH │ │ │ │ │ -remoteindices.hh │ │ │ │ │ -Classes describing a distributed indexset. │ │ │ │ │ -stdstreams.hh │ │ │ │ │ -Standard Dune debug streams. │ │ │ │ │ -exceptions.hh │ │ │ │ │ -A few common exception classes. │ │ │ │ │ -DUNE_THROW │ │ │ │ │ -#define DUNE_THROW(E, m) │ │ │ │ │ -Definition exceptions.hh:218 │ │ │ │ │ -Dune::dvverb │ │ │ │ │ -DVVerbType dvverb(std::cout) │ │ │ │ │ -stream for very verbose output. │ │ │ │ │ -Definition stdstreams.hh:96 │ │ │ │ │ +655 template │ │ │ │ │ +656 inline void SLList::insertAfter(Element* current, const T& item) │ │ │ │ │ +657 { │ │ │ │ │ +658 assert(current); │ │ │ │ │ +659 │ │ │ │ │ +660#ifndef NDEBUG │ │ │ │ │ +661 bool changeTail = (current == tail_); │ │ │ │ │ +662#endif │ │ │ │ │ +663 │ │ │ │ │ +664 // Save old next element │ │ │ │ │ +665 Element* tmp = current->next_; │ │ │ │ │ +666 │ │ │ │ │ +667 assert(!changeTail || !tmp); │ │ │ │ │ +668 │ │ │ │ │ +669 // Allocate space │ │ │ │ │ +670 current->next_ = allocator_.allocate(1); │ │ │ │ │ +671 │ │ │ │ │ +672 // Use copy constructor to initialize memory │ │ │ │ │ +673 std::allocator_traits::construct(allocator_, current->next_, │ │ │ │ │ +Element(item,tmp)); │ │ │ │ │ +674 │ │ │ │ │ +675 //::new(static_cast(&(current->next_->item_))) T(item); │ │ │ │ │ +676 │ │ │ │ │ +677 if(!current->next_->next_) { │ │ │ │ │ +678 // Update tail │ │ │ │ │ +679 assert(changeTail); │ │ │ │ │ +680 tail_ = current->next_; │ │ │ │ │ +681 } │ │ │ │ │ +682 ++size_; │ │ │ │ │ +683 assert(!tail_->next_); │ │ │ │ │ +684 } │ │ │ │ │ +685 │ │ │ │ │ +686 template │ │ │ │ │ +687 inline void SLList::push_front(const MemberType& item) │ │ │ │ │ +688 { │ │ │ │ │ +689 if(tail_ == &beforeHead_) { │ │ │ │ │ +690 // list was empty │ │ │ │ │ +691 beforeHead_.next_ = tail_ = allocator_.allocate(1, 0); │ │ │ │ │ +692 ::new(static_cast(&beforeHead_.next_->item_))T(item); │ │ │ │ │ +693 beforeHead_.next_->next_=0; │ │ │ │ │ +694 }else{ │ │ │ │ │ +695 Element* added = allocator_.allocate(1, 0); │ │ │ │ │ +696 ::new(static_cast(&added->item_))T(item); │ │ │ │ │ +697 added->next_=beforeHead_.next_; │ │ │ │ │ +698 beforeHead_.next_=added; │ │ │ │ │ +699 } │ │ │ │ │ +700 assert(tail_->next_==0); │ │ │ │ │ +701 ++size_; │ │ │ │ │ +702 } │ │ │ │ │ +703 │ │ │ │ │ +704 │ │ │ │ │ +705 template │ │ │ │ │ +706 inline void SLList::deleteNext(Element* current) │ │ │ │ │ +707 { │ │ │ │ │ +708 this->template deleteNext(current); │ │ │ │ │ +709 } │ │ │ │ │ +710 │ │ │ │ │ +711 template │ │ │ │ │ +712 template │ │ │ │ │ +713 inline void SLList::deleteNext(Element* current) │ │ │ │ │ +714 { │ │ │ │ │ +715 assert(current->next_); │ │ │ │ │ +716 Element* next = current->next_; │ │ │ │ │ +717 │ │ │ │ │ +718 if(watchForTail) │ │ │ │ │ +719 if(next == tail_) { │ │ │ │ │ +720 // deleting last element changes tail! │ │ │ │ │ +721 tail_ = current; │ │ │ │ │ +722 } │ │ │ │ │ +723 │ │ │ │ │ +724 current->next_ = next->next_; │ │ │ │ │ +725 std::allocator_traits::destroy(allocator_, next); │ │ │ │ │ +726 allocator_.deallocate(next, 1); │ │ │ │ │ +727 --size_; │ │ │ │ │ +728 assert(!watchForTail || &beforeHead_ != tail_ || size_==0); │ │ │ │ │ +729 } │ │ │ │ │ +730 │ │ │ │ │ +731 template │ │ │ │ │ +732 inline void SLList::pop_front() │ │ │ │ │ +733 { │ │ │ │ │ +734 deleteNext(&beforeHead_); │ │ │ │ │ +735 } │ │ │ │ │ +736 │ │ │ │ │ +737 template │ │ │ │ │ +738 inline void SLList::clear() │ │ │ │ │ +739 { │ │ │ │ │ +740 while(beforeHead_.next_ ) { │ │ │ │ │ +741 this->template deleteNext(&beforeHead_); │ │ │ │ │ +742 } │ │ │ │ │ +743 │ │ │ │ │ +744 assert(size_==0); │ │ │ │ │ +745 // update the tail! │ │ │ │ │ +746 tail_ = &beforeHead_; │ │ │ │ │ +747 } │ │ │ │ │ +748 │ │ │ │ │ +749 template │ │ │ │ │ +750 inline bool SLList::empty() const │ │ │ │ │ +751 { │ │ │ │ │ +752 return (&beforeHead_ == tail_); │ │ │ │ │ +753 } │ │ │ │ │ +754 │ │ │ │ │ +755 template │ │ │ │ │ +756 inline int SLList::size() const │ │ │ │ │ +757 { │ │ │ │ │ +758 return size_; │ │ │ │ │ +759 } │ │ │ │ │ +760 │ │ │ │ │ +761 template │ │ │ │ │ +762 inline SLListIterator SLList::begin() │ │ │ │ │ +763 { │ │ │ │ │ +764 return iterator(beforeHead_.next_, this); │ │ │ │ │ +765 } │ │ │ │ │ +766 │ │ │ │ │ +767 template │ │ │ │ │ +768 inline SLListConstIterator SLList::begin() const │ │ │ │ │ +769 { │ │ │ │ │ +770 return const_iterator(beforeHead_.next_); │ │ │ │ │ +771 } │ │ │ │ │ +772 │ │ │ │ │ +773 template │ │ │ │ │ +774 inline SLListIterator SLList::end() │ │ │ │ │ +775 { │ │ │ │ │ +776 return iterator(); │ │ │ │ │ +777 } │ │ │ │ │ +778 │ │ │ │ │ +779 template │ │ │ │ │ +780 inline SLListModifyIterator SLList::endModify() │ │ │ │ │ +781 { │ │ │ │ │ +782 return SLListModifyIterator(iterator(tail_, this),iterator()); │ │ │ │ │ +783 } │ │ │ │ │ +784 │ │ │ │ │ +785 │ │ │ │ │ +786 template │ │ │ │ │ +787 inline SLListModifyIterator SLList::beginModify() │ │ │ │ │ +788 { │ │ │ │ │ +789 return SLListModifyIterator(iterator(&beforeHead_, this), │ │ │ │ │ +790 iterator(beforeHead_.next_, this)); │ │ │ │ │ +791 } │ │ │ │ │ +792 │ │ │ │ │ +793 template │ │ │ │ │ +794 inline SLListConstIterator SLList::end() const │ │ │ │ │ +795 { │ │ │ │ │ +796 return const_iterator(); │ │ │ │ │ +797 } │ │ │ │ │ +798 │ │ │ │ │ +800} │ │ │ │ │ +801#endif │ │ │ │ │ +iteratorfacades.hh │ │ │ │ │ +This file implements iterator facade classes for writing stl conformant │ │ │ │ │ +iterators. │ │ │ │ │ +Dune::SLList::push_front │ │ │ │ │ +void push_front(const MemberType &item) │ │ │ │ │ +Add a new entry to the beginning of the list. │ │ │ │ │ +Definition sllist.hh:687 │ │ │ │ │ +Dune::SLListConstIterator::equals │ │ │ │ │ +bool equals(const SLListConstIterator< T, A > &other) const │ │ │ │ │ +Equality test for the iterator facade. │ │ │ │ │ +Definition sllist.hh:406 │ │ │ │ │ +Dune::SLList::push_back │ │ │ │ │ +void push_back(const MemberType &item) │ │ │ │ │ +Add a new entry to the end of the list. │ │ │ │ │ +Definition sllist.hh:643 │ │ │ │ │ +Dune::SLList::endModify │ │ │ │ │ +ModifyIterator endModify() │ │ │ │ │ +Get an iterator capable of deleting and inserting elements. │ │ │ │ │ +Definition sllist.hh:780 │ │ │ │ │ +Dune::SLListModifyIterator::SLListModifyIterator │ │ │ │ │ +SLListModifyIterator() │ │ │ │ │ +Definition sllist.hh:438 │ │ │ │ │ +Dune::SLList::Element::Element │ │ │ │ │ +Element() │ │ │ │ │ +Definition sllist.hh:557 │ │ │ │ │ +Dune::SLListIterator::dereference │ │ │ │ │ +T & dereference() const │ │ │ │ │ +Dereferencing function for the iterator facade. │ │ │ │ │ +Definition sllist.hh:294 │ │ │ │ │ +Dune::SLList::operator!= │ │ │ │ │ +bool operator!=(const SLList &sl) const │ │ │ │ │ +Definition sllist.hh:623 │ │ │ │ │ +Dune::SLList::Element::item_ │ │ │ │ │ +MemberType item_ │ │ │ │ │ +The element we hold. │ │ │ │ │ +Definition sllist.hh:212 │ │ │ │ │ +Dune::SLListConstIterator::SLListConstIterator │ │ │ │ │ +SLListConstIterator(typename SLList< T, A >::Element *item) │ │ │ │ │ +Definition sllist.hh:380 │ │ │ │ │ +Dune::SLList::Allocator │ │ │ │ │ +typename std::allocator_traits< A >::template rebind_alloc< Element > Allocator │ │ │ │ │ +The allocator to use. │ │ │ │ │ +Definition sllist.hh:64 │ │ │ │ │ +Dune::SLListIterator::insertAfter │ │ │ │ │ +void insertAfter(const T &v) const │ │ │ │ │ +Insert an element in the underlying list after the current position. │ │ │ │ │ +Definition sllist.hh:342 │ │ │ │ │ +Dune::SLList::iterator │ │ │ │ │ +SLListIterator< T, A > iterator │ │ │ │ │ +The mutable iterator of the list. │ │ │ │ │ +Definition sllist.hh:69 │ │ │ │ │ +Dune::SLListConstIterator::SLListConstIterator │ │ │ │ │ +SLListConstIterator(const SLListModifyIterator< T, A > &other) │ │ │ │ │ +Definition sllist.hh:388 │ │ │ │ │ +Dune::SLListIterator::SLListIterator │ │ │ │ │ +SLListIterator() │ │ │ │ │ +Definition sllist.hh:282 │ │ │ │ │ +Dune::SLList::Element::~Element │ │ │ │ │ +~Element() │ │ │ │ │ +Definition sllist.hh:562 │ │ │ │ │ +Dune::SLList::operator== │ │ │ │ │ +bool operator==(const SLList &sl) const │ │ │ │ │ +Definition sllist.hh:611 │ │ │ │ │ +Dune::SLListIterator::deleteNext │ │ │ │ │ +void deleteNext() const │ │ │ │ │ +Delete the entry after the current position. │ │ │ │ │ +Definition sllist.hh:353 │ │ │ │ │ +Dune::SLList::SLList │ │ │ │ │ +SLList(const SLList< T, A > &other) │ │ │ │ │ +Copy constructor. │ │ │ │ │ +Definition sllist.hh:577 │ │ │ │ │ +Dune::SLListIterator::equals │ │ │ │ │ +bool equals(const SLListModifyIterator< T, A > &other) const │ │ │ │ │ +Equality test for the iterator facade. │ │ │ │ │ +Definition sllist.hh:324 │ │ │ │ │ +Dune::SLListModifyIterator::dereference │ │ │ │ │ +T & dereference() const │ │ │ │ │ +Dereferencing function for the iterator facade. │ │ │ │ │ +Definition sllist.hh:446 │ │ │ │ │ +Dune::SLList::size │ │ │ │ │ +int size() const │ │ │ │ │ +Get the number of elements the list contains. │ │ │ │ │ +Definition sllist.hh:756 │ │ │ │ │ +Dune::SLList::begin │ │ │ │ │ +const_iterator begin() const │ │ │ │ │ +Get an iterator pointing to the first element in the list. │ │ │ │ │ +Definition sllist.hh:768 │ │ │ │ │ +Dune::SLList::end │ │ │ │ │ +iterator end() │ │ │ │ │ +Get an iterator pointing to the end of the list. │ │ │ │ │ +Definition sllist.hh:774 │ │ │ │ │ +Dune::SLList::clear │ │ │ │ │ +void clear() │ │ │ │ │ +Remove all elements from the list. │ │ │ │ │ +Definition sllist.hh:738 │ │ │ │ │ +Dune::SLList::SLList │ │ │ │ │ +SLList(const SLList< T1, A1 > &other) │ │ │ │ │ +Copy constructor with type conversion. │ │ │ │ │ +Definition sllist.hh:585 │ │ │ │ │ +Dune::SLList::MemberType │ │ │ │ │ +T MemberType │ │ │ │ │ +The type we store. │ │ │ │ │ +Definition sllist.hh:59 │ │ │ │ │ +Dune::SLListModifyIterator::equals │ │ │ │ │ +bool equals(const SLListModifyIterator< T, A > &other) const │ │ │ │ │ +Test whether another iterator is equal. │ │ │ │ │ +Definition sllist.hh:478 │ │ │ │ │ +Dune::SLList::beginModify │ │ │ │ │ +ModifyIterator beginModify() │ │ │ │ │ +Get an iterator capable of deleting and inserting elements. │ │ │ │ │ +Definition sllist.hh:787 │ │ │ │ │ +Dune::SLList::operator= │ │ │ │ │ +SLList< T, A > & operator=(const SLList< T, A > &other) │ │ │ │ │ +Assignment operator. │ │ │ │ │ +Definition sllist.hh:635 │ │ │ │ │ +Dune::SLListConstIterator::SLListConstIterator │ │ │ │ │ +SLListConstIterator(const SLListIterator< T, A > &other) │ │ │ │ │ +Definition sllist.hh:384 │ │ │ │ │ +Dune::SLList::const_iterator │ │ │ │ │ +SLListConstIterator< T, A > const_iterator │ │ │ │ │ +The constant iterator of the list. │ │ │ │ │ +Definition sllist.hh:74 │ │ │ │ │ +Dune::SLList::empty │ │ │ │ │ +bool empty() const │ │ │ │ │ +Check whether the list is empty. │ │ │ │ │ +Definition sllist.hh:750 │ │ │ │ │ +Dune::SLListConstIterator::SLListConstIterator │ │ │ │ │ +SLListConstIterator() │ │ │ │ │ +Definition sllist.hh:376 │ │ │ │ │ +Dune::SLListIterator::equals │ │ │ │ │ +bool equals(const SLListConstIterator< T, A > &other) const │ │ │ │ │ +Equality test for the iterator facade. │ │ │ │ │ +Definition sllist.hh:304 │ │ │ │ │ +Dune::SLListModifyIterator::equals │ │ │ │ │ +bool equals(const SLListConstIterator< T, A > &other) const │ │ │ │ │ +Test whether another iterator is equal. │ │ │ │ │ +Definition sllist.hh:456 │ │ │ │ │ +Dune::SLList::ModifyIterator │ │ │ │ │ +SLListModifyIterator< T, A > ModifyIterator │ │ │ │ │ +The type of the iterator capable of deletion and insertion. │ │ │ │ │ +Definition sllist.hh:103 │ │ │ │ │ +Dune::SLList::end │ │ │ │ │ +const_iterator end() const │ │ │ │ │ +Get an iterator pointing to the end of the list. │ │ │ │ │ +Definition sllist.hh:794 │ │ │ │ │ +Dune::SLList::SLList │ │ │ │ │ +SLList() │ │ │ │ │ +Constructor. │ │ │ │ │ +Definition sllist.hh:568 │ │ │ │ │ +Dune::SLListModifyIterator::insert │ │ │ │ │ +void insert(const T &v) │ │ │ │ │ +Insert an element at the current position. │ │ │ │ │ +Definition sllist.hh:505 │ │ │ │ │ +Dune::SLListIterator::SLListIterator │ │ │ │ │ +SLListIterator(typename SLList< T, A >::Element *item, SLList< T, A > *sllist) │ │ │ │ │ +Definition sllist.hh:277 │ │ │ │ │ +Dune::SLListModifyIterator::SLListModifyIterator │ │ │ │ │ +SLListModifyIterator(SLListIterator< T, A > beforeIterator, SLListIterator< T, │ │ │ │ │ +A > _iterator) │ │ │ │ │ +Definition sllist.hh:433 │ │ │ │ │ +Dune::SLList::pop_front │ │ │ │ │ +void pop_front() │ │ │ │ │ +Remove the first item in the list. │ │ │ │ │ +Definition sllist.hh:732 │ │ │ │ │ +Dune::SLListIterator::increment │ │ │ │ │ +void increment() │ │ │ │ │ +Increment function for the iterator facade. │ │ │ │ │ +Definition sllist.hh:332 │ │ │ │ │ +Dune::SLListIterator::SLListIterator │ │ │ │ │ +SLListIterator(const SLListModifyIterator< T, A > &other) │ │ │ │ │ +Definition sllist.hh:286 │ │ │ │ │ +Dune::SLList::size_type │ │ │ │ │ +A::size_type size_type │ │ │ │ │ +The size type. │ │ │ │ │ +Definition sllist.hh:54 │ │ │ │ │ +Dune::SLListModifyIterator::remove │ │ │ │ │ +void remove() │ │ │ │ │ +Delete the entry at the current position. │ │ │ │ │ +Definition sllist.hh:518 │ │ │ │ │ +Dune::SLListConstIterator::dereference │ │ │ │ │ +const T & dereference() const │ │ │ │ │ +Dereferencing function for the facade. │ │ │ │ │ +Definition sllist.hh:396 │ │ │ │ │ +Dune::SLList::Element::next_ │ │ │ │ │ +Element * next_ │ │ │ │ │ +The next element in the list. │ │ │ │ │ +Definition sllist.hh:208 │ │ │ │ │ +Dune::SLListModifyIterator::increment │ │ │ │ │ +void increment() │ │ │ │ │ +Increment function for the iterator facade. │ │ │ │ │ +Definition sllist.hh:486 │ │ │ │ │ +Dune::SLListConstIterator::increment │ │ │ │ │ +void increment() │ │ │ │ │ +Increment function for the iterator facade. │ │ │ │ │ +Definition sllist.hh:414 │ │ │ │ │ +Dune::SLList::~SLList │ │ │ │ │ +~SLList() │ │ │ │ │ +Destructor. │ │ │ │ │ +Definition sllist.hh:605 │ │ │ │ │ +Dune::SLListModifyIterator::equals │ │ │ │ │ +bool equals(const SLListIterator< T, A > &other) const │ │ │ │ │ +Test whether another iterator is equal. │ │ │ │ │ +Definition sllist.hh:467 │ │ │ │ │ +Dune::SLList::begin │ │ │ │ │ +iterator begin() │ │ │ │ │ +Get an iterator pointing to the first element in the list. │ │ │ │ │ +Definition sllist.hh:762 │ │ │ │ │ +Dune::SLListIterator::equals │ │ │ │ │ +bool equals(const SLListIterator< T, A > &other) const │ │ │ │ │ +Equality test for the iterator facade. │ │ │ │ │ +Definition sllist.hh:314 │ │ │ │ │ +Dune::operator<< │ │ │ │ │ +std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x) │ │ │ │ │ +Definition bigunsignedint.hh:278 │ │ │ │ │ Dune │ │ │ │ │ Dune namespace. │ │ │ │ │ Definition alignedallocator.hh:13 │ │ │ │ │ +Dune::push_back │ │ │ │ │ +constexpr std::integer_sequence< T, II..., T(IN)> push_back(std::integer_ │ │ │ │ │ +sequence< T, II... >, std::integral_constant< T, IN >={}) │ │ │ │ │ +Append an index IN to the back of the sequence. │ │ │ │ │ +Definition integersequence.hh:69 │ │ │ │ │ Dune::size │ │ │ │ │ constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std:: │ │ │ │ │ integer_sequence< T, II... >) │ │ │ │ │ Return the size of the sequence. │ │ │ │ │ Definition integersequence.hh:75 │ │ │ │ │ -Dune::IOError │ │ │ │ │ -Default exception class for I/O errors. │ │ │ │ │ -Definition exceptions.hh:231 │ │ │ │ │ -Dune::SizeOne │ │ │ │ │ -Flag for marking indexed data structures where data at each index is of the │ │ │ │ │ -same size. │ │ │ │ │ -Definition communicator.hh:110 │ │ │ │ │ -Dune::VariableSize │ │ │ │ │ -Flag for marking indexed data structures where the data at each index may be a │ │ │ │ │ -variable multiple of a... │ │ │ │ │ -Definition communicator.hh:118 │ │ │ │ │ -Dune::CommPolicy │ │ │ │ │ -Default policy used for communicating an indexed type. │ │ │ │ │ -Definition communicator.hh:128 │ │ │ │ │ -Dune::CommPolicy::IndexedType │ │ │ │ │ -V::value_type IndexedType │ │ │ │ │ -The type we get at each index with operator[]. │ │ │ │ │ -Definition communicator.hh:147 │ │ │ │ │ -Dune::CommPolicy::getSize │ │ │ │ │ -static int getSize(const V &, int index) │ │ │ │ │ -Get the number of primitive elements at that index. │ │ │ │ │ -Dune::CommPolicy::IndexedTypeFlag │ │ │ │ │ -SizeOne IndexedTypeFlag │ │ │ │ │ -Whether the indexed type has variable size or there is always one value at each │ │ │ │ │ -index. │ │ │ │ │ -Definition communicator.hh:153 │ │ │ │ │ -Dune::CommPolicy::getAddress │ │ │ │ │ -static const void * getAddress(const V &v, int index) │ │ │ │ │ -Get the address of entry at an index. │ │ │ │ │ -Dune::CommPolicy::Type │ │ │ │ │ -V Type │ │ │ │ │ -The type the policy is for. │ │ │ │ │ -Definition communicator.hh:140 │ │ │ │ │ -Dune::CommPolicy::FieldVector │ │ │ │ │ -Definition communicator.hh:173 │ │ │ │ │ -Dune::CommPolicy::VariableBlockVector │ │ │ │ │ -Definition communicator.hh:175 │ │ │ │ │ -Dune::CommPolicy::CommPolicy<_VariableBlockVector<_FieldVector<_K,_n_>,_A_>_>:: │ │ │ │ │ -getSize │ │ │ │ │ -static int getSize(const Type &v, int i) │ │ │ │ │ -Dune::CommPolicy::CommPolicy<_VariableBlockVector<_FieldVector<_K,_n_>,_A_>_>:: │ │ │ │ │ -IndexedTypeFlag │ │ │ │ │ -VariableSize IndexedTypeFlag │ │ │ │ │ -Definition communicator.hh:184 │ │ │ │ │ -Dune::CommPolicy::CommPolicy<_VariableBlockVector<_FieldVector<_K,_n_>,_A_>_>:: │ │ │ │ │ -Type │ │ │ │ │ -VariableBlockVector< FieldVector< K, n >, A > Type │ │ │ │ │ -Definition communicator.hh:180 │ │ │ │ │ -Dune::CommPolicy::CommPolicy<_VariableBlockVector<_FieldVector<_K,_n_>,_A_>_>:: │ │ │ │ │ -getAddress │ │ │ │ │ -static const void * getAddress(const Type &v, int i) │ │ │ │ │ -Dune::CommPolicy::CommPolicy<_VariableBlockVector<_FieldVector<_K,_n_>,_A_>_>:: │ │ │ │ │ -IndexedType │ │ │ │ │ -Type::B IndexedType │ │ │ │ │ -Definition communicator.hh:182 │ │ │ │ │ -Dune::CommPolicy::CommunicationError │ │ │ │ │ -Error thrown if there was a problem with the communication. │ │ │ │ │ -Definition communicator.hh:195 │ │ │ │ │ -Dune::CommPolicy::CopyGatherScatter │ │ │ │ │ -GatherScatter default implementation that just copies data. │ │ │ │ │ -Definition communicator.hh:202 │ │ │ │ │ -Dune::CommPolicy::CopyGatherScatter::scatter │ │ │ │ │ -static void scatter(T &vec, const IndexedType &v, std::size_t i) │ │ │ │ │ -Dune::CommPolicy::CopyGatherScatter::IndexedType │ │ │ │ │ -CommPolicy< T >::IndexedType IndexedType │ │ │ │ │ -Definition communicator.hh:203 │ │ │ │ │ -Dune::CommPolicy::CopyGatherScatter::gather │ │ │ │ │ -static const IndexedType & gather(const T &vec, std::size_t i) │ │ │ │ │ -Dune::BufferedCommunicator │ │ │ │ │ -A communicator that uses buffers to gather and scatter the data to be send or │ │ │ │ │ -received. │ │ │ │ │ -Definition communicator.hh:458 │ │ │ │ │ -Dune::BufferedCommunicator::backward │ │ │ │ │ -void backward(Data &data) │ │ │ │ │ -Backward send where target and source are the same. │ │ │ │ │ -Dune::BufferedCommunicator::BufferedCommunicator │ │ │ │ │ -BufferedCommunicator() │ │ │ │ │ -Constructor. │ │ │ │ │ -Dune::BufferedCommunicator::~BufferedCommunicator │ │ │ │ │ -~BufferedCommunicator() │ │ │ │ │ -Destructor. │ │ │ │ │ -Dune::BufferedCommunicator::forward │ │ │ │ │ -void forward(const Data &source, Data &dest) │ │ │ │ │ -Send from source to target. │ │ │ │ │ -Dune::BufferedCommunicator::free │ │ │ │ │ -void free() │ │ │ │ │ -Free the allocated memory (i.e. buffers and message information. │ │ │ │ │ -Dune::BufferedCommunicator::build │ │ │ │ │ -std::enable_if< std::is_same< SizeOne, typenameCommPolicy< Data >:: │ │ │ │ │ -IndexedTypeFlag >::value, void >::type build(const Interface &interface) │ │ │ │ │ -Build the buffers and information for the communication process. │ │ │ │ │ -Dune::BufferedCommunicator::backward │ │ │ │ │ -void backward(Data &source, const Data &dest) │ │ │ │ │ -Communicate in the reverse direction, i.e. send from target to source. │ │ │ │ │ -Dune::BufferedCommunicator::build │ │ │ │ │ -void build(const Data &source, const Data &target, const Interface &interface) │ │ │ │ │ -Build the buffers and information for the communication process. │ │ │ │ │ -Dune::BufferedCommunicator::forward │ │ │ │ │ -void forward(Data &data) │ │ │ │ │ -Forward send where target and source are the same. │ │ │ │ │ -Dune::ParallelIndexSet │ │ │ │ │ -Manager class for the mapping between local indices and globally unique │ │ │ │ │ -indices. │ │ │ │ │ -Definition indexset.hh:218 │ │ │ │ │ -Dune::InterfaceBuilder │ │ │ │ │ -Base class of all classes representing a communication interface. │ │ │ │ │ -Definition parallel/interface.hh:44 │ │ │ │ │ -Dune::InterfaceInformation │ │ │ │ │ -Information describing an interface. │ │ │ │ │ -Definition parallel/interface.hh:110 │ │ │ │ │ -Dune::Interface │ │ │ │ │ -Communication interface between remote and local indices. │ │ │ │ │ -Definition parallel/interface.hh:218 │ │ │ │ │ -Dune::LocalIndex │ │ │ │ │ -An index present on the local process. │ │ │ │ │ -Definition localindex.hh:35 │ │ │ │ │ -Dune::RemoteIndices │ │ │ │ │ -The indices present on remote processes. │ │ │ │ │ -Definition remoteindices.hh:190 │ │ │ │ │ -Dune::RemoteIndices::GlobalIndex │ │ │ │ │ -ParallelIndexSet::GlobalIndex GlobalIndex │ │ │ │ │ -The type of the global index. │ │ │ │ │ -Definition remoteindices.hh:216 │ │ │ │ │ -Dune::RemoteIndices::Attribute │ │ │ │ │ -LocalIndex::Attribute Attribute │ │ │ │ │ -The type of the attribute. │ │ │ │ │ -Definition remoteindices.hh:227 │ │ │ │ │ -Dune::RemoteIndices::LocalIndex │ │ │ │ │ -ParallelIndexSet::LocalIndex LocalIndex │ │ │ │ │ -The type of the local index. │ │ │ │ │ -Definition remoteindices.hh:222 │ │ │ │ │ -interface.hh │ │ │ │ │ -Provides classes for building the communication interface between remote │ │ │ │ │ -indices. │ │ │ │ │ +Dune::ForwardIteratorFacade │ │ │ │ │ +Base class for stl conformant forward iterators. │ │ │ │ │ +Definition iteratorfacades.hh:142 │ │ │ │ │ +Dune::SLListIterator │ │ │ │ │ +A mutable iterator for the SLList. │ │ │ │ │ +Definition sllist.hh:271 │ │ │ │ │ +Dune::SLListConstIterator │ │ │ │ │ +A constant iterator for the SLList. │ │ │ │ │ +Definition sllist.hh:371 │ │ │ │ │ +Dune::SLListModifyIterator │ │ │ │ │ +A mutable iterator for the SLList. │ │ │ │ │ +Definition sllist.hh:429 │ │ │ │ │ +Dune::SLList │ │ │ │ │ +A single linked list. │ │ │ │ │ +Definition sllist.hh:44 │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00104.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: debugstream.hh File Reference │ │ │ │ +dune-common: tupleutility.hh File Reference │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -72,62 +72,116 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ Classes | │ │ │ │ Namespaces | │ │ │ │ -Typedefs
│ │ │ │ -
debugstream.hh File Reference
│ │ │ │ +Functions
│ │ │ │ +
tupleutility.hh File Reference
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ -

Defines several output streams for messages of different importance. │ │ │ │ +

Contains utility classes which can be used with std::tuple. │ │ │ │ More...

│ │ │ │ -
#include <iostream>
│ │ │ │ -#include <stack>
│ │ │ │ -#include <dune/common/exceptions.hh>
│ │ │ │ +
#include <cstddef>
│ │ │ │ +#include <tuple>
│ │ │ │ +#include <type_traits>
│ │ │ │ +#include <utility>
│ │ │ │ +#include <dune/common/hybridutilities.hh>
│ │ │ │ +#include <dune/common/typetraits.hh>
│ │ │ │
│ │ │ │

Go to the source code of this file.

│ │ │ │ │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ │ │ │ │

│ │ │ │ Classes

struct  Dune::greater_or_equal< current, threshold >
 Greater or equal template test. More...
struct  Dune::TupleAccessTraits< T >
 
struct  Dune::common_bits< current, mask >
 activate if current and mask have common bits switched on. More...
struct  Dune::TupleAccessTraits< T * >
 
class  Dune::DebugStreamError
 standard exception for the debugstream More...
struct  Dune::TupleAccessTraits< T & >
 
class  Dune::StreamWrap
struct  Dune::NullPointerInitialiser< std::tuple< Args... > >
 
class  Dune::DebugStreamState
 Intermediate class to implement tie-operation of DebugStream. More...
struct  Dune::ForEachType< TE, std::tuple< Args... > >
 
class  Dune::DebugStream< thislevel, dlevel, alevel, activator >
 Generic class to implement debug output streams. More...
class  Dune::TransformTupleFunctor< TE, Args >
 
struct  Dune::TransformTupleFunctor< TE, Args >::TypeEvaluator< T >
 
struct  Dune::AddRefTypeEvaluator< T >
 TypeEvaluator to turn a type T into a reference to T More...
 
struct  Dune::AddPtrTypeEvaluator< T >
 TypeEvaluator to turn a type T into a pointer to T More...
 
struct  Dune::AddPtrTypeEvaluator< T & >
 
struct  Dune::AtType< N, Tuple >
 Type for reverse element access. More...
 
struct  Dune::At< N >
 Reverse element access. More...
 
struct  Dune::PointerPairDeletor< Tuple >
 Deletes all objects pointed to in a std::tuple of pointers. More...
 
class  Dune::FirstPredicateIndex< Tuple, Predicate, start, size >
 Finding the index of a certain type in a std::tuple. More...
 
struct  Dune::IsType< T >
 Generator for predicates accepting one particular type. More...
 
struct  Dune::IsType< T >::Predicate< U >
 The actual predicate. More...
 
struct  Dune::FirstTypeIndex< Tuple, T, start >
 Find the first occurrence of a type in a std::tuple. More...
 
struct  Dune::PushBackTuple< typename std::tuple< Args... >, T >
 
struct  Dune::PushFrontTuple< typename std::tuple< Args... >, T >
 
struct  Dune::ReduceTuple< F, Tuple, Seed, N >
 Apply reduce with meta binary function to template. More...
 
struct  Dune::ReduceTuple< F, Tuple, Seed, 0 >
 Apply reduce with meta binary function to template. More...
 
struct  Dune::JoinTuples< Head, Tail >
 Join two std::tuple's. More...
 
struct  Dune::FlattenTuple< Tuple >
 Flatten a std::tuple of std::tuple's. More...
 
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │

│ │ │ │ Namespaces

namespace  Dune
 Dune namespace.
 
│ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ - │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │ + │ │ │ │

│ │ │ │ -Typedefs

typedef unsigned int Dune::DebugLevel
 Type for debug levels.
 

│ │ │ │ +Functions

template<class F , class ArgTuple , class I , I... i>
decltype(auto) Dune::applyPartial (F &&f, ArgTuple &&args, std::integer_sequence< I, i... >)
 Apply function with arguments from a given tuple.
 
template<class Tuple , class Functor >
auto Dune::genericTransformTuple (Tuple &&t, Functor &&f) -> decltype(genericTransformTupleBackend(t, f))
 
template<template< class > class TE, class... Args>
TransformTupleFunctor< TE, Args... > Dune::makeTransformTupleFunctor (Args &&... args)
 
template<template< class > class TypeEvaluator, class Tuple , class... Args>
auto Dune::transformTuple (Tuple &&orig, Args &&... args) -> decltype(genericTransformTuple(orig, makeTransformTupleFunctor< TypeEvaluator >(args...)))
 
│ │ │ │

Detailed Description

│ │ │ │ -

Defines several output streams for messages of different importance.

│ │ │ │ -

This file implements the class DebugStream to support output in a variety of debug levels. Additionally, template parameters control if the output operation is really performed so that unused debug levels can be deactivated

│ │ │ │ +

Contains utility classes which can be used with std::tuple.

│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,47 +1,108 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -Classes | Namespaces | Typedefs │ │ │ │ │ -debugstream.hh File Reference │ │ │ │ │ -Common » Debug_output │ │ │ │ │ -Defines several output streams for messages of different importance. More... │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ -#include │ │ │ │ │ +Classes | Namespaces | Functions │ │ │ │ │ +tupleutility.hh File Reference │ │ │ │ │ +Common » Utilities » Tuple_Utilities │ │ │ │ │ +Contains utility classes which can be used with std::tuple. More... │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ +#include │ │ │ │ │ Go_to_the_source_code_of_this_file. │ │ │ │ │ Classes │ │ │ │ │ -struct   Dune::greater_or_equal<_current,_threshold_> │ │ │ │ │ -  Greater or equal template test. More... │ │ │ │ │ +struct   Dune::TupleAccessTraits<_T_> │ │ │ │ │   │ │ │ │ │ -struct   Dune::common_bits<_current,_mask_> │ │ │ │ │ -  activate if current and mask have common bits switched on. More... │ │ │ │ │ +struct   Dune::TupleAccessTraits<_T_*_> │ │ │ │ │   │ │ │ │ │ - class   Dune::DebugStreamError │ │ │ │ │ -  standard exception for the debugstream More... │ │ │ │ │ +struct   Dune::TupleAccessTraits<_T_&_> │ │ │ │ │   │ │ │ │ │ - class   Dune::StreamWrap │ │ │ │ │ +struct   Dune::NullPointerInitialiser<_std::tuple<_Args..._>_> │ │ │ │ │   │ │ │ │ │ - class   Dune::DebugStreamState │ │ │ │ │ -  Intermediate class to implement tie-operation of DebugStream. More... │ │ │ │ │ +struct   Dune::ForEachType<_TE,_std::tuple<_Args..._>_> │ │ │ │ │   │ │ │ │ │ - class   Dune::DebugStream<_thislevel,_dlevel,_alevel,_activator_> │ │ │ │ │ -  Generic class to implement debug output streams. More... │ │ │ │ │ + class   Dune::TransformTupleFunctor<_TE,_Args_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::TransformTupleFunctor<_TE,_Args_>::TypeEvaluator<_T_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::AddRefTypeEvaluator<_T_> │ │ │ │ │ +  TypeEvaluator to turn a type T into a reference to T More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::AddPtrTypeEvaluator<_T_> │ │ │ │ │ +  TypeEvaluator to turn a type T into a pointer to T More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::AddPtrTypeEvaluator<_T_&_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::AtType<_N,_Tuple_> │ │ │ │ │ +  Type for reverse element access. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::At<_N_> │ │ │ │ │ +  Reverse element access. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::PointerPairDeletor<_Tuple_> │ │ │ │ │ +  Deletes all objects pointed to in a std::tuple of pointers. More... │ │ │ │ │ +  │ │ │ │ │ + class   Dune::FirstPredicateIndex<_Tuple,_Predicate,_start,_size_> │ │ │ │ │ +  Finding the index of a certain type in a std::tuple. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::IsType<_T_> │ │ │ │ │ +  Generator for predicates accepting one particular type. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::IsType<_T_>::Predicate<_U_> │ │ │ │ │ +  The actual predicate. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::FirstTypeIndex<_Tuple,_T,_start_> │ │ │ │ │ +  Find the first occurrence of a type in a std::tuple. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::PushBackTuple<_typename_std::tuple<_Args..._>,_T_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::PushFrontTuple<_typename_std::tuple<_Args..._>,_T_> │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::ReduceTuple<_F,_Tuple,_Seed,_N_> │ │ │ │ │ +  Apply reduce with meta binary function to template. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::ReduceTuple<_F,_Tuple,_Seed,_0_> │ │ │ │ │ +  Apply reduce with meta binary function to template. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::JoinTuples<_Head,_Tail_> │ │ │ │ │ +  Join two std::tuple's. More... │ │ │ │ │ +  │ │ │ │ │ +struct   Dune::FlattenTuple<_Tuple_> │ │ │ │ │ +  Flatten a std::tuple of std::tuple's. More... │ │ │ │ │   │ │ │ │ │ Namespaces │ │ │ │ │ namespace   Dune │ │ │ │ │   Dune namespace. │ │ │ │ │   │ │ │ │ │ -Typedefs │ │ │ │ │ -typedef unsigned int  Dune::DebugLevel │ │ │ │ │ -  Type for debug levels. │ │ │ │ │ +Functions │ │ │ │ │ +template │ │ │ │ │ + decltype(auto)  Dune::applyPartial (F &&f, ArgTuple &&args, │ │ │ │ │ + std::integer_sequence< I, i... >) │ │ │ │ │ +  Apply function with arguments from a given │ │ │ │ │ + tuple. │ │ │ │ │ +  │ │ │ │ │ +template │ │ │ │ │ + auto  Dune::genericTransformTuple (Tuple &&t, │ │ │ │ │ + Functor &&f) -> decltype │ │ │ │ │ + (genericTransformTupleBackend(t, f)) │ │ │ │ │ +  │ │ │ │ │ +template class TE, class... Args> │ │ │ │ │ + TransformTupleFunctor< TE, Args... Dune::makeTransformTupleFunctor (Args &&... │ │ │ │ │ + >  args) │ │ │ │ │ +  │ │ │ │ │ +template class TypeEvaluator, class Tuple , class... Args> │ │ │ │ │ + auto  Dune::transformTuple (Tuple &&orig, Args │ │ │ │ │ + &&... args) -> decltype │ │ │ │ │ + (genericTransformTuple(orig, │ │ │ │ │ + makeTransformTupleFunctor< TypeEvaluator > │ │ │ │ │ + (args...))) │ │ │ │ │   │ │ │ │ │ ***** Detailed Description ***** │ │ │ │ │ -Defines several output streams for messages of different importance. │ │ │ │ │ -This file implements the class DebugStream to support output in a variety of │ │ │ │ │ -debug levels. Additionally, template parameters control if the output operation │ │ │ │ │ -is really performed so that unused debug levels can be deactivated │ │ │ │ │ +Contains utility classes which can be used with std::tuple. │ │ │ │ │ =============================================================================== │ │ │ │ │ Generated by [doxygen] 1.9.8 │ │ │ ├── ./usr/share/doc/libdune-common-doc/doxygen/a00104_source.html │ │ │ │ @@ -1,15 +1,15 @@ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ -dune-common: debugstream.hh Source File │ │ │ │ +dune-common: tupleutility.hh Source File │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ @@ -74,333 +74,448 @@ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │
│ │ │ │ -
debugstream.hh
│ │ │ │ +
tupleutility.hh
│ │ │ │
│ │ │ │
│ │ │ │ Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
│ │ │ │
2// vi: set et ts=4 sw=2 sts=2:
│ │ │ │
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
│ │ │ │
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
│ │ │ │
5
│ │ │ │ -
6#ifndef DUNE_DEBUGSTREAM_HH
│ │ │ │ -
7#define DUNE_DEBUGSTREAM_HH
│ │ │ │ +
6#ifndef DUNE_TUPLE_UTILITY_HH
│ │ │ │ +
7#define DUNE_TUPLE_UTILITY_HH
│ │ │ │
8
│ │ │ │ -
13#include <iostream>
│ │ │ │ -
14#include <stack>
│ │ │ │ -
15
│ │ │ │ - │ │ │ │ -
17
│ │ │ │ -
18namespace Dune {
│ │ │ │ -
19
│ │ │ │ -
118 typedef unsigned int DebugLevel;
│ │ │ │ -
119
│ │ │ │ -
129 template <DebugLevel current, DebugLevel threshold>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
131 constexpr static bool value = (current >= threshold);
│ │ │ │ -
132 };
│ │ │ │ -
│ │ │ │ -
133
│ │ │ │ -
134
│ │ │ │ -
141 template <DebugLevel current, DebugLevel mask>
│ │ │ │ -
│ │ │ │ -
142 struct common_bits {
│ │ │ │ -
143 constexpr static bool value = ((current & mask) != 0);
│ │ │ │ -
144 };
│ │ │ │ -
│ │ │ │ -
145
│ │ │ │ +
9#include <cstddef>
│ │ │ │ +
10#include <tuple>
│ │ │ │ +
11#include <type_traits>
│ │ │ │ +
12#include <utility>
│ │ │ │ +
13
│ │ │ │ + │ │ │ │ + │ │ │ │ +
16
│ │ │ │ +
17namespace Dune {
│ │ │ │ +
18
│ │ │ │ +
41 template<class F, class ArgTuple, class I, I... i>
│ │ │ │ +
│ │ │ │ +
42 decltype(auto) applyPartial(F&& f, ArgTuple&& args, std::integer_sequence<I, i...> /*indices*/)
│ │ │ │ +
43 {
│ │ │ │ +
44 return f(std::get<i>(args)...);
│ │ │ │ +
45 }
│ │ │ │ +
│ │ │ │ +
46
│ │ │ │ +
47 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
49 {
│ │ │ │ +
50 typedef typename std::add_const<T>::type& ConstType;
│ │ │ │ +
51 typedef T& NonConstType;
│ │ │ │ +
52 typedef const typename std::remove_const<T>::type& ParameterType;
│ │ │ │ +
53 };
│ │ │ │ +
│ │ │ │ +
54
│ │ │ │ +
55 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
57 {
│ │ │ │ +
58 typedef typename std::add_const<T>::type* ConstType;
│ │ │ │ +
59 typedef T* NonConstType;
│ │ │ │ +
60 typedef T* ParameterType;
│ │ │ │ +
61 };
│ │ │ │ +
│ │ │ │ +
62
│ │ │ │ +
63 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
65 {
│ │ │ │ +
66 typedef T& ConstType;
│ │ │ │ +
67 typedef T& NonConstType;
│ │ │ │ +
68 typedef T& ParameterType;
│ │ │ │ +
69 };
│ │ │ │ +
│ │ │ │ +
70
│ │ │ │ +
78 template<class T>
│ │ │ │ + │ │ │ │ +
80
│ │ │ │ +
81 template<class... Args>
│ │ │ │ +
│ │ │ │ +
82 struct NullPointerInitialiser<std::tuple<Args...> >
│ │ │ │ +
83 {
│ │ │ │ +
84 typedef std::tuple<Args...> ResultType;
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
86 {
│ │ │ │ +
87 return ResultType(static_cast<Args>(nullptr)...);
│ │ │ │ +
88 }
│ │ │ │ +
│ │ │ │ +
89 };
│ │ │ │ +
│ │ │ │ +
90
│ │ │ │ +
115 template<template <class> class TE, class T>
│ │ │ │ + │ │ │ │ +
117
│ │ │ │ +
118 template<template <class> class TE, class... Args>
│ │ │ │ +
│ │ │ │ +
119 struct ForEachType<TE, std::tuple<Args...> >
│ │ │ │ +
120 {
│ │ │ │ +
121 typedef std::tuple<typename TE<Args>::Type...> Type;
│ │ │ │ +
122 };
│ │ │ │ +
│ │ │ │ +
123
│ │ │ │ +
124#ifndef DOXYGEN
│ │ │ │ +
125 template<class Tuple, class Functor, std::size_t... I>
│ │ │ │ +
126 inline auto genericTransformTupleBackendImpl(Tuple& t, Functor& f, const std::index_sequence<I...>& )
│ │ │ │ +
127 -> std::tuple<decltype(f(std::get<I>(t)))...>
│ │ │ │ +
128 {
│ │ │ │ +
129 return std::tuple<decltype(f(std::get<I>(t)))...>(f(std::get<I>(t))...);
│ │ │ │ +
130 }
│ │ │ │ +
131
│ │ │ │ +
132 template<class... Args, class Functor>
│ │ │ │ +
133 auto genericTransformTupleBackend(std::tuple<Args...>& t, Functor& f) ->
│ │ │ │ +
134 decltype(genericTransformTupleBackendImpl(t, f,std::index_sequence_for<Args...>{}))
│ │ │ │ +
135 {
│ │ │ │ +
136 return genericTransformTupleBackendImpl(t, f,std::index_sequence_for<Args...>{});
│ │ │ │ +
137 }
│ │ │ │ +
138
│ │ │ │ +
139 template<class... Args, class Functor>
│ │ │ │ +
140 auto genericTransformTupleBackend(const std::tuple<Args...>& t, Functor& f) ->
│ │ │ │ +
141 decltype(genericTransformTupleBackendImpl(t, f, std::index_sequence_for<Args...>{}))
│ │ │ │ +
142 {
│ │ │ │ +
143 return genericTransformTupleBackendImpl(t, f, std::index_sequence_for<Args...>{});
│ │ │ │ +
144 }
│ │ │ │ +
145#endif
│ │ │ │
146
│ │ │ │ -
148 class DebugStreamError : public IOError {};
│ │ │ │ -
149
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
151 public:
│ │ │ │ -
152 StreamWrap(std::ostream& _out) : out(_out) { }
│ │ │ │ -
153 std::ostream& out;
│ │ │ │ - │ │ │ │ -
155 };
│ │ │ │ -
│ │ │ │ -
156
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
159 // !!! should be protected somehow but that won't be easy
│ │ │ │ -
160 public:
│ │ │ │ - │ │ │ │ -
163
│ │ │ │ - │ │ │ │ -
166
│ │ │ │ -
168 bool _tied;
│ │ │ │ -
169
│ │ │ │ -
171 unsigned int _tied_streams;
│ │ │ │ -
172 };
│ │ │ │ -
│ │ │ │ -
173
│ │ │ │ -
188 template <DebugLevel thislevel = 1,
│ │ │ │ -
189 DebugLevel dlevel = 1,
│ │ │ │ -
190 DebugLevel alevel = 1,
│ │ │ │ -
191 template<DebugLevel, DebugLevel> class activator = greater_or_equal>
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
193 public:
│ │ │ │ -
│ │ │ │ -
199 DebugStream(std::ostream& out = std::cerr) {
│ │ │ │ -
200 // start a new list of streams
│ │ │ │ -
201 current = new StreamWrap(out);
│ │ │ │ -
202 current->next = 0;
│ │ │ │ -
203
│ │ │ │ -
204 // check if we are above the default activation level
│ │ │ │ -
205 _active = activator<thislevel,alevel>::value;
│ │ │ │ -
206
│ │ │ │ -
207 // we're not tied to another DebugStream
│ │ │ │ -
208 _tied = false;
│ │ │ │ -
209
│ │ │ │ -
210 // no child streams yet
│ │ │ │ -
211 _tied_streams = 0;
│ │ │ │ -
212 }
│ │ │ │ -
│ │ │ │ -
213
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
220 std::ostream& fallback = std::cerr)
│ │ │ │ -
221 {
│ │ │ │ -
222 // start a new list of streams
│ │ │ │ -
223 current = new StreamWrap(fallback);
│ │ │ │ -
224 current->next = 0;
│ │ │ │ -
225
│ │ │ │ -
226 // check if we are above the default activation level
│ │ │ │ -
227 _active = activator<thislevel,alevel>::value;
│ │ │ │ -
228 _tied_streams = 0;
│ │ │ │ -
229
│ │ │ │ -
230 // tie to the provided stream
│ │ │ │ -
231 _tied = true;
│ │ │ │ -
232 tiedstate = &master;
│ │ │ │ -
233 tiedstate->_tied_streams++;
│ │ │ │ +
185 template<class Tuple, class Functor>
│ │ │ │ +
│ │ │ │ +
186 auto genericTransformTuple(Tuple&& t, Functor&& f) ->
│ │ │ │ +
187 decltype(genericTransformTupleBackend(t, f))
│ │ │ │ +
188 {
│ │ │ │ +
189 return genericTransformTupleBackend(t, f);
│ │ │ │ +
190 }
│ │ │ │ +
│ │ │ │ +
191
│ │ │ │ +
224 template<template<class> class TE, class... Args>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
226 {
│ │ │ │ +
227 mutable std::tuple<Args&...> tup;
│ │ │ │ +
228
│ │ │ │ +
229 template<class T, std::size_t... I>
│ │ │ │ +
230 inline auto apply(T&& t, const std::index_sequence<I...>& ) ->
│ │ │ │ +
231 decltype(TE<T>::apply(t,std::get<I>(tup)...)) const
│ │ │ │ +
232 {
│ │ │ │ +
233 return TE<T>::apply(t,std::get<I>(tup)...);
│ │ │ │
234 }
│ │ │ │ -
│ │ │ │
235
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
244 {
│ │ │ │ -
245 // untie
│ │ │ │ -
246 if (_tied)
│ │ │ │ -
247 tiedstate->_tied_streams--;
│ │ │ │ -
248 else {
│ │ │ │ -
249 // check if somebody still ties to us...
│ │ │ │ -
250 if (_tied_streams != 0)
│ │ │ │ -
251 {
│ │ │ │ -
252 std::cerr << "DebugStream destructor is called while other streams are still tied to it. Terminating!" << std::endl;
│ │ │ │ -
253 std::terminate();
│ │ │ │ -
254 }
│ │ │ │ -
255 }
│ │ │ │ -
256
│ │ │ │ -
257 // remove ostream-stack
│ │ │ │ -
258 while (current != 0) {
│ │ │ │ -
259 StreamWrap *s = current;
│ │ │ │ - │ │ │ │ -
261 delete s;
│ │ │ │ -
262 }
│ │ │ │ -
263 }
│ │ │ │ -
│ │ │ │ -
264
│ │ │ │ -
266 template <class T>
│ │ │ │ -
│ │ │ │ -
267 DebugStream& operator<<(const T data) {
│ │ │ │ -
268 // remove the following code if stream wasn't compiled active
│ │ │ │ -
269 if (activator<thislevel, dlevel>::value) {
│ │ │ │ -
270 if (! _tied) {
│ │ │ │ -
271 if (_active)
│ │ │ │ -
272 current->out << data;
│ │ │ │ -
273 } else {
│ │ │ │ -
274 if (_active && tiedstate->_active)
│ │ │ │ -
275 tiedstate->current->out << data;
│ │ │ │ -
276 }
│ │ │ │ -
277 }
│ │ │ │ -
278
│ │ │ │ -
279 return *this;
│ │ │ │ -
280 }
│ │ │ │ -
│ │ │ │ -
281
│ │ │ │ -
│ │ │ │ -
289 DebugStream& operator<<(const int data) {
│ │ │ │ -
290 // remove the following code if stream wasn't compiled active
│ │ │ │ -
291 if (activator<thislevel, dlevel>::value) {
│ │ │ │ -
292 if (! _tied) {
│ │ │ │ -
293 if (_active)
│ │ │ │ -
294 current->out << data;
│ │ │ │ -
295 } else {
│ │ │ │ -
296 if (_active && tiedstate->_active)
│ │ │ │ -
297 tiedstate->current->out << data;
│ │ │ │ -
298 }
│ │ │ │ -
299 }
│ │ │ │ -
300
│ │ │ │ -
301 return *this;
│ │ │ │ -
302 }
│ │ │ │ -
│ │ │ │ -
303
│ │ │ │ -
│ │ │ │ -
305 DebugStream& operator<<(std::ostream& (*f)(std::ostream&)) {
│ │ │ │ -
306 if (activator<thislevel, dlevel>::value) {
│ │ │ │ -
307 if (! _tied) {
│ │ │ │ -
308 if (_active)
│ │ │ │ -
309 f(current->out);
│ │ │ │ -
310 } else {
│ │ │ │ -
311 if (_active && tiedstate->_active)
│ │ │ │ -
312 f(tiedstate->current->out);
│ │ │ │ -
313 }
│ │ │ │ -
314 }
│ │ │ │ -
315
│ │ │ │ -
316 return *this;
│ │ │ │ -
317 }
│ │ │ │ -
│ │ │ │ -
318
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
321 if (activator<thislevel, dlevel>::value) {
│ │ │ │ -
322 if (! _tied) {
│ │ │ │ -
323 if (_active)
│ │ │ │ -
324 current->out.flush();
│ │ │ │ -
325 } else {
│ │ │ │ -
326 if (_active && tiedstate->_active)
│ │ │ │ -
327 tiedstate->current->out.flush();
│ │ │ │ -
328 }
│ │ │ │ -
329 }
│ │ │ │ -
330
│ │ │ │ -
331 return *this;
│ │ │ │ -
332 }
│ │ │ │ -
│ │ │ │ -
333
│ │ │ │ -
│ │ │ │ -
335 void push(bool b) {
│ │ │ │ -
336 // are we at all active?
│ │ │ │ -
337 if (activator<thislevel,alevel>::value) {
│ │ │ │ -
338 _actstack.push(_active);
│ │ │ │ -
339 _active = b;
│ │ │ │ -
340 } else {
│ │ │ │ -
341 // stay off
│ │ │ │ -
342 _actstack.push(false);
│ │ │ │ -
343 }
│ │ │ │ -
344 }
│ │ │ │ -
│ │ │ │ -
345
│ │ │ │ -
│ │ │ │ -
349 void pop() {
│ │ │ │ -
350 if (_actstack.empty())
│ │ │ │ -
351 DUNE_THROW(DebugStreamError, "No previous activation setting!");
│ │ │ │ -
352
│ │ │ │ -
353 _active = _actstack.top();
│ │ │ │ -
354 _actstack.pop();
│ │ │ │ -
355 }
│ │ │ │ -
│ │ │ │ -
356
│ │ │ │ -
│ │ │ │ -
363 bool active() const {
│ │ │ │ -
364 return activator<thislevel, dlevel>::value && _active;
│ │ │ │ +
236 public:
│ │ │ │ +
237 template<class T>
│ │ │ │ +
│ │ │ │ +
238 struct TypeEvaluator : public TE<T>
│ │ │ │ +
239 {};
│ │ │ │ +
│ │ │ │ +
240
│ │ │ │ +
│ │ │ │ +
241 TransformTupleFunctor(Args&&... args)
│ │ │ │ +
242 : tup(args...)
│ │ │ │ +
243 { }
│ │ │ │ +
│ │ │ │ +
244
│ │ │ │ +
245 template<class T>
│ │ │ │ +
│ │ │ │ +
246 inline auto operator()(T&& t) ->
│ │ │ │ +
247 decltype(this->apply(t,std::index_sequence_for<Args...>{})) const
│ │ │ │ +
248 {
│ │ │ │ +
249 return apply(t,std::index_sequence_for<Args...>{});
│ │ │ │ +
250 }
│ │ │ │ +
│ │ │ │ +
251 };
│ │ │ │ +
│ │ │ │ +
252
│ │ │ │ +
253 template<template<class> class TE, class... Args>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
255 {
│ │ │ │ +
256 return TransformTupleFunctor<TE, Args...>(args...);
│ │ │ │ +
257 }
│ │ │ │ +
│ │ │ │ +
258
│ │ │ │ +
291 template<template<class> class TypeEvaluator, class Tuple, class... Args>
│ │ │ │ +
│ │ │ │ +
292 auto transformTuple(Tuple&& orig, Args&&... args) ->
│ │ │ │ +
293 decltype(genericTransformTuple(orig, makeTransformTupleFunctor<TypeEvaluator>(args...)))
│ │ │ │ +
294 {
│ │ │ │ +
295 return genericTransformTuple(orig, makeTransformTupleFunctor<TypeEvaluator>(args...));
│ │ │ │ +
296 }
│ │ │ │ +
│ │ │ │ +
297
│ │ │ │ +
299
│ │ │ │ +
303 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
305 {
│ │ │ │ +
306 typedef T& Type;
│ │ │ │ +
│ │ │ │ +
307 static Type apply(T& t)
│ │ │ │ +
308 {
│ │ │ │ +
309 return t;
│ │ │ │ +
310 }
│ │ │ │ +
│ │ │ │ +
311 };
│ │ │ │ +
│ │ │ │ +
312
│ │ │ │ +
314
│ │ │ │ +
318 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
320 {
│ │ │ │ +
321 typedef typename std::remove_reference<T>::type* Type;
│ │ │ │ +
│ │ │ │ +
322 static Type apply(T& t)
│ │ │ │ +
323 {
│ │ │ │ +
324 return &t;
│ │ │ │ +
325 }
│ │ │ │ +
│ │ │ │ +
326 };
│ │ │ │ +
│ │ │ │ +
327
│ │ │ │ +
328 // Specialization, in case the type is already a reference
│ │ │ │ +
329 template<class T>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
331 {
│ │ │ │ +
332 typedef typename std::remove_reference<T>::type* Type;
│ │ │ │ +
│ │ │ │ +
333 static Type apply(T& t)
│ │ │ │ +
334 {
│ │ │ │ +
335 return &t;
│ │ │ │ +
336 }
│ │ │ │ +
│ │ │ │ +
337 };
│ │ │ │ +
│ │ │ │ +
338
│ │ │ │ +
344 template<int N, class Tuple>
│ │ │ │ +
│ │ │ │ +
345 struct AtType
│ │ │ │ +
346 {
│ │ │ │ +
347 typedef typename std::tuple_element<std::tuple_size<Tuple>::value - N - 1, Tuple>::type Type;
│ │ │ │ +
348 };
│ │ │ │ +
│ │ │ │ +
349
│ │ │ │ +
357 template<int N>
│ │ │ │ +
│ │ │ │ +
358 struct At
│ │ │ │ +
359 {
│ │ │ │ +
360 template<typename Tuple>
│ │ │ │ +
361 static typename TupleAccessTraits<typename AtType<N, Tuple>::Type>::NonConstType
│ │ │ │ +
│ │ │ │ +
362 get(Tuple& t)
│ │ │ │ +
363 {
│ │ │ │ +
364 return std::get<std::tuple_size<Tuple>::value - N - 1>(t);
│ │ │ │
365 }
│ │ │ │
│ │ │ │
366
│ │ │ │ -
│ │ │ │ -
371 void attach(std::ostream& stream) {
│ │ │ │ -
372 if (_tied)
│ │ │ │ -
373 DUNE_THROW(DebugStreamError, "Cannot attach to a tied stream!");
│ │ │ │ +
367 template<typename Tuple>
│ │ │ │ +
368 static typename TupleAccessTraits<typename AtType<N, Tuple>::Type>::ConstType
│ │ │ │ +
│ │ │ │ +
369 get(const Tuple& t)
│ │ │ │ +
370 {
│ │ │ │ +
371 return std::get<std::tuple_size<Tuple>::value - N - 1>(t);
│ │ │ │ +
372 }
│ │ │ │ +
│ │ │ │ +
373 };
│ │ │ │ +
│ │ │ │
374
│ │ │ │ -
375 StreamWrap* newcurr = new StreamWrap(stream);
│ │ │ │ -
376 newcurr->next = current;
│ │ │ │ -
377 current = newcurr;
│ │ │ │ -
378 }
│ │ │ │ -
│ │ │ │ -
379
│ │ │ │ -
│ │ │ │ -
383 void detach() {
│ │ │ │ -
384 if (current->next == 0)
│ │ │ │ -
385 DUNE_THROW(DebugStreamError, "Cannot detach initial stream!");
│ │ │ │ -
386 if (_tied)
│ │ │ │ -
387 DUNE_THROW(DebugStreamError, "Cannot detach a tied stream!");
│ │ │ │ -
388
│ │ │ │ -
389 StreamWrap* old = current;
│ │ │ │ - │ │ │ │ -
391 delete old;
│ │ │ │ -
392 }
│ │ │ │ -
│ │ │ │ -
393
│ │ │ │ -
│ │ │ │ - │ │ │ │ -
398 if (to._tied)
│ │ │ │ -
399 DUNE_THROW(DebugStreamError, "Cannot tie to an already tied stream!");
│ │ │ │ -
400 if (_tied)
│ │ │ │ -
401 DUNE_THROW(DebugStreamError, "Stream already tied: untie first!");
│ │ │ │ -
402
│ │ │ │ -
403 _tied = true;
│ │ │ │ -
404 tiedstate = &to;
│ │ │ │ -
405
│ │ │ │ -
406 // tell master class
│ │ │ │ -
407 tiedstate->_tied_streams++;
│ │ │ │ -
408 }
│ │ │ │ -
│ │ │ │ -
409
│ │ │ │ -
│ │ │ │ -
413 void untie() {
│ │ │ │ -
414 if(! _tied)
│ │ │ │ -
415 DUNE_THROW(DebugStreamError, "Cannot untie, stream is not tied!");
│ │ │ │ -
416
│ │ │ │ -
417 tiedstate->_tied_streams--;
│ │ │ │ -
418 _tied = false;
│ │ │ │ -
419 tiedstate = 0;
│ │ │ │ -
420 }
│ │ │ │ -
│ │ │ │ -
421
│ │ │ │ -
422 private:
│ │ │ │ -
424 DebugStreamState* tiedstate;
│ │ │ │ -
425
│ │ │ │ -
430 std::stack<bool> _actstack;
│ │ │ │ +
378 template<class Tuple>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
380 {
│ │ │ │ +
381 template<typename... Ts>
│ │ │ │ +
│ │ │ │ +
382 static void apply(std::tuple<Ts...>& t)
│ │ │ │ +
383 {
│ │ │ │ +
384 Hybrid::forEach(t,[&](auto&& ti){delete ti; ti=nullptr;});
│ │ │ │ +
385 }
│ │ │ │ +
│ │ │ │ +
386 };
│ │ │ │ +
│ │ │ │ +
387
│ │ │ │ +
411 template<class Tuple, template<class> class Predicate, std::size_t start = 0,
│ │ │ │ +
412 std::size_t size = std::tuple_size<Tuple>::value>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
414 public std::conditional<Predicate<typename std::tuple_element<start,
│ │ │ │ +
415 Tuple>::type>::value,
│ │ │ │ +
416 std::integral_constant<std::size_t, start>,
│ │ │ │ +
417 FirstPredicateIndex<Tuple, Predicate, start+1> >::type
│ │ │ │ +
418 {
│ │ │ │ +
419 static_assert(std::tuple_size<Tuple>::value == size, "The \"size\" "
│ │ │ │ +
420 "template parameter of FirstPredicateIndex is an "
│ │ │ │ +
421 "implementation detail and should never be set "
│ │ │ │ +
422 "explicitly!");
│ │ │ │ +
423 };
│ │ │ │ +
│ │ │ │ +
424
│ │ │ │ +
425#ifndef DOXYGEN
│ │ │ │ +
426 template<class Tuple, template<class> class Predicate, std::size_t size>
│ │ │ │ +
427 class FirstPredicateIndex<Tuple, Predicate, size, size>
│ │ │ │ +
428 {
│ │ │ │ +
429 static_assert(AlwaysFalse<Tuple>::value, "None of the std::tuple element "
│ │ │ │ +
430 "types matches the predicate!");
│ │ │ │
431 };
│ │ │ │ -
│ │ │ │ -
432
│ │ │ │ -
434}
│ │ │ │ -
435
│ │ │ │ -
436
│ │ │ │ -
437#endif
│ │ │ │ -
A few common exception classes.
│ │ │ │ -
StreamWrap(std::ostream &_out)
Definition debugstream.hh:152
│ │ │ │ -
DebugStream(std::ostream &out=std::cerr)
Create a DebugStream and set initial output stream.
Definition debugstream.hh:199
│ │ │ │ -
void untie()
Untie stream.
Definition debugstream.hh:413
│ │ │ │ -
DebugStream & flush()
pass on flush to underlying output stream
Definition debugstream.hh:320
│ │ │ │ -
void attach(std::ostream &stream)
set output to a different stream.
Definition debugstream.hh:371
│ │ │ │ -
void detach()
detach current output stream and restore to previous stream
Definition debugstream.hh:383
│ │ │ │ -
static constexpr bool value
Definition debugstream.hh:143
│ │ │ │ -
std::ostream & out
Definition debugstream.hh:153
│ │ │ │ -
void pop()
restore previously set activation flag
Definition debugstream.hh:349
│ │ │ │ -
bool active() const
reports if this stream will produce output
Definition debugstream.hh:363
│ │ │ │ -
bool _active
flag to switch output during runtime
Definition debugstream.hh:165
│ │ │ │ -
unsigned int _tied_streams
how many streams are tied to this state
Definition debugstream.hh:171
│ │ │ │ -
void tie(DebugStreamState &to)
Tie a stream to this one.
Definition debugstream.hh:397
│ │ │ │ -
void push(bool b)
set activation flag and store old value
Definition debugstream.hh:335
│ │ │ │ -
unsigned int DebugLevel
Type for debug levels.
Definition debugstream.hh:118
│ │ │ │ -
bool _tied
are we tied to another DebugStream?
Definition debugstream.hh:168
│ │ │ │ -
StreamWrap * current
current output stream and link to possibly pushed old output streams
Definition debugstream.hh:162
│ │ │ │ -
DebugStream & operator<<(const T data)
Generic types are passed on to current output stream.
Definition debugstream.hh:267
│ │ │ │ -
static constexpr bool value
Definition debugstream.hh:131
│ │ │ │ -
~DebugStream()
Destroy stream.
Definition debugstream.hh:243
│ │ │ │ -
DebugStream(DebugStreamState &master, std::ostream &fallback=std::cerr)
Create a DebugStream and directly tie to another DebugStream.
Definition debugstream.hh:219
│ │ │ │ -
DebugStream & operator<<(const int data)
explicit specialization so that enums can be printed
Definition debugstream.hh:289
│ │ │ │ -
DebugStream & operator<<(std::ostream &(*f)(std::ostream &))
pass on manipulators to underlying output stream
Definition debugstream.hh:305
│ │ │ │ -
StreamWrap * next
Definition debugstream.hh:154
│ │ │ │ -
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
│ │ │ │ +
432#endif // !DOXYGEN
│ │ │ │ +
433
│ │ │ │ +
443 template<class T>
│ │ │ │ +
│ │ │ │ +
444 struct IsType
│ │ │ │ +
445 {
│ │ │ │ +
447 template<class U>
│ │ │ │ +
448 struct Predicate : public std::is_same<T, U> {};
│ │ │ │ +
449 };
│ │ │ │ +
│ │ │ │ +
450
│ │ │ │ +
464 template<class Tuple, class T, std::size_t start = 0>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
466 public FirstPredicateIndex<Tuple, IsType<T>::template Predicate, start>
│ │ │ │ +
467 { };
│ │ │ │ +
│ │ │ │ +
468
│ │ │ │ +
475 template<class Tuple, class T>
│ │ │ │ + │ │ │ │ +
477
│ │ │ │ +
478 template<class... Args, class T>
│ │ │ │ +
│ │ │ │ +
479 struct PushBackTuple<typename std::tuple<Args...>, T>
│ │ │ │ +
480 {
│ │ │ │ +
481 typedef typename std::tuple<Args..., T> type;
│ │ │ │ +
482 };
│ │ │ │ +
│ │ │ │ +
483
│ │ │ │ +
490 template<class Tuple, class T>
│ │ │ │ + │ │ │ │ +
492
│ │ │ │ +
493 template<class... Args, class T>
│ │ │ │ +
│ │ │ │ +
494 struct PushFrontTuple<typename std::tuple<Args...>, T>
│ │ │ │ +
495 {
│ │ │ │ +
496 typedef typename std::tuple<T, Args...> type;
│ │ │ │ +
497 };
│ │ │ │ +
│ │ │ │ +
498
│ │ │ │ +
511 template<
│ │ │ │ +
512 template <class, class> class F,
│ │ │ │ +
513 class Tuple,
│ │ │ │ +
514 class Seed=std::tuple<>,
│ │ │ │ +
515 int N=std::tuple_size<Tuple>::value>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
517 {
│ │ │ │ +
518 typedef typename ReduceTuple<F, Tuple, Seed, N-1>::type Accumulated;
│ │ │ │ +
519 typedef typename std::tuple_element<N-1, Tuple>::type Value;
│ │ │ │ +
520
│ │ │ │ +
522 typedef typename F<Accumulated, Value>::type type;
│ │ │ │ +
523 };
│ │ │ │ +
│ │ │ │ +
524
│ │ │ │ +
535 template<
│ │ │ │ +
536 template <class, class> class F,
│ │ │ │ +
537 class Tuple,
│ │ │ │ +
538 class Seed>
│ │ │ │ +
│ │ │ │ +
539 struct ReduceTuple<F, Tuple, Seed, 0>
│ │ │ │ +
540 {
│ │ │ │ +
542 typedef Seed type;
│ │ │ │ +
543 };
│ │ │ │ +
│ │ │ │ +
544
│ │ │ │ +
554 template<class Head, class Tail>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
556 {
│ │ │ │ + │ │ │ │ +
559 };
│ │ │ │ +
│ │ │ │ +
560
│ │ │ │ +
569 template<class Tuple>
│ │ │ │ +
│ │ │ │ + │ │ │ │ +
571 {
│ │ │ │ + │ │ │ │ +
574 };
│ │ │ │ +
│ │ │ │ +
575
│ │ │ │ +
577}
│ │ │ │ +
578
│ │ │ │ +
579#endif
│ │ │ │ + │ │ │ │ +
Traits for type conversions and type information.
│ │ │ │ +
std::add_const< T >::type & ConstType
Definition tupleutility.hh:50
│ │ │ │ +
static void apply(std::tuple< Ts... > &t)
Definition tupleutility.hh:382
│ │ │ │ +
T * ParameterType
Definition tupleutility.hh:60
│ │ │ │ +
auto transformTuple(Tuple &&orig, Args &&... args) -> decltype(genericTransformTuple(orig, makeTransformTupleFunctor< TypeEvaluator >(args...)))
Definition tupleutility.hh:292
│ │ │ │ +
T & ConstType
Definition tupleutility.hh:66
│ │ │ │ +
ReduceTuple< F, Tuple, Seed, N-1 >::type Accumulated
Definition tupleutility.hh:518
│ │ │ │ +
T * NonConstType
Definition tupleutility.hh:59
│ │ │ │ +
Seed type
Result of the reduce operation.
Definition tupleutility.hh:542
│ │ │ │ +
std::remove_reference< T >::type * Type
Definition tupleutility.hh:321
│ │ │ │ +
static Type apply(T &t)
Definition tupleutility.hh:307
│ │ │ │ +
static ResultType apply()
Definition tupleutility.hh:85
│ │ │ │ +
std::tuple< Args... > ResultType
Definition tupleutility.hh:84
│ │ │ │ +
std::remove_reference< T >::type * Type
Definition tupleutility.hh:332
│ │ │ │ +
TransformTupleFunctor(Args &&... args)
Definition tupleutility.hh:241
│ │ │ │ +
std::tuple_element< std::tuple_size< Tuple >::value-N-1, Tuple >::type Type
Definition tupleutility.hh:347
│ │ │ │ +
static Type apply(T &t)
Definition tupleutility.hh:333
│ │ │ │ +
auto operator()(T &&t) -> decltype(this->apply(t, std::index_sequence_for< Args... >{})) const
Definition tupleutility.hh:246
│ │ │ │ +
T & NonConstType
Definition tupleutility.hh:67
│ │ │ │ +
T & NonConstType
Definition tupleutility.hh:51
│ │ │ │ +
static TupleAccessTraits< typenameAtType< N, Tuple >::Type >::ConstType get(const Tuple &t)
Definition tupleutility.hh:369
│ │ │ │ +
T & Type
Definition tupleutility.hh:306
│ │ │ │ +
static TupleAccessTraits< typenameAtType< N, Tuple >::Type >::NonConstType get(Tuple &t)
Definition tupleutility.hh:362
│ │ │ │ +
std::tuple< Args..., T > type
Definition tupleutility.hh:481
│ │ │ │ +
std::tuple_element< N-1, Tuple >::type Value
Definition tupleutility.hh:519
│ │ │ │ +
std::tuple< T, Args... > type
Definition tupleutility.hh:496
│ │ │ │ +
ReduceTuple< JoinTuples, Tuple >::type type
Result of the flatten operation.
Definition tupleutility.hh:573
│ │ │ │ +
static Type apply(T &t)
Definition tupleutility.hh:322
│ │ │ │ +
F< Accumulated, Value >::type type
Result of the reduce operation.
Definition tupleutility.hh:522
│ │ │ │ +
ReduceTuple< PushBackTuple, Tail, Head >::type type
Result of the join operation.
Definition tupleutility.hh:558
│ │ │ │ +
std::tuple< typename TE< Args >::Type... > Type
Definition tupleutility.hh:121
│ │ │ │ +
auto genericTransformTuple(Tuple &&t, Functor &&f) -> decltype(genericTransformTupleBackend(t, f))
Definition tupleutility.hh:186
│ │ │ │ +
decltype(auto) applyPartial(F &&f, ArgTuple &&args, std::integer_sequence< I, i... >)
Apply function with arguments from a given tuple.
Definition tupleutility.hh:42
│ │ │ │ +
T & ParameterType
Definition tupleutility.hh:68
│ │ │ │ +
const std::remove_const< T >::type & ParameterType
Definition tupleutility.hh:52
│ │ │ │ +
std::add_const< T >::type * ConstType
Definition tupleutility.hh:58
│ │ │ │ +
TransformTupleFunctor< TE, Args... > makeTransformTupleFunctor(Args &&... args)
Definition tupleutility.hh:254
│ │ │ │ +
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition hybridutilities.hh:256
│ │ │ │ +
STL namespace.
│ │ │ │
Dune namespace.
Definition alignedallocator.hh:13
│ │ │ │ -
Greater or equal template test.
Definition debugstream.hh:130
│ │ │ │ -
activate if current and mask have common bits switched on.
Definition debugstream.hh:142
│ │ │ │ -
standard exception for the debugstream
Definition debugstream.hh:148
│ │ │ │ -
Definition debugstream.hh:150
│ │ │ │ -
Intermediate class to implement tie-operation of DebugStream.
Definition debugstream.hh:158
│ │ │ │ -
Generic class to implement debug output streams.
Definition debugstream.hh:192
│ │ │ │ -
Default exception class for I/O errors.
Definition exceptions.hh:231
│ │ │ │ +
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition integersequence.hh:75
│ │ │ │ +
Definition tupleutility.hh:49
│ │ │ │ +
A helper template that initializes a std::tuple consisting of pointers to nullptr.
Definition tupleutility.hh:79
│ │ │ │ +
Helper template to clone the type definition of a std::tuple with the storage types replaced by a use...
Definition tupleutility.hh:116
│ │ │ │ +
Definition tupleutility.hh:226
│ │ │ │ +
Definition tupleutility.hh:239
│ │ │ │ +
TypeEvaluator to turn a type T into a reference to T
Definition tupleutility.hh:305
│ │ │ │ +
TypeEvaluator to turn a type T into a pointer to T
Definition tupleutility.hh:320
│ │ │ │ +
Type for reverse element access.
Definition tupleutility.hh:346
│ │ │ │ +
Reverse element access.
Definition tupleutility.hh:359
│ │ │ │ +
Deletes all objects pointed to in a std::tuple of pointers.
Definition tupleutility.hh:380
│ │ │ │ +
Finding the index of a certain type in a std::tuple.
Definition tupleutility.hh:418
│ │ │ │ +
Generator for predicates accepting one particular type.
Definition tupleutility.hh:445
│ │ │ │ +
The actual predicate.
Definition tupleutility.hh:448
│ │ │ │ +
Find the first occurrence of a type in a std::tuple.
Definition tupleutility.hh:467
│ │ │ │ +
Helper template to append a type to a std::tuple.
Definition tupleutility.hh:476
│ │ │ │ +
Helper template to prepend a type to a std::tuple.
Definition tupleutility.hh:491
│ │ │ │ +
Apply reduce with meta binary function to template.
Definition tupleutility.hh:517
│ │ │ │ +
Join two std::tuple's.
Definition tupleutility.hh:556
│ │ │ │ +
Flatten a std::tuple of std::tuple's.
Definition tupleutility.hh:571
│ │ │ │ +
template which always yields a false value
Definition typetraits.hh:124
│ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -1,375 +1,520 @@ │ │ │ │ │ dune-common 2.10 │ │ │ │ │ Loading... │ │ │ │ │ Searching... │ │ │ │ │ No Matches │ │ │ │ │ * dune │ │ │ │ │ * common │ │ │ │ │ -debugstream.hh │ │ │ │ │ +tupleutility.hh │ │ │ │ │ Go_to_the_documentation_of_this_file. │ │ │ │ │ 1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- │ │ │ │ │ 2// vi: set et ts=4 sw=2 sts=2: │ │ │ │ │ 3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file │ │ │ │ │ LICENSE.md in module root │ │ │ │ │ 4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception │ │ │ │ │ 5 │ │ │ │ │ -6#ifndef DUNE_DEBUGSTREAM_HH │ │ │ │ │ -7#define DUNE_DEBUGSTREAM_HH │ │ │ │ │ +6#ifndef DUNE_TUPLE_UTILITY_HH │ │ │ │ │ +7#define DUNE_TUPLE_UTILITY_HH │ │ │ │ │ 8 │ │ │ │ │ -13#include │ │ │ │ │ -14#include │ │ │ │ │ -15 │ │ │ │ │ -16#include │ │ │ │ │ -17 │ │ │ │ │ -18namespace Dune { │ │ │ │ │ -19 │ │ │ │ │ -118 typedef unsigned int DebugLevel; │ │ │ │ │ -119 │ │ │ │ │ -129 template │ │ │ │ │ -130 struct greater_or_equal { │ │ │ │ │ -131 constexpr static bool value = (current >= threshold); │ │ │ │ │ -132 }; │ │ │ │ │ -133 │ │ │ │ │ -134 │ │ │ │ │ -141 template │ │ │ │ │ -142 struct common_bits { │ │ │ │ │ -143 constexpr static bool value = ((current & mask) != 0); │ │ │ │ │ -144 }; │ │ │ │ │ -145 │ │ │ │ │ +9#include │ │ │ │ │ +10#include │ │ │ │ │ +11#include │ │ │ │ │ +12#include │ │ │ │ │ +13 │ │ │ │ │ +14#include │ │ │ │ │ +15#include │ │ │ │ │ +16 │ │ │ │ │ +17namespace Dune { │ │ │ │ │ +18 │ │ │ │ │ +41 template │ │ │ │ │ +42 decltype(auto) applyPartial(F&& f, ArgTuple&& args, std::integer_sequence /*indices*/) │ │ │ │ │ +43 { │ │ │ │ │ +44 return f(std::get(args)...); │ │ │ │ │ +45 } │ │ │ │ │ +46 │ │ │ │ │ +47 template │ │ │ │ │ +48 struct TupleAccessTraits │ │ │ │ │ +49 { │ │ │ │ │ +50 typedef typename std::add_const::type& ConstType; │ │ │ │ │ +51 typedef T& NonConstType; │ │ │ │ │ +52 typedef const typename std::remove_const::type& ParameterType; │ │ │ │ │ +53 }; │ │ │ │ │ +54 │ │ │ │ │ +55 template │ │ │ │ │ +56 struct TupleAccessTraits │ │ │ │ │ +57 { │ │ │ │ │ +58 typedef typename std::add_const::type* ConstType; │ │ │ │ │ +59 typedef T* NonConstType; │ │ │ │ │ +60 typedef T* ParameterType; │ │ │ │ │ +61 }; │ │ │ │ │ +62 │ │ │ │ │ +63 template │ │ │ │ │ +64 struct TupleAccessTraits │ │ │ │ │ +65 { │ │ │ │ │ +66 typedef T& ConstType; │ │ │ │ │ +67 typedef T& NonConstType; │ │ │ │ │ +68 typedef T& ParameterType; │ │ │ │ │ +69 }; │ │ │ │ │ +70 │ │ │ │ │ +78 template │ │ │ │ │ +79 struct NullPointerInitialiser; │ │ │ │ │ +80 │ │ │ │ │ +81 template │ │ │ │ │ +82 struct NullPointerInitialiser > │ │ │ │ │ +83 { │ │ │ │ │ +84 typedef std::tuple ResultType; │ │ │ │ │ +85 static ResultType apply() │ │ │ │ │ +86 { │ │ │ │ │ +87 return ResultType(static_cast(nullptr)...); │ │ │ │ │ +88 } │ │ │ │ │ +89 }; │ │ │ │ │ +90 │ │ │ │ │ +115 template