FreeCAD and multicores - multithreads

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

FreeCAD and multicores - multithreads

Post by easyw-fc »

Hi,
I'm opening a new thread, following the discussion here:
https://forum.freecadweb.org/viewtopic. ... 25#p317539
wmayer wrote: Fri Jun 28, 2019 8:42 am ping
TheMarkster wrote: Fri Jun 28, 2019 3:44 pm ping
First of all, I normally use FC on windows and there I never noticed issues on multicores-multithreads utilization...
Here some screenshots:
-
fc-mcores-1.png
fc-mcores-1.png (458.77 KiB) Viewed 5788 times
fc-mcores-2.png
fc-mcores-2.png (459.4 KiB) Viewed 5788 times
fc-mcores-3.png
fc-mcores-3.png (528.29 KiB) Viewed 5788 times
-
Then I moved my home pc to Linux and I noticed that the GPU gets triggered as on windows, but the cores and threadings not...

Later on I'm going to post a file with a script I used to test it on win and lin.
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: FreeCAD and multicores - multithreads

Post by easyw-fc »

The file is 'B59-12V_asm.stp'. Is a 220MB STEP file, downloadable at dropbox (it is possible to download it without the need to register, clicking on 'No thanks, continue to view'), and posted at this forum's thread.
Here the script I have used to load the file and trigger the multithreading on windows

Code: Select all

#!/usr/bin/python
# -*- coding: utf-8 -*-
import time
FreeCAD.Console.PrintMessage("loading... \n")
t = time.time()
import ImportGui
#ImportGui.open(r"C:\Temp\B59-12V_asm.stp")
ImportGui.open("/home/mau/Downloads/B59-12V_asm.stp")
timeP = time.time() - t
FreeCAD.Console.PrintMessage("loading time = "+str(timeP) + "s\n")
Gui.SendMsgToActiveView("ViewFit")
timeD = time.time() - t - timeP
FreeCAD.Console.PrintMessage("displaying time = "+str(timeD) + "s\n")
(In the above code I've already changed the path from a win to a linux environment.)

A simple process of loading a big STEP file is triggering the multicore/multithreading on win.
In the previous post images, you can see that FC triggers 13 Threads and involves all 4 CPUs.

When running this code on Linux, unlikely I get only one core to 100% ...
I will post some screeenshots later on.
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: FreeCAD and multicores - multithreads

Post by ickby »

can you give some infos about the used OCC versions and whic linux system you use? Also if conda build or ppa or self build... IMHO the difference could be if OCC is build with multithread support or not, so less a platform topic and more a build settings topic.
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: FreeCAD and multicores - multithreads

Post by easyw-fc »

ickby wrote: Mon Jul 01, 2019 7:33 am can you give some infos about the used OCC versions and whic linux system you use? Also if conda build or ppa or self build... IMHO the difference could be if OCC is build with multithread support or not, so less a platform topic and more a build settings topic.
here my details for windows (download from GH)
it is a Conda build (FreeCAD_0.19.17144_x64_Conda_Py3QT5-WinVS2015.7z)
but I have the same multicore-multithread performance with a standard build
like i.e. FreeCAD_0.19.17144_x64_LP_12.1.2_PY3QT5-WinVS2015.7z
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17144 (Git)
Build type: Release
Branch: master
Hash: ece1b7ecbaa36d22403d6850d8498882d820db3c
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
I agree that it could/should be a build settings topic... but as far as I know everyone at the forum said FC is not multi-thread/multicore on Linux.
Anyway my Linux is Mint 19.1 64b and I have tested the undesired performance with the PPA build and with Conda Appimage py3qt5.

Later on I will post my FC full details and some screenshots...

It would be very nice if someone could test and compare my results using the file and the script in the post above.
I really would like to see these multi-threading multicore performance on Linux also.
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: FreeCAD and multicores - multithreads

Post by easyw-fc »

Ok,
here my FC on Linux version info:
PPA daily release
OS: Linux Mint 19.1 (MATE/mate)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Python version: 3.6.8
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)

FreeCAD_0.19-17147-Linux-Conda_Py3Qt5_glibc2.12-x86_64.AppImage
OS: Linux Mint 19.1 (MATE/mate)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17147 (Git) AppImage
Build type: Release
Branch: master
Hash: 251a3b1ff5517d929b4993d8836e17e01ae2623c
Python version: 3.7.3
Qt version: 5.9.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)

Both are installed/downloaded from the official repositories.
-
cpus.png
cpus.png (95.72 KiB) Viewed 5599 times
wmayer
Founder
Posts: 20302
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCAD and multicores - multithreads

Post by wmayer »

but as far as I know everyone at the forum said FC is not multi-thread/multicore on Linux
The source code is the same for both platforms. So, if there is any difference then only because 3rd party libraries (mainly OCC) are built with different settings.
AFAIR for OCC there are two options available: OpenMP (done by the compiler) or tbb
Could you check your OCC versions on Windows and Linux if they depend on tbb?
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: FreeCAD and multicores - multithreads

Post by easyw-fc »

wmayer wrote: Tue Jul 02, 2019 7:33 am
but as far as I know everyone at the forum said FC is not multi-thread/multicore on Linux
The source code is the same for both platforms. So, if there is any difference then only because 3rd party libraries (mainly OCC) are built with different settings.
AFAIR for OCC there are two options available: OpenMP (done by the compiler) or tbb
Could you check your OCC versions on Windows and Linux if they depend on tbb?
In which way can I check it?
Is there i.e. a python command to get this info inside FC or a shell/bash command to check it?

I'm involving also the users that do the great packaging...
sgrogan wrote: ping
looo wrote: ping
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: FreeCAD and multicores - multithreads

Post by looo »

User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: FreeCAD and multicores - multithreads

Post by easyw-fc »

May be this post would be also relevant
https://forum.freecadweb.org/viewtopic. ... 32#p152519
sgrogan wrote: Mon Jan 09, 2017 10:13 pm
vejmarie wrote:Currently just TBB standalone. I am trying to move out OCCT the stuff I made inside into FreeCAD code. I think it shall be doable ;)
Thanks for the info. As wmayer has said then should be simple.
As of now:
OSX has OCCT 7.0 linked against TBB. No action necessary.
Win, I'm in the process of upgrading to OCCT 7.1 linked against TBB. If you need TBB sooner we can simply add just the TBB libs to the libpack.
Ubuntu, we are still working on the OCCT 7.0 Debian package (we will need to add this to the PPA). Stand alone TBB is a standard package so we can add this sooner.
If this is imminent, let me know and I will add TBB to Ubuntu Travis, Win AppVeyor, and the Ubuntu PPA.
wmayer
Founder
Posts: 20302
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCAD and multicores - multithreads

Post by wmayer »

easyw-fc wrote: Tue Jul 02, 2019 8:14 am In which way can I check it?
Is there i.e. a python command to get this info inside FC or a shell/bash command to check it?

I'm involving also the users that do the great packaging...
On Windows you can use the tool Dependency Walker. If you e.g. then load the file TKGeomBase.dll you will see that it depends on tbb.dll. If you can't see this dependency then OCC was built without tbb support.

Under Linux you open a terminal window and enter:

Code: Select all

ldd libGeomBase.so
Depending on your system the path to OCC libs might be /usr/lib, /usr/lib64, ...
Post Reply