忍者ブログ
  • 2024.02«
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • » 2024.04
Ubuntuの復旧 Ubuntu18.04→Ubuntu20.04へのアップデート
・Ubuntuが起動できなくなったので、インストールCDでリカバリした。
マウント
chroot

デバイスドライバまわりのメモ
・r8168ネットワークドライバが認識しない。
 RTL8111/8168/8411 のインストールに苦悩した話
・i915ビデオドライバがflickerする。
 「PCIe Bus Error: severity=Corrected, type=Data Link Layer」を回避する方法

拍手[1回]

PR
【2021/11/28 09:08 】 | 未選択 | 有り難いご意見(0)
C++17でモンテカルロを並列化してみた。(GNU Version)
C++17でモンテカルロを並列化してみた。に触発されて、GNU版で作ってみました
■コンパイル
$ g++ test.cc -Wall -march=native -std=c++17 -O3  -fopenmp
■ソース
#include <parallel/algorithm>
//#include <execution>
#include <atomic>
#include <mutex>
#include <iostream>
#include <random>
#include <array>
#include <stdlib.h>
int main(int argc, char *argv[])
{
    static int const NUM = 1000000000;
    static int threads = 8;
    static_assert(std::atomic<int>::is_always_lock_free);
    if (argc >= 2)
    {
        threads = atoi(argv[1]);
    }
    auto nums = std::vector<int>(threads);
    for (auto &num : nums)
    {
        num = NUM / threads;
    }
    __gnu_parallel::_Settings s;
    s.algorithm_strategy = __gnu_parallel::force_parallel;
    __gnu_parallel::_Settings::set(s);

    std::atomic counter = {0};

    __gnu_parallel::for_each(nums.begin(), nums.end(), [&counter](int num) {
        std::random_device rnd;
        thread_local std::mt19937 mt(rand());
         std::uniform_real_distribution<double> score(0.0, 1.0);
        for (auto &&no = 0; no < num; ++no)
        {
            auto &&x = score(mt);
            auto &&y = score(mt);
            if ((x * x + y * y) < 1.0)
            {
                counter++;
            }
        }
    });

    std::cout << "PI = " << 4.0 * counter / NUM << std::endl;
}
■結果
$ time ./a.out 1
PI = 3.14155

real	0m27.461s
user	0m27.469s
sys	0m0.001s
$ time ./a.out 2
PI = 3.14159

real	0m29.238s
user	0m58.008s
sys	0m0.016s
$ time ./a.out 3
PI = 3.14151

real	0m28.447s
user	1m24.458s
sys	0m0.000s
$ time ./a.out 4
PI = 3.14155

real	0m32.101s
user	2m5.238s
sys	0m0.020s

なぜか延べ時間(user)が増えるだけでreal時間が減りません。。。
そこでソースを修正してみました。
■ソース修正後
#include <parallel/algorithm>
//#include <execution>
#include <atomic>
#include <mutex>
#include <iostream>
#include <random>
#include <array>
#include <stdlib.h>
int main(int argc, char *argv[])
{
    static int const NUM = 1000000000;
    static int threads = 8;
    static_assert(std::atomic<int>::is_always_lock_free);
    if (argc >= 2)
    {
        threads = atoi(argv[1]);
    }
    auto nums = std::vector<int>(threads);
    for (auto &num : nums)
    {
        num = NUM / threads;
    }
    __gnu_parallel::_Settings s;
    s.algorithm_strategy = __gnu_parallel::force_parallel;
    __gnu_parallel::_Settings::set(s);

    std::atomic counter = {0};

    __gnu_parallel::for_each(nums.begin(), nums.end(), [&counter](int num) {
        std::random_device rnd;
        thread_local std::mt19937 mt(rand());
        int _counter = 0;
        std::uniform_real_distribution<double> score(0.0, 1.0);
        for (auto &&no = 0; no < num; ++no)
        {
            auto &&x = score(mt);
            auto &&y = score(mt);
            if ((x * x + y * y) < 1.0)
            {
                _counter++;
            }
        }
        counter += _counter;
    });

    std::cout << "PI = " << 4.0 * counter / NUM << std::endl;
}

■結果
$ time ./a.out 1
PI = 3.14155

real	0m20.263s
user	0m20.255s
sys	0m0.000s
$ time ./a.out 2
PI = 3.14159

real	0m10.117s
user	0m20.223s
sys	0m0.000s
$ time ./a.out 3
PI = 3.14151

real	0m7.409s
user	0m22.209s
sys	0m0.000s
$ time ./a.out 4
PI = 3.14155

real	0m6.129s
user	0m24.492s
sys	0m0.001s
core4個分で20秒から6秒にその後、8個に増やしても増えませんでした。。。
なかなかのパフォーマンスなり。

拍手[0回]

【2019/05/01 17:11 】 | 未選択 | 有り難いご意見(1)
CentOS7 + ibus
CentOSのアップグレードをかけたらIMEがchromeで効かなくなった・・・


【引用】ibus-based IMEs may not work with Google Chrome after rebooting the computer
修正前

export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus

修正後

export GTK_IM_MODULE=xim
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=xim
解決したなりー。
なんかこの記載方法を昔してダメだったような気がするのでバグが直った感じかな。

拍手[0回]

【2017/08/21 10:39 】 | 未選択 | 有り難いご意見(0)
コンパネに行けないWin10 アップデート
衝撃を受けた。 メニュー右クリックからコンパネが消えた。 同じこと思っている人がいたので1票入れておいたなり。

拍手[0回]

【2017/08/18 20:24 】 | 未選択 | 有り難いご意見(0)
圧縮アーカイブの謎
vistaの20Gのイメージファイルを圧縮しながらファイルサーバに

転送していたのだけどもなぜか解凍するといつも予期せぬEOFになってしまっていた。

圧縮時

tar -jcvf mountdir/vista.img.tar.bz2 vista.img


解凍時

tar -tvf mountdir/vista.img.tar.bz2

拍手[0回]

【2012/04/10 21:21 】 | 未選択 | 有り難いご意見(0)
| ホーム | 次ページ

忍者ブログ [PR]