5
$\begingroup$

I am running my Fortran 95 numerical codes, whose structure is most times easily parallelized by little more than simply adding the corresponding OpenMP instruction before some critical DO sentences, in a dual-core multi-thread CPU Intel CORE i3. Ubuntu "sees" four CPUs (obviously since there are 2 cores, each of them emulating two cores each), and I have read that the "multithread" capability means that, under certain conditions, each of the CPUs may behave close to two separate CPUs itself, but not in general. I have heard somewhere that, in some cases, the four parallel threads may perform worse than two in this kind of machine.

What is the kind of coding or tasks in general with which my machine works nearly as a real 4-core, and in which ones it may not be a good idea to emulate that (thus setting for instance the OMP_NUM_THREADS variable to 2 instead of 4)?


EDIT: In other words and, according to this nice answer in another post, what is the optimal number of hardware threads for my machine in relation to the kind of numerical task involved, provided that, although it is a dual-core cpu, it has that "multithread" ability?

$\endgroup$
  • $\begingroup$ I am not sure whether this question goes better with Programmers than here. My apologizes in advance. $\endgroup$ – user4015 Apr 11 '13 at 20:05
  • $\begingroup$ Ummm, I could go to Stackoverflow too... What is the appropiate site for it? $\endgroup$ – user4015 Apr 11 '13 at 20:15
  • $\begingroup$ Thanks! I upvoted your answers. Anyway, I don't assign the green flag, since I expect some kind of information about the kind of tasks that are better for multi-thread. Perhaps something like "codes that contain vectorizable loops with short precision floating point numbers are good/bad for multithread" or "operations that rely on big array operations with..." who knows... That is the direction of the answer I expect. Anyway, thanks for the indications. I already timed my code and it is faster with twice the threads with respect of the cores, but I don't know how general that result can be. $\endgroup$ – user4015 Apr 15 '13 at 22:18
  • $\begingroup$ Hi @Eduardo Guerras Valera ; sorry to ping you here, but I was afraid my chat message may not ping you (chat often doesn't ping), so I'll link to it here: chat.stackexchange.com/transcript/message/11500156#11500156 $\endgroup$ – user5290 Oct 3 '13 at 1:52
5
$\begingroup$

The community has not really come to much of a conclusion on when this may or may not be worth it. I do compile with 'make -j8' on my 4-core laptop and it is faster than using 'make -j4' but simple multithreaded programs aren't much faster when run with 8 threads than with 4. The only real way to find out is to try.

$\endgroup$
  • $\begingroup$ Sometimes I wish I had a +2. $\endgroup$ – Bill Barth Apr 12 '13 at 2:17
4
$\begingroup$

Hyperthreading utilizes the duplication of cpu parts such as registers to allow the cpu to "look" like twice as many cores to the OS and other hardware. The actual execution units such as the FPU are not duplicated. This means that if your program is CPU limited, ie, with 2 threads the FPU is already at full capacity, then you won't see any improvement.

As such, you can only expect either configuration to improve performance by a few tens of percent. Intel claims an approximately 30% increase in some cases, however even they admit it is application dependent. The only real way to know how it will affect your code is to profile it. Take two identical runs of non-trivial size and time them. I personally work with a code that slight changes in numerical parameters greatly changes the way the code scales with the number of threads.

$\endgroup$
1
$\begingroup$

In general hyperthreading is good if you have a of operations depending on results of the previous operations, because then, the pipeline can be filled with operations from the other thread until the required informations to continue are there. On the other hand, you half the size of available cache size per thread, so depending on your memory usage this can give a huge performance hit.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy