1

I'm working on a program that involves some computationally intensive algorithms. On my i7 it takes about ±45 seconds to perform one complete calculation.

It's not multithreaded yet, hence it only uses one core, so there's an obvious opportunity for improvement.

However, when I monitor my processor usage, I noticed it doesn't even fully use one core. With no other intensive processes running, I see activity on one of my 8 cores, but it's only doing 60-80%, whereas I would expect the core that runs my program to be fully hogged at 100%.

The algorithm involves no disk or network access, and there's no large amounts of memory involved (it does some very heavy image processing, I'm currently using very small images only) and it doesn't use the GPU. It's a simple, straightforward process, doing just one heavy calculation, and I'm not sleeping or interrupting or waiting for events or anything.

Any reason why a computationally intensive program (that doesn't rely on external resources whatsoever) would not be using the running core to it's full capacity?

RocketNuts
  • 9,958
  • 11
  • 47
  • 88
  • A simple explanation is that the computation does more memory access than you think it does. Have you profiled the code or used anything else to see what's really going on ? – High Performance Mark May 20 '15 at 10:23
  • Is the cpu temperature reaching very high? – phoxis May 20 '15 at 10:26
  • @HighPerformanceMark Well the computations I'm doing are typically not memory intensive. I'm using a few buffers that are about 4KB (which are not continuously being entirely read or written), but that's about it. However I'm wondering, even if memory access was the bottleneck, wouldn't that show up in core activity as well? I mean, the processor would be in fact be busy accessing memory most of the time? – RocketNuts May 20 '15 at 10:56
  • @phoxis No, if I run other very intenstive processes, I can typically hear my fans going up, but that's not the case here. – RocketNuts May 20 '15 at 10:56
  • Typically CPU performance monitors don't include memory-access activity which is, on most modern CPUs used for general-purpose computing, off-loaded to other components -- so that the CPU can (if possible) carry on computing while data is fetched from RAM to cache. If the CPU spends 80% of its time computing and 20% waiting for RAM this would show up as 80% busy. – High Performance Mark May 20 '15 at 11:03
  • @HighPerformanceMark OK thanks, interesting. Do you know of a method to monitor or measure this? (either windows or osx) – RocketNuts May 20 '15 at 11:10
  • 1
    That's another question and not one I'm inclined to answer. Ask it if you wish, but do your research first and take care to comply with SO's guidelines on constructing good questions. – High Performance Mark May 20 '15 at 11:13
  • @HighPerformanceMark Yes, OK I see, I'll think of a standalone question about profiling in general, investigate first, and post a new topic if necessary. – RocketNuts May 20 '15 at 11:19

0 Answers0