help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CPU usage by call of C++ code through system() on Linux


From: Kai Torben Ohlhus
Subject: Re: CPU usage by call of C++ code through system() on Linux
Date: Fri, 26 Jun 2020 13:28:24 +0900
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

On 6/26/20 1:17 AM, Andreas Stahel wrote:
> Dear Octave Users
> 
> Maybe one of you can give me a hint on how to make my Octave code run
> faster.
> Within a good size program (run time 40 sec) the command system() is
> used to call a C++ code.
> The C++ code uses pthreads.
> While the code is running htop show approximately 40% of load by the
> kernel on each CPU and 60% "normal" (user space?).
> 
> When running the same code in Matlab only the "normal"load shows and
> very little kernel load on the CPUs.
> The computation time by Matlab is also only 60% of the time consumed by
> Octave (5.2.0)
> The system is an Ubuntu 20.04 on a AMD Ryzen 3950X.
> 
> Any hints on what is slowing Octave down?
> 
> With best regards
> 
> Andreas


Dear Andreas,

Maybe I do not understand your setup correctly.  You have a C++ code
using threads compiled to, e.g. "code.exe" (the suffix does not matter),
and an Octave script "benchmark.m" with somewhere the code line

   system ("code.exe")

First question is, do "benchmark.m" and "code.exe" interact with each
other?  Means, does "code.exe" compute something that "benchmark.m"
processes further by importing results?  What is the purpose of Octave
calling "code.exe"?  Benchmarking with tic-toc?

Second question, does "code.exe" (standalone, without Octave or Matlab)
or "benchmark.m" (called from Octave or Matlab) have a run time of 40
seconds?

Now to your observation.  When running "benchmark.m" in Octave and
Matlab you observe Octave is slower.  I do not understand how this is
related to the CPU "kernel" and "normal" usage?  What is the runtime of
"benchmark.m" in Matlab and Octave, respectively?  Do you complain not
all CPU cores are used?

Maybe it is best to give us (some) code to better understand the situation.

Kai



reply via email to

[Prev in Thread] Current Thread [Next in Thread]