代码之家  ›  专栏  ›  技术社区  ›  Brad Hein

Gnuradio C++块:高CPU

  •  1
  • Brad Hein  · 技术社区  · 7 年前

    我创建了一个没有自定义代码的新块,只将变量类型设置为float,输入和输出的数量设置为1,我看到了相同的行为。我一定做错了什么,但我不知道是什么。。。

    $ gnuradio-config-info -v
    3.7.11
    
    Platform: Mac / x86_64
    

    $ gr_modtool add -t general donothingcpp
    GNU Radio module name identified: acsound
    Language (python/cpp): cpp
    Language: C++
    Block/code identifier: donothingcpp
    Enter valid argument list, including default arguments: 
    Add Python QA code? [Y/n] n
    Add C++ QA code? [Y/n] n
    Adding file 'lib/donothingcpp_impl.h'...
    Adding file 'lib/donothingcpp_impl.cc'...
    Adding file 'include/acsound/donothingcpp.h'...
    Editing swig/acsound_swig.i...
    Adding file 'grc/acsound_donothingcpp.xml'...
    Editing grc/CMakeLists.txt...
    

    以下是用于测试的流程图: gnuradio flow graph

    int
    donothingcpp_impl::general_work (int noutput_items,
                       gr_vector_int &ninput_items,
                       gr_vector_const_void_star &input_items,
                       gr_vector_void_star &output_items)
    {
      const float *in = (const float *) input_items[0];
      float *out = (float *) output_items[0];
    
      // Do <+signal processing+>
      // Tell runtime system how many input items we consumed on
      // each input stream.
      consume_each (noutput_items);
    
      // Tell runtime system how many output items we produced.
      return noutput_items;
    }
    

    我是否在 general_work

    如果我绕过donothing块并运行流程图,它将消耗0.3%的CPU。

    我尝试了零信号接收器和探测信号接收器,但两者似乎都不是一个因素。

    1 回复  |  直到 7 年前
        1
  •  1
  •   Marcus Müller    7 年前

    您正在消耗输出样本的数量,但在一般情况下这是错误的(在同步块情况下是正确的,其中输出项的数量始终与消耗的输入项的数量相同)。

    现在,由于您的块没有检查是否有足够的输入项,因此总是要求它运行,从而导致CPU的消耗。

    我觉得你“不小心”做了一个一般块(与一个 general_work work