Multi-threading in Calc

All,

I am considering the changes necessary to upgrade the Calc Guide to 6.4.

One of the issues we chose to ignore in the 6.2 Calc Guide was
multi-threading. The 6.2 Calc Guide contains the following mention of it,
when describing the Tools > Options > LibreOffice Calc > Calculate page:

CPU threading settings section
Enable multi-threaded calculation controls the use of multi-threading /
parallelism, which can be used to speed up LibreOffice Calc calculations on
computers with multiple processing cores.

That’s it in the Calc Guide, and I couldn't readily find anything in the
Help files.

Is there a slightly more detailed explanation anywhere which might
enlighten me further, so that I can in turn include a little more
information for the user?

Regards,

Steve

Hi Developers

Can charitable soul involved with threading in Calc spend a couple of
minutes to write an outline of what we should look to write a section on
the topic in our guide and Help? Just the outline and some pointers for
our investigation.

We think this feature is a plus, but it is not clear if and how an end
user will benefit.

Thanks in advance
Olivier

-------- Mensagem encaminhada --------

Hi Luboš,

Many thanks for your thoughts on the checkbox, which confirms what I
expected.

As for the processing itself, I remain unclear about how Calc allocates
tasks to threads. Can we give the user any general advice on how he could
structure his spreadsheet to gain the maximum performance benefits from the
availability of multiple cores? Or maybe there are ways to organise a
spreadsheet that will frustrate Calc's attempts to multi-thread, which we
ought to advise against?

Any further help would be greatly appreciated.

Regards,

Steve

Hi Developers

Can charitable soul involved with threading in Calc spend a couple of
minutes to write an outline of what we should look to write a section on
the topic in our guide and Help? Just the outline and some pointers for
our investigation.

We think this feature is a plus, but it is not clear if and how an end
user will benefit.

The "Enable multi-threaded calculation" checkbox is one of those settings
that aren't actually a preference, in an ideal world they should always be
enabled, and in fact shouldn't even exist as the thing should Just Work(TM).
We have others like that, 'Allow use of OpenCL', 'Use OpenGL/Skia for all
rendering', etc. So AFAICT the purpose of those settings is to admit that we
don't live in an ideal world and the setting allows people to disable the
feature in case it turns out it's buggy (which incidentally is relatively
more likely for all the settings I mentioned).

So the way I see it the best thing the docs can say about it is something
along the lines of "this does roughly that, don't touch it unless you know
you want to touch it".

...

Technically threads are generally used only for formula groups, which are a
sufficient number of adjacent cells in a column that use the same formula
(and get different results because of relative cell addressing). In UI terms,
write e.g. "=A1*2" to B1, grab the bottom-right corner of the cell and extend
down. But it's implementated this way because that's usually how large
spreadsheets are created. So I think it's a needless complication to be
specific about this.

IMO it's still useful to mention that the optimization is column-based.
Because many people don't realize that row-based layout is potentially
less efficient. This would be beneficial to those who don't create
spreadsheets according to how it's "usually" done.

Mike and Luboš,

Many thanks for your help on this topic.

Regards,

Steve

BTW I'm copying a paragraph from an email on a different list.

"Also - if you set MAX_CONCURRENCY=16 - or somesuch (ie. twice your
number of threads) - you may be able to defeat the hyper-threaded
halving, and see if this workload happens to be one that does better
with hyper-threading than without."M.M.

It might be worth mentioning the MAX_CURRENCY setting for controlling CPU
thread usage.

Also, I wonder if the folks answering could answer one other question:
Does LibreOffice OnLine also use cpu threading in the same way it does when
run for desktop or headless? It would be with noting in the documentation
if it does not, IMO.

To follow up on that.

Using LO 6.4 & 7.0 pre-release build on Ubuntu. Recalculating one of the
OpenCL test xls files just now.

Starting up with a command line
MAX_CONCURRENCY=0 ./soffice
Does turn the CPU threading off.

Restarting with a command line
MAX_CONCURRENCY=4 ./soffice
Turns it back on (for my AMD a5800 processor this will give me two threads,
because while the CPU is called a 4 core processor and it does have 4
accumulators it only has 2 floatingpoint cores and this is the limiting
factor it seems) with recalculation time for the workbook is ~2x faster.

Also - I read in a couple of places online that if you have OpenCL support
enabled then the CPU threading stops.

I can't test that to see if it is true because I can't seem to get OpenCL
to work on this Linux desktop.

Trying it on a Windows machine should answer that question.

Try dragging a formula down 6000 rows, you have time for a cup of tea
and a snack.
I doubt anyone wanting to use the advantage of multithreading will be
dragging formulae many cells.
So it would be an advantage to know how to optimise for multithreading.
Steve