kcachegrdind
コードを最適化しようとしている間、とによって生成されたプロファイルの違いに少し戸惑っていますgprof
。具体的には、gprof(-pg
スイッチとのコンパイルなど)を使用する場合、次のようになります。
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
89.62 3.71 3.71 204626 0.02 0.02 objR<true>::R_impl(std::vector<coords_t, std::allocator<coords_t> > const&, std::vector<unsigned long, std::allocator<unsigned long> > const&) const
5.56 3.94 0.23 18018180 0.00 0.00 W2(coords_t const&, coords_t const&)
3.87 4.10 0.16 200202 0.00 0.00 build_matrix(std::vector<coords_t, std::allocator<coords_t> > const&)
0.24 4.11 0.01 400406 0.00 0.00 std::vector<double, std::allocator<double> >::vector(std::vector<double, std::allocator<double> > const&)
0.24 4.12 0.01 100000 0.00 0.00 Wrat(std::vector<coords_t, std::allocator<coords_t> > const&, std::vector<coords_t, std::allocator<coords_t> > const&)
0.24 4.13 0.01 9 1.11 1.11 std::vector<short, std::allocator<short> >* std::__uninitialized_copy_a<__gnu_cxx::__normal_iterator<std::vector<short, std::alloca
これは、私がどこかを探す必要がないことを示唆しているようですが、::R_impl(...)
同時に、-pg
スイッチなしでコンパイルしてvalgrind --tool=callgrind ./a.out
代わりに実行すると、かなり異なるものがあります。これがkcachegrind
出力のスクリーンショットです。
これを正しく解釈すると、::R_impl(...)
時間の約50%しかかからないのに対し、残りの半分は、プロファイルのはるか下にある線形代数( Wrat(...)
、および基礎となるlapack呼び出し)に費やされていることを示唆しているようです。eigenvalues
gprof
私はそれを理解し、さまざまな手法gprof
をcachegrind
使用しています。結果が多少異なっていてもかまいません。しかし、ここでは、それは非常に異なって見えます、そして私はそれらをどのように解釈するかについて途方に暮れています。何かアイデアや提案はありますか?